1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 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
41 #define _(msgid) gettext (msgid)
43 #include "debug-print.h"
45 /* Specialized error routine. */
47 static void dls_error (const struct data_in *, const char *format, ...)
51 vdls_error (const struct data_in *i, const char *format, va_list args)
56 if (i->flags & DI_IGNORE_ERROR)
60 if (!getl_reading_script)
61 ds_puts (&title, _("data-file error: "));
63 ds_printf (&title, _("(column %d"), i->f1);
65 ds_printf (&title, _("(columns %d-%d"), i->f1, i->f2);
66 ds_printf (&title, _(", field type %s) "), fmt_to_string (&i->format));
69 err_location (&e.where);
70 e.title = ds_c_str (&title);
72 err_vmsg (&e, format, args);
78 dls_error (const struct data_in *i, const char *format, ...)
82 va_start (args, format);
83 vdls_error (i, format, args);
87 /* Parsing utility functions. */
89 /* Excludes leading and trailing whitespace from I by adjusting
92 trim_whitespace (struct data_in *i)
94 while (i->s < i->e && isspace ((unsigned char) i->s[0]))
97 while (i->s < i->e && isspace ((unsigned char) i->e[-1]))
101 /* Returns nonzero if we're not at the end of the string being
104 have_char (struct data_in *i)
109 /* If implied decimal places are enabled, apply them to
112 apply_implied_decimals (struct data_in *i)
114 if ((i->flags & DI_IMPLIED_DECIMALS) && i->format.d > 0)
115 i->v->f /= pow (10., i->format.d);
118 /* Format parsers. */
120 static bool parse_int (struct data_in *i, long *result);
122 /* This function is based on strtod() from the GNU C library. */
124 parse_numeric (struct data_in *i)
126 int sign; /* +1 or -1. */
127 double num; /* The number so far. */
129 bool got_dot; /* Found a decimal point. */
130 size_t digit_cnt; /* Count of digits. */
132 int decimal; /* Decimal point character. */
133 int grouping; /* Grouping character. */
135 long int exponent; /* Number's exponent. */
136 int type; /* Usually same as i->format.type. */
140 type = i->format.type;
141 if (type == FMT_DOLLAR && have_char (i) && *i->s == '$')
150 sign = *i->s == '-' ? -1 : 1;
151 if (*i->s == '-' || *i->s == '+')
159 decimal = get_decimal();
160 grouping = get_grouping();
164 decimal = get_grouping();
165 grouping = get_decimal();
173 for (; have_char (i); i->s++)
175 if (isdigit ((unsigned char) *i->s))
179 /* Make sure that multiplication by 10 will not overflow. */
180 if (num > DBL_MAX * 0.1)
181 /* The value of the digit doesn't matter, since we have already
182 gotten as many digits as can be represented in a `double'.
183 This doesn't necessarily mean the result will overflow.
184 The exponent may reduce it to within range.
186 We just need to record that there was another
187 digit so that we can multiply by 10 later. */
190 num = (num * 10.0) + (*i->s - '0');
192 /* Keep track of the number of digits after the decimal point.
193 If we just divided by 10 here, we would lose precision. */
197 else if (!got_dot && *i->s == decimal)
198 /* Record that we have found the decimal point. */
200 else if ((type != FMT_COMMA && type != FMT_DOT) || *i->s != grouping)
201 /* Any other character terminates the number. */
212 dls_error (i, _("Field does not form a valid floating-point constant."));
217 if (have_char (i) && strchr ("eEdD-+", *i->s))
219 /* Get the exponent specified after the `e' or `E'. */
222 if (isalpha ((unsigned char) *i->s))
224 if (!parse_int (i, &exp))
232 else if (!got_dot && (i->flags & DI_IMPLIED_DECIMALS))
233 exponent -= i->format.d;
235 if (type == FMT_PCT && have_char (i) && *i->s == '%')
239 dls_error (i, _("Field contents followed by garbage."));
250 /* Multiply NUM by 10 to the EXPONENT power, checking for overflow
254 if (-exponent + digit_cnt > -(DBL_MIN_10_EXP) + 5
255 || num < DBL_MIN * pow (10.0, (double) -exponent))
257 dls_error (i, _("Underflow in floating-point constant."));
262 num *= pow (10.0, (double) exponent);
264 else if (exponent > 0)
266 if (num > DBL_MAX * pow (10.0, (double) -exponent))
268 dls_error (i, _("Overflow in floating-point constant."));
273 num *= pow (10.0, (double) exponent);
276 i->v->f = sign > 0 ? num : -num;
280 /* Returns the integer value of hex digit C. */
284 const char s[] = "0123456789abcdef";
285 const char *cp = strchr (s, tolower ((unsigned char) c));
292 parse_N (struct data_in *i)
297 for (cp = i->s; cp < i->e; cp++)
299 if (!isdigit ((unsigned char) *cp))
301 dls_error (i, _("All characters in field must be digits."));
305 i->v->f = i->v->f * 10.0 + (*cp - '0');
308 apply_implied_decimals (i);
313 parse_PIBHEX (struct data_in *i)
321 for (cp = i->s; cp < i->e; cp++)
323 if (!isxdigit ((unsigned char) *cp))
325 dls_error (i, _("Unrecognized character in field."));
329 n = n * 16.0 + hexit_value (*cp);
337 parse_RBHEX (struct data_in *i)
339 /* Validate input. */
341 if ((i->e - i->s) % 2)
343 dls_error (i, _("Field must have even length."));
350 for (cp = i->s; cp < i->e; cp++)
351 if (!isxdigit ((unsigned char) *cp))
353 dls_error (i, _("Field must contain only hex digits."));
363 unsigned char c[sizeof (double)];
369 memset (u.c, 0, sizeof u.c);
370 for (j = 0; j < min ((i->e - i->s) / 2, sizeof u.d); j++)
371 u.c[j] = 16 * hexit_value (i->s[j * 2]) + hexit_value (i->s[j * 2 + 1]);
380 parse_Z (struct data_in *i)
383 bool got_dot = false;
385 /* Warn user that we suck. */
392 _("Quality of zoned decimal (Z) input format code is "
393 "suspect. Check your results three times. Report bugs "
394 "to %s."),PACKAGE_BUGREPORT);
399 /* Validate input. */
404 dls_error (i, _("Zoned decimal field contains fewer than 2 "
409 /* Copy sign into buf[0]. */
410 if ((i->e[-1] & 0xc0) != 0xc0)
412 dls_error (i, _("Bad sign byte in zoned decimal number."));
415 buf[0] = (i->e[-1] ^ (i->e[-1] >> 1)) & 0x10 ? '-' : '+';
417 /* Copy digits into buf[1 ... len - 1] and terminate string. */
422 for (sp = i->s, dp = buf + 1; sp < i->e - 1; sp++, dp++)
428 else if ((*sp & 0xf0) == 0xf0 && (*sp & 0xf) < 10)
429 *dp = (*sp & 0xf) + '0';
432 dls_error (i, _("Format error in zoned decimal number."));
439 /* Parse as number. */
443 i->v->f = strtod (buf, &tail);
446 dls_error (i, _("Error in syntax of zoned decimal number."));
452 apply_implied_decimals (i);
458 parse_IB (struct data_in *i)
460 #ifndef WORDS_BIGENDIAN
463 const unsigned char *p;
467 /* We want the data to be in big-endian format. If this is a
468 little-endian machine, reverse the byte order. */
469 #ifdef WORDS_BIGENDIAN
470 p = (const unsigned char *) i->s;
472 memcpy (buf, i->s, i->e - i->s);
473 buf_reverse (buf, i->e - i->s);
474 p = (const unsigned char *) buf;
477 /* If the value is negative, we need to logical-NOT each value
488 for (j = 0; j < i->e - i->s; j++)
489 i->v->f = i->v->f * 256.0 + (p[j] ^ xor);
492 /* If the value is negative, add 1 and set the sign, to complete a
493 two's-complement negation. */
495 i->v->f = -(i->v->f + 1.0);
497 apply_implied_decimals (i);
503 parse_PIB (struct data_in *i)
509 for (j = 0; j < i->e - i->s; j++)
510 i->v->f = i->v->f * 256.0 + (unsigned char) i->s[j];
512 for (j = i->e - i->s - 1; j >= 0; j--)
513 i->v->f = i->v->f * 256.0 + (unsigned char) i->s[j];
516 apply_implied_decimals (i);
522 parse_P (struct data_in *i)
527 for (cp = i->s; cp < i->e - 1; cp++)
529 i->v->f = i->v->f * 10 + ((*cp >> 4) & 15);
530 i->v->f = i->v->f * 10 + (*cp & 15);
532 i->v->f = i->v->f * 10 + ((*cp >> 4) & 15);
533 if ((*cp ^ (*cp >> 1)) & 0x10)
536 apply_implied_decimals (i);
542 parse_PK (struct data_in *i)
547 for (cp = i->s; cp < i->e; cp++)
549 i->v->f = i->v->f * 10 + ((*cp >> 4) & 15);
550 i->v->f = i->v->f * 10 + (*cp & 15);
553 apply_implied_decimals (i);
559 parse_RB (struct data_in *i)
564 unsigned char c[sizeof (double)];
568 memset (u.c, 0, sizeof u.c);
569 memcpy (u.c, i->s, min (sizeof u.c, (size_t) (i->e - i->s)));
576 parse_A (struct data_in *i)
578 buf_copy_rpad (i->v->s, i->format.w, i->s, i->e - i->s);
583 parse_AHEX (struct data_in *i)
585 /* Validate input. */
587 if ((i->e - i->s) % 2)
589 dls_error (i, _("Field must have even length."));
596 for (cp = i->s; cp < i->e; cp++)
597 if (!isxdigit ((unsigned char) *cp))
599 dls_error (i, _("Field must contain only hex digits."));
608 for (j = 0; j < min (i->e - i->s, i->format.w); j += 2)
609 i->v->s[j / 2] = hexit_value (i->s[j]) * 16 + hexit_value (i->s[j + 1]);
610 memset (i->v->s + (i->e - i->s) / 2, ' ', (i->format.w - (i->e - i->s)) / 2);
616 /* Date & time format components. */
618 /* Advances *CP past any whitespace characters. */
620 skip_whitespace (struct data_in *i)
622 while (isspace ((unsigned char) *i->s))
627 parse_leader (struct data_in *i)
634 force_have_char (struct data_in *i)
639 dls_error (i, _("Unexpected end of field."));
644 parse_int (struct data_in *i, long *result)
646 bool negative = false;
648 if (!force_have_char (i))
656 else if (*i->s == '-')
663 if (!isdigit ((unsigned char) *i->s))
665 dls_error (i, _("Digit expected in field."));
672 *result = *result * 10 + (*i->s++ - '0');
673 if (!have_char (i) || !isdigit ((unsigned char) *i->s))
683 parse_day (struct data_in *i, long *day)
685 if (!parse_int (i, day))
687 if (*day >= 1 && *day <= 31)
690 dls_error (i, _("Day (%ld) must be between 1 and 31."), *day);
695 parse_day_count (struct data_in *i, long *day_count)
697 return parse_int (i, day_count);
701 parse_date_delimiter (struct data_in *i)
706 && (*i->s == '-' || *i->s == '/' || isspace ((unsigned char) *i->s)
707 || *i->s == '.' || *i->s == ','))
715 dls_error (i, _("Delimiter expected between fields in date."));
719 /* Association between a name and a value. */
722 const char *name; /* Name. */
723 bool can_abbreviate; /* True if name may be abbreviated. */
724 int value; /* Value associated with name. */
727 /* Reads a name from I and sets *OUTPUT to the value associated
728 with that name. Returns true if successful, false otherwise. */
730 parse_enum (struct data_in *i, const char *what,
731 const struct enum_name *enum_names,
736 const struct enum_name *ep;
738 /* Consume alphabetic characters. */
741 while (have_char (i) && isalpha ((unsigned char) *i->s))
748 dls_error (i, _("Parse error at `%c' expecting %s."), *i->s, what);
752 for (ep = enum_names; ep->name != NULL; ep++)
753 if ((ep->can_abbreviate
754 && lex_id_match_len (ep->name, strlen (ep->name), name, length))
755 || (!ep->can_abbreviate && length == strlen (ep->name)
756 && !buf_compare_case (name, ep->name, length)))
762 dls_error (i, _("Unknown %s `%.*s'."), what, (int) length, name);
767 parse_month (struct data_in *i, long *month)
769 static const struct enum_name month_names[] =
771 {"january", true, 1},
772 {"february", true, 2},
779 {"september", true, 9},
780 {"october", true, 10},
781 {"november", true, 11},
782 {"december", true, 12},
802 if (!force_have_char (i))
805 if (isdigit ((unsigned char) *i->s))
807 if (!parse_int (i, month))
809 if (*month >= 1 && *month <= 12)
812 dls_error (i, _("Month (%ld) must be between 1 and 12."), *month);
816 return parse_enum (i, _("month"), month_names, month);
820 parse_year (struct data_in *i, long *year)
822 if (!parse_int (i, year))
825 if (*year >= 0 && *year <= 199)
827 if (*year >= 1582 || *year <= 19999)
830 dls_error (i, _("Year (%ld) must be between 1582 and 19999."), *year);
835 parse_trailer (struct data_in *i)
841 dls_error (i, _("Trailing garbage \"%s\" following date."), i->s);
846 parse_julian (struct data_in *i, long *julian)
848 if (!parse_int (i, julian))
852 int day = *julian % 1000;
854 if (day < 1 || day > 366)
856 dls_error (i, _("Julian day (%d) must be between 1 and 366."), day);
862 int year = *julian / 1000;
864 if (year >= 0 && year <= 199)
866 else if (year < 1582 || year > 19999)
868 dls_error (i, _("Year (%d) must be between 1582 and 19999."), year);
877 parse_quarter (struct data_in *i, long *quarter)
879 if (!parse_int (i, quarter))
881 if (*quarter >= 1 && *quarter <= 4)
884 dls_error (i, _("Quarter (%ld) must be between 1 and 4."), *quarter);
889 parse_q_delimiter (struct data_in *i)
892 if (!have_char (i) || tolower ((unsigned char) *i->s) != 'q')
894 dls_error (i, _("`Q' expected between quarter and year."));
903 parse_week (struct data_in *i, long *week)
905 if (!parse_int (i, week))
907 if (*week >= 1 && *week <= 53)
910 dls_error (i, _("Week (%ld) must be between 1 and 53."), *week);
915 parse_wk_delimiter (struct data_in *i)
919 || tolower ((unsigned char) i->s[0]) != 'w'
920 || tolower ((unsigned char) i->s[1]) != 'k')
922 dls_error (i, _("`WK' expected between week and year."));
931 parse_time_delimiter (struct data_in *i)
935 while (have_char (i) && (*i->s == ':' || *i->s == '.'
936 || isspace ((unsigned char) *i->s)))
945 dls_error (i, _("Delimiter expected between fields in time."));
950 parse_hour (struct data_in *i, long *hour)
952 if (!parse_int (i, hour))
957 dls_error (i, _("Hour (%ld) must be positive."), *hour);
962 parse_minute (struct data_in *i, long *minute)
964 if (!parse_int (i, minute))
966 if (*minute >= 0 && *minute <= 59)
969 dls_error (i, _("Minute (%ld) must be between 0 and 59."), *minute);
974 parse_opt_second (struct data_in *i, double *second)
982 && (*i->s == ':' || *i->s == '.' || isspace ((unsigned char) *i->s)))
988 if (!delim || !isdigit ((unsigned char) *i->s))
995 while (have_char (i) && isdigit ((unsigned char) *i->s))
997 if (have_char (i) && *i->s == '.')
999 while (have_char (i) && isdigit ((unsigned char) *i->s))
1003 *second = strtod (buf, NULL);
1009 parse_hour24 (struct data_in *i, long *hour24)
1011 if (!parse_int (i, hour24))
1013 if (*hour24 >= 0 && *hour24 <= 23)
1016 dls_error (i, _("Hour (%ld) must be between 0 and 23."), *hour24);
1022 parse_weekday (struct data_in *i, long *weekday)
1024 static const struct enum_name weekday_names[] =
1026 {"sunday", true, 1},
1028 {"monday", true, 2},
1030 {"tuesday", true, 3},
1032 {"wednesday", true, 4},
1034 {"thursday", true, 5},
1036 {"friday", true, 6},
1038 {"saturday", true, 7},
1044 return parse_enum (i, _("weekday"), weekday_names, weekday);
1048 parse_spaces (struct data_in *i)
1050 skip_whitespace (i);
1055 parse_sign (struct data_in *i, int *sign)
1057 if (!force_have_char (i))
1079 /* Date & time formats. */
1082 calendar_error (void *i_, const char *format, ...)
1084 struct data_in *i = i_;
1087 va_start (args, format);
1088 vdls_error (i, format, args);
1093 ymd_to_ofs (struct data_in *i, int year, int month, int day, double *ofs)
1095 *ofs = calendar_gregorian_to_offset (year, month, day, calendar_error, i);
1096 return *ofs != SYSMIS;
1100 ymd_to_date (struct data_in *i, int year, int month, int day, double *date)
1102 if (ymd_to_ofs (i, year, month, day, date))
1104 *date *= 60. * 60. * 24.;
1112 parse_DATE (struct data_in *i)
1114 long day, month, year;
1116 return (parse_leader (i)
1117 && parse_day (i, &day)
1118 && parse_date_delimiter (i)
1119 && parse_month (i, &month)
1120 && parse_date_delimiter (i)
1121 && parse_year (i, &year)
1122 && parse_trailer (i)
1123 && ymd_to_date (i, year, month, day, &i->v->f));
1127 parse_ADATE (struct data_in *i)
1129 long month, day, year;
1131 return (parse_leader (i)
1132 && parse_month (i, &month)
1133 && parse_date_delimiter (i)
1134 && parse_day (i, &day)
1135 && parse_date_delimiter (i)
1136 && parse_year (i, &year)
1137 && parse_trailer (i)
1138 && ymd_to_date (i, year, month, day, &i->v->f));
1142 parse_EDATE (struct data_in *i)
1144 long month, day, year;
1146 return (parse_leader (i)
1147 && parse_day (i, &day)
1148 && parse_date_delimiter (i)
1149 && parse_month (i, &month)
1150 && parse_date_delimiter (i)
1151 && parse_year (i, &year)
1152 && parse_trailer (i)
1153 && ymd_to_date (i, year, month, day, &i->v->f));
1157 parse_SDATE (struct data_in *i)
1159 long month, day, year;
1161 return (parse_leader (i)
1162 && parse_year (i, &year)
1163 && parse_date_delimiter (i)
1164 && parse_month (i, &month)
1165 && parse_date_delimiter (i)
1166 && parse_day (i, &day)
1167 && parse_trailer (i)
1168 && ymd_to_date (i, year, month, day, &i->v->f));
1172 parse_JDATE (struct data_in *i)
1177 if (!parse_leader (i)
1178 || !parse_julian (i, &julian)
1179 || !parse_trailer (i)
1180 || !ymd_to_ofs (i, julian / 1000, 1, 1, &ofs))
1183 i->v->f = (ofs + julian % 1000 - 1) * 60. * 60. * 24.;
1188 parse_QYR (struct data_in *i)
1192 return (parse_leader (i)
1193 && parse_quarter (i, &quarter)
1194 && parse_q_delimiter (i)
1195 && parse_year (i, &year)
1196 && parse_trailer (i)
1197 && ymd_to_date (i, year, (quarter - 1) * 3 + 1, 1, &i->v->f));
1201 parse_MOYR (struct data_in *i)
1205 return (parse_leader (i)
1206 && parse_month (i, &month)
1207 && parse_date_delimiter (i)
1208 && parse_year (i, &year)
1209 && parse_trailer (i)
1210 && ymd_to_date (i, year, month, 1, &i->v->f));
1214 parse_WKYR (struct data_in *i)
1219 if (!parse_leader (i)
1220 || !parse_week (i, &week)
1221 || !parse_wk_delimiter (i)
1222 || !parse_year (i, &year)
1223 || !parse_trailer (i))
1228 if (!ymd_to_ofs (i, year, 1, 1, &ofs))
1233 if (ymd_to_ofs (i, 1583, 1, 1, &ofs))
1238 i->v->f = (ofs + (week - 1) * 7) * 60. * 60. * 24.;
1243 parse_TIME (struct data_in *i)
1249 if (!parse_leader (i)
1250 || !parse_sign (i, &sign)
1251 || !parse_spaces (i)
1252 || !parse_hour (i, &hour)
1253 || !parse_time_delimiter (i)
1254 || !parse_minute (i, &minute)
1255 || !parse_opt_second (i, &second))
1258 i->v->f = (hour * 60. * 60. + minute * 60. + second) * sign;
1263 parse_DTIME (struct data_in *i)
1266 long day_count, hour;
1270 if (!parse_leader (i)
1271 || !parse_sign (i, &sign)
1272 || !parse_spaces (i)
1273 || !parse_day_count (i, &day_count)
1274 || !parse_time_delimiter (i)
1275 || !parse_hour (i, &hour)
1276 || !parse_time_delimiter (i)
1277 || !parse_minute (i, &minute)
1278 || !parse_opt_second (i, &second))
1281 i->v->f = (day_count * 60. * 60. * 24.
1289 parse_DATETIME (struct data_in *i)
1291 long day, month, year;
1296 if (!parse_leader (i)
1297 || !parse_day (i, &day)
1298 || !parse_date_delimiter (i)
1299 || !parse_month (i, &month)
1300 || !parse_date_delimiter (i)
1301 || !parse_year (i, &year)
1302 || !parse_time_delimiter (i)
1303 || !parse_hour24 (i, &hour24)
1304 || !parse_time_delimiter (i)
1305 || !parse_minute (i, &minute)
1306 || !parse_opt_second (i, &second)
1307 || !ymd_to_date (i, year, month, day, &i->v->f))
1310 i->v->f += hour24 * 60. * 60. + minute * 60. + second;
1315 parse_WKDAY (struct data_in *i)
1319 if (!parse_leader (i)
1320 || !parse_weekday (i, &weekday)
1321 || !parse_trailer (i))
1329 parse_MONTH (struct data_in *i)
1333 if (!parse_leader (i)
1334 || !parse_month (i, &month)
1335 || !parse_trailer (i))
1342 /* Main dispatcher. */
1345 default_result (struct data_in *i)
1347 const struct fmt_desc *const fmt = &formats[i->format.type];
1349 /* Default to SYSMIS or blanks. */
1350 if (fmt->cat & FCAT_STRING)
1351 memset (i->v->s, ' ', i->format.w);
1353 i->v->f = get_blanks();
1357 data_in (struct data_in *i)
1359 const struct fmt_desc *const fmt = &formats[i->format.type];
1361 assert (check_input_specifier (&i->format, 0));
1363 /* Check that we've got a string to work with. */
1364 if (i->e == i->s || i->format.w <= 0)
1370 i->f2 = i->f1 + (i->e - i->s) - 1;
1372 /* Make sure that the string isn't too long. */
1373 if (i->format.w > fmt->Imax_w)
1375 dls_error (i, _("Field too long (%d characters). Truncated after "
1377 i->format.w, fmt->Imax_w);
1378 i->format.w = fmt->Imax_w;
1381 if (fmt->cat & FCAT_BLANKS_SYSMIS)
1388 if (!isspace ((unsigned char) *cp))
1393 i->v->f = get_blanks();
1400 static bool (*const handlers[FMT_NUMBER_OF_FORMATS])(struct data_in *) =
1402 parse_numeric, parse_N, parse_numeric, parse_numeric,
1403 parse_numeric, parse_numeric, parse_numeric,
1404 parse_Z, parse_A, parse_AHEX, parse_IB, parse_P, parse_PIB,
1405 parse_PIBHEX, parse_PK, parse_RB, parse_RBHEX,
1406 NULL, NULL, NULL, NULL, NULL,
1407 parse_DATE, parse_EDATE, parse_SDATE, parse_ADATE, parse_JDATE,
1408 parse_QYR, parse_MOYR, parse_WKYR,
1409 parse_DATETIME, parse_TIME, parse_DTIME,
1410 parse_WKDAY, parse_MONTH,
1413 bool (*handler)(struct data_in *);
1416 handler = handlers[i->format.type];
1417 assert (handler != NULL);
1419 success = handler (i);
1427 /* Utility function. */
1429 /* Sets DI->{s,e} appropriately given that LINE has length LEN and the
1430 field starts at one-based column FC and ends at one-based column
1433 data_in_finite_line (struct data_in *di, const char *line, size_t len,
1436 di->s = line + ((size_t) fc <= len ? fc - 1 : len);
1437 di->e = line + ((size_t) lc <= len ? lc : len);