xfuncs, bb_ funcs and "nofork/noexec" plans

Tito farmatito at tiscali.it
Mon Mar 13 12:08:51 PST 2006


On Monday 13 March 2006 17:45, Rob Landley wrote:
> On Monday 13 March 2006 2:24 am, Denis Vlasenko wrote:
> > On Friday 10 March 2006 22:01, Rob Landley wrote:
 
> At some point, we may face the spectre of translating our error messages.  
> Dunno.  Some of the earliest code uses libbb/messages.c, although that's 
> fallen out of use.  I'm holding off on worrying about the whole issue for 
> right now...

Hi,
if we split the error message it will be a nightmare to translate it.........
Maybe something like this would make it easier:

void xfputs(const char *line, FILE *stream, const char *filename)
{
       if (fputs(line, stream) == EOF) {
                bb_perror_msg_and_die(filename);
      }
}


So the error message would depend on the errno and
probably the libc would translate it for us like:

program: filename: write error

BTW: obviously one could pass also some string rather than the filename
           but the function declaration is there to give the advice not to do so.

Just my 2 cents.

Tito

> > We cannot save here on error message.
> >
> >         xfputs(line, dest_stream);
> >
> > can give "Write error" at most.
> > No "Error writing to new file" or "Error writing to '%s'", filename.
> >
> >         fputs_or_die(line, dest_stream, "new file");
> >
> > won't save that much, but it will save something AND will provide
> > meaningful error message.
> >
> > Why call it fputs_or_die instead of xfputs, then? I think that almost
> > all currently existing xfuncs have exactly the same parameters as
> > corresponding C lib funcs:
> >
> > 	void* malloc(size_t sz);
> > 	void* xmalloc(size_t sz /* no extra params! */ );
> >
> > And I like this. Thus:
> >
> >         xfputs(line, dest_stream, "new file");	/* breaks that rule */
> >         fputs_or_die(line, dest_stream, "new file"); /* I think this is
> > better */
> Rob


More information about the busybox mailing list