is there a naming convention for libbb files/routines?

Rob Landley rob at landley.net
Mon Mar 27 13:11:54 PST 2006


On Monday 27 March 2006 11:35 am, Robert P. J. Day wrote:
>   (while i'm being annoyingly pedantic, might as well just get it out
> of my system.)
>
>   is there some sort of naming convention for both files and functions
> in libbb, since what's there seems confusingly inconsistent.

I think it varies by who wrote them.

>   in some cases, a source file has exactly the same (generic) name as
> its function, such as chomp() being defined in the source file
> "chomp.c".  fair enough.
>
>   in some cases, the function name will *not* exactly match the source
> file name -- witness the source file "mtab.c" which defines only the
> function erase_mtab().  so why not "erase_mtab.c"?  no big deal,
> though.  onward.

I believe that one used to define more, but I trimmed it.  Didn't rename it 
because my attempts to do so count as a delete and a create, and thus blank 
the svn history for the file.  Dunno why.

>   in many cases, function or file names have a "bb_" prefix, such as
> "bb_askpass()" being defined in "bb_askpass.c".  why the sudden need
> for a "bb_" prefix in some places but not others?

I didn't do it. :)

An attempt to avoid namespace pollution, I suppose.  On the part of one of the 
committers.

>   slightly different are cases where the routine has the prefix but
> the source file *doesn't* -- "bb_xgetlarg()" is defined in the source
> file "xgetlarg.c".  any reason for the difference here?

Not really.

>   in yet another case, the difference is subtle -- the source file
> "bb_asprint.f" defines the routine "bb_xasprintf()".  huh?

That's sneaky.

>   and, finally, there is the variety of things that start with "x".
> what's *that* all about?  especially given that some of those source
> files will define routines with a "bb_" prefix and some not.

This we have a convention for.  The things that start with x are "exit or do 
blah", so you never have to test for errors when you call one.  It either 
succeeds or exits the program with an error message.

>   i realize all of this sounds nitpicky but, given that one of the
> best ways to understand the workings of BB is to RTFS, it would make
> life easier if TFS was a little more self-explanatory.
>
>   thoughts?

Actually, the best way to learn TFS is to document TFS.  We could use a 
libbb.html somewhere...

> rday

Rob
-- 
Never bet against the cheap plastic solution.


More information about the busybox mailing list