[BusyBox] sh valid char for variable
Larry Doolittle
ldoolitt at recycle.lbl.gov
Sat Mar 10 23:59:00 UTC 2001
Vladimir -
> I see good work with sh.c
Thanks!
> strpbrk(dst+1, " \t~`!$^&*()=|\\[];\"'<>?./"); is VERY strange.
:-)
> See patch to sh.c base from real sh parser.
First question: what "real sh parser"?
I'd love to get a look at the original Bell Labs code.
+ local_pending_command = xstrdup(cmd);
Of course.
- const char *out_of_space = "out of space during expansion";
+ static const char out_of_space[] = "out of space during expansion";
That's a clear improvement, too.
+ 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. 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().
- 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.
- Larry
More information about the busybox
mailing list