Re: suggested addition to 'date'

From: Julian Elischer <julian_at_elischer.org>
Date: Fri, 11 Aug 2006 21:31:14 -0700
Giorgos Keramidas wrote:

>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? 
>
 ha!

> To read one
>character at-a-time and only special-case the '\n' characters?
>  
>
I didn't see that being mentionned anywhere, but I guess compared to 
running date once for every line
I could live with a strlen().  :-)
it'd probably be more efficient than doing it one char at a time.

>Maybe something like this?
>
>	if (sflag) {
>
>  
>
[...]

>				otval = tval;
>			}
>			(void)printf("%s", buf);
>			if (fflush(stdout))
>  
>

wonder if it would want to be flushed less often if stdout was a file..
I think stdio would do the right thing in most cases so I guess teh 
fflush woudl only be needed at the end, after the last file,
or maybe just on a signal handler so it flushes out the last buffer on ^C

>				err(1, "stdout");
>		}
>	} ...
>			
>_______________________________________________
>freebsd-current_at_freebsd.org mailing list
>http://lists.freebsd.org/mailman/listinfo/freebsd-current
>To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
>  
>
Received on Sat Aug 12 2006 - 02:31:15 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:58 UTC