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/macro.cc
          +++ new/usr/src/cmd/make/lib/mksh/macro.cc
↓ open down ↓ 30 lines elided ↑ open up ↑
  31   31   */
  32   32  
  33   33  /*
  34   34   * Included files
  35   35   */
  36   36  #include <mksh/dosys.h>         /* sh_command2string() */
  37   37  #include <mksh/i18n.h>          /* get_char_semantics_value() */
  38   38  #include <mksh/macro.h>
  39   39  #include <mksh/misc.h>          /* retmem() */
  40   40  #include <mksh/read.h>          /* get_next_block_fn() */
  41      -#include <mksdmsi18n/mksdmsi18n.h>      /* libmksdmsi18n_init() */
  42   41  
  43   42  #include <widec.h>
       43 +#include <libintl.h>
  44   44  
  45   45  /*
  46   46   * File table of contents
  47   47   */
  48   48  static void     add_macro_to_global_list(Name macro_to_add);
  49   49  static void     expand_value_with_daemon(Name, register Property macro, register String destination, Boolean cmd);
  50   50  
  51   51  static void     init_arch_macros(void);
  52   52  static void     init_mach_macros(void);
  53   53  static Boolean  init_arch_done = false;
↓ open down ↓ 88 lines elided ↑ open up ↑
 142  142                   */
 143  143                  APPEND_NAME(value,
 144  144                          destination,
 145  145                          (int) value->hash.length
 146  146                  );
 147  147                  destination->text.end = destination->text.p;
 148  148                  return;
 149  149          }
 150  150  
 151  151          if (value->being_expanded) {
 152      -                fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 113, "Loop detected when expanding macro value `%s'"),
      152 +                fatal_reader_mksh(gettext("Loop detected when expanding macro value `%s'"),
 153  153                               value->string_mb);
 154  154          }
 155  155          value->being_expanded = true;
 156  156          /* Setup the structure we read from */
 157  157          Wstring vals(value);
 158  158          sourceb.string.text.p = sourceb.string.buffer.start = wsdup(vals.get_string());
 159  159          sourceb.string.free_after_use = true;
 160  160          sourceb.string.text.end =
 161  161            sourceb.string.buffer.end =
 162  162              sourceb.string.text.p + value->hash.length;
↓ open down ↓ 44 lines elided ↑ open up ↑
 207  207                          append_string(block_start,
 208  208                                        destination,
 209  209                                        source_p - block_start);
 210  210                          GET_NEXT_BLOCK_NOCHK(source);
 211  211                          if (source == NULL) {
 212  212                                  destination->text.end = destination->text.p;
 213  213                                  value->being_expanded = false;
 214  214                                  return;
 215  215                          }
 216  216                          if (source->error_converting) {
 217      -                                fatal_reader_mksh(NOCATGETS("Internal error: Invalid byte sequence in expand_value()"));
      217 +                                fatal_reader_mksh("Internal error: Invalid byte sequence in expand_value()");
 218  218                          }
 219  219                          block_start = source_p;
 220  220                          source_p--;
 221  221                          continue;
 222  222                  }
 223  223                  quote_seen = 0;
 224  224          }
 225  225          retmem(sourceb.string.buffer.start);
 226  226  }
 227  227  
↓ open down ↓ 64 lines elided ↑ open up ↑
 292  292                  file_extract
 293  293          }                       extraction = no_extract;
 294  294          enum {
 295  295                  no_replace,
 296  296                  suffix_replace,
 297  297                  pattern_replace,
 298  298                  sh_replace
 299  299          }                       replacement = no_replace;
 300  300  
 301  301          if (make == NULL) {
 302      -                MBSTOWCS(wcs_buffer, NOCATGETS("MAKE"));
      302 +                MBSTOWCS(wcs_buffer, "MAKE");
 303  303                  make = GETNAME(wcs_buffer, FIND_LENGTH);
 304  304  
 305      -                MBSTOWCS(colon_sh, NOCATGETS(":sh"));
 306      -                MBSTOWCS(colon_shell, NOCATGETS(":shell"));
      305 +                MBSTOWCS(colon_sh, ":sh");
      306 +                MBSTOWCS(colon_shell, ":shell");
 307  307          }
 308  308  
 309  309          right_hand[0] = NULL;
 310  310  
 311  311          /* First copy the (macro-expanded) macro name into string. */
 312  312          INIT_STRING_FROM_STACK(string, buffer);
 313  313  recheck_first_char:
 314  314          /* Check the first char of the macro name to figure out what to do. */
 315  315          switch (GET_CHAR()) {
 316  316          case nul_char:
 317  317                  GET_NEXT_BLOCK_NOCHK(source);
 318  318                  if (source == NULL) {
 319  319                          WCSTOMBS(mbs_buffer, current_string);
 320      -                        fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 114, "'$' at end of string `%s'"),
      320 +                        fatal_reader_mksh(gettext("'$' at end of string `%s'"),
 321  321                                       mbs_buffer);
 322  322                  }
 323  323                  if (source->error_converting) {
 324      -                        fatal_reader_mksh(NOCATGETS("Internal error: Invalid byte sequence in expand_macro()"));
      324 +                        fatal_reader_mksh("Internal error: Invalid byte sequence in expand_macro()");
 325  325                  }
 326  326                  goto recheck_first_char;
 327  327          case parenleft_char:
 328  328                  /* Multi char name. */
 329  329                  closer = (int) parenright_char;
 330  330                  break;
 331  331          case braceleft_char:
 332  332                  /* Multi char name. */
 333  333                  closer = (int) braceright_char;
 334  334                  break;
 335  335          case newline_char:
 336      -                fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 115, "'$' at end of line"));
      336 +                fatal_reader_mksh(gettext("'$' at end of line"));
 337  337          default:
 338  338                  /* Single char macro name. Just suck it up */
 339  339                  append_char(*source_p, &string);
 340  340                  source->string.text.p = source_p + 1;
 341  341                  goto get_macro_value;
 342  342          }
 343  343  
 344  344          /* Handle multi-char macro names */
 345  345          block_start = ++source_p;
 346  346          quote_seen = 0;
 347  347          for (; 1; source_p++) {
 348  348                  switch (GET_CHAR()) {
 349  349                  case nul_char:
 350  350                          append_string(block_start,
 351  351                                        &string,
 352  352                                        source_p - block_start);
 353  353                          GET_NEXT_BLOCK_NOCHK(source);
 354  354                          if (source == NULL) {
 355  355                                  if (current_string != NULL) {
 356  356                                          WCSTOMBS(mbs_buffer, current_string);
 357      -                                        fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 116, "Unmatched `%c' in string `%s'"),
      357 +                                        fatal_reader_mksh(gettext("Unmatched `%c' in string `%s'"),
 358  358                                                       closer ==
 359  359                                                       (int) braceright_char ?
 360  360                                                       (int) braceleft_char :
 361  361                                                       (int) parenleft_char,
 362  362                                                       mbs_buffer);
 363  363                                  } else {
 364      -                                        fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 117, "Premature EOF"));
      364 +                                        fatal_reader_mksh(gettext("Premature EOF"));
 365  365                                  }
 366  366                          }
 367  367                          if (source->error_converting) {
 368      -                                fatal_reader_mksh(NOCATGETS("Internal error: Invalid byte sequence in expand_macro()"));
      368 +                                fatal_reader_mksh("Internal error: Invalid byte sequence in expand_macro()");
 369  369                          }
 370  370                          block_start = source_p;
 371  371                          source_p--;
 372  372                          continue;
 373  373                  case newline_char:
 374      -                        fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 118, "Unmatched `%c' on line"),
      374 +                        fatal_reader_mksh(gettext("Unmatched `%c' on line"),
 375  375                                       closer == (int) braceright_char ?
 376  376                                       (int) braceleft_char :
 377  377                                       (int) parenleft_char);
 378  378                  case backslash_char:
 379  379                          /* Quote dollar in macro value. */
 380  380                          if (!cmd) {
 381  381                                  quote_seen = ~quote_seen;
 382  382                          }
 383  383                          continue;
 384  384                  case dollar_char:
↓ open down ↓ 62 lines elided ↑ open up ↑
 447  447               (string.buffer.start[1] == 'F'))) {
 448  448                  switch (string.buffer.start[1]) {
 449  449                  case 'D':
 450  450                          extraction = dir_extract;
 451  451                          break;
 452  452                  case 'F':
 453  453                          extraction = file_extract;
 454  454                          break;
 455  455                  default:
 456  456                          WCSTOMBS(mbs_buffer, string.buffer.start);
 457      -                        fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 119, "Illegal macro reference `%s'"),
      457 +                        fatal_reader_mksh(gettext("Illegal macro reference `%s'"),
 458  458                                       mbs_buffer);
 459  459                  }
 460  460                  /* Internalize the macro name using the first char only. */
 461  461                  name = GETNAME(string.buffer.start, 1);
 462  462                  (void) wscpy(string.buffer.start, string.buffer.start + 2);
 463  463          }
 464  464          /* Check for other kinds of translations. */
 465  465          if ((colon = (wchar_t *) wschr(string.buffer.start,
 466  466                                         (int) colon_char)) != NULL) {
 467  467                  /*
↓ open down ↓ 6 lines elided ↑ open up ↑
 474  474                  }
 475  475                  /* Pickup all the translations. */
 476  476                  if (IS_WEQUAL(colon, colon_sh) || IS_WEQUAL(colon, colon_shell)) {
 477  477                          replacement = sh_replace;
 478  478                  } else if ((svr4) ||
 479  479                             ((percent = (wchar_t *) wschr(colon + 1,
 480  480                                                           (int) percent_char)) == NULL)) {
 481  481                          while (colon != NULL) {
 482  482                                  if ((eq = (wchar_t *) wschr(colon + 1,
 483  483                                                              (int) equal_char)) == NULL) {
 484      -                                        fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 120, "= missing from replacement macro reference"));
      484 +                                        fatal_reader_mksh(gettext("= missing from replacement macro reference"));
 485  485                                  }
 486  486                                  left_tail_len = eq - colon - 1;
 487  487                                  if(left_tail) {
 488  488                                          retmem(left_tail);
 489  489                                  }
 490  490                                  left_tail = ALLOC_WC(left_tail_len + 1);
 491  491                                  (void) wsncpy(left_tail,
 492  492                                                colon + 1,
 493  493                                                eq - colon - 1);
 494  494                                  left_tail[eq - colon - 1] = (int) nul_char;
↓ open down ↓ 14 lines elided ↑ open up ↑
 509  509                                          if(right_tail) {
 510  510                                                  retmem(right_tail);
 511  511                                          }
 512  512                                          right_tail = ALLOC_WC(wslen(eq) + 1);
 513  513                                          (void) wscpy(right_tail, eq + 1);
 514  514                                  }
 515  515                          }
 516  516                  } else {
 517  517                          if ((eq = (wchar_t *) wschr(colon + 1,
 518  518                                                      (int) equal_char)) == NULL) {
 519      -                                fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 121, "= missing from replacement macro reference"));
      519 +                                fatal_reader_mksh(gettext("= missing from replacement macro reference"));
 520  520                          }
 521  521                          if ((percent = (wchar_t *) wschr(colon + 1,
 522  522                                                           (int) percent_char)) == NULL) {
 523      -                                fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 122, "%% missing from replacement macro reference"));
      523 +                                fatal_reader_mksh(gettext("%% missing from replacement macro reference"));
 524  524                          }
 525  525                          if (eq < percent) {
 526      -                                fatal_reader_mksh(catgets(libmksdmsi18n_catd, 1, 123, "%% missing from replacement macro reference"));
      526 +                                fatal_reader_mksh(gettext("%% missing from replacement macro reference"));
 527  527                          }
 528  528  
 529  529                          if (percent > (colon + 1)) {
 530  530                                  tmp_len = percent - colon;
 531  531                                  if(left_head) {
 532  532                                          retmem(left_head);
 533  533                                  }
 534  534                                  left_head = ALLOC_WC(tmp_len);
 535  535                                  (void) wsncpy(left_head,
 536  536                                                colon + 1,
↓ open down ↓ 30 lines elided ↑ open up ↑
 567  567                          } else {
 568  568                                  i = 0;
 569  569                                  do {
 570  570                                          right_hand[i] = ALLOC_WC(percent-eq+1);
 571  571                                          (void) wsncpy(right_hand[i],
 572  572                                                        eq,
 573  573                                                        percent - eq);
 574  574                                          right_hand[i][percent-eq] =
 575  575                                            (int) nul_char;
 576  576                                          if (i++ >= VSIZEOF(right_hand)) {
 577      -                                                fatal_mksh(catgets(libmksdmsi18n_catd, 1, 124, "Too many %% in pattern"));
      577 +                                                fatal_mksh(gettext("Too many %% in pattern"));
 578  578                                          }
 579  579                                          eq = percent + 1;
 580  580                                          if (eq[0] == (int) nul_char) {
 581  581                                                  MBSTOWCS(wcs_buffer, "");
 582  582                                                  right_hand[i] = (wchar_t *) wsdup(wcs_buffer);
 583  583                                                  i++;
 584  584                                                  break;
 585  585                                          }
 586  586                                  } while ((percent = (wchar_t *) wschr(eq, (int) percent_char)) != NULL);
 587  587                                  if (eq[0] != (int) nul_char) {
↓ open down ↓ 38 lines elided ↑ open up ↑
 626  626          /* Get the macro value. */
 627  627          macro = get_prop(name->prop, macro_prop);
 628  628          if ((macro != NULL) && macro->body.macro.is_conditional) {
 629  629                  conditional_macro_used = true;
 630  630                  /*
 631  631                   * Add this conditional macro to the beginning of the
 632  632                   * global list.
 633  633                   */
 634  634                  add_macro_to_global_list(name);
 635  635                  if (makefile_type == reading_makefile) {
 636      -                        warning_mksh(catgets(libmksdmsi18n_catd, 1, 164, "Conditional macro `%s' referenced in file `%ws', line %d"),
      636 +                        warning_mksh(gettext("Conditional macro `%s' referenced in file `%ws', line %d"),
 637  637                                          name->string_mb, file_being_read, line_number);
 638  638                  }
 639  639          }
 640  640          /* Macro name read and parsed. Expand the value. */
 641  641          if ((macro == NULL) || (macro->body.macro.value == NULL)) {
 642  642                  /* If the value is empty, we just get out of here. */
 643  643                  goto exit;
 644  644          }
 645  645          if (replacement == sh_replace) {
 646  646                  /* If we should do a :sh transform, we expand the command
↓ open down ↓ 158 lines elided ↑ open up ↑
 805  805                              }
 806  806                  }
 807  807                  if (string.free_after_use) {
 808  808                          retmem(string.buffer.start);
 809  809                  }
 810  810          } else {
 811  811                  /*
 812  812                   * This is for the case when the macro name did not
 813  813                   * specify transforms.
 814  814                   */
 815      -                if (!strncmp(name->string_mb, NOCATGETS("GET"), 3)) {
      815 +                if (!strncmp(name->string_mb, "GET", 3)) {
 816  816                          dollarget_seen = true;
 817  817                  }
 818  818                  dollarless_flag = false;
 819  819                  if (!strncmp(name->string_mb, "<", 1) &&
 820  820                      dollarget_seen) {
 821  821                          dollarless_flag = true;
 822  822                          dollarget_seen = false;
 823  823                  }
 824  824                  expand_value_with_daemon(name, macro, destination, cmd);
 825  825          }
↓ open down ↓ 72 lines elided ↑ open up ↑
 898  898   */
 899  899  static void
 900  900  init_arch_macros(void)
 901  901  {
 902  902          String_rec      result_string;
 903  903          wchar_t         wc_buf[STRING_BUFFER_LENGTH];
 904  904          char            mb_buf[STRING_BUFFER_LENGTH];
 905  905          FILE            *pipe;
 906  906          Name            value;
 907  907          int             set_host, set_target;
 908      -        const char      *mach_command = NOCATGETS("/bin/mach");
      908 +        const char      *mach_command = "/bin/mach";
 909  909  
 910  910          set_host = (get_prop(host_arch->prop, macro_prop) == NULL);
 911  911          set_target = (get_prop(target_arch->prop, macro_prop) == NULL);
 912  912  
 913  913          if (set_host || set_target) {
 914  914                  INIT_STRING_FROM_STACK(result_string, wc_buf);
 915  915                  append_char((int) hyphen_char, &result_string);
 916  916  
 917  917                  if ((pipe = popen(mach_command, "r")) == NULL) {
 918      -                        fatal_mksh(catgets(libmksdmsi18n_catd, 1, 185, "Execute of %s failed"), mach_command);
      918 +                        fatal_mksh(gettext("Execute of %s failed"), mach_command);
 919  919                  }
 920  920                  while (fgets(mb_buf, sizeof(mb_buf), pipe) != NULL) {
 921  921                          MBSTOWCS(wcs_buffer, mb_buf);
 922  922                          append_string(wcs_buffer, &result_string, wslen(wcs_buffer));
 923  923                  }
 924  924                  if (pclose(pipe) != 0) {
 925      -                        fatal_mksh(catgets(libmksdmsi18n_catd, 1, 186, "Execute of %s failed"), mach_command);
      925 +                        fatal_mksh(gettext("Execute of %s failed"), mach_command);
 926  926                  }
 927  927  
 928  928                  value = GETNAME(result_string.buffer.start, wslen(result_string.buffer.start));
 929  929  
 930  930                  if (set_host) {
 931  931                          (void) setvar_daemon(host_arch, value, false, no_daemon, true, 0);
 932  932                  }
 933  933                  if (set_target) {
 934  934                          (void) setvar_daemon(target_arch, value, false, no_daemon, true, 0);
 935  935                  }
↓ open down ↓ 17 lines elided ↑ open up ↑
 953  953   */
 954  954  static void
 955  955  init_mach_macros(void)
 956  956  {
 957  957          String_rec      result_string;
 958  958          wchar_t         wc_buf[STRING_BUFFER_LENGTH];
 959  959          char            mb_buf[STRING_BUFFER_LENGTH];
 960  960          FILE            *pipe;
 961  961          Name            value;
 962  962          int             set_host, set_target;
 963      -        const char      *arch_command = NOCATGETS("/bin/arch");
      963 +        const char      *arch_command = "/bin/arch";
 964  964  
 965  965          set_host = (get_prop(host_mach->prop, macro_prop) == NULL);
 966  966          set_target = (get_prop(target_mach->prop, macro_prop) == NULL);
 967  967  
 968  968          if (set_host || set_target) {
 969  969                  INIT_STRING_FROM_STACK(result_string, wc_buf);
 970  970                  append_char((int) hyphen_char, &result_string);
 971  971  
 972  972                  if ((pipe = popen(arch_command, "r")) == NULL) {
 973      -                        fatal_mksh(catgets(libmksdmsi18n_catd, 1, 183, "Execute of %s failed"), arch_command);
      973 +                        fatal_mksh(gettext("Execute of %s failed"), arch_command);
 974  974                  }
 975  975                  while (fgets(mb_buf, sizeof(mb_buf), pipe) != NULL) {
 976  976                          MBSTOWCS(wcs_buffer, mb_buf);
 977  977                          append_string(wcs_buffer, &result_string, wslen(wcs_buffer));
 978  978                  }
 979  979                  if (pclose(pipe) != 0) {
 980      -                        fatal_mksh(catgets(libmksdmsi18n_catd, 1, 184, "Execute of %s failed"), arch_command);
      980 +                        fatal_mksh(gettext("Execute of %s failed"), arch_command);
 981  981                  }
 982  982  
 983  983                  value = GETNAME(result_string.buffer.start, wslen(result_string.buffer.start));
 984  984  
 985  985                  if (set_host) {
 986  986                          (void) setvar_daemon(host_mach, value, false, no_daemon, true, 0);
 987  987                  }
 988  988                  if (set_target) {
 989  989                          (void) setvar_daemon(target_mach, value, false, no_daemon, true, 0);
 990  990                  }
↓ open down ↓ 253 lines elided ↑ open up ↑
1244 1244  found_it:;
1245 1245                  } if (reading_environment || (value == NULL) || !value->dollar) {
1246 1246                          length = 2 + strlen(name->string_mb);
1247 1247                          if (value != NULL) {
1248 1248                                  length += strlen(value->string_mb);
1249 1249                          }
1250 1250                          Property env_prop = maybe_append_prop(name, env_mem_prop);
1251 1251                          /*
1252 1252                           * We use a permanent buffer to reset SUNPRO_DEPENDENCIES value.
1253 1253                           */
1254      -                        if (!strncmp(name->string_mb, NOCATGETS("SUNPRO_DEPENDENCIES"), 19)) {
     1254 +                        if (!strncmp(name->string_mb, "SUNPRO_DEPENDENCIES", 19)) {
1255 1255                                  if (length >= sunpro_dependencies_buf_size) {
1256 1256                                          sunpro_dependencies_buf_size=length*2;
1257 1257                                          if (sunpro_dependencies_buf_size < 4096)
1258 1258                                                  sunpro_dependencies_buf_size = 4096; // Default minimum size
1259 1259                                          if (sunpro_dependencies_buf)
1260 1260                                                  sunpro_dependencies_oldbuf = sunpro_dependencies_buf;
1261 1261                                          sunpro_dependencies_buf=getmem(sunpro_dependencies_buf_size);
1262 1262                                  }
1263 1263                                  env = sunpro_dependencies_buf;
1264 1264                          } else {
↓ open down ↓ 30 lines elided ↑ open up ↑
1295 1295  
1296 1296                  wchar_t * wcb_ha = ha_str.get_string();
1297 1297                  wchar_t * wcb_ta = ta_str.get_string();
1298 1298                  wchar_t * wcb_vr = vr_str.get_string();
1299 1299  
1300 1300                  length = 32 +
1301 1301                    wslen(wcb_ha) +
1302 1302                      wslen(wcb_ta) +
1303 1303                        wslen(wcb_vr);
1304 1304                  old_vr = wcb_vr;
1305      -                MBSTOWCS(wcs_buffer, NOCATGETS("/usr/arch/"));
     1305 +                MBSTOWCS(wcs_buffer, "/usr/arch/");
1306 1306                  if (IS_WEQUALN(old_vr,
1307 1307                                 wcs_buffer,
1308 1308                                 wslen(wcs_buffer))) {
1309 1309                          old_vr = (wchar_t *) wschr(old_vr, (int) colon_char) + 1;
1310 1310                  }
1311 1311                  if ( (ha == ta) || (wslen(wcb_ta) == 0) ) {
1312 1312                          new_value = old_vr;
1313 1313                  } else {
1314 1314                          new_value = ALLOC_WC(length);
1315 1315                          new_value_allocated = true;
1316 1316                          WCSTOMBS(mbs_buffer, old_vr);
1317 1317                          (void) wsprintf(new_value,
1318      -                                        NOCATGETS("/usr/arch/%s/%s:%s"),
     1318 +                                        "/usr/arch/%s/%s:%s",
1319 1319                                          ha->string_mb + 1,
1320 1320                                          ta->string_mb + 1,
1321 1321                                          mbs_buffer);
1322 1322                  }
1323 1323                  if (new_value[0] != 0) {
1324 1324                          (void) setvar_daemon(virtual_root,
1325 1325                                               GETNAME(new_value, FIND_LENGTH),
1326 1326                                               false,
1327 1327                                               no_daemon,
1328 1328                                               true,
1329 1329                                               debug_level);
1330 1330                  }
1331 1331                  if (new_value_allocated) {
1332 1332                          retmem(new_value);
1333 1333                  }
1334 1334          }
1335 1335          return macro;
1336 1336  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX