VirtualBox

Changeset 900 in kBuild


Ignore:
Timestamp:
May 23, 2007 3:13:11 AM (18 years ago)
Author:
bird
Message:

Load /home/bird/src/Gnu/make/2007-05-23 into vendor/gnumake/current.

Location:
vendor/gnumake/current
Files:
27 added
126 deleted
48 edited

Legend:

Unmodified
Added
Removed
  • vendor/gnumake/current/ChangeLog

    r501 r900  
     12007-05-11  Paul Smith  <[email protected]>
     2
     3        * job.c (new_job): Add debug info to specify where make found the
     4        command script it is running to build a target.
     5        Fixes Savannah bug #18617.
     6
     7        * default.c (default_suffixes,default_suffix_rules,default_variables):
     8        Add support for Objective C.  Fixes Savannah bug #16389.
     9        Based on a patch provided by Peter O'Gorman <[email protected]>.
     10
     11        * function.c (func_lastword): Initialize p.
     12
     13        * doc/make.texi (Eval Function, Implicit Variables, Special Targets):
     14        Doc fixes noticed by Bob <[email protected]>.  Patch from
     15        Dave Korn <[email protected]>
     16
     172007-05-08  Paul Smith  <[email protected]>
     18
     19        Fix Savannah bug #19656:
     20
     21        * configure.in: Check for strcasecmp(), strcmpi(), and stricmp().
     22
     23        * make.h: Change all case-insensitive string compares to use
     24        strcasecmp() (from POSIX).  If we don't have that but do have one
     25        of the others, define strcasecmp to be one of those instead.  If
     26        we don't have any, declare a prototype for our own version.
     27
     28        * misc.c (strcasecmp): Use this if we can't find any native
     29        case-insensitive string comparison function.
     30        * vmsfunctions.c: Remove strcmpi(); we'll use misc.c:strcasecmp().
     31        * main.c (find_and_set_default_shell): Use strcasecmp() instead of
     32        strcmpi().
     33        * job.c (_is_unixy_shell, construct_command_argv_internal): Use
     34        strcasecmp() instead of stricmp().
     35        * hash.h (ISTRING_COMPARE, return_ISTRING_COMPARE): Use strcasecmp()
     36        instead of strcmpi().
     37        * acinclude.m4: Remove the strcasecmp() check from here.
     38
     392007-03-21  Paul Smith  <[email protected]>
     40
     41        * configure.in: Don't turn on case-insensitive file system support
     42        if --disable-... is given.  Fixes Savannah bug #19348.
     43
     442007-03-19  Paul Smith  <[email protected]>
     45
     46        * ALL: Use the strcache for all file name strings, or other
     47        strings which we will never free.  The goal is to save memory by
     48        avoiding duplicate copies of strings.  However, at the moment this
     49        doesn't save much memory in most situations: due to secondary
     50        expansion we actually save prerequisite lists twice (once before
     51        the secondary expansion, and then again after it's been parsed
     52        into individual file names in the dep list).  We will resolve this
     53        in a future change, by doing the parsing up-front for targets
     54        where secondary expansion is not set.
     55
     56        Moving things into the strcache also allows us to use const
     57        pointers in many more places.
     58
     592007-01-03  Paul Smith  <[email protected]>
     60
     61        * make.h (ENULLLOOP): Reset errno after each failed invocation of
     62        the function, not just the first.  Fixes Savannah bug #18680.
     63
     642006-11-18  Paul Smith  <[email protected]>
     65
     66        * strcache.c (strcache_add_len): Don't allocate a new buffer
     67        unless the string is not already nil-terminated.  Technically this
     68        is a violation of the standard, since we may be passed an array
     69        that is not long enough to test one past.  However, in make this
     70        is never true since we only use nil-terminated strings or
     71        sub-strings thereof.
     72
     73        * read.c (eval, do_define): Use cmd_prefix instead of '\t'.
     74
     75        * main.c: New global cmd_prefix, defaults to '\t'.
     76        * job.c (construct_command_argv_internal): Use cmd_prefix instead
     77        of '\t'.
     78
     79        * dir.c: Constified.
     80        (dir_contents_file_exists_p): Check for an error return from
     81        readdir(), just in case.
     82
     83        * commands.c: Constified.
     84        * default.c: Constified.
     85        * expand.c: Constified.
     86        * function.c: Partial constification.
     87        * variable.c: Partial constification.
     88        * vmsify.c: Constification.  Hard to test this but I hope I didn't
     89        screw it up!
     90        * vpath.c: Partial constification.
     91        * w32/pathstuff.c: Partial constification.
     92
     932006-11-16  Eli Zaretskii  <[email protected]>
     94
     95        * main.c (main) [HAVE_DOS_PATHS]: Treat DOS style argv[0] with
     96        backslashes and drive letters as absolute.
     97
     982006-10-22  Paul Smith  <[email protected]>
     99
     100        * main.c (struct command_switch): Use const and void*.
     101
     1022006-10-21  Paul Smith  <[email protected]>
     103
     104        * ar.c: Constified.
     105        * arscan.c: Constified.
     106
     1072006-09-30  Paul Smith  <[email protected]>
     108
     109        * doc/make.texi (MAKEFILE_LIST Variable): Modify reference to
     110        point to lastword since the example was updated.
     111        Fixes Savannah bug #16304.
     112        (Secondary Expansion): Correct example description.
     113        Fixes Savannah bug #16468.
     114        (Makefile Contents): Clarify that comments cannot appear within
     115        variable references or function calls.
     116        Fixes Savannah bug #16577.
     117        (Special Targets): Clarify how .NOTPARALLEL works in recursion.
     118        Fixes Savannah bug #17701.
     119        Reported by Ralf Wildenhues <[email protected]>:
     120        (Prerequisite Types): Added an example of using order-only
     121        prerequisites.  Fixes Savannah bug #17880.
     122        (Rule Syntax): "lise" -> "list"
     123        (Multiple Rules): ... -> @dots{}
     124        (Splitting Lines): ditto.
     125
     126        * remake.c (update_file_1): Prereqs that don't exist should be
     127        considered changed, for the purposes of $?.
     128        Fixes Savannah bug #16051.
     129
     130        * make.1: Remove extraneous "+".
     131        Fixes Savannah bug #16652.
     132
     1332006-09-06  Paul D. Smith  <[email protected]>
     134
     135        * configure.in: Include sys/types.h when checking for sys/wait.h.
     136
     1372006-08-18  Eli Zaretskii  <[email protected]>
     138
     139        * configure.in (PATH_SEPARATOR_CHAR): Define to the value of
     140        $PATH_SEPARATOR.
     141
     142        * make.h (PATH_SEPARATOR_CHAR): Define only if still undefined.
     143        Normally, it is defined in config.h.
     144
     145        * config/dospaths.m4 <ac_cv_dos_paths>: Define to yes on Cygwin as
     146        well.
     147
     148        * job.c (construct_command_argv_internal) [HAVE_DOS_PATHS]: Define
     149        sh_chars_sh for Windows platforms that emulate Unix.
     150
     1512006-05-07  Paul D. Smith  <[email protected]>
     152
     153        * README.OS2.template: Updates provided by Andreas Buening
     154        <[email protected]>.
     155
     1562006-04-30  Paul D. Smith  <[email protected]>
     157
     158        * make.h: Include <direct.h> if HAVE_DIRECT_H.
     159        * config.h.W32.template (HAVE_DIRECT_H): Set it if it's available.
     160
     1612006-04-26  Paul D. Smith  <[email protected]>
     162
     163        * README.cvs: Add a reminder to notify the GNU translation robot.
     164
     165        * doc/make.texi: Change @direcategory (requested by Karl Berry).
     166
     1672006-04-20  Paul D. Smith  <[email protected]>
     168
     169        * maintMakefile (po-check): Use Perl instead of grep -E, for systems
     170        that don't have extended grep.
     171        (cvsclean): Use $(PERL) instead of perl.
     172
     1732006-04-09  Paul D. Smith  <[email protected]>
     174
     175        * maintMakefile: Add some extra warning options (GCC 4.1 only?)
     176
     177        * expand.c, implicit.c, main.c, read.c: Rename variables so that
     178        inner-scope variables don't mask outer-scope variables.
     179
     180        * ar.c, arscan.c, commands.c, default.c, dir.c, expand.c, file.c:
     181        * function.c, getloadavg.c, implicit.c, job.c, main.c, misc.c, read.c:
     182        * remake.c, remote-cstms.c, rule.c, strcache.c, variable.c:
     183        * vmsfunctions.c, vmsify.c, vpath.c: Remove all casts of returned
     184        values from memory allocation functions: they return void* and so
     185        don't need to be cast.  Also remove (char *) casts of arguments to
     186        xrealloc().
     187
     188        * configure.in: Remove checks for memcpy/memmove/strchr.
     189
     190        * make.h: Remove bcmp/bcopy/bzero/strchr/strrchr macros.
     191
     192        * ar.c, arscan.c, commands.c, dir.c: Convert all bzero/bcopy/bcmp
     193        calls to memset/memcpy/memmove/memcmp calls.
     194        * expand.c, file.c, function.c, getloadavg.c, implicit.c: Ditto.
     195        * job.c, main.c, misc.c, read.c, remake.c, rule.c: Ditto.
     196        * variable.c, vpath.c: Ditto.
     197
     198        * make.h (EXIT_FAILURE): Should be 1, not 0.
     199
     2002006-04-06  Paul D. Smith  <[email protected]>
     201
     202        * configure.in: Removed AM_C_PROTOTYPES.  Starting now on we
     203        require an ISO C 1989 standard compiler and runtime library.
     204
     205        * Makefile.am: Remove the ansi2knr feature.
     206
     207        * make.h: Remove the PARAMS() macro definition and all uses of it.
     208
     209        * amiga.h, ar.c, arscan.c: Remove all uses of the PARAMS() macro.
     210        * commands.c, commands.h, config.h-vms.template: Ditto.
     211        * dep.h, dir.c, expand.c, filedef.h, function.c: Ditto.
     212        * implicit.c, job.c, job.h, main.c, read.c, remake.c: Ditto.
     213        * rule.c, rule.h, variable.h, vmsdir.h, vmsjobs.c, vpath.c: Ditto.
     214
     215        * NEWS: Update.
     216
    12172006-04-01  Paul D. Smith  <[email protected]>
    2218
     
    54270        (main): If we are re-execing, clean up the jobserver first so we
    55271        don't leak file descriptors.
    56         Fix bug reported by Craig Fithian <[email protected]>.
     272        Reported by Craig Fithian <[email protected]>
    57273
    582742006-03-17  Paul D. Smith  <[email protected]>
  • vendor/gnumake/current/Makefile.am

    r501 r900  
    1717# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1818
    19 AUTOMAKE_OPTIONS = 1.8 dist-bzip2 check-news ansi2knr
     19AUTOMAKE_OPTIONS = 1.8 dist-bzip2 check-news
    2020ACLOCAL_AMFLAGS =  -I config
    2121
  • vendor/gnumake/current/NEWS

    r501 r900  
    99See the README file and the GNU make manual for instructions for
    1010reporting bugs.
     11
     12
     13Version 3.81.90
     14
     15* Compiling GNU make now requires a conforming ISO C 1989 compiler and
     16  standard runtime library.
     17
    1118
    1219
  • vendor/gnumake/current/acinclude.m4

    r501 r900  
    6363AC_CHECK_FUNCS(gethostbyname,,[
    6464        CF_RECHECK_FUNC(gethostbyname,nsl,cf_cv_netlibs)])
    65 #
    66 AC_CHECK_FUNCS(strcasecmp,,[
    67         CF_RECHECK_FUNC(strcasecmp,resolv,cf_cv_netlibs)])
    6865])
    6966LIBS="$LIBS $cf_cv_netlibs"
  • vendor/gnumake/current/amiga.h

    r501 r900  
    1616Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.  */
    1717
    18 extern int MyExecute PARAMS ((char ** argv));
    19 extern char * wildcard_expansion PARAMS ((char * wc, char * o));
    20 
     18int MyExecute (char ** argv);
     19char * wildcard_expansion (char * wc, char * o);
  • vendor/gnumake/current/ar.c

    r501 r900  
    2525#include <fnmatch.h>
    2626
    27 /* Defined in arscan.c.  */
    28 extern long int ar_scan PARAMS ((char *archive, long int (*function) (), long int arg));
    29 extern int ar_name_equal PARAMS ((char *name, char *mem, int truncated));
    30 #ifndef VMS
    31 extern int ar_member_touch PARAMS ((char *arname, char *memname));
    32 #endif
    33 
    3427/* Return nonzero if NAME is an archive-member reference, zero if not.
    3528   An archive-member reference is a name like `lib(member)'.
     
    3831
    3932int
    40 ar_name (char *name)
    41 {
    42   char *p = strchr (name, '(');
    43   char *end;
     33ar_name (const char *name)
     34{
     35  const char *p = strchr (name, '(');
     36  const char *end;
    4437
    4538  if (p == 0 || p == name)
     
    5851
    5952/* Parse the archive-member reference NAME into the archive and member names.
    60    Put the malloc'd archive name in *ARNAME_P if ARNAME_P is non-nil;
    61    put the malloc'd member name in *MEMNAME_P if MEMNAME_P is non-nil.  */
     53   Creates one allocated string containing both names, pointed to by ARNAME_P.
     54   MEMNAME_P points to the member.  */
    6255
    6356void
    64 ar_parse_name (char *name, char **arname_p, char **memname_p)
    65 {
    66   char *p = strchr (name, '('), *end = name + strlen (name) - 1;
    67 
    68   if (arname_p != 0)
    69     *arname_p = savestring (name, p - name);
    70 
    71   if (memname_p != 0)
    72     *memname_p = savestring (p + 1, end - (p + 1));
    73 }
    74 
    75 
    76 static long int ar_member_date_1 PARAMS ((int desc, char *mem, int truncated, long int hdrpos,
    77         long int datapos, long int size, long int date, int uid, int gid, int mode, char *name));
     57ar_parse_name (const char *name, char **arname_p, char **memname_p)
     58{
     59  char *p;
     60
     61  *arname_p = xstrdup (name);
     62  p = strchr (*arname_p, '(');
     63  *(p++) = '\0';
     64  p[strlen(p) - 1] = '\0';
     65  *memname_p = p;
     66}
     67
     68
     69
     70/* This function is called by `ar_scan' to find which member to look at.  */
     71
     72/* ARGSUSED */
     73static long int
     74ar_member_date_1 (int desc UNUSED, const char *mem, int truncated,
     75                  long int hdrpos UNUSED, long int datapos UNUSED,
     76                  long int size UNUSED, long int date,
     77                  int uid UNUSED, int gid UNUSED, int mode UNUSED,
     78                  const void *name)
     79{
     80  return ar_name_equal (name, mem, truncated) ? date : 0;
     81}
    7882
    7983/* Return the modtime of NAME.  */
    8084
    8185time_t
    82 ar_member_date (char *name)
     86ar_member_date (const char *name)
    8387{
    8488  char *arname;
    85   int arname_used = 0;
    8689  char *memname;
    8790  long int val;
     
    100103    arfile = lookup_file (arname);
    101104    if (arfile == 0 && file_exists_p (arname))
    102       {
    103         arfile = enter_file (arname);
    104         arname_used = 1;
    105       }
     105      arfile = enter_file (strcache_add (arname));
    106106
    107107    if (arfile != 0)
     
    109109  }
    110110
    111   val = ar_scan (arname, ar_member_date_1, (long int) memname);
    112 
    113   if (!arname_used)
    114     free (arname);
    115   free (memname);
     111  val = ar_scan (arname, ar_member_date_1, memname);
     112
     113  free (arname);
    116114
    117115  return (val <= 0 ? (time_t) -1 : (time_t) val);
    118 }
    119 
    120 /* This function is called by `ar_scan' to find which member to look at.  */
    121 
    122 /* ARGSUSED */
    123 static long int
    124 ar_member_date_1 (int desc UNUSED, char *mem, int truncated,
    125                   long int hdrpos UNUSED, long int datapos UNUSED,
    126                   long int size UNUSED, long int date,
    127                   int uid UNUSED, int gid UNUSED, int mode UNUSED, char *name)
    128 {
    129   return ar_name_equal (name, mem, truncated) ? date : 0;
    130116}
    131117
     
    135121#ifdef VMS
    136122int
    137 ar_touch (char *name)
     123ar_touch (const char *name)
    138124{
    139125  error (NILF, _("touch archive member is not available on VMS"));
     
    142128#else
    143129int
    144 ar_touch (char *name)
     130ar_touch (const char *name)
    145131{
    146132  char *arname, *memname;
    147   int arname_used = 0;
    148   register int val;
     133  int val;
    149134
    150135  ar_parse_name (name, &arname, &memname);
    151136
    152137  /* Make sure we know the modtime of the archive itself before we
    153      touch the member, since this will change the archive itself.  */
     138     touch the member, since this will change the archive modtime.  */
    154139  {
    155140    struct file *arfile;
    156     arfile = lookup_file (arname);
    157     if (arfile == 0)
    158       {
    159         arfile = enter_file (arname);
    160         arname_used = 1;
    161       }
    162 
    163     (void) f_mtime (arfile, 0);
     141    arfile = enter_file (strcache_add (arname));
     142    f_mtime (arfile, 0);
    164143  }
    165144
     
    188167    }
    189168
    190   if (!arname_used)
    191     free (arname);
    192   free (memname);
     169  free (arname);
    193170
    194171  return val;
     
    201178struct ar_glob_state
    202179  {
    203     char *arname;
    204     char *pattern;
     180    const char *arname;
     181    const char *pattern;
    205182    unsigned int size;
    206183    struct nameseq *chain;
     
    212189
    213190static long int
    214 ar_glob_match (int desc UNUSED, char *mem, int truncated UNUSED,
     191ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED,
    215192               long int hdrpos UNUSED, long int datapos UNUSED,
    216193               long int size UNUSED, long int date UNUSED, int uid UNUSED,
    217                int gid UNUSED, int mode UNUSED, struct ar_glob_state *state)
    218 {
     194               int gid UNUSED, int mode UNUSED, const void *arg)
     195{
     196  struct ar_glob_state *state = (struct ar_glob_state *)arg;
     197
    219198  if (fnmatch (state->pattern, mem, FNM_PATHNAME|FNM_PERIOD) == 0)
    220199    {
    221200      /* We have a match.  Add it to the chain.  */
    222       struct nameseq *new = (struct nameseq *) xmalloc (state->size);
    223       new->name = concat (state->arname, mem, ")");
     201      struct nameseq *new = xmalloc (state->size);
     202      new->name = strcache_add (concat (state->arname, mem, ")"));
    224203      new->next = state->chain;
    225204      state->chain = new;
     
    267246
    268247struct nameseq *
    269 ar_glob (char *arname, char *member_pattern, unsigned int size)
     248ar_glob (const char *arname, const char *member_pattern, unsigned int size)
    270249{
    271250  struct ar_glob_state state;
    272   char **names;
    273251  struct nameseq *n;
     252  const char **names;
     253  char *name;
    274254  unsigned int i;
    275255
     
    280260     ar_glob_match will accumulate them in STATE.chain.  */
    281261  i = strlen (arname);
    282   state.arname = (char *) alloca (i + 2);
    283   bcopy (arname, state.arname, i);
    284   state.arname[i] = '(';
    285   state.arname[i + 1] = '\0';
     262  name = alloca (i + 2);
     263  memcpy (name, arname, i);
     264  name[i] = '(';
     265  name[i + 1] = '\0';
     266  state.arname = name;
    286267  state.pattern = member_pattern;
    287268  state.size = size;
    288269  state.chain = 0;
    289270  state.n = 0;
    290   (void) ar_scan (arname, ar_glob_match, (long int) &state);
     271  ar_scan (arname, ar_glob_match, &state);
    291272
    292273  if (state.chain == 0)
     
    294275
    295276  /* Now put the names into a vector for sorting.  */
    296   names = (char **) alloca (state.n * sizeof (char *));
     277  names = alloca (state.n * sizeof (const char *));
    297278  i = 0;
    298279  for (n = state.chain; n != 0; n = n->next)
     
    300281
    301282  /* Sort them alphabetically.  */
    302   qsort ((char *) names, i, sizeof (*names), alpha_compare);
     283  qsort (names, i, sizeof (*names), alpha_compare);
    303284
    304285  /* Put them back into the chain in the sorted order.  */
  • vendor/gnumake/current/arscan.c

    r501 r900  
    2626
    2727#ifndef NO_ARCHIVES
    28 
    2928
    3029#ifdef VMS
     
    136135
    137136long int
    138 ar_scan (char *archive, long int (*function) PARAMS ((void)), long int arg)
     137ar_scan (const char *archive, ar_member_func_t function, const void *arg)
    139138{
    140139  char *p;
     
    304303
    305304long int
    306 ar_scan (char *archive, long int (*function)(), long int arg)
     305ar_scan (const char *archive, ar_member_func_t function, const void *arg)
    307306{
    308307#ifdef AIAMAG
     
    316315#endif
    317316  char *namemap = 0;
    318   register int desc = open (archive, O_RDONLY, 0);
     317  int desc = open (archive, O_RDONLY, 0);
    319318  if (desc < 0)
    320319    return -1;
     
    323322    char buf[SARMAG];
    324323    register int nread = read (desc, buf, SARMAG);
    325     if (nread != SARMAG || bcmp (buf, ARMAG, SARMAG))
     324    if (nread != SARMAG || memcmp (buf, ARMAG, SARMAG))
    326325      {
    327326        (void) close (desc);
     
    332331#ifdef AIAMAG
    333332  {
    334     register int nread = read (desc, (char *) &fl_header, FL_HSZ);
     333    register int nread = read (desc, &fl_header, FL_HSZ);
    335334
    336335    if (nread != FL_HSZ)
     
    342341    /* If this is a "big" archive, then set the flag and
    343342       re-read the header into the "big" structure. */
    344     if (!bcmp (fl_header.fl_magic, AIAMAGBIG, SAIAMAG))
     343    if (!memcmp (fl_header.fl_magic, AIAMAGBIG, SAIAMAG))
    345344      {
    346345        big_archive = 1;
     
    354353
    355354        /* re-read the header into the "big" structure */
    356         nread = read (desc, (char *) &fl_header_big, FL_HSZ_BIG);
     355        nread = read (desc, &fl_header_big, FL_HSZ_BIG);
    357356        if (nread != FL_HSZ_BIG)
    358357          {
     
    364363#endif
    365364       /* Check to make sure this is a "normal" archive. */
    366       if (bcmp (fl_header.fl_magic, AIAMAG, SAIAMAG))
     365      if (memcmp (fl_header.fl_magic, AIAMAG, SAIAMAG))
    367366        {
    368367          (void) close (desc);
     
    458457        if (big_archive)
    459458          {
    460             nread = read (desc, (char *) &member_header_big,
     459            nread = read (desc, &member_header_big,
    461460                          AR_MEMHDR_SZ(member_header_big) );
    462461
     
    490489#endif
    491490          {
    492             nread = read (desc, (char *) &member_header,
     491            nread = read (desc, &member_header,
    493492                          AR_MEMHDR_SZ(member_header) );
    494493
     
    528527
    529528#else   /* Not AIAMAG.  */
    530         nread = read (desc, (char *) &member_header, AR_HDR_SIZE);
     529        nread = read (desc, &member_header, AR_HDR_SIZE);
    531530        if (nread == 0)
    532531          /* No data left means end of file; that is OK.  */
     
    537536            || (
    538537# ifdef ARFMAG
    539                 bcmp (member_header.ar_fmag, ARFMAG, 2)
     538                memcmp (member_header.ar_fmag, ARFMAG, 2)
    540539# else
    541540                1
     
    543542                &&
    544543# ifdef ARFZMAG
    545                 bcmp (member_header.ar_fmag, ARFZMAG, 2)
     544                memcmp (member_header.ar_fmag, ARFZMAG, 2)
    546545# else
    547546                1
     
    556555
    557556        name = namebuf;
    558         bcopy (member_header.ar_name, name, sizeof member_header.ar_name);
     557        memcpy (name, member_header.ar_name, sizeof member_header.ar_name);
    559558        {
    560559          register char *p = name + sizeof member_header.ar_name;
     
    596595              int namesize = atoi (name + 3);
    597596
    598               name = (char *) alloca (namesize + 1);
     597              name = alloca (namesize + 1);
    599598              nread = read (desc, name, namesize);
    600599              if (nread != namesize)
     
    667666            char *limit;
    668667
    669             namemap = (char *) alloca (eltsize);
     668            namemap = alloca (eltsize);
    670669            nread = read (desc, namemap, eltsize);
    671670            if (nread != eltsize)
     
    710709
    711710int
    712 ar_name_equal (char *name, char *mem, int truncated)
     711ar_name_equal (const char *name, const char *mem, int truncated)
    713712{
    714   char *p;
     713  const char *p;
    715714
    716715  p = strrchr (name, '/');
     
    742741/* ARGSUSED */
    743742static long int
    744 ar_member_pos (int desc UNUSED, char *mem, int truncated,
     743ar_member_pos (int desc UNUSED, const char *mem, int truncated,
    745744               long int hdrpos, long int datapos UNUSED, long int size UNUSED,
    746745               long int date UNUSED, int uid UNUSED, int gid UNUSED,
    747                int mode UNUSED, char *name)
     746               int mode UNUSED, const void *name)
    748747{
    749748  if (!ar_name_equal (name, mem, truncated))
     
    760759
    761760int
    762 ar_member_touch (char *arname, char *memname)
     761ar_member_touch (const char *arname, const char *memname)
    763762{
    764   long int pos = ar_scan (arname, ar_member_pos, (long int) memname);
     763  long int pos = ar_scan (arname, ar_member_pos, memname);
    765764  int fd;
    766765  struct ar_hdr ar_hdr;
     
    780779  if (lseek (fd, pos, 0) < 0)
    781780    goto lose;
    782   if (AR_HDR_SIZE != read (fd, (char *) &ar_hdr, AR_HDR_SIZE))
     781  if (AR_HDR_SIZE != read (fd, &ar_hdr, AR_HDR_SIZE))
    783782    goto lose;
    784783  /* Write back the header, thus touching the archive file.  */
    785784  if (lseek (fd, pos, 0) < 0)
    786785    goto lose;
    787   if (AR_HDR_SIZE != write (fd, (char *) &ar_hdr, AR_HDR_SIZE))
     786  if (AR_HDR_SIZE != write (fd, &ar_hdr, AR_HDR_SIZE))
    788787    goto lose;
    789788  /* The file's mtime is the time we we want.  */
     
    805804  if (lseek (fd, pos, 0) < 0)
    806805    goto lose;
    807   if (AR_HDR_SIZE != write (fd, (char *) &ar_hdr, AR_HDR_SIZE))
     806  if (AR_HDR_SIZE != write (fd, &ar_hdr, AR_HDR_SIZE))
    808807    goto lose;
    809808  close (fd);
     
    822821
    823822long int
    824 describe_member (int desc, char *name, int truncated,
     823describe_member (int desc, const char *name, int truncated,
    825824                 long int hdrpos, long int datapos, long int size,
    826                  long int date, int uid, int gid, int mode)
     825                 long int date, int uid, int gid, int mode, const void *arg)
    827826{
    828827  extern char *ctime ();
     
    840839main (int argc, char **argv)
    841840{
    842   ar_scan (argv[1], describe_member);
     841  ar_scan (argv[1], describe_member, NULL);
    843842  return 0;
    844843}
  • vendor/gnumake/current/commands.c

    r501 r900  
    3434#endif
    3535
    36 extern int remote_kill PARAMS ((int id, int sig));
     36int remote_kill (int id, int sig);
    3737
    3838#ifndef HAVE_UNISTD_H
    39 extern int getpid ();
     39int getpid ();
    4040#endif
    4141
     
    4646set_file_variables (struct file *file)
    4747{
    48   struct dep *d;
    49   char *at, *percent, *star, *less;
     48  const struct dep *d;
     49  const char *at, *percent, *star, *less;
    5050
    5151#ifndef NO_ARCHIVES
     
    5656    {
    5757      unsigned int len;
     58      const char *cp;
    5859      char *p;
    5960
    60       p = strchr (file->name, '(');
    61       at = (char *) alloca (p - file->name + 1);
    62       bcopy (file->name, at, p - file->name);
    63       at[p - file->name] = '\0';
    64       len = strlen (p + 1);
    65       percent = (char *) alloca (len);
    66       bcopy (p + 1, percent, len - 1);
    67       percent[len - 1] = '\0';
     61      cp = strchr (file->name, '(');
     62      p = alloca (cp - file->name + 1);
     63      memcpy (p, file->name, cp - file->name);
     64      p[cp - file->name] = '\0';
     65      at = p;
     66      len = strlen (cp + 1);
     67      p = alloca (len);
     68      memcpy (p, cp + 1, len - 1);
     69      p[len - 1] = '\0';
     70      percent = p;
    6871    }
    6972  else
     
    8083         any suffix in the .SUFFIXES list stripped off for
    8184         explicit rules.  We store this in the `stem' member.  */
    82       register struct dep *d;
    83       char *name;
     85      const char *name;
    8486      unsigned int len;
    8587
     
    9799        }
    98100
    99       for (d = enter_file (".SUFFIXES")->deps; d != 0; d = d->next)
     101      for (d = enter_file (strcache_add (".SUFFIXES"))->deps; d ; d = d->next)
    100102        {
    101103          unsigned int slen = strlen (dep_name (d));
    102104          if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
    103105            {
    104               file->stem = savestring (name, len - slen);
     106              file->stem = strcache_add_len (name, len - slen);
    105107              break;
    106108            }
     
    139141  {
    140142    static char *plus_value=0, *bar_value=0, *qmark_value=0;
    141     static unsigned int qmark_max=0, plus_max=0, bar_max=0;
     143    static unsigned int plus_max=0, bar_max=0, qmark_max=0;
    142144
    143145    unsigned int qmark_len, plus_len, bar_len;
     
    166168      if (! d->ignore_mtime)
    167169        {
    168           char *c = dep_name (d);
     170          const char *c = dep_name (d);
    169171
    170172#ifndef NO_ARCHIVES
     
    178180            len = strlen (c);
    179181
    180           bcopy (c, cp, len);
     182          memcpy (cp, c, len);
    181183          cp += len;
    182184          *cp++ = FILE_LIST_SEPARATOR;
     
    217219    for (d = file->deps; d != 0; d = d->next)
    218220      {
    219         char *c = dep_name (d);
     221        const char *c = dep_name (d);
    220222
    221223#ifndef NO_ARCHIVES
     
    231233        if (d->ignore_mtime)
    232234          {
    233             bcopy (c, bp, len);
     235            memcpy (bp, c, len);
    234236            bp += len;
    235237            *bp++ = FILE_LIST_SEPARATOR;
     
    237239        else
    238240          {
    239             bcopy (c, cp, len);
     241            memcpy (cp, c, len);
    240242            cp += len;
    241243            *cp++ = FILE_LIST_SEPARATOR;
    242244            if (d->changed)
    243245              {
    244                 bcopy (c, qp, len);
     246                memcpy (qp, c, len);
    245247                qp += len;
    246248                *qp++ = FILE_LIST_SEPARATOR;
     
    271273chop_commands (struct commands *cmds)
    272274{
    273   register char *p;
     275  const char *p;
    274276  unsigned int nlines, idx;
    275277  char **lines;
     
    286288
    287289  nlines = 5;
    288   lines = (char **) xmalloc (5 * sizeof (char *));
     290  lines = xmalloc (5 * sizeof (char *));
    289291  idx = 0;
    290292  p = cmds->commands;
    291293  while (*p != '\0')
    292294    {
    293       char *end = p;
     295      const char *end = p;
    294296    find_end:;
    295297      end = strchr (end, '\n');
     
    299301        {
    300302          int backslash = 1;
    301           register char *b;
     303          const char *b;
    302304          for (b = end - 2; b >= p && *b == '\\'; --b)
    303305            backslash = !backslash;
     
    312314        {
    313315          nlines += 2;
    314           lines = (char **) xrealloc ((char *) lines,
    315                                       nlines * sizeof (char *));
     316          lines = xrealloc (lines, nlines * sizeof (char *));
    316317        }
    317318      lines[idx++] = savestring (p, end - p);
     
    324325    {
    325326      nlines = idx;
    326       lines = (char **) xrealloc ((char *) lines,
    327                                   nlines * sizeof (char *));
     327      lines = xrealloc (lines, nlines * sizeof (char *));
    328328    }
    329329
     
    332332
    333333  cmds->any_recurse = 0;
    334   cmds->lines_flags = (char *) xmalloc (nlines);
     334  cmds->lines_flags = xmalloc (nlines);
    335335  for (idx = 0; idx < nlines; ++idx)
    336336    {
     
    371371execute_file_commands (struct file *file)
    372372{
    373   register char *p;
     373  const char *p;
    374374
    375375  /* Don't go through all the preparations if
     
    460460  if (sig == SIGTERM)
    461461    {
    462       register struct child *c;
     462      struct child *c;
    463463      for (c = children; c != 0; c = c->next)
    464464        if (!c->remote)
     
    478478    )
    479479    {
    480       register struct child *c;
     480      struct child *c;
    481481
    482482      /* Remote children won't automatically get signals sent
     
    531531
    532532static void
    533 delete_target (struct file *file, char *on_behalf_of)
     533delete_target (struct file *file, const char *on_behalf_of)
    534534{
    535535  struct stat st;
     
    586586
    587587  /* Delete the target file if it changed.  */
    588   delete_target (child->file, (char *) 0);
     588  delete_target (child->file, NULL);
    589589
    590590  /* Also remove any non-precious targets listed in the `also_make' member.  */
     
    599599
    600600void
    601 print_commands (struct commands *cmds)
     601print_commands (const struct commands *cmds)
    602602{
    603   register char *s;
     603  const char *s;
    604604
    605605  fputs (_("#  commands to execute"), stdout);
     
    614614  while (*s != '\0')
    615615    {
    616       char *end;
     616      const char *end;
    617617
    618618      while (isspace ((unsigned char)*s))
  • vendor/gnumake/current/commands.h

    r501 r900  
    3636#define COMMANDS_NOERROR        4 /* No errors: -.  */
    3737
    38 extern void execute_file_commands PARAMS ((struct file *file));
    39 extern void print_commands PARAMS ((struct commands *cmds));
    40 extern void delete_child_targets PARAMS ((struct child *child));
    41 extern void chop_commands PARAMS ((struct commands *cmds));
    42 extern void set_file_variables PARAMS ((struct file *file));
     38void execute_file_commands (struct file *file);
     39void print_commands (const struct commands *cmds);
     40void delete_child_targets (struct child *child);
     41void chop_commands (struct commands *cmds);
     42void set_file_variables (struct file *file);
  • vendor/gnumake/current/config/dospaths.m4

    r501 r900  
    2323      [
    2424        AC_COMPILE_IFELSE([
    25 #if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __EMX__ && !defined __MSYS__
     25#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __EMX__ && !defined __MSYS__ && !defined __CYGWIN__
    2626neither MSDOS nor Windows nor OS2
    2727#endif
  • vendor/gnumake/current/configure.in

    r501 r900  
    1717# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1818
    19 AC_INIT([GNU make],[3.81],[[email protected]])
     19AC_INIT([GNU make],[3.81.90],[[email protected]])
    2020
    2121AC_PREREQ(2.59)
    22 AC_REVISION([[$Id: configure.in,v 1.142 2006/04/01 06:36:40 psmith Exp $]])
     22AC_REVISION([[$Id: configure.in,v 1.147 2007/05/09 02:01:53 psmith Exp $]])
    2323
    2424# Autoconf setup
     
    4545AC_MINIX
    4646
    47 # Needed for ansi2knr
    48 AM_C_PROTOTYPES
    49 
    5047# Enable gettext, in "external" mode.
    5148
     
    7269if test "$ac_cv_prog_cc_stdc" != no; then
    7370  AC_DEFINE(HAVE_ANSI_COMPILER, 1,
    74               [Define if your compiler conforms to the ANSI C standard.])
     71              [Define to 1 if your compiler conforms to the ANSI C standard.])
    7572fi
    7673
     
    123120  if test "$ac_cv_search_clock_gettime" != no; then
    124121    AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
    125               [Define if you have the clock_gettime function.])
     122              [Define to 1 if you have the clock_gettime function.])
    126123  fi
    127124fi
     
    147144if test "$ac_cv_func_gettimeofday" = yes; then
    148145  AC_DEFINE(HAVE_GETTIMEOFDAY, 1,
    149             [Define if you have a standard gettimeofday function])
    150 fi
    151 
    152 AC_CHECK_FUNCS( memcpy memmove strchr strdup mkstemp mktemp fdopen \
     146            [Define to 1 if you have a standard gettimeofday function])
     147fi
     148
     149AC_CHECK_FUNCS( strdup mkstemp mktemp fdopen \
    153150                bsd_signal dup2 getcwd realpath sigsetmask sigaction \
    154151                getgroups seteuid setegid setlinebuf setreuid setregid \
     
    157154
    158155AC_FUNC_SETVBUF_REVERSED
     156
     157# Rumor has it that strcasecmp lives in -lresolv on some odd systems.
     158# It doesn't hurt much to use our own if we can't find it so I don't
     159# make the effort here.
     160AC_CHECK_FUNCS(strcasecmp strcmpi stricmp)
    159161
    160162# strcoll() is used by the GNU glob library
     
    180182  if test "$make_cv_nlist_struct" = yes; then
    181183    AC_DEFINE(NLIST_STRUCT, 1,
    182        [Define if struct nlist.n_name is a pointer rather than an array.])
     184       [Define to 1 if struct nlist.n_name is a pointer rather than an array.])
    183185  fi
    184186fi
     
    195197
    196198# Check out the wait reality.
    197 AC_CHECK_HEADERS(sys/wait.h)
     199AC_CHECK_HEADERS(sys/wait.h,,,[[#include <sys/types.h>]])
    198200AC_CHECK_FUNCS(waitpid wait3)
    199201AC_MSG_CHECKING(for union wait)
     
    221223if test "$make_cv_union_wait" = yes; then
    222224  AC_DEFINE(HAVE_UNION_WAIT, 1,
    223             [Define this if you have the \`union wait' type in <sys/wait.h>.])
     225            [Define to 1 if you have the \`union wait' type in <sys/wait.h>.])
    224226fi
    225227AC_MSG_RESULT($make_cv_union_wait)
     
    229231if test "$PATH_SEPARATOR" = ';'; then
    230232  AC_DEFINE(HAVE_DOS_PATHS, 1,
    231             [Define this if your system requires backslashes or drive specs in pathnames.])
     233            [Define to 1 if your system requires backslashes or drive specs in pathnames.])
    232234fi
    233235
     
    265267AC_ARG_ENABLE(case-insensitive-file-system,
    266268  AC_HELP_STRING([--enable-case-insensitive-file-system],
    267                  [enable case insensitive file system support]),
    268   case_insensitive_fs="yes" AC_DEFINE(HAVE_CASE_INSENSITIVE_FS),
    269   case_insensitive_fs="no")
     269                 [assume file systems are case insensitive]),
     270  [case $enableval in
     271     yes) AC_DEFINE(HAVE_CASE_INSENSITIVE_FS) ;;
     272   esac])
    270273
    271274# See if we can handle the job server feature, and if the user wants it.
     
    290293if test "$make_cv_sa_restart" != no; then
    291294  AC_DEFINE(HAVE_SA_RESTART, 1,
    292      [Define if <signal.h> defines the SA_RESTART constant.])
     295     [Define to 1 if <signal.h> defines the SA_RESTART constant.])
    293296fi
    294297
     
    302305  yes/yes/yes/yes/yes)
    303306    AC_DEFINE(MAKE_JOBSERVER, 1,
    304               [Define this to enable job server support in GNU make.]);;
     307              [Define to 1 to enable job server support in GNU make.]);;
    305308esac
    306309
     
    310313  yes/yes)
    311314    AC_DEFINE(MAKE_SYMLINKS, 1,
    312               [Define this to enable symbolic link timestamp checking.]);;
     315              [Define to 1 to enable symbolic link timestamp checking.]);;
    313316esac
    314317
     
    337340  case "$make_cv_sys_get_minus_G" in
    338341    yes) AC_DEFINE(SCCS_GET_MINUS_G, 1,
    339            [Define this if the SCCS 'get' command understands the '-G<file>' option.]);;
     342           [Define to 1 if the SCCS 'get' command understands the '-G<file>' option.]);;
    340343  esac
    341344fi
     
    385388esac
    386389
     390AC_DEFINE_UNQUOTED(PATH_SEPARATOR_CHAR,'$PATH_SEPARATOR',[Define to the character that separates directories in PATH.])
     391
    387392# Include the Maintainer's Makefile section, if it's here.
    388393
  • vendor/gnumake/current/default.c

    r501 r900  
    4242.w .ch .cweb .web .com .sh .elc .el";
    4343#elif defined(__EMX__)
    44   = ".out .a .ln .o .c .cc .C .cpp .p .f .F .r .y .l .s .S \
     44  = ".out .a .ln .o .c .cc .C .cpp .p .f .F .m .r .y .l .ym .yl .s .S \
    4545.mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
    4646.w .ch .web .sh .elc .el .obj .exe .dll .lib";
    4747#else
    48   = ".out .a .ln .o .c .cc .C .cpp .p .f .F .r .y .l .s .S \
     48  = ".out .a .ln .o .c .cc .C .cpp .p .f .F .m .r .y .l .ym .yl .s .S \
    4949.mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \
    5050.w .ch .web .sh .elc .el";
     
    193193    ".f",
    194194    "$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     195    ".m",
     196    "$(LINK.m) $^ $(LOADLIBES) $(LDLIBS) -o $@",
    195197    ".p",
    196198    "$(LINK.p) $^ $(LOADLIBES) $(LDLIBS) -o $@",
     
    222224    ".f.o",
    223225    "$(COMPILE.f) $(OUTPUT_OPTION) $<",
     226    ".m.o",
     227    "$(COMPILE.m) $(OUTPUT_OPTION) $<",
    224228    ".p.o",
    225229    "$(COMPILE.p) $(OUTPUT_OPTION) $<",
     
    250254    ".l.c",
    251255    "@$(RM) $@ \n $(LEX.l) $< > $@",
     256    ".ym.m",
     257    "$(YACC.m) $< \n mv -f y.tab.c $@",
     258    ".lm.m",
     259    "@$(RM) $@ \n $(LEX.m) $< > $@",
    252260
    253261    ".F.f",
     
    256264    "$(PREPROCESS.r) $(OUTPUT_OPTION) $<",
    257265
    258     /* This might actually make lex.yy.c if there's no %R%
    259        directive in $*.l, but in that case why were you
    260        trying to make $*.r anyway?  */
     266    /* This might actually make lex.yy.c if there's no %R% directive in $*.l,
     267       but in that case why were you trying to make $*.r anyway?  */
    261268    ".l.r",
    262269    "$(LEX.l) $< > $@ \n mv -f lex.yy.r $@",
     
    303310  };
    304311
    305 static char *default_variables[] =
     312static const char *default_variables[] =
    306313  {
    307314#ifdef VMS
     
    399406    "CXX", "gcc",
    400407# endif /* __MSDOS__ */
     408    "OBJC", "gcc",
    401409#else
    402410    "CC", "cc",
    403411    "CXX", "g++",
     412    "OBJC", "cc",
    404413#endif
    405414
     
    469478    "COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
    470479    "LINK.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
     480    "COMPILE.m", "$(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
     481    "LINK.m", "$(OBJC) $(OBJCFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
    471482    "COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c",
    472483    "COMPILE.C", "$(COMPILE.cc)",
     
    477488    "YACC.y", "$(YACC) $(YFLAGS)",
    478489    "LEX.l", "$(LEX) $(LFLAGS) -t",
     490    "YACC.m", "$(YACC) $(YFLAGS)",
     491    "LEX.m", "$(LEX) $(LFLAGS) -t",
    479492    "COMPILE.f", "$(FC) $(FFLAGS) $(TARGET_ARCH) -c",
    480493    "LINK.f", "$(FC) $(FFLAGS) $(LDFLAGS) $(TARGET_ARCH)",
     
    524537set_default_suffixes (void)
    525538{
    526   suffix_file = enter_file (".SUFFIXES");
     539  suffix_file = enter_file (strcache_add (".SUFFIXES"));
    527540
    528541  if (no_builtin_rules_flag)
    529     (void) define_variable ("SUFFIXES", 8, "", o_default, 0);
     542    define_variable ("SUFFIXES", 8, "", o_default, 0);
    530543  else
    531544    {
     
    534547        multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1),
    535548                    sizeof (struct dep));
    536       (void) define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0);
     549      define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0);
    537550    }
    538551}
     
    540553/* Enter the default suffix rules as file rules.  This used to be done in
    541554   install_default_implicit_rules, but that loses because we want the
    542    suffix rules installed before reading makefiles, and thee pattern rules
     555   suffix rules installed before reading makefiles, and the pattern rules
    543556   installed after.  */
    544557
     
    546559install_default_suffix_rules (void)
    547560{
    548   register char **s;
     561  char **s;
    549562
    550563  if (no_builtin_rules_flag)
    551564    return;
    552565
    553  for (s = default_suffix_rules; *s != 0; s += 2)
     566  for (s = default_suffix_rules; *s != 0; s += 2)
    554567    {
    555       register struct file *f = enter_file (s[0]);
     568      struct file *f = enter_file (strcache_add (s[0]));
    556569      /* Don't clobber cmds given in a makefile if there were any.  */
    557570      if (f->cmds == 0)
    558571        {
    559           f->cmds = (struct commands *) xmalloc (sizeof (struct commands));
     572          f->cmds = xmalloc (sizeof (struct commands));
    560573          f->cmds->fileinfo.filenm = 0;
    561574          f->cmds->commands = s[1];
     
    571584install_default_implicit_rules (void)
    572585{
    573   register struct pspec *p;
     586  struct pspec *p;
    574587
    575588  if (no_builtin_rules_flag)
     
    586599define_default_variables (void)
    587600{
    588   register char **s;
     601  const char **s;
    589602
    590603  if (no_builtin_variables_flag)
     
    592605
    593606  for (s = default_variables; *s != 0; s += 2)
    594     (void) define_variable (s[0], strlen (s[0]), s[1], o_default, 1);
     607    define_variable (s[0], strlen (s[0]), s[1], o_default, 1);
    595608}
  • vendor/gnumake/current/dep.h

    r501 r900  
    3737  {
    3838    struct dep *next;
    39     char *name;
    40     char *stem;
     39    const char *name;
     40    const char *stem;
    4141    struct file *file;
    4242    unsigned int changed : 8;
     
    5252  {
    5353    struct nameseq *next;
    54     char *name;
     54    const char *name;
    5555  };
    5656
    5757
    58 extern struct nameseq *multi_glob PARAMS ((struct nameseq *chain, unsigned int size));
     58struct nameseq *multi_glob (struct nameseq *chain, unsigned int size);
    5959#ifdef VMS
    60 extern struct nameseq *parse_file_seq ();
     60struct nameseq *parse_file_seq ();
    6161#else
    62 extern struct nameseq *parse_file_seq PARAMS ((char **stringp, int stopchar, unsigned int size, int strip));
     62struct nameseq *parse_file_seq (char **stringp, int stopchar, unsigned int size, int strip);
    6363#endif
    64 extern char *tilde_expand PARAMS ((char *name));
     64char *tilde_expand (const char *name);
    6565
    6666#ifndef NO_ARCHIVES
    67 extern struct nameseq *ar_glob PARAMS ((char *arname, char *member_pattern, unsigned int size));
     67struct nameseq *ar_glob (const char *arname, const char *member_pattern, unsigned int size);
    6868#endif
    6969
    70 #ifndef iAPX286
    7170#define dep_name(d) ((d)->name == 0 ? (d)->file->name : (d)->name)
    72 #else
    73 /* Buggy compiler can't hack this.  */
    74 extern char *dep_name ();
    75 #endif
    7671
    77 extern struct dep *alloc_dep PARAMS ((void));
    78 extern void free_dep PARAMS ((struct dep *d));
    79 extern struct dep *copy_dep_chain PARAMS ((const struct dep *d));
    80 extern void free_dep_chain PARAMS ((struct dep *d));
    81 extern void free_ns_chain PARAMS ((struct nameseq *n));
    82 extern struct dep *read_all_makefiles PARAMS ((char **makefiles));
    83 extern int eval_buffer PARAMS ((char *buffer));
    84 extern int update_goal_chain PARAMS ((struct dep *goals));
    85 extern void uniquize_deps PARAMS ((struct dep *));
     72struct dep *alloc_dep (void);
     73void free_dep (struct dep *d);
     74struct dep *copy_dep_chain (const struct dep *d);
     75void free_dep_chain (struct dep *d);
     76void free_ns_chain (struct nameseq *n);
     77struct dep *read_all_makefiles (const char **makefiles);
     78int eval_buffer (char *buffer);
     79int update_goal_chain (struct dep *goals);
     80void uniquize_deps (struct dep *);
  • vendor/gnumake/current/dir.c

    r501 r900  
    2424# define NAMLEN(dirent) strlen((dirent)->d_name)
    2525# ifdef VMS
    26 extern char *vmsify PARAMS ((char *name, int type));
     26char *vmsify (char *name, int type);
    2727# endif
    2828#else
     
    6969#endif
    7070
    71 static char *
    72 dosify (char *filename)
     71static const char *
     72dosify (const char *filename)
    7373{
    7474  static char dos_filename[14];
     
    119119
    120120#ifdef HAVE_CASE_INSENSITIVE_FS
    121 static char *
    122 downcase (char *filename)
     121static const char *
     122downcase (const char *filename)
    123123{
    124124  static PATH_VAR (new_filename);
     
    132132
    133133  /* First, transform the name part.  */
    134   for (i = 0; *filename != '\0'; ++i)
    135   {
    136     *df++ = tolower ((unsigned char)*filename);
    137     ++filename;
    138   }
     134  while (*filename != '\0')
     135    {
     136      *df++ = tolower ((unsigned char)*filename);
     137      ++filename;
     138    }
    139139
    140140  *df = 0;
     
    217217    dev_t dev;                  /* Device and inode numbers of this dir.  */
    218218#ifdef WINDOWS32
    219     /*
    220      * Inode means nothing on WINDOWS32. Even file key information is
    221      * unreliable because it is random per file open and undefined
    222      * for remote filesystems. The most unique attribute I can
    223      * come up with is the fully qualified name of the directory. Beware
    224      * though, this is also unreliable. I'm open to suggestion on a better
    225      * way to emulate inode.
    226      */
     219    /* Inode means nothing on WINDOWS32. Even file key information is
     220     * unreliable because it is random per file open and undefined for remote
     221     * filesystems. The most unique attribute I can come up with is the fully
     222     * qualified name of the directory. Beware though, this is also
     223     * unreliable. I'm open to suggestion on a better way to emulate inode.  */
    227224    char *path_key;
    228225    int   ctime;
    229226    int   mtime;        /* controls check for stale directory cache */
    230227    int   fs_flags;     /* FS_FAT, FS_NTFS, ... */
    231 #define FS_FAT      0x1
    232 #define FS_NTFS     0x2
    233 #define FS_UNKNOWN  0x4
    234 #else
    235 #ifdef VMS
     228# define FS_FAT      0x1
     229# define FS_NTFS     0x2
     230# define FS_UNKNOWN  0x4
     231#else
     232# ifdef VMS
    236233    ino_t ino[3];
    237 #else
     234# else
    238235    ino_t ino;
    239 #endif
     236# endif
    240237#endif /* WINDOWS32 */
    241238    struct hash_table dirfiles; /* Files in this directory.  */
     
    246243directory_contents_hash_1 (const void *key_0)
    247244{
    248   struct directory_contents const *key = (struct directory_contents const *) key_0;
     245  const struct directory_contents *key = key_0;
    249246  unsigned long hash;
    250247
     
    269266directory_contents_hash_2 (const void *key_0)
    270267{
    271   struct directory_contents const *key = (struct directory_contents const *) key_0;
     268  const struct directory_contents *key = key_0;
    272269  unsigned long hash;
    273270
     
    304301directory_contents_hash_cmp (const void *xv, const void *yv)
    305302{
    306   struct directory_contents const *x = (struct directory_contents const *) xv;
    307   struct directory_contents const *y = (struct directory_contents const *) yv;
     303  const struct directory_contents *x = xv;
     304  const struct directory_contents *y = yv;
    308305  int result;
    309306
     
    341338struct directory
    342339  {
    343     char *name;                 /* Name of the directory.  */
     340    const char *name;                   /* Name of the directory.  */
    344341
    345342    /* The directory's contents.  This data may be shared by several
     
    352349directory_hash_1 (const void *key)
    353350{
    354   return_ISTRING_HASH_1 (((struct directory const *) key)->name);
     351  return_ISTRING_HASH_1 (((const struct directory *) key)->name);
    355352}
    356353
     
    358355directory_hash_2 (const void *key)
    359356{
    360   return_ISTRING_HASH_2 (((struct directory const *) key)->name);
     357  return_ISTRING_HASH_2 (((const struct directory *) key)->name);
    361358}
    362359
     
    364361directory_hash_cmp (const void *x, const void *y)
    365362{
    366   return_ISTRING_COMPARE (((struct directory const *) x)->name,
    367                           ((struct directory const *) y)->name);
     363  return_ISTRING_COMPARE (((const struct directory *) x)->name,
     364                          ((const struct directory *) y)->name);
    368365}
    369366
     
    382379struct dirfile
    383380  {
    384     char *name;                 /* Name of the file.  */
     381    const char *name;           /* Name of the file.  */
    385382    short length;
    386383    short impossible;           /* This file is impossible.  */
     
    402399dirfile_hash_cmp (const void *xv, const void *yv)
    403400{
    404   struct dirfile const *x = ((struct dirfile const *) xv);
    405   struct dirfile const *y = ((struct dirfile const *) yv);
     401  const struct dirfile *x = xv;
     402  const struct dirfile *y = yv;
    406403  int result = x->length - y->length;
    407404  if (result)
     
    415412
    416413
    417 static int dir_contents_file_exists_p PARAMS ((struct directory_contents *dir, char *filename));
    418 static struct directory *find_directory PARAMS ((char *name));
     414static int dir_contents_file_exists_p (struct directory_contents *dir,
     415                                       const char *filename);
     416static struct directory *find_directory (const char *name);
    419417
    420418/* Find the directory named NAME and return its `struct directory'.  */
    421419
    422420static struct directory *
    423 find_directory (char *name)
    424 {
    425   register char *p;
    426   register struct directory *dir;
    427   register struct directory **dir_slot;
     421find_directory (const char *name)
     422{
     423  const char *p;
     424  struct directory *dir;
     425  struct directory **dir_slot;
    428426  struct directory dir_key;
    429427  int r;
     
    454452
    455453      p = name + strlen (name);
    456       dir = (struct directory *) xmalloc (sizeof (struct directory));
    457       dir->name = savestring (name, p - name);
     454      dir = xmalloc (sizeof (struct directory));
     455      dir->name = strcache_add_len (name, p - name);
    458456      hash_insert_at (&directories, dir, dir_slot);
    459457      /* The directory is not in the name hash table.
     
    553551              ENULLLOOP (dc->dirstream, opendir (name));
    554552              if (dc->dirstream == 0)
    555                 /* Couldn't open the directory.  Mark this by
    556                    setting the `files' member to a nil pointer.  */
     553                /* Couldn't open the directory.  Mark this by setting the
     554                   `files' member to a nil pointer.  */
    557555                dc->dirfiles.ht_vec = 0;
    558556              else
     
    565563                    /* We have too many directories open already.
    566564                       Read the entire directory and then close it.  */
    567                     (void) dir_contents_file_exists_p (dc, (char *) 0);
     565                    dir_contents_file_exists_p (dc, 0);
    568566                }
    569567            }
     
    582580
    583581static int
    584 dir_contents_file_exists_p (struct directory_contents *dir, char *filename)
     582dir_contents_file_exists_p (struct directory_contents *dir,
     583                            const char *filename)
    585584{
    586585  unsigned int hash;
     
    593592
    594593  if (dir == 0 || dir->dirfiles.ht_vec == 0)
    595     {
    596594    /* The directory could not be stat'd or opened.  */
    597       return 0;
    598     }
     595    return 0;
     596
    599597#ifdef __MSDOS__
    600598  filename = dosify (filename);
     
    626624      dirfile_key.name = filename;
    627625      dirfile_key.length = strlen (filename);
    628       df = (struct dirfile *) hash_find_item (&dir->dirfiles, &dirfile_key);
     626      df = hash_find_item (&dir->dirfiles, &dirfile_key);
    629627      if (df)
    630         {
    631           return !df->impossible;
    632         }
     628        return !df->impossible;
    633629    }
    634630
     
    651647              rehash = 1;
    652648            }
    653           else if (stat(dir->path_key, &st) == 0 && st.st_mtime > dir->mtime)
     649          else if (stat (dir->path_key, &st) == 0 && st.st_mtime > dir->mtime)
    654650            {
    655651              /* reset date stamp to show most recent re-process.  */
     
    663659
    664660          /* make sure directory can still be opened; if not return.  */
    665           dir->dirstream = opendir(dir->path_key);
     661          dir->dirstream = opendir (dir->path_key);
    666662          if (!dir->dirstream)
    667663            return 0;
     
    682678      ENULLLOOP (d, readdir (dir->dirstream));
    683679      if (d == 0)
    684         break;
     680        {
     681          if (errno)
     682            fatal (NILF, "INTERNAL: readdir: %s\n", strerror (errno));
     683          break;
     684        }
    685685
    686686#if defined(VMS) && defined(HAVE_DIRENT_H)
     
    707707#endif
    708708        {
    709           df = (struct dirfile *) xmalloc (sizeof (struct dirfile));
    710           df->name = savestring (d->d_name, len);
     709          df = xmalloc (sizeof (struct dirfile));
     710          df->name = strcache_add_len (d->d_name, len);
    711711          df->length = len;
    712712          df->impossible = 0;
     
    715715      /* Check if the name matches the one we're searching for.  */
    716716      if (filename != 0 && strieq (d->d_name, filename))
    717         {
    718           return 1;
    719         }
     717        return 1;
    720718    }
    721719
     
    736734
    737735int
    738 dir_file_exists_p (char *dirname, char *filename)
     736dir_file_exists_p (const char *dirname, const char *filename)
    739737{
    740738  return dir_contents_file_exists_p (find_directory (dirname)->contents,
     
    746744
    747745int
    748 file_exists_p (char *name)
    749 {
    750   char *dirend;
    751   char *dirname;
    752   char *slash;
     746file_exists_p (const char *name)
     747{
     748  const char *dirend;
     749  const char *dirname;
     750  const char *slash;
    753751
    754752#ifndef NO_ARCHIVES
     
    761759  if (dirend == 0)
    762760    dirend = strrchr (name, ':');
    763   if (dirend == (char *)0)
     761  if (dirend == 0)
    764762    return dir_file_exists_p ("[]", name);
    765763#else /* !VMS */
     
    768766  /* Forward and backslashes might be mixed.  We need the rightmost one.  */
    769767  {
    770     char *bslash = strrchr(name, '\\');
     768    const char *bslash = strrchr(name, '\\');
    771769    if (!dirend || bslash > dirend)
    772770      dirend = bslash;
     
    789787  else
    790788    {
     789      char *p;
    791790#ifdef HAVE_DOS_PATHS
    792791  /* d:/ and d: are *very* different...  */
     
    795794        dirend++;
    796795#endif
    797       dirname = (char *) alloca (dirend - name + 1);
    798       bcopy (name, dirname, dirend - name);
    799       dirname[dirend - name] = '\0';
     796      p = alloca (dirend - name + 1);
     797      memcpy (p, name, dirend - name);
     798      p[dirend - name] = '\0';
     799      dirname = p;
    800800    }
    801801  return dir_file_exists_p (dirname, slash + 1);
     
    808808
    809809void
    810 file_impossible (char *filename)
    811 {
    812   char *dirend;
    813   register char *p = filename;
    814   register struct directory *dir;
    815   register struct dirfile *new;
     810file_impossible (const char *filename)
     811{
     812  const char *dirend;
     813  const char *p = filename;
     814  struct directory *dir;
     815  struct dirfile *new;
    816816
    817817#ifdef VMS
     
    827827  /* Forward and backslashes might be mixed.  We need the rightmost one.  */
    828828  {
    829     char *bslash = strrchr(p, '\\');
     829    const char *bslash = strrchr(p, '\\');
    830830    if (!dirend || bslash > dirend)
    831831      dirend = bslash;
     
    844844  else
    845845    {
    846       char *dirname;
    847       char *slash = dirend;
     846      const char *dirname;
     847      const char *slash = dirend;
    848848      if (dirend == p)
    849849        dirname = "/";
    850850      else
    851851        {
     852          char *cp;
    852853#ifdef HAVE_DOS_PATHS
    853854          /* d:/ and d: are *very* different...  */
     
    856857            dirend++;
    857858#endif
    858           dirname = (char *) alloca (dirend - p + 1);
    859           bcopy (p, dirname, dirend - p);
    860           dirname[dirend - p] = '\0';
     859          cp = alloca (dirend - p + 1);
     860          memcpy (cp, p, dirend - p);
     861          cp[dirend - p] = '\0';
     862          dirname = cp;
    861863        }
    862864      dir = find_directory (dirname);
     
    868870      /* The directory could not be stat'd.  We allocate a contents
    869871         structure for it, but leave it out of the contents hash table.  */
    870       dir->contents = (struct directory_contents *)
    871         xmalloc (sizeof (struct directory_contents));
    872       bzero ((char *) dir->contents, sizeof (struct directory_contents));
     872      dir->contents = xmalloc (sizeof (struct directory_contents));
     873      memset (dir->contents, '\0', sizeof (struct directory_contents));
    873874    }
    874875
     
    881882  /* Make a new entry and put it in the table.  */
    882883
    883   new = (struct dirfile *) xmalloc (sizeof (struct dirfile));
    884   new->name = xstrdup (filename);
     884  new = xmalloc (sizeof (struct dirfile));
    885885  new->length = strlen (filename);
     886  new->name = strcache_add_len (filename, new->length);
    886887  new->impossible = 1;
    887888  hash_insert (&dir->contents->dirfiles, new);
     
    892893
    893894int
    894 file_impossible_p (char *filename)
    895 {
    896   char *dirend;
    897   register char *p = filename;
    898   register struct directory_contents *dir;
    899   register struct dirfile *dirfile;
     895file_impossible_p (const char *filename)
     896{
     897  const char *dirend;
     898  const char *p = filename;
     899  struct directory_contents *dir;
     900  struct dirfile *dirfile;
    900901  struct dirfile dirfile_key;
    901902
     
    909910  /* Forward and backslashes might be mixed.  We need the rightmost one.  */
    910911  {
    911     char *bslash = strrchr(filename, '\\');
     912    const char *bslash = strrchr(filename, '\\');
    912913    if (!dirend || bslash > dirend)
    913914      dirend = bslash;
     
    926927  else
    927928    {
    928       char *dirname;
    929       char *slash = dirend;
     929      const char *dirname;
     930      const char *slash = dirend;
    930931      if (dirend == filename)
    931932        dirname = "/";
    932933      else
    933934        {
     935          char *cp;
    934936#ifdef HAVE_DOS_PATHS
    935937          /* d:/ and d: are *very* different...  */
     
    938940            dirend++;
    939941#endif
    940           dirname = (char *) alloca (dirend - filename + 1);
    941           bcopy (p, dirname, dirend - p);
    942           dirname[dirend - p] = '\0';
     942          cp = alloca (dirend - filename + 1);
     943          memcpy (cp, p, dirend - p);
     944          cp[dirend - p] = '\0';
     945          dirname = cp;
    943946        }
    944947      dir = find_directory (dirname)->contents;
     
    962965  dirfile_key.name = filename;
    963966  dirfile_key.length = strlen (filename);
    964   dirfile = (struct dirfile *) hash_find_item (&dir->dirfiles, &dirfile_key);
     967  dirfile = hash_find_item (&dir->dirfiles, &dirfile_key);
    965968  if (dirfile)
    966969    return dirfile->impossible;
     
    973976   directory hash table that matches DIR.  */
    974977
    975 char *
    976 dir_name (char *dir)
     978const char *
     979dir_name (const char *dir)
    977980{
    978981  return find_directory (dir)->name;
     
    985988print_dir_data_base (void)
    986989{
    987   register unsigned int files;
    988   register unsigned int impossible;
    989   register struct directory **dir_slot;
    990   register struct directory **dir_end;
     990  unsigned int files;
     991  unsigned int impossible;
     992  struct directory **dir_slot;
     993  struct directory **dir_end;
    991994
    992995  puts (_("\n# Directories\n"));
     
    9981001  for ( ; dir_slot < dir_end; dir_slot++)
    9991002    {
    1000       register struct directory *dir = *dir_slot;
     1003      struct directory *dir = *dir_slot;
    10011004      if (! HASH_VACANT (dir))
    10021005        {
     
    10231026          else
    10241027            {
    1025               register unsigned int f = 0;
    1026               register unsigned int im = 0;
    1027               register struct dirfile **files_slot;
    1028               register struct dirfile **files_end;
     1028              unsigned int f = 0;
     1029              unsigned int im = 0;
     1030              struct dirfile **files_slot;
     1031              struct dirfile **files_end;
    10291032
    10301033              files_slot = (struct dirfile **) dir->contents->dirfiles.ht_vec;
     
    10321035              for ( ; files_slot < files_end; files_slot++)
    10331036                {
    1034                   register struct dirfile *df = *files_slot;
     1037                  struct dirfile *df = *files_slot;
    10351038                  if (! HASH_VACANT (df))
    10361039                    {
     
    11031106
    11041107/* Forward declarations.  */
    1105 static __ptr_t open_dirstream PARAMS ((const char *));
    1106 static struct dirent *read_dirstream PARAMS ((__ptr_t));
     1108static __ptr_t open_dirstream (const char *);
     1109static struct dirent *read_dirstream (__ptr_t);
    11071110
    11081111static __ptr_t
     
    11101113{
    11111114  struct dirstream *new;
    1112   struct directory *dir = find_directory ((char *)directory);
     1115  struct directory *dir = find_directory (directory);
    11131116
    11141117  if (dir->contents == 0 || dir->contents->dirfiles.ht_vec == 0)
     
    11201123     in being lazy, since glob will want to see every file anyway.  */
    11211124
    1122   (void) dir_contents_file_exists_p (dir->contents, (char *) 0);
    1123 
    1124   new = (struct dirstream *) xmalloc (sizeof (struct dirstream));
     1125  dir_contents_file_exists_p (dir->contents, 0);
     1126
     1127  new = xmalloc (sizeof (struct dirstream));
    11251128  new->contents = dir->contents;
    11261129  new->dirfile_slot = (struct dirfile **) new->contents->dirfiles.ht_vec;
     
    11321135read_dirstream (__ptr_t stream)
    11331136{
     1137  static char *buf;
     1138  static unsigned int bufsz;
     1139
    11341140  struct dirstream *const ds = (struct dirstream *) stream;
    11351141  struct directory_contents *dc = ds->contents;
    11361142  struct dirfile **dirfile_end = (struct dirfile **) dc->dirfiles.ht_vec + dc->dirfiles.ht_size;
    1137   static char *buf;
    1138   static unsigned int bufsz;
    11391143
    11401144  while (ds->dirfile_slot < dirfile_end)
    11411145    {
    1142       register struct dirfile *df = *ds->dirfile_slot++;
     1146      struct dirfile *df = *ds->dirfile_slot++;
    11431147      if (! HASH_VACANT (df) && !df->impossible)
    11441148        {
    1145           /* The glob interface wants a `struct dirent',
    1146              so mock one up.  */
     1149          /* The glob interface wants a `struct dirent', so mock one up.  */
    11471150          struct dirent *d;
    11481151          unsigned int len = df->length + 1;
    1149           if (sizeof *d - sizeof d->d_name + len > bufsz)
     1152          unsigned int sz = sizeof (*d) - sizeof (d->d_name) + len;
     1153          if (sz > bufsz)
    11501154            {
    1151               if (buf != 0)
    1152                 free (buf);
    11531155              bufsz *= 2;
    1154               if (sizeof *d - sizeof d->d_name + len > bufsz)
    1155                 bufsz = sizeof *d - sizeof d->d_name + len;
    1156               buf = xmalloc (bufsz);
     1156              if (sz > bufsz)
     1157                bufsz = sz;
     1158              buf = xrealloc (buf, bufsz);
    11571159            }
    11581160          d = (struct dirent *) buf;
     
    11911193#ifndef stat
    11921194# ifndef VMS
    1193 extern int stat PARAMS ((const char *path, struct stat *sbuf));
     1195int stat (const char *path, struct stat *sbuf);
    11941196# endif
    11951197# define local_stat stat
     
    12081210dir_setup_glob (glob_t *gl)
    12091211{
    1210   /* Bogus sunos4 compiler complains (!) about & before functions.  */
    12111212  gl->gl_opendir = open_dirstream;
    12121213  gl->gl_readdir = read_dirstream;
     
    12231224             directory_hash_1, directory_hash_2, directory_hash_cmp);
    12241225  hash_init (&directory_contents, DIRECTORY_BUCKETS,
    1225              directory_contents_hash_1, directory_contents_hash_2, directory_contents_hash_cmp);
    1226 }
     1226             directory_contents_hash_1, directory_contents_hash_2,
     1227             directory_contents_hash_cmp);
     1228}
  • vendor/gnumake/current/doc/make.texi

    r501 r900  
    55@include version.texi
    66@set EDITION 0.70
    7 @set RCSID $Id: make.texi,v 1.45 2006/04/01 06:36:40 psmith Exp $
     7@set RCSID $Id: make.texi,v 1.47 2007/05/11 20:57:21 psmith Exp $
    88
    99@settitle GNU @code{make}
     
    5151
    5252
    53 @dircategory GNU Packages
     53@dircategory Software development
    5454@direntry
    5555* Make: (make).            Remake files automatically.
     
    10101010specially in certain situations.
    10111011
     1012You cannot use comments within variable references or function calls:
     1013any instance of @code{#} will be treated literally (rather than as the
     1014start of a comment) inside a variable reference or function call.
     1015
    10121016Within a command script (if the line begins with a TAB character) the
    10131017entire line is passed to the shell, just as with any other line that
     
    12521256@end example
    12531257
    1254 @xref{Text Functions}, for more information on the @code{word} and
    1255 @code{words} functions used above.  @xref{Flavors, The Two Flavors of
    1256 Variables}, for more information on simply-expanded (@code{:=})
    1257 variable definitions.
     1258@xref{Text Functions}, for more information on the @code{lastword}
     1259function used above.  @xref{Flavors, The Two Flavors of Variables},
     1260for more information on simply-expanded (@code{:=}) variable
     1261definitions.
    12581262
    12591263@node Special Variables, Remaking Makefiles, MAKEFILE_LIST Variable, Makefiles
     
    17451749@code{foo.1 bar.1} respectively.  In the third they will have values
    17461750@code{foo.1}, @code{foo.1 bar.1 foo.2 bar.2}, and @code{foo.1 bar.1
    1747 foo.2 bar.2} respectively.
     1751foo.2 bar.2 foo.1 foo.1 bar.1 foo.1 bar.1} respectively.
    17481752
    17491753Rules undergo secondary expansion in makefile order, except that
     
    19381942Variables, ,How to Use Variables}).  If you have enabled secondary
    19391943expansion (@pxref{Secondary Expansion}) and you want a literal dollar
    1940 sign in the prerequisites lise, you must actually write @emph{four}
     1944sign in the prerequisites list, you must actually write @emph{four}
    19411945dollar signs (@samp{$$$$}).
    19421946
     
    20012005The normal prerequisites section may of course be empty.  Also, you
    20022006may still declare multiple lines of prerequisites for the same target:
    2003 they are appended appropriately.  Note that if you declare the same
    2004 file to be both a normal and an order-only prerequisite, the normal
    2005 prerequisite takes precedence (since they are a strict superset of the
    2006 behavior of an order-only prerequisite).
     2007they are appended appropriately (normal prerequisites are appended to
     2008the list of normal prerequisites; order-only prerequisites are
     2009appended to the list of order-only prerequisites).  Note that if you
     2010declare the same file to be both a normal and an order-only
     2011prerequisite, the normal prerequisite takes precedence (since they
     2012have a strict superset of the behavior of an order-only prerequisite).
     2013
     2014Consider an example where your targets are to be placed in a separate
     2015directory, and that directory might not exist before @code{make} is
     2016run.  In this situation, you want the directory to be created before
     2017any targets are placed into it but, because the timestamps on
     2018directories change whenever a file is added, removed, or renamed, we
     2019certainly don't want to rebuild all the targets whenever the
     2020directory's timestamp changes.  One way to manage this is with
     2021order-only prerequisites: make the directory an order-only
     2022prerequisite on all the targets:
     2023
     2024@example
     2025OBJDIR := objdir
     2026OBJS := $(addprefix $(OBJDIR)/,foo.o bar.o baz.o)
     2027
     2028$(OBJDIR)/%.o : %.c
     2029        $(COMPILE.c) $(OUTPUT_OPTION) $<
     2030
     2031all: $(OBJS)
     2032
     2033$(OBJS): | $(OBJDIR)
     2034
     2035$(OBJDIR):
     2036        mkdir $(OBJDIR)
     2037@end example
     2038
     2039Now the rule to create the @file{objdir} directory will be run, if
     2040needed, before any @samp{.o} is built, but no @samp{.o} will be built
     2041because the @file{objdir} directory timestamp changed.
    20072042
    20082043@node Wildcards, Directory Search, Prerequisite Types, Rules
     
    29062941@xref{Secondary Expansion, ,Secondary Expansion}.
    29072942
    2908 The prerequisites of the special target @code{.SUFFIXES} are the list
    2909 of suffixes to be used in checking for suffix rules.
    2910 @xref{Suffix Rules, , Old-Fashioned Suffix Rules}.
    2911 
    29122943@findex .DELETE_ON_ERROR
    29132944@item .DELETE_ON_ERROR
     
    29963027@cindex parallel execution, overriding
    29973028
    2998 If @code{.NOTPARALLEL} is mentioned as a target, then this invocation of
    2999 @code{make} will be run serially, even if the @samp{-j} option is
    3000 given.  Any recursively invoked @code{make} command will still be run in
    3001 parallel (unless its makefile contains this target).  Any prerequisites
    3002 on this target are ignored.
     3029If @code{.NOTPARALLEL} is mentioned as a target, then this invocation
     3030of @code{make} will be run serially, even if the @samp{-j} option is
     3031given.  Any recursively invoked @code{make} command will still run
     3032commands in parallel (unless its makefile also contains this target).
     3033Any prerequisites on this target are ignored.
    30033034@end table
    30043035
     
    30943125if the file's name begins with a dot, no error message is printed.
    30953126This odd behavior is only for compatibility with other implementations
    3096 of @code{make}... you should avoid using it).  Occasionally it is
     3127of @code{make}@dots{} you should avoid using it).  Occasionally it is
    30973128useful to have the same target invoke multiple commands which are
    30983129defined in different parts of your makefile; you can use
     
    36533684
    36543685@noindent
    3655 Notice how the backslash/newline pair was removed inside the string quoted
    3656 with double quotes (@code{"..."}), but not from the string quoted with single
    3657 quotes (@code{'...'}).  This is the way the default shell (@file{/bin/sh})
    3658 handles backslash/newline pairs.  If you specify a different shell in your
    3659 makefiles it may treat them differently.
     3686Notice how the backslash/newline pair was removed inside the string
     3687quoted with double quotes (@code{"@dots{}"}), but not from the string
     3688quoted with single quotes (@code{'@dots{}'}).  This is the way the
     3689default shell (@file{/bin/sh}) handles backslash/newline pairs.  If
     3690you specify a different shell in your makefiles it may treat them
     3691differently.
    36603692
    36613693Sometimes you want to split a long line inside of single quotes, but
     
    39433975for it to finish before executing the next.  However, the @samp{-j} or
    39443976@samp{--jobs} option tells @code{make} to execute many commands
    3945 simultaneously.@refill
     3977simultaneously.  You can inhibit parallelism in a particular makefile
     3978with the @code{.NOTPARALLEL} pseudo-target (@pxref{Special
     3979Targets,Special Built-in Target Names}).@refill
    39463980
    39473981On MS-DOS, the @samp{-j} option has no effect, since that system doesn't
     
    83538387the special target @code{.SUFFIXES}).  The default suffix list is:
    83548388@code{.out}, @code{.a}, @code{.ln}, @code{.o}, @code{.c}, @code{.cc},
    8355 @code{.C}, @code{.cpp}, @code{.p}, @code{.f}, @code{.F}, @code{.r}, @code{.y},
    8356 @code{.l}, @code{.s}, @code{.S}, @code{.mod}, @code{.sym}, @code{.def},
    8357 @code{.h}, @code{.info}, @code{.dvi}, @code{.tex}, @code{.texinfo},
    8358 @code{.texi}, @code{.txinfo}, @code{.w}, @code{.ch} @code{.web},
    8359 @code{.sh}, @code{.elc}, @code{.el}.  All of the implicit rules
    8360 described below whose prerequisites have one of these suffixes are
    8361 actually suffix rules.  If you modify the suffix list, the only
    8362 predefined suffix rules in effect will be those named by one or two of
    8363 the suffixes that are on the list you specify; rules whose suffixes fail
    8364 to be on the list are disabled.  @xref{Suffix Rules, ,Old-Fashioned
    8365 Suffix Rules}, for full details on suffix rules.
     8389@code{.C}, @code{.cpp}, @code{.p}, @code{.f}, @code{.F}, @code{.m},
     8390@code{.r}, @code{.y}, @code{.l}, @code{.ym}, @code{.lm}, @code{.s},
     8391@code{.S}, @code{.mod}, @code{.sym}, @code{.def}, @code{.h},
     8392@code{.info}, @code{.dvi}, @code{.tex}, @code{.texinfo}, @code{.texi},
     8393@code{.txinfo}, @code{.w}, @code{.ch} @code{.web}, @code{.sh},
     8394@code{.elc}, @code{.el}.  All of the implicit rules described below
     8395whose prerequisites have one of these suffixes are actually suffix
     8396rules.  If you modify the suffix list, the only predefined suffix
     8397rules in effect will be those named by one or two of the suffixes that
     8398are on the list you specify; rules whose suffixes fail to be on the
     8399list are disabled.  @xref{Suffix Rules, ,Old-Fashioned Suffix Rules},
     8400for full details on suffix rules.
    83668401
    83678402@table @asis
     
    86948729@pindex cc
    86958730
    8696 @item CO
    8697 @vindex CO
    8698 Program for checking out files from RCS; default @samp{co}.
    8699 @pindex cc
    8700 
    87018731@item CXX
    87028732@vindex CXX
    87038733Program for compiling C++ programs; default @samp{g++}.
    87048734@pindex g++
    8705 
    8706 @item CO
    8707 @vindex CO
    8708 Program for extracting a file from RCS; default @samp{co}.
    8709 @pindex co
    87108735
    87118736@item CPP
     
    87208745@pindex f77
    87218746
     8747@item M2C
     8748@vindex M2C
     8749Program to use to compile Modula-2 source code; default @samp{m2c}.
     8750@pindex m2c
     8751
     8752@item PC
     8753@vindex PC
     8754Program for compiling Pascal programs; default @samp{pc}.
     8755@pindex pc
     8756
     8757@item CO
     8758@vindex CO
     8759Program for extracting a file from RCS; default @samp{co}.
     8760@pindex co
     8761
    87228762@item GET
    87238763@vindex GET
     
    87398779Program to use to run lint on source code; default @samp{lint}.
    87408780@pindex lint
    8741 
    8742 @item M2C
    8743 @vindex M2C
    8744 Program to use to compile Modula-2 source code; default @samp{m2c}.
    8745 @pindex m2c
    8746 
    8747 @item PC
    8748 @vindex PC
    8749 Program for compiling Pascal programs; default @samp{pc}.
    8750 @pindex pc
    87518781
    87528782@item MAKEINFO
  • vendor/gnumake/current/expand.c

    r501 r900  
    5656
    5757char *
    58 variable_buffer_output (char *ptr, char *string, unsigned int length)
     58variable_buffer_output (char *ptr, const char *string, unsigned int length)
    5959{
    6060  register unsigned int newlen = length + (ptr - variable_buffer);
     
    6666                                ? newlen + 100
    6767                                : 2 * variable_buffer_length);
    68       variable_buffer = (char *) xrealloc (variable_buffer,
    69                                            variable_buffer_length);
     68      variable_buffer = xrealloc (variable_buffer, variable_buffer_length);
    7069      ptr = variable_buffer + offset;
    7170    }
    7271
    73   bcopy (string, ptr, length);
     72  memcpy (ptr, string, length);
    7473  return ptr + length;
    7574}
     
    8584    {
    8685      variable_buffer_length = 200;
    87       variable_buffer = (char *) xmalloc (variable_buffer_length);
     86      variable_buffer = xmalloc (variable_buffer_length);
    8887      variable_buffer[0] = '\0';
    8988    }
     
    9594/* Recursively expand V.  The returned string is malloc'd.  */
    9695
    97 static char *allocated_variable_append PARAMS ((const struct variable *v));
     96static char *allocated_variable_append (const struct variable *v);
    9897
    9998char *
     
    162161#endif
    163162static char *
    164 reference_variable (char *o, char *name, unsigned int length)
    165 {
    166   register struct variable *v;
     163reference_variable (char *o, const char *name, unsigned int length)
     164{
     165  struct variable *v;
    167166  char *value;
    168167
     
    194193   LINE is NULL, start at the beginning of the buffer.
    195194   Return a pointer to LINE, or to the beginning of the buffer if LINE is
    196    NULL.  */
    197 
     195   NULL.
     196 */
    198197char *
    199 variable_expand_string (char *line, char *string, long length)
    200 {
    201   register struct variable *v;
    202   register char *p, *o, *p1;
    203   char save_char = '\0';
     198variable_expand_string (char *line, const char *string, long length)
     199{
     200  struct variable *v;
     201  const char *p, *p1;
     202  char *abuf = NULL;
     203  char *o;
    204204  unsigned int line_offset;
    205205
    206206  if (!line)
    207207    line = initialize_variable_output();
    208 
    209   p = string;
    210208  o = line;
    211209  line_offset = line - variable_buffer;
    212210
    213   if (length >= 0)
    214     {
    215       save_char = string[length];
    216       string[length] = '\0';
    217     }
     211  if (length == 0)
     212    {
     213      variable_buffer_output (o, "", 1);
     214      return (variable_buffer);
     215    }
     216
     217  /* If we want a subset of the string, allocate a temporary buffer for it.
     218     Most of the functions we use here don't work with length limits.  */
     219  if (length > 0 && string[length] != '\0')
     220    {
     221      abuf = xmalloc(length+1);
     222      memcpy(abuf, string, length);
     223      abuf[length] = '\0';
     224      string = abuf;
     225    }
     226  p = string;
    218227
    219228  while (1)
     
    246255            char openparen = *p;
    247256            char closeparen = (openparen == '(') ? ')' : '}';
    248             register char *beg = p + 1;
    249             int free_beg = 0;
    250             char *op, *begp;
    251             char *end, *colon;
     257            const char *begp;
     258            const char *beg = p + 1;
     259            char *op;
     260            char *abeg = NULL;
     261            const char *end, *colon;
    252262
    253263            op = o;
     
    285295                if (count < 0)
    286296                  {
    287                     beg = expand_argument (beg, p); /* Expand the name.  */
    288                     free_beg = 1; /* Remember to free BEG when finished.  */
     297                    abeg = expand_argument (beg, p); /* Expand the name.  */
     298                    beg = abeg;
    289299                    end = strchr (beg, '\0');
    290300                  }
     
    304314              {
    305315                /* This looks like a substitution reference: $(FOO:A=B).  */
    306                 char *subst_beg, *subst_end, *replace_beg, *replace_end;
     316                const char *subst_beg, *subst_end, *replace_beg, *replace_end;
    307317
    308318                subst_beg = colon + 1;
     
    336346                           extra % at the beginning to use in case there
    337347                           isn't one in the pattern.  */
    338                         pattern = (char *) alloca (subst_end - subst_beg + 2);
     348                        pattern = alloca (subst_end - subst_beg + 2);
    339349                        *(pattern++) = '%';
    340                         bcopy (subst_beg, pattern, subst_end - subst_beg);
     350                        memcpy (pattern, subst_beg, subst_end - subst_beg);
    341351                        pattern[subst_end - subst_beg] = '\0';
    342352
    343                         replace = (char *) alloca (replace_end
    344                                                    - replace_beg + 2);
     353                        replace = alloca (replace_end - replace_beg + 2);
    345354                        *(replace++) = '%';
    346                         bcopy (replace_beg, replace,
     355                        memcpy (replace, replace_beg,
    347356                               replace_end - replace_beg);
    348357                        replace[replace_end - replace_beg] = '\0';
     
    354363                          {
    355364                            ++ppercent;
    356                             rpercent = 0;
     365                            rpercent = find_percent (replace);
     366                            if (rpercent)
     367                              ++rpercent;
    357368                          }
    358369                        else
     
    364375                          }
    365376
    366                         o = patsubst_expand (o, value, pattern, replace,
    367                                              ppercent, rpercent);
     377                        o = patsubst_expand_pat (o, value, pattern, replace,
     378                                                 ppercent, rpercent);
    368379
    369380                        if (v->recursive)
     
    378389                o = reference_variable (o, beg, end - beg);
    379390
    380           if (free_beg)
    381             free (beg);
     391          if (abeg)
     392            free (abeg);
    382393          }
    383394          break;
     
    403414    }
    404415
    405   if (save_char)
    406     string[length] = save_char;
    407 
    408   (void)variable_buffer_output (o, "", 1);
     416  if (abuf)
     417    free (abuf);
     418
     419  variable_buffer_output (o, "", 1);
    409420  return (variable_buffer + line_offset);
    410421}
     
    417428
    418429char *
    419 variable_expand (char *line)
     430variable_expand (const char *line)
    420431{
    421432  return variable_expand_string(NULL, line, (long)-1);
     
    438449
    439450  if (!end || *end == '\0')
    440     return allocated_variable_expand ((char *)str);
    441 
    442   tmp = (char *) alloca (end - str + 1);
    443   bcopy (str, tmp, end - str);
     451    return allocated_variable_expand (str);
     452
     453  tmp = alloca (end - str + 1);
     454  memcpy (tmp, str, end - str);
    444455  tmp[end - str] = '\0';
    445456
     
    452463
    453464char *
    454 variable_expand_for_file (char *line, struct file *file)
     465variable_expand_for_file (const char *line, struct file *file)
    455466{
    456467  char *result;
     
    543554
    544555char *
    545 allocated_variable_expand_for_file (char *line, struct file *file)
     556allocated_variable_expand_for_file (const char *line, struct file *file)
    546557{
    547558  char *value;
  • vendor/gnumake/current/file.c

    r501 r900  
    7070/* Access the hash table of all file records.
    7171   lookup_file  given a name, return the struct file * for that name,
    72            or nil if there is none.
    73    enter_file   similar, but create one if there is none.  */
     72                or nil if there is none.
     73*/
    7474
    7575struct file *
    76 lookup_file (char *name)
    77 {
    78   register struct file *f;
     76lookup_file (const char *name)
     77{
     78  struct file *f;
    7979  struct file file_key;
    8080#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
    81   register char *lname, *ln;
     81  char *lname;
    8282#endif
    8383
     
    9191  if (*name != '.')
    9292    {
    93       register char *n;
    94       lname = (char *) malloc (strlen (name) + 1);
     93      const char *n;
     94      char *ln;
     95      lname = xstrdup (name);
    9596      for (n = name, ln = lname; *n != '\0'; ++n, ++ln)
    9697        *ln = isupper ((unsigned char)*n) ? tolower ((unsigned char)*n) : *n;
     
    113114  if (*name == '\0')
    114115    /* It was all slashes after a dot.  */
    115 #ifdef VMS
     116#if defined(VMS)
    116117    name = "[]";
    117 #else
    118 #ifdef _AMIGA
     118#elif defined(_AMIGA)
    119119    name = "";
    120120#else
    121121    name = "./";
    122 #endif /* AMIGA */
    123 #endif /* VMS */
     122#endif
    124123
    125124  file_key.hname = name;
    126   f = (struct file *) hash_find_item (&files, &file_key);
     125  f = hash_find_item (&files, &file_key);
    127126#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
    128127  if (*name != '.')
    129128    free (lname);
    130129#endif
     130
    131131  return f;
    132132}
    133133
     134/* Look up a file record for file NAME and return it.
     135   Create a new record if one doesn't exist.  NAME will be stored in the
     136   new record so it should be constant or in the strcache etc.
     137 */
     138
    134139struct file *
    135 enter_file (char *name)
    136 {
    137   register struct file *f;
    138   register struct file *new;
    139   register struct file **file_slot;
     140enter_file (const char *name)
     141{
     142  struct file *f;
     143  struct file *new;
     144  struct file **file_slot;
    140145  struct file file_key;
    141 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
    142   char *lname, *ln;
    143 #endif
    144146
    145147  assert (*name != '\0');
     148  assert (strcache_iscached (name));
    146149
    147150#if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
    148151  if (*name != '.')
    149152    {
    150       register char *n;
    151       lname = (char *) malloc (strlen (name) + 1);
     153      const char *n;
     154      char *lname, *ln;
     155      lname = xstrdup (name);
    152156      for (n = name, ln = lname; *n != '\0'; ++n, ++ln)
    153         {
    154           if (isupper ((unsigned char)*n))
    155             *ln = tolower ((unsigned char)*n);
    156           else
    157             *ln = *n;
    158         }
    159 
    160       *ln = 0;
    161       /* Creates a possible leak, old value of name is unreachable, but I
    162          currently don't know how to fix it. */
    163       name = lname;
     157        if (isupper ((unsigned char)*n))
     158          *ln = tolower ((unsigned char)*n);
     159        else
     160          *ln = *n;
     161
     162      *ln = '\0';
     163      name = strcache_add (lname);
     164      free (lname);
    164165    }
    165166#endif
     
    169170  f = *file_slot;
    170171  if (! HASH_VACANT (f) && !f->double_colon)
    171     {
    172 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)
    173       if (*name != '.')
    174         free (lname);
    175 #endif
    176       return f;
    177     }
    178 
    179   new = (struct file *) xmalloc (sizeof (struct file));
    180   bzero ((char *) new, sizeof (struct file));
     172    return f;
     173
     174  new = xmalloc (sizeof (struct file));
     175  memset (new, '\0', sizeof (struct file));
    181176  new->name = new->hname = name;
    182177  new->update_status = -1;
     
    199194
    200195
    201 /* Rename FILE to NAME.  This is not as simple as resetting
    202    the `name' member, since it must be put in a new hash bucket,
    203    and possibly merged with an existing file called NAME.  */
    204 
    205 void
    206 rename_file (struct file *from_file, char *to_hname)
    207 {
    208   rehash_file (from_file, to_hname);
    209   while (from_file)
    210     {
    211       from_file->name = from_file->hname;
    212       from_file = from_file->prev;
    213     }
    214 }
    215 
    216196/* Rehash FILE to NAME.  This is not as simple as resetting
    217197   the `hname' member, since it must be put in a new hash bucket,
     
    219199
    220200void
    221 rehash_file (struct file *from_file, char *to_hname)
     201rehash_file (struct file *from_file, const char *to_hname)
    222202{
    223203  struct file file_key;
     
    227207  struct file *f;
    228208
     209  /* If it's already that name, we're done.  */
    229210  file_key.hname = to_hname;
    230   if (0 == file_hash_cmp (from_file, &file_key))
     211  if (! file_hash_cmp (from_file, &file_key))
    231212    return;
    232213
     214  /* Find the end of the renamed list for the "from" file.  */
    233215  file_key.hname = from_file->hname;
    234216  while (from_file->renamed != 0)
    235217    from_file = from_file->renamed;
    236218  if (file_hash_cmp (from_file, &file_key))
    237     /* hname changed unexpectedly */
     219    /* hname changed unexpectedly!! */
    238220    abort ();
    239221
     222  /* Remove the "from" file from the hash.  */
    240223  deleted_file = hash_delete (&files, from_file);
    241224  if (deleted_file != from_file)
     
    243226    abort ();
    244227
     228  /* Find where the newly renamed file will go in the hash.  */
    245229  file_key.hname = to_hname;
    246230  file_slot = (struct file **) hash_find_slot (&files, &file_key);
    247231  to_file = *file_slot;
    248232
     233  /* Change the hash name for this file.  */
    249234  from_file->hname = to_hname;
    250235  for (f = from_file->double_colon; f != 0; f = f->prev)
    251236    f->hname = to_hname;
    252237
     238  /* If the new name doesn't exist yet just set it to the renamed file.  */
    253239  if (HASH_VACANT (to_file))
    254     hash_insert_at (&files, from_file, file_slot);
     240    {
     241      hash_insert_at (&files, from_file, file_slot);
     242      return;
     243    }
     244
     245  /* TO_FILE already exists under TO_HNAME.
     246     We must retain TO_FILE and merge FROM_FILE into it.  */
     247
     248  if (from_file->cmds != 0)
     249    {
     250      if (to_file->cmds == 0)
     251        to_file->cmds = from_file->cmds;
     252      else if (from_file->cmds != to_file->cmds)
     253        {
     254          /* We have two sets of commands.  We will go with the
     255             one given in the rule explicitly mentioning this name,
     256             but give a message to let the user know what's going on.  */
     257          if (to_file->cmds->fileinfo.filenm != 0)
     258            error (&from_file->cmds->fileinfo,
     259                   _("Commands were specified for file `%s' at %s:%lu,"),
     260                   from_file->name, to_file->cmds->fileinfo.filenm,
     261                   to_file->cmds->fileinfo.lineno);
     262          else
     263            error (&from_file->cmds->fileinfo,
     264                   _("Commands for file `%s' were found by implicit rule search,"),
     265                   from_file->name);
     266          error (&from_file->cmds->fileinfo,
     267                 _("but `%s' is now considered the same file as `%s'."),
     268                 from_file->name, to_hname);
     269          error (&from_file->cmds->fileinfo,
     270                 _("Commands for `%s' will be ignored in favor of those for `%s'."),
     271                 to_hname, from_file->name);
     272        }
     273    }
     274
     275  /* Merge the dependencies of the two files.  */
     276
     277  if (to_file->deps == 0)
     278    to_file->deps = from_file->deps;
    255279  else
    256280    {
    257       /* TO_FILE already exists under TO_HNAME.
    258          We must retain TO_FILE and merge FROM_FILE into it.  */
    259 
    260       if (from_file->cmds != 0)
    261         {
    262           if (to_file->cmds == 0)
    263             to_file->cmds = from_file->cmds;
    264           else if (from_file->cmds != to_file->cmds)
    265             {
    266               /* We have two sets of commands.  We will go with the
    267                  one given in the rule explicitly mentioning this name,
    268                  but give a message to let the user know what's going on.  */
    269               if (to_file->cmds->fileinfo.filenm != 0)
    270                 error (&from_file->cmds->fileinfo,
    271                        _("Commands were specified for file `%s' at %s:%lu,"),
    272                        from_file->name, to_file->cmds->fileinfo.filenm,
    273                        to_file->cmds->fileinfo.lineno);
    274               else
    275                 error (&from_file->cmds->fileinfo,
    276                        _("Commands for file `%s' were found by implicit rule search,"),
    277                        from_file->name);
    278               error (&from_file->cmds->fileinfo,
    279                      _("but `%s' is now considered the same file as `%s'."),
    280                      from_file->name, to_hname);
    281               error (&from_file->cmds->fileinfo,
    282                      _("Commands for `%s' will be ignored in favor of those for `%s'."),
    283                      to_hname, from_file->name);
    284             }
    285         }
    286 
    287       /* Merge the dependencies of the two files.  */
    288 
    289       if (to_file->deps == 0)
    290         to_file->deps = from_file->deps;
     281      struct dep *deps = to_file->deps;
     282      while (deps->next != 0)
     283        deps = deps->next;
     284      deps->next = from_file->deps;
     285    }
     286
     287  merge_variable_set_lists (&to_file->variables, from_file->variables);
     288
     289  if (to_file->double_colon && from_file->is_target && !from_file->double_colon)
     290    fatal (NILF, _("can't rename single-colon `%s' to double-colon `%s'"),
     291           from_file->name, to_hname);
     292  if (!to_file->double_colon  && from_file->double_colon)
     293    {
     294      if (to_file->is_target)
     295        fatal (NILF, _("can't rename double-colon `%s' to single-colon `%s'"),
     296               from_file->name, to_hname);
    291297      else
    292         {
    293           register struct dep *deps = to_file->deps;
    294           while (deps->next != 0)
    295             deps = deps->next;
    296           deps->next = from_file->deps;
    297         }
    298 
    299       merge_variable_set_lists (&to_file->variables, from_file->variables);
    300 
    301       if (to_file->double_colon && from_file->is_target && !from_file->double_colon)
    302         fatal (NILF, _("can't rename single-colon `%s' to double-colon `%s'"),
    303                from_file->name, to_hname);
    304       if (!to_file->double_colon  && from_file->double_colon)
    305         {
    306           if (to_file->is_target)
    307             fatal (NILF, _("can't rename double-colon `%s' to single-colon `%s'"),
    308                    from_file->name, to_hname);
    309           else
    310             to_file->double_colon = from_file->double_colon;
    311         }
    312 
    313       if (from_file->last_mtime > to_file->last_mtime)
    314         /* %%% Kludge so -W wins on a file that gets vpathized.  */
    315         to_file->last_mtime = from_file->last_mtime;
    316 
    317       to_file->mtime_before_update = from_file->mtime_before_update;
     298        to_file->double_colon = from_file->double_colon;
     299    }
     300
     301  if (from_file->last_mtime > to_file->last_mtime)
     302    /* %%% Kludge so -W wins on a file that gets vpathized.  */
     303    to_file->last_mtime = from_file->last_mtime;
     304
     305  to_file->mtime_before_update = from_file->mtime_before_update;
    318306
    319307#define MERGE(field) to_file->field |= from_file->field
    320       MERGE (precious);
    321       MERGE (tried_implicit);
    322       MERGE (updating);
    323       MERGE (updated);
    324       MERGE (is_target);
    325       MERGE (cmd_target);
    326       MERGE (phony);
    327       MERGE (ignore_vpath);
     308  MERGE (precious);
     309  MERGE (tried_implicit);
     310  MERGE (updating);
     311  MERGE (updated);
     312  MERGE (is_target);
     313  MERGE (cmd_target);
     314  MERGE (phony);
     315  MERGE (ignore_vpath);
    328316#undef MERGE
    329317
    330       from_file->renamed = to_file;
     318  from_file->renamed = to_file;
     319}
     320
     321/* Rename FILE to NAME.  This is not as simple as resetting
     322   the `name' member, since it must be put in a new hash bucket,
     323   and possibly merged with an existing file called NAME.  */
     324
     325void
     326rename_file (struct file *from_file, const char *to_hname)
     327{
     328  rehash_file (from_file, to_hname);
     329  while (from_file)
     330    {
     331      from_file->name = from_file->hname;
     332      from_file = from_file->prev;
    331333    }
    332334}
     
    341343remove_intermediates (int sig)
    342344{
    343   register struct file **file_slot;
    344   register struct file **file_end;
     345  struct file **file_slot;
     346  struct file **file_end;
    345347  int doneany = 0;
    346348
     
    357359    if (! HASH_VACANT (*file_slot))
    358360      {
    359         register struct file *f = *file_slot;
     361        struct file *f = *file_slot;
    360362        /* Is this file eligible for automatic deletion?
    361363           Yes, IFF: it's marked intermediate, it's not secondary, it wasn't
     
    448450}
    449451
    450 
    451452/* Set the intermediate flag.  */
    452453
     
    464465  struct dep *d;
    465466  struct dep *old = f->deps;
    466   char *file_stem = f->stem;
     467  const char *file_stem = f->stem;
    467468  unsigned int last_dep_has_cmds = f->updating;
    468469  int initialized = 0;
     
    480481
    481482      /* Create the dependency list.
    482          If we're not doing 2nd expansion, then it's just the name.  */
     483         If we're not doing 2nd expansion, then it's just the name.  We will
     484         still need to massage it though.  */
    483485      if (! d->need_2nd_expansion)
    484         p = d->name;
     486        {
     487          p = variable_expand ("");
     488          variable_buffer_output (p, d->name, strlen (d->name) + 1);
     489        }
    485490      else
    486491        {
     
    494499              o = subst_expand (buffer, d->name, "%", "$*", 1, 2, 0);
    495500
    496               free (d->name);
    497               d->name = savestring (buffer, o - buffer);
     501              d->name = strcache_add_len (buffer, o - buffer);
    498502              d->staticpattern = 0; /* Clear staticpattern so that we don't
    499503                                       re-expand %s below. */
     
    529533      if (new && d->staticpattern)
    530534        {
    531           char *pattern = "%";
     535          const char *pattern = "%";
    532536          char *buffer = variable_expand ("");
    533537          struct dep *dp = new, *dl = 0;
     
    535539          while (dp != 0)
    536540            {
    537               char *percent = find_percent (dp->name);
     541              char *percent;
     542              int nl = strlen (dp->name) + 1;
     543              char *nm = alloca (nl);
     544              memcpy (nm, dp->name, nl);
     545              percent = find_percent (nm);
    538546              if (percent)
    539547                {
     548                  char *o;
     549
    540550                  /* We have to handle empty stems specially, because that
    541551                     would be equivalent to $(patsubst %,dp->name,) which
    542552                     will always be empty.  */
    543553                  if (d->stem[0] == '\0')
    544                     /* This needs memmove() in ISO C.  */
    545                     bcopy (percent+1, percent, strlen (percent));
     554                    {
     555                      memmove (percent, percent+1, strlen (percent));
     556                      o = variable_buffer_output (buffer, nm, strlen (nm) + 1);
     557                    }
    546558                  else
    547                     {
    548                       char *o = patsubst_expand (buffer, d->stem, pattern,
    549                                                  dp->name, pattern+1,
    550                                                  percent+1);
    551                       if (o == buffer)
    552                         dp->name[0] = '\0';
    553                       else
    554                         {
    555                           free (dp->name);
    556                           dp->name = savestring (buffer, o - buffer);
    557                         }
    558                     }
     559                    o = patsubst_expand_pat (buffer, d->stem, pattern, nm,
     560                                             pattern+1, percent+1);
    559561
    560562                  /* If the name expanded to the empty string, ignore it.  */
    561                   if (dp->name[0] == '\0')
     563                  if (buffer[0] == '\0')
    562564                    {
    563565                      struct dep *df = dp;
     
    566568                      else
    567569                        dp = dl->next = dp->next;
    568                       /* @@ Are we leaking df->name here?  */
    569                       df->name = 0;
    570570                      free_dep (df);
    571571                      continue;
    572572                    }
     573
     574                  /* Save the name.  */
     575                  dp->name = strcache_add_len (buffer, o - buffer);
    573576                }
    574577              dl = dp;
     
    583586          if (d1->file == 0)
    584587            d1->file = enter_file (d1->name);
    585           else
    586             free (d1->name);
    587588          d1->name = 0;
    588589          d1->staticpattern = 0;
     
    639640  struct file **file_end;
    640641
    641   /* Perform second expansion and enter each dependency
    642      name as a file. */
    643 
    644   /* Expand .SUFFIXES first; it's dependencies are used for
    645      $$* calculation. */
     642  /* Perform second expansion and enter each dependency name as a file. */
     643
     644  /* Expand .SUFFIXES first; it's dependencies are used for $$* calculation. */
    646645  for (f = lookup_file (".SUFFIXES"); f != 0; f = f->prev)
    647646    expand_deps (f);
    648647
    649   /* We must use hash_dump (), because within this loop
    650      we might add new files to the table, possibly causing
    651      an in-situ table expansion.  */
     648  /* For every target that's not .SUFFIXES, expand its dependencies.
     649     We must use hash_dump (), because within this loop we might add new files
     650     to the table, possibly causing an in-situ table expansion.  */
    652651  file_slot_0 = (struct file **) hash_dump (&files, 0, 0);
    653652  file_end = file_slot_0 + files.ht_fill;
    654653  for (file_slot = file_slot_0; file_slot < file_end; file_slot++)
    655654    for (f = *file_slot; f != 0; f = f->prev)
    656       {
    657         if (strcmp (f->name, ".SUFFIXES") != 0)
    658           expand_deps (f);
    659       }
     655      if (strcmp (f->name, ".SUFFIXES") != 0)
     656        expand_deps (f);
    660657  free (file_slot_0);
     658
     659  /* Now manage all the special targets.  */
    661660
    662661  for (f = lookup_file (".PRECIOUS"); f != 0; f = f->prev)
     
    682681
    683682  for (f = lookup_file (".INTERMEDIATE"); f != 0; f = f->prev)
    684     {
    685       /* .INTERMEDIATE with deps listed
    686          marks those deps as intermediate files.  */
     683    /* Mark .INTERMEDIATE deps as intermediate files.  */
     684    for (d = f->deps; d != 0; d = d->next)
     685      for (f2 = d->file; f2 != 0; f2 = f2->prev)
     686        f2->intermediate = 1;
     687    /* .INTERMEDIATE with no deps does nothing.
     688       Marking all files as intermediates is useless since the goal targets
     689       would be deleted after they are built.  */
     690
     691  for (f = lookup_file (".SECONDARY"); f != 0; f = f->prev)
     692    /* Mark .SECONDARY deps as both intermediate and secondary.  */
     693    if (f->deps)
    687694      for (d = f->deps; d != 0; d = d->next)
    688         for (f2 = d->file; f2 != 0; f2 = f2->prev)
    689           f2->intermediate = 1;
    690       /* .INTERMEDIATE with no deps does nothing.
    691          Marking all files as intermediates is useless
    692          since the goal targets would be deleted after they are built.  */
    693     }
    694 
    695   for (f = lookup_file (".SECONDARY"); f != 0; f = f->prev)
    696     {
    697       /* .SECONDARY with deps listed
    698          marks those deps as intermediate files
    699          in that they don't get rebuilt if not actually needed;
    700          but unlike real intermediate files,
    701          these are not deleted after make finishes.  */
    702       if (f->deps)
    703         for (d = f->deps; d != 0; d = d->next)
    704           for (f2 = d->file; f2 != 0; f2 = f2->prev)
    705             f2->intermediate = f2->secondary = 1;
    706       /* .SECONDARY with no deps listed marks *all* files that way.  */
    707       else
    708         {
    709           all_secondary = 1;
    710           hash_map (&files, set_intermediate);
    711         }
    712     }
     695        for (f2 = d->file; f2 != 0; f2 = f2->prev)
     696          f2->intermediate = f2->secondary = 1;
     697    /* .SECONDARY with no deps listed marks *all* files that way.  */
     698    else
     699      {
     700        all_secondary = 1;
     701        hash_map (&files, set_intermediate);
     702      }
    713703
    714704  f = lookup_file (".EXPORT_ALL_VARIABLES");
     
    860850  p += strlen (p);
    861851
    862   /* Append nanoseconds as a fraction, but remove trailing zeros.
    863      We don't know the actual timestamp resolution, since clock_getres
    864      applies only to local times, whereas this timestamp might come
    865      from a remote filesystem.  So removing trailing zeros is the
    866      best guess that we can do.  */
     852  /* Append nanoseconds as a fraction, but remove trailing zeros.  We don't
     853     know the actual timestamp resolution, since clock_getres applies only to
     854     local times, whereas this timestamp might come from a remote filesystem.
     855     So removing trailing zeros is the best guess that we can do.  */
    867856  sprintf (p, ".%09d", FILE_TIMESTAMP_NS (ts));
    868857  p += strlen (p) - 1;
     
    880869print_file (const void *item)
    881870{
    882   struct file *f = (struct file *) item;
     871  const struct file *f = item;
    883872  struct dep *d;
    884873  struct dep *ood = 0;
     
    1002991}
    1003992
     993
     994/* Verify the integrity of the data base of files.  */
     995
     996#define VERIFY_CACHED(_p,_n) \
     997    do{\
     998        if (_p->_n && _p->_n[0] && !strcache_iscached (_p->_n)) \
     999          printf ("%s: Field %s not cached: %s\n", _p->name, # _n, _p->_n); \
     1000    }while(0)
     1001
     1002static void
     1003verify_file (const void *item)
     1004{
     1005  const struct file *f = item;
     1006  const struct dep *d;
     1007
     1008  VERIFY_CACHED (f, name);
     1009  VERIFY_CACHED (f, hname);
     1010  VERIFY_CACHED (f, vpath);
     1011  VERIFY_CACHED (f, stem);
     1012
     1013  /* Check the deps.  */
     1014  for (d = f->deps; d != 0; d = d->next)
     1015    {
     1016      VERIFY_CACHED (d, name);
     1017      VERIFY_CACHED (d, stem);
     1018    }
     1019}
     1020
     1021void
     1022verify_file_data_base (void)
     1023{
     1024  hash_map (&files, verify_file);
     1025}
     1026
    10041027#define EXPANSION_INCREMENT(_l)  ((((_l) / 500) + 1) * 500)
    10051028
     
    10381061              }
    10391062
    1040             bcopy (f->name, p, l);
     1063            memcpy (p, f->name, l);
    10411064            p += l;
    10421065            *(p++) = ' ';
  • vendor/gnumake/current/filedef.h

    r501 r900  
    2626struct file
    2727  {
    28     char *name;
    29     char *hname;                /* Hashed filename */
    30     char *vpath;                /* VPATH/vpath pathname */
     28    const char *name;
     29    const char *hname;          /* Hashed filename */
     30    const char *vpath;          /* VPATH/vpath pathname */
    3131    struct dep *deps;           /* all dependencies, including duplicates */
    3232    struct commands *cmds;      /* Commands to execute for this target.  */
    3333    int command_flags;          /* Flags OR'd in for cmds; see commands.h.  */
    34     char *stem;                 /* Implicit stem, if an implicit
    35                                    rule has been used */
     34    const char *stem;           /* Implicit stem, if an implicit
     35                                   rule has been used */
    3636    struct dep *also_make;      /* Targets that are made by making this.  */
    3737    FILE_TIMESTAMP last_mtime;  /* File's modtime, if already known.  */
     
    102102
    103103
    104 extern struct file *lookup_file PARAMS ((char *name));
    105 extern struct file *enter_file PARAMS ((char *name));
    106 extern struct dep *parse_prereqs PARAMS ((char *prereqs));
    107 extern void remove_intermediates PARAMS ((int sig));
    108 extern void snap_deps PARAMS ((void));
    109 extern void rename_file PARAMS ((struct file *file, char *name));
    110 extern void rehash_file PARAMS ((struct file *file, char *name));
    111 extern void set_command_state PARAMS ((struct file *file, enum cmd_state state));
    112 extern void notice_finished_file PARAMS ((struct file *file));
    113 extern void init_hash_files PARAMS ((void));
    114 extern char *build_target_list PARAMS ((char *old_list));
     104struct file *lookup_file (const char *name);
     105struct file *enter_file (const char *name);
     106struct dep *parse_prereqs (char *prereqs);
     107void remove_intermediates (int sig);
     108void snap_deps (void);
     109void rename_file (struct file *file, const char *name);
     110void rehash_file (struct file *file, const char *name);
     111void set_command_state (struct file *file, enum cmd_state state);
     112void notice_finished_file (struct file *file);
     113void init_hash_files (void);
     114char *build_target_list (char *old_list);
    115115
    116116#if FILE_TIMESTAMP_HI_RES
     
    153153   + 1 + 1 + 4 + 25)
    154154
    155 extern FILE_TIMESTAMP file_timestamp_cons PARAMS ((char const *,
    156                                                    time_t, int));
    157 extern FILE_TIMESTAMP file_timestamp_now PARAMS ((int *));
    158 extern void file_timestamp_sprintf PARAMS ((char *p, FILE_TIMESTAMP ts));
     155FILE_TIMESTAMP file_timestamp_cons (char const *, time_t, int);
     156FILE_TIMESTAMP file_timestamp_now (int *);
     157void file_timestamp_sprintf (char *p, FILE_TIMESTAMP ts);
    159158
    160159/* Return the mtime of file F (a struct file *), caching it.
     
    166165   The value is NONEXISTENT_MTIME if the file does not exist.  */
    167166#define file_mtime_no_search(f) file_mtime_1 ((f), 0)
    168 extern FILE_TIMESTAMP f_mtime PARAMS ((struct file *file, int search));
     167FILE_TIMESTAMP f_mtime (struct file *file, int search);
    169168#define file_mtime_1(f, v) \
    170169  ((f)->last_mtime == UNKNOWN_MTIME ? f_mtime ((f), v) : (f)->last_mtime)
  • vendor/gnumake/current/function.c

    r501 r900  
    3737    unsigned char maximum_args;
    3838    char expand_args;
    39     char *(*func_ptr) PARAMS ((char *output, char **argv, const char *fname));
     39    char *(*func_ptr) (char *output, char **argv, const char *fname);
    4040  };
    4141
     
    4343function_table_entry_hash_1 (const void *keyv)
    4444{
    45   struct function_table_entry const *key = (struct function_table_entry const *) keyv;
     45  const struct function_table_entry *key = keyv;
    4646  return_STRING_N_HASH_1 (key->name, key->len);
    4747}
     
    5050function_table_entry_hash_2 (const void *keyv)
    5151{
    52   struct function_table_entry const *key = (struct function_table_entry const *) keyv;
     52  const struct function_table_entry *key = keyv;
    5353  return_STRING_N_HASH_2 (key->name, key->len);
    5454}
     
    5757function_table_entry_hash_cmp (const void *xv, const void *yv)
    5858{
    59   struct function_table_entry const *x = (struct function_table_entry const *) xv;
    60   struct function_table_entry const *y = (struct function_table_entry const *) yv;
     59  const struct function_table_entry *x = xv;
     60  const struct function_table_entry *y = yv;
    6161  int result = x->len - y->len;
    6262  if (result)
     
    7676
    7777char *
    78 subst_expand (char *o, char *text, char *subst, char *replace,
     78subst_expand (char *o, const char *text, const char *subst, const char *replace,
    7979              unsigned int slen, unsigned int rlen, int by_word)
    8080{
    81   char *t = text;
    82   char *p;
     81  const char *t = text;
     82  const char *p;
    8383
    8484  if (slen == 0 && !by_word)
     
    125125
    126126      /* Advance T past the string to be replaced.  */
    127       {
    128         char *nt = p + slen;
    129         t = nt;
    130       }
     127      t = p + slen;
    131128    } while (*t != '\0');
    132129
     
    147144
    148145char *
    149 patsubst_expand (char *o, char *text, char *pattern, char *replace,
    150                  char *pattern_percent, char *replace_percent)
     146patsubst_expand_pat (char *o, const char *text,
     147                     const char *pattern, const char *replace,
     148                     const char *pattern_percent, const char *replace_percent)
    151149{
    152150  unsigned int pattern_prepercent_len, pattern_postpercent_len;
    153151  unsigned int replace_prepercent_len, replace_postpercent_len;
    154   char *t;
     152  const char *t;
    155153  unsigned int len;
    156154  int doneany = 0;
    157 
    158   /* We call find_percent on REPLACE before checking PATTERN so that REPLACE
    159      will be collapsed before we call subst_expand if PATTERN has no %.  */
    160   if (!replace_percent)
    161     {
    162       replace_percent = find_percent (replace);
    163       if (replace_percent)
    164         ++replace_percent;
    165     }
    166155
    167156  /* Record the length of REPLACE before and after the % so we don't have to
     
    178167    }
    179168
    180   if (!pattern_percent)
    181     {
    182       pattern_percent = find_percent (pattern);
    183       if (pattern_percent)
    184         ++pattern_percent;
    185     }
    186169  if (!pattern_percent)
    187170    /* With no % in the pattern, this is just a simple substitution.  */
     
    255238}
    256239
     240/* Store into VARIABLE_BUFFER at O the result of scanning TEXT
     241   and replacing strings matching PATTERN with REPLACE.
     242   If PATTERN_PERCENT is not nil, PATTERN has already been
     243   run through find_percent, and PATTERN_PERCENT is the result.
     244   If REPLACE_PERCENT is not nil, REPLACE has already been
     245   run through find_percent, and REPLACE_PERCENT is the result.
     246   Note that we expect PATTERN_PERCENT and REPLACE_PERCENT to point to the
     247   character _AFTER_ the %, not to the % itself.
     248*/
     249
     250char *
     251patsubst_expand (char *o, const char *text, char *pattern, char *replace)
     252{
     253  const char *pattern_percent = find_percent (pattern);
     254  const char *replace_percent = find_percent (replace);
     255
     256  /* If there's a percent in the pattern or replacement skip it.  */
     257  if (replace_percent)
     258    ++replace_percent;
     259  if (pattern_percent)
     260    ++pattern_percent;
     261
     262  return patsubst_expand_pat (o, text, pattern, replace,
     263                              pattern_percent, replace_percent);
     264}
     265
    257266
    258267
     
    282291
    283292int
    284 pattern_matches (char *pattern, char *percent, char *str)
     293pattern_matches (const char *pattern, const char *percent, const char *str)
    285294{
    286295  unsigned int sfxlen, strlength;
     
    289298    {
    290299      unsigned int len = strlen (pattern) + 1;
    291       char *new_chars = (char *) alloca (len);
    292       bcopy (pattern, new_chars, len);
     300      char *new_chars = alloca (len);
     301      memcpy (new_chars, pattern, len);
     302      percent = find_percent (new_chars);
     303      if (percent == 0)
     304        return streq (new_chars, str);
    293305      pattern = new_chars;
    294       percent = find_percent (pattern);
    295       if (percent == 0)
    296         return streq (pattern, str);
    297306    }
    298307
     
    350359  static char *result = 0;
    351360  static unsigned int length;
    352   register struct nameseq *chain;
    353   register unsigned int idx;
     361  struct nameseq *chain;
     362  unsigned int idx;
    354363
    355364  chain = multi_glob (parse_file_seq
     
    364373    {
    365374      length = 100;
    366       result = (char *) xmalloc (100);
     375      result = xmalloc (100);
    367376    }
    368377
     
    370379  while (chain != 0)
    371380    {
    372       register char *name = chain->name;
     381      const char *name = chain->name;
    373382      unsigned int len = strlen (name);
    374383
    375384      struct nameseq *next = chain->next;
    376       free ((char *) chain);
     385      free (chain);
    377386      chain = next;
    378387
     
    384393            {
    385394              length += (len + 1) * 2;
    386               result = (char *) xrealloc (result, length);
     395              result = xrealloc (result, length);
    387396            }
    388           bcopy (name, &result[idx], len);
     397          memcpy (&result[idx], name, len);
    389398          idx += len;
    390399          result[idx++] = ' ';
    391400        }
    392 
    393       free (name);
    394401    }
    395402
     
    411418func_patsubst (char *o, char **argv, const char *funcname UNUSED)
    412419{
    413   o = patsubst_expand (o, argv[2], argv[0], argv[1], (char *) 0, (char *) 0);
     420  o = patsubst_expand (o, argv[2], argv[0], argv[1]);
    414421  return o;
    415422}
     
    425432     If the two arguments have a different number of words,
    426433     the excess words are just output separated by blanks.  */
    427   register char *tp;
    428   register char *pp;
    429   char *list1_iterator = argv[0];
    430   char *list2_iterator = argv[1];
     434  const char *tp;
     435  const char *pp;
     436  const char *list1_iterator = argv[0];
     437  const char *list2_iterator = argv[1];
    431438  do
    432439    {
     
    460467{
    461468  /* Expand the argument.  */
    462   register struct variable *v = lookup_variable (argv[0], strlen (argv[0]));
     469  struct variable *v = lookup_variable (argv[0], strlen (argv[0]));
    463470  if (v == 0)
    464471    o = variable_buffer_output (o, "undefined", 9);
     
    499506func_flavor (char *o, char **argv, const char *funcname UNUSED)
    500507{
    501   register struct variable *v = lookup_variable (argv[0], strlen (argv[0]));
     508  struct variable *v = lookup_variable (argv[0], strlen (argv[0]));
    502509
    503510  if (v == 0)
     
    527534{
    528535  /* Expand the argument.  */
    529   char *list_iterator = argv[0];
    530   char *p2 =0;
     536  const char *list_iterator = argv[0];
     537  const char *p2;
    531538  int doneany =0;
    532539  unsigned int len=0;
     
    536543  while ((p2 = find_next_token (&list_iterator, &len)) != 0)
    537544    {
    538       char *p = p2 + len;
     545      const char *p = p2 + len;
    539546
    540547
     
    571578        }
    572579    }
     580
    573581  if (doneany)
    574582    /* Kill last space.  */
    575583    --o;
    576584
    577 
    578   return o;
    579 
     585  return o;
    580586}
    581587
     
    585591{
    586592  /* Expand the argument.  */
    587   char *p3 = argv[0];
    588   char *p2=0;
     593  const char *p3 = argv[0];
     594  const char *p2;
    589595  int doneany=0;
    590596  unsigned int len=0;
    591   char *p=0;
     597
    592598  int is_basename= streq (funcname, "basename");
    593599  int is_dir= !is_basename;
    594600
    595601  while ((p2 = find_next_token (&p3, &len)) != 0)
    596         {
    597           p = p2 + len;
    598           while (p >= p2 && (!is_basename  || *p != '.'))
    599             {
    600               if (IS_PATHSEP (*p))
    601                 break;
    602                     --p;
    603             }
    604 
    605           if (p >= p2 && (is_dir))
    606             o = variable_buffer_output (o, p2, ++p - p2);
    607           else if (p >= p2 && (*p == '.'))
    608             o = variable_buffer_output (o, p2, p - p2);
     602    {
     603      const char *p = p2 + len;
     604      while (p >= p2 && (!is_basename  || *p != '.'))
     605        {
     606          if (IS_PATHSEP (*p))
     607            break;
     608          --p;
     609        }
     610
     611      if (p >= p2 && (is_dir))
     612        o = variable_buffer_output (o, p2, ++p - p2);
     613      else if (p >= p2 && (*p == '.'))
     614        o = variable_buffer_output (o, p2, p - p2);
    609615#ifdef HAVE_DOS_PATHS
    610         /* Handle the "d:foobar" case */
    611           else if (p2[0] && p2[1] == ':' && is_dir)
    612             o = variable_buffer_output (o, p2, 2);
     616      /* Handle the "d:foobar" case */
     617      else if (p2[0] && p2[1] == ':' && is_dir)
     618        o = variable_buffer_output (o, p2, 2);
    613619#endif
    614           else if (is_dir)
     620      else if (is_dir)
    615621#ifdef VMS
    616             o = variable_buffer_output (o, "[]", 2);
     622        o = variable_buffer_output (o, "[]", 2);
    617623#else
    618624#ifndef _AMIGA
    619             o = variable_buffer_output (o, "./", 2);
     625      o = variable_buffer_output (o, "./", 2);
    620626#else
    621             ; /* Just a nop...  */
     627      ; /* Just a nop...  */
    622628#endif /* AMIGA */
    623629#endif /* !VMS */
    624           else
    625             /* The entire name is the basename.  */
    626             o = variable_buffer_output (o, p2, len);
    627 
    628           o = variable_buffer_output (o, " ", 1);
    629           doneany = 1;
    630         }
    631       if (doneany)
    632         /* Kill last space.  */
    633         --o;
    634 
    635 
    636  return o;
     630      else
     631        /* The entire name is the basename.  */
     632        o = variable_buffer_output (o, p2, len);
     633
     634      o = variable_buffer_output (o, " ", 1);
     635      doneany = 1;
     636    }
     637
     638  if (doneany)
     639    /* Kill last space.  */
     640    --o;
     641
     642  return o;
    637643}
    638644
     
    641647{
    642648  int fixlen = strlen (argv[0]);
    643   char *list_iterator = argv[1];
     649  const char *list_iterator = argv[1];
    644650  int is_addprefix = streq (funcname, "addprefix");
    645651  int is_addsuffix = !is_addprefix;
    646652
    647653  int doneany = 0;
    648   char *p;
     654  const char *p;
    649655  unsigned int len;
    650656
     
    681687{
    682688  unsigned int i;
    683   char *words = argv[0];    /* Use a temp variable for find_next_token */
    684   char *p = find_next_token (&words, &i);
     689  const char *words = argv[0];    /* Use a temp variable for find_next_token */
     690  const char *p = find_next_token (&words, &i);
    685691
    686692  if (p != 0)
     
    694700{
    695701  unsigned int i;
    696   char *words = argv[0];    /* Use a temp variable for find_next_token */
    697   char *p = 0;
    698   char *t;
     702  const char *words = argv[0];    /* Use a temp variable for find_next_token */
     703  const char *p = NULL;
     704  const char *t;
    699705
    700706  while ((t = find_next_token (&words, &i)))
     
    711717{
    712718  int i = 0;
    713   char *word_iterator = argv[0];
     719  const char *word_iterator = argv[0];
    714720  char buf[20];
    715721
     
    719725  sprintf (buf, "%d", i);
    720726  o = variable_buffer_output (o, buf, strlen (buf));
    721 
    722727
    723728  return o;
     
    740745
    741746static void
    742 check_numeric (const char *s, const char *message)
     747check_numeric (const char *s, const char *msg)
    743748{
    744749  const char *end = s + strlen (s) - 1;
     
    751756
    752757  if (s <= end || end - beg < 0)
    753     fatal (*expanding_var, "%s: '%s'", message, beg);
     758    fatal (*expanding_var, "%s: '%s'", msg, beg);
    754759}
    755760
     
    759764func_word (char *o, char **argv, const char *funcname UNUSED)
    760765{
    761   char *end_p=0;
    762   int i=0;
    763   char *p=0;
     766  const char *end_p;
     767  const char *p;
     768  int i;
    764769
    765770  /* Check the first argument.  */
    766771  check_numeric (argv[0], _("non-numeric first argument to `word' function"));
    767   i =  atoi (argv[0]);
     772  i = atoi (argv[0]);
    768773
    769774  if (i == 0)
    770775    fatal (*expanding_var,
    771776           _("first argument to `word' function must be greater than 0"));
    772 
    773777
    774778  end_p = argv[1];
     
    803807  if (count > 0)
    804808    {
    805       char *p;
    806       char *end_p = argv[2];
     809      const char *p;
     810      const char *end_p = argv[2];
    807811
    808812      /* Find the beginning of the "start"th word.  */
     
    824828}
    825829
    826 static char*
     830static char *
    827831func_findstring (char *o, char **argv, const char *funcname UNUSED)
    828832{
     
    840844  char *varname = expand_argument (argv[0], NULL);
    841845  char *list = expand_argument (argv[1], NULL);
    842   char *body = argv[2];
     846  const char *body = argv[2];
    843847
    844848  int doneany = 0;
    845   char *list_iterator = list;
    846   char *p;
     849  const char *list_iterator = list;
     850  const char *p;
    847851  unsigned int len;
    848   register struct variable *var;
     852  struct variable *var;
    849853
    850854  push_new_variable_scope ();
     
    856860      char *result = 0;
    857861
    858       {
    859         char save = p[len];
    860 
    861         p[len] = '\0';
    862         free (var->value);
    863         var->value = (char *) xstrdup ((char*) p);
    864         p[len] = save;
    865       }
     862      free (var->value);
     863      var->value = savestring (p, len);
    866864
    867865      result = allocated_variable_expand (body);
     
    936934  struct hash_table a_word_table;
    937935  int is_filter = streq (funcname, "filter");
    938   char *pat_iterator = argv[0];
    939   char *word_iterator = argv[1];
     936  const char *pat_iterator = argv[0];
     937  const char *word_iterator = argv[1];
    940938  int literals = 0;
    941939  int words = 0;
     
    949947  while ((p = find_next_token (&pat_iterator, &len)) != 0)
    950948    {
    951       struct a_pattern *pat = (struct a_pattern *) alloca (sizeof (struct a_pattern));
     949      struct a_pattern *pat = alloca (sizeof (struct a_pattern));
    952950
    953951      *pattail = pat;
     
    972970  while ((p = find_next_token (&word_iterator, &len)) != 0)
    973971    {
    974       struct a_word *word = (struct a_word *) alloca (sizeof (struct a_word));
     972      struct a_word *word = alloca (sizeof (struct a_word));
    975973
    976974      *wordtail = word;
     
    993991  if (hashing)
    994992    {
    995       hash_init (&a_word_table, words, a_word_hash_1, a_word_hash_2, a_word_hash_cmp);
     993      hash_init (&a_word_table, words, a_word_hash_1, a_word_hash_2,
     994                 a_word_hash_cmp);
    996995      for (wp = wordhead; wp != 0; wp = wp->next)
    997996        {
     
    10171016              a_word_key.str = pp->str;
    10181017              a_word_key.length = pp->length;
    1019               wp = (struct a_word *) hash_find_item (&a_word_table, &a_word_key);
     1018              wp = hash_find_item (&a_word_table, &a_word_key);
    10201019              while (wp)
    10211020                {
     
    10571056func_strip (char *o, char **argv, const char *funcname UNUSED)
    10581057{
    1059   char *p = argv[0];
    1060   int doneany =0;
     1058  const char *p = argv[0];
     1059  int doneany = 0;
    10611060
    10621061  while (*p != '\0')
    10631062    {
    10641063      int i=0;
    1065       char *word_start=0;
     1064      const char *word_start;
    10661065
    10671066      while (isspace ((unsigned char)*p))
     
    10801079    /* Kill the last space.  */
    10811080    --o;
     1081
    10821082  return o;
    10831083}
     
    10991099    len += strlen (*argvp) + 2;
    11001100
    1101   p = msg = (char *) alloca (len + 1);
     1101  p = msg = alloca (len + 1);
    11021102
    11031103  for (argvp=argv; argvp[1] != 0; ++argvp)
     
    11381138func_sort (char *o, char **argv, const char *funcname UNUSED)
    11391139{
    1140   char **words = 0;
    1141   int nwords = 0;
    1142   register int wordi = 0;
    1143 
    1144   /* Chop ARGV[0] into words and put them in WORDS.  */
    1145   char *t = argv[0];
     1140  const char *t;
     1141  char **words;
     1142  int wordi;
    11461143  char *p;
    11471144  unsigned int len;
    11481145  int i;
    11491146
     1147  /* Find the maximum number of words we'll have.  */
     1148  t = argv[0];
     1149  wordi = 1;
     1150  while (*t != '\0')
     1151    {
     1152      char c = *(t++);
     1153
     1154      if (! isspace ((unsigned char)c))
     1155        continue;
     1156
     1157      ++wordi;
     1158
     1159      while (isspace ((unsigned char)*t))
     1160        ++t;
     1161    }
     1162
     1163  words = xmalloc (wordi * sizeof (char *));
     1164
     1165  /* Now assign pointers to each string in the array.  */
     1166  t = argv[0];
     1167  wordi = 0;
    11501168  while ((p = find_next_token (&t, &len)) != 0)
    11511169    {
    1152       if (wordi >= nwords - 1)
    1153         {
    1154           nwords = (2 * nwords) + 5;
    1155           words = (char **) xrealloc ((char *) words,
    1156                                       nwords * sizeof (char *));
    1157         }
    1158       words[wordi++] = savestring (p, len);
    1159     }
    1160 
    1161   if (!wordi)
    1162     return o;
    1163 
    1164   /* Now sort the list of words.  */
    1165   qsort ((char *) words, wordi, sizeof (char *), alpha_compare);
    1166 
    1167   /* Now write the sorted list.  */
    1168   for (i = 0; i < wordi; ++i)
    1169     {
    1170       len = strlen (words[i]);
    1171       if (i == wordi - 1 || strlen (words[i + 1]) != len
    1172           || strcmp (words[i], words[i + 1]))
     1170      ++t;
     1171      p[len] = '\0';
     1172      words[wordi++] = p;
     1173    }
     1174
     1175  if (wordi)
     1176    {
     1177      /* Now sort the list of words.  */
     1178      qsort (words, wordi, sizeof (char *), alpha_compare);
     1179
     1180      /* Now write the sorted list, uniquified.  */
     1181      for (i = 0; i < wordi; ++i)
    11731182        {
    1174           o = variable_buffer_output (o, words[i], len);
    1175           o = variable_buffer_output (o, " ", 1);
     1183          len = strlen (words[i]);
     1184          if (i == wordi - 1 || strlen (words[i + 1]) != len
     1185              || strcmp (words[i], words[i + 1]))
     1186            {
     1187              o = variable_buffer_output (o, words[i], len);
     1188              o = variable_buffer_output (o, " ", 1);
     1189            }
    11761190        }
    1177       free (words[i]);
    1178     }
    1179   /* Kill the last space.  */
    1180   --o;
     1191
     1192      /* Kill the last space.  */
     1193      --o;
     1194    }
    11811195
    11821196  free (words);
     
    12241238  argv += 1 + !result;
    12251239
    1226   if (argv[0])
    1227     {
    1228       char *expansion;
    1229 
    1230       expansion = expand_argument (argv[0], NULL);
     1240  if (*argv)
     1241    {
     1242      char *expansion = expand_argument (*argv, NULL);
    12311243
    12321244      o = variable_buffer_output (o, expansion, strlen (expansion));
     
    13451357func_wildcard (char *o, char **argv, const char *funcname UNUSED)
    13461358{
    1347 
    13481359#ifdef _AMIGA
    13491360   o = wildcard_expansion (argv[0], o);
     
    15851596func_shell (char *o, char **argv, const char *funcname UNUSED)
    15861597{
    1587   char* batch_filename = NULL;
     1598  char *batch_filename = NULL;
    15881599
    15891600#ifdef __MSDOS__
     
    15911602#endif
    15921603  char **command_argv;
    1593   char *error_prefix;
     1604  const char *error_prefix;
    15941605  char **envp;
    15951606  int pipedes[2];
     
    15981609#ifndef __MSDOS__
    15991610  /* Construct the argument list.  */
    1600   command_argv = construct_command_argv (argv[0],
    1601                                          (char **) NULL, (struct file *) 0,
    1602                                          &batch_filename);
     1611  command_argv = construct_command_argv (argv[0], NULL, NULL, &batch_filename);
    16031612  if (command_argv == 0)
    16041613    return o;
     
    16121621     calling environment.
    16131622
     1623     See Savannah bug #10593.
     1624
    16141625  envp = target_environment (NILF);
    16151626  */
     
    16201631  if (reading_file && reading_file->filenm)
    16211632    {
    1622       error_prefix = (char *) alloca (strlen (reading_file->filenm)+11+4);
    1623       sprintf (error_prefix,
    1624                "%s:%lu: ", reading_file->filenm, reading_file->lineno);
     1633      char *p = alloca (strlen (reading_file->filenm)+11+4);
     1634      sprintf (p, "%s:%lu: ", reading_file->filenm, reading_file->lineno);
     1635      error_prefix = p;
    16251636    }
    16261637  else
    16271638    error_prefix = "";
    16281639
    1629 #ifdef WINDOWS32
    1630 
    1631   windows32_openpipe (pipedes, &pid, command_argv, envp);
    1632 
    1633   if (pipedes[0] < 0) {
    1634         /* open of the pipe failed, mark as failed execution */
    1635     shell_function_completed = -1;
    1636 
    1637         return o;
    1638   } else
    1639 
    1640 #elif defined(__MSDOS__)
    1641 
     1640#if defined(__MSDOS__)
    16421641  fpipe = msdos_openpipe (pipedes, &pid, argv[0]);
    16431642  if (pipedes[0] < 0)
     
    16461645      return o;
    16471646    }
    1648 
     1647#elif defined(WINDOWS32)
     1648  windows32_openpipe (pipedes, &pid, command_argv, envp);
     1649  if (pipedes[0] < 0)
     1650    {
     1651      /* open of the pipe failed, mark as failed execution */
     1652      shell_function_completed = -1;
     1653
     1654      return o;
     1655    }
     1656  else
    16491657#else
    1650 
    16511658  if (pipe (pipedes) < 0)
    16521659    {
     
    16561663
    16571664# ifdef __EMX__
    1658 
    16591665  /* close some handles that are unnecessary for the child process */
    16601666  CLOSE_ON_EXEC(pipedes[1]);
     
    16641670  if (pid < 0)
    16651671    perror_with_name (error_prefix, "spawn");
    1666 
    16671672# else /* ! __EMX__ */
    1668 
    16691673  pid = vfork ();
    16701674  if (pid < 0)
     
    16731677    child_execute_job (0, pipedes[1], command_argv, envp);
    16741678  else
    1675 
    16761679# endif
    1677 
    16781680#endif
    16791681    {
     
    16901692      /* Free the storage only the child needed.  */
    16911693      free (command_argv[0]);
    1692       free ((char *) command_argv);
     1694      free (command_argv);
    16931695
    16941696      /* Close the write side of the pipe.  */
    1695       (void) close (pipedes[1]);
     1697      close (pipedes[1]);
    16961698#endif
    16971699
     
    16991701
    17001702      maxlen = 200;
    1701       buffer = (char *) xmalloc (maxlen + 1);
     1703      buffer = xmalloc (maxlen + 1);
    17021704
    17031705      /* Read from the pipe until it gets EOF.  */
     
    17071709            {
    17081710              maxlen += 512;
    1709               buffer = (char *) xrealloc (buffer, maxlen + 1);
     1711              buffer = xrealloc (buffer, maxlen + 1);
    17101712            }
    17111713
     
    18341836        {
    18351837          maxlen += 512;
    1836           buffer = (char *) xrealloc (buffer, maxlen + 1);
     1838          buffer = xrealloc (buffer, maxlen + 1);
    18371839        }
    18381840
     
    18721874func_not (char *o, char **argv, char *funcname)
    18731875{
    1874   char *s = argv[0];
     1876  const char *s = argv[0];
    18751877  int result = 0;
    18761878  while (isspace ((unsigned char)*s))
     
    19661968{
    19671969  /* Expand the argument.  */
    1968   char *p = argv[0];
    1969   char *path = 0;
     1970  const char *p = argv[0];
     1971  const char *path = 0;
    19701972  int doneany = 0;
    19711973  unsigned int len = 0;
     
    19801982          in[len] = '\0';
    19811983
    1982           if
    1983           (
     1984          if (
    19841985#ifdef HAVE_REALPATH
    1985             realpath (in, out)
     1986              realpath (in, out)
    19861987#else
    1987             abspath (in, out)
     1988              abspath (in, out)
    19881989#endif
    1989           )
     1990             )
    19901991            {
    19911992              o = variable_buffer_output (o, out, strlen (out));
     
    20002001    --o;
    20012002
    2002  return o;
     2003  return o;
    20032004}
    20042005
     
    20072008{
    20082009  /* Expand the argument.  */
    2009   char *p = argv[0];
    2010   char *path = 0;
     2010  const char *p = argv[0];
     2011  const char *path = 0;
    20112012  int doneany = 0;
    20122013  unsigned int len = 0;
     
    20342035    --o;
    20352036
    2036  return o;
     2037  return o;
    20372038}
    20382039
     
    20492050   Functions that do namespace tricks (foreach) don't automatically expand.  */
    20502051
    2051 static char *func_call PARAMS ((char *o, char **argv, const char *funcname));
     2052static char *func_call (char *o, char **argv, const char *funcname);
    20522053
    20532054
     
    21312132
    21322133int
    2133 handle_function (char **op, char **stringp)
     2134handle_function (char **op, const char **stringp)
    21342135{
    21352136  const struct function_table_entry *entry_p;
    21362137  char openparen = (*stringp)[0];
    21372138  char closeparen = openparen == '(' ? ')' : '}';
    2138   char *beg;
    2139   char *end;
     2139  const char *beg;
     2140  const char *end;
    21402141  int count = 0;
    2141   register char *p;
     2142  char *abeg = NULL;
    21422143  char **argv, **argvp;
    21432144  int nargs;
     
    21762177
    21772178  /* Get some memory to store the arg pointers.  */
    2178   argvp = argv = (char **) alloca (sizeof (char *) * (nargs + 2));
     2179  argvp = argv = alloca (sizeof (char *) * (nargs + 2));
    21792180
    21802181  /* Chop the string into arguments, then a nul.  As soon as we hit
     
    21862187     each argument.  */
    21872188
    2188   if (!entry_p->expand_args)
     2189  if (entry_p->expand_args)
     2190    {
     2191      const char *p;
     2192      for (p=beg, nargs=0; p <= end; ++argvp)
     2193        {
     2194          const char *next;
     2195
     2196          ++nargs;
     2197
     2198          if (nargs == entry_p->maximum_args
     2199              || (! (next = find_next_argument (openparen, closeparen, p, end))))
     2200            next = end;
     2201
     2202          *argvp = expand_argument (p, next);
     2203          p = next + 1;
     2204        }
     2205    }
     2206  else
    21892207    {
    21902208      int len = end - beg;
    2191 
    2192       p = xmalloc (len+1);
    2193       memcpy (p, beg, len);
    2194       p[len] = '\0';
    2195       beg = p;
    2196       end = beg + len;
    2197     }
    2198 
    2199   for (p=beg, nargs=0; p <= end; ++argvp)
    2200     {
    2201       char *next;
    2202 
    2203       ++nargs;
    2204 
    2205       if (nargs == entry_p->maximum_args
    2206           || (! (next = find_next_argument (openparen, closeparen, p, end))))
    2207         next = end;
    2208 
    2209       if (entry_p->expand_args)
    2210         *argvp = expand_argument (p, next);
    2211       else
     2209      char *p, *aend;
     2210
     2211      abeg = xmalloc (len+1);
     2212      memcpy (abeg, beg, len);
     2213      abeg[len] = '\0';
     2214      aend = abeg + len;
     2215
     2216      for (p=abeg, nargs=0; p <= aend; ++argvp)
    22122217        {
     2218          char *next;
     2219
     2220          ++nargs;
     2221
     2222          if (nargs == entry_p->maximum_args
     2223              || (! (next = find_next_argument (openparen, closeparen, p, aend))))
     2224            next = aend;
     2225
    22132226          *argvp = p;
    22142227          *next = '\0';
     2228          p = next + 1;
    22152229        }
    2216 
    2217       p = next + 1;
    22182230    }
    22192231  *argvp = NULL;
     
    22262238    for (argvp=argv; *argvp != 0; ++argvp)
    22272239      free (*argvp);
    2228   else
    2229     free (beg);
     2240  if (abeg)
     2241    free (abeg);
    22302242
    22312243  return 1;
     
    22692281
    22702282  entry_p = lookup_function (fname);
    2271 
    22722283  if (entry_p)
    22732284    {
    22742285      /* How many arguments do we have?  */
    22752286      for (i=0; argv[i+1]; ++i)
    2276         ;
    2277 
     2287        ;
    22782288      return expand_builtin_function (o, i, argv+1, entry_p);
    22792289    }
     
    22912301    return o;
    22922302
    2293   body = (char *) alloca (flen + 4);
     2303  body = alloca (flen + 4);
    22942304  body[0] = '$';
    22952305  body[1] = '(';
  • vendor/gnumake/current/getloadavg.c

    r501 r900  
    707707        {
    708708          struct class_stats stats;
    709           bzero ((char *) &stats, sizeof stats);
     709          memset (&stats, '\0', sizeof stats);
    710710
    711711          desc.sd_type = CPUTYPE_CLASS;
  • vendor/gnumake/current/hash.h

    r501 r900  
    175175
    176176#define ISTRING_COMPARE(X, Y, RESULT) do { \
    177   RESULT = strcmpi ((X), (Y)); \
     177  RESULT = strcasecmp ((X), (Y)); \
    178178} while (0)
    179179#define return_ISTRING_COMPARE(X, Y) do { \
    180   return strcmpi ((X), (Y)); \
     180  return strcasecmp ((X), (Y)); \
    181181} while (0)
    182182
  • vendor/gnumake/current/implicit.c

    r501 r900  
    2626#include "commands.h" /* set_file_variables */
    2727
    28 static int
    29 pattern_search PARAMS ((struct file *file, int archive,
    30                         unsigned int depth, unsigned int recursions));
     28static int pattern_search (struct file *file, int archive,
     29                           unsigned int depth, unsigned int recursions);
    3130
    3231
     
    7271{
    7372  struct idep *next;              /* struct dep -compatible interface */
    74   char *name;                     /* name of the prerequisite */
     73  const char *name;               /* name of the prerequisite */
    7574  struct file *intermediate_file; /* intermediate file, 0 otherwise */
    76   char *intermediate_pattern;    /* pattern for intermediate file */
     75  const char *intermediate_pattern; /* pattern for intermediate file */
    7776  unsigned char had_stem;         /* had % substituted with stem */
    7877  unsigned char ignore_mtime;     /* ignore_mtime flag */
     
    8786    {
    8887      n = p->next;
    89 
    90       if (p->name)
    91         {
    92           struct file *f = p->intermediate_file;
    93 
    94           if (f != 0
    95               && (f->stem < f->name || f->stem > f->name + strlen (f->name)))
    96             free (f->stem);
    97 
    98           free (p->name);
    99         }
    100 
    10188      free (p);
    10289    }
     
    10996
    11097static char *
    111 get_next_word (char *buffer, unsigned int *length)
     98get_next_word (const char *buffer, unsigned int *length)
    11299{
    113   char *p = buffer, *beg;
     100  const char *p = buffer, *beg;
    114101  char c;
    115102
     
    182169    *length = p - beg;
    183170
    184   return beg;
     171  return (char *)beg;
    185172}
    186173
     
    204191{
    205192  /* Filename we are searching for a rule for.  */
    206   char *filename = archive ? strchr (file->name, '(') : file->name;
     193  const char *filename = archive ? strchr (file->name, '(') : file->name;
    207194
    208195  /* Length of FILENAME.  */
     
    226213
    227214  /* Names of possible dependencies are constructed in this buffer.  */
    228   register char *depname = (char *) alloca (namelen + max_pattern_dep_length);
     215  char *depname = alloca (namelen + max_pattern_dep_length);
    229216
    230217  /* The start and length of the stem of FILENAME for the current rule.  */
    231   register char *stem = 0;
    232   register unsigned int stemlen = 0;
    233   register unsigned int fullstemlen = 0;
     218  const char *stem = 0;
     219  unsigned int stemlen = 0;
     220  unsigned int fullstemlen = 0;
    234221
    235222  /* Buffer in which we store all the rules that are possibly applicable.  */
    236   struct rule **tryrules
    237     = (struct rule **) xmalloc (num_pattern_rules * max_pattern_targets
    238                                 * sizeof (struct rule *));
     223  struct rule **tryrules = xmalloc (num_pattern_rules * max_pattern_targets
     224                                    * sizeof (struct rule *));
    239225
    240226  /* Number of valid elements in TRYRULES.  */
     
    243229  /* The numbers of the rule targets of each rule
    244230     in TRYRULES that matched the target file.  */
    245   unsigned int *matches
    246     = (unsigned int *) alloca (num_pattern_rules * sizeof (unsigned int));
     231  unsigned int *matches = alloca (num_pattern_rules * sizeof (unsigned int));
    247232
    248233  /* Each element is nonzero if LASTSLASH was used in
    249234     matching the corresponding element of TRYRULES.  */
    250   char *checked_lastslash
    251     = (char *) alloca (num_pattern_rules * sizeof (char));
     235  char *checked_lastslash = alloca (num_pattern_rules * sizeof (char));
    252236
    253237  /* The index in TRYRULES of the rule we found.  */
     
    261245  int specific_rule_matched = 0;
    262246
    263   unsigned int i = 0;  /* uninit checks OK */
     247  unsigned int ri;  /* uninit checks OK */
    264248  struct rule *rule;
    265249  struct dep *dep, *expl_d;
    266 
    267   char *p, *vname;
    268250
    269251  struct idep *d;
     
    310292  for (rule = pattern_rules; rule != 0; rule = rule->next)
    311293    {
     294      unsigned int ti;
     295
    312296      /* If the pattern rule has deps but no commands, ignore it.
    313297         Users cancel built-in rules by redefining them without commands.  */
     
    323307        }
    324308
    325       for (i = 0; rule->targets[i] != 0; ++i)
     309      for (ti = 0; ti < rule->num; ++ti)
    326310        {
    327           char *target = rule->targets[i];
    328           char *suffix = rule->suffixes[i];
     311          const char *target = rule->targets[ti];
     312          const char *suffix = rule->suffixes[ti];
    329313          int check_lastslash;
    330314
     
    335319            continue;
    336320
    337           if (rule->lens[i] > namelen)
     321          if (rule->lens[ti] > namelen)
    338322            /* It can't possibly match.  */
    339323            continue;
     
    342326             find the stem: the part of the filename that matches the %.  */
    343327          stem = filename + (suffix - target - 1);
    344           stemlen = namelen - rule->lens[i] + 1;
     328          stemlen = namelen - rule->lens[ti] + 1;
    345329
    346330          /* Set CHECK_LASTSLASH if FILENAME contains a directory
     
    408392             that rule will be in TRYRULES more than once.  */
    409393          tryrules[nrules] = rule;
    410           matches[nrules] = i;
     394          matches[nrules] = ti;
    411395          checked_lastslash[nrules] = check_lastslash;
    412396          ++nrules;
     
    417401     retroactively reject any non-"terminal" rules that do always match.  */
    418402  if (specific_rule_matched)
    419     for (i = 0; i < nrules; ++i)
    420       if (!tryrules[i]->terminal)
     403    for (ri = 0; ri < nrules; ++ri)
     404      if (!tryrules[ri]->terminal)
    421405        {
    422           register unsigned int j;
    423           for (j = 0; tryrules[i]->targets[j] != 0; ++j)
    424             if (tryrules[i]->targets[j][1] == '\0')
    425               break;
    426           if (tryrules[i]->targets[j] != 0)
    427             tryrules[i] = 0;
     406          unsigned int j;
     407          for (j = 0; j < tryrules[ri]->num; ++j)
     408            if (tryrules[ri]->targets[j][1] == '\0')
     409              {
     410                tryrules[ri] = 0;
     411                break;
     412              }
    428413        }
    429414
     
    439424         and chain them in DEPS.  */
    440425
    441       for (i = 0; i < nrules; i++)
     426      for (ri = 0; ri < nrules; ri++)
    442427        {
    443428          struct file *f;
     
    446431          int file_variables_set = 0;
    447432
    448           rule = tryrules[i];
     433          rule = tryrules[ri];
    449434
    450435          remove_explicit_deps = 0;
     
    467452             find the stem: the part of the filename that matches the %.  */
    468453          stem = filename
    469             + (rule->suffixes[matches[i]] - rule->targets[matches[i]]) - 1;
    470           stemlen = namelen - rule->lens[matches[i]] + 1;
    471           check_lastslash = checked_lastslash[i];
     454            + (rule->suffixes[matches[ri]] - rule->targets[matches[ri]]) - 1;
     455          stemlen = namelen - rule->lens[matches[ri]] + 1;
     456          check_lastslash = checked_lastslash[ri];
    472457          if (check_lastslash)
    473458            {
     
    491476            {
    492477              unsigned int len;
     478              char *p;
    493479              char *p2;
    494480              unsigned int order_only = 0; /* Set if '|' was seen. */
     
    536522                      if (p2 < p + len)
    537523                        {
    538                           register unsigned int i = p2 - p;
    539                           bcopy (p, depname, i);
    540                           bcopy ("$*", depname + i, 2);
    541                           bcopy (p2 + 1, depname + i + 2, len - i - 1);
     524                          unsigned int i = p2 - p;
     525                          memcpy (depname, p, i);
     526                          memcpy (depname + i, "$*", 2);
     527                          memcpy (depname + i + 2, p2 + 1, len - i - 1);
    542528                          depname[len + 2 - 1] = '\0';
    543529
     
    549535                      else
    550536                        {
    551                           bcopy (p, depname, len);
     537                          memcpy (depname, p, len);
    552538                          depname[len] = '\0';
    553539                        }
     
    568554                       if (p2 < p + len)
    569555                        {
    570                           register unsigned int i = p2 - p;
    571                           bcopy (p, depname, i);
    572                           bcopy (stem_str, depname + i, stemlen);
    573                           bcopy (p2 + 1, depname + i + stemlen, len - i - 1);
     556                          unsigned int i = p2 - p;
     557                          memcpy (depname, p, i);
     558                          memcpy (depname + i, stem_str, stemlen);
     559                          memcpy (depname + i + stemlen, p2 + 1, len - i - 1);
    574560                          depname[len + stemlen - 1] = '\0';
    575561
     
    581567                      else
    582568                        {
    583                           bcopy (p, depname, len);
     569                          memcpy (depname, p, len);
    584570                          depname[len] = '\0';
    585571                        }
     
    619605                              if (add_dir)
    620606                                {
    621                                   char *p = d->name;
    622 
    623                                   d->name = xmalloc (strlen (p) + l + 1);
    624 
    625                                   bcopy (filename, d->name, l);
    626                                   bcopy (p, d->name + l, strlen (p) + 1);
    627 
    628                                   free (p);
     607                                  char *n = alloca (strlen (d->name) + l + 1);
     608                                  memcpy (n, filename, l);
     609                                  memcpy (n+l, d->name, strlen (d->name) + 1);
     610                                  d->name = strcache_add (n);
    629611                                }
    630612
     
    658640          for (d = deps; d != 0; d = d->next)
    659641            {
    660               char *name = d->name;
     642              const char *name = d->name;
    661643
    662644              if (file_impossible_p (name))
     
    670652                        : _("Rejecting impossible rule prerequisite `%s'.\n"),
    671653                        name));
    672                   tryrules[i] = 0;
     654                  tryrules[ri] = 0;
    673655
    674656                  failed = 1;
     
    706688              /* This code, given FILENAME = "lib/foo.o", dependency name
    707689                 "lib/foo.c", and VPATH=src, searches for "src/lib/foo.c".  */
    708               vname = name;
    709               if (vpath_search (&vname, (FILE_TIMESTAMP *) 0))
    710                 {
    711                   DBS (DB_IMPLICIT,
    712                        (_("Found prerequisite `%s' as VPATH `%s'\n"),
    713                         name,
    714                         vname));
    715 
    716                   free (vname);
    717                   continue;
    718                 }
     690              {
     691                const char *vname = vpath_search (name, 0);
     692                if (vname)
     693                  {
     694                    DBS (DB_IMPLICIT,
     695                         (_("Found prerequisite `%s' as VPATH `%s'\n"),
     696                          name, vname));
     697                    continue;
     698                  }
     699              }
    719700
    720701
     
    726707                {
    727708                  if (intermediate_file == 0)
    728                     intermediate_file
    729                       = (struct file *) alloca (sizeof (struct file));
     709                    intermediate_file = alloca (sizeof (struct file));
    730710
    731711                  DBS (DB_IMPLICIT,
     
    733713                        name));
    734714
    735                   bzero ((char *) intermediate_file, sizeof (struct file));
     715                  memset (intermediate_file, '\0', sizeof (struct file));
    736716                  intermediate_file->name = name;
    737717                  if (pattern_search (intermediate_file,
     
    740720                                      recursions + 1))
    741721                    {
     722                      d->intermediate_pattern = intermediate_file->name;
     723                      intermediate_file->name = strcache_add (name);
    742724                      d->intermediate_file = intermediate_file;
    743                       d->intermediate_pattern = intermediate_file->name;
    744 
    745                       intermediate_file->name = xstrdup (name);
    746725                      intermediate_file = 0;
    747726
     
    781760      /* If we found an applicable rule without
    782761         intermediate files, don't try with them.  */
    783       if (i < nrules)
     762      if (ri < nrules)
    784763        break;
    785764
     
    792771    goto done;
    793772
    794   foundrule = i;
     773  foundrule = ri;
    795774
    796775  /* If we are recursing, store the pattern that matched
     
    825804  for (d = deps; d != 0; d = d->next)
    826805    {
    827       register char *s;
     806      const char *s;
    828807
    829808      if (d->intermediate_file != 0)
     
    845824            f->precious = 1;
    846825          else
    847             f = enter_file (imf->name);
     826            f = enter_file (strcache_add (imf->name));
    848827
    849828          f->deps = imf->deps;
     
    865844            {
    866845              dep->file = enter_file (dep->name);
    867               /* enter_file uses dep->name _if_ we created a new file.  */
    868               if (dep->name != dep->file->name)
    869                 free (dep->name);
    870846              dep->name = 0;
    871847              dep->file->tried_implicit |= dep->changed;
     
    881857          dep->file = lookup_file (s);
    882858          if (dep->file == 0)
    883             /* enter_file consumes S's storage.  */
    884859            dep->file = enter_file (s);
    885           else
    886             /* A copy of S is already allocated in DEP->file->name.
    887                So we can free S.  */
    888             free (s);
    889860        }
    890861      else
    891         {
    892           dep->name = s;
    893         }
     862        dep->name = s;
    894863
    895864      if (d->intermediate_file == 0 && tryrules[foundrule]->terminal)
     
    916885      /* Always allocate new storage, since STEM might be
    917886         on the stack for an intermediate file.  */
    918       file->stem = savestring (stem, stemlen);
     887      file->stem = strcache_add_len (stem, stemlen);
    919888      fullstemlen = stemlen;
    920889    }
     
    922891    {
    923892      int dirlen = (lastslash + 1) - filename;
     893      char *sp;
    924894
    925895      /* We want to prepend the directory from
    926896         the original FILENAME onto the stem.  */
    927897      fullstemlen = dirlen + stemlen;
    928       file->stem = (char *) xmalloc (fullstemlen + 1);
    929       bcopy (filename, file->stem, dirlen);
    930       bcopy (stem, file->stem + dirlen, stemlen);
    931       file->stem[fullstemlen] = '\0';
     898      sp = alloca (fullstemlen + 1);
     899      memcpy (sp, filename, dirlen);
     900      memcpy (sp + dirlen, stem, stemlen);
     901      sp[fullstemlen] = '\0';
     902      file->stem = strcache_add (sp);
    932903    }
    933904
     
    945916     `also_make' member.  */
    946917
    947   if (rule->targets[1] != 0)
    948     for (i = 0; rule->targets[i] != 0; ++i)
    949       if (i != matches[foundrule])
     918  if (rule->num > 1)
     919    for (ri = 0; ri < rule->num; ++ri)
     920      if (ri != matches[foundrule])
    950921        {
     922          char *p = alloca (rule->lens[ri] + fullstemlen + 1);
    951923          struct file *f;
    952924          struct dep *new = alloc_dep ();
    953925
    954926          /* GKM FIMXE: handle '|' here too */
    955           new->name = p = (char *) xmalloc (rule->lens[i] + fullstemlen + 1);
    956           bcopy (rule->targets[i], p,
    957                  rule->suffixes[i] - rule->targets[i] - 1);
    958           p += rule->suffixes[i] - rule->targets[i] - 1;
    959           bcopy (file->stem, p, fullstemlen);
     927          memcpy (p, rule->targets[ri],
     928                  rule->suffixes[ri] - rule->targets[ri] - 1);
     929          p += rule->suffixes[ri] - rule->targets[ri] - 1;
     930          memcpy (p, file->stem, fullstemlen);
    960931          p += fullstemlen;
    961           bcopy (rule->suffixes[i], p,
    962                  rule->lens[i] - (rule->suffixes[i] - rule->targets[i]) + 1);
     932          memcpy (p, rule->suffixes[ri],
     933                  rule->lens[ri] - (rule->suffixes[ri] - rule->targets[ri])+1);
     934          new->name = strcache_add (p);
    963935          new->file = enter_file (new->name);
    964936          new->next = file->also_make;
    965937
    966938          /* Set precious flag. */
    967           f = lookup_file (rule->targets[i]);
     939          f = lookup_file (rule->targets[ri]);
    968940          if (f && f->precious)
    969941            new->file->precious = 1;
  • vendor/gnumake/current/job.c

    r501 r900  
    9999# include <starlet.h>
    100100# include <lib$routines.h>
    101 static void vmsWaitForChildren PARAMS ((int *));
     101static void vmsWaitForChildren (int *);
    102102#endif
    103103
     
    131131
    132132#if !defined (wait) && !defined (POSIX)
    133 extern int wait ();
     133int wait ();
    134134#endif
    135135
     
    176176
    177177#ifndef HAVE_UNISTD_H
    178 extern int dup2 ();
    179 extern int execve ();
    180 extern void _exit ();
     178int dup2 ();
     179int execve ();
     180void _exit ();
    181181# ifndef VMS
    182 extern int geteuid ();
    183 extern int getegid ();
    184 extern int setgid ();
    185 extern int getgid ();
     182int geteuid ();
     183int getegid ();
     184int setgid ();
     185int getgid ();
    186186# endif
    187187#endif
    188188
    189 extern char *allocated_variable_expand_for_file PARAMS ((char *line, struct file *file));
    190 
    191 extern int getloadavg PARAMS ((double loadavg[], int nelem));
    192 extern int start_remote_job PARAMS ((char **argv, char **envp, int stdin_fd,
    193                 int *is_remote, int *id_ptr, int *used_stdin));
    194 extern int start_remote_job_p PARAMS ((int));
    195 extern int remote_status PARAMS ((int *exit_code_ptr, int *signal_ptr,
    196                 int *coredump_ptr, int block));
    197 
    198 RETSIGTYPE child_handler PARAMS ((int));
    199 static void free_child PARAMS ((struct child *));
    200 static void start_job_command PARAMS ((struct child *child));
    201 static int load_too_high PARAMS ((void));
    202 static int job_next_command PARAMS ((struct child *));
    203 static int start_waiting_job PARAMS ((struct child *));
     189int getloadavg (double loadavg[], int nelem);
     190int start_remote_job (char **argv, char **envp, int stdin_fd, int *is_remote,
     191                      int *id_ptr, int *used_stdin);
     192int start_remote_job_p (int);
     193int remote_status (int *exit_code_ptr, int *signal_ptr, int *coredump_ptr,
     194                   int block);
     195
     196RETSIGTYPE child_handler (int);
     197static void free_child (struct child *);
     198static void start_job_command (struct child *child);
     199static int load_too_high (void);
     200static int job_next_command (struct child *);
     201static int start_waiting_job (struct child *);
    204202
    205203
     
    304302        {
    305303          const unsigned final_size = path_size + size + 1;
    306           char *const path = (char *) xmalloc (final_size);
     304          char *const path = xmalloc (final_size);
    307305          memcpy (path, temp_path, final_size);
    308306          *fd = _open_osfhandle ((long)h, 0);
     
    363361  i = 0;
    364362  while (known_os2shells[i] != NULL) {
    365     if (stricmp (name, known_os2shells[i]) == 0) /* strcasecmp() */
     363    if (strcasecmp (name, known_os2shells[i]) == 0)
    366364      return 0; /* not a unix shell */
    367365    i++;
     
    380378
    381379static void
    382 child_error (char *target_name, int exit_code, int exit_sig, int coredump,
    383              int ignored)
     380child_error (const char *target_name,
     381             int exit_code, int exit_sig, int coredump, int ignored)
    384382{
    385383  if (ignored && silent_flag)
     
    501499
    502500         The test and decrement are not atomic; if it is compiled into:
    503                 register = dead_children - 1;
     501                register = dead_children - 1;
    504502                dead_children = register;
    505503         a SIGCHLD could come between the two instructions.
     
    881879      for (i = 0; i < child->file->cmds->ncommand_lines; ++i)
    882880        free (child->command_lines[i]);
    883       free ((char *) child->command_lines);
     881      free (child->command_lines);
    884882    }
    885883
     
    889887      while (*ep != 0)
    890888        free (*ep++);
    891       free ((char *) child->environment);
    892     }
    893 
    894   free ((char *) child);
     889      free (child->environment);
     890    }
     891
     892  free (child);
    895893}
    896894
     
    938936#endif
    939937
    940   bzero ((char *) &sa, sizeof sa);
     938  memset (&sa, '\0', sizeof sa);
    941939  sa.sa_handler = child_handler;
    942940  sa.sa_flags = set_handler ? 0 : SA_RESTART;
     
    10441042#ifndef VMS
    10451043      free (argv[0]);
    1046       free ((char *) argv);
     1044      free (argv);
    10471045#endif
    10481046      child->file->update_status = 1;
     
    10591057        {
    10601058          free (argv[0]);
    1061           free ((char *) argv);
     1059          free (argv);
    10621060        }
    10631061#endif
     
    11201118    {
    11211119      free (argv[0]);
    1122       free ((char *) argv);
     1120      free (argv);
    11231121      goto next_command;
    11241122    }
     
    11311129#ifndef VMS
    11321130      free (argv[0]);
    1133       free ((char *) argv);
     1131      free (argv);
    11341132#endif
    11351133      goto next_command;
     
    14091407#ifndef VMS
    14101408  free (argv[0]);
    1411   free ((char *) argv);
     1409  free (argv);
    14121410#endif
    14131411
     
    14911489new_job (struct file *file)
    14921490{
    1493   register struct commands *cmds = file->cmds;
    1494   register struct child *c;
     1491  struct commands *cmds = file->cmds;
     1492  struct child *c;
    14951493  char **lines;
    1496   register unsigned int i;
     1494  unsigned int i;
    14971495
    14981496  /* Let any previously decided-upon jobs that are waiting
     
    15071505
    15081506  /* Expand the command lines and store the results in LINES.  */
    1509   lines = (char **) xmalloc (cmds->ncommand_lines * sizeof (char *));
     1507  lines = xmalloc (cmds->ncommand_lines * sizeof (char *));
    15101508  for (i = 0; i < cmds->ncommand_lines; ++i)
    15111509    {
     
    15331531               we processed (where IN points) and the new chunk
    15341532               we are about to process (where REF points).  */
    1535             bcopy (in, out, ref - in);
     1533            memmove (out, in, ref - in);
    15361534
    15371535          /* Move both pointers past the boring stuff.  */
     
    16111609     `struct child', and add that to the chain.  */
    16121610
    1613   c = (struct child *) xmalloc (sizeof (struct child));
    1614   bzero ((char *)c, sizeof (struct child));
     1611  c = xmalloc (sizeof (struct child));
     1612  memset (c, '\0', sizeof (struct child));
    16151613  c->file = file;
    16161614  c->command_lines = lines;
     
    17321730  /* The job is now primed.  Start it running.
    17331731     (This will notice if there are in fact no commands.)  */
    1734   (void) start_waiting_job (c);
     1732  if (cmds->fileinfo.filenm)
     1733    DB (DB_BASIC, (_("Invoking commands from %s:%lu to update target `%s'.\n"),
     1734                   cmds->fileinfo.filenm, cmds->fileinfo.lineno,
     1735                   c->file->name));
     1736  else
     1737    DB (DB_BASIC, (_("Invoking builtin commands to update target `%s'.\n"),
     1738                   c->file->name));
     1739
     1740
     1741  start_waiting_job (c);
    17351742
    17361743  if (job_slots == 1 || not_parallel)
     
    21252132# endif
    21262133
    2127         new_argv = (char **) alloca ((1 + argc + 1) * sizeof (char *));
     2134        new_argv = alloca ((1 + argc + 1) * sizeof (char *));
    21282135        new_argv[0] = shell;
    21292136
     
    23182325                             "shift", "switch", "test", "times", "trap",
    23192326                             "umask", "wait", "while", 0 };
    2320 #endif
    2321   register int i;
    2322   register char *p;
    2323   register char *ap;
     2327# ifdef HAVE_DOS_PATHS
     2328  /* This is required if the MSYS/Cygwin ports (which do not define
     2329     WINDOWS32) are compiled with HAVE_DOS_PATHS defined, which uses
     2330     sh_chars_sh[] directly (see below).  */
     2331  static char *sh_chars_sh = sh_chars;
     2332# endif  /* HAVE_DOS_PATHS */
     2333#endif
     2334  int i;
     2335  char *p;
     2336  char *ap;
    23242337  char *end;
    23252338  int instring, word_has_equals, seen_nonequals, last_argument_was_empty;
     
    23532366  else if (strcmp (shell, default_shell))
    23542367  {
    2355     char *s1 = _fullpath(NULL, shell, 0);
    2356     char *s2 = _fullpath(NULL, default_shell, 0);
    2357 
    2358     slow_flag = strcmp((s1 ? s1 : ""), (s2 ? s2 : ""));
     2368    char *s1 = _fullpath (NULL, shell, 0);
     2369    char *s2 = _fullpath (NULL, default_shell, 0);
     2370
     2371    slow_flag = strcmp ((s1 ? s1 : ""), (s2 ? s2 : ""));
    23592372
    23602373    if (s1)
     
    23672380#else  /* not WINDOWS32 */
    23682381#if defined (__MSDOS__) || defined (__EMX__)
    2369   else if (stricmp (shell, default_shell))
     2382  else if (strcasecmp (shell, default_shell))
    23702383    {
    23712384      extern int _is_unixy_shell (const char *_path);
     
    24092422
    24102423  /* More than 1 arg per character is impossible.  */
    2411   new_argv = (char **) xmalloc (i * sizeof (char *));
     2424  new_argv = xmalloc (i * sizeof (char *));
    24122425
    24132426  /* All the args can fit in a buffer as big as LINE is.   */
    2414   ap = new_argv[0] = argstr = (char *) xmalloc (i);
     2427  ap = new_argv[0] = argstr = xmalloc (i);
    24152428  end = ap + i;
    24162429
     
    24512464                  *(ap++) = *p;
    24522465                }
    2453               /* If there's a TAB here, skip it.  */
    2454               if (p[1] == '\t')
     2466              /* If there's a command prefix char here, skip it.  */
     2467              if (p[1] == cmd_prefix)
    24552468                ++p;
    24562469            }
     
    25012514                ++p;
    25022515
    2503                 /* If there is a tab after a backslash-newline, remove it.  */
    2504                 if (p[1] == '\t')
     2516                /* If there is a command prefix after a backslash-newline,
     2517                   remove it.  */
     2518                if (p[1] == cmd_prefix)
    25052519                  ++p;
    25062520
     
    26292643      /* Line was empty.  */
    26302644      free (argstr);
    2631       free ((char *)new_argv);
     2645      free (new_argv);
    26322646      return 0;
    26332647    }
     
    26422656      /* Free the old argument list we were working on.  */
    26432657      free (argstr);
    2644       free ((char *)new_argv);
     2658      free (new_argv);
    26452659    }
    26462660
     
    26552669    char *dptr;
    26562670
    2657     buffer = (char *)xmalloc (strlen (line)+1);
     2671    buffer = xmalloc (strlen (line)+1);
    26582672
    26592673    ptr = line;
     
    26722686    *dptr = 0;
    26732687
    2674     new_argv = (char **) xmalloc (2 * sizeof (char *));
     2688    new_argv = xmalloc (2 * sizeof (char *));
    26752689    new_argv[0] = buffer;
    26762690    new_argv[1] = 0;
     
    27082722    unsigned int line_len = strlen (line);
    27092723
    2710     char *new_line = (char *) alloca (shell_len + (sizeof (minus_c) - 1)
    2711                                       + (line_len * 2) + 1);
     2724    char *new_line = alloca (shell_len + (sizeof (minus_c)-1)
     2725                             + (line_len*2) + 1);
    27122726    char *command_ptr = NULL; /* used for batch_mode_shell mode */
    27132727
     
    27182732
    27192733    ap = new_line;
    2720     bcopy (shell, ap, shell_len);
     2734    memcpy (ap, shell, shell_len);
    27212735    ap += shell_len;
    2722     bcopy (minus_c, ap, sizeof (minus_c) - 1);
     2736    memcpy (ap, minus_c, sizeof (minus_c) - 1);
    27232737    ap += sizeof (minus_c) - 1;
    27242738    command_ptr = ap;
     
    27492763
    27502764            ++p;
    2751             if (p[1] == '\t')
     2765            if (p[1] == cmd_prefix)
    27522766              ++p;
    27532767
     
    27842798      /* Need to allocate new_argv, although it's unused, because
    27852799        start_job_command will want to free it and its 0'th element.  */
    2786       new_argv = (char **) xmalloc(2 * sizeof (char *));
     2800      new_argv = xmalloc(2 * sizeof (char *));
    27872801      new_argv[0] = xstrdup ("");
    27882802      new_argv[1] = NULL;
     
    28112825
    28122826      /* create argv */
    2813       new_argv = (char **) xmalloc(3 * sizeof (char *));
     2827      new_argv = xmalloc(3 * sizeof (char *));
    28142828      if (unixy_shell) {
    28152829        new_argv[0] = xstrdup (shell);
     
    28232837#endif /* WINDOWS32 */
    28242838    if (unixy_shell)
    2825       new_argv = construct_command_argv_internal (new_line, (char **) NULL,
    2826                                                   (char *) 0, (char *) 0,
    2827                                                   (char **) 0);
     2839      new_argv = construct_command_argv_internal (new_line, 0, 0, 0, 0);
    28282840#ifdef __EMX__
    28292841    else if (!unixy_shell)
     
    28422854              {
    28432855                q += 2; /* remove '\\' and '\n' */
    2844                 if (q[0] == '\t')
    2845                   q++; /* remove 1st tab in the next line */
     2856                /* Remove any command prefix in the next line */
     2857                if (q[0] == cmd_prefix)
     2858                  q++;
    28462859              }
    28472860            else
     
    28832896
    28842897          /* exactly 3 arguments + NULL */
    2885           new_argv = (char **) xmalloc (4 * sizeof (char *));
     2898          new_argv = xmalloc (4 * sizeof (char *));
    28862899          /* Exactly strlen(shell) + strlen("/c") + strlen(line) + 3 times
    28872900             the trailing '\0' */
    2888           new_argv[0] = (char *) malloc (sh_len + line_len + 5);
     2901          new_argv[0] = xmalloc (sh_len + line_len + 5);
    28892902          memcpy (new_argv[0], shell, sh_len + 1);
    28902903          new_argv[1] = new_argv[0] + sh_len + 1;
     
    29012914           instead of recursively calling ourselves, because we
    29022915           cannot backslash-escape the special characters (see above).  */
    2903         new_argv = (char **) xmalloc (sizeof (char *));
     2916        new_argv = xmalloc (sizeof (char *));
    29042917        line_len = strlen (new_line) - shell_len - sizeof (minus_c) + 1;
    29052918        new_argv[0] = xmalloc (line_len + 1);
     
    29592972    }
    29602973
    2961   argv = (char **)malloc (argc * sizeof (char *));
     2974  argv = xmalloc (argc * sizeof (char *));
    29622975  if (argv == 0)
    29632976    abort ();
  • vendor/gnumake/current/job.h

    r501 r900  
    6767extern struct child *children;
    6868
    69 extern void new_job PARAMS ((struct file *file));
    70 extern void reap_children PARAMS ((int block, int err));
    71 extern void start_waiting_jobs PARAMS ((void));
     69void new_job (struct file *file);
     70void reap_children (int block, int err);
     71void start_waiting_jobs (void);
    7272
    73 extern char **construct_command_argv PARAMS ((char *line, char **restp, struct file *file, char** batch_file));
     73char **construct_command_argv (char *line, char **restp, struct file *file, char** batch_file);
    7474#ifdef VMS
    75 extern int child_execute_job PARAMS ((char *argv, struct child *child));
     75int child_execute_job (char *argv, struct child *child);
    7676#elif defined(__EMX__)
    77 extern int child_execute_job PARAMS ((int stdin_fd, int stdout_fd, char **argv, char **envp));
     77int child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp);
    7878#else
    79 extern void child_execute_job PARAMS ((int stdin_fd, int stdout_fd, char **argv, char **envp));
     79void child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp);
    8080#endif
    8181#ifdef _AMIGA
    82 extern void exec_command PARAMS ((char **argv));
     82void exec_command (char **argv);
    8383#elif defined(__EMX__)
    84 extern int exec_command PARAMS ((char **argv, char **envp));
     84int exec_command (char **argv, char **envp);
    8585#else
    86 extern void exec_command PARAMS ((char **argv, char **envp));
     86void exec_command (char **argv, char **envp);
    8787#endif
    8888
    8989extern unsigned int job_slots_used;
    9090
    91 extern void block_sigs PARAMS ((void));
     91void block_sigs (void);
    9292#ifdef POSIX
    93 extern void unblock_sigs PARAMS ((void));
     93void unblock_sigs (void);
    9494#else
    9595#ifdef  HAVE_SIGSETMASK
  • vendor/gnumake/current/main.c

    r501 r900  
    11/* Argument parsing and main program of GNU Make.
    22Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
    3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
     31998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
    44Foundation, Inc.
    55This file is part of GNU Make.
     
    5757#endif
    5858
    59 extern void init_dir PARAMS ((void));
    60 extern void remote_setup PARAMS ((void));
    61 extern void remote_cleanup PARAMS ((void));
    62 extern RETSIGTYPE fatal_error_signal PARAMS ((int sig));
    63 
    64 extern void print_variable_data_base PARAMS ((void));
    65 extern void print_dir_data_base PARAMS ((void));
    66 extern void print_rule_data_base PARAMS ((void));
    67 extern void print_file_data_base PARAMS ((void));
    68 extern void print_vpath_data_base PARAMS ((void));
     59void init_dir (void);
     60void remote_setup (void);
     61void remote_cleanup (void);
     62RETSIGTYPE fatal_error_signal (int sig);
     63
     64void print_variable_data_base (void);
     65void print_dir_data_base (void);
     66void print_rule_data_base (void);
     67void print_file_data_base (void);
     68void print_vpath_data_base (void);
     69
     70void verify_file_data_base (void);
    6971
    7072#if defined HAVE_WAITPID || defined HAVE_WAIT3
     
    7375
    7476#ifndef HAVE_UNISTD_H
    75 extern int chdir ();
     77int chdir ();
    7678#endif
    7779#ifndef STDC_HEADERS
    7880# ifndef sun                    /* Sun has an incorrect decl in a header.  */
    79 extern void exit PARAMS ((int)) __attribute__ ((noreturn));
     81void exit (int) __attribute__ ((noreturn));
    8082# endif
    81 extern double atof ();
    82 #endif
    83 
    84 static void clean_jobserver PARAMS ((int status));
    85 static void print_data_base PARAMS ((void));
    86 static void print_version PARAMS ((void));
    87 static void decode_switches PARAMS ((int argc, char **argv, int env));
    88 static void decode_env_switches PARAMS ((char *envar, unsigned int len));
    89 static void define_makeflags PARAMS ((int all, int makefile));
    90 static char *quote_for_env PARAMS ((char *out, char *in));
    91 static void initialize_global_hash_tables PARAMS ((void));
     83double atof ();
     84#endif
     85
     86static void clean_jobserver (int status);
     87static void print_data_base (void);
     88static void print_version (void);
     89static void decode_switches (int argc, char **argv, int env);
     90static void decode_env_switches (char *envar, unsigned int len);
     91static void define_makeflags (int all, int makefile);
     92static char *quote_for_env (char *out, const char *in);
     93static void initialize_global_hash_tables (void);
    9294
    9395
     
    104106        flag_off,               /* Turn int flag off.  */
    105107        string,                 /* One string per switch.  */
     108        filename,               /* A string containing a file name.  */
    106109        positive_int,           /* A positive integer.  */
    107110        floating,               /* A floating-point number (double).  */
     
    109112      } type;
    110113
    111     char *value_ptr;    /* Pointer to the value-holding variable.  */
     114    void *value_ptr;    /* Pointer to the value-holding variable.  */
    112115
    113116    unsigned int env:1;         /* Can come from MAKEFLAGS.  */
     
    115118    unsigned int no_makefile:1; /* Don't propagate when remaking makefiles.  */
    116119
    117     char *noarg_value;  /* Pointer to value used if no argument is given.  */
    118     char *default_value;/* Pointer to default value.  */
     120    const void *noarg_value;    /* Pointer to value used if no arg given.  */
     121    const void *default_value;  /* Pointer to default value.  */
    119122
    120123    char *long_name;            /* Long option name.  */
     
    130133struct stringlist
    131134  {
    132     char **list;        /* Nil-terminated list of strings.  */
     135    const char **list;  /* Nil-terminated list of strings.  */
    133136    unsigned int idx;   /* Index into above.  */
    134137    unsigned int max;   /* Number of pointers allocated.  */
     
    158161
    159162int db_level = 0;
     163
     164/* Output level (--verbosity).  */
     165
     166static struct stringlist *verbosity_flags;
    160167
    161168#ifdef WINDOWS32
     
    282289
    283290struct variable shell_var;
     291
     292/* This character introduces a command: it's the first char on the line.  */
     293
     294char cmd_prefix = '\t';
    284295
    285296
     
    365376  {
    366377    { 'b', ignore, 0, 0, 0, 0, 0, 0, 0 },
    367     { 'B', flag, (char *) &always_make_set, 1, 1, 0, 0, 0, "always-make" },
    368     { 'C', string, (char *) &directories, 0, 0, 0, 0, 0, "directory" },
    369     { 'd', flag, (char *) &debug_flag, 1, 1, 0, 0, 0, 0 },
    370     { CHAR_MAX+1, string, (char *) &db_flags, 1, 1, 0, "basic", 0, "debug" },
     378    { 'B', flag, &always_make_set, 1, 1, 0, 0, 0, "always-make" },
     379    { 'C', filename, &directories, 0, 0, 0, 0, 0, "directory" },
     380    { 'd', flag, &debug_flag, 1, 1, 0, 0, 0, 0 },
     381    { CHAR_MAX+1, string, &db_flags, 1, 1, 0, "basic", 0, "debug" },
    371382#ifdef WINDOWS32
    372     { 'D', flag, (char *) &suspend_flag, 1, 1, 0, 0, 0, "suspend-for-debug" },
    373 #endif
    374     { 'e', flag, (char *) &env_overrides, 1, 1, 0, 0, 0,
    375       "environment-overrides", },
    376     { 'f', string, (char *) &makefiles, 0, 0, 0, 0, 0, "file" },
    377     { 'h', flag, (char *) &print_usage_flag, 0, 0, 0, 0, 0, "help" },
    378     { 'i', flag, (char *) &ignore_errors_flag, 1, 1, 0, 0, 0,
    379       "ignore-errors" },
    380     { 'I', string, (char *) &include_directories, 1, 1, 0, 0, 0,
     383    { 'D', flag, &suspend_flag, 1, 1, 0, 0, 0, "suspend-for-debug" },
     384#endif
     385    { 'e', flag, &env_overrides, 1, 1, 0, 0, 0, "environment-overrides", },
     386    { 'f', filename, &makefiles, 0, 0, 0, 0, 0, "file" },
     387    { 'h', flag, &print_usage_flag, 0, 0, 0, 0, 0, "help" },
     388    { 'i', flag, &ignore_errors_flag, 1, 1, 0, 0, 0, "ignore-errors" },
     389    { 'I', filename, &include_directories, 1, 1, 0, 0, 0,
    381390      "include-dir" },
    382     { 'j', positive_int, (char *) &job_slots, 1, 1, 0, (char *) &inf_jobs,
    383       (char *) &default_job_slots, "jobs" },
    384     { CHAR_MAX+2, string, (char *) &jobserver_fds, 1, 1, 0, 0, 0,
    385       "jobserver-fds" },
    386     { 'k', flag, (char *) &keep_going_flag, 1, 1, 0, 0,
    387       (char *) &default_keep_going_flag, "keep-going" },
     391    { 'j', positive_int, &job_slots, 1, 1, 0, &inf_jobs, &default_job_slots,
     392      "jobs" },
     393    { CHAR_MAX+2, string, &jobserver_fds, 1, 1, 0, 0, 0, "jobserver-fds" },
     394    { 'k', flag, &keep_going_flag, 1, 1, 0, 0, &default_keep_going_flag,
     395      "keep-going" },
    388396#ifndef NO_FLOAT
    389     { 'l', floating, (char *) &max_load_average, 1, 1, 0,
    390       (char *) &default_load_average, (char *) &default_load_average,
    391       "load-average" },
     397    { 'l', floating, &max_load_average, 1, 1, 0, &default_load_average,
     398      &default_load_average, "load-average" },
    392399#else
    393     { 'l', positive_int, (char *) &max_load_average, 1, 1, 0,
    394       (char *) &default_load_average, (char *) &default_load_average,
    395       "load-average" },
    396 #endif
    397     { 'L', flag, (char *) &check_symlink_flag, 1, 1, 0, 0, 0,
    398       "check-symlink-times" },
     400    { 'l', positive_int, &max_load_average, 1, 1, 0, &default_load_average,
     401      &default_load_average, "load-average" },
     402#endif
     403    { 'L', flag, &check_symlink_flag, 1, 1, 0, 0, 0, "check-symlink-times" },
    399404    { 'm', ignore, 0, 0, 0, 0, 0, 0, 0 },
    400     { 'n', flag, (char *) &just_print_flag, 1, 1, 1, 0, 0, "just-print" },
    401     { 'o', string, (char *) &old_files, 0, 0, 0, 0, 0, "old-file" },
    402     { 'p', flag, (char *) &print_data_base_flag, 1, 1, 0, 0, 0,
    403       "print-data-base" },
    404     { 'q', flag, (char *) &question_flag, 1, 1, 1, 0, 0, "question" },
    405     { 'r', flag, (char *) &no_builtin_rules_flag, 1, 1, 0, 0, 0,
    406       "no-builtin-rules" },
    407     { 'R', flag, (char *) &no_builtin_variables_flag, 1, 1, 0, 0, 0,
     405    { 'n', flag, &just_print_flag, 1, 1, 1, 0, 0, "just-print" },
     406    { 'o', filename, &old_files, 0, 0, 0, 0, 0, "old-file" },
     407    { 'p', flag, &print_data_base_flag, 1, 1, 0, 0, 0, "print-data-base" },
     408    { 'q', flag, &question_flag, 1, 1, 1, 0, 0, "question" },
     409    { 'r', flag, &no_builtin_rules_flag, 1, 1, 0, 0, 0, "no-builtin-rules" },
     410    { 'R', flag, &no_builtin_variables_flag, 1, 1, 0, 0, 0,
    408411      "no-builtin-variables" },
    409     { 's', flag, (char *) &silent_flag, 1, 1, 0, 0, 0, "silent" },
    410     { 'S', flag_off, (char *) &keep_going_flag, 1, 1, 0, 0,
    411       (char *) &default_keep_going_flag, "no-keep-going" },
    412     { 't', flag, (char *) &touch_flag, 1, 1, 1, 0, 0, "touch" },
    413     { 'v', flag, (char *) &print_version_flag, 1, 1, 0, 0, 0, "version" },
    414     { 'w', flag, (char *) &print_directory_flag, 1, 1, 0, 0, 0,
    415       "print-directory" },
    416     { CHAR_MAX+3, flag, (char *) &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
     412    { 's', flag, &silent_flag, 1, 1, 0, 0, 0, "silent" },
     413    { 'S', flag_off, &keep_going_flag, 1, 1, 0, 0, &default_keep_going_flag,
     414      "no-keep-going" },
     415    { 't', flag, &touch_flag, 1, 1, 1, 0, 0, "touch" },
     416    { 'v', flag, &print_version_flag, 1, 1, 0, 0, 0, "version" },
     417    { CHAR_MAX+3, string, &verbosity_flags, 1, 1, 0, 0, 0,
     418      "verbosity" },
     419    { 'w', flag, &print_directory_flag, 1, 1, 0, 0, 0, "print-directory" },
     420    { CHAR_MAX+4, flag, &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
    417421      "no-print-directory" },
    418     { 'W', string, (char *) &new_files, 0, 0, 0, 0, 0, "what-if" },
    419     { CHAR_MAX+4, flag, (char *) &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
     422    { 'W', filename, &new_files, 0, 0, 0, 0, 0, "what-if" },
     423    { CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
    420424      "warn-undefined-variables" },
    421425    { 0, 0, 0, 0, 0, 0, 0, 0, 0 }
     
    547551}
    548552
    549 static struct file *
    550 enter_command_line_file (char *name)
     553static const char *
     554expand_command_line_file (char *name)
    551555{
     556  const char *cp;
     557  char *expanded = 0;
     558
    552559  if (name[0] == '\0')
    553560    fatal (NILF, _("empty string invalid as file name"));
     
    555562  if (name[0] == '~')
    556563    {
    557       char *expanded = tilde_expand (name);
     564      expanded = tilde_expand (name);
    558565      if (expanded != 0)
    559         name = expanded;        /* Memory leak; I don't care.  */
     566        name = expanded;
    560567    }
    561568
     
    581588    }
    582589
    583   return enter_file (xstrdup (name));
     590  cp = strcache_add (name);
     591
     592  if (expanded)
     593    free (expanded);
     594
     595  return cp;
    584596}
    585597
     
    597609decode_debug_flags (void)
    598610{
    599   char **pp;
     611  const char **pp;
    600612
    601613  if (debug_flag)
     
    732744
    733745int
    734 find_and_set_default_shell (char *token)
     746find_and_set_default_shell (const char *token)
    735747{
    736748  int sh_found = 0;
     749  char *atoken = 0;
    737750  char *search_token;
    738751  char *tokend;
     
    743756    search_token = default_shell;
    744757  else
    745     search_token = token;
    746 
     758    atoken = search_token = xstrdup (token);
    747759
    748760  /* If the user explicitly requests the DOS cmd shell, obey that request.
     
    754766        || (tokend > search_token
    755767            && (tokend[-1] == '/' || tokend[-1] == '\\')))
    756        && !strcmpi (tokend, "cmd"))
     768       && !strcasecmp (tokend, "cmd"))
    757769      || ((tokend - 4 == search_token
    758770           || (tokend - 4 > search_token
    759771               && (tokend[-5] == '/' || tokend[-5] == '\\')))
    760           && !strcmpi (tokend - 4, "cmd.exe"))) {
     772          && !strcasecmp (tokend - 4, "cmd.exe"))) {
    761773    batch_mode_shell = 1;
    762774    unixy_shell = 0;
     
    770782    /* no new information, path already set or known */
    771783    sh_found = 1;
    772   } else if (file_exists_p(search_token)) {
     784  } else if (file_exists_p (search_token)) {
    773785    /* search token path was found */
    774     sprintf(sh_path, "%s", search_token);
    775     default_shell = xstrdup(w32ify(sh_path,0));
     786    sprintf (sh_path, "%s", search_token);
     787    default_shell = xstrdup (w32ify (sh_path, 0));
    776788    DB (DB_VERBOSE,
    777789        (_("find_and_set_shell setting default_shell = %s\n"), default_shell));
     
    786798
    787799      p  = v->value;
    788       ep = strchr(p, PATH_SEPARATOR_CHAR);
     800      ep = strchr (p, PATH_SEPARATOR_CHAR);
    789801
    790802      while (ep && *ep) {
    791803        *ep = '\0';
    792804
    793         if (dir_file_exists_p(p, search_token)) {
    794           sprintf(sh_path, "%s/%s", p, search_token);
    795           default_shell = xstrdup(w32ify(sh_path,0));
     805        if (dir_file_exists_p (p, search_token)) {
     806          sprintf (sh_path, "%s/%s", p, search_token);
     807          default_shell = xstrdup (w32ify (sh_path, 0));
    796808          sh_found = 1;
    797809          *ep = PATH_SEPARATOR_CHAR;
    798810
    799811          /* terminate loop */
    800           p += strlen(p);
     812          p += strlen (p);
    801813        } else {
    802814          *ep = PATH_SEPARATOR_CHAR;
     
    804816        }
    805817
    806         ep = strchr(p, PATH_SEPARATOR_CHAR);
     818        ep = strchr (p, PATH_SEPARATOR_CHAR);
    807819      }
    808820
    809821      /* be sure to check last element of Path */
    810       if (p && *p && dir_file_exists_p(p, search_token)) {
    811           sprintf(sh_path, "%s/%s", p, search_token);
    812           default_shell = xstrdup(w32ify(sh_path,0));
     822      if (p && *p && dir_file_exists_p (p, search_token)) {
     823          sprintf (sh_path, "%s/%s", p, search_token);
     824          default_shell = xstrdup (w32ify (sh_path, 0));
    813825          sh_found = 1;
    814826      }
     
    823835  /* naive test */
    824836  if (!unixy_shell && sh_found &&
    825       (strstr(default_shell, "sh") || strstr(default_shell, "SH"))) {
     837      (strstr (default_shell, "sh") || strstr (default_shell, "SH"))) {
    826838    unixy_shell = 1;
    827839    batch_mode_shell = 0;
     
    832844#endif
    833845
     846  if (atoken)
     847    free (atoken);
     848
    834849  return (sh_found);
    835850}
    836851#endif  /* WINDOWS32 */
    837852
    838 #ifdef  __MSDOS__
    839 
     853#ifdef __MSDOS__
    840854static void
    841855msdos_return_to_initial_directory (void)
     
    844858    chdir (directory_before_chdir);
    845859}
    846 #endif
    847 
    848 extern char *mktemp PARAMS ((char *template));
    849 extern int mkstemp PARAMS ((char *template));
     860#endif  /* __MSDOS__ */
     861
     862char *mktemp (char *template);
     863int mkstemp (char *template);
    850864
    851865FILE *
     
    900914{
    901915  static char *stdin_nm = 0;
    902   struct file *f;
    903   int i;
    904916  int makefile_status = MAKE_SUCCESS;
    905   char **p;
    906917  struct dep *read_makefiles;
    907918  PATH_VAR (current_directory);
     
    10261037# else  /* setvbuf not reversed.  */
    10271038  /* Some buggy systems lose if we pass 0 instead of allocating ourselves.  */
    1028   setvbuf (stdout, (char *) 0, _IOLBF, BUFSIZ);
     1039  setvbuf (stdout, 0, _IOLBF, BUFSIZ);
    10291040# endif /* setvbuf reversed.  */
    10301041#elif HAVE_SETLINEBUF
     
    11341145
    11351146#ifndef _AMIGA
    1136   for (i = 0; envp[i] != 0; ++i)
    1137     {
    1138       int do_not_define = 0;
    1139       char *ep = envp[i];
    1140 
    1141       while (*ep != '\0' && *ep != '=')
    1142         ++ep;
     1147  {
     1148    unsigned int i;
     1149
     1150    for (i = 0; envp[i] != 0; ++i)
     1151      {
     1152        int do_not_define = 0;
     1153        char *ep = envp[i];
     1154
     1155        while (*ep != '\0' && *ep != '=')
     1156          ++ep;
    11431157#ifdef WINDOWS32
    1144       if (!unix_path && strneq(envp[i], "PATH=", 5))
    1145         unix_path = ep+1;
    1146       else if (!strnicmp(envp[i], "Path=", 5)) {
    1147         do_not_define = 1; /* it gets defined after loop exits */
    1148         if (!windows32_path)
    1149           windows32_path = ep+1;
     1158        if (!unix_path && strneq(envp[i], "PATH=", 5))
     1159          unix_path = ep+1;
     1160        else if (!strnicmp(envp[i], "Path=", 5)) {
     1161          do_not_define = 1; /* it gets defined after loop exits */
     1162          if (!windows32_path)
     1163            windows32_path = ep+1;
     1164        }
     1165#endif
     1166        /* The result of pointer arithmetic is cast to unsigned int for
     1167           machines where ptrdiff_t is a different size that doesn't widen
     1168           the same.  */
     1169        if (!do_not_define)
     1170          {
     1171            struct variable *v;
     1172
     1173            v = define_variable (envp[i], (unsigned int) (ep - envp[i]),
     1174                                 ep + 1, o_env, 1);
     1175            /* Force exportation of every variable culled from the
     1176               environment.  We used to rely on target_environment's
     1177               v_default code to do this.  But that does not work for the
     1178               case where an environment variable is redefined in a makefile
     1179               with `override'; it should then still be exported, because it
     1180               was originally in the environment.  */
     1181            v->export = v_export;
     1182
     1183            /* Another wrinkle is that POSIX says the value of SHELL set in
     1184               the makefile won't change the value of SHELL given to
     1185               subprocesses.  */
     1186            if (streq (v->name, "SHELL"))
     1187              {
     1188#ifndef __MSDOS__
     1189                v->export = v_noexport;
     1190#endif
     1191                shell_var.name = "SHELL";
     1192                shell_var.value = xstrdup (ep + 1);
     1193              }
     1194
     1195            /* If MAKE_RESTARTS is set, remember it but don't export it.  */
     1196            if (streq (v->name, "MAKE_RESTARTS"))
     1197              {
     1198                v->export = v_noexport;
     1199                restarts = (unsigned int) atoi (ep + 1);
     1200              }
     1201          }
    11501202      }
    1151 #endif
    1152       /* The result of pointer arithmetic is cast to unsigned int for
    1153          machines where ptrdiff_t is a different size that doesn't widen
    1154          the same.  */
    1155       if (!do_not_define)
    1156         {
    1157           struct variable *v;
    1158 
    1159           v = define_variable (envp[i], (unsigned int) (ep - envp[i]),
    1160                                ep + 1, o_env, 1);
    1161           /* Force exportation of every variable culled from the environment.
    1162              We used to rely on target_environment's v_default code to do this.
    1163              But that does not work for the case where an environment variable
    1164              is redefined in a makefile with `override'; it should then still
    1165              be exported, because it was originally in the environment.  */
    1166           v->export = v_export;
    1167 
    1168           /* Another wrinkle is that POSIX says the value of SHELL set in the
    1169              makefile won't change the value of SHELL given to subprocesses  */
    1170           if (streq (v->name, "SHELL"))
    1171             {
    1172 #ifndef __MSDOS__
    1173               v->export = v_noexport;
    1174 #endif
    1175               shell_var.name = "SHELL";
    1176               shell_var.value = xstrdup (ep + 1);
    1177             }
    1178 
    1179           /* If MAKE_RESTARTS is set, remember it but don't export it.  */
    1180           if (streq (v->name, "MAKE_RESTARTS"))
    1181             {
    1182               v->export = v_noexport;
    1183               restarts = (unsigned int) atoi (ep + 1);
    1184             }
    1185         }
    1186     }
     1203  }
    11871204#ifdef WINDOWS32
    11881205    /* If we didn't find a correctly spelled PATH we define PATH as
     
    12301247#if 0
    12311248  /* People write things like:
    1232         MFLAGS="CC=gcc -pipe" "CFLAGS=-g"
     1249        MFLAGS="CC=gcc -pipe" "CFLAGS=-g"
    12331250     and we set the -p, -i and -e switches.  Doesn't seem quite right.  */
    12341251  decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS"));
     
    12931310      && argv[0] != 0
    12941311      && (argv[0][0] != '/' && (argv[0][0] == '\0' || argv[0][1] != ':'))
    1295 #ifdef __EMX__
     1312# ifdef __EMX__
    12961313      /* do not prepend cwd if argv[0] contains no '/', e.g. "make" */
    12971314      && (strchr (argv[0], '/') != 0 || strchr (argv[0], '\\') != 0)
    12981315# endif
    12991316      )
    1300     argv[0] = concat (current_directory, "/", argv[0]);
     1317    argv[0] = xstrdup (concat (current_directory, "/", argv[0]));
    13011318#else  /* !__MSDOS__ */
    13021319  if (current_directory[0] != '\0'
    1303       && argv[0] != 0 && argv[0][0] != '/' && strchr (argv[0], '/') != 0)
    1304     argv[0] = concat (current_directory, "/", argv[0]);
     1320      && argv[0] != 0 && argv[0][0] != '/' && strchr (argv[0], '/') != 0
     1321#ifdef HAVE_DOS_PATHS
     1322      && (argv[0][0] != '\\' && (!argv[0][0] || argv[0][1] != ':'))
     1323      && strchr (argv[0], '\\') != 0
     1324#endif
     1325      )
     1326    argv[0] = xstrdup (concat (current_directory, "/", argv[0]));
    13051327#endif /* !__MSDOS__ */
    13061328#endif /* WINDOWS32 */
     
    13331355
    13341356      /* Now allocate a buffer big enough and fill it.  */
    1335       p = value = (char *) alloca (len);
     1357      p = value = alloca (len);
    13361358      for (cv = command_variables; cv != 0; cv = cv->next)
    13371359        {
     
    13631385  /* If there were -C flags, move ourselves about.  */
    13641386  if (directories != 0)
    1365     for (i = 0; directories->list[i] != 0; ++i)
    1366       {
    1367         char *dir = directories->list[i];
    1368         char *expanded = 0;
    1369         if (dir[0] == '~')
    1370           {
    1371             expanded = tilde_expand (dir);
    1372             if (expanded != 0)
    1373               dir = expanded;
    1374           }
     1387    {
     1388      unsigned int i;
     1389      for (i = 0; directories->list[i] != 0; ++i)
     1390        {
     1391          const char *dir = directories->list[i];
    13751392#ifdef WINDOWS32
    1376         /* WINDOWS32 chdir() doesn't work if the directory has a trailing '/'
    1377            But allow -C/ just in case someone wants that.  */
    1378         {
    1379           char *p = dir + strlen (dir) - 1;
    1380           while (p > dir && (p[0] == '/' || p[0] == '\\'))
    1381             --p;
    1382           p[1] = '\0';
     1393          /* WINDOWS32 chdir() doesn't work if the directory has a trailing '/'
     1394             But allow -C/ just in case someone wants that.  */
     1395          {
     1396            char *p = dir + strlen (dir) - 1;
     1397            while (p > dir && (p[0] == '/' || p[0] == '\\'))
     1398              --p;
     1399            p[1] = '\0';
     1400          }
     1401#endif
     1402          if (chdir (dir) < 0)
     1403            pfatal_with_name (dir);
    13831404        }
    1384 #endif
    1385         if (chdir (dir) < 0)
    1386           pfatal_with_name (dir);
    1387         if (expanded)
    1388           free (expanded);
    1389       }
     1405    }
    13901406
    13911407#ifdef WINDOWS32
     
    14251441  /* Construct the list of include directories to search.  */
    14261442
    1427   construct_include_path (include_directories == 0 ? (char **) 0
    1428                           : include_directories->list);
     1443  construct_include_path (include_directories == 0
     1444                          ? 0 : include_directories->list);
    14291445
    14301446  /* Figure out where we are now, after chdir'ing.  */
     
    14571473  if (makefiles != 0)
    14581474    {
    1459       register unsigned int i;
     1475      unsigned int i;
    14601476      for (i = 0; i < makefiles->idx; ++i)
    14611477        if (makefiles->list[i][0] == '-' && makefiles->list[i][1] == '\0')
     
    14901506              tmpdir = DEFAULT_TMPDIR;
    14911507
    1492             template = (char *) alloca (strlen (tmpdir)
    1493                                         + sizeof (DEFAULT_TMPFILE) + 1);
     1508            template = alloca (strlen (tmpdir) + sizeof (DEFAULT_TMPFILE) + 1);
    14941509            strcpy (template, tmpdir);
    14951510
     
    15151530                  pfatal_with_name (_("fwrite (temporary file)"));
    15161531              }
    1517             (void) fclose (outfile);
     1532            fclose (outfile);
    15181533
    15191534            /* Replace the name that read_all_makefiles will
    15201535               see with the name of the temporary file.  */
    1521             makefiles->list[i] = xstrdup (stdin_nm);
     1536            makefiles->list[i] = strcache_add (stdin_nm);
    15221537
    15231538            /* Make sure the temporary file will not be remade.  */
    1524             f = enter_file (stdin_nm);
    1525             f->updated = 1;
    1526             f->update_status = 0;
    1527             f->command_state = cs_finished;
    1528             /* Can't be intermediate, or it'll be removed too early for
    1529                make re-exec.  */
    1530             f->intermediate = 0;
    1531             f->dontcare = 0;
     1539            {
     1540              struct file *f = enter_file (strcache_add (stdin_nm));
     1541              f->updated = 1;
     1542              f->update_status = 0;
     1543              f->command_state = cs_finished;
     1544              /* Can't be intermediate, or it'll be removed too early for
     1545                 make re-exec.  */
     1546              f->intermediate = 0;
     1547              f->dontcare = 0;
     1548            }
    15321549          }
    15331550    }
     
    15481565     If none of these are true, we don't need a signal handler at all.  */
    15491566  {
    1550     extern RETSIGTYPE child_handler PARAMS ((int sig));
     1567    RETSIGTYPE child_handler (int sig);
    15511568# if defined SIGCHLD
    15521569    bsd_signal (SIGCHLD, child_handler);
     
    15881605  define_default_variables ();
    15891606
    1590   default_file = enter_file (".DEFAULT");
     1607  default_file = enter_file (strcache_add (".DEFAULT"));
    15911608
    15921609  {
     
    15981615
    15991616  read_makefiles
    1600     = read_all_makefiles (makefiles == 0 ? (char **) 0 : makefiles->list);
     1617    = read_all_makefiles (makefiles == 0 ? 0 : makefiles->list);
    16011618
    16021619#ifdef WINDOWS32
     
    16531670  if (jobserver_fds)
    16541671  {
    1655     char *cp;
     1672    const char *cp;
    16561673    unsigned int ui;
    16571674
     
    16671684      fatal (NILF,
    16681685             _("internal error: invalid --jobserver-fds string `%s'"), cp);
     1686
     1687    DB (DB_JOBS,
     1688        (_("Jobserver client (fds %d,%d)\n"), job_fds[0], job_fds[1]));
    16691689
    16701690    /* The combination of a pipe + !job_slots means we're using the
     
    17091729  if (job_slots > 1)
    17101730    {
     1731      char *cp;
    17111732      char c = '+';
    17121733
     
    17321753      /* Fill in the jobserver_fds struct for our children.  */
    17331754
     1755      cp = xmalloc ((sizeof ("1024")*2)+1);
     1756      sprintf (cp, "%d,%d", job_fds[0], job_fds[1]);
     1757
    17341758      jobserver_fds = (struct stringlist *)
    17351759                        xmalloc (sizeof (struct stringlist));
    1736       jobserver_fds->list = (char **) xmalloc (sizeof (char *));
    1737       jobserver_fds->list[0] = xmalloc ((sizeof ("1024")*2)+1);
    1738 
    1739       sprintf (jobserver_fds->list[0], "%d,%d", job_fds[0], job_fds[1]);
     1760      jobserver_fds->list = xmalloc (sizeof (char *));
     1761      jobserver_fds->list[0] = cp;
    17401762      jobserver_fds->idx = 1;
    17411763      jobserver_fds->max = 1;
     
    17871809
    17881810  if (old_files != 0)
    1789     for (p = old_files->list; *p != 0; ++p)
    1790       {
    1791         f = enter_command_line_file (*p);
    1792         f->last_mtime = f->mtime_before_update = OLD_MTIME;
    1793         f->updated = 1;
    1794         f->update_status = 0;
    1795         f->command_state = cs_finished;
    1796       }
     1811    {
     1812      const char **p;
     1813      for (p = old_files->list; *p != 0; ++p)
     1814        {
     1815          struct file *f = enter_file (*p);
     1816          f->last_mtime = f->mtime_before_update = OLD_MTIME;
     1817          f->updated = 1;
     1818          f->update_status = 0;
     1819          f->command_state = cs_finished;
     1820        }
     1821    }
    17971822
    17981823  if (!restarts && new_files != 0)
    17991824    {
     1825      const char **p;
    18001826      for (p = new_files->list; *p != 0; ++p)
    18011827        {
    1802           f = enter_command_line_file (*p);
     1828          struct file *f = enter_file (*p);
    18031829          f->last_mtime = f->mtime_before_update = NEW_MTIME;
    18041830        }
     
    18321858        while (d != 0)
    18331859          {
    1834             register struct file *f = d->file;
     1860            struct file *f = d->file;
    18351861            if (f->double_colon)
    18361862              for (f = f->double_colon; f != NULL; f = f->prev)
     
    18651891            if (f == NULL || !f->double_colon)
    18661892              {
    1867                 makefile_mtimes = (FILE_TIMESTAMP *)
    1868                   xrealloc ((char *) makefile_mtimes,
    1869                             (mm_idx + 1) * sizeof (FILE_TIMESTAMP));
     1893                makefile_mtimes = xrealloc (makefile_mtimes,
     1894                                            (mm_idx+1)
     1895                                            * sizeof (FILE_TIMESTAMP));
    18701896                makefile_mtimes[mm_idx++] = file_mtime_no_search (d->file);
    18711897                last = d;
     
    19862012                    char *p = &argv[i][2];
    19872013                    if (*p == '\0')
    1988                       argv[++i] = makefiles->list[j];
     2014                      /* This cast is OK since we never modify argv.  */
     2015                      argv[++i] = (char *) makefiles->list[j];
    19892016                    else
    1990                       argv[i] = concat ("-f", makefiles->list[j], "");
     2017                      argv[i] = xstrdup (concat ("-f", makefiles->list[j], ""));
    19912018                    ++j;
    19922019                  }
     
    19962023          if (stdin_nm)
    19972024            {
    1998               nargv = (char **) xmalloc ((nargc + 2) * sizeof (char *));
    1999               bcopy ((char *) argv, (char *) nargv, argc * sizeof (char *));
    2000               nargv[nargc++] = concat ("-o", stdin_nm, "");
     2025              nargv = xmalloc ((nargc + 2) * sizeof (char *));
     2026              memcpy (nargv, argv, argc * sizeof (char *));
     2027              nargv[nargc++] = xstrdup (concat ("-o", stdin_nm, ""));
    20012028              nargv[nargc] = 0;
    20022029            }
     
    20042031          if (directories != 0 && directories->idx > 0)
    20052032            {
    2006               char bad;
     2033              int bad = 1;
    20072034              if (directory_before_chdir != 0)
    20082035                {
    20092036                  if (chdir (directory_before_chdir) < 0)
    2010                     {
    20112037                      perror_with_name ("chdir", "");
    2012                       bad = 1;
    2013                     }
    20142038                  else
    20152039                    bad = 0;
    20162040                }
    2017               else
    2018                 bad = 1;
    20192041              if (bad)
    20202042                fatal (NILF, _("Couldn't change back to original directory."));
     
    20332055
    20342056#ifndef _AMIGA
    2035           for (p = environ; *p != 0; ++p)
    2036             {
    2037               if (strneq (*p, MAKELEVEL_NAME, MAKELEVEL_LENGTH)
    2038                   && (*p)[MAKELEVEL_LENGTH] == '=')
    2039                 {
    2040                   /* The SGI compiler apparently can't understand
    2041                      the concept of storing the result of a function
    2042                      in something other than a local variable.  */
    2043                   char *sgi_loses;
    2044                   sgi_loses = (char *) alloca (40);
    2045                   *p = sgi_loses;
    2046                   sprintf (*p, "%s=%u", MAKELEVEL_NAME, makelevel);
    2047                 }
    2048               if (strneq (*p, "MAKE_RESTARTS=", 14))
    2049                 {
    2050                   char *sgi_loses;
    2051                   sgi_loses = (char *) alloca (40);
    2052                   *p = sgi_loses;
    2053                   sprintf (*p, "MAKE_RESTARTS=%u", restarts);
    2054                   restarts = 0;
    2055                 }
    2056             }
     2057          {
     2058            char **p;
     2059            for (p = environ; *p != 0; ++p)
     2060              {
     2061                if (strneq (*p, MAKELEVEL_NAME, MAKELEVEL_LENGTH)
     2062                    && (*p)[MAKELEVEL_LENGTH] == '=')
     2063                  {
     2064                    *p = alloca (40);
     2065                    sprintf (*p, "%s=%u", MAKELEVEL_NAME, makelevel);
     2066                  }
     2067                if (strneq (*p, "MAKE_RESTARTS=", 14))
     2068                  {
     2069                    *p = alloca (40);
     2070                    sprintf (*p, "MAKE_RESTARTS=%u", restarts);
     2071                    restarts = 0;
     2072                  }
     2073              }
     2074          }
    20572075#else /* AMIGA */
    20582076          {
     
    21202138      /* Free the makefile mtimes (if we allocated any).  */
    21212139      if (makefile_mtimes)
    2122         free ((char *) makefile_mtimes);
     2140        free (makefile_mtimes);
    21232141    }
    21242142
     
    21322150  if (restarts && new_files != 0)
    21332151    {
     2152      const char **p;
    21342153      for (p = new_files->list; *p != 0; ++p)
    21352154        {
    2136           f = enter_command_line_file (*p);
     2155          struct file *f = enter_file (*p);
    21372156          f->last_mtime = f->mtime_before_update = NEW_MTIME;
    21382157        }
     
    21732192                      fatal (NILF, _(".DEFAULT_GOAL contains more than one target"));
    21742193
    2175                     default_goal_file = enter_file (ns->name);
     2194                    default_goal_file = enter_file (strcache_add (ns->name));
    21762195
    21772196                    ns->name = 0; /* It was reused by enter_file(). */
     
    22772296
    22782297        case string:
     2298        case filename:
    22792299        case positive_int:
    22802300        case floating:
     
    23212341
    23222342      if (! cv) {
    2323         cv = (struct command_variable *) xmalloc (sizeof (*cv));
     2343        cv = xmalloc (sizeof (*cv));
    23242344        cv->variable = v;
    23252345        cv->next = command_variables;
     
    23322352         target!  Enter it as a file and add it to the dep chain of
    23332353         goals.  */
    2334       struct file *f = enter_command_line_file (arg);
     2354      struct file *f = enter_file (strcache_add (expand_command_line_file (arg)));
    23352355      f->cmd_target = 1;
    23362356
     
    23502370      {
    23512371        /* Add this target name to the MAKECMDGOALS variable. */
    2352         struct variable *v;
    2353         char *value;
    2354 
    2355         v = lookup_variable (STRING_SIZE_TUPLE ("MAKECMDGOALS"));
    2356         if (v == 0)
     2372        struct variable *gv;
     2373        const char *value;
     2374
     2375        gv = lookup_variable (STRING_SIZE_TUPLE ("MAKECMDGOALS"));
     2376        if (gv == 0)
    23572377          value = f->name;
    23582378        else
     
    23602380            /* Paste the old and new values together */
    23612381            unsigned int oldlen, newlen;
    2362 
    2363             oldlen = strlen (v->value);
     2382            char *vp;
     2383
     2384            oldlen = strlen (gv->value);
    23642385            newlen = strlen (f->name);
    2365             value = (char *) alloca (oldlen + 1 + newlen + 1);
    2366             bcopy (v->value, value, oldlen);
    2367             value[oldlen] = ' ';
    2368             bcopy (f->name, &value[oldlen + 1], newlen + 1);
     2386            vp = alloca (oldlen + 1 + newlen + 1);
     2387            memcpy (vp, gv->value, oldlen);
     2388            vp[oldlen] = ' ';
     2389            memcpy (&vp[oldlen + 1], f->name, newlen + 1);
     2390            value = vp;
    23692391          }
    23702392        define_variable ("MAKECMDGOALS", 12, value, o_default, 0);
     
    24622484
    24632485                case string:
     2486                case filename:
    24642487                  if (!doit)
    24652488                    break;
    24662489
    24672490                  if (optarg == 0)
    2468                     optarg = cs->noarg_value;
     2491                    optarg = xstrdup (cs->noarg_value);
    24692492                  else if (*optarg == '\0')
    24702493                    {
     
    24812504                      sl->max = 5;
    24822505                      sl->idx = 0;
    2483                       sl->list = (char **) xmalloc (5 * sizeof (char *));
     2506                      sl->list = xmalloc (5 * sizeof (char *));
    24842507                      *(struct stringlist **) cs->value_ptr = sl;
    24852508                    }
     
    24872510                    {
    24882511                      sl->max += 5;
    2489                       sl->list = (char **)
    2490                         xrealloc ((char *) sl->list,
    2491                                   sl->max * sizeof (char *));
     2512                      sl->list = xrealloc (sl->list,
     2513                                           sl->max * sizeof (char *));
    24922514                    }
    2493                   sl->list[sl->idx++] = optarg;
     2515                  if (cs->type == filename)
     2516                    sl->list[sl->idx++] = expand_command_line_file (optarg);
     2517                  else
     2518                    sl->list[sl->idx++] = optarg;
    24942519                  sl->list[sl->idx] = 0;
    24952520                  break;
     
    25762601decode_env_switches (char *envar, unsigned int len)
    25772602{
    2578   char *varref = (char *) alloca (2 + len + 2);
     2603  char *varref = alloca (2 + len + 2);
    25792604  char *value, *p;
    25802605  int argc;
     
    25842609  varref[0] = '$';
    25852610  varref[1] = '(';
    2586   bcopy (envar, &varref[2], len);
     2611  memcpy (&varref[2], envar, len);
    25872612  varref[2 + len] = ')';
    25882613  varref[2 + len + 1] = '\0';
     
    25962621
    25972622  /* Allocate a vector that is definitely big enough.  */
    2598   argv = (char **) alloca ((1 + len + 1) * sizeof (char *));
     2623  argv = alloca ((1 + len + 1) * sizeof (char *));
    25992624
    26002625  /* Allocate a buffer to copy the value into while we split it into words
    26012626     and unquote it.  We must use permanent storage for this because
    26022627     decode_switches may store pointers into the passed argument words.  */
    2603   p = (char *) xmalloc (2 * len);
     2628  p = xmalloc (2 * len);
    26042629
    26052630  /* getopt will look at the arguments starting at ARGV[1].
     
    26322657       need permanent storage for this in case decode_switches saves
    26332658       pointers into the value.  */
    2634     argv[1] = concat ("-", argv[1], "");
     2659    argv[1] = xstrdup (concat ("-", argv[1], ""));
    26352660
    26362661  /* Parse those words.  */
     
    26462671
    26472672static char *
    2648 quote_for_env (char *out, char *in)
     2673quote_for_env (char *out, const char *in)
    26492674{
    26502675  while (*in != '\0')
     
    26842709      struct flag *next;
    26852710      const struct command_switch *cs;
    2686       char *arg;
     2711      const char *arg;
    26872712    };
    26882713  struct flag *flags = 0;
     
    26902715#define ADD_FLAG(ARG, LEN) \
    26912716  do {                                                                        \
    2692     struct flag *new = (struct flag *) alloca (sizeof (struct flag));         \
     2717    struct flag *new = alloca (sizeof (struct flag));                         \
    26932718    new->cs = cs;                                                             \
    26942719    new->arg = (ARG);                                                         \
     
    27082733      switch (cs->type)
    27092734        {
    2710         default:
    2711           abort ();
    2712 
    27132735        case ignore:
    27142736          break;
     
    27382760              else
    27392761                {
    2740                   char *buf = (char *) alloca (30);
     2762                  char *buf = alloca (30);
    27412763                  sprintf (buf, "%u", *(unsigned int *) cs->value_ptr);
    27422764                  ADD_FLAG (buf, strlen (buf));
     
    27592781              else
    27602782                {
    2761                   char *buf = (char *) alloca (100);
     2783                  char *buf = alloca (100);
    27622784                  sprintf (buf, "%g", *(double *) cs->value_ptr);
    27632785                  ADD_FLAG (buf, strlen (buf));
     
    27672789#endif
    27682790
     2791        case filename:
    27692792        case string:
    27702793          if (all)
     
    27732796              if (sl != 0)
    27742797                {
    2775                   /* Add the elements in reverse order, because
    2776                      all the flags get reversed below; and the order
    2777                      matters for some switches (like -I).  */
    2778                   register unsigned int i = sl->idx;
     2798                  /* Add the elements in reverse order, because all the flags
     2799                     get reversed below; and the order matters for some
     2800                     switches (like -I).  */
     2801                  unsigned int i = sl->idx;
    27792802                  while (i-- > 0)
    27802803                    ADD_FLAG (sl->list[i], strlen (sl->list[i]));
     
    27822805            }
    27832806          break;
     2807
     2808        default:
     2809          abort ();
    27842810        }
    27852811
     
    27902816  /* Construct the value in FLAGSTRING.
    27912817     We allocate enough space for a preceding dash and trailing null.  */
    2792   flagstring = (char *) alloca (1 + flagslen + 1);
    2793   bzero (flagstring, 1 + flagslen + 1);
     2818  flagstring = alloca (1 + flagslen + 1);
     2819  memset (flagstring, '\0', 1 + flagslen + 1);
    27942820  p = flagstring;
    27952821  words = 1;
     
    28832909      if (posix_pedantic)
    28842910        {
    2885           bcopy (posixref, p, sizeof posixref - 1);
     2911          memcpy (p, posixref, sizeof posixref - 1);
    28862912          p += sizeof posixref - 1;
    28872913        }
    28882914      else
    28892915        {
    2890           bcopy (ref, p, sizeof ref - 1);
     2916          memcpy (p, ref, sizeof ref - 1);
    28912917          p += sizeof ref - 1;
    28922918        }
     
    30663092      if (print_data_base_flag)
    30673093        print_data_base ();
     3094
     3095      verify_file_data_base ();
    30683096
    30693097      clean_jobserver (status);
  • vendor/gnumake/current/make.1

    r501 r900  
    165165over variables from makefiles.
    166166.TP 0.5i
    167 +\fB\-f\fR \fIfile\fR, \fB\-\-file\fR=\fIfile\fR, \fB\-\-makefile\fR=\fIFILE\fR
     167\fB\-f\fR \fIfile\fR, \fB\-\-file\fR=\fIfile\fR, \fB\-\-makefile\fR=\fIFILE\fR
    168168Use
    169169.I file
  • vendor/gnumake/current/make.h

    r501 r900  
    3939#endif
    4040
    41 
    42 /* Use prototypes if available.  */
    43 #if defined (__cplusplus) || defined (__STDC__)
    44 # undef  PARAMS
    45 # define PARAMS(protos)  protos
    46 #else /* Not C++ or ANSI C.  */
    47 # undef  PARAMS
    48 # define PARAMS(protos)  ()
    49 #endif /* C++ or ANSI C.  */
    5041
    5142/* Specify we want GNU source code.  This must be defined before any
     
    151142# define NEED_GET_PATH_MAX 1
    152143# define GET_PATH_MAX   (get_path_max ())
    153 # define PATH_VAR(var)  char *var = (char *) alloca (GET_PATH_MAX)
    154 extern unsigned int get_path_max PARAMS ((void));
     144# define PATH_VAR(var)  char *var = alloca (GET_PATH_MAX)
     145unsigned int get_path_max (void);
    155146#endif
    156147
     
    228219#  include <stdlib.h>
    229220# else
    230 extern char *malloc PARAMS ((int));
    231 extern char *realloc PARAMS ((char *, int));
    232 extern void free PARAMS ((char *));
    233 
    234 extern void abort PARAMS ((void)) __attribute__ ((noreturn));
    235 extern void exit PARAMS ((int)) __attribute__ ((noreturn));
     221void *malloc (int);
     222void *realloc (void *, int);
     223void free (void *);
     224
     225void abort (void) __attribute__ ((noreturn));
     226void exit (int) __attribute__ ((noreturn));
    236227# endif /* HAVE_STDLIB_H.  */
    237228
     
    243234#endif
    244235#ifndef EXIT_FAILURE
    245 # define EXIT_FAILURE 0
    246 #endif
    247 
    248 #ifdef  ANSI_STRING
    249 
    250 # ifndef bcmp
    251 #  define bcmp(s1, s2, n)   memcmp ((s1), (s2), (n))
    252 # endif
    253 # ifndef bzero
    254 #  define bzero(s, n)       memset ((s), 0, (n))
    255 # endif
    256 # if defined(HAVE_MEMMOVE) && !defined(bcopy)
    257 #  define bcopy(s, d, n)    memmove ((d), (s), (n))
    258 # endif
    259 
    260 #else   /* Not ANSI_STRING.  */
    261 
    262 # ifndef HAVE_STRCHR
    263 #  define strchr(s, c)      index((s), (c))
    264 #  define strrchr(s, c)     rindex((s), (c))
    265 # endif
    266 
    267 # ifndef bcmp
    268 extern int bcmp PARAMS ((const char *, const char *, int));
    269 # endif
    270 # ifndef bzero
    271 extern void bzero PARAMS ((char *, int));
    272 #endif
    273 # ifndef bcopy
    274 extern void bcopy PARAMS ((const char *b1, char *b2, int));
    275 # endif
     236# define EXIT_FAILURE 1
     237#endif
     238
     239#ifndef  ANSI_STRING
    276240
    277241/* SCO Xenix has a buggy macro definition in <string.h>.  */
    278242#undef  strerror
    279243#if !defined(__DECC)
    280 extern char *strerror PARAMS ((int errnum));
     244char *strerror (int errnum);
    281245#endif
    282246
     
    290254
    291255#if !defined(HAVE_STRSIGNAL)
    292 extern char *strsignal PARAMS ((int signum));
     256char *strsignal (int signum);
    293257#endif
    294258
     
    309273    (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
    310274# ifdef HAVE_CASE_INSENSITIVE_FS
    311 /* This is only used on Windows/DOS platforms, so we assume strcmpi().  */
    312275#  define strieq(a, b) \
    313276    ((a) == (b) \
    314277     || (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
    315          && (*(a) == '\0' || !strcmpi ((a) + 1, (b) + 1))))
     278         && (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1))))
    316279# else
    317280#  define strieq(a, b) streq(a, b)
     
    323286#endif
    324287#define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
    325 #ifdef  VMS
    326 extern int strcmpi (const char *,const char *);
    327 #endif
    328288
    329289#if defined(__GNUC__) || defined(ENUM_BITFIELDS)
     
    348308
    349309/* Handle other OSs.  */
    350 #if defined(HAVE_DOS_PATHS)
    351 # define PATH_SEPARATOR_CHAR ';'
    352 #elif defined(VMS)
    353 # define PATH_SEPARATOR_CHAR ','
    354 #else
    355 # define PATH_SEPARATOR_CHAR ':'
    356 #endif
    357 
    358 /* This is needed for getcwd() and chdir().  */
    359 #if defined(_MSC_VER) || defined(__BORLANDC__)
     310#ifndef PATH_SEPARATOR_CHAR
     311# if defined(HAVE_DOS_PATHS)
     312#  define PATH_SEPARATOR_CHAR ';'
     313# elif defined(VMS)
     314#  define PATH_SEPARATOR_CHAR ','
     315# else
     316#  define PATH_SEPARATOR_CHAR ':'
     317# endif
     318#endif
     319
     320/* This is needed for getcwd() and chdir(), on some W32 systems.  */
     321#if defined(HAVE_DIRECT_H)
    360322# include <direct.h>
    361323#endif
     
    364326# include <fcntl.h>
    365327# include <malloc.h>
    366 # define pipe(p) _pipe(p, 512, O_BINARY)
    367 # define kill(pid,sig) w32_kill(pid,sig)
    368 
    369 extern void sync_Path_environment(void);
    370 extern int kill(int pid, int sig);
    371 extern char *end_of_token_w32(char *s, char stopchar);
    372 extern int find_and_set_default_shell(char *token);
     328# define pipe(_p)        _pipe((_p), 512, O_BINARY)
     329# define kill(_pid,_sig) w32_kill((_pid),(_sig))
     330
     331void sync_Path_environment (void);
     332int kill (int pid, int sig);
     333char *end_of_token_w32 (const char *s, char stopchar);
     334int find_and_set_default_shell (const char *token);
    373335
    374336/* indicates whether or not we have Bourne shell */
     
    400362
    401363#if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H
    402 extern void message (int prefix, const char *fmt, ...)
    403                      __attribute__ ((__format__ (__printf__, 2, 3)));
    404 extern void error (const struct floc *flocp, const char *fmt, ...)
    405                    __attribute__ ((__format__ (__printf__, 2, 3)));
    406 extern void fatal (const struct floc *flocp, const char *fmt, ...)
     364void message (int prefix, const char *fmt, ...)
     365              __attribute__ ((__format__ (__printf__, 2, 3)));
     366void error (const struct floc *flocp, const char *fmt, ...)
     367            __attribute__ ((__format__ (__printf__, 2, 3)));
     368void fatal (const struct floc *flocp, const char *fmt, ...)
    407369                   __attribute__ ((noreturn, __format__ (__printf__, 2, 3)));
    408370#else
    409 extern void message ();
    410 extern void error ();
    411 extern void fatal ();
    412 #endif
    413 
    414 extern void die PARAMS ((int)) __attribute__ ((noreturn));
    415 extern void log_working_directory PARAMS ((int));
    416 extern void pfatal_with_name PARAMS ((const char *)) __attribute__ ((noreturn));
    417 extern void perror_with_name PARAMS ((const char *, const char *));
    418 extern char *savestring PARAMS ((const char *, unsigned int));
    419 extern char *concat PARAMS ((const char *, const char *, const char *));
    420 extern char *xmalloc PARAMS ((unsigned int));
    421 extern char *xrealloc PARAMS ((char *, unsigned int));
    422 extern char *xstrdup PARAMS ((const char *));
    423 extern char *find_next_token PARAMS ((char **, unsigned int *));
    424 extern char *next_token PARAMS ((const char *));
    425 extern char *end_of_token PARAMS ((const char *));
    426 extern void collapse_continuations PARAMS ((char *));
    427 extern char *lindex PARAMS ((const char *, const char *, int));
    428 extern int alpha_compare PARAMS ((const void *, const void *));
    429 extern void print_spaces PARAMS ((unsigned int));
    430 extern char *find_percent PARAMS ((char *));
    431 extern FILE *open_tmpfile PARAMS ((char **, const char *));
     371void message ();
     372void error ();
     373void fatal ();
     374#endif
     375
     376void die (int) __attribute__ ((noreturn));
     377void log_working_directory (int);
     378void pfatal_with_name (const char *) __attribute__ ((noreturn));
     379void perror_with_name (const char *, const char *);
     380char *savestring (const char *, unsigned int);
     381char *concat (const char *, const char *, const char *);
     382void *xmalloc (unsigned int);
     383void *xrealloc (void *, unsigned int);
     384char *xstrdup (const char *);
     385char *find_next_token (const char **, unsigned int *);
     386char *next_token (const char *);
     387char *end_of_token (const char *);
     388void collapse_continuations (char *);
     389char *lindex (const char *, const char *, int);
     390int alpha_compare (const void *, const void *);
     391void print_spaces (unsigned int);
     392char *find_percent (char *);
     393const char *find_percent_cached (const char **);
     394FILE *open_tmpfile (char **, const char *);
    432395
    433396#ifndef NO_ARCHIVES
    434 extern int ar_name PARAMS ((char *));
    435 extern void ar_parse_name PARAMS ((char *, char **, char **));
    436 extern int ar_touch PARAMS ((char *));
    437 extern time_t ar_member_date PARAMS ((char *));
    438 #endif
    439 
    440 extern int dir_file_exists_p PARAMS ((char *, char *));
    441 extern int file_exists_p PARAMS ((char *));
    442 extern int file_impossible_p PARAMS ((char *));
    443 extern void file_impossible PARAMS ((char *));
    444 extern char *dir_name PARAMS ((char *));
    445 extern void hash_init_directories PARAMS ((void));
    446 
    447 extern void define_default_variables PARAMS ((void));
    448 extern void set_default_suffixes PARAMS ((void));
    449 extern void install_default_suffix_rules PARAMS ((void));
    450 extern void install_default_implicit_rules PARAMS ((void));
    451 
    452 extern void build_vpath_lists PARAMS ((void));
    453 extern void construct_vpath_list PARAMS ((char *pattern, char *dirpath));
    454 extern int vpath_search PARAMS ((char **file, FILE_TIMESTAMP *mtime_ptr));
    455 extern int gpath_search PARAMS ((char *file, unsigned int len));
    456 
    457 extern void construct_include_path PARAMS ((char **arg_dirs));
    458 
    459 extern void user_access PARAMS ((void));
    460 extern void make_access PARAMS ((void));
    461 extern void child_access PARAMS ((void));
    462 
    463 extern void close_stdout PARAMS ((void));
    464 
    465 extern char *strip_whitespace PARAMS ((const char **begpp, const char **endpp));
     397int ar_name (const char *);
     398void ar_parse_name (const char *, char **, char **);
     399int ar_touch (const char *);
     400time_t ar_member_date (const char *);
     401
     402typedef long int (*ar_member_func_t) (int desc, const char *mem, int truncated,
     403                                      long int hdrpos, long int datapos,
     404                                      long int size, long int date, int uid,
     405                                      int gid, int mode, const void *arg);
     406
     407long int ar_scan (const char *archive, ar_member_func_t function, const void *arg);
     408int ar_name_equal (const char *name, const char *mem, int truncated);
     409#ifndef VMS
     410int ar_member_touch (const char *arname, const char *memname);
     411#endif
     412#endif
     413
     414int dir_file_exists_p (const char *, const char *);
     415int file_exists_p (const char *);
     416int file_impossible_p (const char *);
     417void file_impossible (const char *);
     418const char *dir_name (const char *);
     419void hash_init_directories (void);
     420
     421void define_default_variables (void);
     422void set_default_suffixes (void);
     423void install_default_suffix_rules (void);
     424void install_default_implicit_rules (void);
     425
     426void build_vpath_lists (void);
     427void construct_vpath_list (char *pattern, char *dirpath);
     428const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr);
     429int gpath_search (const char *file, unsigned int len);
     430
     431void construct_include_path (const char **arg_dirs);
     432
     433void user_access (void);
     434void make_access (void);
     435void child_access (void);
     436
     437void close_stdout (void);
     438
     439char *strip_whitespace (const char **begpp, const char **endpp);
    466440
    467441/* String caching  */
    468 extern void strcache_init PARAMS ((void));
    469 extern void strcache_print_stats PARAMS ((const char *prefix));
    470 extern int strcache_iscached PARAMS ((const char *str));
    471 extern const char *strcache_add PARAMS ((const char *str));
    472 extern const char *strcache_add_len PARAMS ((const char *str, int len));
    473 extern int strcache_setbufsize PARAMS ((int size));
     442void strcache_init (void);
     443void strcache_print_stats (const char *prefix);
     444int strcache_iscached (const char *str);
     445const char *strcache_add (const char *str);
     446const char *strcache_add_len (const char *str, int len);
     447int strcache_setbufsize (int size);
    474448
    475449#ifdef  HAVE_VFORK_H
     
    482456#if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
    483457
    484 extern long int atol ();
     458long int atol ();
    485459# ifndef VMS
    486 extern long int lseek ();
     460long int lseek ();
    487461# endif
    488462
     
    491465#ifdef  HAVE_GETCWD
    492466# if !defined(VMS) && !defined(__DECC)
    493 extern char *getcwd ();
    494 # endif
    495 #else
    496 extern char *getwd ();
     467char *getcwd ();
     468# endif
     469#else
     470char *getwd ();
    497471# define getcwd(buf, len)       getwd (buf)
     472#endif
     473
     474#if !HAVE_STRCASECMP
     475# if HAVE_STRICMP
     476#  define strcasecmp stricmp
     477# elif HAVE_STRCMPI
     478#  define strcasecmp strcmpi
     479# else
     480/* Create our own, in misc.c */
     481int strcasecmp (const char *s1, const char *s2);
     482# endif
    498483#endif
    499484
     
    513498extern int batch_mode_shell;
    514499
     500extern char cmd_prefix;
     501
    515502extern unsigned int job_slots;
    516503extern int job_fds[2];
     
    564551#endif
    565552
    566 
    567553#ifdef __EMX__
    568 # if !HAVE_STRCASECMP
    569 #  define strcasecmp stricmp
    570 # endif
    571 
    572554# if !defined chdir
    573555#  define chdir _chdir2
     
    608590   to do it ourselves here.  */
    609591
    610 #define ENULLLOOP(_v,_c)   do{ errno = 0; \
    611                                while (((_v)=_c)==0 && errno==EINTR); }while(0)
    612 
     592#define ENULLLOOP(_v,_c)   do { errno = 0; (_v) = _c; } \
     593                           while((_v)==0 && errno==EINTR)
  • vendor/gnumake/current/misc.c

    r501 r900  
    162162
    163163
    164 /* Return a newly-allocated string whose contents
    165    concatenate those of s1, s2, s3.  */
     164/* Return a string whose contents concatenate those of s1, s2, s3.
     165   This string lives in static, re-used memory.  */
    166166
    167167char *
     
    169169{
    170170  unsigned int len1, len2, len3;
    171   char *result;
    172 
    173   len1 = *s1 != '\0' ? strlen (s1) : 0;
    174   len2 = *s2 != '\0' ? strlen (s2) : 0;
    175   len3 = *s3 != '\0' ? strlen (s3) : 0;
    176 
    177   result = (char *) xmalloc (len1 + len2 + len3 + 1);
    178 
    179   if (*s1 != '\0')
    180     bcopy (s1, result, len1);
    181   if (*s2 != '\0')
    182     bcopy (s2, result + len1, len2);
    183   if (*s3 != '\0')
    184     bcopy (s3, result + len1 + len2, len3);
    185   *(result + len1 + len2 + len3) = '\0';
     171  static unsigned int rlen = 0;
     172  static char *result = NULL;
     173
     174  len1 = (s1 && *s1 != '\0') ? strlen (s1) : 0;
     175  len2 = (s2 && *s2 != '\0') ? strlen (s2) : 0;
     176  len3 = (s3 && *s3 != '\0') ? strlen (s3) : 0;
     177
     178  if (len1 + len2 + len3 + 1 > rlen)
     179    result = xrealloc (result, (rlen = len1 + len2 + len3 + 10));
     180
     181  if (len1)
     182    memcpy (result, s1, len1);
     183  if (len2)
     184    memcpy (result + len1, s2, len2);
     185  if (len3)
     186    memcpy (result + len1 + len2, s3, len3);
     187
     188  result[len1+len2+len3] = '\0';
    186189
    187190  return result;
     
    341344#undef xstrdup
    342345
    343 char *
     346void *
    344347xmalloc (unsigned int size)
    345348{
    346349  /* Make sure we don't allocate 0, for pre-ANSI libraries.  */
    347   char *result = (char *) malloc (size ? size : 1);
     350  void *result = malloc (size ? size : 1);
    348351  if (result == 0)
    349352    fatal (NILF, _("virtual memory exhausted"));
     
    352355
    353356
    354 char *
    355 xrealloc (char *ptr, unsigned int size)
    356 {
    357   char *result;
     357void *
     358xrealloc (void *ptr, unsigned int size)
     359{
     360  void *result;
    358361
    359362  /* Some older implementations of realloc() don't conform to ANSI.  */
     
    375378  result = strdup (ptr);
    376379#else
    377   result = (char *) malloc (strlen (ptr) + 1);
     380  result = malloc (strlen (ptr) + 1);
    378381#endif
    379382
     
    384387  return result;
    385388#else
    386   return strcpy(result, ptr);
     389  return strcpy (result, ptr);
    387390#endif
    388391}
     
    393396savestring (const char *str, unsigned int length)
    394397{
    395   register char *out = (char *) xmalloc (length + 1);
     398  char *out = xmalloc (length + 1);
    396399  if (length > 0)
    397     bcopy (str, out, length);
     400    memcpy (out, str, length);
    398401  out[length] = '\0';
    399402  return out;
     
    434437 */
    435438char *
    436 end_of_token_w32 (char *s, char stopchar)
    437 {
    438   register char *p = s;
    439   register int backslash = 0;
     439end_of_token_w32 (const char *s, char stopchar)
     440{
     441  const char *p = s;
     442  int backslash = 0;
    440443
    441444  while (*p != '\0' && *p != stopchar
     
    455458    }
    456459
    457   return p;
     460  return (char *)p;
    458461}
    459462#endif
     
    469472}
    470473
    471 /* Find the next token in PTR; return the address of it, and store the
    472    length of the token into *LENGTHPTR if LENGTHPTR is not nil.  */
     474/* Find the next token in PTR; return the address of it, and store the length
     475   of the token into *LENGTHPTR if LENGTHPTR is not nil.  Set *PTR to the end
     476   of the token, so this function can be called repeatedly in a loop.  */
    473477
    474478char *
    475 find_next_token (char **ptr, unsigned int *lengthptr)
    476 {
    477   char *p = next_token (*ptr);
    478   char *end;
     479find_next_token (const char **ptr, unsigned int *lengthptr)
     480{
     481  const char *p = next_token (*ptr);
    479482
    480483  if (*p == '\0')
    481484    return 0;
    482485
    483   *ptr = end = end_of_token (p);
     486  *ptr = end_of_token (p);
    484487  if (lengthptr != 0)
    485     *lengthptr = end - p;
    486   return p;
     488    *lengthptr = *ptr - p;
     489
     490  return (char *)p;
    487491}
    488492
     
    494498alloc_dep ()
    495499{
    496   struct dep *d = (struct dep *) xmalloc (sizeof (struct dep));
    497   bzero ((char *) d, sizeof (struct dep));
     500  struct dep *d = xmalloc (sizeof (struct dep));
     501  memset (d, '\0', sizeof (struct dep));
    498502  return d;
    499503}
     
    505509free_dep (struct dep *d)
    506510{
    507   if (d->name != 0)
    508     free (d->name);
    509 
    510   if (d->stem != 0)
    511     free (d->stem);
    512 
    513   free ((char *)d);
     511  free (d);
    514512}
    515513
     
    520518copy_dep_chain (const struct dep *d)
    521519{
    522   register struct dep *c;
    523520  struct dep *firstnew = 0;
    524521  struct dep *lastnew = 0;
     
    526523  while (d != 0)
    527524    {
    528       c = (struct dep *) xmalloc (sizeof (struct dep));
    529       bcopy ((char *) d, (char *) c, sizeof (struct dep));
    530 
    531       if (c->name != 0)
    532         c->name = xstrdup (c->name);
    533       if (c->stem != 0)
    534         c->stem = xstrdup (c->stem);
     525      struct dep *c = xmalloc (sizeof (struct dep));
     526      memcpy (c, d, sizeof (struct dep));
    535527
    536528      c->next = 0;
     
    559551}
    560552
    561 
    562 /* Free a chain of `struct nameseq'. Each nameseq->name is freed
    563    as well.  For `struct dep' chains use free_dep_chain.  */
    564 
    565 void
    566 free_ns_chain (struct nameseq *n)
    567 {
    568   register struct nameseq *tmp;
    569 
    570   while (n != 0)
    571   {
    572     if (n->name != 0)
    573       free (n->name);
    574 
    575     tmp = n;
    576 
    577     n = n->next;
    578 
    579     free (tmp);
    580   }
    581 
    582 }
    583 
    584 #ifdef  iAPX286
    585 /* The losing compiler on this machine can't handle this macro.  */
    586 
    587 char *
    588 dep_name (struct dep *dep)
    589 {
    590   return dep->name == 0 ? dep->file->name : dep->name;
     553/* Free a chain of struct nameseq.
     554   For struct dep chains use free_dep_chain.  */
     555
     556void
     557free_ns_chain (struct nameseq *ns)
     558{
     559  while (ns != 0)
     560    {
     561      struct nameseq *t = ns;
     562      ns = ns->next;
     563      free (t);
     564    }
     565}
     566
     567
     568
     569#if !HAVE_STRCASECMP && !HAVE_STRICMP && !HAVE_STRCMPI
     570
     571/* If we don't have strcasecmp() (from POSIX), or anything that can substitute
     572   for it, define our own version.  */
     573
     574int
     575strcasecmp (const char *s1, const char *s2)
     576{
     577  while (1)
     578    {
     579      int c1 = (int) *(s1++);
     580      int c2 = (int) *(s2++);
     581
     582      if (isalpha (c1))
     583        c1 = tolower (c1);
     584      if (isalpha (c2))
     585        c2 = tolower (c2);
     586
     587      if (c1 != '\0' && c1 == c2)
     588        continue;
     589
     590      return (c1 - c2);
     591    }
    591592}
    592593#endif
  • vendor/gnumake/current/read.c

    r501 r900  
    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')
     
    251248            {
    252249              struct dep *d = alloc_dep ();
    253               d->file = enter_file (*p);
     250              d->file = enter_file (strcache_add (*p));
    254251              d->file->dontcare = 1;
    255252              /* Tell update_goal_chain to bail out as soon as this file is
     
    278275  struct conditionals *save = conditionals;
    279276
    280   bzero ((char *) new, sizeof (*new));
     277  memset (new, '\0', sizeof (*new));
    281278  conditionals = new;
    282279
     
    301298
    302299static int
    303 eval_makefile (char *filename, int flags)
     300eval_makefile (const char *filename, int flags)
    304301{
    305302  struct dep *deps;
     
    307304  const struct floc *curfile;
    308305  char *expanded = 0;
    309   char *included = 0;
    310306  int makefile_errno;
    311307  int r;
    312308
    313   ebuf.floc.filenm = strcache_add (filename);
     309  filename = strcache_add (filename);
     310  ebuf.floc.filenm = filename;
    314311  ebuf.floc.lineno = 1;
    315312
     
    348345  if (ebuf.fp == 0 && (flags & RM_INCLUDED) && *filename != '/')
    349346    {
    350       register unsigned int i;
     347      unsigned int i;
    351348      for (i = 0; include_directories[i] != 0; ++i)
    352349        {
    353           included = concat (include_directories[i], "/", filename);
     350          const char *included = concat (include_directories[i], "/", filename);
    354351          ebuf.fp = fopen (included, "r");
    355352          if (ebuf.fp)
    356353            {
    357               filename = included;
     354              filename = strcache_add (included);
    358355              break;
    359356            }
    360           free (included);
    361         }
    362       /* If we're not using it, we already freed it above.  */
    363       if (filename != included)
    364         included = 0;
     357        }
    365358    }
    366359
     
    371364  deps->file = lookup_file (filename);
    372365  if (deps->file == 0)
    373     deps->file = enter_file (xstrdup (filename));
     366    deps->file = enter_file (filename);
    374367  filename = deps->file->name;
    375368  deps->changed = flags;
     
    379372  if (expanded)
    380373    free (expanded);
    381   if (included)
    382     free (included);
    383374
    384375  /* If the makefile can't be found at all, give up entirely.  */
     
    470461  long nlines = 0;
    471462  int two_colon = 0;
    472   char *pattern = 0, *pattern_percent;
     463  const char *pattern = 0;
     464  const char *pattern_percent;
    473465  struct floc *fstart;
    474466  struct floc fi;
     
    487479      commands_idx = 0;                                                       \
    488480      no_targets = 0;                                                         \
    489       if (pattern) { free(pattern); pattern = 0; }                            \
     481      pattern = 0;                                                            \
    490482    } while (0)
    491483
     
    512504      unsigned int linelen;
    513505      char *line;
    514       int len;
     506      unsigned int wlen;
    515507      char *p;
    516508      char *p2;
     
    533525      /* Check for a shell command line first.
    534526         If it is not one, we can stop treating tab specially.  */
    535       if (line[0] == '\t')
     527      if (line[0] == cmd_prefix)
    536528        {
    537529          if (no_targets)
     
    558550                  commands = xrealloc (commands, commands_len);
    559551                }
    560               bcopy (line, &commands[commands_idx], linelen);
     552              memcpy (&commands[commands_idx], line, linelen);
    561553              commands_idx += linelen;
    562554              commands[commands_idx++] = '\n';
     
    574566          collapsed_length = linelen+1;
    575567          if (collapsed)
    576             free ((char *)collapsed);
    577           collapsed = (char *) xmalloc (collapsed_length);
     568            free (collapsed);
     569          collapsed = xmalloc (collapsed_length);
    578570        }
    579571      strcpy (collapsed, line);
     
    583575
    584576      /* Compare a word, both length and contents. */
    585 #define word1eq(s)      (len == sizeof(s)-1 && strneq (s, p, sizeof(s)-1))
     577#define word1eq(s)      (wlen == sizeof(s)-1 && strneq (s, p, sizeof(s)-1))
    586578      p = collapsed;
    587579      while (isspace ((unsigned char)*p))
     
    598590      for (p2 = p+1; *p2 != '\0' && !isspace ((unsigned char)*p2); ++p2)
    599591        ;
    600       len = p2 - p;
     592      wlen = p2 - p;
    601593
    602594      /* Find the start of the second token.  If it looks like a target or
     
    621613      if (!in_ignored_define)
    622614        {
    623           int i = conditional_line (p, len, fstart);
     615          int i = conditional_line (p, wlen, fstart);
    624616          if (i != -2)
    625617            {
     
    713705              else
    714706                {
    715                   unsigned int len;
     707                  unsigned int l;
     708                  const char *cp;
    716709                  char *ap;
    717710
    718711                  /* Expand the line so we can use indirect and constructed
    719712                     variable names in an export command.  */
    720                   p2 = ap = allocated_variable_expand (p2);
    721 
    722                   for (p = find_next_token (&p2, &len); p != 0;
    723                        p = find_next_token (&p2, &len))
     713                  cp = ap = allocated_variable_expand (p2);
     714
     715                  for (p = find_next_token (&cp, &l); p != 0;
     716                       p = find_next_token (&cp, &l))
    724717                    {
    725                       v = lookup_variable (p, len);
     718                      v = lookup_variable (p, l);
    726719                      if (v == 0)
    727                         v = define_variable_loc (p, len, "", o_file, 0,
    728                                                  fstart);
     720                        v = define_variable_loc (p, l, "", o_file, 0, fstart);
    729721                      v->export = v_export;
    730722                    }
     
    742734          else
    743735            {
    744               unsigned int len;
     736              unsigned int l;
    745737              struct variable *v;
     738              const char *cp;
    746739              char *ap;
    747740
    748741              /* Expand the line so we can use indirect and constructed
    749742                 variable names in an unexport command.  */
    750               p2 = ap = allocated_variable_expand (p2);
    751 
    752               for (p = find_next_token (&p2, &len); p != 0;
    753                    p = find_next_token (&p2, &len))
     743              cp = ap = allocated_variable_expand (p2);
     744
     745              for (p = find_next_token (&cp, &l); p != 0;
     746                   p = find_next_token (&cp, &l))
    754747                {
    755                   v = lookup_variable (p, len);
     748                  v = lookup_variable (p, l);
    756749                  if (v == 0)
    757                     v = define_variable_loc (p, len, "", o_file, 0, fstart);
     750                    v = define_variable_loc (p, l, "", o_file, 0, fstart);
    758751
    759752                  v->export = v_noexport;
     
    768761      if (word1eq ("vpath"))
    769762        {
    770           char *pattern;
    771           unsigned int len;
    772           p2 = variable_expand (p2);
    773           p = find_next_token (&p2, &len);
     763          const char *cp;
     764          char *vpat;
     765          unsigned int l;
     766          cp = variable_expand (p2);
     767          p = find_next_token (&cp, &l);
    774768          if (p != 0)
    775769            {
    776               pattern = savestring (p, len);
    777               p = find_next_token (&p2, &len);
     770              vpat = savestring (p, l);
     771              p = find_next_token (&cp, &l);
    778772              /* No searchpath means remove all previous
    779773                 selective VPATH's with the same pattern.  */
     
    781775          else
    782776            /* No pattern means remove all previous selective VPATH's.  */
    783             pattern = 0;
    784           construct_vpath_list (pattern, p);
    785           if (pattern != 0)
    786             free (pattern);
     777            vpat = 0;
     778          construct_vpath_list (vpat, p);
     779          if (vpat != 0)
     780            free (vpat);
    787781
    788782          goto rule_complete;
     
    829823            {
    830824              struct nameseq *next = files->next;
    831               char *name = files->name;
     825              const char *name = files->name;
    832826              int r;
    833827
    834               free ((char *)files);
     828              free (files);
    835829              files = next;
    836830
     
    839833              if (!r && !noerror)
    840834                error (fstart, "%s: %s", name, strerror (errno));
    841               free (name);
    842835            }
    843836
     
    855848         was no preceding target, and the line might have been usable as a
    856849         variable definition.  But now we know it is definitely lossage.  */
    857       if (line[0] == '\t')
     850      if (line[0] == cmd_prefix)
    858851        fatal(fstart, _("commands commence before first target"));
    859852
     
    873866        int exported;
    874867        char *cmdleft, *semip, *lb_next;
    875         unsigned int len, plen = 0;
     868        unsigned int plen = 0;
    876869        char *colonp;
    877870        const char *end, *beg; /* Helpers for whitespace stripping. */
     
    902895           beginning, expanding as we go, and looking for "interesting"
    903896           chars.  The first word is always expandable.  */
    904         wtype = get_next_mword(line, NULL, &lb_next, &len);
     897        wtype = get_next_mword(line, NULL, &lb_next, &wlen);
    905898        switch (wtype)
    906899          {
     
    923916          }
    924917
    925         p2 = variable_expand_string(NULL, lb_next, len);
     918        p2 = variable_expand_string(NULL, lb_next, wlen);
    926919
    927920        while (1)
    928921          {
    929             lb_next += len;
     922            lb_next += wlen;
    930923            if (cmdleft == 0)
    931924              {
     
    972965              break;
    973966
    974             wtype = get_next_mword(lb_next, NULL, &lb_next, &len);
     967            wtype = get_next_mword(lb_next, NULL, &lb_next, &wlen);
    975968            if (wtype == w_eol)
    976969              break;
     
    978971            p2 += strlen(p2);
    979972            *(p2++) = ' ';
    980             p2 = variable_expand_string(p2, lb_next, len);
     973            p2 = variable_expand_string(p2, lb_next, wlen);
    981974            /* We don't need to worry about cmdleft here, because if it was
    982975               found in the variable_buffer the entire buffer has already
     
    10331026            unsigned int l = p2 - variable_buffer;
    10341027            plen = strlen (p2);
    1035             (void) variable_buffer_output (p2+plen,
    1036                                            lb_next, strlen (lb_next)+1);
     1028            variable_buffer_output (p2+plen, lb_next, strlen (lb_next)+1);
    10371029            p2 = variable_buffer + l;
    10381030          }
     
    10411033           comes after it looks like a variable definition.  */
    10421034
    1043         wtype = get_next_mword (p2, NULL, &p, &len);
     1035        wtype = get_next_mword (p2, NULL, &p, &wlen);
    10441036
    10451037        v_origin = o_file;
     
    10501042              {
    10511043                v_origin = o_override;
    1052                 wtype = get_next_mword (p+len, NULL, &p, &len);
     1044                wtype = get_next_mword (p+wlen, NULL, &p, &wlen);
    10531045              }
    10541046            else if (word1eq ("export"))
    10551047              {
    10561048                exported = 1;
    1057                 wtype = get_next_mword (p+len, NULL, &p, &len);
     1049                wtype = get_next_mword (p+wlen, NULL, &p, &wlen);
    10581050              }
    10591051          }
    10601052
    10611053        if (wtype != w_eol)
    1062           wtype = get_next_mword (p+len, NULL, NULL, NULL);
     1054          wtype = get_next_mword (p+wlen, NULL, NULL, NULL);
    10631055
    10641056        if (wtype == w_varassign)
     
    11351127        {
    11361128          int check_again;
    1137 
    11381129          do {
    11391130            check_again = 0;
     
    11571148            else if (target->next != 0)
    11581149              fatal (fstart, _("multiple target patterns"));
     1150            pattern_percent = find_percent_cached (&target->name);
    11591151            pattern = target->name;
    1160             pattern_percent = find_percent (pattern);
    11611152            if (pattern_percent == 0)
    11621153              fatal (fstart, _("target pattern contains no `%%'"));
    1163             free ((char *)target);
     1154            free (target);
    11641155          }
    11651156        else
     
    11751166            /* Put all the prerequisites here; they'll be parsed later.  */
    11761167            deps = alloc_dep ();
    1177             deps->name = savestring (beg, end - beg + 1);
     1168            deps->name = strcache_add_len (beg, end - beg + 1);
    11781169          }
    11791170        else
     
    11841175          {
    11851176            /* Semicolon means rest of line is a command.  */
    1186             unsigned int len = strlen (cmdleft);
     1177            unsigned int l = strlen (cmdleft);
    11871178
    11881179            cmds_started = fstart->lineno;
    11891180
    11901181            /* Add this command line to the buffer.  */
    1191             if (len + 2 > commands_len)
     1182            if (l + 2 > commands_len)
    11921183              {
    1193                 commands_len = (len + 2) * 2;
    1194                 commands = (char *) xrealloc (commands, commands_len);
     1184                commands_len = (l + 2) * 2;
     1185                commands = xrealloc (commands, commands_len);
    11951186              }
    1196             bcopy (cmdleft, commands, len);
    1197             commands_idx += len;
     1187            memcpy (commands, cmdleft, l);
     1188            commands_idx += l;
    11981189            commands[commands_idx++] = '\n';
    11991190          }
     
    12171208        if (**default_goal_name == '\0' && set_default)
    12181209          {
    1219             char* name;
     1210            const char *name;
    12201211            struct dep *d;
    12211212            struct nameseq *t = filenames;
     
    12521243                    for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)
    12531244                      {
    1254                         register unsigned int len = strlen (dep_name (d2));
    1255                         if (!strneq (name, dep_name (d2), len))
     1245                        unsigned int l = strlen (dep_name (d2));
     1246                        if (!strneq (name, dep_name (d2), l))
    12561247                          continue;
    1257                         if (streq (name + len, dep_name (d)))
     1248                        if (streq (name + l, dep_name (d)))
    12581249                          {
    12591250                            reject = 1;
     
    12941285
    12951286  if (collapsed)
    1296     free ((char *) collapsed);
    1297   free ((char *) commands);
     1287    free (collapsed);
     1288  free (commands);
    12981289
    12991290  return 1;
     
    13291320  int nlevels = 1;
    13301321  unsigned int length = 100;
    1331   char *definition = (char *) xmalloc (length);
     1322  char *definition = xmalloc (length);
    13321323  unsigned int idx = 0;
    13331324  char *p;
    13341325
    13351326  /* Expand the variable name.  */
    1336   char *var = (char *) alloca (namelen + 1);
    1337   bcopy (name, var, namelen);
     1327  char *var = alloca (namelen + 1);
     1328  memcpy (var, name, namelen);
    13381329  var[namelen] = '\0';
    13391330  var = variable_expand (var);
     
    13611352
    13621353      /* Stop if we find an 'endef' */
    1363       if (line[0] != '\t')
     1354      if (line[0] != cmd_prefix)
    13641355        {
    13651356          p = next_token (line);
     
    14041395        {
    14051396          length = (idx + len) * 2;
    1406           definition = (char *) xrealloc (definition, length + 1);
     1397          definition = xrealloc (definition, length + 1);
    14071398        }
    14081399
    1409       bcopy (line, &definition[idx], len);
     1400      memcpy (&definition[idx], line, len);
    14101401      idx += len;
    14111402      /* Separate lines with a newline.  */
     
    15351526    {
    15361527      conditionals->allocated = 5;
    1537       conditionals->ignoring = (char *) xmalloc (conditionals->allocated);
    1538       conditionals->seen_else = (char *) xmalloc (conditionals->allocated);
     1528      conditionals->ignoring = xmalloc (conditionals->allocated);
     1529      conditionals->seen_else = xmalloc (conditionals->allocated);
    15391530    }
    15401531
     
    15431534    {
    15441535      conditionals->allocated += 5;
    1545       conditionals->ignoring = (char *)
    1546         xrealloc (conditionals->ignoring, conditionals->allocated);
    1547       conditionals->seen_else = (char *)
    1548         xrealloc (conditionals->seen_else, conditionals->allocated);
     1536      conditionals->ignoring = xrealloc (conditionals->ignoring,
     1537                                        conditionals->allocated);
     1538      conditionals->seen_else = xrealloc (conditionals->seen_else,
     1539                                          conditionals->allocated);
    15491540    }
    15501541
     
    15901581  else
    15911582    {
    1592       /* "Ifeq" or "ifneq".  */
     1583      /* "ifeq" or "ifneq".  */
    15931584      char *s1, *s2;
    1594       unsigned int len;
     1585      unsigned int l;
    15951586      char termin = *line == '(' ? ',' : *line;
    15961587
     
    16321623      /* We must allocate a new copy of the expanded string because
    16331624         variable_expand re-uses the same buffer.  */
    1634       len = strlen (s2);
    1635       s1 = (char *) alloca (len + 1);
    1636       bcopy (s2, s1, len + 1);
     1625      l = strlen (s2);
     1626      s1 = alloca (l + 1);
     1627      memcpy (s1, s2, l + 1);
    16371628
    16381629      if (termin != ',')
     
    16471638      if (termin == ')')
    16481639        {
    1649           register int count = 0;
     1640          int count = 0;
    16501641          s2 = next_token (line);
    16511642          for (line = s2; *line != '\0'; ++line)
     
    17821773    {
    17831774      struct variable *v;
    1784       register char *name = filenames->name;
    1785       char *fname;
    1786       char *percent;
     1775      const char *name = filenames->name;
     1776      const char *fname;
     1777      const char *percent;
    17871778      struct pattern_var *p;
    17881779
    17891780      nextf = filenames->next;
    1790       free ((char *) filenames);
     1781      free (filenames);
    17911782
    17921783      /* If it's a pattern target, then add it to the pattern-specific
    17931784         variable list.  */
    1794       percent = find_percent (name);
     1785      percent = find_percent_cached (&name);
    17951786      if (percent)
    17961787        {
     
    18201811          f = lookup_file (name);
    18211812          if (!f)
    1822             f = enter_file (name);
     1813            f = enter_file (strcache_add (name));
    18231814          else if (f->double_colon)
    18241815            f = f->double_colon;
     
    18571848            }
    18581849        }
    1859 
    1860       /* Free name if not needed further.  */
    1861       if (name != fname && (name < fname || name > fname + strlen (fname)))
    1862         free (name);
    18631850    }
    18641851}
     
    18771864
    18781865static void
    1879 record_files (struct nameseq *filenames, char *pattern, char *pattern_percent,
    1880               struct dep *deps, unsigned int cmds_started, char *commands,
     1866record_files (struct nameseq *filenames, const char *pattern,
     1867              const char *pattern_percent, struct dep *deps,
     1868              unsigned int cmds_started, char *commands,
    18811869              unsigned int commands_idx, int two_colon,
    18821870              const struct floc *flocp)
     
    18851873  int implicit = 0;
    18861874  unsigned int max_targets = 0, target_idx = 0;
    1887   char **targets = 0, **target_percents = 0;
     1875  const char **targets = 0, **target_percents = 0;
    18881876  struct commands *cmds;
    18891877
     
    18971885  if (commands_idx > 0)
    18981886    {
    1899       cmds = (struct commands *) xmalloc (sizeof (struct commands));
     1887      cmds = xmalloc (sizeof (struct commands));
    19001888      cmds->fileinfo.filenm = flocp->filenm;
    19011889      cmds->fileinfo.lineno = cmds_started;
     
    19081896  for (; filenames != 0; filenames = nextf)
    19091897    {
    1910       char *name = filenames->name;
     1898      const char *name = filenames->name;
    19111899      struct file *f;
    19121900      struct dep *this = 0;
    1913       char *implicit_percent;
     1901      const char *implicit_percent;
    19141902
    19151903      nextf = filenames->next;
     
    19241912        second_expansion = 1;
    19251913
    1926       implicit_percent = find_percent (name);
     1914      implicit_percent = find_percent_cached (&name);
    19271915      implicit |= implicit_percent != 0;
    19281916
    1929       if (implicit && pattern != 0)
    1930         fatal (flocp, _("mixed implicit and static pattern rules"));
    1931 
    1932       if (implicit && implicit_percent == 0)
    1933         fatal (flocp, _("mixed implicit and normal rules"));
    1934 
    19351917      if (implicit)
    1936         {
     1918        {
     1919          if (pattern != 0)
     1920            fatal (flocp, _("mixed implicit and static pattern rules"));
     1921
     1922          if (implicit_percent == 0)
     1923            fatal (flocp, _("mixed implicit and normal rules"));
     1924
    19371925          if (targets == 0)
    19381926            {
    19391927              max_targets = 5;
    1940               targets = (char **) xmalloc (5 * sizeof (char *));
    1941               target_percents = (char **) xmalloc (5 * sizeof (char *));
     1928              targets = xmalloc (5 * sizeof (char *));
     1929              target_percents = xmalloc (5 * sizeof (char *));
    19421930              target_idx = 0;
    19431931            }
     
    19451933            {
    19461934              max_targets += 5;
    1947               targets = (char **) xrealloc ((char *) targets,
    1948                                             max_targets * sizeof (char *));
    1949               target_percents
    1950                 = (char **) xrealloc ((char *) target_percents,
    1951                                       max_targets * sizeof (char *));
     1935              targets = xrealloc (targets, max_targets * sizeof (char *));
     1936              target_percents = xrealloc (target_percents,
     1937                                          max_targets * sizeof (char *));
    19521938            }
    19531939          targets[target_idx] = name;
     
    19761962          /* Single-colon.  Combine these dependencies
    19771963             with others in file's existing record, if any.  */
    1978           f = enter_file (name);
     1964          f = enter_file (strcache_add (name));
    19791965
    19801966          if (f->double_colon)
     
    20822068            fatal (flocp,
    20832069                   _("target file `%s' has both : and :: entries"), f->name);
    2084           f = enter_file (name);
     2070          f = enter_file (strcache_add (name));
    20852071          /* If there was an existing entry and it was a double-colon entry,
    20862072             enter_file will have returned a new one, making it the prev
     
    21012087      if (pattern)
    21022088        {
    2103           static char *percent = "%";
     2089          static const char *percent = "%";
    21042090          char *buffer = variable_expand ("");
    2105           char *o = patsubst_expand (buffer, name, pattern, percent,
    2106                                      pattern_percent+1, percent+1);
    2107           f->stem = savestring (buffer, o - buffer);
     2091          char *o = patsubst_expand_pat (buffer, name, pattern, percent,
     2092                                         pattern_percent+1, percent+1);
     2093          f->stem = strcache_add_len (buffer, o - buffer);
    21082094          if (this)
    21092095            {
    21102096              this->staticpattern = 1;
    2111               this->stem = xstrdup (f->stem);
     2097              this->stem = f->stem;
    21122098            }
    21132099        }
    21142100
    2115       /* Free name if not needed further.  */
    2116       if (f != 0 && name != f->name
    2117           && (name < f->name || name > f->name + strlen (f->name)))
    2118         {
    2119           free (name);
    2120           name = f->name;
    2121         }
     2101      name = f->name;
    21222102
    21232103      /* If this target is a default target, update DEFAULT_GOAL_FILE.  */
     
    21302110  if (implicit)
    21312111    {
    2132       targets[target_idx] = 0;
    2133       target_percents[target_idx] = 0;
    21342112      if (deps)
    21352113        deps->need_2nd_expansion = second_expansion;
    2136       create_pattern_rule (targets, target_percents, two_colon, deps, cmds, 1);
    2137       free ((char *) target_percents);
     2114      create_pattern_rule (targets, target_percents, target_idx,
     2115                           two_colon, deps, cmds, 1);
    21382116    }
    21392117}
     
    21542132{
    21552133  unsigned int string_len = 0;
    2156   register char *p = string;
     2134  char *p = string;
    21572135
    21582136  if (ignorevars)
     
    22132191        {
    22142192          /* Search for more backslashes.  */
    2215           register int i = -2;
     2193          int i = -2;
    22162194          while (&p[i] >= string && p[i] == '\\')
    22172195            --i;
     
    22222200          /* The number of backslashes is now -I.
    22232201             Copy P over itself to swallow half of them.  */
    2224           bcopy (&p[i / 2], &p[i], (string_len - (p - string)) - (i / 2) + 1);
    2225           p += i / 2;
     2202          memmove (&p[i], &p[i/2], (string_len - (p - string)) - (i/2) + 1);
     2203          p += i/2;
    22262204          if (i % 2 == 0)
    22272205            /* All the backslashes quoted each other; the STOPCHAR was
     
    22402218}
    22412219
    2242 /* Search PATTERN for an unquoted %.  */
     2220/* Search PATTERN for an unquoted % and handle quoting.  */
    22432221
    22442222char *
     
    22462224{
    22472225  return find_char_unquote (pattern, '%', 0, 0, 0);
     2226}
     2227
     2228/* Search STRING for an unquoted % and handle quoting.  Returns a pointer to
     2229   the % or NULL if no % was found.
     2230   This version is used with strings in the string cache: if there's a need to
     2231   modify the string a new version will be added to the string cache and
     2232   *STRING will be set to that.  */
     2233
     2234const char *
     2235find_percent_cached (const char **string)
     2236{
     2237  const char *p = *string;
     2238  char *new = 0;
     2239  int slen;
     2240
     2241  /* If the first char is a % return now.  This lets us avoid extra tests
     2242     inside the loop.  */
     2243  if (*p == '%')
     2244    return p;
     2245
     2246  while (1)
     2247    {
     2248      while (*p != '\0' && *p != '%')
     2249        ++p;
     2250
     2251      if (*p == '\0')
     2252        break;
     2253
     2254      /* See if this % is escaped with a backslash; if not we're done.  */
     2255      if (p[-1] != '\\')
     2256        break;
     2257
     2258      {
     2259        /* Search for more backslashes.  */
     2260        char *pv;
     2261        int i = -2;
     2262
     2263        while (&p[i] >= *string && p[i] == '\\')
     2264          --i;
     2265        ++i;
     2266
     2267        /* At this point we know we'll need to allocate a new string.
     2268           Make a copy if we haven't yet done so.  */
     2269        if (! new)
     2270          {
     2271            slen = strlen (*string);
     2272            new = alloca (slen + 1);
     2273            memcpy (new, *string, slen + 1);
     2274            p = new + (p - *string);
     2275            *string = new;
     2276          }
     2277
     2278        /* At this point *string, p, and new all point into the same string.
     2279           Get a non-const version of p so we can modify new.  */
     2280        pv = new + (p - *string);
     2281
     2282        /* The number of backslashes is now -I.
     2283           Copy P over itself to swallow half of them.  */
     2284        memmove (&pv[i], &pv[i/2], (slen - (pv - new)) - (i/2) + 1);
     2285        p += i/2;
     2286
     2287        /* If the backslashes quoted each other; the % was unquoted.  */
     2288        if (i % 2 == 0)
     2289          break;
     2290      }
     2291    }
     2292
     2293  /* If we had to change STRING, add it to the strcache.  */
     2294  if (new)
     2295    {
     2296      *string = strcache_add (*string);
     2297      p = *string + (p - new);
     2298    }
     2299
     2300  /* If we didn't find a %, return NULL.  Otherwise return a ptr to it.  */
     2301  return (*p == '\0') ? NULL : p;
    22482302}
    22492303
     
    22682322  struct nameseq *new1, *lastnew1;
    22692323  char *p = *stringp;
    2270   char *q;
    2271   char *name;
    22722324
    22732325#ifdef VMS
     
    22792331  while (1)
    22802332    {
     2333      const char *name;
     2334      char *q;
     2335
    22812336      /* Skip whitespace; see if any more names are left.  */
    22822337      p = next_token (p);
     
    22862341        break;
    22872342
    2288       /* Yes, find end of next name.  */
     2343      /* There are, so find the end of the next name.  */
    22892344      q = p;
    22902345      p = find_char_unquote (q, stopchar, VMS_COMMA, 1, 0);
     
    22982353          && !(isspace ((unsigned char)p[1]) || !p[1]
    22992354               || isspace ((unsigned char)p[-1])))
    2300       {
    23012355        p = find_char_unquote (p+1, stopchar, VMS_COMMA, 1, 0);
    2302       }
    23032356#endif
    23042357#ifdef HAVE_DOS_PATHS
     
    23342387      if (q == p)
    23352388        /* ".///" was stripped to "". */
    2336 #ifdef VMS
     2389#if defined(VMS)
    23372390        continue;
     2391#elif defined(_AMIGA)
     2392        name = "";
    23382393#else
    2339 #ifdef _AMIGA
    2340         name = savestring ("", 0);
    2341 #else
    2342         name = savestring ("./", 2);
    2343 #endif
     2394        name = "./";
    23442395#endif
    23452396      else
     
    23652416              *q2++ = *q1++;
    23662417            }
    2367           name = savestring (qbase, p1 - qbase);
     2418          name = strcache_add_len (qbase, p1 - qbase);
    23682419          free (qbase);
    23692420        }
    23702421#else
    2371         name = savestring (q, p - q);
     2422        name = strcache_add_len (q, p - q);
    23722423#endif
    23732424
    23742425      /* Add it to the front of the chain.  */
    2375       new1 = (struct nameseq *) xmalloc (size);
     2426      new1 = xmalloc (size);
    23762427      new1->name = name;
    23772428      new1->next = new;
     
    24162467            /* Copy "lib(" into LIBNAME.  */
    24172468            ++paren;
    2418             libname = (char *) alloca (paren - n->name + 1);
    2419             bcopy (n->name, libname, paren - n->name);
     2469            libname = alloca (paren - n->name + 1);
     2470            memcpy (libname, n->name, paren - n->name);
    24202471            libname[paren - n->name] = '\0';
    24212472
     
    24252476                   Edit it out of the chain and free its storage.  */
    24262477                lastn->next = n->next;
    2427                 free (n->name);
    2428                 free ((char *) n);
     2478                free (n);
    24292479                /* LASTN->next is the new stopping elt for the loop below.  */
    24302480                n = lastn->next;
     
    24332483              {
    24342484                /* Replace N's name with the full archive reference.  */
    2435                 name = concat (libname, paren, ")");
    2436                 free (n->name);
    2437                 n->name = name;
     2485                n->name = strcache_add (concat (libname, paren, ")"));
    24382486              }
    24392487
     
    24482496                lastn = new1;
    24492497                new1 = new1->next;
    2450                 free (lastn->name);
    2451                 free ((char *) lastn);
     2498                free (lastn);
    24522499              }
    24532500            else
    24542501              {
    24552502                /* Replace also NEW1->name, which already has closing `)'.  */
    2456                 name = concat (libname, new1->name, "");
    2457                 free (new1->name);
    2458                 new1->name = name;
     2503                new1->name = strcache_add (concat (libname, new1->name, ""));
    24592504                new1 = new1->next;
    24602505              }
     
    24662511            while (new1 != n)
    24672512              {
    2468                 name = concat (libname, new1->name, ")");
    2469                 free (new1->name);
    2470                 new1->name = name;
     2513                new1->name = strcache_add (concat (libname, new1->name, ")"));
    24712514                lastnew1 = new1;
    24722515                new1 = new1->next;
     
    26362679        unsigned long off = p - start;
    26372680        ebuf->size *= 2;
    2638         start = ebuf->buffer = ebuf->bufstart = (char *) xrealloc (start,
    2639                                                                    ebuf->size);
     2681        start = ebuf->buffer = ebuf->bufstart = xrealloc (start, ebuf->size);
    26402682        p = start + off;
    26412683        end = start + ebuf->size;
     
    28402882
    28412883void
    2842 construct_include_path (char **arg_dirs)
     2884construct_include_path (const char **arg_dirs)
    28432885{
    2844   register unsigned int i;
    28452886#ifdef VAXC             /* just don't ask ... */
    28462887  stat_t stbuf;
     
    28482889  struct stat stbuf;
    28492890#endif
    2850   /* Table to hold the dirs.  */
    2851 
    2852   register unsigned int defsize = (sizeof (default_include_directories)
    2853                                    / sizeof (default_include_directories[0]));
    2854   register unsigned int max = 5;
    2855   register char **dirs = (char **) xmalloc ((5 + defsize) * sizeof (char *));
    2856   register unsigned int idx = 0;
     2891  const char **dirs;
     2892  const char **cpp;
     2893  unsigned int idx;
     2894
     2895  /* Compute the number of pointers we need in the table.  */
     2896  idx = sizeof (default_include_directories) / sizeof (const char *);
     2897  if (arg_dirs)
     2898    for (cpp = arg_dirs; *cpp != 0; ++cpp)
     2899      ++idx;
    28572900
    28582901#ifdef  __MSDOS__
    2859   defsize++;
     2902  /* Add one for $DJDIR.  */
     2903  ++idx;
    28602904#endif
    28612905
     2906  dirs = xmalloc (idx * sizeof (const char *));
     2907
     2908  idx = 0;
     2909  max_incl_len = 0;
     2910
    28622911  /* First consider any dirs specified with -I switches.
    2863      Ignore dirs that don't exist.  */
    2864 
    2865   if (arg_dirs != 0)
     2912     Ignore any that don't exist.  Remember the maximum string length.  */
     2913
     2914  if (arg_dirs)
    28662915    while (*arg_dirs != 0)
    28672916      {
    2868         char *dir = *arg_dirs++;
     2917        const char *dir = *(arg_dirs++);
     2918        char *expanded = 0;
    28692919        int e;
    28702920
    28712921        if (dir[0] == '~')
    28722922          {
    2873             char *expanded = tilde_expand (dir);
     2923            expanded = tilde_expand (dir);
    28742924            if (expanded != 0)
    28752925              dir = expanded;
     
    28782928        EINTRLOOP (e, stat (dir, &stbuf));
    28792929        if (e == 0 && S_ISDIR (stbuf.st_mode))
    2880           {
    2881             if (idx == max - 1)
    2882               {
    2883                 max += 5;
    2884                 dirs = (char **)
    2885                   xrealloc ((char *) dirs, (max + defsize) * sizeof (char *));
    2886               }
    2887             dirs[idx++] = dir;
    2888           }
    2889         else if (dir != arg_dirs[-1])
    2890           free (dir);
     2930          {
     2931            unsigned int len = strlen (dir);
     2932            /* If dir name is written with trailing slashes, discard them.  */
     2933            while (len > 1 && dir[len - 1] == '/')
     2934              --len;
     2935            if (len > max_incl_len)
     2936              max_incl_len = len;
     2937            dirs[idx++] = strcache_add_len (dir, len);
     2938          }
     2939
     2940        if (expanded)
     2941          free (expanded);
    28912942      }
    28922943
    2893   /* Now add at the end the standard default dirs.  */
     2944  /* Now add the standard default dirs at the end.  */
    28942945
    28952946#ifdef  __MSDOS__
    28962947  {
    2897     /* The environment variable $DJDIR holds the root of the
    2898        DJGPP directory tree; add ${DJDIR}/include.  */
     2948    /* The environment variable $DJDIR holds the root of the DJGPP directory
     2949       tree; add ${DJDIR}/include.  */
    28992950    struct variable *djdir = lookup_variable ("DJDIR", 5);
    29002951
    29012952    if (djdir)
    29022953      {
    2903         char *defdir = (char *) xmalloc (strlen (djdir->value) + 8 + 1);
     2954        unsigned int len = strlen (djdir->value) + 8;
     2955        char *defdir = alloca (len + 1);
    29042956
    29052957        strcat (strcpy (defdir, djdir->value), "/include");
    2906         dirs[idx++] = defdir;
     2958        dirs[idx++] = strcache_add (defdir);
     2959
     2960        if (len > max_incl_len)
     2961          max_incl_len = len;
    29072962      }
    29082963  }
    29092964#endif
    29102965
    2911   for (i = 0; default_include_directories[i] != 0; ++i)
     2966  for (cpp = default_include_directories; *cpp != 0; ++cpp)
    29122967    {
    29132968      int e;
    29142969
    2915       EINTRLOOP (e, stat (default_include_directories[i], &stbuf));
     2970      EINTRLOOP (e, stat (*cpp, &stbuf));
    29162971      if (e == 0 && S_ISDIR (stbuf.st_mode))
    2917         dirs[idx++] = default_include_directories[i];
     2972        {
     2973          unsigned int len = strlen (*cpp);
     2974          /* If dir name is written with trailing slashes, discard them.  */
     2975          while (len > 1 && (*cpp)[len - 1] == '/')
     2976            --len;
     2977          if (len > max_incl_len)
     2978            max_incl_len = len;
     2979          dirs[idx++] = strcache_add_len (*cpp, len - 1);
     2980        }
    29182981    }
    29192982
    29202983  dirs[idx] = 0;
    29212984
    2922   /* Now compute the maximum length of any name in it. Also add each
    2923      dir to the .INCLUDE_DIRS variable.  */
    2924 
    2925   max_incl_len = 0;
    2926   for (i = 0; i < idx; ++i)
    2927     {
    2928       unsigned int len = strlen (dirs[i]);
    2929       /* If dir name is written with a trailing slash, discard it.  */
    2930       if (dirs[i][len - 1] == '/')
    2931         /* We can't just clobber a null in because it may have come from
    2932            a literal string and literal strings may not be writable.  */
    2933         dirs[i] = savestring (dirs[i], len - 1);
    2934       if (len > max_incl_len)
    2935         max_incl_len = len;
    2936 
    2937       /* Append to .INCLUDE_DIRS.   */
    2938       do_variable_definition (NILF, ".INCLUDE_DIRS", dirs[i],
    2939                               o_default, f_append, 0);
    2940     }
     2985  /* Now add each dir to the .INCLUDE_DIRS variable.  */
     2986
     2987  for (cpp = dirs; *cpp != 0; ++cpp)
     2988    do_variable_definition (NILF, ".INCLUDE_DIRS", *cpp,
     2989                            o_default, f_append, 0);
    29412990
    29422991  include_directories = dirs;
     
    29482997
    29492998char *
    2950 tilde_expand (char *name)
     2999tilde_expand (const char *name)
    29513000{
    29523001#ifndef VMS
     
    29733022          home_dir = getenv ("HOME");
    29743023        }
    2975 #if !defined(_AMIGA) && !defined(WINDOWS32)
     3024# if !defined(_AMIGA) && !defined(WINDOWS32)
    29763025      if (home_dir == 0 || home_dir[0] == '\0')
    29773026        {
     
    29863035            }
    29873036        }
    2988 #endif /* !AMIGA && !WINDOWS32 */
     3037# endif /* !AMIGA && !WINDOWS32 */
    29893038      if (home_dir != 0)
    29903039        {
    2991           char *new = concat (home_dir, "", name + 1);
     3040          char *new = xstrdup (concat (home_dir, "", name + 1));
    29923041          if (is_variable)
    29933042            free (home_dir);
     
    29953044        }
    29963045    }
    2997 #if !defined(_AMIGA) && !defined(WINDOWS32)
     3046# if !defined(_AMIGA) && !defined(WINDOWS32)
    29983047  else
    29993048    {
     
    30083057            return xstrdup (pwent->pw_dir);
    30093058          else
    3010             return concat (pwent->pw_dir, "/", userend + 1);
     3059            return xstrdup (concat (pwent->pw_dir, "/", userend + 1));
    30113060        }
    30123061      else if (userend != 0)
    30133062        *userend = '/';
    30143063    }
    3015 #endif /* !AMIGA && !WINDOWS32 */
     3064# endif /* !AMIGA && !WINDOWS32 */
    30163065#endif /* !VMS */
    30173066  return 0;
     
    30313080multi_glob (struct nameseq *chain, unsigned int size)
    30323081{
    3033   extern void dir_setup_glob ();
    3034   register struct nameseq *new = 0;
    3035   register struct nameseq *old;
     3082  void dir_setup_glob (glob_t *);
     3083  struct nameseq *new = 0;
     3084  struct nameseq *old;
    30363085  struct nameseq *nexto;
    30373086  glob_t gl;
     
    30413090  for (old = chain; old != 0; old = nexto)
    30423091    {
     3092      const char *gname;
    30433093#ifndef NO_ARCHIVES
    3044       char *memname;
     3094      char *arname = 0;
     3095      char *memname = 0;
    30453096#endif
    3046 
    30473097      nexto = old->next;
    3048 
    3049       if (old->name[0] == '~')
     3098      gname = old->name;
     3099
     3100      if (gname[0] == '~')
    30503101        {
    30513102          char *newname = tilde_expand (old->name);
    30523103          if (newname != 0)
    3053             {
    3054               free (old->name);
    3055               old->name = newname;
    3056             }
     3104            gname = newname;
    30573105        }
    30583106
    30593107#ifndef NO_ARCHIVES
    3060       if (ar_name (old->name))
     3108      if (ar_name (gname))
    30613109        {
    3062           /* OLD->name is an archive member reference.
    3063              Replace it with the archive file name,
    3064              and save the member name in MEMNAME.
    3065              We will glob on the archive name and then
    3066              reattach MEMNAME later.  */
    3067           char *arname;
    3068           ar_parse_name (old->name, &arname, &memname);
    3069           free (old->name);
    3070           old->name = arname;
    3071         }
    3072       else
    3073         memname = 0;
     3110          /* OLD->name is an archive member reference.  Replace it with the
     3111             archive file name, and save the member name in MEMNAME.  We will
     3112             glob on the archive name and then reattach MEMNAME later.  */
     3113          ar_parse_name (gname, &arname, &memname);
     3114          gname = arname;
     3115        }
    30743116#endif /* !NO_ARCHIVES */
    30753117
    3076       switch (glob (old->name, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl))
     3118      switch (glob (gname, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl))
    30773119        {
    30783120        case 0:                 /* Success.  */
    30793121          {
    3080             register int i = gl.gl_pathc;
     3122            int i = gl.gl_pathc;
    30813123            while (i-- > 0)
    30823124              {
     
    30873129                    struct nameseq *found
    30883130                      = ar_glob (gl.gl_pathv[i], memname, size);
    3089                     if (found == 0)
     3131                    if (! found)
    30903132                      {
    30913133                        /* No matches.  Use MEMNAME as-is.  */
    30923134                        unsigned int alen = strlen (gl.gl_pathv[i]);
    30933135                        unsigned int mlen = strlen (memname);
    3094                         struct nameseq *elt
    3095                           = (struct nameseq *) xmalloc (size);
    3096                         if (size > sizeof (struct nameseq))
    3097                           bzero (((char *) elt) + sizeof (struct nameseq),
    3098                                  size - sizeof (struct nameseq));
    3099                         elt->name = (char *) xmalloc (alen + 1 + mlen + 2);
    3100                         bcopy (gl.gl_pathv[i], elt->name, alen);
    3101                         elt->name[alen] = '(';
    3102                         bcopy (memname, &elt->name[alen + 1], mlen);
    3103                         elt->name[alen + 1 + mlen] = ')';
    3104                         elt->name[alen + 1 + mlen + 1] = '\0';
     3136                        char *name;
     3137                        struct nameseq *elt = xmalloc (size);
     3138                        memset (elt, '\0', size);
     3139
     3140                        name = alloca (alen + 1 + mlen + 2);
     3141                        memcpy (name, gl.gl_pathv[i], alen);
     3142                        name[alen] = '(';
     3143                        memcpy (name+alen+1, memname, mlen);
     3144                        name[alen + 1 + mlen] = ')';
     3145                        name[alen + 1 + mlen + 1] = '\0';
     3146                        elt->name = strcache_add (name);
    31053147                        elt->next = new;
    31063148                        new = elt;
     
    31183160                        new = found;
    31193161                      }
    3120 
    3121                     free (memname);
    31223162                  }
    31233163                else
    31243164#endif /* !NO_ARCHIVES */
    31253165                  {
    3126                     struct nameseq *elt = (struct nameseq *) xmalloc (size);
    3127                     if (size > sizeof (struct nameseq))
    3128                       bzero (((char *) elt) + sizeof (struct nameseq),
    3129                              size - sizeof (struct nameseq));
    3130                     elt->name = xstrdup (gl.gl_pathv[i]);
     3166                    struct nameseq *elt = xmalloc (size);
     3167                    memset (elt, '\0', size);
     3168                    elt->name = strcache_add (gl.gl_pathv[i]);
    31313169                    elt->next = new;
    31323170                    new = elt;
     
    31343172              }
    31353173            globfree (&gl);
    3136             free (old->name);
    3137             free ((char *)old);
     3174            free (old);
    31383175            break;
    31393176          }
     
    31483185          break;
    31493186        }
     3187
     3188#ifndef NO_ARCHIVES
     3189      if (arname)
     3190        free (arname);
     3191#endif
    31503192    }
    31513193
  • vendor/gnumake/current/remake.c

    r501 r900  
    4040#endif
    4141
    42 extern int try_implicit_rule PARAMS ((struct file *file, unsigned int depth));
     42extern int try_implicit_rule (struct file *file, unsigned int depth);
    4343
    4444
     
    6161static unsigned int considered;
    6262
    63 static int update_file PARAMS ((struct file *file, unsigned int depth));
    64 static int update_file_1 PARAMS ((struct file *file, unsigned int depth));
    65 static int check_dep PARAMS ((struct file *file, unsigned int depth, FILE_TIMESTAMP this_mtime, int *must_make_ptr));
    66 static int touch_file PARAMS ((struct file *file));
    67 static void remake_file PARAMS ((struct file *file));
    68 static FILE_TIMESTAMP name_mtime PARAMS ((char *name));
    69 static int library_search PARAMS ((char **lib, FILE_TIMESTAMP *mtime_ptr));
     63static int update_file (struct file *file, unsigned int depth);
     64static int update_file_1 (struct file *file, unsigned int depth);
     65static int check_dep (struct file *file, unsigned int depth,
     66                      FILE_TIMESTAMP this_mtime, int *must_make_ptr);
     67static int touch_file (struct file *file);
     68static void remake_file (struct file *file);
     69static FILE_TIMESTAMP name_mtime (const char *name);
     70static const char *library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr);
    7071
    7172
     
    239240
    240241              /* Free the storage.  */
    241               free ((char *) g);
     242              free (g);
    242243
    243244              g = lastgoal == 0 ? goals : lastgoal->next;
     
    538539      if (!running)
    539540        /* The prereq is considered changed if the timestamp has changed while
    540            it was built, OR it doesn't exist.
    541            This causes the Linux kernel build to break.  We'll defer this
    542            fix until GNU make 3.82 to give them time to update.  */
     541           it was built, OR it doesn't exist.  */
    543542        d->changed = ((file_mtime (d->file) != mtime)
    544                       /* || (mtime == NONEXISTENT_MTIME) */);
     543                      || (mtime == NONEXISTENT_MTIME));
    545544
    546545      lastd = d;
     
    809808  if (touch_flag
    810809      /* The update status will be:
    811                 -1      if this target was not remade;
     810                -1      if this target was not remade;
    812811                0       if 0 or more commands (+ or ${MAKE}) were run and won;
    813812                1       if some commands were run and lost.
     
    919918             so that a vpath_search can happen.  Otherwise, it would
    920919             never be done because the target is already updated.  */
    921           (void) f_mtime (d->file, 0);
     920          f_mtime (d->file, 0);
    922921      }
    923922  else if (file->update_status == -1)
     
    928927
    929928
    930 /* Check whether another file (whose mtime is THIS_MTIME)
    931    needs updating on account of a dependency which is file FILE.
    932    If it does, store 1 in *MUST_MAKE_PTR.
    933    In the process, update any non-intermediate files
    934    that FILE depends on (including FILE itself).
    935    Return nonzero if any updating failed.  */
     929/* Check whether another file (whose mtime is THIS_MTIME) needs updating on
     930   account of a dependency which is file FILE.  If it does, store 1 in
     931   *MUST_MAKE_PTR.  In the process, update any non-intermediate files that
     932   FILE depends on (including FILE itself).  Return nonzero if any updating
     933   failed.  */
    936934
    937935static int
     
    947945  if (file->phony || !file->intermediate)
    948946    {
    949       /* If this is a non-intermediate file, update it and record
    950          whether it is newer than THIS_MTIME.  */
     947      /* If this is a non-intermediate file, update it and record whether it
     948         is newer than THIS_MTIME.  */
    951949      FILE_TIMESTAMP mtime;
    952950      dep_status = update_file (file, depth);
     
    977975        }
    978976
    979       /* If the intermediate file actually exists
    980          and is newer, then we should remake from it.  */
    981977      check_renamed (file);
    982978      mtime = file_mtime (file);
    983979      check_renamed (file);
    984980      if (mtime != NONEXISTENT_MTIME && mtime > this_mtime)
     981        /* If the intermediate file actually exists and is newer, then we
     982           should remake from it.  */
    985983        *must_make_ptr = 1;
    986           /* Otherwise, update all non-intermediate files we depend on,
    987              if necessary, and see whether any of them is more
    988              recent than the file on whose behalf we are checking.  */
    989984      else
    990985        {
     986          /* Otherwise, update all non-intermediate files we depend on, if
     987             necessary, and see whether any of them is more recent than the
     988             file on whose behalf we are checking.  */
    991989          struct dep *lastd;
    992990
     
    10671065        {
    10681066          struct stat statbuf;
    1069           char buf;
     1067          char buf = 'x';
    10701068          int e;
    10711069
     
    11631161      char *arname, *memname;
    11641162      struct file *arfile;
    1165       int arname_used = 0;
    11661163      time_t member_date;
    11671164
     
    11731170      arfile = lookup_file (arname);
    11741171      if (arfile == 0)
    1175         {
    1176           arfile = enter_file (arname);
    1177           arname_used = 1;
    1178         }
     1172        arfile = enter_file (strcache_add (arname));
    11791173      mtime = f_mtime (arfile, search);
    11801174      check_renamed (arfile);
     
    11871181          unsigned int arlen, memlen;
    11881182
    1189           if (!arname_used)
    1190             {
    1191               free (arname);
    1192               arname_used = 1;
    1193             }
    1194 
    1195           arname = arfile->hname;
    1196           arlen = strlen (arname);
     1183          arlen = strlen (arfile->hname);
    11971184          memlen = strlen (memname);
    11981185
    1199           /* free (file->name); */
    1200 
    1201           name = (char *) xmalloc (arlen + 1 + memlen + 2);
    1202           bcopy (arname, name, arlen);
     1186          name = xmalloc (arlen + 1 + memlen + 2);
     1187          memcpy (name, arfile->hname, arlen);
    12031188          name[arlen] = '(';
    1204           bcopy (memname, name + arlen + 1, memlen);
     1189          memcpy (name + arlen + 1, memname, memlen);
    12051190          name[arlen + 1 + memlen] = ')';
    12061191          name[arlen + 1 + memlen + 1] = '\0';
     
    12151200        }
    12161201
    1217       if (!arname_used)
    1218         free (arname);
    1219       free (memname);
     1202      free (arname);
    12201203
    12211204      file->low_resolution_time = 1;
     
    12381221        {
    12391222          /* If name_mtime failed, search VPATH.  */
    1240           char *name = file->name;
    1241           if (vpath_search (&name, &mtime)
     1223          const char *name = vpath_search (file->name, &mtime);
     1224          if (name
    12421225              /* Last resort, is it a library (-lxxx)?  */
    1243               || (name[0] == '-' && name[1] == 'l'
    1244                   && library_search (&name, &mtime)))
     1226              || (file->name[0] == '-' && file->name[1] == 'l'
     1227                  && (name = library_search (file->name, &mtime)) != 0))
    12451228            {
    12461229              if (mtime != UNKNOWN_MTIME)
     
    13611344
    13621345static FILE_TIMESTAMP
    1363 name_mtime (char *name)
     1346name_mtime (const char *name)
    13641347{
    13651348  FILE_TIMESTAMP mtime;
     
    14551438   directories.  */
    14561439
    1457 static int
    1458 library_search (char **lib, FILE_TIMESTAMP *mtime_ptr)
     1440static const char *
     1441library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr)
    14591442{
    14601443  static char *dirs[] =
     
    14771460  static char *libpatterns = NULL;
    14781461
    1479   char *libname = &(*lib)[2];   /* Name without the `-l'.  */
     1462  const char *libname = lib+2;  /* Name without the '-l'.  */
    14801463  FILE_TIMESTAMP mtime;
    14811464
    14821465  /* Loop variables for the libpatterns value.  */
    1483   char *p, *p2;
     1466  char *p;
     1467  const char *p2;
    14841468  unsigned int len;
    14851469
    1486   char *file, **dp;
     1470  char **dp;
    14871471
    14881472  /* If we don't have libpatterns, get it.  */
     
    15331517      if (mtime != NONEXISTENT_MTIME)
    15341518        {
    1535           *lib = xstrdup (libbuf);
    15361519          if (mtime_ptr != 0)
    15371520            *mtime_ptr = mtime;
    1538           return 1;
     1521          return strcache_add (libbuf);
    15391522        }
    15401523
    15411524      /* Now try VPATH search on that.  */
    15421525
    1543       file = libbuf;
    1544       if (vpath_search (&file, mtime_ptr))
    1545         {
    1546           *lib = file;
    1547           return 1;
    1548         }
     1526      {
     1527        const char *file = vpath_search (libbuf, mtime_ptr);
     1528        if (file)
     1529          return file;
     1530      }
    15491531
    15501532      /* Now try the standard set of directories.  */
     
    15731555          if (mtime != NONEXISTENT_MTIME)
    15741556            {
    1575               *lib = xstrdup (buf);
    15761557              if (mtime_ptr != 0)
    15771558                *mtime_ptr = mtime;
    1578               return 1;
     1559              return strcache_add (buf);
    15791560            }
    15801561        }
  • vendor/gnumake/current/remote-cstms.c

    r501 r900  
    100100             that should work on all machines exported to.  */
    101101
    102           normalized_cwd = (char *) xmalloc (GET_PATH_MAX);
     102          normalized_cwd = xmalloc (GET_PATH_MAX);
    103103          strcpy (normalized_cwd, starting_directory);
    104104          if (Customs_NormPath (normalized_cwd, GET_PATH_MAX) < 0)
  • vendor/gnumake/current/rule.c

    r501 r900  
    1818
    1919#include "make.h"
     20
     21#include <assert.h>
     22
    2023#include "dep.h"
    2124#include "filedef.h"
     
    2528#include "rule.h"
    2629
    27 static void freerule PARAMS ((struct rule *rule, struct rule *lastrule));
     30static void freerule (struct rule *rule, struct rule *lastrule);
    2831
    2932
     
    7275  char *name;
    7376  int namelen;
    74   register struct rule *rule, *lastrule;
     77  struct rule *rule, *lastrule;
    7578
    7679  num_pattern_rules = max_pattern_targets = max_pattern_deps = 0;
     
    8487    {
    8588      unsigned int ndeps = 0;
    86       register struct dep *dep;
     89      struct dep *dep;
    8790      struct rule *next = rule->next;
    88       unsigned int ntargets;
    8991
    9092      ++num_pattern_rules;
    9193
    92       ntargets = 0;
    93       while (rule->targets[ntargets] != 0)
    94         ++ntargets;
    95 
    96       if (ntargets > max_pattern_targets)
    97         max_pattern_targets = ntargets;
     94      if (rule->num > max_pattern_targets)
     95        max_pattern_targets = rule->num;
    9896
    9997      for (dep = rule->deps; dep != 0; dep = dep->next)
     
    102100
    103101#ifdef VMS
    104           char *p = strrchr (dep->name, ']');
    105           char *p2;
     102          const char *p = strrchr (dep->name, ']');
     103          const char *p2;
    106104          if (p == 0)
    107105            p = strrchr (dep->name, ':');
    108106          p2 = p != 0 ? strchr (dep->name, '%') : 0;
    109107#else
    110           char *p = strrchr (dep->name, '/');
    111           char *p2 = p != 0 ? strchr (dep->name, '%') : 0;
     108          const char *p = strrchr (dep->name, '/');
     109          const char *p2 = p != 0 ? strchr (dep->name, '%') : 0;
    112110#endif
    113111          ndeps++;
     
    124122              if (p - dep->name > namelen)
    125123                {
    126                   if (name != 0)
    127                     free (name);
    128124                  namelen = p - dep->name;
    129                   name = (char *) xmalloc (namelen + 1);
     125                  name = xrealloc (name, namelen + 1);
    130126                }
    131               bcopy (dep->name, name, p - dep->name);
     127              memcpy (name, dep->name, p - dep->name);
    132128              name[p - dep->name] = '\0';
    133129
     
    162158
    163159static void
    164 convert_suffix_rule (char *target, char *source, struct commands *cmds)
    165 {
    166   char *targname, *targpercent, *depname;
    167   char **names, **percents;
     160convert_suffix_rule (const char *target, const char *source,
     161                     struct commands *cmds)
     162{
     163  const char **names, **percents;
    168164  struct dep *deps;
    169   unsigned int len;
     165
     166  names = xmalloc (sizeof (const char *));
     167  percents = xmalloc (sizeof (const char *));
    170168
    171169  if (target == 0)
    172     /* Special case: TARGET being nil means we are defining a
    173        `.X.a' suffix rule; the target pattern is always `(%.o)'.  */
    174     {
     170    {
     171      /* Special case: TARGET being nil means we are defining a `.X.a' suffix
     172         rule; the target pattern is always `(%.o)'.  */
    175173#ifdef VMS
    176       targname = savestring ("(%.obj)", 7);
     174      *names = strcache_add_len ("(%.obj)", 7);
    177175#else
    178       targname = savestring ("(%.o)", 5);
     176      *names = strcache_add_len ("(%.o)", 5);
    179177#endif
    180       targpercent = targname + 1;
     178      *percents = *names + 1;
    181179    }
    182180  else
    183181    {
    184182      /* Construct the target name.  */
    185       len = strlen (target);
    186       targname = xmalloc (1 + len + 1);
    187       targname[0] = '%';
    188       bcopy (target, targname + 1, len + 1);
    189       targpercent = targname;
    190     }
    191 
    192   names = (char **) xmalloc (2 * sizeof (char *));
    193   percents = (char **) alloca (2 * sizeof (char *));
    194   names[0] = targname;
    195   percents[0] = targpercent;
    196   names[1] = percents[1] = 0;
     183      unsigned int len = strlen (target);
     184      char *p = alloca (1 + len + 1);
     185      p[0] = '%';
     186      memcpy (p + 1, target, len + 1);
     187      *names = strcache_add_len (p, len + 1);
     188      *percents = *names;
     189    }
    197190
    198191  if (source == 0)
     
    201194    {
    202195      /* Construct the dependency name.  */
    203       len = strlen (source);
    204       depname = xmalloc (1 + len + 1);
    205       depname[0] = '%';
    206       bcopy (source, depname + 1, len + 1);
     196      unsigned int len = strlen (source);
     197      char *p = alloca (1 + len + 1);
     198      p[0] = '%';
     199      memcpy (p + 1, source, len + 1);
    207200      deps = alloc_dep ();
    208       deps->name = depname;
    209     }
    210 
    211   create_pattern_rule (names, percents, 0, deps, cmds, 0);
     201      deps->name = strcache_add_len (p, len + 1);
     202    }
     203
     204  create_pattern_rule (names, percents, 1, 0, deps, cmds, 0);
    212205}
    213206
    214207/* Convert old-style suffix rules to pattern rules.
    215    All rules for the suffixes on the .SUFFIXES list
    216    are converted and added to the chain of pattern rules.  */
     208   All rules for the suffixes on the .SUFFIXES list are converted and added to
     209   the chain of pattern rules.  */
    217210
    218211void
    219212convert_to_pattern (void)
    220213{
    221   register struct dep *d, *d2;
    222   register struct file *f;
    223   register char *rulename;
    224   register unsigned int slen, s2len;
    225 
    226   /* Compute maximum length of all the suffixes.  */
     214  struct dep *d, *d2;
     215  char *rulename;
     216
     217  /* We will compute every potential suffix rule (.x.y) from the list of
     218     suffixes in the .SUFFIXES target's dependencies and see if it exists.
     219     First find the longest of the suffixes.  */
    227220
    228221  maxsuffix = 0;
    229222  for (d = suffix_file->deps; d != 0; d = d->next)
    230223    {
    231       register unsigned int namelen = strlen (dep_name (d));
    232       if (namelen > maxsuffix)
    233         maxsuffix = namelen;
    234     }
    235 
    236   rulename = (char *) alloca ((maxsuffix * 2) + 1);
     224      unsigned int l = strlen (dep_name (d));
     225      if (l > maxsuffix)
     226        maxsuffix = l;
     227    }
     228
     229  /* Space to construct the suffix rule target name.  */
     230  rulename = alloca ((maxsuffix * 2) + 1);
    237231
    238232  for (d = suffix_file->deps; d != 0; d = d->next)
    239233    {
     234      unsigned int slen;
     235
    240236      /* Make a rule that is just the suffix, with no deps or commands.
    241237         This rule exists solely to disqualify match-anything rules.  */
    242       convert_suffix_rule (dep_name (d), (char *) 0, (struct commands *) 0);
    243 
    244       f = d->file;
    245       if (f->cmds != 0)
     238      convert_suffix_rule (dep_name (d), 0, 0);
     239
     240      if (d->file->cmds != 0)
    246241        /* Record a pattern for this suffix's null-suffix rule.  */
    247         convert_suffix_rule ("", dep_name (d), f->cmds);
    248 
    249       /* Record a pattern for each of this suffix's two-suffix rules.  */
     242        convert_suffix_rule ("", dep_name (d), d->file->cmds);
     243
     244      /* Add every other suffix to this one and see if it exists as a
     245         two-suffix rule.  */
    250246      slen = strlen (dep_name (d));
    251       bcopy (dep_name (d), rulename, slen);
     247      memcpy (rulename, dep_name (d), slen);
     248
    252249      for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)
    253250        {
     251          struct file *f;
     252          unsigned int s2len;
     253
    254254          s2len = strlen (dep_name (d2));
    255255
     256          /* Can't build something from itself.  */
    256257          if (slen == s2len && streq (dep_name (d), dep_name (d2)))
    257258            continue;
    258259
    259           bcopy (dep_name (d2), rulename + slen, s2len + 1);
     260          memcpy (rulename + slen, dep_name (d2), s2len + 1);
    260261          f = lookup_file (rulename);
    261262          if (f == 0 || f->cmds == 0)
     
    265266            /* A suffix rule `.X.a:' generates the pattern rule `(%.o): %.X'.
    266267               It also generates a normal `%.a: %.X' rule below.  */
    267             convert_suffix_rule ((char *) 0, /* Indicates `(%.o)'.  */
     268            convert_suffix_rule (NULL, /* Indicates `(%.o)'.  */
    268269                                 dep_name (d),
    269270                                 f->cmds);
     
    277278
    278279
    279 /* Install the pattern rule RULE (whose fields have been filled in)
    280    at the end of the list (so that any rules previously defined
    281    will take precedence).  If this rule duplicates a previous one
    282    (identical target and dependencies), the old one is replaced
    283    if OVERRIDE is nonzero, otherwise this new one is thrown out.
    284    When an old rule is replaced, the new one is put at the end of the
    285    list.  Return nonzero if RULE is used; zero if not.  */
    286 
    287 int
     280/* Install the pattern rule RULE (whose fields have been filled in) at the end
     281   of the list (so that any rules previously defined will take precedence).
     282   If this rule duplicates a previous one (identical target and dependencies),
     283   the old one is replaced if OVERRIDE is nonzero, otherwise this new one is
     284   thrown out.  When an old rule is replaced, the new one is put at the end of
     285   the list.  Return nonzero if RULE is used; zero if not.  */
     286
     287static int
    288288new_pattern_rule (struct rule *rule, int override)
    289289{
    290   register struct rule *r, *lastrule;
    291   register unsigned int i, j;
     290  struct rule *r, *lastrule;
     291  unsigned int i, j;
    292292
    293293  rule->in_use = 0;
     
    299299  lastrule = 0;
    300300  for (r = pattern_rules; r != 0; lastrule = r, r = r->next)
    301     for (i = 0; rule->targets[i] != 0; ++i)
     301    for (i = 0; i < rule->num; ++i)
    302302      {
    303         for (j = 0; r->targets[j] != 0; ++j)
     303        for (j = 0; j < r->num; ++j)
    304304          if (!streq (rule->targets[i], r->targets[j]))
    305305            break;
    306         if (r->targets[j] == 0)
    307           /* All the targets matched.  */
     306        /* If all the targets matched...  */
     307        if (j == r->num)
    308308          {
    309             register struct dep *d, *d2;
     309            struct dep *d, *d2;
    310310            for (d = rule->deps, d2 = r->deps;
    311311                 d != 0 && d2 != 0; d = d->next, d2 = d2->next)
     
    363363install_pattern_rule (struct pspec *p, int terminal)
    364364{
    365   register struct rule *r;
     365  struct rule *r;
    366366  char *ptr;
    367367
    368   r = (struct rule *) xmalloc (sizeof (struct rule));
    369 
    370   r->targets = (char **) xmalloc (2 * sizeof (char *));
    371   r->suffixes = (char **) xmalloc (2 * sizeof (char *));
    372   r->lens = (unsigned int *) xmalloc (2 * sizeof (unsigned int));
    373 
    374   r->targets[1] = 0;
    375   r->suffixes[1] = 0;
    376   r->lens[1] = 0;
     368  r = xmalloc (sizeof (struct rule));
     369
     370  r->num = 1;
     371  r->targets = xmalloc (sizeof (const char *));
     372  r->suffixes = xmalloc (sizeof (const char *));
     373  r->lens = xmalloc (sizeof (unsigned int));
    377374
    378375  r->lens[0] = strlen (p->target);
    379   /* These will all be string literals, but we malloc space for
    380      them anyway because somebody might want to free them later on.  */
    381   r->targets[0] = savestring (p->target, r->lens[0]);
    382   r->suffixes[0] = find_percent (r->targets[0]);
    383   if (r->suffixes[0] == 0)
    384     /* Programmer-out-to-lunch error.  */
    385     abort ();
    386   else
    387     ++r->suffixes[0];
     376  r->targets[0] = p->target;
     377  r->suffixes[0] = find_percent_cached (&r->targets[0]);
     378  assert (r->suffixes[0] != NULL);
     379  ++r->suffixes[0];
    388380
    389381  ptr = p->dep;
     
    395387    {
    396388      r->terminal = terminal;
    397       r->cmds = (struct commands *) xmalloc (sizeof (struct commands));
     389      r->cmds = xmalloc (sizeof (struct commands));
    398390      r->cmds->fileinfo.filenm = 0;
    399391      r->cmds->fileinfo.lineno = 0;
     
    414406{
    415407  struct rule *next = rule->next;
    416   register unsigned int i;
    417   register struct dep *dep;
    418 
    419   for (i = 0; rule->targets[i] != 0; ++i)
    420     free (rule->targets[i]);
     408  struct dep *dep;
    421409
    422410  dep = rule->deps;
    423411  while (dep)
    424412    {
    425       struct dep *t;
    426 
    427       t = dep->next;
    428       /* We might leak dep->name here, but I'm not sure how to fix this: I
    429          think that pointer might be shared (e.g., in the file hash?)  */
    430       dep->name = 0; /* Make sure free_dep does not free name.  */
     413      struct dep *t = dep->next;
    431414      free_dep (dep);
    432415      dep = t;
    433416    }
    434417
    435   free ((char *) rule->targets);
    436   free ((char *) rule->suffixes);
    437   free ((char *) rule->lens);
     418  free (rule->targets);
     419  free (rule->suffixes);
     420  free (rule->lens);
    438421
    439422  /* We can't free the storage for the commands because there
     
    448431       pointer from the `struct file' for the suffix rule.  */
    449432
    450   free ((char *) rule);
     433  free (rule);
    451434
    452435  if (pattern_rules == rule)
     
    462445
    463446
    464 /* Create a new pattern rule with the targets in the nil-terminated
    465    array TARGETS.  If TARGET_PERCENTS is not nil, it is an array of
    466    pointers into the elements of TARGETS, where the `%'s are.
    467    The new rule has dependencies DEPS and commands from COMMANDS.
     447/* Create a new pattern rule with the targets in the nil-terminated array
     448   TARGETS.  TARGET_PERCENTS is an array of pointers to the % in each element
     449   of TARGETS.  N is the number of items in the array (not counting the nil
     450   element).  The new rule has dependencies DEPS and commands from COMMANDS.
    468451   It is a terminal rule if TERMINAL is nonzero.  This rule overrides
    469452   identical rules with different commands if OVERRIDE is nonzero.
    470453
    471    The storage for TARGETS and its elements is used and must not be freed
    472    until the rule is destroyed.  The storage for TARGET_PERCENTS is not used;
    473    it may be freed.  */
     454   The storage for TARGETS and its elements and TARGET_PERCENTS is used and
     455   must not be freed until the rule is destroyed.  */
    474456
    475457void
    476 create_pattern_rule (char **targets, char **target_percents,
    477                     int terminal, struct dep *deps,
     458create_pattern_rule (const char **targets, const char **target_percents,
     459                     unsigned int n, int terminal, struct dep *deps,
    478460                     struct commands *commands, int override)
    479461{
    480   unsigned int max_targets, i;
    481   struct rule *r = (struct rule *) xmalloc (sizeof (struct rule));
    482 
     462  unsigned int i;
     463  struct rule *r = xmalloc (sizeof (struct rule));
     464
     465  r->num = n;
    483466  r->cmds = commands;
    484467  r->deps = deps;
    485468  r->targets = targets;
    486 
    487   max_targets = 2;
    488   r->lens = (unsigned int *) xmalloc (2 * sizeof (unsigned int));
    489   r->suffixes = (char **) xmalloc (2 * sizeof (char *));
    490   for (i = 0; targets[i] != 0; ++i)
    491     {
    492       if (i == max_targets - 1)
    493         {
    494           max_targets += 5;
    495           r->lens = (unsigned int *)
    496             xrealloc ((char *) r->lens, max_targets * sizeof (unsigned int));
    497           r->suffixes = (char **)
    498             xrealloc ((char *) r->suffixes, max_targets * sizeof (char *));
    499         }
     469  r->suffixes = target_percents;
     470  r->lens = xmalloc (n * sizeof (unsigned int));
     471
     472  for (i = 0; i < n; ++i)
     473    {
    500474      r->lens[i] = strlen (targets[i]);
    501       r->suffixes[i] = (target_percents == 0 ? find_percent (targets[i])
    502                         : target_percents[i]) + 1;
    503       if (r->suffixes[i] == 0)
    504         abort ();
    505     }
    506 
    507   if (i < max_targets - 1)
    508     {
    509       r->lens = (unsigned int *) xrealloc ((char *) r->lens,
    510                                            (i + 1) * sizeof (unsigned int));
    511       r->suffixes = (char **) xrealloc ((char *) r->suffixes,
    512                                         (i + 1) * sizeof (char *));
     475      assert (r->suffixes[i] != NULL);
     476      ++r->suffixes[i];
    513477    }
    514478
     
    523487print_rule (struct rule *r)
    524488{
    525   register unsigned int i;
    526   register struct dep *d;
    527 
    528   for (i = 0; r->targets[i] != 0; ++i)
     489  unsigned int i;
     490  struct dep *d;
     491
     492  for (i = 0; i < r->num; ++i)
    529493    {
    530494      fputs (r->targets[i], stdout);
    531       if (r->targets[i + 1] != 0)
    532         putchar (' ');
    533       else
    534         putchar (':');
     495      putchar ((i + 1 == r->num) ? ':' : ' ');
    535496    }
    536497  if (r->terminal)
     
    548509print_rule_data_base (void)
    549510{
    550   register unsigned int rules, terminal;
    551   register struct rule *r;
     511  unsigned int rules, terminal;
     512  struct rule *r;
    552513
    553514  puts (_("\n# Implicit Rules"));
  • vendor/gnumake/current/rule.h

    r501 r900  
    1717Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.  */
    1818
    19 /* Structure used for pattern rules.  */
     19
     20/* Structure used for pattern (implicit) rules.  */
    2021
    2122struct rule
    2223  {
    2324    struct rule *next;
    24     char **targets;             /* Targets of the rule.  */
     25    const char **targets;       /* Targets of the rule.  */
    2526    unsigned int *lens;         /* Lengths of each target.  */
    26     char **suffixes;            /* Suffixes (after `%') of each target.  */
     27    const char **suffixes;      /* Suffixes (after `%') of each target.  */
    2728    struct dep *deps;           /* Dependencies of the rule.  */
    2829    struct commands *cmds;      /* Commands to execute.  */
     30    unsigned short num;         /* Number of targets.  */
    2931    char terminal;              /* If terminal (double-colon).  */
    3032    char in_use;                /* If in use by a parent pattern_search.  */
     
    5052
    5153
    52 extern void install_pattern_rule PARAMS ((struct pspec *p, int terminal));
    53 extern int new_pattern_rule PARAMS ((struct rule *rule, int override));
    54 extern void count_implicit_rule_limits PARAMS ((void));
    55 extern void convert_to_pattern PARAMS ((void));
    56 extern void create_pattern_rule PARAMS ((char **targets,
    57                                          char **target_percents, int terminal,
    58                                          struct dep *deps,
    59                                          struct commands *commands,
    60                                          int override));
     54void count_implicit_rule_limits (void);
     55void convert_to_pattern (void);
     56void install_pattern_rule (struct pspec *p, int terminal);
     57void create_pattern_rule (const char **targets, const char **target_percents,
     58                          unsigned int num, int terminal, struct dep *deps,
     59                          struct commands *commands, int override);
  • vendor/gnumake/current/strcache.c

    r501 r900  
    2121#include "hash.h"
    2222
    23 /* The size (in bytes) of each cache buffer.  */
    24 #define CACHE_BUFFER_SIZE   (4096)
     23/* The size (in bytes) of each cache buffer.
     24   Try to pick something that will map well into the heap.  */
     25#define CACHE_BUFFER_SIZE   (8192 - 16)
    2526
    2627
     
    4041static struct strcache *strcache = NULL;
    4142
     43/* Add a new buffer to the cache.  Add it at the front to reduce search time.
     44   This can also increase the overhead, since it's less likely that older
     45   buffers will be filled in.  However, GNU make has so many smaller strings
     46   that this doesn't seem to be much of an issue in practice.
     47 */
    4248static struct strcache *
    4349new_cache()
    4450{
    4551  struct strcache *new;
    46   new = (struct strcache *) xmalloc (sizeof (*new) + bufsize);
     52  new = xmalloc (sizeof (*new) + bufsize);
    4753  new->end = new->buffer;
    4854  new->count = 0;
     
    6268  const char *res;
    6369
    64   /* If the string we want is too large to fit into a single buffer, then we're
    65      screwed; nothing will ever fit!  Change the maximum size of the cache to
    66      be big enough.  */
     70  /* If the string we want is too large to fit into a single buffer, then
     71     we're screwed; nothing will ever fit!  Change the maximum size of the
     72     cache to be big enough.  */
    6773  if (len > bufsize)
    6874    bufsize = len * 2;
     
    114120
    115121static struct hash_table strings;
     122static unsigned long total_adds = 0;
    116123
    117124static const char *
     
    119126{
    120127  /* Look up the string in the hash.  If it's there, return it.  */
    121   char **slot = (char **) hash_find_slot (&strings, str);
     128  char *const *slot = (char *const *) hash_find_slot (&strings, str);
    122129  const char *key = *slot;
     130
     131  /* Count the total number of adds we performed.  */
     132  ++total_adds;
    123133
    124134  if (!HASH_VACANT (key))
     
    156166strcache_add_len (const char *str, int len)
    157167{
    158   char *key = alloca (len + 1);
    159   memcpy (key, str, len);
    160   key[len] = '\0';
    161 
    162   return add_hash (key, len);
     168  /* If we're not given a nul-terminated string we have to create one, because
     169     the hashing functions expect it.  */
     170  if (str[len] != '\0')
     171    {
     172      char *key = alloca (len + 1);
     173      memcpy (key, str, len);
     174      key[len] = '\0';
     175      str = key;
     176    }
     177
     178  return add_hash (str, len);
    163179}
    164180
     
    174190strcache_init (void)
    175191{
    176   hash_init (&strings, 1000, str_hash_1, str_hash_2, str_hash_cmp);
     192  hash_init (&strings, 8000, str_hash_1, str_hash_2, str_hash_cmp);
    177193}
    178194
     
    186202  int totsize = 0, avgsize, maxsize = 0, minsize = bufsize;
    187203  int totfree = 0, avgfree, maxfree = 0, minfree = bufsize;
    188   const struct strcache *sp;
    189 
    190   for (sp = strcache; sp != NULL; sp = sp->next)
     204  int lastused = 0, lastfree = 0;
     205
     206  if (strcache)
    191207    {
    192       int bf = sp->bytesfree;
    193       int sz = (sp->end - sp->buffer) + bf;
    194 
    195       ++numbuffs;
    196       numstrs += sp->count;
    197 
    198       totsize += sz;
    199       maxsize = (sz > maxsize ? sz : maxsize);
    200       minsize = (sz < minsize ? sz : minsize);
    201 
    202       totfree += bf;
    203       maxfree = (bf > maxfree ? bf : maxfree);
    204       minfree = (bf < minfree ? bf : minfree);
     208      const struct strcache *sp;
     209
     210      /* Count the first buffer separately since it's not full.  */
     211      lastused = strcache->end - strcache->buffer;
     212      lastfree = strcache->bytesfree;
     213
     214      for (sp = strcache->next; sp != NULL; sp = sp->next)
     215        {
     216          int bf = sp->bytesfree;
     217          int sz = sp->end - sp->buffer;
     218
     219          ++numbuffs;
     220          numstrs += sp->count;
     221
     222          totsize += sz;
     223          maxsize = (sz > maxsize ? sz : maxsize);
     224          minsize = (sz < minsize ? sz : minsize);
     225
     226          totfree += bf;
     227          maxfree = (bf > maxfree ? bf : maxfree);
     228          minfree = (bf < minfree ? bf : minfree);
     229        }
    205230    }
    206231
     
    208233  avgfree = numbuffs ? (int)(totfree / numbuffs) : 0;
    209234
    210   printf (_("\n%s # of strings in strcache: %d\n"), prefix, numstrs);
    211   printf (_("%s # of strcache buffers: %d\n"), prefix, numbuffs);
    212   printf (_("%s strcache size: total = %d / max = %d / min = %d / avg = %d\n"),
    213           prefix, totsize, maxsize, minsize, avgsize);
    214   printf (_("%s strcache free: total = %d / max = %d / min = %d / avg = %d\n"),
    215           prefix, totfree, maxfree, minfree, avgfree);
    216 }
     235  printf (_("\n%s # of strings in strcache: %d / lookups = %lu / hits = %lu\n"),
     236          prefix, numstrs, total_adds, (total_adds - numstrs));
     237  printf (_("%s # of strcache buffers: %d (* %d B/buffer = %d B)\n"),
     238          prefix, (numbuffs + 1), bufsize, ((numbuffs + 1) * bufsize));
     239  printf (_("%s strcache used: total = %d (%d) / max = %d / min = %d / avg = %d\n"),
     240          prefix, totsize, lastused, maxsize, minsize, avgsize);
     241  printf (_("%s strcache free: total = %d (%d) / max = %d / min = %d / avg = %d\n"),
     242          prefix, totfree, lastfree, maxfree, minfree, avgfree);
     243
     244  fputs (_("\n# strcache hash-table stats:\n# "), stdout);
     245  hash_print_stats (&strings, stdout);
     246}
  • vendor/gnumake/current/tests/ChangeLog

    r501 r900  
     12006-10-01  Paul Smith  <[email protected]>
     2
     3        * run_make_tests.pl (set_more_defaults): Remove setting of LANG in
     4        ENV here.  This doesn't always work.
     5        * test_driver.pl (toplevel): Set LC_ALL to 'C' in the make
     6        environment.  Fixes Savannah bug #16698.
     7
     82006-09-30  Paul Smith  <[email protected]>
     9
     10        * scripts/variables/automatic: Add back the test for bug #8154.
     11
    1122006-04-01  Paul D. Smith  <[email protected]>
    213
  • vendor/gnumake/current/tests/run_make_tests.pl

    r501 r900  
    191191sub print_usage
    192192{
    193    &print_standard_usage ("run_make_tests", "[-make_path make_pathname]");
     193   &print_standard_usage ("run_make_tests",
     194                          "[-make_path make_pathname] [-valgrind]",);
    194195}
    195196
     
    229230   local($index);
    230231
    231    # Make sure we're in the C locale for those systems that support it,
    232    # so sorting, etc. is predictable.
    233    #
    234    $ENV{LANG} = 'C';
    235 
    236232   # find the type of the port.  We do this up front to have a single
    237233   # point of change if it needs to be tweaked.
  • vendor/gnumake/current/tests/scripts/features/patternrules

    r501 r900  
    1111
    1212
    13 #  TEST #1: Make sure that multiple patterns where the same target
    14 #           can be built are searched even if the first one fails
    15 #           to match properly.
     13# TEST #0: Make sure that multiple patterns where the same target
     14#          can be built are searched even if the first one fails
     15#          to match properly.
    1616#
    1717
     
    4646'');
    4747
    48 # TEST #2: make sure files that are built via implicit rules are marked
     48# TEST #1: make sure files that are built via implicit rules are marked
    4949#          as targets (Savannah bug #12202).
    5050#
     
    7070
    7171
    72 # TEST #3: make sure intermidite files that also happened to be
     72# TEST #2: make sure intermediate files that also happened to be
    7373#          prerequisites are not removed (Savannah bug #12267).
    7474#
     
    9797
    9898
    99 # TEST #4: make sure precious flag is set properly for targets
     99# TEST #3: make sure precious flag is set properly for targets
    100100#          that are built via implicit rules (Savannah bug #13218).
    101101#
     
    117117
    118118
    119 # TEST #5: make sure targets of a macthed implicit pattern rule never
     119# TEST #4: make sure targets of a matched implicit pattern rule are
    120120#          never considered intermediate (Savannah bug #13022).
    121121#
  • vendor/gnumake/current/tests/scripts/variables/automatic

    r501 r900  
    9696# considered reasons for the target to be rebuilt.
    9797#
    98 # This was undone due to Savannah bug #16002.  We'll re-do it in the next
    99 # release.  See Savannah bug #16051.
     98# See also Savannah bugs #16002 and #16051.
    10099
    101 #touch('foo');
    102 #
    103 #run_make_test('
    104 #foo: bar ; @echo "\$$? = $?"
    105 #bar: ;',
    106 #              '',
    107 #              '$? = bar');
    108 #
    109 #unlink('foo');
     100touch('foo');
     101
     102run_make_test('
     103foo: bar ; @echo "\$$? = $?"
     104bar: ;',
     105              '',
     106              '$? = bar');
     107
     108unlink('foo');
    110109
    1111101;
  • vendor/gnumake/current/tests/test_driver.pl

    r501 r900  
    2929# variables and then calls &toplevel, which does all the real work.
    3030
    31 # $Id: test_driver.pl,v 1.19 2006/03/10 02:20:45 psmith Exp $
     31# $Id: test_driver.pl,v 1.21 2007/03/20 03:02:26 psmith Exp $
    3232
    3333
     
    7979{
    8080  # Pull in benign variables from the user's environment
    81   #
     81
    8282  foreach (# UNIX-specific things
    83            'TZ', 'LANG', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH',
     83           'TZ', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH',
    8484           # Purify things
    8585           'PURIFYOPTIONS',
     
    9292    $makeENV{$_} = $ENV{$_} if $ENV{$_};
    9393  }
     94
     95  # Make sure our compares are not foiled by locale differences
     96
     97  $makeENV{LC_ALL} = 'C';
    9498
    9599  # Replace the environment with the new one
     
    544548  local($line);
    545549
    546   print "Usage:  perl $plname [testname] [-verbose] [-detail] [-keep]\n";
    547   print "                               [-profile] [-usage] [-help] "
    548       . "[-debug]\n";
    549   foreach $line (@moreusage)
    550   {
    551     print "                               $line\n";
     550  print "usage:\t$plname [testname] [-verbose] [-detail] [-keep]\n";
     551  print "\t\t\t[-profile] [-usage] [-help] [-debug]\n";
     552  foreach (@moreusage) {
     553    print "\t\t\t$_\n";
    552554  }
    553555}
  • vendor/gnumake/current/variable.c

    r501 r900  
    4343
    4444struct pattern_var *
    45 create_pattern_var (char *target, char *suffix)
    46 {
    47   register struct pattern_var *p
    48     = (struct pattern_var *) xmalloc (sizeof (struct pattern_var));
     45create_pattern_var (const char *target, const char *suffix)
     46{
     47  register struct pattern_var *p = xmalloc (sizeof (struct pattern_var));
    4948
    5049  if (last_pattern_var != 0)
     
    6564
    6665static struct pattern_var *
    67 lookup_pattern_var (struct pattern_var *start, char *target)
     66lookup_pattern_var (struct pattern_var *start, const char *target)
    6867{
    6968  struct pattern_var *p;
     
    7271  for (p = start ? start->next : pattern_vars; p != 0; p = p->next)
    7372    {
    74       char *stem;
     73      const char *stem;
    7574      unsigned int stemlen;
    7675
     
    163162struct variable *
    164163define_variable_in_set (const char *name, unsigned int length,
    165                         char *value, enum variable_origin origin,
     164                        const char *value, enum variable_origin origin,
    166165                        int recursive, struct variable_set *set,
    167166                        const struct floc *flocp)
     
    209208  /* Create a new variable definition and add it to the hash table.  */
    210209
    211   v = (struct variable *) xmalloc (sizeof (struct variable));
     210  v = xmalloc (sizeof (struct variable));
    212211  v->name = savestring (name, length);
    213212  v->length = length;
     
    318317              }
    319318
    320             bcopy (v->name, p, l);
     319            memcpy (p, v->name, l);
    321320            p += l;
    322321            *(p++) = ' ';
     
    445444   parent of FILE's variable set.
    446445
    447    If we're READing a makefile, don't do the pattern variable search now,
     446   If we're READING a makefile, don't do the pattern variable search now,
    448447   since the pattern variable might not have been defined yet.  */
    449448
     
    457456      l = (struct variable_set_list *)
    458457        xmalloc (sizeof (struct variable_set_list));
    459       l->set = (struct variable_set *) xmalloc (sizeof (struct variable_set));
     458      l->set = xmalloc (sizeof (struct variable_set));
    460459      hash_init (&l->set->table, PERFILE_VARIABLE_BUCKETS,
    461460                 variable_hash_1, variable_hash_2, variable_hash_cmp);
     
    553552  register struct variable_set *set;
    554553
    555   set = (struct variable_set *) xmalloc (sizeof (struct variable_set));
     554  set = xmalloc (sizeof (struct variable_set));
    556555  hash_init (&set->table, SMALL_SCOPE_VARIABLE_BUCKETS,
    557556             variable_hash_1, variable_hash_2, variable_hash_cmp);
     
    578577  hash_map (&list->set->table, free_variable_name_and_value);
    579578  hash_free (&list->set->table, 1);
    580   free ((char *) list->set);
    581   free ((char *) list);
     579  free (list->set);
     580  free (list);
    582581}
    583582
     
    635634
    636635  /* Free the one we no longer need.  */
    637   free ((char *) setlist);
     636  free (setlist);
    638637  hash_map (&set->table, free_variable_name_and_value);
    639638  hash_free (&set->table, 1);
    640   free ((char *) set);
     639  free (set);
    641640}
    642641
     
    953952  hash_delete (&table, &makelevel_key);
    954953
    955   result = result_0 = (char **) xmalloc ((table.ht_fill + 2) * sizeof (char *));
     954  result = result_0 = xmalloc ((table.ht_fill + 2) * sizeof (char *));
    956955
    957956  v_slot = (struct variable **) table.ht_vec;
     
    974973              convert_Path_to_windows32(value, ';');
    975974#endif
    976             *result++ = concat (v->name, "=", value);
     975            *result++ = xstrdup (concat (v->name, "=", value));
    977976            free (value);
    978977          }
     
    984983              convert_Path_to_windows32(v->value, ';');
    985984#endif
    986             *result++ = concat (v->name, "=", v->value);
     985            *result++ = xstrdup (concat (v->name, "=", v->value));
    987986          }
    988987      }
    989988
    990   *result = (char *) xmalloc (100);
    991   (void) sprintf (*result, "%s=%u", MAKELEVEL_NAME, makelevel + 1);
     989  *result = xmalloc (100);
     990  sprintf (*result, "%s=%u", MAKELEVEL_NAME, makelevel + 1);
    992991  *++result = 0;
    993992
     
    10031002struct variable *
    10041003do_variable_definition (const struct floc *flocp, const char *varname,
    1005                         char *value, enum variable_origin origin,
     1004                        const char *value, enum variable_origin origin,
    10061005                        enum variable_flavor flavor, int target_var)
    10071006{
    1008   char *p, *alloc_value = NULL;
     1007  const char *p;
     1008  char *alloc_value = NULL;
    10091009  struct variable *v;
    10101010  int append = 0;
     
    10711071
    10721072            unsigned int oldlen, vallen;
    1073             char *val;
     1073            const char *val;
     1074            char *tp;
    10741075
    10751076            val = value;
     
    10881089            oldlen = strlen (v->value);
    10891090            vallen = strlen (val);
    1090             p = (char *) alloca (oldlen + 1 + vallen + 1);
    1091             bcopy (v->value, p, oldlen);
    1092             p[oldlen] = ' ';
    1093             bcopy (val, &p[oldlen + 1], vallen + 1);
     1091            tp = alloca (oldlen + 1 + vallen + 1);
     1092            memcpy (tp, v->value, oldlen);
     1093            tp[oldlen] = ' ';
     1094            memcpy (&tp[oldlen + 1], val, vallen + 1);
     1095            p = tp;
    10941096          }
    10951097      }
     
    11171119
    11181120      /* See if we can find "/bin/sh.exe", "/bin/sh.com", etc.  */
    1119       if (__dosexec_find_on_path (p, (char **)0, shellpath))
     1121      if (__dosexec_find_on_path (p, NULL, shellpath))
    11201122        {
    1121           char *p;
    1122 
    1123           for (p = shellpath; *p; p++)
    1124             {
    1125               if (*p == '\\')
    1126                 *p = '/';
    1127             }
     1123          char *tp;
     1124
     1125          for (tp = shellpath; *tp; tp++)
     1126            if (*tp == '\\')
     1127              *tp = '/';
     1128
    11281129          v = define_variable_loc (varname, strlen (varname),
    11291130                                   shellpath, origin, flavor == f_recursive,
     
    11321133      else
    11331134        {
    1134           char *shellbase, *bslash;
     1135          const char *shellbase, *bslash;
    11351136          struct variable *pathv = lookup_variable ("PATH", 4);
    11361137          char *path_string;
     
    11531154          if (pathv)
    11541155            pathlen = strlen (pathv->value);
    1155           path_string = (char *)xmalloc (5 + pathlen + 2 + 1);
     1156          path_string = xmalloc (5 + pathlen + 2 + 1);
    11561157          /* On MSDOS, current directory is considered as part of $PATH.  */
    11571158          sprintf (path_string, "PATH=.;%s", pathv ? pathv->value : "");
    11581159          fake_env[0] = path_string;
    1159           fake_env[1] = (char *)0;
     1160          fake_env[1] = 0;
    11601161          if (__dosexec_find_on_path (shellbase, fake_env, shellpath))
    11611162            {
    1162               char *p;
    1163 
    1164               for (p = shellpath; *p; p++)
    1165                 {
    1166                   if (*p == '\\')
    1167                     *p = '/';
    1168                 }
     1163              char *tp;
     1164
     1165              for (tp = shellpath; *tp; tp++)
     1166                if (*tp == '\\')
     1167                  *tp = '/';
     1168
    11691169              v = define_variable_loc (varname, strlen (varname),
    11701170                                       shellpath, origin,
     
    13201320
    13211321  /* Expand the name, so "$(foo)bar = baz" works.  */
    1322   name = (char *) alloca (end - beg + 1);
    1323   bcopy (beg, name, end - beg);
     1322  name = alloca (end - beg + 1);
     1323  memcpy (name, beg, end - beg);
    13241324  name[end - beg] = '\0';
    13251325  v->name = allocated_variable_expand (name);
     
    13741374print_variable (const void *item, void *arg)
    13751375{
    1376   const struct variable *v = (struct variable *) item;
    1377   const char *prefix = (char *) arg;
     1376  const struct variable *v = item;
     1377  const char *prefix = arg;
    13781378  const char *origin;
    13791379
     
    14891489
    14901490void
    1491 print_file_variables (struct file *file)
     1491print_file_variables (const struct file *file)
    14921492{
    14931493  if (file->variables != 0)
     
    15161516   */
    15171517  convert_Path_to_windows32 (path, ';');
    1518   environ_path = concat ("PATH", "=", path);
     1518  environ_path = xstrdup (concat ("PATH", "=", path));
    15191519  putenv (environ_path);
    15201520  free (path);
  • vendor/gnumake/current/variable.h

    r501 r900  
    100100  {
    101101    struct pattern_var *next;
    102     char *target;
     102    const char *suffix;
     103    const char *target;
    103104    unsigned int len;
    104     char *suffix;
    105105    struct variable variable;
    106106  };
     
    110110
    111111/* expand.c */
    112 extern char *variable_buffer_output PARAMS ((char *ptr, char *string, unsigned int length));
    113 extern char *variable_expand PARAMS ((char *line));
    114 extern char *variable_expand_for_file PARAMS ((char *line, struct file *file));
    115 extern char *allocated_variable_expand_for_file PARAMS ((char *line, struct file *file));
     112char *variable_buffer_output (char *ptr, const char *string, unsigned int length);
     113char *variable_expand (const char *line);
     114char *variable_expand_for_file (const char *line, struct file *file);
     115char *allocated_variable_expand_for_file (const char *line, struct file *file);
    116116#define allocated_variable_expand(line) \
    117117  allocated_variable_expand_for_file (line, (struct file *) 0)
    118 extern char *expand_argument PARAMS ((const char *str, const char *end));
    119 extern char *variable_expand_string PARAMS ((char *line, char *string,
    120                                              long length));
    121 extern void install_variable_buffer PARAMS ((char **bufp, unsigned int *lenp));
    122 extern void restore_variable_buffer PARAMS ((char *buf, unsigned int len));
     118char *expand_argument (const char *str, const char *end);
     119char *variable_expand_string (char *line, const char *string, long length);
     120void install_variable_buffer (char **bufp, unsigned int *lenp);
     121void restore_variable_buffer (char *buf, unsigned int len);
    123122
    124123/* function.c */
    125 extern int handle_function PARAMS ((char **op, char **stringp));
    126 extern int pattern_matches PARAMS ((char *pattern, char *percent, char *str));
    127 extern char *subst_expand PARAMS ((char *o, char *text, char *subst, char *replace,
    128                 unsigned int slen, unsigned int rlen, int by_word));
    129 extern char *patsubst_expand PARAMS ((char *o, char *text, char *pattern, char *replace,
    130                 char *pattern_percent, char *replace_percent));
     124int handle_function (char **op, const char **stringp);
     125int pattern_matches (const char *pattern, const char *percent, const char *str);
     126char *subst_expand (char *o, const char *text, const char *subst,
     127                    const char *replace, unsigned int slen, unsigned int rlen,
     128                    int by_word);
     129char *patsubst_expand_pat (char *o, const char *text, const char *pattern,
     130                           const char *replace, const char *pattern_percent,
     131                           const char *replace_percent);
     132char *patsubst_expand (char *o, const char *text, char *pattern, char *replace);
    131133
    132134/* expand.c */
    133 extern char *recursively_expand_for_file PARAMS ((struct variable *v,
    134                                                   struct file *file));
     135char *recursively_expand_for_file (struct variable *v, struct file *file);
    135136#define recursively_expand(v)   recursively_expand_for_file (v, NULL)
    136137
    137138/* variable.c */
    138 extern struct variable_set_list *create_new_variable_set PARAMS ((void));
    139 extern void free_variable_set PARAMS ((struct variable_set_list *));
    140 extern struct variable_set_list *push_new_variable_scope PARAMS ((void));
    141 extern void pop_variable_scope PARAMS ((void));
    142 extern void define_automatic_variables PARAMS ((void));
    143 extern void initialize_file_variables PARAMS ((struct file *file, int read));
    144 extern void print_file_variables PARAMS ((struct file *file));
    145 extern void print_variable_set PARAMS ((struct variable_set *set, char *prefix));
    146 extern void merge_variable_set_lists PARAMS ((struct variable_set_list **to_list, struct variable_set_list *from_list));
    147 extern struct variable *do_variable_definition PARAMS ((const struct floc *flocp, const char *name, char *value, enum variable_origin origin, enum variable_flavor flavor, int target_var));
    148 extern struct variable *parse_variable_definition PARAMS ((struct variable *v, char *line));
    149 extern struct variable *try_variable_definition PARAMS ((const struct floc *flocp, char *line, enum variable_origin origin, int target_var));
    150 extern void init_hash_global_variable_set PARAMS ((void));
    151 extern void hash_init_function_table PARAMS ((void));
    152 extern struct variable *lookup_variable PARAMS ((const char *name, unsigned int length));
    153 extern struct variable *lookup_variable_in_set PARAMS ((const char *name,
    154                                                         unsigned int length,
    155                                                         const struct variable_set *set));
    156 
    157 extern struct variable *define_variable_in_set
    158     PARAMS ((const char *name, unsigned int length, char *value,
    159              enum variable_origin origin, int recursive,
    160              struct variable_set *set, const struct floc *flocp));
     139struct variable_set_list *create_new_variable_set (void);
     140void free_variable_set (struct variable_set_list *);
     141struct variable_set_list *push_new_variable_scope (void);
     142void pop_variable_scope (void);
     143void define_automatic_variables (void);
     144void initialize_file_variables (struct file *file, int reading);
     145void print_file_variables (const struct file *file);
     146void print_variable_set (struct variable_set *set, char *prefix);
     147void merge_variable_set_lists (struct variable_set_list **to_list,
     148                               struct variable_set_list *from_list);
     149struct variable *do_variable_definition (const struct floc *flocp,
     150                                         const char *name, const char *value,
     151                                         enum variable_origin origin,
     152                                         enum variable_flavor flavor,
     153                                         int target_var);
     154struct variable *parse_variable_definition (struct variable *v, char *line);
     155struct variable *try_variable_definition (const struct floc *flocp, char *line,
     156                                          enum variable_origin origin,
     157                                          int target_var);
     158void init_hash_global_variable_set (void);
     159void hash_init_function_table (void);
     160struct variable *lookup_variable (const char *name, unsigned int length);
     161struct variable *lookup_variable_in_set (const char *name, unsigned int length,
     162                                         const struct variable_set *set);
     163
     164struct variable *define_variable_in_set (const char *name, unsigned int length,
     165                                         const char *value,
     166                                         enum variable_origin origin,
     167                                         int recursive,
     168                                         struct variable_set *set,
     169                                         const struct floc *flocp);
    161170
    162171/* Define a variable in the current variable set.  */
     
    191200                              }while(0)
    192201
    193 extern char **target_environment PARAMS ((struct file *file));
    194 
    195 extern struct pattern_var *create_pattern_var PARAMS ((char *target, char *suffix));
     202char **target_environment (struct file *file);
     203
     204struct pattern_var *create_pattern_var (const char *target,
     205                                        const char *suffix);
    196206
    197207extern int export_all_variables;
  • vendor/gnumake/current/vmsdir.h

    r501 r900  
    6868#endif
    6969
    70 extern  DIR *opendir PARAMS (());
    71 extern  struct direct *readdir PARAMS ((DIR *dfd));
    7270#define rewinddir(dirp) seekdir((dirp), (long)0)
    73 extern  int closedir PARAMS ((DIR *dfd));
    74 extern char *vmsify PARAMS ((char *name, int type));
     71
     72DIR *opendir ();
     73struct direct *readdir (DIR *dfd);
     74int closedir (DIR *dfd);
     75const char *vmsify (const char *name, int type);
    7576
    7677#endif /* VMSDIR_H */
  • vendor/gnumake/current/vmsfunctions.c

    r501 r900  
    3838  struct NAM *dnam = (struct NAM *)xmalloc (sizeof (struct NAM));
    3939  struct FAB *dfab = &dir->fab;
    40   char *searchspec = (char *)xmalloc (MAXNAMLEN + 1);
     40  char *searchspec = xmalloc (MAXNAMLEN + 1);
    4141
    4242  memset (dir, 0, sizeof *dir);
     
    258258  return (str);
    259259}
    260 
    261 int
    262 strcmpi (const char *s1, const char *s2)
    263 {
    264   while (*s1 != '\0' && toupper(*s1) == toupper(*s2))
    265     {
    266       s1++;
    267       s2++;
    268     }
    269 
    270   return toupper(*(unsigned char *) s1) - toupper(*(unsigned char *) s2);
    271 }
  • vendor/gnumake/current/vmsify.c

    r501 r900  
    6464
    6565static int
    66 copyto (char **to, char **from, char upto, int as_dir)
     66copyto (char **to, const char **from, char upto, int as_dir)
    6767{
    68   char *s;
     68  const char *s;
    6969
    7070  s = strrchr (*from, '.');
     
    112112
    113113static char *
    114 trnlog (char *name)
     114trnlog (const char *name)
    115115{
    116116  int stat;
     
    135135  reslt[resltlen] = '\0';
    136136
    137   s = (char *)malloc (resltlen+1);
     137  s = malloc (resltlen+1);
    138138  if (s == 0)
    139139    return "";
     
    20620626  filenames with a single pair of '[' ']' are left unchanged
    207207
    208   the input string is not written to
     208  The input string is not written to.  The result is also const because
     209  it's a static buffer; we don't want to change it.
    209210*/
    210211
    211 char *
    212 vmsify (char *name, int type)
     212const char *
     213vmsify (const char *name, int type)
    213214{
    214215/* max 255 device
     
    222223  enum namestate nstate;
    223224  static char vmsname[MAXPATHLEN+1];
    224   char *fptr;
     225  const char *fptr;
     226  const char *t;
    225227  char *vptr;
    226   char *s,*s1;
    227228  int as_dir;
    228229  int count;
     
    235236
    236237  /* case 25a */
    237 
    238   s = strpbrk (name, "$:");
    239   if (s != 0)
    240     {
    241       char *s1;
    242       char *s2;
     238  t = strpbrk (name, "$:");
     239
     240  if (t != 0)
     241    {
     242      const char *s1;
     243      const char *s2;
    243244
    244245      if (type == 1)
    245         {
    246           s1 = strchr (s+1, '[');
    247           s2 = strchr (s+1, ']');
    248         }
    249 
    250       if (*s == '$')
    251         {
    252           if (strchr (name, '/') == 0)
    253             {
    254               if ((type == 1) && (s1 != 0) && (s2 == 0))
    255                 {
    256                   strcpy (vmsname, name);
    257                   strcat (vmsname, "]");
    258                   return vmsname;
    259                 }
    260               else
    261                 return name;
    262             }
    263         }
     246        {
     247          s1 = strchr (t+1, '[');
     248          s2 = strchr (t+1, ']');
     249        }
     250
     251      if (*t == '$')
     252        {
     253          if (strchr (name, '/') == 0)
     254            {
     255              strcpy (vmsname, name);
     256              if ((type == 1) && (s1 != 0) && (s2 == 0))
     257                strcat (vmsname, "]");
     258              return vmsname;
     259            }
     260        }
    264261      else
    265         {
    266           if ((type == 1) && (s1 != 0) && (s2 == 0))
    267             {
    268               strcpy (vmsname, name);
    269               strcat (vmsname, "]");
    270               return vmsname;
    271             }
    272           else
    273             return name;
    274         }
     262        {
     263          strcpy (vmsname, name);
     264          if ((type == 1) && (s1 != 0) && (s2 == 0))
     265            strcat (vmsname, "]");
     266          return vmsname;
     267        }
    275268    }
    276269
    277270  /* case 26 */
    278 
    279   s = strchr (name, '[');
    280 
    281   if (s != 0)
    282     {
    283       s1 = strchr (s+1, '[');
     271  t = strchr (name, '[');
     272
     273  if (t != 0)
     274    {
     275      const char *s;
     276      const char *s1 = strchr (t+1, '[');
    284277      if (s1 == 0)
    285278        {
    286           if ((type == 1)
    287                && (strchr (s+1, ']') == 0))
    288             {
    289               strcpy (vmsname, name);
    290               strcat (vmsname, "]");
    291               return vmsname;
    292             }
    293           else
    294             return name;                        /* single [, keep unchanged */
     279          strcpy (vmsname, name);
     280          if ((type == 1) && (strchr (t+1, ']') == 0))
     281            strcat (vmsname, "]");
     282          return vmsname;
    295283        }
    296284      s1--;
    297285      if (*s1 != ']')
    298286        {
    299           return name;                  /* not ][, keep unchanged */
     287          strcpy (vmsname, name);
     288          return vmsname;               /* not ][, keep unchanged */
    300289        }
    301290
     
    306295      /* s  -> starting char
    307296         s1 -> ending ']'  */
    308 
    309297      do
    310298        {
     
    330318
    331319    }
    332 
    333320  else          /* no [ in name */
    334 
    335     {
    336 
    337       int state;
     321    {
     322      int state = 0;
    338323      int rooted = 1;   /* flag if logical is rooted, else insert [000000] */
    339 
    340       state = 0;
    341324
    342325      do
    343326        {
    344 
    345327      switch (state)
    346328        {
     
    371353
    372354          case 2:                               /* no '/' at start */
    373             s = strchr (fptr, '/');
     355            {
     356            const char *s = strchr (fptr, '/');
    374357            if (s == 0)                 /* no '/' (16) */
    375358              {
     
    402385              }
    403386            break;
     387            }
    404388
    405389          case 3:                               /* '//' at start */
     390            {
     391            const char *s;
     392            const char *s1;
     393            char *vp;
    406394            while (*fptr == '/')        /* collapse all '/' */
    407395              fptr++;
     
    413401                if (s1 == 0)
    414402                  {
    415                     return "";          /* FIXME, err getcwd */
     403                    vmsname[0] = '\0';
     404                    return vmsname;     /* FIXME, err getcwd */
    416405                  }
    417406                s = strchr (s1, ':');
    418407                if (s == 0)
    419408                  {
    420                     return "";          /* FIXME, err no device */
     409                    vmsname[0] = '\0';
     410                    return vmsname;     /* FIXME, err no device */
    421411                  }
    422412                strncpy (vptr, s1, s-s1+1);
     
    445435            *vptr = 0;
    446436                                /* check logical for [000000] insertion */
    447             s1 = trnlog (s);
    448             if (*s1 != 0)
     437            vp = trnlog (s);
     438            if (*vp != '\0')
    449439              {                 /* found translation */
    450                 char *s2;
    451440                for (;;)        /* loop over all nested logicals */
    452441                  {
    453                     s2 = s1 + strlen (s1) - 1;
    454                     if (*s2 == ':')     /* translation ends in ':' */
    455                       {
    456                         s2 = trnlog (s1);
    457                         free (s1);
    458                         if (*s2 == 0)
     442                    char *vp2 = vp + strlen (vp) - 1;
     443                    if (*vp2 == ':')    /* translation ends in ':' */
     444                      {
     445                        vp2 = trnlog (vp);
     446                        free (vp);
     447                        if (*vp2 == 0)
    459448                          {
    460449                            rooted = 0;
    461450                            break;
    462451                          }
    463                         s1 = s2;
     452                        vp = vp2;
    464453                        continue;       /* next iteration */
    465454                      }
    466                     if (*s2 == ']')     /* translation ends in ']' */
    467                       {
    468                         if (*(s2-1) == '.')     /* ends in '.]' */
     455                    if (*vp2 == ']')    /* translation ends in ']' */
     456                      {
     457                        if (*(vp2-1) == '.')    /* ends in '.]' */
    469458                          {
    470459                            if (strncmp (fptr, "000000", 6) != 0)
     
    474463                          {
    475464                            strcpy (vmsname, s1);
    476                             s = strchr (vmsname, ']');
    477                             *s = '.';
     465                            vp = strchr (vmsname, ']');
     466                            *vp = '.';
    478467                            nstate = N_DOT;
    479                             vptr = s;
     468                            vptr = vp;
    480469                          }
    481470                      }
    482471                    break;
    483472                  }
    484                 free (s1);
     473                free (vp);
    485474              }
    486475            else
     
    497486            if (rooted == 0)
    498487              {
     488                nstate = N_DOT;
    499489                strcpy (vptr, "[000000.");
    500490                vptr += 8;
    501                 s1 = vptr-1;
    502                 nstate = N_DOT;
    503               }
    504             else
    505               s1 = 0;
    506 
    507         /* s1-> '.' after 000000 or NULL */
     491                vp = vptr-1;
     492              }
     493            else
     494              vp = 0;
     495
     496            /* vp-> '.' after 000000 or NULL */
    508497
    509498            s = strchr (fptr, '/');
     
    532521            else
    533522              if ((nstate == N_DOT)
    534                  && (s1 != 0)
     523                 && (vp != 0)
    535524                 && (*(s+1) == 0))
    536525                {
    537526                  if (type == 2)
    538527                    {
    539                       *s1 = ']';
     528                      *vp = ']';
    540529                      nstate = N_CLOSED;
    541530                    }
     
    543532            state = 9;
    544533            break;
    545 
     534            }
    546535          case 4:                               /* single '/' at start (9..15) */
    547536            if (*fptr == 0)
     
    565554            break;
    566555
    567           case 6:                               /* chars following '/' at start 10..15 */
     556          case 6:               /* chars following '/' at start 10..15 */
     557            {
     558            const char *s;
    568559            *vptr++ = '[';
    569560            nstate = N_OPEN;
     
    596587              }
    597588            break;
     589            }
    598590
    599591          case 7:                               /* add '.dir' and exit */
     
    601593                || (nstate == N_DOT))
    602594              {
    603                 s = vptr-1;
    604                 while (s > vmsname)
    605                   {
    606                     if (*s == ']')
     595                char *vp = vptr-1;
     596                while (vp > vmsname)
     597                  {
     598                    if (*vp == ']')
    607599                      {
    608600                        break;
    609601                      }
    610                     if (*s == '.')
    611                       {
    612                         *s = ']';
     602                    if (*vp == '.')
     603                      {
     604                        *vp = ']';
    613605                        break;
    614606                      }
    615                     s--;
     607                    vp--;
    616608                  }
    617609              }
     
    626618            break;
    627619
    628           case 9:                               /* 17..21, fptr -> 1st '/' + 1 */
     620          case 9:                       /* 17..21, fptr -> 1st '/' + 1 */
     621            {
     622            const char *s;
    629623            if (*fptr == 0)
    630624              {
     
    688682                    || (*(fptr+2) == 0)) )
    689683              {
     684                char *vp;
    690685                fptr += 2;
    691686                if (*fptr == '/')
     
    700695                  type = 1;
    701696                vptr--;                         /* vptr -> '.' or ']' */
    702                 s1 = vptr;
     697                vp = vptr;
    703698                for (;;)
    704699                  {
    705                     s1--;
    706                     if (*s1 == '.')             /* one back */
    707                       {
    708                         vptr = s1;
     700                    vp--;
     701                    if (*vp == '.')             /* one back */
     702                      {
     703                        vptr = vp;
    709704                        nstate = N_OPEN;
    710705                        break;
    711706                      }
    712                     if (*s1 == '[')             /* top level reached */
     707                    if (*vp == '[')             /* top level reached */
    713708                      {
    714709                        if (*fptr == 0)
    715710                          {
    716                             strcpy (s1, "[000000]");
    717                             vptr = s1 + 8;
     711                            strcpy (vp, "[000000]");
     712                            vptr = vp + 8;
    718713                            nstate = N_CLOSED;
    719714                            s = 0;
     
    722717                        else
    723718                          {
    724                             vptr = s1+1;
     719                            vptr = vp+1;
    725720                            nstate = N_OPEN;
    726721                            break;
     
    757752              }
    758753            break;
     754            }
    759755
    760756          case 10:                              /* 1,2 first is '.' */
     
    774770                if (*fptr != '/')               /* got ..xxx */
    775771                  {
    776                     return name;
     772                    strcpy (vmsname, name);
     773                    return vmsname;
    777774                  }
    778775                do                              /* got ../ */
     
    792789              }
    793790            {                                   /* got '..' or '../' */
     791              char *vp;
    794792              char cwdbuf[MAXPATHLEN+1];
    795793
    796               s1 = getcwd(cwdbuf, MAXPATHLEN);
    797               if (s1 == 0)
     794              vp = getcwd(cwdbuf, MAXPATHLEN);
     795              if (vp == 0)
    798796                {
    799                   return "";        /* FIXME, err getcwd */
     797                  vmsname[0] = '\0';
     798                  return vmsname;    /* FIXME, err getcwd */
    800799                }
    801               strcpy (vptr, s1);
    802               s = strchr (vptr, ']');
    803               if (s != 0)
     800              strcpy (vptr, vp);
     801              vp = strchr (vptr, ']');
     802              if (vp != 0)
    804803                {
    805804                  nstate = N_OPEN;
    806                   while (s > vptr)
     805                  while (vp > vptr)
    807806                    {
    808                       s--;
    809                       if (*s == '[')
     807                      vp--;
     808                      if (*vp == '[')
    810809                        {
    811                           s++;
    812                           strcpy (s, "000000]");
     810                          vp++;
     811                          strcpy (vp, "000000]");
    813812                          state = -1;
    814813                          break;
    815814                        }
    816                       else if (*s == '.')
     815                      else if (*vp == '.')
    817816                        {
    818817                          if (--count == 0)
     
    820819                              if (*fptr == 0)   /* had '..' or '../' */
    821820                                {
    822                                   *s++ = ']';
     821                                  *vp++ = ']';
    823822                                  state = -1;
    824823                                }
     
    827826                                  state = 9;
    828827                                }
    829                               *s = 0;
     828                              *vp = '\0';
    830829                              break;
    831830                            }
     
    842841                if (*fptr != '/')
    843842                  {
    844                     return name;
     843                    strcpy (vmsname, name);
     844                    return vmsname;
    845845                  }
    846846                while (*fptr == '/')
     
    849849
    850850            {
     851              char *vp;
    851852              char cwdbuf[MAXPATHLEN+1];
    852853
    853               s1 = getcwd(cwdbuf, MAXPATHLEN);
    854               if (s1 == 0)
     854              vp = getcwd(cwdbuf, MAXPATHLEN);
     855              if (vp == 0)
    855856                {
    856                   return "";        /*FIXME, err getcwd */
     857                  vmsname[0] = '\0';
     858                  return vmsname;    /*FIXME, err getcwd */
    857859                }
    858               strcpy (vptr, s1);
    859               if (*fptr == 0)
    860                 {
    861                   state = -1;
    862                   break;
    863                 }
    864               else
    865                 {
    866                   s = strchr (vptr, ']');
    867                   if (s == 0)
    868                     {
    869                       state = -1;
    870                       break;
    871                     }
    872                   *s = 0;
    873                   nstate = N_OPEN;
    874                   vptr += strlen (vptr);
    875                   state = 9;
    876                 }
    877             }
     860              strcpy (vptr, vp);
     861            }
     862            if (*fptr == 0)
     863              {
     864                state = -1;
     865                break;
     866              }
     867            else
     868              {
     869                char *vp = strchr (vptr, ']');
     870                if (vp == 0)
     871                  {
     872                    state = -1;
     873                    break;
     874                  }
     875                *vp = '\0';
     876                nstate = N_OPEN;
     877                vptr += strlen (vptr);
     878                state = 9;
     879              }
    878880            break;
    879881        }
     
    904906*/
    905907
    906 char *
    907 unixify (char *name)
     908const char *
     909unixify (const char *name)
    908910{
    909911  static char piece[512];
    910   char *s, *p;
     912  const char *s;
     913  char *p;
    911914
    912915  if (strchr (name, '/') != 0)          /* already in unix style */
    913     return name;
     916    {
     917      strcpy (piece, name);
     918      return piece;
     919    }
    914920
    915921  p = piece;
     
    922928  if (s != 0)
    923929    {
    924       *s = 0;
     930      int l = s - name;
    925931      *p++ = '/';
    926932      *p++ = '/';
    927       strcpy (p, name);
    928       p += strlen (p);
    929       *s = ':';
     933      strncpy (p, name, l);
     934      p += l;
    930935    }
    931936
  • vendor/gnumake/current/vmsjobs.c

    r501 r900  
    2222#include <clidef.h>
    2323
    24 extern char *vmsify PARAMS ((char *name, int type));
     24char *vmsify (char *name, int type);
    2525
    2626static int vms_jobsefnmask = 0;
  • vendor/gnumake/current/vpath.c

    r501 r900  
    3030  {
    3131    struct vpath *next; /* Pointer to next struct in the linked list.  */
    32     char *pattern;      /* The pattern to match.  */
    33     char *percent;      /* Pointer into `pattern' where the `%' is.  */
     32    const char *pattern;/* The pattern to match.  */
     33    const char *percent;/* Pointer into `pattern' where the `%' is.  */
    3434    unsigned int patlen;/* Length of the pattern.  */
    35     char **searchpath;  /* Null-terminated list of directories.  */
     35    const char **searchpath; /* Null-terminated list of directories.  */
    3636    unsigned int maxlen;/* Maximum length of any entry in the list.  */
    3737  };
     
    5050
    5151
    52 static int selective_vpath_search PARAMS ((struct vpath *path, char **file, FILE_TIMESTAMP *mtime_ptr));
    53 
    54 /* Reverse the chain of selective VPATH lists so they
    55    will be searched in the order given in the makefiles
    56    and construct the list from the VPATH variable.  */
     52
     53/* Reverse the chain of selective VPATH lists so they will be searched in the
     54   order given in the makefiles and construct the list from the VPATH
     55   variable.  */
    5756
    5857void
     
    9190      /* Save the list of vpaths.  */
    9291      struct vpath *save_vpaths = vpaths;
     92      char gp[] = "%";
    9393
    9494      /* Empty `vpaths' so the new one will have no next, and `vpaths'
     
    9797
    9898      /* Parse P.  */
    99       construct_vpath_list ("%", p);
     99      construct_vpath_list (gp, p);
    100100
    101101      /* Store the created path as the general path,
     
    123123      /* Save the list of vpaths.  */
    124124      struct vpath *save_vpaths = vpaths;
     125      char gp[] = "%";
    125126
    126127      /* Empty `vpaths' so the new one will have no next, and `vpaths'
     
    129130
    130131      /* Parse P.  */
    131       construct_vpath_list ("%", p);
     132      construct_vpath_list (gp, p);
    132133
    133134      /* Store the created path as the GPATH,
     
    161162construct_vpath_list (char *pattern, char *dirpath)
    162163{
    163   register unsigned int elem;
    164   register char *p;
    165   register char **vpath;
    166   register unsigned int maxvpath;
     164  unsigned int elem;
     165  char *p;
     166  const char **vpath;
     167  unsigned int maxvpath;
    167168  unsigned int maxelem;
    168   char *percent = NULL;
     169  const char *percent = NULL;
    169170
    170171  if (pattern != 0)
    171     {
    172       pattern = xstrdup (pattern);
    173       percent = find_percent (pattern);
    174     }
     172    percent = find_percent (pattern);
    175173
    176174  if (dirpath == 0)
    177175    {
    178176      /* Remove matching listings.  */
    179       register struct vpath *path, *lastpath;
     177      struct vpath *path, *lastpath;
    180178
    181179      lastpath = 0;
     
    197195
    198196              /* Free its unused storage.  */
    199               free (path->pattern);
    200               free ((char *) path->searchpath);
    201               free ((char *) path);
     197              free (path->searchpath);
     198              free (path);
    202199            }
    203200          else
     
    207204        }
    208205
    209       if (pattern != 0)
    210         free (pattern);
    211206      return;
    212207    }
     
    215210    convert_vpath_to_windows32(dirpath, ';');
    216211#endif
     212
     213  /* Skip over any initial separators and blanks.  */
     214  while (*dirpath == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*dirpath))
     215    ++dirpath;
    217216
    218217  /* Figure out the maximum number of VPATH entries and put it in
     
    226225      ++maxelem;
    227226
    228   vpath = (char **) xmalloc (maxelem * sizeof (char *));
     227  vpath = xmalloc (maxelem * sizeof (const char *));
    229228  maxvpath = 0;
    230229
    231   /* Skip over any initial separators and blanks.  */
     230  elem = 0;
    232231  p = dirpath;
    233   while (*p == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*p))
    234     ++p;
    235 
    236   elem = 0;
    237232  while (*p != '\0')
    238233    {
     
    256251        --len;
    257252
     253      /* Put the directory on the vpath list.  */
    258254      if (len > 1 || *v != '.')
    259255        {
    260           v = savestring (v, len);
    261 
    262           /* Verify that the directory actually exists.  */
    263 
    264           if (dir_file_exists_p (v, ""))
    265             {
    266               /* It does.  Put it in the list.  */
    267               vpath[elem++] = dir_name (v);
    268               free (v);
    269               if (len > maxvpath)
    270                 maxvpath = len;
    271             }
    272           else
    273             /* The directory does not exist.  Omit from the list.  */
    274             free (v);
     256          vpath[elem++] = dir_name (strcache_add_len (v, len));
     257          if (len > maxvpath)
     258            maxvpath = len;
    275259        }
    276260
     
    287271         Usually this is maxelem - 1.  If not, shrink down.  */
    288272      if (elem < (maxelem - 1))
    289         vpath = (char **) xrealloc ((char *) vpath,
    290                                     (elem + 1) * sizeof (char *));
     273        vpath = xrealloc (vpath, (elem+1) * sizeof (const char *));
    291274
    292275      /* Put the nil-pointer terminator on the end of the VPATH list.  */
    293       vpath[elem] = 0;
     276      vpath[elem] = NULL;
    294277
    295278      /* Construct the vpath structure and put it into the linked list.  */
    296       path = (struct vpath *) xmalloc (sizeof (struct vpath));
     279      path = xmalloc (sizeof (struct vpath));
    297280      path->searchpath = vpath;
    298281      path->maxlen = maxvpath;
     
    301284
    302285      /* Set up the members.  */
    303       path->pattern = pattern;
    304       path->percent = percent;
     286      path->pattern = strcache_add (pattern);
    305287      path->patlen = strlen (pattern);
     288      path->percent = percent ? path->pattern + (percent - pattern) : 0;
    306289    }
    307290  else
    308     {
    309       /* There were no entries, so free whatever space we allocated.  */
    310       free ((char *) vpath);
    311       if (pattern != 0)
    312         free (pattern);
    313     }
     291    /* There were no entries, so free whatever space we allocated.  */
     292    free (vpath);
    314293}
    315294
     
    319298
    320299int
    321 gpath_search (char *file, unsigned int len)
     300gpath_search (const char *file, unsigned int len)
    322301{
    323   char **gp;
     302  const char **gp;
    324303
    325304  if (gpaths && (len <= gpaths->maxlen))
     
    332311
    333312
    334 /* Search the VPATH list whose pattern matches *FILE for a directory
    335    where the name pointed to by FILE exists.  If it is found, we set *FILE to
    336    the newly malloc'd name of the existing file, *MTIME_PTR (if MTIME_PTR is
    337    not NULL) to its modtime (or zero if no stat call was done), and return 1.
    338    Otherwise we return 0.  */
    339 
    340 int
    341 vpath_search (char **file, FILE_TIMESTAMP *mtime_ptr)
    342 {
    343   register struct vpath *v;
    344 
    345   /* If there are no VPATH entries or FILENAME starts at the root,
    346      there is nothing we can do.  */
    347 
    348   if (**file == '/'
    349 #ifdef HAVE_DOS_PATHS
    350       || **file == '\\'
    351       || (*file)[1] == ':'
    352 #endif
    353       || (vpaths == 0 && general_vpath == 0))
    354     return 0;
    355 
    356   for (v = vpaths; v != 0; v = v->next)
    357     if (pattern_matches (v->pattern, v->percent, *file))
    358       if (selective_vpath_search (v, file, mtime_ptr))
    359         return 1;
    360 
    361   if (general_vpath != 0
    362       && selective_vpath_search (general_vpath, file, mtime_ptr))
    363     return 1;
    364 
    365   return 0;
    366 }
    367 
    368 
    369 /* Search the given VPATH list for a directory where the name pointed
    370    to by FILE exists.  If it is found, we set *FILE to the newly malloc'd
    371    name of the existing file, *MTIME_PTR (if MTIME_PTR is not NULL) to
    372    its modtime (or zero if no stat call was done), and we return 1.
    373    Otherwise we return 0.  */
    374 
    375 static int
    376 selective_vpath_search (struct vpath *path, char **file,
     313
     314/* Search the given VPATH list for a directory where the name pointed to by
     315   FILE exists.  If it is found, we return a cached name of the existing file
     316   and set *MTIME_PTR (if MTIME_PTR is not NULL) to its modtime (or zero if no
     317   stat call was done).  Otherwise we return NULL.  */
     318
     319static const char *
     320selective_vpath_search (struct vpath *path, const char *file,
    377321                        FILE_TIMESTAMP *mtime_ptr)
    378322{
    379323  int not_target;
    380   char *name, *n;
    381   char *filename;
    382   register char **vpath = path->searchpath;
     324  char *name;
     325  const char *n;
     326  const char *filename;
     327  const char **vpath = path->searchpath;
    383328  unsigned int maxvpath = path->maxlen;
    384   register unsigned int i;
     329  unsigned int i;
    385330  unsigned int flen, vlen, name_dplen;
    386331  int exists = 0;
     
    390335     files that don't exist but are mentioned in a makefile.  */
    391336  {
    392     struct file *f = lookup_file (*file);
     337    struct file *f = lookup_file (file);
    393338    not_target = f == 0 || !f->is_target;
    394339  }
    395340
    396   flen = strlen (*file);
     341  flen = strlen (file);
    397342
    398343  /* Split *FILE into a directory prefix and a name-within-directory.
    399      NAME_DPLEN gets the length of the prefix; FILENAME gets the
    400      pointer to the name-within-directory and FLEN is its length.  */
    401 
    402   n = strrchr (*file, '/');
     344     NAME_DPLEN gets the length of the prefix; FILENAME gets the pointer to
     345     the name-within-directory and FLEN is its length.  */
     346
     347  n = strrchr (file, '/');
    403348#ifdef HAVE_DOS_PATHS
    404349  /* We need the rightmost slash or backslash.  */
    405350  {
    406     char *bslash = strrchr(*file, '\\');
     351    const char *bslash = strrchr(file, '\\');
    407352    if (!n || bslash > n)
    408353      n = bslash;
    409354  }
    410355#endif
    411   name_dplen = n != 0 ? n - *file : 0;
    412   filename = name_dplen > 0 ? n + 1 : *file;
     356  name_dplen = n != 0 ? n - file : 0;
     357  filename = name_dplen > 0 ? n + 1 : file;
    413358  if (name_dplen > 0)
    414359    flen -= name_dplen + 1;
    415360
    416   /* Allocate enough space for the biggest VPATH entry,
    417      a slash, the directory prefix that came with *FILE,
    418      another slash (although this one may not always be
    419      necessary), the filename, and a null terminator.  */
    420   name = (char *) xmalloc (maxvpath + 1 + name_dplen + 1 + flen + 1);
     361  /* Get enough space for the biggest VPATH entry, a slash, the directory
     362     prefix that came with FILE, another slash (although this one may not
     363     always be necessary), the filename, and a null terminator.  */
     364  name = alloca (maxvpath + 1 + name_dplen + 1 + flen + 1);
    421365
    422366  /* Try each VPATH entry.  */
     
    424368    {
    425369      int exists_in_cache = 0;
    426 
    427       n = name;
    428 
    429       /* Put the next VPATH entry into NAME at N and increment N past it.  */
     370      char *p;
     371
     372      p = name;
     373
     374      /* Put the next VPATH entry into NAME at P and increment P past it.  */
    430375      vlen = strlen (vpath[i]);
    431       bcopy (vpath[i], n, vlen);
    432       n += vlen;
     376      memcpy (p, vpath[i], vlen);
     377      p += vlen;
    433378
    434379      /* Add the directory prefix already in *FILE.  */
     
    436381        {
    437382#ifndef VMS
    438           *n++ = '/';
    439 #endif
    440           bcopy (*file, n, name_dplen);
    441           n += name_dplen;
     383          *p++ = '/';
     384#endif
     385          memcpy (p, file, name_dplen);
     386          p += name_dplen;
    442387        }
    443388
    444389#ifdef HAVE_DOS_PATHS
    445390      /* Cause the next if to treat backslash and slash alike.  */
    446       if (n != name && n[-1] == '\\' )
    447         n[-1] = '/';
     391      if (p != name && p[-1] == '\\' )
     392        p[-1] = '/';
    448393#endif
    449394      /* Now add the name-within-directory at the end of NAME.  */
    450395#ifndef VMS
    451       if (n != name && n[-1] != '/')
     396      if (p != name && p[-1] != '/')
    452397        {
    453           *n = '/';
    454           bcopy (filename, n + 1, flen + 1);
     398          *p = '/';
     399          memcpy (p + 1, filename, flen + 1);
    455400        }
    456401      else
    457402#endif
    458         bcopy (filename, n, flen + 1);
     403        memcpy (p, filename, flen + 1);
    459404
    460405      /* Check if the file is mentioned in a makefile.  If *FILE is not
     
    503448          /* Clobber a null into the name at the last slash.
    504449             Now NAME is the name of the directory to look in.  */
    505           *n = '\0';
     450          *p = '\0';
    506451
    507452          /* We know the directory is in the hash table now because either
     
    524469#ifndef VMS
    525470          /* Put the slash back in NAME.  */
    526           *n = '/';
     471          *p = '/';
    527472#endif
    528473
     
    547492
    548493          /* We have found a file.
    549              Store the name we found into *FILE for the caller.  */
    550 
    551           *file = savestring (name, (n + 1 - name) + flen);
    552 
    553           /* If we get here and mtime_ptr hasn't been set, record
     494             If we get here and mtime_ptr hasn't been set, record
    554495             UNKNOWN_MTIME to indicate this.  */
    555496          if (mtime_ptr != 0)
    556497            *mtime_ptr = UNKNOWN_MTIME;
    557498
    558           free (name);
    559           return 1;
     499          /* Store the name we found and return it.  */
     500
     501          return strcache_add_len (name, (p + 1 - name) + flen);
    560502        }
    561503    }
    562504
    563   free (name);
     505  return 0;
     506}
     507
     508
     509/* Search the VPATH list whose pattern matches FILE for a directory where FILE
     510   exists.  If it is found, return the cached name of an existing file, and
     511   set *MTIME_PTR (if MTIME_PTR is not NULL) to its modtime (or zero if no
     512   stat call was done).  Otherwise we return 0.  */
     513
     514const char *
     515vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr)
     516{
     517  struct vpath *v;
     518
     519  /* If there are no VPATH entries or FILENAME starts at the root,
     520     there is nothing we can do.  */
     521
     522  if (file[0] == '/'
     523#ifdef HAVE_DOS_PATHS
     524      || file[0] == '\\' || file[1] == ':'
     525#endif
     526      || (vpaths == 0 && general_vpath == 0))
     527    return 0;
     528
     529  for (v = vpaths; v != 0; v = v->next)
     530    if (pattern_matches (v->pattern, v->percent, file))
     531      {
     532        const char *p = selective_vpath_search (v, file, mtime_ptr);
     533        if (p)
     534          return p;
     535      }
     536
     537  if (general_vpath != 0)
     538    {
     539      const char *p = selective_vpath_search (general_vpath, file, mtime_ptr);
     540      if (p)
     541        return p;
     542    }
     543
    564544  return 0;
    565545}
     
    571551print_vpath_data_base (void)
    572552{
    573   register unsigned int nvpaths;
    574   register struct vpath *v;
     553  unsigned int nvpaths;
     554  struct vpath *v;
    575555
    576556  puts (_("\n# VPATH Search Paths\n"));
     
    599579  else
    600580    {
    601       register char **path = general_vpath->searchpath;
    602       register unsigned int i;
     581      const char **path = general_vpath->searchpath;
     582      unsigned int i;
    603583
    604584      fputs (_("\n# General (`VPATH' variable) search path:\n# "), stdout);
  • vendor/gnumake/current/w32/include/pathstuff.h

    r501 r900  
    1919#define _PATHSTUFF_H
    2020
    21 extern char * convert_Path_to_windows32(char *Path, char to_delim);
    22 extern char * convert_vpath_to_windows32(char *Path, char to_delim);
    23 extern char * w32ify(char *file, int resolve);
    24 extern char * getcwd_fs(char *buf, int len);
     21char *convert_Path_to_windows32(char *Path, char to_delim);
     22char *convert_vpath_to_windows32(char *Path, char to_delim);
     23char *w32ify(const char *file, int resolve);
     24char *getcwd_fs(char *buf, int len);
    2525
    2626#endif
  • vendor/gnumake/current/w32/pathstuff.c

    r501 r900  
    8484 */
    8585char *
    86 w32ify(char *filename, int resolve)
     86w32ify(const char *filename, int resolve)
    8787{
    8888    static char w32_path[FILENAME_MAX];
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