Print this page
make: translate using gettext, rather than the unmaintainable catgets

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/lib/mksh/dosys.cc
          +++ new/usr/src/cmd/make/lib/mksh/dosys.cc
↓ open down ↓ 34 lines elided ↑ open up ↑
  35   35   */
  36   36  #include <sys/wait.h>                   /* WIFEXITED(status) */
  37   37  #include <alloca.h>             /* alloca() */
  38   38  
  39   39  #include <stdio.h>              /* errno */
  40   40  #include <errno.h>              /* errno */
  41   41  #include <fcntl.h>              /* open() */
  42   42  #include <mksh/dosys.h>
  43   43  #include <mksh/macro.h>         /* getvar() */
  44   44  #include <mksh/misc.h>          /* getmem(), fatal_mksh(), errmsg() */
  45      -#include <mksdmsi18n/mksdmsi18n.h>      /* libmksdmsi18n_init() */
  46   45  #include <sys/signal.h>         /* SIG_DFL */
  47   46  #include <sys/stat.h>           /* open() */
  48   47  #include <sys/wait.h>           /* wait() */
  49   48  #include <ulimit.h>             /* ulimit() */
  50   49  #include <unistd.h>             /* close(), dup2() */
       50 +#include <libintl.h>
  51   51  
  52   52  /*
  53   53   * typedefs & structs
  54   54   */
  55   55  
  56   56  /*
  57   57   * Static variables
  58   58   */
  59   59  
  60   60  /*
↓ open down ↓ 22 lines elided ↑ open up ↑
  83   83   *
  84   84   *      Redirects stdout and stderr for a child mksh process.
  85   85   */
  86   86  void
  87   87  redirect_io(char *stdout_file, char *stderr_file)
  88   88  {        
  89   89          long            descriptor_limit;
  90   90          int             i;
  91   91  
  92   92          if ((descriptor_limit = ulimit(UL_GDESLIM)) < 0) {
  93      -                fatal_mksh(catgets(libmksdmsi18n_catd, 1, 89, "ulimit() failed: %s"), errmsg(errno));
       93 +                fatal_mksh(gettext("ulimit() failed: %s"), errmsg(errno));
  94   94          }
  95   95          for (i = 3; i < descriptor_limit; i++) {
  96   96                  (void) close(i);
  97   97          }
  98   98          if ((i = my_open(stdout_file,
  99   99                   O_WRONLY | O_CREAT | O_TRUNC | O_DSYNC,
 100  100                   S_IREAD | S_IWRITE)) < 0) {
 101      -                fatal_mksh(catgets(libmksdmsi18n_catd, 1, 90, "Couldn't open standard out temp file `%s': %s"),
      101 +                fatal_mksh(gettext("Couldn't open standard out temp file `%s': %s"),
 102  102                        stdout_file,
 103  103                        errmsg(errno));
 104  104          } else {
 105  105                  if (dup2(i, 1) == -1) {
 106      -                        fatal_mksh(NOCATGETS("*** Error: dup2(3, 1) failed: %s"),
      106 +                        fatal_mksh("*** Error: dup2(3, 1) failed: %s",
 107  107                                  errmsg(errno));
 108  108                  }
 109  109                  close(i);
 110  110          }
 111  111          if (stderr_file == NULL) {
 112  112                  if (dup2(1, 2) == -1) {
 113      -                        fatal_mksh(NOCATGETS("*** Error: dup2(1, 2) failed: %s"),
      113 +                        fatal_mksh("*** Error: dup2(1, 2) failed: %s",
 114  114                                  errmsg(errno));
 115  115                  }
 116  116          } else if ((i = my_open(stderr_file,
 117  117                          O_WRONLY | O_CREAT | O_TRUNC | O_DSYNC,
 118  118                          S_IREAD | S_IWRITE)) < 0) {
 119      -                fatal_mksh(catgets(libmksdmsi18n_catd, 1, 91, "Couldn't open standard error temp file `%s': %s"),
      119 +                fatal_mksh(gettext("Couldn't open standard error temp file `%s': %s"),
 120  120                        stderr_file,
 121  121                        errmsg(errno));
 122  122          } else {
 123  123                  if (dup2(i, 2) == -1) {
 124      -                        fatal_mksh(NOCATGETS("*** Error: dup2(3, 2) failed: %s"),
      124 +                        fatal_mksh("*** Error: dup2(3, 2) failed: %s",
 125  125                                  errmsg(errno));
 126  126                  }
 127  127                  close(i);
 128  128          }
 129  129  }
 130  130  
 131  131  /*
 132  132   *      doshell(command, ignore_error)
 133  133   *
 134  134   *      Used to run command lines that include shell meta-characters.
↓ open down ↓ 31 lines elided ↑ open up ↑
 166  166          } else {
 167  167                  shellname++;
 168  168          }
 169  169  
 170  170          /*
 171  171           * Only prepend the /usr/bin/nice command to the original command
 172  172           * if the nice priority, nice_prio, is NOT zero (0).
 173  173           * Nice priorities can be a positive or a negative number.
 174  174           */
 175  175          if (nice_prio != 0) {
 176      -                argv[argv_index++] = (char *)NOCATGETS("nice");
 177      -                (void) sprintf(nice_prio_buf, NOCATGETS("-%d"), nice_prio);
      176 +                argv[argv_index++] = (char *)"nice";
      177 +                (void) sprintf(nice_prio_buf, "-%d", nice_prio);
 178  178                  argv[argv_index++] = strdup(nice_prio_buf);
 179  179          }
 180  180          argv[argv_index++] = shellname;
 181      -        argv[argv_index++] = (char*)(ignore_error ? NOCATGETS("-c") : NOCATGETS("-ce"));
      181 +        argv[argv_index++] = (char*)(ignore_error ? "-c" : "-ce");
 182  182          if ((length = wslen(command)) >= MAXPATHLEN) {
 183  183                  tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1);
 184  184                  (void) wcstombs(tmp_mbs_buffer, command, (length * MB_LEN_MAX) + 1);
 185  185                  cmd_argv_index = argv_index;
 186  186                  argv[argv_index++] = strdup(tmp_mbs_buffer);
 187  187                  retmem_mb(tmp_mbs_buffer);
 188  188          } else {
 189  189                  WCSTOMBS(mbs_buffer, command);
 190  190                  cmd_argv_index = argv_index;
 191  191                  argv[argv_index++] = strdup(mbs_buffer);
↓ open down ↓ 1 lines elided ↑ open up ↑
 193  193          argv[argv_index] = NULL;
 194  194          (void) fflush(stdout);
 195  195          if ((childPid = fork()) == 0) {
 196  196                  enable_interrupt((void (*) (int)) SIG_DFL);
 197  197  #if 0
 198  198                  if (filter_stderr) {
 199  199                          redirect_stderr();
 200  200                  }
 201  201  #endif
 202  202                  if (nice_prio != 0) {
 203      -                        (void) execve(NOCATGETS("/usr/bin/nice"), argv, environ);
 204      -                        fatal_mksh(catgets(libmksdmsi18n_catd, 1, 92, "Could not load `/usr/bin/nice': %s"),
      203 +                        (void) execve("/usr/bin/nice", argv, environ);
      204 +                        fatal_mksh(gettext("Could not load `/usr/bin/nice': %s"),
 205  205                                errmsg(errno));
 206  206                  } else {
 207  207                          (void) execve(shell->string_mb, argv, environ);
 208      -                        fatal_mksh(catgets(libmksdmsi18n_catd, 1, 93, "Could not load Shell from `%s': %s"),
      208 +                        fatal_mksh(gettext("Could not load Shell from `%s': %s"),
 209  209                                shell->string_mb,
 210  210                                errmsg(errno));
 211  211                  }
 212  212          }
 213  213          if (childPid  == -1) {
 214      -                fatal_mksh(catgets(libmksdmsi18n_catd, 1, 94, "fork failed: %s"),
      214 +                fatal_mksh(gettext("fork failed: %s"),
 215  215                        errmsg(errno));
 216  216          }
 217  217          retmem_mb(argv[cmd_argv_index]);
 218  218          return childPid;
 219  219  }
 220  220  
 221  221  /*
 222  222   *      exec_vp(name, argv, envp, ignore_error)
 223  223   *
 224  224   *      Like execve, but does path search.
↓ open down ↓ 34 lines elided ↑ open up ↑
 259  259                  case ENOEXEC:
 260  260                  case ENOENT:
 261  261                          /* That failed. Let the shell handle it */
 262  262                          shellname = strrchr(shell->string_mb, (int) slash_char);
 263  263                          if (shellname == NULL) {
 264  264                                  shellname = shell->string_mb;
 265  265                          } else {
 266  266                                  shellname++;
 267  267                          }
 268  268                          shargv[0] = shellname;
 269      -                        shargv[1] = (char*)(ignore_error ? NOCATGETS("-c") : NOCATGETS("-ce"));
      269 +                        shargv[1] = (char*)(ignore_error ? "-c" : "-ce");
 270  270                          shargv[2] = argv[0];
 271  271                          shargv[3] = NULL;
 272  272                          tmp_shell = getvar(shell_name);
 273  273                          if (IS_EQUAL(tmp_shell->string_mb, "")) {
 274  274                                  tmp_shell = shell_name;
 275  275                          }
 276  276                          (void) execve_vroot(tmp_shell->string_mb,
 277  277                                              shargv,
 278  278                                              envp,
 279  279                                              vroot_path,
↓ open down ↓ 66 lines elided ↑ open up ↑
 346  346                  tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1);
 347  347                  (void) wcstombs(tmp_mbs_buffer, command, (length * MB_LEN_MAX) + 1);
 348  348                  argv[0] = strdup(tmp_mbs_buffer);
 349  349                  retmem_mb(tmp_mbs_buffer);
 350  350          } else {
 351  351                  WCSTOMBS(mbs_buffer, command);
 352  352                  argv[0] = strdup(mbs_buffer);
 353  353          }
 354  354  
 355  355          if (nice_prio != 0) {
 356      -                *p++ = strdup(NOCATGETS("/usr/bin/nice"));
 357      -                (void) sprintf(nice_prio_buf, NOCATGETS("-%d"), nice_prio);
      356 +                *p++ = strdup("/usr/bin/nice");
      357 +                (void) sprintf(nice_prio_buf, "-%d", nice_prio);
 358  358                  *p++ = strdup(nice_prio_buf);
 359  359          }
 360  360          /* Build list of argument words. */
 361  361          for (t = command; *t;) {
 362  362                  if (p >= &argv[arg_count]) {
 363  363                          /* This should never happen, right? */
 364  364                          WCSTOMBS(mbs_buffer, command);
 365      -                        fatal_mksh(catgets(libmksdmsi18n_catd, 1, 95, "Command `%s' has more than %d arguments"),
      365 +                        fatal_mksh(gettext("Command `%s' has more than %d arguments"),
 366  366                                mbs_buffer,
 367  367                                arg_count);
 368  368                  }
 369  369                  q = t;
 370  370                  while (!iswspace(*t) && (*t != (int) nul_char)) {
 371  371                          t++;
 372  372                  }
 373  373                  if (*t) {
 374  374                          for (*t++ = (int) nul_char; iswspace(*t); t++);
 375  375                  }
↓ open down ↓ 12 lines elided ↑ open up ↑
 388  388          /* Then exec the command with that argument list. */
 389  389          (void) fflush(stdout);
 390  390          if ((childPid = fork()) == 0) {
 391  391                  enable_interrupt((void (*) (int)) SIG_DFL);
 392  392  #if 0
 393  393                  if (filter_stderr) {
 394  394                          redirect_stderr();
 395  395                  }
 396  396  #endif
 397  397                  (void) exec_vp(argv[1], argv, environ, ignore_error, vroot_path);
 398      -                fatal_mksh(catgets(libmksdmsi18n_catd, 1, 96, "Cannot load command `%s': %s"), argv[1], errmsg(errno));
      398 +                fatal_mksh(gettext("Cannot load command `%s': %s"), argv[1], errmsg(errno));
 399  399          }
 400  400          if (childPid  == -1) {
 401      -                fatal_mksh(catgets(libmksdmsi18n_catd, 1, 97, "fork failed: %s"),
      401 +                fatal_mksh(gettext("fork failed: %s"),
 402  402                        errmsg(errno));
 403  403          }
 404  404          for (int i = 0; argv[i] != NULL; i++) {
 405  405                  retmem_mb(argv[i]);
 406  406          }
 407  407          return childPid;
 408  408  }
 409  409  
 410  410  /*
 411  411   *      await(ignore_error, silent_error, target, command, running_pid)
↓ open down ↓ 26 lines elided ↑ open up ↑
 438  438          int                     core_dumped;
 439  439          int                     exit_status;
 440  440          FILE                    *outfp;
 441  441          register pid_t          pid;
 442  442          struct stat             stat_buff;
 443  443          int                     termination_signal;
 444  444          char                    tmp_buf[MAXPATHLEN];
 445  445  
 446  446          while ((pid = wait(&status)) != running_pid) {
 447  447                  if (pid == -1) {
 448      -                        fatal_mksh(catgets(libmksdmsi18n_catd, 1, 98, "wait() failed: %s"), errmsg(errno));
      448 +                        fatal_mksh(gettext("wait() failed: %s"), errmsg(errno));
 449  449                  }
 450  450          }
 451  451          (void) fflush(stdout);
 452  452          (void) fflush(stderr);
 453  453  
 454  454          if (status == 0) {
 455  455  
 456  456  #ifdef PRINT_EXIT_STATUS
 457      -                warning_mksh(NOCATGETS("I'm in await(), and status is 0."));
      457 +                warning_mksh("I'm in await(), and status is 0.");
 458  458  #endif
 459  459  
 460  460                  return succeeded;
 461  461          }
 462  462  
 463  463  #ifdef PRINT_EXIT_STATUS
 464      -        warning_mksh(NOCATGETS("I'm in await(), and status is *NOT* 0."));
      464 +        warning_mksh("I'm in await(), and status is *NOT* 0.");
 465  465  #endif
 466  466  
 467  467  
 468  468          exit_status = WEXITSTATUS(status);
 469  469  
 470  470  #ifdef PRINT_EXIT_STATUS
 471      -        warning_mksh(NOCATGETS("I'm in await(), and exit_status is %d."), exit_status);
      471 +        warning_mksh("I'm in await(), and exit_status is %d.", exit_status);
 472  472  #endif
 473  473  
 474  474          termination_signal = WTERMSIG(status);
 475  475          core_dumped = WCOREDUMP(status);
 476  476  
 477  477          /*
 478  478           * If the child returned an error, we now try to print a
 479  479           * nice message about it.
 480  480           */
 481  481          
 482  482          tmp_buf[0] = (int) nul_char;
 483  483          if (!silent_error) {
 484  484                  if (exit_status != 0) {
 485  485                          (void) fprintf(stdout,
 486      -                                       catgets(libmksdmsi18n_catd, 1, 103, "*** Error code %d"),
      486 +                                       gettext("*** Error code %d"),
 487  487                                         exit_status);
 488  488                  } else {
 489  489                                  (void) fprintf(stdout,
 490      -                                               catgets(libmksdmsi18n_catd, 1, 105, "*** Signal %d"),
      490 +                                               gettext("*** Signal %d"),
 491  491                                                 termination_signal);
 492  492                          if (core_dumped) {
 493  493                                  (void) fprintf(stdout,
 494      -                                               catgets(libmksdmsi18n_catd, 1, 107, " - core dumped"));
      494 +                                               gettext(" - core dumped"));
 495  495                          }
 496  496                  }
 497  497                  if (ignore_error) {
 498  498                          (void) fprintf(stdout,
 499      -                                       catgets(libmksdmsi18n_catd, 1, 109, " (ignored)"));
      499 +                                       gettext(" (ignored)"));
 500  500                  }
 501  501                  (void) fprintf(stdout, "\n");
 502  502                  (void) fflush(stdout);
 503  503          }
 504  504  
 505  505  #ifdef PRINT_EXIT_STATUS
 506      -        warning_mksh(NOCATGETS("I'm in await(), returning failed."));
      506 +        warning_mksh("I'm in await(), returning failed.");
 507  507  #endif
 508  508  
 509  509          return failed;
 510  510  }
 511  511  
 512  512  /*
 513  513   *      sh_command2string(command, destination)
 514  514   *
 515  515   *      Run one sh command and capture the output from it.
 516  516   *
↓ open down ↓ 12 lines elided ↑ open up ↑
 529  529  {
 530  530          register FILE           *fd;
 531  531          register int            chr;
 532  532          int                     status;
 533  533          Boolean                 command_generated_output = false;
 534  534  
 535  535          command->text.p = (int) nul_char;
 536  536          WCSTOMBS(mbs_buffer, command->buffer.start);
 537  537          if ((fd = popen(mbs_buffer, "r")) == NULL) {
 538  538                  WCSTOMBS(mbs_buffer, command->buffer.start);
 539      -                fatal_mksh(catgets(libmksdmsi18n_catd, 1, 111, "Could not run command `%s' for :sh transformation"),
      539 +                fatal_mksh(gettext("Could not run command `%s' for :sh transformation"),
 540  540                        mbs_buffer);
 541  541          }
 542  542          while ((chr = getc(fd)) != EOF) {
 543  543                  if (chr == (int) newline_char) {
 544  544                          chr = (int) space_char;
 545  545                  }
 546  546                  command_generated_output = true;
 547  547                  append_char(chr, destination);
 548  548          }
 549  549  
↓ open down ↓ 12 lines elided ↑ open up ↑
 562  562                  /*
 563  563                   * If the command didn't generate any output,
 564  564                   * set the buffer to a null string.
 565  565                   */
 566  566                  *(destination->text.p) = '\0';
 567  567          }
 568  568                          
 569  569          status = pclose(fd);
 570  570          if (status != 0) {
 571  571                  WCSTOMBS(mbs_buffer, command->buffer.start);
 572      -                fatal_mksh(catgets(libmksdmsi18n_catd, 1, 112, "The command `%s' returned status `%d'"),
      572 +                fatal_mksh(gettext("The command `%s' returned status `%d'"),
 573  573                        mbs_buffer,
 574  574                        WEXITSTATUS(status));
 575  575          }
 576  576  }
 577  577  
 578  578  
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX