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/misc.cc
          +++ new/usr/src/cmd/make/lib/mksh/misc.cc
↓ open down ↓ 35 lines elided ↑ open up ↑
  36   36   *              Make internal state dumping
  37   37   *              main routine support
  38   38   */
  39   39  
  40   40  /*
  41   41   * Included files
  42   42   */
  43   43  #include <bsd/bsd.h>            /* bsd_signal() */
  44   44  #include <mksh/i18n.h>          /* get_char_semantics_value() */
  45   45  #include <mksh/misc.h>
  46      -#include <mksdmsi18n/mksdmsi18n.h>
  47   46  #include <stdarg.h>             /* va_list, va_start(), va_end() */
  48   47  #include <stdlib.h>             /* mbstowcs() */
  49   48  #include <sys/signal.h>         /* SIG_DFL */
  50   49  #include <sys/wait.h>           /* wait() */
  51   50  
  52   51  #include <string.h>             /* strerror() */
       52 +#include <libintl.h>
  53   53  
  54   54  
  55   55  /*
  56   56   * Defined macros
  57   57   */
  58   58  
  59   59  /*
  60   60   * typedefs & structs
  61   61   */
  62   62  
↓ open down ↓ 37 lines elided ↑ open up ↑
 100  100   *              size            The size of the chunk we need
 101  101   *
 102  102   *      Global variables used:
 103  103   */
 104  104  char *
 105  105  getmem(register int size)
 106  106  {
 107  107          register char          *result = (char *) malloc((unsigned) size);
 108  108          if (result == NULL) {
 109  109                  char buf[FATAL_ERROR_MSG_SIZE];
 110      -                sprintf(buf, NOCATGETS("*** Error: malloc(%d) failed: %s\n"), size, strerror(errno));
 111      -                strcat(buf, catgets(libmksdmsi18n_catd, 1, 126, "mksh: Fatal error: Out of memory\n"));
      110 +                sprintf(buf, "*** Error: malloc(%d) failed: %s\n", size, strerror(errno));
      111 +                strcat(buf, gettext("mksh: Fatal error: Out of memory\n"));
 112  112                  fputs(buf, stderr);
 113  113                  exit_status = 1;
 114  114                  exit(1);
 115  115          }
 116  116          return result;
 117  117  }
 118  118  
 119  119  /*
 120  120   *      retmem(p)
 121  121   *
↓ open down ↓ 223 lines elided ↑ open up ↑
 345  345   */
 346  346  char *
 347  347  errmsg(int errnum)
 348  348  {
 349  349  
 350  350          extern int              sys_nerr;
 351  351          char                    *errbuf;
 352  352  
 353  353          if ((errnum < 0) || (errnum > sys_nerr)) {
 354  354                  errbuf = getmem(6+1+11+1);
 355      -                (void) sprintf(errbuf, catgets(libmksdmsi18n_catd, 1, 127, "Error %d"), errnum);
      355 +                (void) sprintf(errbuf, gettext("Error %d"), errnum);
 356  356                  return errbuf;
 357  357          } else {
 358  358                  return strerror(errnum);
 359  359  
 360  360          }
 361  361  }
 362  362  
 363  363  static char static_buf[MAXPATHLEN*3];
 364  364  
 365  365  /*
↓ open down ↓ 4 lines elided ↑ open up ↑
 370  370   *      Parameters:
 371  371   *              format          printf type format string
 372  372   *              args            Arguments to match the format
 373  373   */
 374  374  /*VARARGS*/
 375  375  void
 376  376  fatal_mksh(const char *message, ...)
 377  377  {
 378  378          va_list args;
 379  379          char    *buf = static_buf;
 380      -        char    *mksh_fat_err = catgets(libmksdmsi18n_catd, 1, 128, "mksh: Fatal error: ");
 381      -        char    *cur_wrk_dir = catgets(libmksdmsi18n_catd, 1, 129, "Current working directory: ");
      380 +        char    *mksh_fat_err = gettext("mksh: Fatal error: ");
      381 +        char    *cur_wrk_dir = gettext("Current working directory: ");
 382  382          int     mksh_fat_err_len = strlen(mksh_fat_err);
 383  383  
 384  384          va_start(args, message);
 385  385          (void) fflush(stdout);
 386  386          (void) strcpy(buf, mksh_fat_err);
 387  387          size_t buf_len = vsnprintf(static_buf + mksh_fat_err_len,
 388  388                                     sizeof(static_buf) - mksh_fat_err_len,
 389  389                                     message, args)
 390  390                          + mksh_fat_err_len
 391  391                          + strlen(cur_wrk_dir)
↓ open down ↓ 38 lines elided ↑ open up ↑
 430  430  {
 431  431          va_list args;
 432  432          char    message[1000];
 433  433  
 434  434          va_start(args, pattern);
 435  435  /*
 436  436          if (file_being_read != NULL) {
 437  437                  WCSTOMBS(mbs_buffer, file_being_read);
 438  438                  if (line_number != 0) {
 439  439                          (void) sprintf(message,
 440      -                                       catgets(libmksdmsi18n_catd, 1, 130, "%s, line %d: %s"),
      440 +                                       gettext("%s, line %d: %s"),
 441  441                                         mbs_buffer,
 442  442                                         line_number,
 443  443                                         pattern);
 444  444                  } else {
 445  445                          (void) sprintf(message,
 446  446                                         "%s: %s",
 447  447                                         mbs_buffer,
 448  448                                         pattern);
 449  449                  }
 450  450                  pattern = message;
 451  451          }
 452  452   */
 453  453  
 454  454          (void) fflush(stdout);
 455      -        (void) fprintf(stderr, catgets(libmksdmsi18n_catd, 1, 131, "mksh: Fatal error in reader: "));
      455 +        (void) fprintf(stderr, gettext("mksh: Fatal error in reader: "));
 456  456          (void) vfprintf(stderr, pattern, args);
 457  457          (void) fprintf(stderr, "\n");
 458  458          va_end(args);
 459  459  
 460  460  /*
 461  461          if (temp_file_name != NULL) {
 462  462                  (void) fprintf(stderr,
 463      -                               catgets(libmksdmsi18n_catd, 1, 132, "mksh: Temp-file %s not removed\n"),
      463 +                               gettext("mksh: Temp-file %s not removed\n"),
 464  464                                 temp_file_name->string_mb);
 465  465                  temp_file_name = NULL;
 466  466          }
 467  467   */
 468  468  
 469  469  /*
 470  470          if (report_pwd) {
 471  471   */
 472  472          if (1) {
 473  473                  (void) fprintf(stderr,
 474      -                               catgets(libmksdmsi18n_catd, 1, 133, "Current working directory %s\n"),
      474 +                               gettext("Current working directory %s\n"),
 475  475                                 get_current_path_mksh());
 476  476          }
 477  477          (void) fflush(stderr);
 478  478          exit_status = 1;
 479  479          exit(1);
 480  480  }
 481  481  
 482  482  /*
 483  483   *      warning_mksh(format, args...)
 484  484   *
↓ open down ↓ 4 lines elided ↑ open up ↑
 489  489   *              args            Arguments to match the format
 490  490   */
 491  491  /*VARARGS*/
 492  492  void
 493  493  warning_mksh(char * message, ...)
 494  494  {
 495  495          va_list args;
 496  496  
 497  497          va_start(args, message);
 498  498          (void) fflush(stdout);
 499      -        (void) fprintf(stderr, catgets(libmksdmsi18n_catd, 1, 134, "mksh: Warning: "));
      499 +        (void) fprintf(stderr, gettext("mksh: Warning: "));
 500  500          (void) vfprintf(stderr, message, args);
 501  501          (void) fprintf(stderr, "\n");
 502  502          va_end(args);
 503  503  /*
 504  504          if (report_pwd) {
 505  505   */
 506  506          if (1) {
 507  507                  (void) fprintf(stderr,
 508      -                               catgets(libmksdmsi18n_catd, 1, 135, "Current working directory %s\n"),
      508 +                               gettext("Current working directory %s\n"),
 509  509                                 get_current_path_mksh());
 510  510          }
 511  511          (void) fflush(stderr);
 512  512  }
 513  513  
 514  514  /*
 515  515   *      get_current_path_mksh()
 516  516   *
 517  517   *      Stuff current_path with the current path if it isnt there already.
 518  518   *
↓ open down ↓ 76 lines elided ↑ open up ↑
 595  595          case long_member_name_prop:
 596  596                  size = sizeof (struct Long_member_name);
 597  597                  break;
 598  598          case macro_append_prop:
 599  599                  size = sizeof (struct _Macro_appendix);
 600  600                  break;
 601  601          case env_mem_prop:
 602  602                  size = sizeof (struct _Env_mem);
 603  603                  break;
 604  604          default:
 605      -                fatal_mksh(catgets(libmksdmsi18n_catd, 1, 136, "Internal error. Unknown prop type %d"), type);
      605 +                fatal_mksh(gettext("Internal error. Unknown prop type %d"), type);
 606  606          }
 607  607          for (; prop != NULL; insert = &prop->next, prop = *insert);
 608  608          size += PROPERTY_HEAD_SIZE;
 609  609          *insert = prop = (Property) getmem(size);
 610  610          memset((char *) prop, 0, size);
 611  611          prop->type = type;
 612  612          prop->next = NULL;
 613  613          return prop;
 614  614  }
 615  615  
↓ open down ↓ 226 lines elided ↑ open up ↑
 842  842          sigtvalue = bsd_signal(SIGTERM, SIG_IGN);
 843  843          sighvalue = bsd_signal(SIGHUP, SIG_IGN);
 844  844          enable_interrupt(handler);
 845  845  }
 846  846  
 847  847  
 848  848  void
 849  849  mbstowcs_with_check(wchar_t *pwcs, const char *s, size_t n)
 850  850  {
 851  851          if(mbstowcs(pwcs, s, n) == -1) {
 852      -                fatal_mksh(catgets(libmksdmsi18n_catd, 1, 143, "The string `%s' is not valid in current locale"), s);
      852 +                fatal_mksh(gettext("The string `%s' is not valid in current locale"), s);
 853  853          }
 854  854  }
 855  855  
 856  856  
 857  857  
 858  858  Wstring::Wstring()
 859  859  {
 860  860          INIT_STRING_FROM_STACK(string, string_buf);
 861  861  }
 862  862  
↓ open down ↓ 251 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX