VirtualBox

Changeset 3140 in kBuild for trunk/src/kmk/ar.c


Ignore:
Timestamp:
Mar 14, 2018 9:28:10 PM (7 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

  • trunk/src/kmk/ar.c

    r2591 r3140  
    1 /* Interface to `ar' archives for GNU Make.
    2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
    4 2010 Free Software Foundation, Inc.
     1/* Interface to 'ar' archives for GNU Make.
     2Copyright (C) 1988-2016 Free Software Foundation, Inc.
    53
    64This file is part of GNU Make.
     
    1816this program.  If not, see <http://www.gnu.org/licenses/>.  */
    1917
    20 #include "make.h"
    21 
    22 #ifndef NO_ARCHIVES
     18#include "makeint.h"
     19
     20#ifndef NO_ARCHIVES
    2321
    2422#include "filedef.h"
     
    2725
    2826/* Return nonzero if NAME is an archive-member reference, zero if not.  An
    29    archive-member reference is a name like `lib(member)' where member is a
     27   archive-member reference is a name like 'lib(member)' where member is a
    3028   non-empty string.
    31    If a name like `lib((entry))' is used, a fatal error is signaled at
     29   If a name like 'lib((entry))' is used, a fatal error is signaled at
    3230   the attempt to use this unsupported feature.  */
    3331
     
    4644
    4745  if (p[1] == '(' && end[-1] == ')')
    48     fatal (NILF, _("attempt to use unsupported feature: `%s'"), name);
     46    OS (fatal, NILF, _("attempt to use unsupported feature: '%s'"), name);
    4947
    5048  return 1;
     
    6462  p = strchr (*arname_p, '(');
    6563  *(p++) = '\0';
    66   p[strlen(p) - 1] = '\0';
     64  p[strlen (p) - 1] = '\0';
    6765  *memname_p = p;
    6866}
     
    7068
    7169
    72 /* This function is called by `ar_scan' to find which member to look at.  */
     70/* This function is called by 'ar_scan' to find which member to look at.  */
    7371
    7472/* ARGSUSED */
    7573static long int
    7674ar_member_date_1 (int desc UNUSED, const char *mem, int truncated,
    77                   long int hdrpos UNUSED, long int datapos UNUSED,
     75                  long int hdrpos UNUSED, long int datapos UNUSED,
    7876                  long int size UNUSED, long int date,
    79                   int uid UNUSED, int gid UNUSED, int mode UNUSED,
    80                   const void *name)
     77                  int uid UNUSED, int gid UNUSED, unsigned int mode UNUSED,
     78                  const void *name)
    8179{
    8280  return ar_name_equal (name, mem, truncated) ? date : 0;
     
    125123ar_touch (const char *name)
    126124{
    127   error (NILF, _("touch archive member is not available on VMS"));
     125  O (error, NILF, _("touch archive member is not available on VMS"));
    128126  return -1;
    129127}
     
    149147    {
    150148    case -1:
    151       error (NILF, _("touch: Archive `%s' does not exist"), arname);
     149      OS (error, NILF, _("touch: Archive '%s' does not exist"), arname);
    152150      break;
    153151    case -2:
    154       error (NILF, _("touch: `%s' is not a valid archive"), arname);
     152      OS (error, NILF, _("touch: '%s' is not a valid archive"), arname);
    155153      break;
    156154    case -3:
     
    158156      break;
    159157    case 1:
    160       error (NILF,
    161              _("touch: Member `%s' does not exist in `%s'"), memname, arname);
     158      OSS (error, NILF,
     159           _("touch: Member '%s' does not exist in '%s'"), memname, arname);
    162160      break;
    163161    case 0:
     
    165163      break;
    166164    default:
    167       error (NILF,
    168              _("touch: Bad return code from ar_member_touch on `%s'"), name);
     165      OS (error, NILF,
     166          _("touch: Bad return code from ar_member_touch on '%s'"), name);
    169167    }
    170168
     
    176174
    177175
    178 /* State of an `ar_glob' run, passed to `ar_glob_match'.  */
     176/* State of an 'ar_glob' run, passed to 'ar_glob_match'.  */
     177
     178/* On VMS, (object) modules in libraries do not have suffixes. That is, to
     179   find a match for a pattern, the pattern must not have any suffix. So the
     180   suffix of the pattern is saved and the pattern is stripped (ar_glob).
     181   If there is a match and the match, which is a module name, is added to
     182   the chain, the saved suffix is added back to construct a source filename
     183   (ar_glob_match). */
    179184
    180185struct ar_glob_state
     
    182187    const char *arname;
    183188    const char *pattern;
     189#ifdef VMS
     190    char *suffix;
     191#endif
    184192    unsigned int size;
    185193    struct nameseq *chain;
     
    187195  };
    188196
    189 /* This function is called by `ar_scan' to match one archive
     197/* This function is called by 'ar_scan' to match one archive
    190198   element against the pattern in STATE.  */
    191199
    192200static long int
    193201ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED,
    194                long int hdrpos UNUSED, long int datapos UNUSED,
     202               long int hdrpos UNUSED, long int datapos UNUSED,
    195203               long int size UNUSED, long int date UNUSED, int uid UNUSED,
    196                int gid UNUSED, int mode UNUSED, const void *arg)
     204               int gid UNUSED, unsigned int mode UNUSED, const void *arg)
    197205{
    198206  struct ar_glob_state *state = (struct ar_glob_state *)arg;
     
    202210      /* We have a match.  Add it to the chain.  */
    203211      struct nameseq *new = xcalloc (state->size);
    204       new->name = strcache_add (concat (4, state->arname, "(", mem, ")"));
     212#ifdef VMS
     213      if (state->suffix)
     214        new->name = strcache_add(
     215            concat(5, state->arname, "(", mem, state->suffix, ")"));
     216      else
     217#endif
     218        new->name = strcache_add(concat(4, state->arname, "(", mem, ")"));
    205219      new->next = state->chain;
    206220      state->chain = new;
     
    214228   Metacharacters can be quoted with backslashes if QUOTE is nonzero.  */
    215229static int
    216 glob_pattern_p (const char *pattern, int quote)
     230ar_glob_pattern_p (const char *pattern, int quote)
    217231{
    218232  const char *p;
     
    224238      case '?':
    225239      case '*':
    226         return 1;
     240        return 1;
    227241
    228242      case '\\':
    229         if (quote)
    230           ++p;
    231         break;
     243        if (quote)
     244          ++p;
     245        break;
    232246
    233247      case '[':
    234         opened = 1;
    235         break;
     248        opened = 1;
     249        break;
    236250
    237251      case ']':
    238         if (opened)
    239           return 1;
    240         break;
     252        if (opened)
     253          return 1;
     254        break;
    241255      }
    242256
     
    254268  const char **names;
    255269  unsigned int i;
    256 
    257   if (! glob_pattern_p (member_pattern, 1))
     270#ifdef VMS
     271  char *vms_member_pattern;
     272#endif
     273  if (! ar_glob_pattern_p (member_pattern, 1))
    258274    return 0;
    259275
     
    262278  state.arname = arname;
    263279  state.pattern = member_pattern;
     280#ifdef VMS
     281    {
     282      /* In a copy of the pattern, find the suffix, save it and  remove it from
     283         the pattern */
     284      char *lastdot;
     285      vms_member_pattern = xstrdup(member_pattern);
     286      lastdot = strrchr(vms_member_pattern, '.');
     287      state.suffix = lastdot;
     288      if (lastdot)
     289        {
     290          state.suffix = xstrdup(lastdot);
     291          *lastdot = 0;
     292        }
     293      state.pattern = vms_member_pattern;
     294    }
     295#endif
    264296  state.size = size;
    265297  state.chain = 0;
    266298  state.n = 0;
    267299  ar_scan (arname, ar_glob_match, &state);
     300
     301#ifdef VMS
     302  /* Deallocate any duplicated string */
     303  free(vms_member_pattern);
     304  if (state.suffix)
     305    {
     306      free(state.suffix);
     307    }
     308#endif
    268309
    269310  if (state.chain == 0)
     
    288329}
    289330
    290 #endif  /* Not NO_ARCHIVES.  */
     331#endif  /* Not NO_ARCHIVES.  */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette