diff options
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/shell/ash.c b/shell/ash.c index c77ee8620..9bb8fd805 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -10286,44 +10286,56 @@ find_builtin(const char *name) | |||
10286 | static const char * FAST_FUNC | 10286 | static const char * FAST_FUNC |
10287 | ash_command_name(struct exe_state *e) | 10287 | ash_command_name(struct exe_state *e) |
10288 | { | 10288 | { |
10289 | if (e->e_type == 0) { | 10289 | int index; |
10290 | if (/*e->e_index >= 0 &&*/ e->e_index < ARRAY_SIZE(builtintab)) { | 10290 | struct tblentry *cmdp; |
10291 | # if ENABLE_ASH_ALIAS | ||
10292 | struct alias *ap; | ||
10293 | # endif | ||
10294 | |||
10295 | index = e->e_index; | ||
10296 | switch (e->e_type) { | ||
10297 | case 0: | ||
10298 | if (index < ARRAY_SIZE(builtintab)) | ||
10291 | return builtintab[e->e_index++].name + 1; | 10299 | return builtintab[e->e_index++].name + 1; |
10292 | } | ||
10293 | e->e_type++; | 10300 | e->e_type++; |
10294 | e->e_index = 0; | 10301 | index = 0; |
10295 | e->e_ptr = cmdtable[0]; | 10302 | /* e->e_ptr = NULL; */ |
10296 | } | 10303 | /* fall through */ |
10297 | if (e->e_type == 1) { | 10304 | case 1: |
10298 | struct tblentry *cmdp = (struct tblentry *)e->e_ptr; | 10305 | cmdp = (struct tblentry *)e->e_ptr; |
10299 | while (e->e_index < CMDTABLESIZE) { | 10306 | for (;;) { |
10300 | while (cmdp) { | 10307 | while (cmdp) { |
10301 | if (cmdp->cmdtype == CMDFUNCTION) { | 10308 | if (cmdp->cmdtype == CMDFUNCTION) { |
10309 | e->e_index = index; | ||
10302 | e->e_ptr = cmdp->next; | 10310 | e->e_ptr = cmdp->next; |
10303 | return cmdp->cmdname; | 10311 | return cmdp->cmdname; |
10304 | } | 10312 | } |
10305 | cmdp = cmdp->next; | 10313 | cmdp = cmdp->next; |
10306 | } | 10314 | } |
10307 | cmdp = cmdtable[++e->e_index]; | 10315 | if (++index == CMDTABLESIZE) |
10316 | break; | ||
10317 | cmdp = cmdtable[index]; | ||
10308 | } | 10318 | } |
10309 | # if ENABLE_ASH_ALIAS | 10319 | # if ENABLE_ASH_ALIAS |
10310 | e->e_type++; | 10320 | e->e_type++; |
10311 | e->e_index = 0; | 10321 | index = 0; |
10312 | e->e_ptr = atab[0]; | 10322 | e->e_ptr = NULL; |
10313 | # endif | 10323 | /* fall through */ |
10314 | } | 10324 | case 2: |
10315 | # if ENABLE_ASH_ALIAS | 10325 | ap = (struct alias *)e->e_ptr; |
10316 | if (e->e_type == 2) { | 10326 | for (;;) { |
10317 | struct alias *ap = (struct alias *)e->e_ptr; | 10327 | if (ap) { |
10318 | while (e->e_index < ATABSIZE) { | 10328 | e->e_index = index; |
10319 | while (ap) { | ||
10320 | e->e_ptr = ap->next; | 10329 | e->e_ptr = ap->next; |
10321 | return ap->name; | 10330 | return ap->name; |
10322 | } | 10331 | } |
10323 | ap = atab[++e->e_index]; | 10332 | if (++index == ATABSIZE) |
10333 | break; | ||
10334 | ap = atab[index]; | ||
10324 | } | 10335 | } |
10325 | } | ||
10326 | # endif | 10336 | # endif |
10337 | break; | ||
10338 | } | ||
10327 | return NULL; | 10339 | return NULL; |
10328 | } | 10340 | } |
10329 | #endif | 10341 | #endif |