setterm.diff not final, lots of changes in the near future

////// alastors at gmail.com
Fri Sep 16 00:29:50 UTC 2005


                        ,,,,
                       (o o)
************oOO**(_)**OOo***************


Hi, as promessed setterm.diff

patch -p1 < *.diff works fine for me.

ok I saw man 4 console_codes, there is a way to save the current configuration
to be the default so
 printf ( "\033[0m" )ñ

doesn't make it back to grey on black, but to the saved settings, so
the enviromental var BB_SETTERM it is not going to be necessary, and
there's no need to patch neither ls nor ash ( cmdline.c in fact ). and
since there is one escape sequence that sets the leds I'll add the
functionality of setleds to setterm too, two for one jeje.

now one opinion :

the function wich_one ( now called wich_option ) is
still a nessesity, I need it to parse the args, humm...
lets see how other applets handle argumnets with
options.

hmm... most just do atoi(optarg).

most of the rest just use it as is, they don't
need anything.

others use bb_xgetlarg, what is that? lets see in
xgetlarg.c, no documentation.

mkdir uses bb_parse_mode, what is that?  lets see in
parse_mode.c, no documentation, I gonna risk it's for
file permisions or something like that.

ok it seemes nobody needs wich_option for now...
wait a minute!!!

coreutils/date.c :

bb_getopt_ulflags( /* some stuff*/ , &isofmt_arg );

// other stuff, and around line 175 :

int ifmt_len = bb_strlen(isofmt_arg);

 if ((ifmt_len <= 4)  &&
    (strncmp(isofmt_arg, "date", ifmt_len) == 0))
	ifmt = 1;
 else if ((ifmt_len <= 5) &&
   (strncmp(isofmt_arg, "hours", ifmt_len) == 0))
	ifmt = 2;
 else if ((ifmt_len <= 7) &&
   (strncmp(isofmt_arg, "minutes", ifmt_len) == 0))
	ifmt = 3;
 else if ((ifmt_len <= 7) &&
   (strncmp(isofmt_arg, "seconds", ifmt_len) == 0))
	ifmt = 4;

if (!ifmt)
	bb_show_usage();


ok is a little more efficient like this,
but lets see it my way now:

bb_getopt_ulflags( /* some stuff*/ , &isofmt_arg );

// other stuff not changed

ifmt = 1 + wich_option( isofmt_arg,
                   "date hours minutes seconds ");

if ( ifmt > 4 )
	show_usage();


smaller isn't it ?

but parsing a big string doesn't conforms me.
maybe I can use a linked list like with long arguments in
bb_getopts_ulflags ( those --some --other ...) maybe the
same code can be used in both
situations modifying a little bb_getopts_ulflags.

but both date.c and setterm needs the result to be a
number not a char so...

               .oooO    Oooo.
*************(     )****(     )****************
                 \   (       )   /
                  \_ )     ( _/

No corrijas al necio no sea cosa que te odie, corrije al sabio y te lo
agradecera.
Al que a buen árbol se arrima buena sombra lo cobija.
Lo mejor que podemos hacer por otro no es sólo compartir con él
nuestras riquezas, sino mostrarle las suyas.

                                                Atentamente Alastor



More information about the busybox mailing list