suggested addition to 'date'
Giorgos Keramidas
keramida at FreeBSD.org
Sat Aug 12 04:16:05 UTC 2006
On 2006-08-11 20:54, Julian Elischer <julian at elischer.org> wrote:
> Yes I said I hacked it in :-)
> In my app you will never have such long lines..
> basically you need something that reads lines and tells you how much it
> read..
> (I have no idea WHY fgets need sto return the START.. you already KNOW
> that!)
> it'd be nice if you didn't have to to a strlen() on each line.
Perhaps the solution Sam proposed is much better then? To read one
character at-a-time and only special-case the '\n' characters?
Maybe something like this?
if (sflag) {
int ch;
time_t otval = 0;
while ((ch = getchar()) != EOF) {
putchar(ch);
if (ch != '\n')
continue;
if (rlfag == 0 && time(&tval) == -1)
err(1, "time");
if (tval != otval) {
lt = *localtime(&tval);
badv = vary_apply(v, <);
if (badv) {
fprintf(stderr,
"%s: Cannot apply date adjustment\n",
badv->arg);
vary_destroy(v);
usage();
}
(void)strftime(buf, sizeof(buf), format, <);
otval = tval;
}
(void)printf("%s", buf);
if (fflush(stdout))
err(1, "stdout");
}
} ...
More information about the freebsd-current
mailing list