Print this page
make: unifdef SUN5_0 (defined)

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/bin/ar.cc
          +++ new/usr/src/cmd/make/bin/ar.cc
↓ open down ↓ 38 lines elided ↑ open up ↑
  39   39  /*
  40   40   * Included files
  41   41   */
  42   42  #include <avo/avo_alloca.h>             /* alloca() */
  43   43  #include <ar.h>
  44   44  #include <errno.h>              /* errno */
  45   45  #include <fcntl.h>              /* open() */
  46   46  #include <mk/defs.h>
  47   47  #include <mksh/misc.h>          /* retmem_mb() */
  48   48  
  49      -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
  50   49  struct ranlib {
  51   50          union {
  52   51                  off_t   ran_strx;       /* string table index of */
  53   52                  char    *ran_name;      /* symbol defined by */
  54   53          }       ran_un;
  55   54          off_t   ran_off;                /* library member at this offset */
  56   55  };
  57      -#else
  58      -#include <ranlib.h>
  59      -#endif
  60   56  
  61   57  #if defined(linux)
  62   58  #include <ctype.h>              /* isspace */
  63   59  #else
  64   60  #include <unistd.h>             /* close() */
  65   61  #endif
  66   62  
  67   63  
  68   64  /*
  69   65   * Defined macros
↓ open down ↓ 211 lines elided ↑ open up ↑
 281  277          char                    mag_port[AR_PORT_MAGIC_LENGTH];
 282  278          char                    buffer[4];
 283  279  
 284  280          arp->fd = NULL;
 285  281          fd = open_vroot(filename, O_RDONLY, 0, NULL, VROOT_DEFAULT);
 286  282          if ((fd < 0) || ((arp->fd = fdopen(fd, "r")) == NULL)) {
 287  283                  return failed;
 288  284          }
 289  285          (void) fcntl(fileno(arp->fd), F_SETFD, 1);
 290  286  
 291      -#if !defined(SUN5_0) && !defined(linux) //XXX
 292      -        /* Read enough of the archive to distinguish between the formats */
 293      -        if (fread(mag_5, AR_5_MAGIC_LENGTH, 1, arp->fd) != 1) {
 294      -                return failed;
 295      -        }
 296      -        if (IS_EQUALN(mag_5, AR_5_MAGIC, AR_5_MAGIC_LENGTH)) {
 297      -                arp->type = AR_5;
 298      -                /* Must read in header to set necessary info */
 299      -                if (fseek(arp->fd, 0L, 0) != 0 ||
 300      -                    fread((char *) &arp->arh_5, sizeof (Arh_5), 1, arp->fd) !=
 301      -                                                                        1) {
 302      -                        return failed;
 303      -                }
 304      -                arp->sym_begin = ftell(arp->fd);
 305      -                arp->num_symbols = sgetl(arp->arh_5.ar_syms);
 306      -                arp->first_ar_mem = arp->sym_begin +
 307      -                                        sizeof (Ars_5) * arp->num_symbols;
 308      -                arp->sym_size = 0L;
 309      -                return succeeded;
 310      -        }
 311      -        if (fseek(arp->fd, 0L, 0) != 0) {
 312      -                return failed;
 313      -        }
 314      -#endif
 315  287          if (fread(mag_port, AR_PORT_MAGIC_LENGTH, 1, arp->fd) != 1) {
 316  288                  return failed;
 317  289          }
 318  290          if (IS_EQUALN(mag_port, AR_PORT_MAGIC, AR_PORT_MAGIC_LENGTH)) {
 319  291                  arp->type = AR_PORT;
 320  292                  /*
 321  293                   * Read in first member header to find out if there is 
 322  294                   * a symbol definition table.
 323  295                   */
 324  296  
↓ open down ↓ 12 lines elided ↑ open up ↑
 337  309                   */
 338  310                  arp->sym_size = arp->num_symbols = arp->sym_begin = 0L;
 339  311                  arp->first_ar_mem = ftell(arp->fd) - (long) sizeof (Ar_port);
 340  312  
 341  313                  /*
 342  314                   * Do we have a symbol table? A symbol table is always
 343  315                   * the first member in an archive. In 4.1.x it has the 
 344  316                   * name __.SYMDEF, in SVr4, it has the name "/        "
 345  317                   */
 346  318  /*
 347      -#ifdef SUN5_0
 348      -                MBSTOWCS(wcs_buffer, NOCATGETS("/               "));
 349      -                if (IS_WEQUALN(arp->ar_port.ar_name, wcs_buffer, 16)) {
 350      -#else
 351      -                MBSTOWCS(wcs_buffer, NOCATGETS("__.SYMDEF       "));
      319 +                MBSTOWCS(wcs_buffer, "/               ");
 352  320                  if (IS_WEQUALN(arp->ar_port.ar_name, wcs_buffer, 16)) {
 353      -#endif
 354  321   */
 355      -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
 356  322                  if (IS_EQUALN(arp->ar_port.ar_name,
 357  323                                NOCATGETS("/               "),
 358  324                                16)) {
 359      -#else
 360      -                if (IS_EQUALN(arp->ar_port.ar_name,
 361      -                              NOCATGETS("__.SYMDEF       "),
 362      -                              16)) {
 363      -#endif
 364  325                          if (sscanf(arp->ar_port.ar_size,
 365  326                                     "%ld",
 366  327                                     &arp->sym_size) != 1) {
 367  328                                  return failed;
 368  329                          }
 369  330                          arp->sym_size += (arp->sym_size & 1); /* round up */
 370  331                          if (fread(buffer, sizeof buffer, 1, arp->fd) != 1) {
 371  332                                  return failed;
 372  333                          }
 373  334                          arp->num_symbols = sgetl(buffer);
↓ open down ↓ 35 lines elided ↑ open up ↑
 409  370   *      Parameters:
 410  371   *              arp             Pointer to ar file description block
 411  372   *              library         Name of lib to enter members for.
 412  373   *                              Used to form "lib(member)" string.
 413  374   *              long_names_table table that contains list of members
 414  375   *                              with names > 15 characters long
 415  376   *
 416  377   *      Global variables used:
 417  378   */
 418  379  static Boolean
 419      -#if defined(SUN5_0) || defined(linux) //XXX
 420  380  read_archive_dir(register Ar *arp, Name library, char **long_names_table)
 421      -#else
 422      -read_archive_dir(register Ar *arp, Name library, char **)
 423      -#endif
 424  381  {
 425  382          wchar_t                 *name_string;
 426  383          wchar_t                 *member_string;
 427  384          register long           len;
 428  385          register wchar_t        *p;
 429  386          register char           *q;
 430  387          register Name           name;
 431  388          Property                member;
 432  389          long                    ptr;
 433  390          long                    date;
 434  391  
 435      -#if defined(SUN5_0) || defined(linux) //XXX
 436  392          int                     offset;
 437  393  
 438  394          /*
 439  395           * If any of the members has a name > 15 chars,
 440  396           * it will be found here.
 441  397           */
 442  398          if (process_long_names_member(arp, long_names_table, library->string_mb) == failed) {
 443  399                  return failed;
 444  400          }
 445      -#endif
 446  401          name_string = ALLOC_WC((int) (library->hash.length +
 447  402                                        (int) ar_member_name_len * 2));
 448  403          (void) mbstowcs(name_string, library->string_mb, (int) library->hash.length);
 449  404          member_string = name_string + library->hash.length;
 450  405          *member_string++ = (int) parenleft_char;
 451  406  
 452  407          if (fseek(arp->fd, arp->first_ar_mem, 0) != 0) {
 453  408                  goto read_error;
 454  409          }
 455  410          /* Read the directory using the appropriate format */
↓ open down ↓ 55 lines elided ↑ open up ↑
 511  466                                     sizeof arp->ar_port.ar_fmag)) {
 512  467                              if (feof(arp->fd)) {
 513  468                                      return succeeded;
 514  469                              }
 515  470                              fatal(
 516  471                                  catgets(catd, 1, 28, "Read error in archive `%s': invalid archive file member header at 0x%x"),
 517  472                                  library->string_mb,
 518  473                                  ftell(arp->fd)
 519  474                              );
 520  475                      }
 521      -#if defined(SUN5_0) || defined(linux) //XXX
 522  476                      /* If it's a long name, retrieve it from long name table */
 523  477                      if (arp->ar_port.ar_name[0] == '/') {
 524  478                              /*
 525  479                               * "len" is used for hashing the string.
 526  480                               * We're using "ar_member_name_len" instead of
 527  481                               * the actual name length since it's the longest
 528  482                               * string the "ar" command can handle at this
 529  483                               * point.
 530  484                               */
 531  485                              len = ar_member_name_len;
 532  486                              sscanf(arp->ar_port.ar_name + 1,
 533  487                                     "%ld",
 534  488                                     &offset);
 535  489                              q = *long_names_table + offset;
 536  490                      } else {
 537  491                              q = arp->ar_port.ar_name;   
 538  492                              len = sizeof arp->ar_port.ar_name;
 539  493                      }
 540      -#else
 541      -                    q = arp->ar_port.ar_name;   
 542      -                    len = sizeof arp->ar_port.ar_name;
 543      -#endif
 544  494                      
 545  495                      for (p = member_string;
 546  496                           (len > 0) &&
 547  497                           (*q != (int) nul_char) &&
 548  498                           !isspace(*q) &&
 549  499                           (*q != (int) slash_char);
 550  500                           ) {
 551  501                              MBTOWC(p, q);
 552  502                              p++;
 553  503                              q++;
↓ open down ↓ 223 lines elided ↑ open up ↑
 777  727                                                 sizeof arp->ar_port.ar_fmag)) {
 778  728                                          goto read_error;
 779  729                                  }
 780  730                                  if (sscanf(arp->ar_port.ar_date,
 781  731                                             "%ld",
 782  732                                             &date) != 1) {
 783  733                                          fatal(catgets(catd, 1, 9, "Bad date field for member `%s' in archive `%s'"),
 784  734                                                arp->ar_port.ar_name,
 785  735                                                target->string_mb);
 786  736                                  }
 787      -#if defined(SUN5_0) || defined(linux) //XXX
 788  737                      /* If it's a long name, retrieve it from long name table */
 789  738                      if (arp->ar_port.ar_name[0] == '/') {
 790  739                              sscanf(arp->ar_port.ar_name + 1,
 791  740                                     "%ld",
 792  741                                     &offset);
 793  742                              len = ar_member_name_len;
 794  743                              hp = *long_names_table + offset;
 795  744                      } else {
 796  745                              len = sizeof arp->ar_port.ar_name;
 797  746                              hp = arp->ar_port.ar_name;  
 798  747                      }
 799      -#else
 800      -                    hp = arp->ar_port.ar_name;  
 801      -#endif
 802  748                                  ap = member_string;
 803  749                                  while (*hp &&
 804  750                                         (*hp != (int) slash_char) &&
 805  751                                         (ap < &member_string[len])) {
 806  752                                          MBTOWC(ap, hp);
 807  753                                          ap++;
 808  754                                          hp++;
 809  755                                  }
 810  756                                  *ap = (int) nul_char;
 811  757                                  member->body.member.member =
↓ open down ↓ 92 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX