Ignore:
Timestamp:
May 23, 2007, 7:31:19 AM (18 years ago)
Author:
bird
Message:

Merged with the 2007-05-23 CVS. Added rsort and fixed a couple of windows build issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gmakenew/read.c

    r530 r903  
    3838#include <pwd.h>
    3939#else
    40 struct passwd *getpwnam PARAMS ((char *name));
     40struct passwd *getpwnam (char *name);
    4141#endif
    4242#endif
     
    8989/* Default directories to search for include files in  */
    9090
    91 static char *default_include_directories[] =
     91static const char *default_include_directories[] =
    9292  {
    9393#if defined(WINDOWS32) && !defined(INCLUDEDIR)
    94 /*
    95  * This completely up to the user when they install MSVC or other packages.
    96  * This is defined as a placeholder.
    97  */
    98 #define INCLUDEDIR "."
     94/* This completely up to the user when they install MSVC or other packages.
     95   This is defined as a placeholder.  */
     96# define INCLUDEDIR "."
    9997#endif
    10098    INCLUDEDIR,
     
    109107/* List of directories to search for include files in  */
    110108
    111 static char **include_directories;
     109static const char **include_directories;
    112110
    113111/* Maximum length of an element of the above.  */
     
    124122static struct dep *read_makefiles = 0;
    125123
    126 static int eval_makefile PARAMS ((char *filename, int flags));
    127 static int eval PARAMS ((struct ebuffer *buffer, int flags));
    128 
    129 static long readline PARAMS ((struct ebuffer *ebuf));
    130 static void do_define PARAMS ((char *name, unsigned int namelen,
    131                                enum variable_origin origin,
    132                                struct ebuffer *ebuf));
    133 static int conditional_line PARAMS ((char *line, int len, const struct floc *flocp));
    134 static void record_files PARAMS ((struct nameseq *filenames, char *pattern, char *pattern_percent,
    135                         struct dep *deps, unsigned int cmds_started, char *commands,
    136                         unsigned int commands_idx, int two_colon,
    137                         const struct floc *flocp));
    138 static void record_target_var PARAMS ((struct nameseq *filenames, char *defn,
    139                                        enum variable_origin origin,
    140                                        int enabled,
    141                                        const struct floc *flocp));
    142 static enum make_word_type get_next_mword PARAMS ((char *buffer, char *delim,
    143                         char **startp, unsigned int *length));
    144 static void remove_comments PARAMS ((char *line));
    145 static char *find_char_unquote PARAMS ((char *string, int stop1,
    146                                         int stop2, int blank, int ignorevars));
     124static int eval_makefile (const char *filename, int flags);
     125static int eval (struct ebuffer *buffer, int flags);
     126
     127static long readline (struct ebuffer *ebuf);
     128static void do_define (char *name, unsigned int namelen,
     129                       enum variable_origin origin, struct ebuffer *ebuf);
     130static int conditional_line (char *line, int len, const struct floc *flocp);
     131static void record_files (struct nameseq *filenames, const char *pattern,
     132                          const char *pattern_percent, struct dep *deps,
     133                          unsigned int cmds_started, char *commands,
     134                          unsigned int commands_idx, int two_colon,
     135                          const struct floc *flocp);
     136static void record_target_var (struct nameseq *filenames, char *defn,
     137                               enum variable_origin origin, int enabled,
     138                               const struct floc *flocp);
     139static enum make_word_type get_next_mword (char *buffer, char *delim,
     140                                           char **startp, unsigned int *length);
     141static void remove_comments (char *line);
     142static char *find_char_unquote (char *string, int stop1, int stop2,
     143                                int blank, int ignorevars);
    147144
    148145
     
    150147
    151148struct dep *
    152 read_all_makefiles (char **makefiles)
     149read_all_makefiles (const char **makefiles)
    153150{
    154151  unsigned int num_makefiles = 0;
     
    184181    p = value;
    185182
    186     while ((name = find_next_token (&p, &length)) != 0)
     183    while ((name = find_next_token ((const char **)&p, &length)) != 0)
    187184      {
    188185        if (*p != '\0')
     
    227224# else
    228225        { "makefile.vms", "gnumakefile.", "makefile.", 0 };
    229 # endif 
     226# endif
    230227#else
    231228#ifdef _AMIGA
     
    264261            {
    265262              struct dep *d = alloc_dep ();
    266               d->file = enter_file (*p);
     263              d->file = enter_file (strcache_add (*p));
    267264              d->file->dontcare = 1;
    268265              /* Tell update_goal_chain to bail out as soon as this file is
     
    291288  struct conditionals *save = conditionals;
    292289
    293   bzero ((char *) new, sizeof (*new));
     290  memset (new, '\0', sizeof (*new));
    294291  conditionals = new;
    295292
     
    314311
    315312static int
    316 eval_makefile (char *filename, int flags)
     313eval_makefile (const char *filename, int flags)
    317314{
    318315  struct dep *deps;
     
    320317  const struct floc *curfile;
    321318  char *expanded = 0;
    322   char *included = 0;
    323319  int makefile_errno;
    324320  int r;
    325321
    326   ebuf.floc.filenm = strcache_add (filename);
     322  filename = strcache_add (filename);
     323  ebuf.floc.filenm = filename;
    327324  ebuf.floc.lineno = 1;
    328325
     
    361358  if (ebuf.fp == 0 && (flags & RM_INCLUDED) && *filename != '/')
    362359    {
    363       register unsigned int i;
     360      unsigned int i;
    364361      for (i = 0; include_directories[i] != 0; ++i)
    365362        {
    366           included = concat (include_directories[i], "/", filename);
     363          const char *included = concat (include_directories[i], "/", filename);
    367364          ebuf.fp = fopen (included, "r");
    368365          if (ebuf.fp)
    369366            {
    370               filename = included;
     367              filename = strcache_add (included);
    371368              break;
    372369            }
    373           free (included);
    374370        }
    375       /* If we're not using it, we already freed it above.  */
    376       if (filename != included)
    377         included = 0;
    378371    }
    379372
     
    384377  deps->file = lookup_file (filename);
    385378  if (deps->file == 0)
    386     deps->file = enter_file (xstrdup (filename));
     379    deps->file = enter_file (filename);
    387380  filename = deps->file->name;
    388381  deps->changed = flags;
     
    392385  if (expanded)
    393386    free (expanded);
    394   if (included)
    395     free (included);
    396387
    397388  /* If the makefile can't be found at all, give up entirely.  */
     
    463454#ifdef CONFIG_WITH_INCLUDEDEP
    464455/* no nonsense dependency file including. */
    465 void 
    466 eval_include_dep(char *name, struct floc *f)
     456void
     457eval_include_dep (const char *name, struct floc *f)
    467458{
    468459  FILE *fp;
     
    501492  }
    502493
    503   /* allocate a buffer and read the file. \r\n -> \n conversion 
     494  /* allocate a buffer and read the file. \r\n -> \n conversion
    504495     make this intersting ... */
    505496  buf = xmalloc (max_size + 1);
     
    544535  long nlines = 0;
    545536  int two_colon = 0;
    546   char *pattern = 0, *pattern_percent;
     537  const char *pattern = 0;
     538  const char *pattern_percent;
    547539  struct floc *fstart;
    548540  struct floc fi;
     
    561553      commands_idx = 0;                                                       \
    562554      no_targets = 0;                                                         \
    563       if (pattern) { free(pattern); pattern = 0; }                            \
     555      pattern = 0;                                                            \
    564556    } while (0)
    565557
     
    586578      unsigned int linelen;
    587579      char *line;
    588       int len;
     580      unsigned int wlen;
    589581      char *p;
    590582      char *p2;
     
    607599      /* Check for a shell command line first.
    608600         If it is not one, we can stop treating tab specially.  */
    609       if (line[0] == '\t')
     601      if (line[0] == cmd_prefix)
    610602        {
    611603          if (no_targets)
     
    632624                  commands = xrealloc (commands, commands_len);
    633625                }
    634               bcopy (line, &commands[commands_idx], linelen);
     626              memcpy (&commands[commands_idx], line, linelen);
    635627              commands_idx += linelen;
    636628              commands[commands_idx++] = '\n';
     
    648640          collapsed_length = linelen+1;
    649641          if (collapsed)
    650             free ((char *)collapsed);
    651           collapsed = (char *) xmalloc (collapsed_length);
     642            free (collapsed);
     643          collapsed = xmalloc (collapsed_length);
    652644        }
    653645      strcpy (collapsed, line);
     
    657649
    658650      /* Compare a word, both length and contents. */
    659 #define word1eq(s)      (len == sizeof(s)-1 && strneq (s, p, sizeof(s)-1))
     651#define word1eq(s)      (wlen == sizeof(s)-1 && strneq (s, p, sizeof(s)-1))
    660652      p = collapsed;
    661653      while (isspace ((unsigned char)*p))
     
    672664      for (p2 = p+1; *p2 != '\0' && !isspace ((unsigned char)*p2); ++p2)
    673665        ;
    674       len = p2 - p;
     666      wlen = p2 - p;
    675667
    676668      /* Find the start of the second token.  If it looks like a target or
     
    695687      if (!in_ignored_define)
    696688        {
    697           int i = conditional_line (p, len, fstart);
     689          int i = conditional_line (p, wlen, fstart);
    698690          if (i != -2)
    699691            {
     
    787779              else
    788780                {
    789                   unsigned int len;
     781                  unsigned int l;
     782                  const char *cp;
    790783                  char *ap;
    791784
    792785                  /* Expand the line so we can use indirect and constructed
    793786                     variable names in an export command.  */
    794                   p2 = ap = allocated_variable_expand (p2);
    795 
    796                   for (p = find_next_token (&p2, &len); p != 0;
    797                        p = find_next_token (&p2, &len))
     787                  cp = ap = allocated_variable_expand (p2);
     788
     789                  for (p = find_next_token (&cp, &l); p != 0;
     790                       p = find_next_token (&cp, &l))
    798791                    {
    799                       v = lookup_variable (p, len);
     792                      v = lookup_variable (p, l);
    800793                      if (v == 0)
    801                         v = define_variable_loc (p, len, "", o_file, 0,
    802                                                  fstart);
     794                        v = define_variable_loc (p, l, "", o_file, 0, fstart);
    803795                      v->export = v_export;
    804796                    }
     
    816808          else
    817809            {
    818               unsigned int len;
     810              unsigned int l;
    819811              struct variable *v;
     812              const char *cp;
    820813              char *ap;
    821814
    822815              /* Expand the line so we can use indirect and constructed
    823816                 variable names in an unexport command.  */
    824               p2 = ap = allocated_variable_expand (p2);
    825 
    826               for (p = find_next_token (&p2, &len); p != 0;
    827                    p = find_next_token (&p2, &len))
     817              cp = ap = allocated_variable_expand (p2);
     818
     819              for (p = find_next_token (&cp, &l); p != 0;
     820                   p = find_next_token (&cp, &l))
    828821                {
    829                   v = lookup_variable (p, len);
     822                  v = lookup_variable (p, l);
    830823                  if (v == 0)
    831                     v = define_variable_loc (p, len, "", o_file, 0, fstart);
     824                    v = define_variable_loc (p, l, "", o_file, 0, fstart);
    832825
    833826                  v->export = v_noexport;
     
    842835      if (word1eq ("vpath"))
    843836        {
    844           char *pattern;
    845           unsigned int len;
    846           p2 = variable_expand (p2);
    847           p = find_next_token (&p2, &len);
     837          const char *cp;
     838          char *vpat;
     839          unsigned int l;
     840          cp = variable_expand (p2);
     841          p = find_next_token (&cp, &l);
    848842          if (p != 0)
    849843            {
    850               pattern = savestring (p, len);
    851               p = find_next_token (&p2, &len);
     844              vpat = savestring (p, l);
     845              p = find_next_token (&cp, &l);
    852846              /* No searchpath means remove all previous
    853847                 selective VPATH's with the same pattern.  */
     
    855849          else
    856850            /* No pattern means remove all previous selective VPATH's.  */
    857             pattern = 0;
    858           construct_vpath_list (pattern, p);
    859           if (pattern != 0)
    860             free (pattern);
     851            vpat = 0;
     852          construct_vpath_list (vpat, p);
     853          if (vpat != 0)
     854            free (vpat);
    861855
    862856          goto rule_complete;
     
    926920            {
    927921              struct nameseq *next = files->next;
    928               char *name = files->name;
     922              const char *name = files->name;
    929923              int r;
    930924
    931               free ((char *)files);
     925              free (files);
    932926              files = next;
    933927
     
    936930              if (!r && !noerror)
    937931                error (fstart, "%s: %s", name, strerror (errno));
    938               free (name);
    939932            }
    940933
     
    952945         was no preceding target, and the line might have been usable as a
    953946         variable definition.  But now we know it is definitely lossage.  */
    954       if (line[0] == '\t')
     947      if (line[0] == cmd_prefix)
    955948        fatal(fstart, _("commands commence before first target"));
    956949
     
    970963        int exported;
    971964        char *cmdleft, *semip, *lb_next;
    972         unsigned int len, plen = 0;
     965        unsigned int plen = 0;
    973966        char *colonp;
    974967        const char *end, *beg; /* Helpers for whitespace stripping. */
     
    999992           beginning, expanding as we go, and looking for "interesting"
    1000993           chars.  The first word is always expandable.  */
    1001         wtype = get_next_mword(line, NULL, &lb_next, &len);
     994        wtype = get_next_mword(line, NULL, &lb_next, &wlen);
    1002995        switch (wtype)
    1003996          {
     
    10201013          }
    10211014
    1022         p2 = variable_expand_string(NULL, lb_next, len);
     1015        p2 = variable_expand_string(NULL, lb_next, wlen);
    10231016
    10241017        while (1)
    10251018          {
    1026             lb_next += len;
     1019            lb_next += wlen;
    10271020            if (cmdleft == 0)
    10281021              {
     
    10691062              break;
    10701063
    1071             wtype = get_next_mword(lb_next, NULL, &lb_next, &len);
     1064            wtype = get_next_mword(lb_next, NULL, &lb_next, &wlen);
    10721065            if (wtype == w_eol)
    10731066              break;
     
    10751068            p2 += strlen(p2);
    10761069            *(p2++) = ' ';
    1077             p2 = variable_expand_string(p2, lb_next, len);
     1070            p2 = variable_expand_string(p2, lb_next, wlen);
    10781071            /* We don't need to worry about cmdleft here, because if it was
    10791072               found in the variable_buffer the entire buffer has already
     
    11301123            unsigned int l = p2 - variable_buffer;
    11311124            plen = strlen (p2);
    1132             (void) variable_buffer_output (p2+plen,
    1133                                            lb_next, strlen (lb_next)+1);
     1125            variable_buffer_output (p2+plen, lb_next, strlen (lb_next)+1);
    11341126            p2 = variable_buffer + l;
    11351127          }
     
    11381130           comes after it looks like a variable definition.  */
    11391131
    1140         wtype = get_next_mword (p2, NULL, &p, &len);
     1132        wtype = get_next_mword (p2, NULL, &p, &wlen);
    11411133
    11421134        v_origin = o_file;
     
    11471139              {
    11481140                v_origin = o_override;
    1149                 wtype = get_next_mword (p+len, NULL, &p, &len);
     1141                wtype = get_next_mword (p+wlen, NULL, &p, &wlen);
    11501142              }
    11511143            else if (word1eq ("export"))
    11521144              {
    11531145                exported = 1;
    1154                 wtype = get_next_mword (p+len, NULL, &p, &len);
     1146                wtype = get_next_mword (p+wlen, NULL, &p, &wlen);
    11551147              }
    11561148          }
    11571149
    11581150        if (wtype != w_eol)
    1159           wtype = get_next_mword (p+len, NULL, NULL, NULL);
     1151          wtype = get_next_mword (p+wlen, NULL, NULL, NULL);
    11601152
    11611153        if (wtype == w_varassign)
     
    12321224        {
    12331225          int check_again;
    1234 
    12351226          do {
    12361227            check_again = 0;
     
    12541245            else if (target->next != 0)
    12551246              fatal (fstart, _("multiple target patterns (target `%s')"), target->name); /* bird */
     1247            pattern_percent = find_percent_cached (&target->name);
    12561248            pattern = target->name;
    1257             pattern_percent = find_percent (pattern);
    12581249            if (pattern_percent == 0)
    12591250              fatal (fstart, _("target pattern contains no `%%' (target `%s')"), target->name); /* bird */
    1260             free ((char *)target);
     1251            free (target);
    12611252          }
    12621253        else
     
    12721263            /* Put all the prerequisites here; they'll be parsed later.  */
    12731264            deps = alloc_dep ();
    1274             deps->name = savestring (beg, end - beg + 1);
     1265            deps->name = strcache_add_len (beg, end - beg + 1);
    12751266          }
    12761267        else
     
    12811272          {
    12821273            /* Semicolon means rest of line is a command.  */
    1283             unsigned int len = strlen (cmdleft);
     1274            unsigned int l = strlen (cmdleft);
    12841275
    12851276            cmds_started = fstart->lineno;
    12861277
    12871278            /* Add this command line to the buffer.  */
    1288             if (len + 2 > commands_len)
     1279            if (l + 2 > commands_len)
    12891280              {
    1290                 commands_len = (len + 2) * 2;
    1291                 commands = (char *) xrealloc (commands, commands_len);
     1281                commands_len = (l + 2) * 2;
     1282                commands = xrealloc (commands, commands_len);
    12921283              }
    1293             bcopy (cmdleft, commands, len);
    1294             commands_idx += len;
     1284            memcpy (commands, cmdleft, l);
     1285            commands_idx += l;
    12951286            commands[commands_idx++] = '\n';
    12961287          }
     
    13141305        if (**default_goal_name == '\0' && set_default)
    13151306          {
    1316             char* name;
     1307            const char *name;
    13171308            struct dep *d;
    13181309            struct nameseq *t = filenames;
     
    13491340                    for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)
    13501341                      {
    1351                         register unsigned int len = strlen (dep_name (d2));
    1352                         if (!strneq (name, dep_name (d2), len))
     1342                        unsigned int l = strlen (dep_name (d2));
     1343                        if (!strneq (name, dep_name (d2), l))
    13531344                          continue;
    1354                         if (streq (name + len, dep_name (d)))
     1345                        if (streq (name + l, dep_name (d)))
    13551346                          {
    13561347                            reject = 1;
     
    13911382
    13921383  if (collapsed)
    1393     free ((char *) collapsed);
    1394   free ((char *) commands);
     1384    free (collapsed);
     1385  free (commands);
    13951386
    13961387  return 1;
     
    14261417  int nlevels = 1;
    14271418  unsigned int length = 100;
    1428   char *definition = (char *) xmalloc (length);
     1419  char *definition = xmalloc (length);
    14291420  unsigned int idx = 0;
    14301421  char *p;
    14311422
    14321423  /* Expand the variable name.  */
    1433   char *var = (char *) alloca (namelen + 1);
    1434   bcopy (name, var, namelen);
     1424  char *var = alloca (namelen + 1);
     1425  memcpy (var, name, namelen);
    14351426  var[namelen] = '\0';
    14361427  var = variable_expand (var);
     
    14581449
    14591450      /* Stop if we find an 'endef' */
    1460       if (line[0] != '\t')
     1451      if (line[0] != cmd_prefix)
    14611452        {
    14621453          p = next_token (line);
     
    15011492        {
    15021493          length = (idx + len) * 2;
    1503           definition = (char *) xrealloc (definition, length + 1);
     1494          definition = xrealloc (definition, length + 1);
    15041495        }
    15051496
    1506       bcopy (line, &definition[idx], len);
     1497      memcpy (&definition[idx], line, len);
    15071498      idx += len;
    15081499      /* Separate lines with a newline.  */
     
    16321623    {
    16331624      conditionals->allocated = 5;
    1634       conditionals->ignoring = (char *) xmalloc (conditionals->allocated);
    1635       conditionals->seen_else = (char *) xmalloc (conditionals->allocated);
     1625      conditionals->ignoring = xmalloc (conditionals->allocated);
     1626      conditionals->seen_else = xmalloc (conditionals->allocated);
    16361627    }
    16371628
     
    16401631    {
    16411632      conditionals->allocated += 5;
    1642       conditionals->ignoring = (char *)
    1643         xrealloc (conditionals->ignoring, conditionals->allocated);
    1644       conditionals->seen_else = (char *)
    1645         xrealloc (conditionals->seen_else, conditionals->allocated);
     1633      conditionals->ignoring = xrealloc (conditionals->ignoring,
     1634                                        conditionals->allocated);
     1635      conditionals->seen_else = xrealloc (conditionals->seen_else,
     1636                                          conditionals->allocated);
    16461637    }
    16471638
     
    16871678  else
    16881679    {
    1689       /* "Ifeq" or "ifneq".  */
     1680      /* "ifeq" or "ifneq".  */
    16901681      char *s1, *s2;
    1691       unsigned int len;
     1682      unsigned int l;
    16921683      char termin = *line == '(' ? ',' : *line;
    16931684
     
    17291720      /* We must allocate a new copy of the expanded string because
    17301721         variable_expand re-uses the same buffer.  */
    1731       len = strlen (s2);
    1732       s1 = (char *) alloca (len + 1);
    1733       bcopy (s2, s1, len + 1);
     1722      l = strlen (s2);
     1723      s1 = alloca (l + 1);
     1724      memcpy (s1, s2, l + 1);
    17341725
    17351726      if (termin != ',')
     
    17441735      if (termin == ')')
    17451736        {
    1746           register int count = 0;
     1737          int count = 0;
    17471738          s2 = next_token (line);
    17481739          for (line = s2; *line != '\0'; ++line)
     
    18791870    {
    18801871      struct variable *v;
    1881       register char *name = filenames->name;
    1882       char *fname;
    1883       char *percent;
     1872      const char *name = filenames->name;
     1873      const char *fname;
     1874      const char *percent;
    18841875      struct pattern_var *p;
    18851876
    18861877      nextf = filenames->next;
    1887       free ((char *) filenames);
     1878      free (filenames);
    18881879
    18891880      /* If it's a pattern target, then add it to the pattern-specific
    18901881         variable list.  */
    1891       percent = find_percent (name);
     1882      percent = find_percent_cached (&name);
    18921883      if (percent)
    18931884        {
     
    19171908          f = lookup_file (name);
    19181909          if (!f)
    1919             f = enter_file (name);
     1910            f = enter_file (strcache_add (name));
    19201911          else if (f->double_colon)
    19211912            f = f->double_colon;
     
    19541945            }
    19551946        }
    1956 
    1957       /* Free name if not needed further.  */
    1958       if (name != fname && (name < fname || name > fname + strlen (fname)))
    1959         free (name);
    19601947    }
    19611948}
     
    19741961
    19751962static void
    1976 record_files (struct nameseq *filenames, char *pattern, char *pattern_percent,
    1977               struct dep *deps, unsigned int cmds_started, char *commands,
     1963record_files (struct nameseq *filenames, const char *pattern,
     1964              const char *pattern_percent, struct dep *deps,
     1965              unsigned int cmds_started, char *commands,
    19781966              unsigned int commands_idx, int two_colon,
    19791967              const struct floc *flocp)
     
    19821970  int implicit = 0;
    19831971  unsigned int max_targets = 0, target_idx = 0;
    1984   char **targets = 0, **target_percents = 0;
     1972  const char **targets = 0, **target_percents = 0;
    19851973  struct commands *cmds;
    19861974
     
    19941982  if (commands_idx > 0)
    19951983    {
    1996       cmds = (struct commands *) xmalloc (sizeof (struct commands));
     1984      cmds = xmalloc (sizeof (struct commands));
    19971985      cmds->fileinfo.filenm = flocp->filenm;
    19981986      cmds->fileinfo.lineno = cmds_started;
     
    20051993  for (; filenames != 0; filenames = nextf)
    20061994    {
    2007       char *name = filenames->name;
     1995      const char *name = filenames->name;
    20081996      struct file *f;
    20091997      struct dep *this = 0;
    2010       char *implicit_percent;
     1998      const char *implicit_percent;
    20111999
    20122000      nextf = filenames->next;
     
    20212009        second_expansion = 1;
    20222010
    2023       implicit_percent = find_percent (name);
     2011      implicit_percent = find_percent_cached (&name);
    20242012      implicit |= implicit_percent != 0;
    20252013
    2026       if (implicit && pattern != 0)
    2027         fatal (flocp, _("mixed implicit and static pattern rules"));
    2028 
    2029       if (implicit && implicit_percent == 0)
    2030         fatal (flocp, _("mixed implicit and normal rules"));
    2031 
    20322014      if (implicit)
    2033         {
     2015        {
     2016          if (pattern != 0)
     2017            fatal (flocp, _("mixed implicit and static pattern rules"));
     2018
     2019          if (implicit_percent == 0)
     2020            fatal (flocp, _("mixed implicit and normal rules"));
     2021
    20342022          if (targets == 0)
    20352023            {
    20362024              max_targets = 5;
    2037               targets = (char **) xmalloc (5 * sizeof (char *));
    2038               target_percents = (char **) xmalloc (5 * sizeof (char *));
     2025              targets = xmalloc (5 * sizeof (char *));
     2026              target_percents = xmalloc (5 * sizeof (char *));
    20392027              target_idx = 0;
    20402028            }
     
    20422030            {
    20432031              max_targets += 5;
    2044               targets = (char **) xrealloc ((char *) targets,
    2045                                             max_targets * sizeof (char *));
    2046               target_percents
    2047                 = (char **) xrealloc ((char *) target_percents,
    2048                                       max_targets * sizeof (char *));
     2032              targets = xrealloc (targets, max_targets * sizeof (char *));
     2033              target_percents = xrealloc (target_percents,
     2034                                          max_targets * sizeof (char *));
    20492035            }
    20502036          targets[target_idx] = name;
     
    20732059          /* Single-colon.  Combine these dependencies
    20742060             with others in file's existing record, if any.  */
    2075           f = enter_file (name);
     2061          f = enter_file (strcache_add (name));
    20762062
    20772063          if (f->double_colon)
     
    21792165            fatal (flocp,
    21802166                   _("target file `%s' has both : and :: entries"), f->name);
    2181           f = enter_file (name);
     2167          f = enter_file (strcache_add (name));
    21822168          /* If there was an existing entry and it was a double-colon entry,
    21832169             enter_file will have returned a new one, making it the prev
     
    21982184      if (pattern)
    21992185        {
    2200           static char *percent = "%";
     2186          static const char *percent = "%";
    22012187          char *buffer = variable_expand ("");
    2202           char *o = patsubst_expand (buffer, name, pattern, percent,
    2203                                      pattern_percent+1, percent+1);
    2204           f->stem = savestring (buffer, o - buffer);
     2188          char *o = patsubst_expand_pat (buffer, name, pattern, percent,
     2189                                         pattern_percent+1, percent+1);
     2190          f->stem = strcache_add_len (buffer, o - buffer);
    22052191          if (this)
    22062192            {
    22072193              this->staticpattern = 1;
    2208               this->stem = xstrdup (f->stem);
     2194              this->stem = f->stem;
    22092195            }
    22102196        }
    22112197
    2212       /* Free name if not needed further.  */
    2213       if (f != 0 && name != f->name
    2214           && (name < f->name || name > f->name + strlen (f->name)))
    2215         {
    2216           free (name);
    2217           name = f->name;
    2218         }
     2198      name = f->name;
    22192199
    22202200      /* If this target is a default target, update DEFAULT_GOAL_FILE.  */
     
    22272207  if (implicit)
    22282208    {
    2229       targets[target_idx] = 0;
    2230       target_percents[target_idx] = 0;
    22312209      if (deps)
    22322210        deps->need_2nd_expansion = second_expansion;
    2233       create_pattern_rule (targets, target_percents, two_colon, deps, cmds, 1);
    2234       free ((char *) target_percents);
     2211      create_pattern_rule (targets, target_percents, target_idx,
     2212                           two_colon, deps, cmds, 1);
    22352213    }
    22362214}
     
    22512229{
    22522230  unsigned int string_len = 0;
    2253   register char *p = string;
     2231  char *p = string;
    22542232  register int ch; /* bird: 'optimiziations' */
    22552233
     
    23112289        {
    23122290          /* Search for more backslashes.  */
    2313           register int i = -2;
     2291          int i = -2;
    23142292          while (&p[i] >= string && p[i] == '\\')
    23152293            --i;
     
    23202298          /* The number of backslashes is now -I.
    23212299             Copy P over itself to swallow half of them.  */
    2322           bcopy (&p[i / 2], &p[i], (string_len - (p - string)) - (i / 2) + 1);
    2323           p += i / 2;
     2300          memmove (&p[i], &p[i/2], (string_len - (p - string)) - (i/2) + 1);
     2301          p += i/2;
    23242302          if (i % 2 == 0)
    23252303            /* All the backslashes quoted each other; the STOPCHAR was
     
    23382316}
    23392317
    2340 /* Search PATTERN for an unquoted %.  */
     2318/* Search PATTERN for an unquoted % and handle quoting.  */
    23412319
    23422320char *
     
    23442322{
    23452323  return find_char_unquote (pattern, '%', 0, 0, 0);
     2324}
     2325
     2326/* Search STRING for an unquoted % and handle quoting.  Returns a pointer to
     2327   the % or NULL if no % was found.
     2328   This version is used with strings in the string cache: if there's a need to
     2329   modify the string a new version will be added to the string cache and
     2330   *STRING will be set to that.  */
     2331
     2332const char *
     2333find_percent_cached (const char **string)
     2334{
     2335  const char *p = *string;
     2336  char *new = 0;
     2337  int slen;
     2338
     2339  /* If the first char is a % return now.  This lets us avoid extra tests
     2340     inside the loop.  */
     2341  if (*p == '%')
     2342    return p;
     2343
     2344  while (1)
     2345    {
     2346      while (*p != '\0' && *p != '%')
     2347        ++p;
     2348
     2349      if (*p == '\0')
     2350        break;
     2351
     2352      /* See if this % is escaped with a backslash; if not we're done.  */
     2353      if (p[-1] != '\\')
     2354        break;
     2355
     2356      {
     2357        /* Search for more backslashes.  */
     2358        char *pv;
     2359        int i = -2;
     2360
     2361        while (&p[i] >= *string && p[i] == '\\')
     2362          --i;
     2363        ++i;
     2364
     2365        /* At this point we know we'll need to allocate a new string.
     2366           Make a copy if we haven't yet done so.  */
     2367        if (! new)
     2368          {
     2369            slen = strlen (*string);
     2370            new = alloca (slen + 1);
     2371            memcpy (new, *string, slen + 1);
     2372            p = new + (p - *string);
     2373            *string = new;
     2374          }
     2375
     2376        /* At this point *string, p, and new all point into the same string.
     2377           Get a non-const version of p so we can modify new.  */
     2378        pv = new + (p - *string);
     2379
     2380        /* The number of backslashes is now -I.
     2381           Copy P over itself to swallow half of them.  */
     2382        memmove (&pv[i], &pv[i/2], (slen - (pv - new)) - (i/2) + 1);
     2383        p += i/2;
     2384
     2385        /* If the backslashes quoted each other; the % was unquoted.  */
     2386        if (i % 2 == 0)
     2387          break;
     2388      }
     2389    }
     2390
     2391  /* If we had to change STRING, add it to the strcache.  */
     2392  if (new)
     2393    {
     2394      *string = strcache_add (*string);
     2395      p = *string + (p - new);
     2396    }
     2397
     2398  /* If we didn't find a %, return NULL.  Otherwise return a ptr to it.  */
     2399  return (*p == '\0') ? NULL : p;
    23462400}
    23472401
     
    23672421#ifndef NO_ARCHIVES /* bird: MSC warning */
    23682422  struct nameseq *lastnew1;
    2369 #endif 
     2423#endif
    23702424  char *p = *stringp;
    2371   char *q;
    2372   char *name;
    23732425
    23742426#ifdef VMS
     
    23802432  while (1)
    23812433    {
     2434      const char *name;
     2435      char *q;
     2436
    23822437      /* Skip whitespace; see if any more names are left.  */
    23832438      p = next_token (p);
     
    23872442        break;
    23882443
    2389       /* Yes, find end of next name.  */
     2444      /* There are, so find the end of the next name.  */
    23902445      q = p;
    23912446      p = find_char_unquote (q, stopchar, VMS_COMMA, 1, 0);
     
    23992454          && !(isspace ((unsigned char)p[1]) || !p[1]
    24002455               || isspace ((unsigned char)p[-1])))
    2401       {
    24022456        p = find_char_unquote (p+1, stopchar, VMS_COMMA, 1, 0);
    2403       }
    24042457#endif
    24052458#ifdef HAVE_DOS_PATHS
     
    24352488      if (q == p)
    24362489        /* ".///" was stripped to "". */
    2437 #ifdef VMS
     2490#if defined(VMS)
    24382491        continue;
     2492#elif defined(_AMIGA)
     2493        name = "";
    24392494#else
    2440 #ifdef _AMIGA
    2441         name = savestring ("", 0);
    2442 #else
    2443         name = savestring ("./", 2);
    2444 #endif
     2495        name = "./";
    24452496#endif
    24462497      else
     
    24662517              *q2++ = *q1++;
    24672518            }
    2468           name = savestring (qbase, p1 - qbase);
     2519          name = strcache_add_len (qbase, p1 - qbase);
    24692520          free (qbase);
    24702521        }
    24712522#else
    2472         name = savestring (q, p - q);
     2523        name = strcache_add_len (q, p - q);
    24732524#endif
    24742525
    24752526      /* Add it to the front of the chain.  */
    2476       new1 = (struct nameseq *) xmalloc (size);
     2527      new1 = xmalloc (size);
    24772528      new1->name = name;
    24782529      new1->next = new;
     
    25172568            /* Copy "lib(" into LIBNAME.  */
    25182569            ++paren;
    2519             libname = (char *) alloca (paren - n->name + 1);
    2520             bcopy (n->name, libname, paren - n->name);
     2570            libname = alloca (paren - n->name + 1);
     2571            memcpy (libname, n->name, paren - n->name);
    25212572            libname[paren - n->name] = '\0';
    25222573
     
    25262577                   Edit it out of the chain and free its storage.  */
    25272578                lastn->next = n->next;
    2528                 free (n->name);
    2529                 free ((char *) n);
     2579                free (n);
    25302580                /* LASTN->next is the new stopping elt for the loop below.  */
    25312581                n = lastn->next;
     
    25342584              {
    25352585                /* Replace N's name with the full archive reference.  */
    2536                 name = concat (libname, paren, ")");
    2537                 free (n->name);
    2538                 n->name = name;
     2586                n->name = strcache_add (concat (libname, paren, ")"));
    25392587              }
    25402588
     
    25492597                lastn = new1;
    25502598                new1 = new1->next;
    2551                 free (lastn->name);
    2552                 free ((char *) lastn);
     2599                free (lastn);
    25532600              }
    25542601            else
    25552602              {
    25562603                /* Replace also NEW1->name, which already has closing `)'.  */
    2557                 name = concat (libname, new1->name, "");
    2558                 free (new1->name);
    2559                 new1->name = name;
     2604                new1->name = strcache_add (concat (libname, new1->name, ""));
    25602605                new1 = new1->next;
    25612606              }
     
    25672612            while (new1 != n)
    25682613              {
    2569                 name = concat (libname, new1->name, ")");
    2570                 free (new1->name);
    2571                 new1->name = name;
     2614                new1->name = strcache_add (concat (libname, new1->name, ")"));
    25722615                lastnew1 = new1;
    25732616                new1 = new1->next;
     
    27372780        unsigned long off = p - start;
    27382781        ebuf->size *= 2;
    2739         start = ebuf->buffer = ebuf->bufstart = (char *) xrealloc (start,
    2740                                                                    ebuf->size);
     2782        start = ebuf->buffer = ebuf->bufstart = xrealloc (start, ebuf->size);
    27412783        p = start + off;
    27422784        end = start + ebuf->size;
     
    29412983
    29422984void
    2943 construct_include_path (char **arg_dirs)
     2985construct_include_path (const char **arg_dirs)
    29442986{
    2945   register unsigned int i;
    29462987#ifdef VAXC             /* just don't ask ... */
    29472988  stat_t stbuf;
     
    29492990  struct stat stbuf;
    29502991#endif
    2951   /* Table to hold the dirs.  */
    2952 
    2953   register unsigned int defsize = (sizeof (default_include_directories)
    2954                                    / sizeof (default_include_directories[0]));
    2955   register unsigned int max = 5;
    2956   register char **dirs = (char **) xmalloc ((5 + defsize) * sizeof (char *));
    2957   register unsigned int idx = 0;
     2992  const char **dirs;
     2993  const char **cpp;
     2994  unsigned int idx;
     2995
     2996  /* Compute the number of pointers we need in the table.  */
     2997  idx = sizeof (default_include_directories) / sizeof (const char *);
     2998  if (arg_dirs)
     2999    for (cpp = arg_dirs; *cpp != 0; ++cpp)
     3000      ++idx;
    29583001
    29593002#ifdef  __MSDOS__
    2960   defsize++;
     3003  /* Add one for $DJDIR.  */
     3004  ++idx;
    29613005#endif
    29623006
     3007  dirs = xmalloc (idx * sizeof (const char *));
     3008
     3009  idx = 0;
     3010  max_incl_len = 0;
     3011
    29633012  /* First consider any dirs specified with -I switches.
    2964      Ignore dirs that don't exist.  */
    2965 
    2966   if (arg_dirs != 0)
     3013     Ignore any that don't exist.  Remember the maximum string length.  */
     3014
     3015  if (arg_dirs)
    29673016    while (*arg_dirs != 0)
    29683017      {
    2969         char *dir = *arg_dirs++;
     3018        const char *dir = *(arg_dirs++);
     3019        char *expanded = 0;
    29703020        int e;
    29713021
    29723022        if (dir[0] == '~')
    29733023          {
    2974             char *expanded = tilde_expand (dir);
     3024            expanded = tilde_expand (dir);
    29753025            if (expanded != 0)
    29763026              dir = expanded;
     
    29793029        EINTRLOOP (e, stat (dir, &stbuf));
    29803030        if (e == 0 && S_ISDIR (stbuf.st_mode))
    2981           {
    2982             if (idx == max - 1)
    2983               {
    2984                 max += 5;
    2985                 dirs = (char **)
    2986                   xrealloc ((char *) dirs, (max + defsize) * sizeof (char *));
    2987               }
    2988             dirs[idx++] = dir;
    2989           }
    2990         else if (dir != arg_dirs[-1])
    2991           free (dir);
     3031          {
     3032            unsigned int len = strlen (dir);
     3033            /* If dir name is written with trailing slashes, discard them.  */
     3034            while (len > 1 && dir[len - 1] == '/')
     3035              --len;
     3036            if (len > max_incl_len)
     3037              max_incl_len = len;
     3038            dirs[idx++] = strcache_add_len (dir, len);
     3039          }
     3040
     3041        if (expanded)
     3042          free (expanded);
    29923043      }
    29933044
    2994   /* Now add at the end the standard default dirs.  */
     3045  /* Now add the standard default dirs at the end.  */
    29953046
    29963047#ifdef  __MSDOS__
    29973048  {
    2998     /* The environment variable $DJDIR holds the root of the
    2999        DJGPP directory tree; add ${DJDIR}/include.  */
     3049    /* The environment variable $DJDIR holds the root of the DJGPP directory
     3050       tree; add ${DJDIR}/include.  */
    30003051    struct variable *djdir = lookup_variable ("DJDIR", 5);
    30013052
    30023053    if (djdir)
    30033054      {
    3004         char *defdir = (char *) xmalloc (strlen (djdir->value) + 8 + 1);
     3055        unsigned int len = strlen (djdir->value) + 8;
     3056        char *defdir = alloca (len + 1);
    30053057
    30063058        strcat (strcpy (defdir, djdir->value), "/include");
    3007         dirs[idx++] = defdir;
     3059        dirs[idx++] = strcache_add (defdir);
     3060
     3061        if (len > max_incl_len)
     3062          max_incl_len = len;
    30083063      }
    30093064  }
    30103065#endif
    30113066
    3012   for (i = 0; default_include_directories[i] != 0; ++i)
     3067  for (cpp = default_include_directories; *cpp != 0; ++cpp)
    30133068    {
    30143069      int e;
    30153070
    3016       EINTRLOOP (e, stat (default_include_directories[i], &stbuf));
     3071      EINTRLOOP (e, stat (*cpp, &stbuf));
    30173072      if (e == 0 && S_ISDIR (stbuf.st_mode))
    3018         dirs[idx++] = default_include_directories[i];
     3073        {
     3074          unsigned int len = strlen (*cpp);
     3075          /* If dir name is written with trailing slashes, discard them.  */
     3076          while (len > 1 && (*cpp)[len - 1] == '/')
     3077            --len;
     3078          if (len > max_incl_len)
     3079            max_incl_len = len;
     3080          dirs[idx++] = strcache_add_len (*cpp, len - 1);
     3081        }
    30193082    }
    30203083
    30213084  dirs[idx] = 0;
    30223085
    3023   /* Now compute the maximum length of any name in it. Also add each
    3024      dir to the .INCLUDE_DIRS variable.  */
    3025 
    3026   max_incl_len = 0;
    3027   for (i = 0; i < idx; ++i)
    3028     {
    3029       unsigned int len = strlen (dirs[i]);
    3030       /* If dir name is written with a trailing slash, discard it.  */
    3031       if (dirs[i][len - 1] == '/')
    3032         /* We can't just clobber a null in because it may have come from
    3033            a literal string and literal strings may not be writable.  */
    3034         dirs[i] = savestring (dirs[i], len - 1);
    3035       if (len > max_incl_len)
    3036         max_incl_len = len;
    3037 
    3038       /* Append to .INCLUDE_DIRS.   */
    3039       do_variable_definition (NILF, ".INCLUDE_DIRS", dirs[i],
    3040                               o_default, f_append, 0);
    3041     }
     3086  /* Now add each dir to the .INCLUDE_DIRS variable.  */
     3087
     3088  for (cpp = dirs; *cpp != 0; ++cpp)
     3089    do_variable_definition (NILF, ".INCLUDE_DIRS", *cpp,
     3090                            o_default, f_append, 0);
    30423091
    30433092  include_directories = dirs;
     
    30493098
    30503099char *
    3051 tilde_expand (char *name)
     3100tilde_expand (const char *name)
    30523101{
    30533102#ifndef VMS
     
    30743123          home_dir = getenv ("HOME");
    30753124        }
    3076 #if !defined(_AMIGA) && !defined(WINDOWS32)
     3125# if !defined(_AMIGA) && !defined(WINDOWS32)
    30773126      if (home_dir == 0 || home_dir[0] == '\0')
    30783127        {
     
    30873136            }
    30883137        }
    3089 #endif /* !AMIGA && !WINDOWS32 */
     3138# endif /* !AMIGA && !WINDOWS32 */
    30903139      if (home_dir != 0)
    30913140        {
    3092           char *new = concat (home_dir, "", name + 1);
     3141          char *new = xstrdup (concat (home_dir, "", name + 1));
    30933142          if (is_variable)
    30943143            free (home_dir);
     
    30963145        }
    30973146    }
    3098 #if !defined(_AMIGA) && !defined(WINDOWS32)
     3147# if !defined(_AMIGA) && !defined(WINDOWS32)
    30993148  else
    31003149    {
     
    31093158            return xstrdup (pwent->pw_dir);
    31103159          else
    3111             return concat (pwent->pw_dir, "/", userend + 1);
     3160            return xstrdup (concat (pwent->pw_dir, "/", userend + 1));
    31123161        }
    31133162      else if (userend != 0)
    31143163        *userend = '/';
    31153164    }
    3116 #endif /* !AMIGA && !WINDOWS32 */
     3165# endif /* !AMIGA && !WINDOWS32 */
    31173166#endif /* !VMS */
    31183167  return 0;
     
    31323181multi_glob (struct nameseq *chain, unsigned int size)
    31333182{
    3134   extern void dir_setup_glob ();
    3135   register struct nameseq *new = 0;
    3136   register struct nameseq *old;
     3183  void dir_setup_glob (glob_t *);
     3184  struct nameseq *new = 0;
     3185  struct nameseq *old;
    31373186  struct nameseq *nexto;
    31383187  glob_t gl;
     
    31453194  for (old = chain; old != 0; old = nexto)
    31463195    {
     3196      const char *gname;
    31473197#ifndef NO_ARCHIVES
    3148       char *memname;
     3198      char *arname = 0;
     3199      char *memname = 0;
    31493200#endif
    3150 
    31513201      nexto = old->next;
    3152 
    3153       if (old->name[0] == '~')
     3202      gname = old->name;
     3203
     3204      if (gname[0] == '~')
    31543205        {
    31553206          char *newname = tilde_expand (old->name);
    31563207          if (newname != 0)
    3157             {
    3158               free (old->name);
    3159               old->name = newname;
    3160             }
     3208            gname = newname;
    31613209        }
    31623210
    31633211#ifndef NO_ARCHIVES
    3164       if (ar_name (old->name))
     3212      if (ar_name (gname))
    31653213        {
    3166           /* OLD->name is an archive member reference.
    3167              Replace it with the archive file name,
    3168              and save the member name in MEMNAME.
    3169              We will glob on the archive name and then
    3170              reattach MEMNAME later.  */
    3171           char *arname;
    3172           ar_parse_name (old->name, &arname, &memname);
    3173           free (old->name);
    3174           old->name = arname;
     3214          /* OLD->name is an archive member reference.  Replace it with the
     3215             archive file name, and save the member name in MEMNAME.  We will
     3216             glob on the archive name and then reattach MEMNAME later.  */
     3217          ar_parse_name (gname, &arname, &memname);
     3218          gname = arname;
    31753219        }
    3176       else
    3177         memname = 0;
    31783220#endif /* !NO_ARCHIVES */
    31793221
    31803222#if defined(KMK) || defined(__EMX__) /* speed optimization */
    3181       if (!strpbrk(old->name, "*?["))
     3223      if (!strpbrk(gname, "*?["))
    31823224        {
    31833225          gl.gl_pathc = 1;
    3184           gl.gl_pathv = &old->name;
     3226          gl.gl_pathv = (char *)&gname;
    31853227          rc = 0;
    31863228        }
    31873229      else
    3188         rc = glob (old->name, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl);
     3230        rc = glob (gname, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl);
    31893231      switch (rc)
    31903232#else
    3191       switch (glob (old->name, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl))
     3233      switch (glob (gname, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl))
    31923234#endif
    31933235        {
    31943236        case 0:                 /* Success.  */
    31953237          {
    3196             register int i = gl.gl_pathc;
     3238            int i = gl.gl_pathc;
    31973239            while (i-- > 0)
    31983240              {
     
    32033245                    struct nameseq *found
    32043246                      = ar_glob (gl.gl_pathv[i], memname, size);
    3205                     if (found == 0)
     3247                    if (! found)
    32063248                      {
    32073249                        /* No matches.  Use MEMNAME as-is.  */
    32083250                        unsigned int alen = strlen (gl.gl_pathv[i]);
    32093251                        unsigned int mlen = strlen (memname);
    3210                         struct nameseq *elt
    3211                           = (struct nameseq *) xmalloc (size);
    3212                         if (size > sizeof (struct nameseq))
    3213                           bzero (((char *) elt) + sizeof (struct nameseq),
    3214                                  size - sizeof (struct nameseq));
    3215                         elt->name = (char *) xmalloc (alen + 1 + mlen + 2);
    3216                         bcopy (gl.gl_pathv[i], elt->name, alen);
    3217                         elt->name[alen] = '(';
    3218                         bcopy (memname, &elt->name[alen + 1], mlen);
    3219                         elt->name[alen + 1 + mlen] = ')';
    3220                         elt->name[alen + 1 + mlen + 1] = '\0';
     3252                        char *name;
     3253                        struct nameseq *elt = xmalloc (size);
     3254                        memset (elt, '\0', size);
     3255
     3256                        name = alloca (alen + 1 + mlen + 2);
     3257                        memcpy (name, gl.gl_pathv[i], alen);
     3258                        name[alen] = '(';
     3259                        memcpy (name+alen+1, memname, mlen);
     3260                        name[alen + 1 + mlen] = ')';
     3261                        name[alen + 1 + mlen + 1] = '\0';
     3262                        elt->name = strcache_add (name);
    32213263                        elt->next = new;
    32223264                        new = elt;
     
    32343276                        new = found;
    32353277                      }
    3236 
    3237                     free (memname);
    32383278                  }
    32393279                else
    32403280#endif /* !NO_ARCHIVES */
    32413281                  {
    3242                     struct nameseq *elt = (struct nameseq *) xmalloc (size);
    3243                     if (size > sizeof (struct nameseq))
    3244                       bzero (((char *) elt) + sizeof (struct nameseq),
    3245                              size - sizeof (struct nameseq));
    3246                     elt->name = xstrdup (gl.gl_pathv[i]);
     3282                    struct nameseq *elt = xmalloc (size);
     3283                    memset (elt, '\0', size);
     3284                    elt->name = strcache_add (gl.gl_pathv[i]);
    32473285                    elt->next = new;
    32483286                    new = elt;
     
    32503288              }
    32513289#if defined(KMK) || defined(__EMX__) /* speed optimization */
    3252             if (gl.gl_pathv != &old->name)
     3290            if (gl.gl_pathv != &gname)
    32533291#endif
    32543292            globfree (&gl);
    3255             free (old->name);
    3256             free ((char *)old);
     3293            free (old);
    32573294            break;
    32583295          }
     
    32673304          break;
    32683305        }
     3306
     3307#ifndef NO_ARCHIVES
     3308      if (arname)
     3309        free (arname);
     3310#endif
    32693311    }
    32703312
Note: See TracChangeset for help on using the changeset viewer.