1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include <libpspp/assertion.h>
30 #include <libpspp/message.h>
32 #include <libpspp/compiler.h>
33 #include "identifier.h"
34 #include <libpspp/magic.h>
35 #include <libpspp/misc.h>
37 #include <libpspp/str.h>
41 #define _(msgid) gettext (msgid)
43 /* Specialized error routine. */
45 static void dls_error (const struct data_in *, const char *format, ...)
49 vdls_error (const struct data_in *i, const char *format, va_list args)
53 char format_string[FMT_STRING_LEN_MAX + 1];
55 if (i->flags & DI_IGNORE_ERROR)
58 ds_init_empty (&text);
60 ds_put_format (&text, _("(column %d"), i->f1);
62 ds_put_format (&text, _("(columns %d-%d"), i->f1, i->f2);
63 ds_put_format (&text, _(", field type %s) "),
64 fmt_to_string (&i->format, format_string));
65 ds_put_vformat (&text, format, args);
67 m.category = MSG_DATA;
68 m.severity = MSG_ERROR;
69 m.text = ds_cstr (&text);
75 dls_error (const struct data_in *i, const char *format, ...)
79 va_start (args, format);
80 vdls_error (i, format, args);
84 /* Parsing utility functions. */
86 /* Excludes leading and trailing whitespace from I by adjusting
89 trim_whitespace (struct data_in *i)
91 while (i->s < i->e && isspace ((unsigned char) i->s[0]))
94 while (i->s < i->e && isspace ((unsigned char) i->e[-1]))
98 /* Returns true if we're not at the end of the string being
101 have_char (struct data_in *i)
106 /* If implied decimal places are enabled, apply them to
109 apply_implied_decimals (struct data_in *i)
111 if ((i->flags & DI_IMPLIED_DECIMALS) && i->format.d > 0)
112 i->v->f /= pow (10., i->format.d);
115 /* Format parsers. */
117 static bool parse_int (struct data_in *i, long *result);
119 /* This function is based on strtod() from the GNU C library. */
121 parse_numeric (struct data_in *i)
123 int sign; /* +1 or -1. */
124 double num; /* The number so far. */
126 bool got_dot; /* Found a decimal point. */
127 size_t digit_cnt; /* Count of digits. */
129 int decimal; /* Decimal point character. */
130 int grouping; /* Grouping character. */
132 long int exponent; /* Number's exponent. */
133 int type; /* Usually same as i->format.type. */
137 type = i->format.type;
138 if (type == FMT_DOLLAR && have_char (i) && *i->s == '$')
147 sign = *i->s == '-' ? -1 : 1;
148 if (*i->s == '-' || *i->s == '+')
154 decimal = fmt_decimal_char (type);
155 grouping = fmt_grouping_char (type);
162 for (; have_char (i); i->s++)
164 if (isdigit ((unsigned char) *i->s))
168 /* Make sure that multiplication by 10 will not overflow. */
169 if (num > DBL_MAX * 0.1)
170 /* The value of the digit doesn't matter, since we have already
171 gotten as many digits as can be represented in a `double'.
172 This doesn't necessarily mean the result will overflow.
173 The exponent may reduce it to within range.
175 We just need to record that there was another
176 digit so that we can multiply by 10 later. */
179 num = (num * 10.0) + (*i->s - '0');
181 /* Keep track of the number of digits after the decimal point.
182 If we just divided by 10 here, we would lose precision. */
186 else if (!got_dot && *i->s == decimal)
187 /* Record that we have found the decimal point. */
189 else if ((type != FMT_COMMA && type != FMT_DOT) || *i->s != grouping)
190 /* Any other character terminates the number. */
201 dls_error (i, _("Field does not form a valid floating-point constant."));
206 if (have_char (i) && strchr ("eEdD-+", *i->s))
208 /* Get the exponent specified after the `e' or `E'. */
211 if (isalpha ((unsigned char) *i->s))
213 if (!parse_int (i, &exp))
221 else if (!got_dot && (i->flags & DI_IMPLIED_DECIMALS))
222 exponent -= i->format.d;
224 if (type == FMT_PCT && have_char (i) && *i->s == '%')
228 dls_error (i, _("Field contents followed by garbage."));
239 /* Multiply NUM by 10 to the EXPONENT power, checking for overflow
243 if (-exponent + digit_cnt > -(DBL_MIN_10_EXP) + 5
244 || num < DBL_MIN * pow (10.0, (double) -exponent))
246 dls_error (i, _("Underflow in floating-point constant."));
251 num *= pow (10.0, (double) exponent);
253 else if (exponent > 0)
255 if (num > DBL_MAX * pow (10.0, (double) -exponent))
257 dls_error (i, _("Overflow in floating-point constant."));
262 num *= pow (10.0, (double) exponent);
265 i->v->f = sign > 0 ? num : -num;
269 /* Returns the integer value of hex digit C. */
273 const char s[] = "0123456789abcdef";
274 const char *cp = strchr (s, tolower ((unsigned char) c));
281 parse_N (struct data_in *i)
286 for (cp = i->s; cp < i->e; cp++)
288 if (!isdigit ((unsigned char) *cp))
290 dls_error (i, _("All characters in field must be digits."));
294 i->v->f = i->v->f * 10.0 + (*cp - '0');
297 apply_implied_decimals (i);
302 parse_PIBHEX (struct data_in *i)
310 for (cp = i->s; cp < i->e; cp++)
312 if (!isxdigit ((unsigned char) *cp))
314 dls_error (i, _("Unrecognized character in field."));
318 n = n * 16.0 + hexit_value (*cp);
326 parse_RBHEX (struct data_in *i)
328 /* Validate input. */
330 if ((i->e - i->s) % 2)
332 dls_error (i, _("Field must have even length."));
339 for (cp = i->s; cp < i->e; cp++)
340 if (!isxdigit ((unsigned char) *cp))
342 dls_error (i, _("Field must contain only hex digits."));
352 unsigned char c[sizeof (double)];
358 memset (u.c, 0, sizeof u.c);
359 for (j = 0; j < min ((i->e - i->s) / 2, sizeof u.d); j++)
360 u.c[j] = 16 * hexit_value (i->s[j * 2]) + hexit_value (i->s[j * 2 + 1]);
369 parse_Z (struct data_in *i)
372 bool got_dot = false;
374 /* Warn user that we suck. */
381 _("Quality of zoned decimal (Z) input format code is "
382 "suspect. Check your results three times. Report bugs "
383 "to %s."),PACKAGE_BUGREPORT);
388 /* Validate input. */
393 dls_error (i, _("Zoned decimal field contains fewer than 2 "
398 /* Copy sign into buf[0]. */
399 if ((i->e[-1] & 0xc0) != 0xc0)
401 dls_error (i, _("Bad sign byte in zoned decimal number."));
404 buf[0] = (i->e[-1] ^ (i->e[-1] >> 1)) & 0x10 ? '-' : '+';
406 /* Copy digits into buf[1 ... len - 1] and terminate string. */
411 for (sp = i->s, dp = buf + 1; sp < i->e - 1; sp++, dp++)
417 else if ((*sp & 0xf0) == 0xf0 && (*sp & 0xf) < 10)
418 *dp = (*sp & 0xf) + '0';
421 dls_error (i, _("Format error in zoned decimal number."));
428 /* Parse as number. */
432 i->v->f = strtod (buf, &tail);
435 dls_error (i, _("Error in syntax of zoned decimal number."));
441 apply_implied_decimals (i);
447 parse_IB (struct data_in *i)
449 #ifndef WORDS_BIGENDIAN
452 const unsigned char *p;
456 /* We want the data to be in big-endian format. If this is a
457 little-endian machine, reverse the byte order. */
458 #ifdef WORDS_BIGENDIAN
459 p = (const unsigned char *) i->s;
461 memcpy (buf, i->s, i->e - i->s);
462 buf_reverse (buf, i->e - i->s);
463 p = (const unsigned char *) buf;
466 /* If the value is negative, we need to logical-NOT each value
477 for (j = 0; j < i->e - i->s; j++)
478 i->v->f = i->v->f * 256.0 + (p[j] ^ xor);
481 /* If the value is negative, add 1 and set the sign, to complete a
482 two's-complement negation. */
484 i->v->f = -(i->v->f + 1.0);
486 apply_implied_decimals (i);
492 parse_PIB (struct data_in *i)
498 for (j = 0; j < i->e - i->s; j++)
499 i->v->f = i->v->f * 256.0 + (unsigned char) i->s[j];
501 for (j = i->e - i->s - 1; j >= 0; j--)
502 i->v->f = i->v->f * 256.0 + (unsigned char) i->s[j];
505 apply_implied_decimals (i);
511 parse_P (struct data_in *i)
516 for (cp = i->s; cp < i->e - 1; cp++)
518 i->v->f = i->v->f * 10 + ((*cp >> 4) & 15);
519 i->v->f = i->v->f * 10 + (*cp & 15);
521 i->v->f = i->v->f * 10 + ((*cp >> 4) & 15);
522 if ((*cp ^ (*cp >> 1)) & 0x10)
525 apply_implied_decimals (i);
531 parse_PK (struct data_in *i)
536 for (cp = i->s; cp < i->e; cp++)
538 i->v->f = i->v->f * 10 + ((*cp >> 4) & 15);
539 i->v->f = i->v->f * 10 + (*cp & 15);
542 apply_implied_decimals (i);
548 parse_RB (struct data_in *i)
553 unsigned char c[sizeof (double)];
557 memset (u.c, 0, sizeof u.c);
558 memcpy (u.c, i->s, min (sizeof u.c, (size_t) (i->e - i->s)));
566 parse_A (struct data_in *i)
568 buf_copy_rpad (i->v->s, i->format.w, i->s, i->e - i->s);
574 parse_AHEX (struct data_in *i)
576 /* Validate input. */
578 if ((i->e - i->s) % 2)
580 dls_error (i, _("Field must have even length."));
587 for (cp = i->s; cp < i->e; cp++)
588 if (!isxdigit ((unsigned char) *cp))
590 dls_error (i, _("Field must contain only hex digits."));
599 for (j = 0; j < min (i->e - i->s, i->format.w); j += 2)
600 i->v->s[j / 2] = hexit_value (i->s[j]) * 16 + hexit_value (i->s[j + 1]);
601 memset (i->v->s + (i->e - i->s) / 2, ' ', (i->format.w - (i->e - i->s)) / 2);
607 /* Date & time format components. */
609 /* Advances *CP past any whitespace characters. */
611 skip_whitespace (struct data_in *i)
613 while (isspace ((unsigned char) *i->s))
618 parse_leader (struct data_in *i)
625 force_have_char (struct data_in *i)
630 dls_error (i, _("Unexpected end of field."));
635 parse_int (struct data_in *i, long *result)
637 bool negative = false;
639 if (!force_have_char (i))
647 else if (*i->s == '-')
654 if (!isdigit ((unsigned char) *i->s))
656 dls_error (i, _("Digit expected in field."));
663 *result = *result * 10 + (*i->s++ - '0');
664 if (!have_char (i) || !isdigit ((unsigned char) *i->s))
674 parse_day (struct data_in *i, long *day)
676 if (!parse_int (i, day))
678 if (*day >= 1 && *day <= 31)
681 dls_error (i, _("Day (%ld) must be between 1 and 31."), *day);
686 parse_day_count (struct data_in *i, long *day_count)
688 return parse_int (i, day_count);
692 parse_date_delimiter (struct data_in *i)
697 && (*i->s == '-' || *i->s == '/' || isspace ((unsigned char) *i->s)
698 || *i->s == '.' || *i->s == ','))
706 dls_error (i, _("Delimiter expected between fields in date."));
710 /* Association between a name and a value. */
713 const char *name; /* Name. */
714 bool can_abbreviate; /* True if name may be abbreviated. */
715 int value; /* Value associated with name. */
718 /* Reads a name from I and sets *OUTPUT to the value associated
719 with that name. Returns true if successful, false otherwise. */
721 parse_enum (struct data_in *i, const char *what,
722 const struct enum_name *enum_names,
727 const struct enum_name *ep;
729 /* Consume alphabetic characters. */
732 while (have_char (i) && isalpha ((unsigned char) *i->s))
739 dls_error (i, _("Parse error at `%c' expecting %s."), *i->s, what);
743 for (ep = enum_names; ep->name != NULL; ep++)
744 if ((ep->can_abbreviate
745 && lex_id_match_len (ep->name, strlen (ep->name), name, length))
746 || (!ep->can_abbreviate && length == strlen (ep->name)
747 && !buf_compare_case (name, ep->name, length)))
753 dls_error (i, _("Unknown %s `%.*s'."), what, (int) length, name);
758 parse_month (struct data_in *i, long *month)
760 static const struct enum_name month_names[] =
762 {"january", true, 1},
763 {"february", true, 2},
770 {"september", true, 9},
771 {"october", true, 10},
772 {"november", true, 11},
773 {"december", true, 12},
793 if (!force_have_char (i))
796 if (isdigit ((unsigned char) *i->s))
798 if (!parse_int (i, month))
800 if (*month >= 1 && *month <= 12)
803 dls_error (i, _("Month (%ld) must be between 1 and 12."), *month);
807 return parse_enum (i, _("month"), month_names, month);
811 parse_year (struct data_in *i, long *year)
813 if (!parse_int (i, year))
816 if (*year >= 0 && *year <= 199)
818 if (*year >= 1582 || *year <= 19999)
821 dls_error (i, _("Year (%ld) must be between 1582 and 19999."), *year);
826 parse_trailer (struct data_in *i)
832 dls_error (i, _("Trailing garbage \"%.*s\" following date."),
833 (int) (i->e - i->s), i->s);
838 parse_julian (struct data_in *i, long *julian)
840 if (!parse_int (i, julian))
844 int day = *julian % 1000;
846 if (day < 1 || day > 366)
848 dls_error (i, _("Julian day (%d) must be between 1 and 366."), day);
854 int year = *julian / 1000;
856 if (year >= 0 && year <= 199)
858 else if (year < 1582 || year > 19999)
860 dls_error (i, _("Year (%d) must be between 1582 and 19999."), year);
869 parse_quarter (struct data_in *i, long *quarter)
871 if (!parse_int (i, quarter))
873 if (*quarter >= 1 && *quarter <= 4)
876 dls_error (i, _("Quarter (%ld) must be between 1 and 4."), *quarter);
881 parse_q_delimiter (struct data_in *i)
884 if (!have_char (i) || tolower ((unsigned char) *i->s) != 'q')
886 dls_error (i, _("`Q' expected between quarter and year."));
895 parse_week (struct data_in *i, long *week)
897 if (!parse_int (i, week))
899 if (*week >= 1 && *week <= 53)
902 dls_error (i, _("Week (%ld) must be between 1 and 53."), *week);
907 parse_wk_delimiter (struct data_in *i)
911 || tolower ((unsigned char) i->s[0]) != 'w'
912 || tolower ((unsigned char) i->s[1]) != 'k')
914 dls_error (i, _("`WK' expected between week and year."));
923 parse_time_delimiter (struct data_in *i)
927 while (have_char (i) && (*i->s == ':' || *i->s == '.'
928 || isspace ((unsigned char) *i->s)))
937 dls_error (i, _("Delimiter expected between fields in time."));
942 parse_hour (struct data_in *i, long *hour)
944 if (!parse_int (i, hour))
949 dls_error (i, _("Hour (%ld) must be positive."), *hour);
954 parse_minute (struct data_in *i, long *minute)
956 if (!parse_int (i, minute))
958 if (*minute >= 0 && *minute <= 59)
961 dls_error (i, _("Minute (%ld) must be between 0 and 59."), *minute);
966 parse_opt_second (struct data_in *i, double *second)
974 && (*i->s == ':' || *i->s == '.' || isspace ((unsigned char) *i->s)))
980 if (!delim || !isdigit ((unsigned char) *i->s))
987 while (have_char (i) && isdigit ((unsigned char) *i->s))
989 if (have_char (i) && *i->s == '.')
991 while (have_char (i) && isdigit ((unsigned char) *i->s))
995 *second = strtod (buf, NULL);
1001 parse_hour24 (struct data_in *i, long *hour24)
1003 if (!parse_int (i, hour24))
1005 if (*hour24 >= 0 && *hour24 <= 23)
1008 dls_error (i, _("Hour (%ld) must be between 0 and 23."), *hour24);
1014 parse_weekday (struct data_in *i, long *weekday)
1016 static const struct enum_name weekday_names[] =
1018 {"sunday", true, 1},
1020 {"monday", true, 2},
1022 {"tuesday", true, 3},
1024 {"wednesday", true, 4},
1026 {"thursday", true, 5},
1028 {"friday", true, 6},
1030 {"saturday", true, 7},
1036 return parse_enum (i, _("weekday"), weekday_names, weekday);
1040 parse_spaces (struct data_in *i)
1042 skip_whitespace (i);
1047 parse_sign (struct data_in *i, int *sign)
1049 if (!force_have_char (i))
1071 /* Date & time formats. */
1074 calendar_error (void *i_, const char *format, ...)
1076 struct data_in *i = i_;
1079 va_start (args, format);
1080 vdls_error (i, format, args);
1085 ymd_to_ofs (struct data_in *i, int year, int month, int day, double *ofs)
1087 *ofs = calendar_gregorian_to_offset (year, month, day, calendar_error, i);
1088 return *ofs != SYSMIS;
1092 ymd_to_date (struct data_in *i, int year, int month, int day, double *date)
1094 if (ymd_to_ofs (i, year, month, day, date))
1096 *date *= 60. * 60. * 24.;
1104 parse_DATE (struct data_in *i)
1106 long day, month, year;
1108 return (parse_leader (i)
1109 && parse_day (i, &day)
1110 && parse_date_delimiter (i)
1111 && parse_month (i, &month)
1112 && parse_date_delimiter (i)
1113 && parse_year (i, &year)
1114 && parse_trailer (i)
1115 && ymd_to_date (i, year, month, day, &i->v->f));
1119 parse_ADATE (struct data_in *i)
1121 long month, day, year;
1123 return (parse_leader (i)
1124 && parse_month (i, &month)
1125 && parse_date_delimiter (i)
1126 && parse_day (i, &day)
1127 && parse_date_delimiter (i)
1128 && parse_year (i, &year)
1129 && parse_trailer (i)
1130 && ymd_to_date (i, year, month, day, &i->v->f));
1134 parse_EDATE (struct data_in *i)
1136 long month, day, year;
1138 return (parse_leader (i)
1139 && parse_day (i, &day)
1140 && parse_date_delimiter (i)
1141 && parse_month (i, &month)
1142 && parse_date_delimiter (i)
1143 && parse_year (i, &year)
1144 && parse_trailer (i)
1145 && ymd_to_date (i, year, month, day, &i->v->f));
1149 parse_SDATE (struct data_in *i)
1151 long month, day, year;
1153 return (parse_leader (i)
1154 && parse_year (i, &year)
1155 && parse_date_delimiter (i)
1156 && parse_month (i, &month)
1157 && parse_date_delimiter (i)
1158 && parse_day (i, &day)
1159 && parse_trailer (i)
1160 && ymd_to_date (i, year, month, day, &i->v->f));
1164 parse_JDATE (struct data_in *i)
1169 if (!parse_leader (i)
1170 || !parse_julian (i, &julian)
1171 || !parse_trailer (i)
1172 || !ymd_to_ofs (i, julian / 1000, 1, 1, &ofs))
1175 i->v->f = (ofs + julian % 1000 - 1) * 60. * 60. * 24.;
1180 parse_QYR (struct data_in *i)
1184 return (parse_leader (i)
1185 && parse_quarter (i, &quarter)
1186 && parse_q_delimiter (i)
1187 && parse_year (i, &year)
1188 && parse_trailer (i)
1189 && ymd_to_date (i, year, (quarter - 1) * 3 + 1, 1, &i->v->f));
1193 parse_MOYR (struct data_in *i)
1197 return (parse_leader (i)
1198 && parse_month (i, &month)
1199 && parse_date_delimiter (i)
1200 && parse_year (i, &year)
1201 && parse_trailer (i)
1202 && ymd_to_date (i, year, month, 1, &i->v->f));
1206 parse_WKYR (struct data_in *i)
1211 if (!parse_leader (i)
1212 || !parse_week (i, &week)
1213 || !parse_wk_delimiter (i)
1214 || !parse_year (i, &year)
1215 || !parse_trailer (i))
1220 if (!ymd_to_ofs (i, year, 1, 1, &ofs))
1225 if (ymd_to_ofs (i, 1583, 1, 1, &ofs))
1230 i->v->f = (ofs + (week - 1) * 7) * 60. * 60. * 24.;
1235 parse_TIME (struct data_in *i)
1241 if (!parse_leader (i)
1242 || !parse_sign (i, &sign)
1243 || !parse_spaces (i)
1244 || !parse_hour (i, &hour)
1245 || !parse_time_delimiter (i)
1246 || !parse_minute (i, &minute)
1247 || !parse_opt_second (i, &second))
1250 i->v->f = (hour * 60. * 60. + minute * 60. + second) * sign;
1255 parse_DTIME (struct data_in *i)
1258 long day_count, hour;
1262 if (!parse_leader (i)
1263 || !parse_sign (i, &sign)
1264 || !parse_spaces (i)
1265 || !parse_day_count (i, &day_count)
1266 || !parse_time_delimiter (i)
1267 || !parse_hour (i, &hour)
1268 || !parse_time_delimiter (i)
1269 || !parse_minute (i, &minute)
1270 || !parse_opt_second (i, &second))
1273 i->v->f = (day_count * 60. * 60. * 24.
1281 parse_DATETIME (struct data_in *i)
1283 long day, month, year;
1288 if (!parse_leader (i)
1289 || !parse_day (i, &day)
1290 || !parse_date_delimiter (i)
1291 || !parse_month (i, &month)
1292 || !parse_date_delimiter (i)
1293 || !parse_year (i, &year)
1294 || !parse_time_delimiter (i)
1295 || !parse_hour24 (i, &hour24)
1296 || !parse_time_delimiter (i)
1297 || !parse_minute (i, &minute)
1298 || !parse_opt_second (i, &second)
1299 || !ymd_to_date (i, year, month, day, &i->v->f))
1302 i->v->f += hour24 * 60. * 60. + minute * 60. + second;
1307 parse_WKDAY (struct data_in *i)
1311 if (!parse_leader (i)
1312 || !parse_weekday (i, &weekday)
1313 || !parse_trailer (i))
1321 parse_MONTH (struct data_in *i)
1325 if (!parse_leader (i)
1326 || !parse_month (i, &month)
1327 || !parse_trailer (i))
1334 /* Main dispatcher. */
1337 default_result (struct data_in *i)
1339 /* Default to SYSMIS or blanks. */
1340 if (fmt_is_string (i->format.type))
1341 memset (i->v->s, ' ', i->format.w);
1343 i->v->f = get_blanks();
1347 data_in (struct data_in *i)
1351 assert (fmt_check_input (&i->format));
1353 /* Check that we've got a string to work with. */
1354 if (i->e == i->s || i->format.w <= 0)
1360 i->f2 = i->f1 + (i->e - i->s) - 1;
1362 /* Make sure that the string isn't too long. */
1363 if (i->format.w > fmt_max_input_width (i->format.type))
1365 dls_error (i, _("Field too long (%d characters). Truncated after "
1367 i->format.w, fmt_max_input_width (i->format.type));
1368 i->format.w = fmt_max_input_width (i->format.type);
1371 if (!(fmt_get_category (i->format.type)
1372 & (FMT_CAT_STRING | FMT_CAT_BINARY | FMT_CAT_HEXADECIMAL)))
1379 if (!isspace ((unsigned char) *cp))
1384 i->v->f = get_blanks();
1391 switch (i->format.type)
1399 success = parse_numeric (i);
1408 success = parse_N (i);
1411 success = parse_Z (i);
1414 success = parse_P (i);
1417 success = parse_PK (i);
1420 success = parse_IB (i);
1423 success = parse_PIB (i);
1426 success = parse_PIBHEX (i);
1429 success = parse_RB (i);
1432 success = parse_RBHEX (i);
1435 success = parse_DATE (i);
1438 success = parse_ADATE (i);
1441 success = parse_EDATE (i);
1444 success = parse_JDATE (i);
1447 success = parse_SDATE (i);
1450 success = parse_QYR (i);
1453 success = parse_MOYR (i);
1456 success = parse_WKYR (i);
1459 success = parse_DATETIME (i);
1462 success = parse_TIME (i);
1465 success = parse_DTIME (i);
1468 success = parse_WKDAY (i);
1471 success = parse_MONTH (i);
1474 success = parse_A (i);
1477 success = parse_AHEX (i);
1488 /* Utility function. */
1490 /* Sets DI->{s,e} appropriately given that LINE has length LEN and the
1491 field starts at one-based column FC and ends at one-based column
1494 data_in_finite_line (struct data_in *di, const char *line, size_t len,
1497 di->s = line + ((size_t) fc <= len ? fc - 1 : len);
1498 di->e = line + ((size_t) lc <= len ? lc : len);