[BusyBox] sh valid char for variable

Vladimir N. Oleynik dzo at simtreas.ru
Sun Mar 11 09:17:51 UTC 2001


Larry,

> First question: what "real sh parser"?
> I'd love to get a look at the original Bell Labs code.

Hmm. www.sco.com? Opened now.
(What way I had it in 86 year I already wrote. ;) )
 
> +             if(isascii(*src) && (isalpha(*src) || *src == '_')) {
> +                      src++;
> +                      while(isascii(*src) && (isalpha(*src)
> +                                      || *src == '_'
> +                                      || isdigit(*src)))
> +                                            src++;
> 
> I don't understand the purpose to isascii, or why you explicitly
> call out isalpha || isdigit, instead of using isalnum. 

Yes. This only for see.

> Apart from
> those minor details, your suggested behavior is more correct, so
> I support changing it to something like this.  You see that code
> size is probably larger.  The desire for small size probably
> motivated the original usage of strpbrk().

Oh, no. 
1) For only lation-1: addition please also: "@+-".
2) isspace() not only " \t"!

Why I used here isasscii() it is very long history, 
base  on just on original codes sh. 
(There such algorithm, in quality quoting the high of bit was used).

> -                       delim_hold=*src;
> +                       delim_hold = *src;
>                         *src='\0';  /* temporary */
> -                       var = getenv(dst + num_skip_chars);
> -                       *src=delim_hold;
> -                       if (num_skip_chars==2) {
> -                               src++;
> -                       }
> +                       var = getenv(dst + num_skip_chars + 1);
> +                       *src = delim_hold + num_skip_chars;
> 
> That last line is totally bogus.  You have to restore the
> original string with "*src = delim_hold;" no matter what
> num_skip_chars is.

Oops. Yes. Thanks.


--w
vodz





More information about the busybox mailing list