- static char limit[MAX_LINE+1]; /* ascii value of BIG */
- static int limit_len; /* digit count of limit */
- int len; /* digits in input (excluding +/-) */
- char *s; /* line start marker */
- char *d; /* first digit, skip +/- */
- char *p; /* scan pointer */
- char *z; /* zero scan pointer */
-
- /* form the ascii value of BIG if needed */
- if (!isascii(limit[0]) || !isdigit(limit[0])) {
- sprintf(limit, "%lu", BIG);
- limit_len = strlen(limit);
- }
-
- /*
- * the search for a good line
- */
- if (input != NULL && fgets(buf, MAX_LINE, input) == NULL) {
- /* error or EOF */
- return NULL;
- }
- do {
-
- /* ignore leading whitespace */
- for (s=buf; *s && s < buf+MAX_LINE; ++s) {
- if (!isascii(*s) || !isspace(*s)) {
- break;
- }
- }
-
- /* object if - */
- if (*s == '-') {
- fprintf(stderr, "%s: ouch for minuses\n", program);
- continue;
- }
-
- /* skip over any leading + */
- if (*s == '+') {
- d = s+1;
- } else {
- d = s;
- }
-
- /* note leading zeros */
- for (z=d; *z && z < buf+MAX_LINE; ++z) {
- if (*z != '0') {
- break;
- }
- }
-
- /* scan for the first non-digit/non-plus/non-minus */
- for (p=d; *p && p < buf+MAX_LINE; ++p) {
- if (!isascii(*p) || !isdigit(*p)) {
- break;
- }
- }