[Toybox] [CLEANUP] uudecode commit 835

Rob Landley rob at landley.net
Sat Jan 11 12:18:27 PST 2014


http://landley.net/hg/toybox/rev/835

Two changes to the NEWTOY() line: only allow at most 1 leftover 
non-option argument instead of 2 (because POSIX says so), and use 
TOYFLAG_UMASK to tell the setup code in main.c to set the umask to 0 
before calling uudecode's main function. (That way we don't have to do it.)

This means the test for toys.optc == 1 near the start of uudecode_main() 
can just test for nonzero instead of specifically for 1. (Saves a ~4 
byte constant. You'd think they'd have 1 byte constants for small 
commonly used numbers, but oddly it doesn't seem to come up much in 
assembly dumps.)

The old "mode = 744" in the declaration went away because we actually 
parse the permission string in the input now. So the old mode was an 
int, the new one is a string.

The old code had a special purpose loop to skip blank lines at the 
beginning, followed by a bunch of strncmp() and loops to parse the rest.

The new code puts all that inside a single loop using two sscanf() calls 
to parse each of the two kinds of lines it's looking for in one go 
(including the mode field the previous one ignored). The new loop skips 
any line that isn't one of the begin lines it's looking for (blank or 
not), so a uudecode blob appended to a message should decode ok. The 
error message changed from "empty file" to the slightly more accurate 
"no header" (it could have all sorts of stuff in it, just not a valid 
uudecode block).

At the end, close both the input and output filehandles in the 
TOYBOX_FREE block.

 1389471507.0


More information about the Toybox mailing list