diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-30 22:44:07 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-30 22:44:07 +0000 |
| commit | 71d8abf30cee76141fbb86f5e80f97de284041a6 (patch) | |
| tree | cc805016f5c28c2eb1bb61cb2607a0739fb45077 /shell | |
| parent | bb81c5831aa81a9e0ef793681e21ea2352bc6f57 (diff) | |
| download | busybox-w32-71d8abf30cee76141fbb86f5e80f97de284041a6.tar.gz busybox-w32-71d8abf30cee76141fbb86f5e80f97de284041a6.tar.bz2 busybox-w32-71d8abf30cee76141fbb86f5e80f97de284041a6.zip | |
lash: -Wwrite-strings fixes
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/lash.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/shell/lash.c b/shell/lash.c index 90bd16885..51ad3cc06 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
| @@ -90,8 +90,8 @@ struct job { | |||
| 90 | }; | 90 | }; |
| 91 | 91 | ||
| 92 | struct built_in_command { | 92 | struct built_in_command { |
| 93 | char *cmd; /* name */ | 93 | const char *cmd; /* name */ |
| 94 | char *descr; /* description */ | 94 | const char *descr; /* description */ |
| 95 | int (*function) (struct child_prog *); /* function ptr */ | 95 | int (*function) (struct child_prog *); /* function ptr */ |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| @@ -122,7 +122,7 @@ static int busy_loop(FILE * input); | |||
| 122 | /* Table of built-in functions (these are non-forking builtins, meaning they | 122 | /* Table of built-in functions (these are non-forking builtins, meaning they |
| 123 | * can change global variables in the parent shell process but they will not | 123 | * can change global variables in the parent shell process but they will not |
| 124 | * work with pipes and redirects; 'unset foo | whatever' will not work) */ | 124 | * work with pipes and redirects; 'unset foo | whatever' will not work) */ |
| 125 | static struct built_in_command bltins[] = { | 125 | static const struct built_in_command bltins[] = { |
| 126 | {"bg", "Resume a job in the background", builtin_fg_bg}, | 126 | {"bg", "Resume a job in the background", builtin_fg_bg}, |
| 127 | {"cd", "Change working directory", builtin_cd}, | 127 | {"cd", "Change working directory", builtin_cd}, |
| 128 | {"exec", "Exec command, replacing this shell with the exec'd process", builtin_exec}, | 128 | {"exec", "Exec command, replacing this shell with the exec'd process", builtin_exec}, |
| @@ -160,8 +160,8 @@ static int last_return_code; | |||
| 160 | static int last_bg_pid; | 160 | static int last_bg_pid; |
| 161 | static unsigned int last_jobid; | 161 | static unsigned int last_jobid; |
| 162 | static int shell_terminal; | 162 | static int shell_terminal; |
| 163 | static char *PS1; | 163 | static const char *PS1; |
| 164 | static char *PS2 = "> "; | 164 | static const char *PS2 = "> "; |
| 165 | 165 | ||
| 166 | 166 | ||
| 167 | #ifdef DEBUG_SHELL | 167 | #ifdef DEBUG_SHELL |
| @@ -303,17 +303,17 @@ static int builtin_fg_bg(struct child_prog *child) | |||
| 303 | /* built-in 'help' handler */ | 303 | /* built-in 'help' handler */ |
| 304 | static int builtin_help(struct child_prog ATTRIBUTE_UNUSED *dummy) | 304 | static int builtin_help(struct child_prog ATTRIBUTE_UNUSED *dummy) |
| 305 | { | 305 | { |
| 306 | struct built_in_command *x; | 306 | const struct built_in_command *x; |
| 307 | 307 | ||
| 308 | printf("\nBuilt-in commands:\n" | 308 | printf("\nBuilt-in commands:\n" |
| 309 | "-------------------\n"); | 309 | "-------------------\n"); |
| 310 | for (x = bltins; x->cmd; x++) { | 310 | for (x = bltins; x->cmd; x++) { |
| 311 | if (x->descr==NULL) | 311 | if (x->descr == NULL) |
| 312 | continue; | 312 | continue; |
| 313 | printf("%s\t%s\n", x->cmd, x->descr); | 313 | printf("%s\t%s\n", x->cmd, x->descr); |
| 314 | } | 314 | } |
| 315 | for (x = bltins_forking; x->cmd; x++) { | 315 | for (x = bltins_forking; x->cmd; x++) { |
| 316 | if (x->descr==NULL) | 316 | if (x->descr == NULL) |
| 317 | continue; | 317 | continue; |
| 318 | printf("%s\t%s\n", x->cmd, x->descr); | 318 | printf("%s\t%s\n", x->cmd, x->descr); |
| 319 | } | 319 | } |
| @@ -325,7 +325,7 @@ static int builtin_help(struct child_prog ATTRIBUTE_UNUSED *dummy) | |||
| 325 | static int builtin_jobs(struct child_prog *child) | 325 | static int builtin_jobs(struct child_prog *child) |
| 326 | { | 326 | { |
| 327 | struct job *job; | 327 | struct job *job; |
| 328 | char *status_string; | 328 | const char *status_string; |
| 329 | 329 | ||
| 330 | for (job = child->family->job_list->head; job; job = job->next) { | 330 | for (job = child->family->job_list->head; job; job = job->next) { |
| 331 | if (job->running_progs == job->stopped_progs) | 331 | if (job->running_progs == job->stopped_progs) |
| @@ -622,20 +622,22 @@ static inline void cmdedit_set_initial_prompt(void) | |||
| 622 | #endif | 622 | #endif |
| 623 | } | 623 | } |
| 624 | 624 | ||
| 625 | static inline void setup_prompt_string(char **prompt_str) | 625 | static inline const char* setup_prompt_string(void) |
| 626 | { | 626 | { |
| 627 | #if !ENABLE_FEATURE_EDITING_FANCY_PROMPT | 627 | #if !ENABLE_FEATURE_EDITING_FANCY_PROMPT |
| 628 | /* Set up the prompt */ | 628 | /* Set up the prompt */ |
| 629 | if (shell_context == 0) { | 629 | if (shell_context == 0) { |
| 630 | free(PS1); | 630 | char *ns; |
| 631 | PS1=xmalloc(strlen(cwd)+4); | 631 | free((char*)PS1); |
| 632 | sprintf(PS1, "%s %c ", cwd, ( geteuid() != 0 ) ? '$': '#'); | 632 | ns = xmalloc(strlen(cwd)+4); |
| 633 | *prompt_str = PS1; | 633 | sprintf(ns, "%s %c ", cwd, (geteuid() != 0) ? '$': '#'); |
| 634 | PS1 = ns; | ||
| 635 | return ns; | ||
| 634 | } else { | 636 | } else { |
| 635 | *prompt_str = PS2; | 637 | return PS2; |
| 636 | } | 638 | } |
| 637 | #else | 639 | #else |
| 638 | *prompt_str = (shell_context==0)? PS1 : PS2; | 640 | return (shell_context==0)? PS1 : PS2; |
| 639 | #endif | 641 | #endif |
| 640 | } | 642 | } |
| 641 | 643 | ||
| @@ -645,7 +647,7 @@ static line_input_t *line_input_state; | |||
| 645 | 647 | ||
| 646 | static int get_command(FILE * source, char *command) | 648 | static int get_command(FILE * source, char *command) |
| 647 | { | 649 | { |
| 648 | char *prompt_str; | 650 | const char *prompt_str; |
| 649 | 651 | ||
| 650 | if (source == NULL) { | 652 | if (source == NULL) { |
| 651 | if (local_pending_command) { | 653 | if (local_pending_command) { |
| @@ -659,7 +661,7 @@ static int get_command(FILE * source, char *command) | |||
| 659 | } | 661 | } |
| 660 | 662 | ||
| 661 | if (source == stdin) { | 663 | if (source == stdin) { |
| 662 | setup_prompt_string(&prompt_str); | 664 | prompt_str = setup_prompt_string(); |
| 663 | 665 | ||
| 664 | #if ENABLE_FEATURE_EDITING | 666 | #if ENABLE_FEATURE_EDITING |
| 665 | /* | 667 | /* |
| @@ -797,7 +799,7 @@ static int expand_arguments(char *command) | |||
| 797 | break; | 799 | break; |
| 798 | case '!': | 800 | case '!': |
| 799 | if (last_bg_pid==-1) | 801 | if (last_bg_pid==-1) |
| 800 | *(var)='\0'; | 802 | *var = '\0'; |
| 801 | else | 803 | else |
| 802 | var = itoa(last_bg_pid); | 804 | var = itoa(last_bg_pid); |
| 803 | break; | 805 | break; |
| @@ -853,7 +855,7 @@ static int expand_arguments(char *command) | |||
| 853 | } | 855 | } |
| 854 | if (var == NULL) { | 856 | if (var == NULL) { |
| 855 | /* Seems we got an un-expandable variable. So delete it. */ | 857 | /* Seems we got an un-expandable variable. So delete it. */ |
| 856 | var = ""; | 858 | var = (char*)""; |
| 857 | } | 859 | } |
| 858 | { | 860 | { |
| 859 | int subst_len = strlen(var); | 861 | int subst_len = strlen(var); |
| @@ -1128,7 +1130,7 @@ empty_command_in_pipe: | |||
| 1128 | */ | 1130 | */ |
| 1129 | static int pseudo_exec(struct child_prog *child) | 1131 | static int pseudo_exec(struct child_prog *child) |
| 1130 | { | 1132 | { |
| 1131 | struct built_in_command *x; | 1133 | const struct built_in_command *x; |
| 1132 | 1134 | ||
| 1133 | /* Check if the command matches any of the non-forking builtins. | 1135 | /* Check if the command matches any of the non-forking builtins. |
| 1134 | * Depending on context, this might be redundant. But it's | 1136 | * Depending on context, this might be redundant. But it's |
| @@ -1227,7 +1229,7 @@ static int run_command(struct job *newjob, int inbg, int outpipe[2]) | |||
| 1227 | int i; | 1229 | int i; |
| 1228 | int nextin, nextout; | 1230 | int nextin, nextout; |
| 1229 | int pipefds[2]; /* pipefd[0] is for reading */ | 1231 | int pipefds[2]; /* pipefd[0] is for reading */ |
| 1230 | struct built_in_command *x; | 1232 | const struct built_in_command *x; |
| 1231 | struct child_prog *child; | 1233 | struct child_prog *child; |
| 1232 | 1234 | ||
| 1233 | nextin = 0, nextout = 1; | 1235 | nextin = 0, nextout = 1; |
