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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/bin/ar.cc
          +++ new/usr/src/cmd/make/bin/ar.cc
↓ open down ↓ 35 lines elided ↑ open up ↑
  36   36   * formats.  This is kind of tricky, and <ar.h> isnt any help.
  37   37   */
  38   38  
  39   39  /*
  40   40   * Included files
  41   41   */
  42   42  #include <alloca.h>             /* alloca() */
  43   43  #include <ar.h>
  44   44  #include <errno.h>              /* errno */
  45   45  #include <fcntl.h>              /* open() */
       46 +#include <libintl.h>
  46   47  #include <mk/defs.h>
  47   48  #include <mksh/misc.h>          /* retmem_mb() */
  48   49  
  49   50  struct ranlib {
  50   51          union {
  51   52                  off_t   ran_strx;       /* string table index of */
  52   53                  char    *ran_name;      /* symbol defined by */
  53   54          }       ran_un;
  54   55          off_t   ran_off;                /* library member at this offset */
  55   56  };
↓ open down ↓ 160 lines elided ↑ open up ↑
 216  217          }
 217  218          if (open_archive(member->body.member.library->string_mb, &ar) == failed) {
 218  219                  if (errno == ENOENT) {
 219  220                          target->stat.stat_errno = ENOENT;
 220  221                          close_archive(&ar);
 221  222                          if (member->body.member.member == NULL) {
 222  223                                  member->body.member.member = empty_name;
 223  224                          }
 224  225                          return target->stat.time = file_doesnt_exist;
 225  226                  } else {
 226      -                        fatal(catgets(catd, 1, 1, "Can't access archive `%s': %s"),
      227 +                        fatal(gettext("Can't access archive `%s': %s"),
 227  228                                member->body.member.library->string_mb,
 228  229                                errmsg(errno));
 229  230                  }
 230  231          }
 231  232          if (target->stat.time == file_no_time) {
 232  233                  if (read_archive_dir(&ar, member->body.member.library, 
 233  234                                       &long_names_table)
 234  235                      == failed){
 235      -                        fatal(catgets(catd, 1, 2, "Can't access archive `%s': %s"),
      236 +                        fatal(gettext("Can't access archive `%s': %s"),
 236  237                                member->body.member.library->string_mb,
 237  238                                errmsg(errno));
 238  239                  }
 239  240          }
 240  241          if (member->body.member.entry != NULL) {
 241  242                  translate_entry(&ar, target, member,&long_names_table);
 242  243          }
 243  244          close_archive(&ar);
 244  245          if (long_names_table) {
 245  246                  retmem_mb(long_names_table);
↓ open down ↓ 63 lines elided ↑ open up ↑
 309  310                  /*
 310  311                   * Do we have a symbol table? A symbol table is always
 311  312                   * the first member in an archive. In 4.1.x it has the 
 312  313                   * name __.SYMDEF, in SVr4, it has the name "/        "
 313  314                   */
 314  315  /*
 315  316                  MBSTOWCS(wcs_buffer, "/               ");
 316  317                  if (IS_WEQUALN(arp->ar_port.ar_name, wcs_buffer, 16)) {
 317  318   */
 318  319                  if (IS_EQUALN(arp->ar_port.ar_name,
 319      -                              NOCATGETS("/               "),
      320 +                              "/               ",
 320  321                                16)) {
 321  322                          if (sscanf(arp->ar_port.ar_size,
 322  323                                     "%ld",
 323  324                                     &arp->sym_size) != 1) {
 324  325                                  return failed;
 325  326                          }
 326  327                          arp->sym_size += (arp->sym_size & 1); /* round up */
 327  328                          if (fread(buffer, sizeof buffer, 1, arp->fd) != 1) {
 328  329                                  return failed;
 329  330                          }
 330  331                          arp->num_symbols = sgetl(buffer);
 331  332                          arp->sym_begin = ftell(arp->fd);
 332  333                          arp->first_ar_mem = arp->sym_begin +
 333  334                                                  arp->sym_size - sizeof buffer;
 334  335                  }
 335  336                  return succeeded;
 336  337          }
 337      -        fatal(catgets(catd, 1, 3, "`%s' is not an archive"), filename);
      338 +        fatal(gettext("`%s' is not an archive"), filename);
 338  339          /* NOTREACHED */
 339  340          return failed;
 340  341  }
 341  342  
 342  343  
 343  344  /*
 344  345   *      close_archive(arp)
 345  346   *
 346  347   *      Parameters:
 347  348   *              arp             Pointer to ar file description block
↓ open down ↓ 109 lines elided ↑ open up ↑
 457  458                                 sizeof arp->ar_port,
 458  459                                 1,
 459  460                                 arp->fd) != 1) ||
 460  461                          !IS_EQUALN(arp->ar_port.ar_fmag,
 461  462                                     AR_PORT_END_MAGIC,
 462  463                                     sizeof arp->ar_port.ar_fmag)) {
 463  464                              if (feof(arp->fd)) {
 464  465                                      return succeeded;
 465  466                              }
 466  467                              fatal(
 467      -                                catgets(catd, 1, 28, "Read error in archive `%s': invalid archive file member header at 0x%x"),
      468 +                                gettext("Read error in archive `%s': invalid archive file member header at 0x%x"),
 468  469                                  library->string_mb,
 469  470                                  ftell(arp->fd)
 470  471                              );
 471  472                      }
 472  473                      /* If it's a long name, retrieve it from long name table */
 473  474                      if (arp->ar_port.ar_name[0] == '/') {
 474  475                              /*
 475  476                               * "len" is used for hashing the string.
 476  477                               * We're using "ar_member_name_len" instead of
 477  478                               * the actual name length since it's the longest
↓ open down ↓ 26 lines elided ↑ open up ↑
 504  505                      name->is_member = library->is_member;
 505  506                      member = maybe_append_prop(name, member_prop);
 506  507                      member->body.member.library = library;
 507  508                      *--p = (int) nul_char;
 508  509                      if (member->body.member.member == NULL) {
 509  510                              member->body.member.member =
 510  511                                GETNAME(member_string, FIND_LENGTH);
 511  512                      }
 512  513                      if (sscanf(arp->ar_port.ar_date, "%ld", &date) != 1) {
 513  514                              WCSTOMBS(mbs_buffer, name_string);
 514      -                            fatal(catgets(catd, 1, 4, "Bad date field for member `%s' in archive `%s'"),
      515 +                            fatal(gettext("Bad date field for member `%s' in archive `%s'"),
 515  516                                    mbs_buffer,
 516  517                                    library->string_mb);
 517  518                      }
 518  519                      /*
 519  520                       * [tolik] Fix for dmake bug 1234018.
 520  521                       */
 521  522                      if(name->stat.time == file_no_time) {
 522  523                          name->stat.time.tv_sec = date;
 523  524                          name->stat.time.tv_nsec = LONG_MAX;
 524  525                      }
 525  526                      if (sscanf(arp->ar_port.ar_size, "%ld", &ptr) != 1) {
 526  527                              WCSTOMBS(mbs_buffer, name_string);
 527      -                            fatal(catgets(catd, 1, 5, "Bad size field for member `%s' in archive `%s'"),
      528 +                            fatal(gettext("Bad size field for member `%s' in archive `%s'"),
 528  529                                    mbs_buffer,
 529  530                                    library->string_mb);
 530  531                      }
 531  532                      ptr += (ptr & 1);
 532  533                      if (fseek(arp->fd, ptr, 1) != 0) {
 533  534                              goto read_error;
 534  535                      }   
 535  536              }
 536  537              break;
 537  538          }
 538  539  
 539  540          /* Only here if fread() [or IS_EQUALN()] failed and not at EOF */
 540  541  read_error:
 541      -        fatal(catgets(catd, 1, 6, "Read error in archive `%s': %s"),
      542 +        fatal(gettext("Read error in archive `%s': %s"),
 542  543                library->string_mb,
 543  544                errmsg(errno));
 544  545              /* NOTREACHED */
 545  546  }
 546  547  
 547  548  
 548  549  /*
 549  550   *      process_long_names_member(arp)
 550  551   *
 551  552   *      If the archive contains members with names longer
↓ open down ↓ 12 lines elided ↑ open up ↑
 564  565  process_long_names_member(register Ar *arp, char **long_names_table, char *filename)
 565  566  {  
 566  567          Ar_port                 *ar_member_header;
 567  568          int                     table_size;
 568  569  
 569  570          if (fseek(arp->fd, arp->first_ar_mem, 0) != 0) {
 570  571                  return failed;
 571  572          }
 572  573          if ((ar_member_header = 
 573  574               (Ar_port *) alloca((int) sizeof(Ar_port))) == NULL){
 574      -                perror(catgets(catd, 1, 7, "memory allocation failure"));
      575 +                perror(gettext("memory allocation failure"));
 575  576                  return failed;
 576  577          } 
 577  578          int ret = read_member_header(ar_member_header, arp->fd, filename);
 578  579          if (ret == failed) {
 579  580                  return failed;
 580  581          } else if(ret == -1) {
 581  582                  /* There is no member header - empty archive */
 582  583                  return succeeded;
 583  584          }
 584  585          /* Do we have special member containing long names? */
 585  586          if (IS_EQUALN(ar_member_header->ar_name, 
 586      -                      NOCATGETS("//              "),
      587 +                      "//              ",
 587  588                        16)){
 588  589                  if (sscanf(ar_member_header->ar_size,
 589  590                             "%ld",
 590  591                             &table_size) != 1) {
 591  592                          return failed;
 592  593                  }
 593  594                  *long_names_table = (char *) malloc(table_size);
 594  595                  /* Read the list of long member names into the table */
 595  596                  if (fread(*long_names_table, table_size, 1, arp->fd) != 1) {
 596  597                          return failed;
↓ open down ↓ 27 lines elided ↑ open up ↑
 624  625          char                    *csym;           /* string table */
 625  626          ar_port_word            *offend;         /* end of offsets table */
 626  627          int                     date;
 627  628          register wchar_t        *ap;
 628  629          register char           *hp;
 629  630          int                     maxs;
 630  631          int                     offset;
 631  632          char            buffer[4];
 632  633  
 633  634          if (arp->sym_begin == 0L || arp->num_symbols == 0L) {
 634      -                fatal(catgets(catd, 1, 8, "Cannot find symbol `%s' in archive `%s'"),
      635 +                fatal(gettext("Cannot find symbol `%s' in archive `%s'"),
 635  636                        member->body.member.entry->string_mb,
 636  637                        member->body.member.library->string_mb);
 637  638          }
 638  639  
 639  640          if (fseek(arp->fd, arp->sym_begin, 0) != 0) {
 640  641                  goto read_error;
 641  642          }
 642  643          member_string = ALLOC_WC((int) ((int) ar_member_name_len * 2));
 643  644  
 644  645          switch (arp->type) {
↓ open down ↓ 74 lines elided ↑ open up ↑
 719  720                                             1,
 720  721                                             arp->fd) != 1) ||
 721  722                                      !IS_EQUALN(arp->ar_port.ar_fmag,
 722  723                                                 AR_PORT_END_MAGIC,
 723  724                                                 sizeof arp->ar_port.ar_fmag)) {
 724  725                                          goto read_error;
 725  726                                  }
 726  727                                  if (sscanf(arp->ar_port.ar_date,
 727  728                                             "%ld",
 728  729                                             &date) != 1) {
 729      -                                        fatal(catgets(catd, 1, 9, "Bad date field for member `%s' in archive `%s'"),
      730 +                                        fatal(gettext("Bad date field for member `%s' in archive `%s'"),
 730  731                                                arp->ar_port.ar_name,
 731  732                                                target->string_mb);
 732  733                                  }
 733  734                      /* If it's a long name, retrieve it from long name table */
 734  735                      if (arp->ar_port.ar_name[0] == '/') {
 735  736                              sscanf(arp->ar_port.ar_name + 1,
 736  737                                     "%ld",
 737  738                                     &offset);
 738  739                              len = ar_member_name_len;
 739  740                              hp = *long_names_table + offset;
↓ open down ↓ 14 lines elided ↑ open up ↑
 754  755                                          GETNAME(member_string, FIND_LENGTH);
 755  756                                  target->stat.time.tv_sec = date;
 756  757                                  target->stat.time.tv_nsec = LONG_MAX;
 757  758                                  return;
 758  759                          }
 759  760                          offs++;
 760  761                          while(*syms!='\0') syms++;
 761  762                          syms++;
 762  763                  }
 763  764          }
 764      -        fatal(catgets(catd, 1, 10, "Cannot find symbol `%s' in archive `%s'"),
      765 +        fatal(gettext("Cannot find symbol `%s' in archive `%s'"),
 765  766                member->body.member.entry->string_mb,
 766  767                member->body.member.library->string_mb);
 767  768          /*NOTREACHED*/
 768  769  
 769  770  read_error:
 770  771          if (ferror(arp->fd)) {
 771      -                fatal(catgets(catd, 1, 11, "Read error in archive `%s': %s"),
      772 +                fatal(gettext("Read error in archive `%s': %s"),
 772  773                        member->body.member.library->string_mb,
 773  774                        errmsg(errno));
 774  775          } else {
 775      -                fatal(catgets(catd, 1, 12, "Read error in archive `%s': Premature EOF"),
      776 +                fatal(gettext("Read error in archive `%s': Premature EOF"),
 776  777                        member->body.member.library->string_mb);
 777  778          }
 778  779  }
 779  780  
 780  781  /*
 781  782   *      sgetl(buffer)
 782  783   *
 783  784   *      The intent here is to provide a means to make the value of
 784  785   *      bytes in an io-buffer correspond to the value of a long
 785  786   *      in the memory while doing the io a long at a time.
↓ open down ↓ 42 lines elided ↑ open up ↑
 828  829                  return -1;
 829  830          }
 830  831          if ((num != 1) ||
 831  832              !IS_EQUALN(
 832  833                  AR_PORT_END_MAGIC,
 833  834                  header->ar_fmag,
 834  835                  sizeof (header->ar_fmag)
 835  836              )
 836  837          ) {
 837  838                  fatal(
 838      -                        catgets(catd, 1, 28, "Read error in archive `%s': invalid archive file member header at 0x%x"),
      839 +                        gettext("Read error in archive `%s': invalid archive file member header at 0x%x"),
 839  840                          filename,
 840  841                          ftell(fd)
 841  842                  );
 842  843          }
 843  844          return succeeded;
 844  845  }
 845  846  
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX