[GRASS-dev] Re: g.rename consolidation

Glynn Clements glynn at gclements.plus.com
Mon Feb 26 02:11:57 EST 2007


Hamish wrote:

> > OK, it would be also useful to have G_message_no_nl() which does not
> > print new-line character at the of the message. I am not sure how to
> > derive these functions from the existing G_message() fn.
> 
> Easy, don't bother with another new libgis fn. The no newline situation*
> is better handled by fprintf(stdout, ) + fflush(stdout). AFAIK
> fprintf(stderr, ..) will only print complete \n terminated lines, and so
> you can only output:
> 
> [*]  "Working: " [code+time] " done.\n"
> 
> using stdout.

Other way around. stderr is always unbuffered, while stdout is
line-buffered if it refers to a tty and fully-buffered otherwise.

In practice, this just means that you don't need to use fflush() with
stderr.

> And stdout works fine, so why reimpliment all of glibc as
> G_() fns? Better to just G_() fns when there are portability issues or
> it helps to clean the code a lot, eg G_debug().
> 
> If fprintf(stdout,..) is the most appropriate thing to use, then don't
> be afraid to use it.

If you're writing incomplete lines, then you're probably writing
progress information, which should always use stderr.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list