fdate.c - bug report and correction
Robert Elz
kre at munnari.OZ
Sun Sep 30 15:41:22 AEST 1984
echo x - "BUG" 2>&1
sed "s/^X//" >"BUG" <<'!The!End!'
X
X Andrew Sharpe (drivax!sharpe) pointed out a bug in the
X fdate program that I posted a week or so ago. Its amazing
X how bugs infest programs the day that they're posted.
X (Well, not really, this one has been there hibernating
X for ever).
X
X This is a sh archive, unpack it & you'll get 3 files,
X BUG (this file), fdate.c.ed, and fdate.c.diffs. Fdate.c.ed
X is an ed script (diff -e output) that you can run
X as
X ed - fdate.c <fdate.c.ed
X if you haven't changed fdate.c from its distribution form.
X
X Fdate.c.diffs is diff -c output, for those who like to
X look, and those who have changed it.
X
X For those few of you who care, the problem this fixes relates
X to using the converter-indicator character ('%') without
X a following conversion character (or with an illegal
X conversion character).
X
X Robert Elz decvax!mulga!kre
!The!End!
echo x - "fdate.c.diffs" 2>&1
sed "s/^X//" >"fdate.c.diffs" <<'!The!End!'
X*** fdate.c.distrib Fri Sep 21 07:37:27 1984
X--- fdate.c Wed Sep 26 18:45:49 1984
X***************
X*** 187,192
X case 'M': incr.tm_min = i; break;
X case 'S': incr.tm_sec = i; break;
X
X default: hadincr--; break;
X }
X }
X
X--- 187,193 -----
X case 'M': incr.tm_min = i; break;
X case 'S': incr.tm_sec = i; break;
X
X+ case '\0': aptr--; /* fall through */
X default: hadincr--; break;
X }
X }
X***************
X*** 297,303
X continue;
X }
X }
X! switch (*aptr++) {
X case '%':
X putchar('%');
X continue;
X
X--- 298,304 -----
X continue;
X }
X }
X! switch (c = *aptr++) {
X case '%':
X putchar('%');
X continue;
X***************
X*** 445,451
X putchar(c);
X break;
X }
X! fprintf(stderr, "fdate: bad format character - %c\n", *--aptr);
X exit(2);
X
X } /* endsw */
X
X--- 446,456 -----
X putchar(c);
X break;
X }
X! if (c == '\0' || c == ' ')
X! fprintf(stderr, "fdate: missing format character in \"%s\"\n", *argv);
X! else
X! fprintf(stderr, "fdate: bad format character - %c\n", c);
X! close(1); /* trash stdout! */
X exit(2);
X
X } /* endsw */
!The!End!
echo x - "fdate.c.ed" 2>&1
sed "s/^X//" >"fdate.c.ed" <<'!The!End!'
X448c
X if (c == '\0' || c == ' ')
X fprintf(stderr, "fdate: missing format character in \"%s\"\n", *argv);
X else
X fprintf(stderr, "fdate: bad format character - %c\n", c);
X close(1); /* trash stdout! */
X.
X300c
X switch (c = *aptr++) {
X.
X189a
X case '\0': aptr--; /* fall through */
X.
Xw
Xq
!The!End!
exit
More information about the Comp.sources.unix
mailing list