Print this page
make: use the more modern wchar routines, not widec.h


 162                 shell = shell_name;
 163         }
 164         if ((shellname = strrchr(shell->string_mb, (int) slash_char)) == NULL) {
 165                 shellname = shell->string_mb;
 166         } else {
 167                 shellname++;
 168         }
 169 
 170         /*
 171          * Only prepend the /usr/bin/nice command to the original command
 172          * if the nice priority, nice_prio, is NOT zero (0).
 173          * Nice priorities can be a positive or a negative number.
 174          */
 175         if (nice_prio != 0) {
 176                 argv[argv_index++] = (char *)"nice";
 177                 (void) sprintf(nice_prio_buf, "-%d", nice_prio);
 178                 argv[argv_index++] = strdup(nice_prio_buf);
 179         }
 180         argv[argv_index++] = shellname;
 181         argv[argv_index++] = (char*)(ignore_error ? "-c" : "-ce");
 182         if ((length = wslen(command)) >= MAXPATHLEN) {
 183                 tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1);
 184                 (void) wcstombs(tmp_mbs_buffer, command, (length * MB_LEN_MAX) + 1);
 185                 cmd_argv_index = argv_index;
 186                 argv[argv_index++] = strdup(tmp_mbs_buffer);
 187                 retmem_mb(tmp_mbs_buffer);
 188         } else {
 189                 WCSTOMBS(mbs_buffer, command);
 190                 cmd_argv_index = argv_index;
 191                 argv[argv_index++] = strdup(mbs_buffer);
 192         }
 193         argv[argv_index] = NULL;
 194         (void) fflush(stdout);
 195         if ((childPid = fork()) == 0) {
 196                 enable_interrupt((void (*) (int)) SIG_DFL);
 197 #if 0
 198                 if (filter_stderr) {
 199                         redirect_stderr();
 200                 }
 201 #endif
 202                 if (nice_prio != 0) {


 325         /*
 326          * Only prepend the /usr/bin/nice command to the original command
 327          * if the nice priority, nice_prio, is NOT zero (0).
 328          * Nice priorities can be a positive or a negative number.
 329          */
 330         if (nice_prio != 0) {
 331                 arg_count += 2;
 332         }
 333         for (t = command; *t != (int) nul_char; t++) {
 334                 if (iswspace(*t)) {
 335                         arg_count++;
 336                 }
 337         }
 338         argv = (char **)alloca(arg_count * (sizeof(char *)));
 339         /*
 340          * Reserve argv[0] for sh in case of exec_vp failure.
 341          * Don't worry about prepending /usr/bin/nice command to argv[0].
 342          * In fact, doing it may cause the sh command to fail!
 343          */
 344         p = &argv[1];
 345         if ((length = wslen(command)) >= MAXPATHLEN) {
 346                 tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1);
 347                 (void) wcstombs(tmp_mbs_buffer, command, (length * MB_LEN_MAX) + 1);
 348                 argv[0] = strdup(tmp_mbs_buffer);
 349                 retmem_mb(tmp_mbs_buffer);
 350         } else {
 351                 WCSTOMBS(mbs_buffer, command);
 352                 argv[0] = strdup(mbs_buffer);
 353         }
 354 
 355         if (nice_prio != 0) {
 356                 *p++ = strdup("/usr/bin/nice");
 357                 (void) sprintf(nice_prio_buf, "-%d", nice_prio);
 358                 *p++ = strdup(nice_prio_buf);
 359         }
 360         /* Build list of argument words. */
 361         for (t = command; *t;) {
 362                 if (p >= &argv[arg_count]) {
 363                         /* This should never happen, right? */
 364                         WCSTOMBS(mbs_buffer, command);
 365                         fatal_mksh(gettext("Command `%s' has more than %d arguments"),
 366                               mbs_buffer,
 367                               arg_count);
 368                 }
 369                 q = t;
 370                 while (!iswspace(*t) && (*t != (int) nul_char)) {
 371                         t++;
 372                 }
 373                 if (*t) {
 374                         for (*t++ = (int) nul_char; iswspace(*t); t++);
 375                 }
 376                 if ((length = wslen(q)) >= MAXPATHLEN) {
 377                         tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1);
 378                         (void) wcstombs(tmp_mbs_buffer, q, (length * MB_LEN_MAX) + 1);
 379                         *p++ = strdup(tmp_mbs_buffer);
 380                         retmem_mb(tmp_mbs_buffer);
 381                 } else {
 382                         WCSTOMBS(mbs_buffer, q);
 383                         *p++ = strdup(mbs_buffer);
 384                 }
 385         }
 386         *p = NULL;
 387 
 388         /* Then exec the command with that argument list. */
 389         (void) fflush(stdout);
 390         if ((childPid = fork()) == 0) {
 391                 enable_interrupt((void (*) (int)) SIG_DFL);
 392 #if 0
 393                 if (filter_stderr) {
 394                         redirect_stderr();
 395                 }
 396 #endif




 162                 shell = shell_name;
 163         }
 164         if ((shellname = strrchr(shell->string_mb, (int) slash_char)) == NULL) {
 165                 shellname = shell->string_mb;
 166         } else {
 167                 shellname++;
 168         }
 169 
 170         /*
 171          * Only prepend the /usr/bin/nice command to the original command
 172          * if the nice priority, nice_prio, is NOT zero (0).
 173          * Nice priorities can be a positive or a negative number.
 174          */
 175         if (nice_prio != 0) {
 176                 argv[argv_index++] = (char *)"nice";
 177                 (void) sprintf(nice_prio_buf, "-%d", nice_prio);
 178                 argv[argv_index++] = strdup(nice_prio_buf);
 179         }
 180         argv[argv_index++] = shellname;
 181         argv[argv_index++] = (char*)(ignore_error ? "-c" : "-ce");
 182         if ((length = wcslen(command)) >= MAXPATHLEN) {
 183                 tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1);
 184                 (void) wcstombs(tmp_mbs_buffer, command, (length * MB_LEN_MAX) + 1);
 185                 cmd_argv_index = argv_index;
 186                 argv[argv_index++] = strdup(tmp_mbs_buffer);
 187                 retmem_mb(tmp_mbs_buffer);
 188         } else {
 189                 WCSTOMBS(mbs_buffer, command);
 190                 cmd_argv_index = argv_index;
 191                 argv[argv_index++] = strdup(mbs_buffer);
 192         }
 193         argv[argv_index] = NULL;
 194         (void) fflush(stdout);
 195         if ((childPid = fork()) == 0) {
 196                 enable_interrupt((void (*) (int)) SIG_DFL);
 197 #if 0
 198                 if (filter_stderr) {
 199                         redirect_stderr();
 200                 }
 201 #endif
 202                 if (nice_prio != 0) {


 325         /*
 326          * Only prepend the /usr/bin/nice command to the original command
 327          * if the nice priority, nice_prio, is NOT zero (0).
 328          * Nice priorities can be a positive or a negative number.
 329          */
 330         if (nice_prio != 0) {
 331                 arg_count += 2;
 332         }
 333         for (t = command; *t != (int) nul_char; t++) {
 334                 if (iswspace(*t)) {
 335                         arg_count++;
 336                 }
 337         }
 338         argv = (char **)alloca(arg_count * (sizeof(char *)));
 339         /*
 340          * Reserve argv[0] for sh in case of exec_vp failure.
 341          * Don't worry about prepending /usr/bin/nice command to argv[0].
 342          * In fact, doing it may cause the sh command to fail!
 343          */
 344         p = &argv[1];
 345         if ((length = wcslen(command)) >= MAXPATHLEN) {
 346                 tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1);
 347                 (void) wcstombs(tmp_mbs_buffer, command, (length * MB_LEN_MAX) + 1);
 348                 argv[0] = strdup(tmp_mbs_buffer);
 349                 retmem_mb(tmp_mbs_buffer);
 350         } else {
 351                 WCSTOMBS(mbs_buffer, command);
 352                 argv[0] = strdup(mbs_buffer);
 353         }
 354 
 355         if (nice_prio != 0) {
 356                 *p++ = strdup("/usr/bin/nice");
 357                 (void) sprintf(nice_prio_buf, "-%d", nice_prio);
 358                 *p++ = strdup(nice_prio_buf);
 359         }
 360         /* Build list of argument words. */
 361         for (t = command; *t;) {
 362                 if (p >= &argv[arg_count]) {
 363                         /* This should never happen, right? */
 364                         WCSTOMBS(mbs_buffer, command);
 365                         fatal_mksh(gettext("Command `%s' has more than %d arguments"),
 366                               mbs_buffer,
 367                               arg_count);
 368                 }
 369                 q = t;
 370                 while (!iswspace(*t) && (*t != (int) nul_char)) {
 371                         t++;
 372                 }
 373                 if (*t) {
 374                         for (*t++ = (int) nul_char; iswspace(*t); t++);
 375                 }
 376                 if ((length = wcslen(q)) >= MAXPATHLEN) {
 377                         tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1);
 378                         (void) wcstombs(tmp_mbs_buffer, q, (length * MB_LEN_MAX) + 1);
 379                         *p++ = strdup(tmp_mbs_buffer);
 380                         retmem_mb(tmp_mbs_buffer);
 381                 } else {
 382                         WCSTOMBS(mbs_buffer, q);
 383                         *p++ = strdup(mbs_buffer);
 384                 }
 385         }
 386         *p = NULL;
 387 
 388         /* Then exec the command with that argument list. */
 389         (void) fflush(stdout);
 390         if ((childPid = fork()) == 0) {
 391                 enable_interrupt((void (*) (int)) SIG_DFL);
 392 #if 0
 393                 if (filter_stderr) {
 394                         redirect_stderr();
 395                 }
 396 #endif