diff options
Diffstat (limited to 'sh.c')
-rw-r--r-- | sh.c | 70 |
1 files changed, 35 insertions, 35 deletions
@@ -687,16 +687,16 @@ static void free_job(struct job *cmd) | |||
687 | cmd->job_list = keep; | 687 | cmd->job_list = keep; |
688 | } | 688 | } |
689 | 689 | ||
690 | /* remove a job from the job_list */ | 690 | /* remove a job from a jobset */ |
691 | static void remove_job(struct jobset *job_list, struct job *job) | 691 | static void remove_job(struct jobset *j_list, struct job *job) |
692 | { | 692 | { |
693 | struct job *prevjob; | 693 | struct job *prevjob; |
694 | 694 | ||
695 | free_job(job); | 695 | free_job(job); |
696 | if (job == job_list->head) { | 696 | if (job == j_list->head) { |
697 | job_list->head = job->next; | 697 | j_list->head = job->next; |
698 | } else { | 698 | } else { |
699 | prevjob = job_list->head; | 699 | prevjob = j_list->head; |
700 | while (prevjob->next != job) | 700 | while (prevjob->next != job) |
701 | prevjob = prevjob->next; | 701 | prevjob = prevjob->next; |
702 | prevjob->next = job->next; | 702 | prevjob->next = job->next; |
@@ -707,7 +707,7 @@ static void remove_job(struct jobset *job_list, struct job *job) | |||
707 | 707 | ||
708 | /* Checks to see if any background processes have exited -- if they | 708 | /* Checks to see if any background processes have exited -- if they |
709 | have, figure out why and see if a job has completed */ | 709 | have, figure out why and see if a job has completed */ |
710 | static void checkjobs(struct jobset *job_list) | 710 | static void checkjobs(struct jobset *j_list) |
711 | { | 711 | { |
712 | struct job *job; | 712 | struct job *job; |
713 | pid_t childpid; | 713 | pid_t childpid; |
@@ -715,7 +715,7 @@ static void checkjobs(struct jobset *job_list) | |||
715 | int prognum = 0; | 715 | int prognum = 0; |
716 | 716 | ||
717 | while ((childpid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 0) { | 717 | while ((childpid = waitpid(-1, &status, WNOHANG | WUNTRACED)) > 0) { |
718 | for (job = job_list->head; job; job = job->next) { | 718 | for (job = j_list->head; job; job = job->next) { |
719 | prognum = 0; | 719 | prognum = 0; |
720 | while (prognum < job->num_progs && | 720 | while (prognum < job->num_progs && |
721 | job->progs[prognum].pid != childpid) prognum++; | 721 | job->progs[prognum].pid != childpid) prognum++; |
@@ -734,7 +734,7 @@ static void checkjobs(struct jobset *job_list) | |||
734 | 734 | ||
735 | if (!job->running_progs) { | 735 | if (!job->running_progs) { |
736 | printf(JOB_STATUS_FORMAT, job->jobid, "Done", job->text); | 736 | printf(JOB_STATUS_FORMAT, job->jobid, "Done", job->text); |
737 | remove_job(job_list, job); | 737 | remove_job(j_list, job); |
738 | } | 738 | } |
739 | } else { | 739 | } else { |
740 | /* child stopped */ | 740 | /* child stopped */ |
@@ -907,35 +907,35 @@ static char* itoa(register int i) | |||
907 | #endif | 907 | #endif |
908 | 908 | ||
909 | #if defined BB_FEATURE_SH_ENVIRONMENT && ! defined BB_FEATURE_SH_WORDEXP | 909 | #if defined BB_FEATURE_SH_ENVIRONMENT && ! defined BB_FEATURE_SH_WORDEXP |
910 | char * strsep_space( char *string, int * index) | 910 | char * strsep_space( char *string, int * ix) |
911 | { | 911 | { |
912 | char *token, *begin; | 912 | char *token, *begin; |
913 | 913 | ||
914 | begin = string; | 914 | begin = string; |
915 | 915 | ||
916 | /* Short circuit the trivial case */ | 916 | /* Short circuit the trivial case */ |
917 | if ( !string || ! string[*index]) | 917 | if ( !string || ! string[*ix]) |
918 | return NULL; | 918 | return NULL; |
919 | 919 | ||
920 | /* Find the end of the token. */ | 920 | /* Find the end of the token. */ |
921 | while( string && string[*index] && !isspace(string[*index]) ) { | 921 | while( string && string[*ix] && !isspace(string[*ix]) ) { |
922 | (*index)++; | 922 | (*ix)++; |
923 | } | 923 | } |
924 | 924 | ||
925 | /* Find the end of any whitespace trailing behind | 925 | /* Find the end of any whitespace trailing behind |
926 | * the token and let that be part of the token */ | 926 | * the token and let that be part of the token */ |
927 | while( string && string[*index] && isspace(string[*index]) ) { | 927 | while( string && string[*ix] && isspace(string[*ix]) ) { |
928 | (*index)++; | 928 | (*ix)++; |
929 | } | 929 | } |
930 | 930 | ||
931 | if (! string && *index==0) { | 931 | if (! string && *ix==0) { |
932 | /* Nothing useful was found */ | 932 | /* Nothing useful was found */ |
933 | return NULL; | 933 | return NULL; |
934 | } | 934 | } |
935 | 935 | ||
936 | token = xmalloc(*index+1); | 936 | token = xmalloc(*ix+1); |
937 | token[*index] = '\0'; | 937 | token[*ix] = '\0'; |
938 | strncpy(token, string, *index); | 938 | strncpy(token, string, *ix); |
939 | 939 | ||
940 | return token; | 940 | return token; |
941 | } | 941 | } |
@@ -947,7 +947,7 @@ static int expand_arguments(char *command) | |||
947 | #ifdef BB_FEATURE_SH_ENVIRONMENT | 947 | #ifdef BB_FEATURE_SH_ENVIRONMENT |
948 | expand_t expand_result; | 948 | expand_t expand_result; |
949 | char *src, *dst, *var; | 949 | char *src, *dst, *var; |
950 | int index = 0; | 950 | int ix = 0; |
951 | int i=0, length, total_length=0, retval; | 951 | int i=0, length, total_length=0, retval; |
952 | const char *out_of_space = "out of space during expansion"; | 952 | const char *out_of_space = "out of space during expansion"; |
953 | #endif | 953 | #endif |
@@ -956,13 +956,13 @@ static int expand_arguments(char *command) | |||
956 | chomp(command); | 956 | chomp(command); |
957 | 957 | ||
958 | /* Fix up escape sequences to be the Real Thing(tm) */ | 958 | /* Fix up escape sequences to be the Real Thing(tm) */ |
959 | while( command && command[index]) { | 959 | while( command && command[ix]) { |
960 | if (command[index] == '\\') { | 960 | if (command[ix] == '\\') { |
961 | char *tmp = command+index+1; | 961 | char *tmp = command+ix+1; |
962 | command[index] = process_escape_sequence( &tmp ); | 962 | command[ix] = process_escape_sequence( &tmp ); |
963 | memmove(command+index + 1, tmp, strlen(tmp)+1); | 963 | memmove(command+ix + 1, tmp, strlen(tmp)+1); |
964 | } | 964 | } |
965 | index++; | 965 | ix++; |
966 | } | 966 | } |
967 | 967 | ||
968 | #ifdef BB_FEATURE_SH_ENVIRONMENT | 968 | #ifdef BB_FEATURE_SH_ENVIRONMENT |
@@ -1025,8 +1025,8 @@ static int expand_arguments(char *command) | |||
1025 | * we write stuff into the original (in a minute) */ | 1025 | * we write stuff into the original (in a minute) */ |
1026 | cmd = cmd_copy = strdup(command); | 1026 | cmd = cmd_copy = strdup(command); |
1027 | *command = '\0'; | 1027 | *command = '\0'; |
1028 | for (index = 0, tmpcmd = cmd; | 1028 | for (ix = 0, tmpcmd = cmd; |
1029 | (tmpcmd = strsep_space(cmd, &index)) != NULL; cmd += index, index=0) { | 1029 | (tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) { |
1030 | if (*tmpcmd == '\0') | 1030 | if (*tmpcmd == '\0') |
1031 | break; | 1031 | break; |
1032 | retval = glob(tmpcmd, flags, NULL, &expand_result); | 1032 | retval = glob(tmpcmd, flags, NULL, &expand_result); |
@@ -1096,11 +1096,11 @@ static int expand_arguments(char *command) | |||
1096 | case '0':case '1':case '2':case '3':case '4': | 1096 | case '0':case '1':case '2':case '3':case '4': |
1097 | case '5':case '6':case '7':case '8':case '9': | 1097 | case '5':case '6':case '7':case '8':case '9': |
1098 | { | 1098 | { |
1099 | int index=*(dst + 1)-48; | 1099 | int ixx=*(dst + 1)-48; |
1100 | if (index >= argc) { | 1100 | if (ixx >= argc) { |
1101 | var='\0'; | 1101 | var='\0'; |
1102 | } else { | 1102 | } else { |
1103 | var = argv[index]; | 1103 | var = argv[ixx]; |
1104 | } | 1104 | } |
1105 | } | 1105 | } |
1106 | break; | 1106 | break; |
@@ -1575,19 +1575,19 @@ static int pseudo_exec(struct child_prog *child) | |||
1575 | static void insert_job(struct job *newjob, int inbg) | 1575 | static void insert_job(struct job *newjob, int inbg) |
1576 | { | 1576 | { |
1577 | struct job *thejob; | 1577 | struct job *thejob; |
1578 | struct jobset *job_list=newjob->job_list; | 1578 | struct jobset *j_list=newjob->job_list; |
1579 | 1579 | ||
1580 | /* find the ID for thejob to use */ | 1580 | /* find the ID for thejob to use */ |
1581 | newjob->jobid = 1; | 1581 | newjob->jobid = 1; |
1582 | for (thejob = job_list->head; thejob; thejob = thejob->next) | 1582 | for (thejob = j_list->head; thejob; thejob = thejob->next) |
1583 | if (thejob->jobid >= newjob->jobid) | 1583 | if (thejob->jobid >= newjob->jobid) |
1584 | newjob->jobid = thejob->jobid + 1; | 1584 | newjob->jobid = thejob->jobid + 1; |
1585 | 1585 | ||
1586 | /* add thejob to the list of running jobs */ | 1586 | /* add thejob to the list of running jobs */ |
1587 | if (!job_list->head) { | 1587 | if (!j_list->head) { |
1588 | thejob = job_list->head = xmalloc(sizeof(*thejob)); | 1588 | thejob = j_list->head = xmalloc(sizeof(*thejob)); |
1589 | } else { | 1589 | } else { |
1590 | for (thejob = job_list->head; thejob->next; thejob = thejob->next) /* nothing */; | 1590 | for (thejob = j_list->head; thejob->next; thejob = thejob->next) /* nothing */; |
1591 | thejob->next = xmalloc(sizeof(*thejob)); | 1591 | thejob->next = xmalloc(sizeof(*thejob)); |
1592 | thejob = thejob->next; | 1592 | thejob = thejob->next; |
1593 | } | 1593 | } |