Changeset 900 in kBuild
- Timestamp:
- May 23, 2007 3:13:11 AM (18 years ago)
- Location:
- vendor/gnumake/current
- Files:
-
- 27 added
- 126 deleted
- 48 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current/ChangeLog
r501 r900 1 2007-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 17 2007-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 39 2007-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 44 2007-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 59 2007-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 64 2006-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 93 2006-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 98 2006-10-22 Paul Smith <[email protected]> 99 100 * main.c (struct command_switch): Use const and void*. 101 102 2006-10-21 Paul Smith <[email protected]> 103 104 * ar.c: Constified. 105 * arscan.c: Constified. 106 107 2006-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 133 2006-09-06 Paul D. Smith <[email protected]> 134 135 * configure.in: Include sys/types.h when checking for sys/wait.h. 136 137 2006-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 151 2006-05-07 Paul D. Smith <[email protected]> 152 153 * README.OS2.template: Updates provided by Andreas Buening 154 <[email protected]>. 155 156 2006-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 161 2006-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 167 2006-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 173 2006-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 200 2006-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 1 217 2006-04-01 Paul D. Smith <[email protected]> 2 218 … … 54 270 (main): If we are re-execing, clean up the jobserver first so we 55 271 don't leak file descriptors. 56 Fix bug reported by Craig Fithian <[email protected]>.272 Reported by Craig Fithian <[email protected]> 57 273 58 274 2006-03-17 Paul D. Smith <[email protected]> -
vendor/gnumake/current/Makefile.am
r501 r900 17 17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 18 19 AUTOMAKE_OPTIONS = 1.8 dist-bzip2 check-news ansi2knr19 AUTOMAKE_OPTIONS = 1.8 dist-bzip2 check-news 20 20 ACLOCAL_AMFLAGS = -I config 21 21 -
vendor/gnumake/current/NEWS
r501 r900 9 9 See the README file and the GNU make manual for instructions for 10 10 reporting bugs. 11 12 13 Version 3.81.90 14 15 * Compiling GNU make now requires a conforming ISO C 1989 compiler and 16 standard runtime library. 17 11 18 12 19 -
vendor/gnumake/current/acinclude.m4
r501 r900 63 63 AC_CHECK_FUNCS(gethostbyname,,[ 64 64 CF_RECHECK_FUNC(gethostbyname,nsl,cf_cv_netlibs)]) 65 #66 AC_CHECK_FUNCS(strcasecmp,,[67 CF_RECHECK_FUNC(strcasecmp,resolv,cf_cv_netlibs)])68 65 ]) 69 66 LIBS="$LIBS $cf_cv_netlibs" -
vendor/gnumake/current/amiga.h
r501 r900 16 16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ 17 17 18 extern int MyExecute PARAMS ((char ** argv)); 19 extern char * wildcard_expansion PARAMS ((char * wc, char * o)); 20 18 int MyExecute (char ** argv); 19 char * wildcard_expansion (char * wc, char * o); -
vendor/gnumake/current/ar.c
r501 r900 25 25 #include <fnmatch.h> 26 26 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 VMS31 extern int ar_member_touch PARAMS ((char *arname, char *memname));32 #endif33 34 27 /* Return nonzero if NAME is an archive-member reference, zero if not. 35 28 An archive-member reference is a name like `lib(member)'. … … 38 31 39 32 int 40 ar_name (c har *name)41 { 42 c har *p = strchr (name, '(');43 c har *end;33 ar_name (const char *name) 34 { 35 const char *p = strchr (name, '('); 36 const char *end; 44 37 45 38 if (p == 0 || p == name) … … 58 51 59 52 /* 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. */ 62 55 63 56 void 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)); 57 ar_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 */ 73 static long int 74 ar_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 } 78 82 79 83 /* Return the modtime of NAME. */ 80 84 81 85 time_t 82 ar_member_date (c har *name)86 ar_member_date (const char *name) 83 87 { 84 88 char *arname; 85 int arname_used = 0;86 89 char *memname; 87 90 long int val; … … 100 103 arfile = lookup_file (arname); 101 104 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)); 106 106 107 107 if (arfile != 0) … … 109 109 } 110 110 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); 116 114 117 115 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 int124 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;130 116 } 131 117 … … 135 121 #ifdef VMS 136 122 int 137 ar_touch (c har *name)123 ar_touch (const char *name) 138 124 { 139 125 error (NILF, _("touch archive member is not available on VMS")); … … 142 128 #else 143 129 int 144 ar_touch (c har *name)130 ar_touch (const char *name) 145 131 { 146 132 char *arname, *memname; 147 int arname_used = 0; 148 register int val; 133 int val; 149 134 150 135 ar_parse_name (name, &arname, &memname); 151 136 152 137 /* 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. */ 154 139 { 155 140 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); 164 143 } 165 144 … … 188 167 } 189 168 190 if (!arname_used) 191 free (arname); 192 free (memname); 169 free (arname); 193 170 194 171 return val; … … 201 178 struct ar_glob_state 202 179 { 203 c har *arname;204 c har *pattern;180 const char *arname; 181 const char *pattern; 205 182 unsigned int size; 206 183 struct nameseq *chain; … … 212 189 213 190 static long int 214 ar_glob_match (int desc UNUSED, c har *mem, int truncated UNUSED,191 ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED, 215 192 long int hdrpos UNUSED, long int datapos UNUSED, 216 193 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 219 198 if (fnmatch (state->pattern, mem, FNM_PATHNAME|FNM_PERIOD) == 0) 220 199 { 221 200 /* 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, ")")); 224 203 new->next = state->chain; 225 204 state->chain = new; … … 267 246 268 247 struct nameseq * 269 ar_glob (c har *arname,char *member_pattern, unsigned int size)248 ar_glob (const char *arname, const char *member_pattern, unsigned int size) 270 249 { 271 250 struct ar_glob_state state; 272 char **names;273 251 struct nameseq *n; 252 const char **names; 253 char *name; 274 254 unsigned int i; 275 255 … … 280 260 ar_glob_match will accumulate them in STATE.chain. */ 281 261 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; 286 267 state.pattern = member_pattern; 287 268 state.size = size; 288 269 state.chain = 0; 289 270 state.n = 0; 290 (void) ar_scan (arname, ar_glob_match, (long int)&state);271 ar_scan (arname, ar_glob_match, &state); 291 272 292 273 if (state.chain == 0) … … 294 275 295 276 /* 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 *)); 297 278 i = 0; 298 279 for (n = state.chain; n != 0; n = n->next) … … 300 281 301 282 /* Sort them alphabetically. */ 302 qsort ( (char *)names, i, sizeof (*names), alpha_compare);283 qsort (names, i, sizeof (*names), alpha_compare); 303 284 304 285 /* Put them back into the chain in the sorted order. */ -
vendor/gnumake/current/arscan.c
r501 r900 26 26 27 27 #ifndef NO_ARCHIVES 28 29 28 30 29 #ifdef VMS … … 136 135 137 136 long int 138 ar_scan (c har *archive, long int (*function) PARAMS ((void)), long intarg)137 ar_scan (const char *archive, ar_member_func_t function, const void *arg) 139 138 { 140 139 char *p; … … 304 303 305 304 long int 306 ar_scan (c har *archive, long int (*function)(), long intarg)305 ar_scan (const char *archive, ar_member_func_t function, const void *arg) 307 306 { 308 307 #ifdef AIAMAG … … 316 315 #endif 317 316 char *namemap = 0; 318 registerint desc = open (archive, O_RDONLY, 0);317 int desc = open (archive, O_RDONLY, 0); 319 318 if (desc < 0) 320 319 return -1; … … 323 322 char buf[SARMAG]; 324 323 register int nread = read (desc, buf, SARMAG); 325 if (nread != SARMAG || bcmp (buf, ARMAG, SARMAG))324 if (nread != SARMAG || memcmp (buf, ARMAG, SARMAG)) 326 325 { 327 326 (void) close (desc); … … 332 331 #ifdef AIAMAG 333 332 { 334 register int nread = read (desc, (char *)&fl_header, FL_HSZ);333 register int nread = read (desc, &fl_header, FL_HSZ); 335 334 336 335 if (nread != FL_HSZ) … … 342 341 /* If this is a "big" archive, then set the flag and 343 342 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)) 345 344 { 346 345 big_archive = 1; … … 354 353 355 354 /* 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); 357 356 if (nread != FL_HSZ_BIG) 358 357 { … … 364 363 #endif 365 364 /* 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)) 367 366 { 368 367 (void) close (desc); … … 458 457 if (big_archive) 459 458 { 460 nread = read (desc, (char *)&member_header_big,459 nread = read (desc, &member_header_big, 461 460 AR_MEMHDR_SZ(member_header_big) ); 462 461 … … 490 489 #endif 491 490 { 492 nread = read (desc, (char *)&member_header,491 nread = read (desc, &member_header, 493 492 AR_MEMHDR_SZ(member_header) ); 494 493 … … 528 527 529 528 #else /* Not AIAMAG. */ 530 nread = read (desc, (char *)&member_header, AR_HDR_SIZE);529 nread = read (desc, &member_header, AR_HDR_SIZE); 531 530 if (nread == 0) 532 531 /* No data left means end of file; that is OK. */ … … 537 536 || ( 538 537 # ifdef ARFMAG 539 bcmp (member_header.ar_fmag, ARFMAG, 2)538 memcmp (member_header.ar_fmag, ARFMAG, 2) 540 539 # else 541 540 1 … … 543 542 && 544 543 # ifdef ARFZMAG 545 bcmp (member_header.ar_fmag, ARFZMAG, 2)544 memcmp (member_header.ar_fmag, ARFZMAG, 2) 546 545 # else 547 546 1 … … 556 555 557 556 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); 559 558 { 560 559 register char *p = name + sizeof member_header.ar_name; … … 596 595 int namesize = atoi (name + 3); 597 596 598 name = (char *)alloca (namesize + 1);597 name = alloca (namesize + 1); 599 598 nread = read (desc, name, namesize); 600 599 if (nread != namesize) … … 667 666 char *limit; 668 667 669 namemap = (char *)alloca (eltsize);668 namemap = alloca (eltsize); 670 669 nread = read (desc, namemap, eltsize); 671 670 if (nread != eltsize) … … 710 709 711 710 int 712 ar_name_equal (c har *name,char *mem, int truncated)711 ar_name_equal (const char *name, const char *mem, int truncated) 713 712 { 714 c har *p;713 const char *p; 715 714 716 715 p = strrchr (name, '/'); … … 742 741 /* ARGSUSED */ 743 742 static long int 744 ar_member_pos (int desc UNUSED, c har *mem, int truncated,743 ar_member_pos (int desc UNUSED, const char *mem, int truncated, 745 744 long int hdrpos, long int datapos UNUSED, long int size UNUSED, 746 745 long int date UNUSED, int uid UNUSED, int gid UNUSED, 747 int mode UNUSED, c har*name)746 int mode UNUSED, const void *name) 748 747 { 749 748 if (!ar_name_equal (name, mem, truncated)) … … 760 759 761 760 int 762 ar_member_touch (c har *arname,char *memname)761 ar_member_touch (const char *arname, const char *memname) 763 762 { 764 long int pos = ar_scan (arname, ar_member_pos, (long int)memname);763 long int pos = ar_scan (arname, ar_member_pos, memname); 765 764 int fd; 766 765 struct ar_hdr ar_hdr; … … 780 779 if (lseek (fd, pos, 0) < 0) 781 780 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)) 783 782 goto lose; 784 783 /* Write back the header, thus touching the archive file. */ 785 784 if (lseek (fd, pos, 0) < 0) 786 785 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)) 788 787 goto lose; 789 788 /* The file's mtime is the time we we want. */ … … 805 804 if (lseek (fd, pos, 0) < 0) 806 805 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)) 808 807 goto lose; 809 808 close (fd); … … 822 821 823 822 long int 824 describe_member (int desc, c har *name, int truncated,823 describe_member (int desc, const char *name, int truncated, 825 824 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) 827 826 { 828 827 extern char *ctime (); … … 840 839 main (int argc, char **argv) 841 840 { 842 ar_scan (argv[1], describe_member );841 ar_scan (argv[1], describe_member, NULL); 843 842 return 0; 844 843 } -
vendor/gnumake/current/commands.c
r501 r900 34 34 #endif 35 35 36 extern int remote_kill PARAMS ((int id, int sig));36 int remote_kill (int id, int sig); 37 37 38 38 #ifndef HAVE_UNISTD_H 39 externint getpid ();39 int getpid (); 40 40 #endif 41 41 … … 46 46 set_file_variables (struct file *file) 47 47 { 48 struct dep *d;49 c har *at, *percent, *star, *less;48 const struct dep *d; 49 const char *at, *percent, *star, *less; 50 50 51 51 #ifndef NO_ARCHIVES … … 56 56 { 57 57 unsigned int len; 58 const char *cp; 58 59 char *p; 59 60 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; 68 71 } 69 72 else … … 80 83 any suffix in the .SUFFIXES list stripped off for 81 84 explicit rules. We store this in the `stem' member. */ 82 register struct dep *d; 83 char *name; 85 const char *name; 84 86 unsigned int len; 85 87 … … 97 99 } 98 100 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) 100 102 { 101 103 unsigned int slen = strlen (dep_name (d)); 102 104 if (len > slen && strneq (dep_name (d), name + (len - slen), slen)) 103 105 { 104 file->stem = s avestring(name, len - slen);106 file->stem = strcache_add_len (name, len - slen); 105 107 break; 106 108 } … … 139 141 { 140 142 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; 142 144 143 145 unsigned int qmark_len, plus_len, bar_len; … … 166 168 if (! d->ignore_mtime) 167 169 { 168 c har *c = dep_name (d);170 const char *c = dep_name (d); 169 171 170 172 #ifndef NO_ARCHIVES … … 178 180 len = strlen (c); 179 181 180 bcopy (c, cp, len);182 memcpy (cp, c, len); 181 183 cp += len; 182 184 *cp++ = FILE_LIST_SEPARATOR; … … 217 219 for (d = file->deps; d != 0; d = d->next) 218 220 { 219 c har *c = dep_name (d);221 const char *c = dep_name (d); 220 222 221 223 #ifndef NO_ARCHIVES … … 231 233 if (d->ignore_mtime) 232 234 { 233 bcopy (c, bp, len);235 memcpy (bp, c, len); 234 236 bp += len; 235 237 *bp++ = FILE_LIST_SEPARATOR; … … 237 239 else 238 240 { 239 bcopy (c, cp, len);241 memcpy (cp, c, len); 240 242 cp += len; 241 243 *cp++ = FILE_LIST_SEPARATOR; 242 244 if (d->changed) 243 245 { 244 bcopy (c, qp, len);246 memcpy (qp, c, len); 245 247 qp += len; 246 248 *qp++ = FILE_LIST_SEPARATOR; … … 271 273 chop_commands (struct commands *cmds) 272 274 { 273 registerchar *p;275 const char *p; 274 276 unsigned int nlines, idx; 275 277 char **lines; … … 286 288 287 289 nlines = 5; 288 lines = (char **)xmalloc (5 * sizeof (char *));290 lines = xmalloc (5 * sizeof (char *)); 289 291 idx = 0; 290 292 p = cmds->commands; 291 293 while (*p != '\0') 292 294 { 293 c har *end = p;295 const char *end = p; 294 296 find_end:; 295 297 end = strchr (end, '\n'); … … 299 301 { 300 302 int backslash = 1; 301 registerchar *b;303 const char *b; 302 304 for (b = end - 2; b >= p && *b == '\\'; --b) 303 305 backslash = !backslash; … … 312 314 { 313 315 nlines += 2; 314 lines = (char **) xrealloc ((char *) lines, 315 nlines * sizeof (char *)); 316 lines = xrealloc (lines, nlines * sizeof (char *)); 316 317 } 317 318 lines[idx++] = savestring (p, end - p); … … 324 325 { 325 326 nlines = idx; 326 lines = (char **) xrealloc ((char *) lines, 327 nlines * sizeof (char *)); 327 lines = xrealloc (lines, nlines * sizeof (char *)); 328 328 } 329 329 … … 332 332 333 333 cmds->any_recurse = 0; 334 cmds->lines_flags = (char *)xmalloc (nlines);334 cmds->lines_flags = xmalloc (nlines); 335 335 for (idx = 0; idx < nlines; ++idx) 336 336 { … … 371 371 execute_file_commands (struct file *file) 372 372 { 373 registerchar *p;373 const char *p; 374 374 375 375 /* Don't go through all the preparations if … … 460 460 if (sig == SIGTERM) 461 461 { 462 registerstruct child *c;462 struct child *c; 463 463 for (c = children; c != 0; c = c->next) 464 464 if (!c->remote) … … 478 478 ) 479 479 { 480 registerstruct child *c;480 struct child *c; 481 481 482 482 /* Remote children won't automatically get signals sent … … 531 531 532 532 static void 533 delete_target (struct file *file, c har *on_behalf_of)533 delete_target (struct file *file, const char *on_behalf_of) 534 534 { 535 535 struct stat st; … … 586 586 587 587 /* Delete the target file if it changed. */ 588 delete_target (child->file, (char *) 0);588 delete_target (child->file, NULL); 589 589 590 590 /* Also remove any non-precious targets listed in the `also_make' member. */ … … 599 599 600 600 void 601 print_commands ( struct commands *cmds)601 print_commands (const struct commands *cmds) 602 602 { 603 registerchar *s;603 const char *s; 604 604 605 605 fputs (_("# commands to execute"), stdout); … … 614 614 while (*s != '\0') 615 615 { 616 c har *end;616 const char *end; 617 617 618 618 while (isspace ((unsigned char)*s)) -
vendor/gnumake/current/commands.h
r501 r900 36 36 #define COMMANDS_NOERROR 4 /* No errors: -. */ 37 37 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));38 void execute_file_commands (struct file *file); 39 void print_commands (const struct commands *cmds); 40 void delete_child_targets (struct child *child); 41 void chop_commands (struct commands *cmds); 42 void set_file_variables (struct file *file); -
vendor/gnumake/current/config/dospaths.m4
r501 r900 23 23 [ 24 24 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__ 26 26 neither MSDOS nor Windows nor OS2 27 27 #endif -
vendor/gnumake/current/configure.in
r501 r900 17 17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 18 19 AC_INIT([GNU make],[3.81 ],[[email protected]])19 AC_INIT([GNU make],[3.81.90],[[email protected]]) 20 20 21 21 AC_PREREQ(2.59) 22 AC_REVISION([[$Id: configure.in,v 1.14 2 2006/04/01 06:36:40psmith Exp $]])22 AC_REVISION([[$Id: configure.in,v 1.147 2007/05/09 02:01:53 psmith Exp $]]) 23 23 24 24 # Autoconf setup … … 45 45 AC_MINIX 46 46 47 # Needed for ansi2knr48 AM_C_PROTOTYPES49 50 47 # Enable gettext, in "external" mode. 51 48 … … 72 69 if test "$ac_cv_prog_cc_stdc" != no; then 73 70 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.]) 75 72 fi 76 73 … … 123 120 if test "$ac_cv_search_clock_gettime" != no; then 124 121 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.]) 126 123 fi 127 124 fi … … 147 144 if test "$ac_cv_func_gettimeofday" = yes; then 148 145 AC_DEFINE(HAVE_GETTIMEOFDAY, 1, 149 [Define if you have a standard gettimeofday function])150 fi 151 152 AC_CHECK_FUNCS( memcpy memmove strchrstrdup mkstemp mktemp fdopen \146 [Define to 1 if you have a standard gettimeofday function]) 147 fi 148 149 AC_CHECK_FUNCS( strdup mkstemp mktemp fdopen \ 153 150 bsd_signal dup2 getcwd realpath sigsetmask sigaction \ 154 151 getgroups seteuid setegid setlinebuf setreuid setregid \ … … 157 154 158 155 AC_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. 160 AC_CHECK_FUNCS(strcasecmp strcmpi stricmp) 159 161 160 162 # strcoll() is used by the GNU glob library … … 180 182 if test "$make_cv_nlist_struct" = yes; then 181 183 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.]) 183 185 fi 184 186 fi … … 195 197 196 198 # Check out the wait reality. 197 AC_CHECK_HEADERS(sys/wait.h )199 AC_CHECK_HEADERS(sys/wait.h,,,[[#include <sys/types.h>]]) 198 200 AC_CHECK_FUNCS(waitpid wait3) 199 201 AC_MSG_CHECKING(for union wait) … … 221 223 if test "$make_cv_union_wait" = yes; then 222 224 AC_DEFINE(HAVE_UNION_WAIT, 1, 223 [Define t hisif 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>.]) 224 226 fi 225 227 AC_MSG_RESULT($make_cv_union_wait) … … 229 231 if test "$PATH_SEPARATOR" = ';'; then 230 232 AC_DEFINE(HAVE_DOS_PATHS, 1, 231 [Define t hisif your system requires backslashes or drive specs in pathnames.])233 [Define to 1 if your system requires backslashes or drive specs in pathnames.]) 232 234 fi 233 235 … … 265 267 AC_ARG_ENABLE(case-insensitive-file-system, 266 268 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]) 270 273 271 274 # See if we can handle the job server feature, and if the user wants it. … … 290 293 if test "$make_cv_sa_restart" != no; then 291 294 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.]) 293 296 fi 294 297 … … 302 305 yes/yes/yes/yes/yes) 303 306 AC_DEFINE(MAKE_JOBSERVER, 1, 304 [Define t histo enable job server support in GNU make.]);;307 [Define to 1 to enable job server support in GNU make.]);; 305 308 esac 306 309 … … 310 313 yes/yes) 311 314 AC_DEFINE(MAKE_SYMLINKS, 1, 312 [Define t histo enable symbolic link timestamp checking.]);;315 [Define to 1 to enable symbolic link timestamp checking.]);; 313 316 esac 314 317 … … 337 340 case "$make_cv_sys_get_minus_G" in 338 341 yes) AC_DEFINE(SCCS_GET_MINUS_G, 1, 339 [Define t hisif the SCCS 'get' command understands the '-G<file>' option.]);;342 [Define to 1 if the SCCS 'get' command understands the '-G<file>' option.]);; 340 343 esac 341 344 fi … … 385 388 esac 386 389 390 AC_DEFINE_UNQUOTED(PATH_SEPARATOR_CHAR,'$PATH_SEPARATOR',[Define to the character that separates directories in PATH.]) 391 387 392 # Include the Maintainer's Makefile section, if it's here. 388 393 -
vendor/gnumake/current/default.c
r501 r900 42 42 .w .ch .cweb .web .com .sh .elc .el"; 43 43 #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 \ 45 45 .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \ 46 46 .w .ch .web .sh .elc .el .obj .exe .dll .lib"; 47 47 #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 \ 49 49 .mod .sym .def .h .info .dvi .tex .texinfo .texi .txinfo \ 50 50 .w .ch .web .sh .elc .el"; … … 193 193 ".f", 194 194 "$(LINK.f) $^ $(LOADLIBES) $(LDLIBS) -o $@", 195 ".m", 196 "$(LINK.m) $^ $(LOADLIBES) $(LDLIBS) -o $@", 195 197 ".p", 196 198 "$(LINK.p) $^ $(LOADLIBES) $(LDLIBS) -o $@", … … 222 224 ".f.o", 223 225 "$(COMPILE.f) $(OUTPUT_OPTION) $<", 226 ".m.o", 227 "$(COMPILE.m) $(OUTPUT_OPTION) $<", 224 228 ".p.o", 225 229 "$(COMPILE.p) $(OUTPUT_OPTION) $<", … … 250 254 ".l.c", 251 255 "@$(RM) $@ \n $(LEX.l) $< > $@", 256 ".ym.m", 257 "$(YACC.m) $< \n mv -f y.tab.c $@", 258 ".lm.m", 259 "@$(RM) $@ \n $(LEX.m) $< > $@", 252 260 253 261 ".F.f", … … 256 264 "$(PREPROCESS.r) $(OUTPUT_OPTION) $<", 257 265 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? */ 261 268 ".l.r", 262 269 "$(LEX.l) $< > $@ \n mv -f lex.yy.r $@", … … 303 310 }; 304 311 305 static c har *default_variables[] =312 static const char *default_variables[] = 306 313 { 307 314 #ifdef VMS … … 399 406 "CXX", "gcc", 400 407 # endif /* __MSDOS__ */ 408 "OBJC", "gcc", 401 409 #else 402 410 "CC", "cc", 403 411 "CXX", "g++", 412 "OBJC", "cc", 404 413 #endif 405 414 … … 469 478 "COMPILE.c", "$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c", 470 479 "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)", 471 482 "COMPILE.cc", "$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c", 472 483 "COMPILE.C", "$(COMPILE.cc)", … … 477 488 "YACC.y", "$(YACC) $(YFLAGS)", 478 489 "LEX.l", "$(LEX) $(LFLAGS) -t", 490 "YACC.m", "$(YACC) $(YFLAGS)", 491 "LEX.m", "$(LEX) $(LFLAGS) -t", 479 492 "COMPILE.f", "$(FC) $(FFLAGS) $(TARGET_ARCH) -c", 480 493 "LINK.f", "$(FC) $(FFLAGS) $(LDFLAGS) $(TARGET_ARCH)", … … 524 537 set_default_suffixes (void) 525 538 { 526 suffix_file = enter_file ( ".SUFFIXES");539 suffix_file = enter_file (strcache_add (".SUFFIXES")); 527 540 528 541 if (no_builtin_rules_flag) 529 (void)define_variable ("SUFFIXES", 8, "", o_default, 0);542 define_variable ("SUFFIXES", 8, "", o_default, 0); 530 543 else 531 544 { … … 534 547 multi_glob (parse_file_seq (&p, '\0', sizeof (struct dep), 1), 535 548 sizeof (struct dep)); 536 (void)define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0);549 define_variable ("SUFFIXES", 8, default_suffixes, o_default, 0); 537 550 } 538 551 } … … 540 553 /* Enter the default suffix rules as file rules. This used to be done in 541 554 install_default_implicit_rules, but that loses because we want the 542 suffix rules installed before reading makefiles, and the epattern rules555 suffix rules installed before reading makefiles, and the pattern rules 543 556 installed after. */ 544 557 … … 546 559 install_default_suffix_rules (void) 547 560 { 548 registerchar **s;561 char **s; 549 562 550 563 if (no_builtin_rules_flag) 551 564 return; 552 565 553 for (s = default_suffix_rules; *s != 0; s += 2)566 for (s = default_suffix_rules; *s != 0; s += 2) 554 567 { 555 register struct file *f = enter_file (s[0]);568 struct file *f = enter_file (strcache_add (s[0])); 556 569 /* Don't clobber cmds given in a makefile if there were any. */ 557 570 if (f->cmds == 0) 558 571 { 559 f->cmds = (struct commands *)xmalloc (sizeof (struct commands));572 f->cmds = xmalloc (sizeof (struct commands)); 560 573 f->cmds->fileinfo.filenm = 0; 561 574 f->cmds->commands = s[1]; … … 571 584 install_default_implicit_rules (void) 572 585 { 573 registerstruct pspec *p;586 struct pspec *p; 574 587 575 588 if (no_builtin_rules_flag) … … 586 599 define_default_variables (void) 587 600 { 588 registerchar **s;601 const char **s; 589 602 590 603 if (no_builtin_variables_flag) … … 592 605 593 606 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); 595 608 } -
vendor/gnumake/current/dep.h
r501 r900 37 37 { 38 38 struct dep *next; 39 c har *name;40 c har *stem;39 const char *name; 40 const char *stem; 41 41 struct file *file; 42 42 unsigned int changed : 8; … … 52 52 { 53 53 struct nameseq *next; 54 c har *name;54 const char *name; 55 55 }; 56 56 57 57 58 extern struct nameseq *multi_glob PARAMS ((struct nameseq *chain, unsigned int size));58 struct nameseq *multi_glob (struct nameseq *chain, unsigned int size); 59 59 #ifdef VMS 60 externstruct nameseq *parse_file_seq ();60 struct nameseq *parse_file_seq (); 61 61 #else 62 extern struct nameseq *parse_file_seq PARAMS ((char **stringp, int stopchar, unsigned int size, int strip));62 struct nameseq *parse_file_seq (char **stringp, int stopchar, unsigned int size, int strip); 63 63 #endif 64 extern char *tilde_expand PARAMS ((char *name));64 char *tilde_expand (const char *name); 65 65 66 66 #ifndef NO_ARCHIVES 67 extern struct nameseq *ar_glob PARAMS ((char *arname, char *member_pattern, unsigned int size));67 struct nameseq *ar_glob (const char *arname, const char *member_pattern, unsigned int size); 68 68 #endif 69 69 70 #ifndef iAPX28671 70 #define dep_name(d) ((d)->name == 0 ? (d)->file->name : (d)->name) 72 #else73 /* Buggy compiler can't hack this. */74 extern char *dep_name ();75 #endif76 71 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 *));72 struct dep *alloc_dep (void); 73 void free_dep (struct dep *d); 74 struct dep *copy_dep_chain (const struct dep *d); 75 void free_dep_chain (struct dep *d); 76 void free_ns_chain (struct nameseq *n); 77 struct dep *read_all_makefiles (const char **makefiles); 78 int eval_buffer (char *buffer); 79 int update_goal_chain (struct dep *goals); 80 void uniquize_deps (struct dep *); -
vendor/gnumake/current/dir.c
r501 r900 24 24 # define NAMLEN(dirent) strlen((dirent)->d_name) 25 25 # ifdef VMS 26 extern char *vmsify PARAMS ((char *name, int type));26 char *vmsify (char *name, int type); 27 27 # endif 28 28 #else … … 69 69 #endif 70 70 71 static c har *72 dosify (c har *filename)71 static const char * 72 dosify (const char *filename) 73 73 { 74 74 static char dos_filename[14]; … … 119 119 120 120 #ifdef HAVE_CASE_INSENSITIVE_FS 121 static c har *122 downcase (c har *filename)121 static const char * 122 downcase (const char *filename) 123 123 { 124 124 static PATH_VAR (new_filename); … … 132 132 133 133 /* 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 } 139 139 140 140 *df = 0; … … 217 217 dev_t dev; /* Device and inode numbers of this dir. */ 218 218 #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. */ 227 224 char *path_key; 228 225 int ctime; 229 226 int mtime; /* controls check for stale directory cache */ 230 227 int fs_flags; /* FS_FAT, FS_NTFS, ... */ 231 # define FS_FAT 0x1232 # define FS_NTFS 0x2233 # define FS_UNKNOWN 0x4234 #else 235 # ifdef VMS228 # define FS_FAT 0x1 229 # define FS_NTFS 0x2 230 # define FS_UNKNOWN 0x4 231 #else 232 # ifdef VMS 236 233 ino_t ino[3]; 237 # else234 # else 238 235 ino_t ino; 239 # endif236 # endif 240 237 #endif /* WINDOWS32 */ 241 238 struct hash_table dirfiles; /* Files in this directory. */ … … 246 243 directory_contents_hash_1 (const void *key_0) 247 244 { 248 struct directory_contents const *key = (struct directory_contents const *)key_0;245 const struct directory_contents *key = key_0; 249 246 unsigned long hash; 250 247 … … 269 266 directory_contents_hash_2 (const void *key_0) 270 267 { 271 struct directory_contents const *key = (struct directory_contents const *)key_0;268 const struct directory_contents *key = key_0; 272 269 unsigned long hash; 273 270 … … 304 301 directory_contents_hash_cmp (const void *xv, const void *yv) 305 302 { 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; 308 305 int result; 309 306 … … 341 338 struct directory 342 339 { 343 c har *name; /* Name of the directory. */340 const char *name; /* Name of the directory. */ 344 341 345 342 /* The directory's contents. This data may be shared by several … … 352 349 directory_hash_1 (const void *key) 353 350 { 354 return_ISTRING_HASH_1 ((( struct directory const*) key)->name);351 return_ISTRING_HASH_1 (((const struct directory *) key)->name); 355 352 } 356 353 … … 358 355 directory_hash_2 (const void *key) 359 356 { 360 return_ISTRING_HASH_2 ((( struct directory const*) key)->name);357 return_ISTRING_HASH_2 (((const struct directory *) key)->name); 361 358 } 362 359 … … 364 361 directory_hash_cmp (const void *x, const void *y) 365 362 { 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); 368 365 } 369 366 … … 382 379 struct dirfile 383 380 { 384 c har *name;/* Name of the file. */381 const char *name; /* Name of the file. */ 385 382 short length; 386 383 short impossible; /* This file is impossible. */ … … 402 399 dirfile_hash_cmp (const void *xv, const void *yv) 403 400 { 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; 406 403 int result = x->length - y->length; 407 404 if (result) … … 415 412 416 413 417 static int dir_contents_file_exists_p PARAMS ((struct directory_contents *dir, char *filename)); 418 static struct directory *find_directory PARAMS ((char *name)); 414 static int dir_contents_file_exists_p (struct directory_contents *dir, 415 const char *filename); 416 static struct directory *find_directory (const char *name); 419 417 420 418 /* Find the directory named NAME and return its `struct directory'. */ 421 419 422 420 static struct directory * 423 find_directory (c har *name)424 { 425 registerchar *p;426 registerstruct directory *dir;427 registerstruct directory **dir_slot;421 find_directory (const char *name) 422 { 423 const char *p; 424 struct directory *dir; 425 struct directory **dir_slot; 428 426 struct directory dir_key; 429 427 int r; … … 454 452 455 453 p = name + strlen (name); 456 dir = (struct directory *)xmalloc (sizeof (struct directory));457 dir->name = s avestring(name, p - name);454 dir = xmalloc (sizeof (struct directory)); 455 dir->name = strcache_add_len (name, p - name); 458 456 hash_insert_at (&directories, dir, dir_slot); 459 457 /* The directory is not in the name hash table. … … 553 551 ENULLLOOP (dc->dirstream, opendir (name)); 554 552 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. */ 557 555 dc->dirfiles.ht_vec = 0; 558 556 else … … 565 563 /* We have too many directories open already. 566 564 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); 568 566 } 569 567 } … … 582 580 583 581 static int 584 dir_contents_file_exists_p (struct directory_contents *dir, char *filename) 582 dir_contents_file_exists_p (struct directory_contents *dir, 583 const char *filename) 585 584 { 586 585 unsigned int hash; … … 593 592 594 593 if (dir == 0 || dir->dirfiles.ht_vec == 0) 595 {596 594 /* The directory could not be stat'd or opened. */ 597 598 } 595 return 0; 596 599 597 #ifdef __MSDOS__ 600 598 filename = dosify (filename); … … 626 624 dirfile_key.name = filename; 627 625 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); 629 627 if (df) 630 { 631 return !df->impossible; 632 } 628 return !df->impossible; 633 629 } 634 630 … … 651 647 rehash = 1; 652 648 } 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) 654 650 { 655 651 /* reset date stamp to show most recent re-process. */ … … 663 659 664 660 /* make sure directory can still be opened; if not return. */ 665 dir->dirstream = opendir (dir->path_key);661 dir->dirstream = opendir (dir->path_key); 666 662 if (!dir->dirstream) 667 663 return 0; … … 682 678 ENULLLOOP (d, readdir (dir->dirstream)); 683 679 if (d == 0) 684 break; 680 { 681 if (errno) 682 fatal (NILF, "INTERNAL: readdir: %s\n", strerror (errno)); 683 break; 684 } 685 685 686 686 #if defined(VMS) && defined(HAVE_DIRENT_H) … … 707 707 #endif 708 708 { 709 df = (struct dirfile *)xmalloc (sizeof (struct dirfile));710 df->name = s avestring(d->d_name, len);709 df = xmalloc (sizeof (struct dirfile)); 710 df->name = strcache_add_len (d->d_name, len); 711 711 df->length = len; 712 712 df->impossible = 0; … … 715 715 /* Check if the name matches the one we're searching for. */ 716 716 if (filename != 0 && strieq (d->d_name, filename)) 717 { 718 return 1; 719 } 717 return 1; 720 718 } 721 719 … … 736 734 737 735 int 738 dir_file_exists_p (c har *dirname,char *filename)736 dir_file_exists_p (const char *dirname, const char *filename) 739 737 { 740 738 return dir_contents_file_exists_p (find_directory (dirname)->contents, … … 746 744 747 745 int 748 file_exists_p (c har *name)749 { 750 c har *dirend;751 c har *dirname;752 c har *slash;746 file_exists_p (const char *name) 747 { 748 const char *dirend; 749 const char *dirname; 750 const char *slash; 753 751 754 752 #ifndef NO_ARCHIVES … … 761 759 if (dirend == 0) 762 760 dirend = strrchr (name, ':'); 763 if (dirend == (char *)0)761 if (dirend == 0) 764 762 return dir_file_exists_p ("[]", name); 765 763 #else /* !VMS */ … … 768 766 /* Forward and backslashes might be mixed. We need the rightmost one. */ 769 767 { 770 c har *bslash = strrchr(name, '\\');768 const char *bslash = strrchr(name, '\\'); 771 769 if (!dirend || bslash > dirend) 772 770 dirend = bslash; … … 789 787 else 790 788 { 789 char *p; 791 790 #ifdef HAVE_DOS_PATHS 792 791 /* d:/ and d: are *very* different... */ … … 795 794 dirend++; 796 795 #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; 800 800 } 801 801 return dir_file_exists_p (dirname, slash + 1); … … 808 808 809 809 void 810 file_impossible (c har *filename)811 { 812 c har *dirend;813 registerchar *p = filename;814 registerstruct directory *dir;815 registerstruct dirfile *new;810 file_impossible (const char *filename) 811 { 812 const char *dirend; 813 const char *p = filename; 814 struct directory *dir; 815 struct dirfile *new; 816 816 817 817 #ifdef VMS … … 827 827 /* Forward and backslashes might be mixed. We need the rightmost one. */ 828 828 { 829 c har *bslash = strrchr(p, '\\');829 const char *bslash = strrchr(p, '\\'); 830 830 if (!dirend || bslash > dirend) 831 831 dirend = bslash; … … 844 844 else 845 845 { 846 c har *dirname;847 c har *slash = dirend;846 const char *dirname; 847 const char *slash = dirend; 848 848 if (dirend == p) 849 849 dirname = "/"; 850 850 else 851 851 { 852 char *cp; 852 853 #ifdef HAVE_DOS_PATHS 853 854 /* d:/ and d: are *very* different... */ … … 856 857 dirend++; 857 858 #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; 861 863 } 862 864 dir = find_directory (dirname); … … 868 870 /* The directory could not be stat'd. We allocate a contents 869 871 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)); 873 874 } 874 875 … … 881 882 /* Make a new entry and put it in the table. */ 882 883 883 new = (struct dirfile *) xmalloc (sizeof (struct dirfile)); 884 new->name = xstrdup (filename); 884 new = xmalloc (sizeof (struct dirfile)); 885 885 new->length = strlen (filename); 886 new->name = strcache_add_len (filename, new->length); 886 887 new->impossible = 1; 887 888 hash_insert (&dir->contents->dirfiles, new); … … 892 893 893 894 int 894 file_impossible_p (c har *filename)895 { 896 c har *dirend;897 registerchar *p = filename;898 registerstruct directory_contents *dir;899 registerstruct dirfile *dirfile;895 file_impossible_p (const char *filename) 896 { 897 const char *dirend; 898 const char *p = filename; 899 struct directory_contents *dir; 900 struct dirfile *dirfile; 900 901 struct dirfile dirfile_key; 901 902 … … 909 910 /* Forward and backslashes might be mixed. We need the rightmost one. */ 910 911 { 911 c har *bslash = strrchr(filename, '\\');912 const char *bslash = strrchr(filename, '\\'); 912 913 if (!dirend || bslash > dirend) 913 914 dirend = bslash; … … 926 927 else 927 928 { 928 c har *dirname;929 c har *slash = dirend;929 const char *dirname; 930 const char *slash = dirend; 930 931 if (dirend == filename) 931 932 dirname = "/"; 932 933 else 933 934 { 935 char *cp; 934 936 #ifdef HAVE_DOS_PATHS 935 937 /* d:/ and d: are *very* different... */ … … 938 940 dirend++; 939 941 #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; 943 946 } 944 947 dir = find_directory (dirname)->contents; … … 962 965 dirfile_key.name = filename; 963 966 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); 965 968 if (dirfile) 966 969 return dirfile->impossible; … … 973 976 directory hash table that matches DIR. */ 974 977 975 c har *976 dir_name (c har *dir)978 const char * 979 dir_name (const char *dir) 977 980 { 978 981 return find_directory (dir)->name; … … 985 988 print_dir_data_base (void) 986 989 { 987 registerunsigned int files;988 registerunsigned int impossible;989 registerstruct directory **dir_slot;990 registerstruct directory **dir_end;990 unsigned int files; 991 unsigned int impossible; 992 struct directory **dir_slot; 993 struct directory **dir_end; 991 994 992 995 puts (_("\n# Directories\n")); … … 998 1001 for ( ; dir_slot < dir_end; dir_slot++) 999 1002 { 1000 registerstruct directory *dir = *dir_slot;1003 struct directory *dir = *dir_slot; 1001 1004 if (! HASH_VACANT (dir)) 1002 1005 { … … 1023 1026 else 1024 1027 { 1025 registerunsigned int f = 0;1026 registerunsigned int im = 0;1027 registerstruct dirfile **files_slot;1028 registerstruct dirfile **files_end;1028 unsigned int f = 0; 1029 unsigned int im = 0; 1030 struct dirfile **files_slot; 1031 struct dirfile **files_end; 1029 1032 1030 1033 files_slot = (struct dirfile **) dir->contents->dirfiles.ht_vec; … … 1032 1035 for ( ; files_slot < files_end; files_slot++) 1033 1036 { 1034 registerstruct dirfile *df = *files_slot;1037 struct dirfile *df = *files_slot; 1035 1038 if (! HASH_VACANT (df)) 1036 1039 { … … 1103 1106 1104 1107 /* Forward declarations. */ 1105 static __ptr_t open_dirstream PARAMS ((const char *));1106 static struct dirent *read_dirstream PARAMS ((__ptr_t));1108 static __ptr_t open_dirstream (const char *); 1109 static struct dirent *read_dirstream (__ptr_t); 1107 1110 1108 1111 static __ptr_t … … 1110 1113 { 1111 1114 struct dirstream *new; 1112 struct directory *dir = find_directory ( (char *)directory);1115 struct directory *dir = find_directory (directory); 1113 1116 1114 1117 if (dir->contents == 0 || dir->contents->dirfiles.ht_vec == 0) … … 1120 1123 in being lazy, since glob will want to see every file anyway. */ 1121 1124 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)); 1125 1128 new->contents = dir->contents; 1126 1129 new->dirfile_slot = (struct dirfile **) new->contents->dirfiles.ht_vec; … … 1132 1135 read_dirstream (__ptr_t stream) 1133 1136 { 1137 static char *buf; 1138 static unsigned int bufsz; 1139 1134 1140 struct dirstream *const ds = (struct dirstream *) stream; 1135 1141 struct directory_contents *dc = ds->contents; 1136 1142 struct dirfile **dirfile_end = (struct dirfile **) dc->dirfiles.ht_vec + dc->dirfiles.ht_size; 1137 static char *buf;1138 static unsigned int bufsz;1139 1143 1140 1144 while (ds->dirfile_slot < dirfile_end) 1141 1145 { 1142 registerstruct dirfile *df = *ds->dirfile_slot++;1146 struct dirfile *df = *ds->dirfile_slot++; 1143 1147 if (! HASH_VACANT (df) && !df->impossible) 1144 1148 { 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. */ 1147 1150 struct dirent *d; 1148 1151 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) 1150 1154 { 1151 if (buf != 0)1152 free (buf);1153 1155 bufsz *= 2; 1154 if (s izeof *d - sizeof d->d_name + len> bufsz)1155 bufsz = s izeof *d - sizeof d->d_name + len;1156 buf = x malloc (bufsz);1156 if (sz > bufsz) 1157 bufsz = sz; 1158 buf = xrealloc (buf, bufsz); 1157 1159 } 1158 1160 d = (struct dirent *) buf; … … 1191 1193 #ifndef stat 1192 1194 # ifndef VMS 1193 extern int stat PARAMS ((const char *path, struct stat *sbuf));1195 int stat (const char *path, struct stat *sbuf); 1194 1196 # endif 1195 1197 # define local_stat stat … … 1208 1210 dir_setup_glob (glob_t *gl) 1209 1211 { 1210 /* Bogus sunos4 compiler complains (!) about & before functions. */1211 1212 gl->gl_opendir = open_dirstream; 1212 1213 gl->gl_readdir = read_dirstream; … … 1223 1224 directory_hash_1, directory_hash_2, directory_hash_cmp); 1224 1225 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 5 5 @include version.texi 6 6 @set EDITION 0.70 7 @set RCSID $Id: make.texi,v 1.4 5 2006/04/01 06:36:40psmith Exp $7 @set RCSID $Id: make.texi,v 1.47 2007/05/11 20:57:21 psmith Exp $ 8 8 9 9 @settitle GNU @code{make} … … 51 51 52 52 53 @dircategory GNU Packages53 @dircategory Software development 54 54 @direntry 55 55 * Make: (make). Remake files automatically. … … 1010 1010 specially in certain situations. 1011 1011 1012 You cannot use comments within variable references or function calls: 1013 any instance of @code{#} will be treated literally (rather than as the 1014 start of a comment) inside a variable reference or function call. 1015 1012 1016 Within a command script (if the line begins with a TAB character) the 1013 1017 entire line is passed to the shell, just as with any other line that … … 1252 1256 @end example 1253 1257 1254 @xref{Text Functions}, for more information on the @code{ word} and1255 @code{words} functions used above. @xref{Flavors, The Two Flavors of 1256 Variables}, for more information on simply-expanded (@code{:=}) 1257 variabledefinitions.1258 @xref{Text Functions}, for more information on the @code{lastword} 1259 function used above. @xref{Flavors, The Two Flavors of Variables}, 1260 for more information on simply-expanded (@code{:=}) variable 1261 definitions. 1258 1262 1259 1263 @node Special Variables, Remaking Makefiles, MAKEFILE_LIST Variable, Makefiles … … 1745 1749 @code{foo.1 bar.1} respectively. In the third they will have values 1746 1750 @code{foo.1}, @code{foo.1 bar.1 foo.2 bar.2}, and @code{foo.1 bar.1 1747 foo.2 bar.2 } respectively.1751 foo.2 bar.2 foo.1 foo.1 bar.1 foo.1 bar.1} respectively. 1748 1752 1749 1753 Rules undergo secondary expansion in makefile order, except that … … 1938 1942 Variables, ,How to Use Variables}). If you have enabled secondary 1939 1943 expansion (@pxref{Secondary Expansion}) and you want a literal dollar 1940 sign in the prerequisites lis e, you must actually write @emph{four}1944 sign in the prerequisites list, you must actually write @emph{four} 1941 1945 dollar signs (@samp{$$$$}). 1942 1946 … … 2001 2005 The normal prerequisites section may of course be empty. Also, you 2002 2006 may 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). 2007 they are appended appropriately (normal prerequisites are appended to 2008 the list of normal prerequisites; order-only prerequisites are 2009 appended to the list of order-only prerequisites). Note that if you 2010 declare the same file to be both a normal and an order-only 2011 prerequisite, the normal prerequisite takes precedence (since they 2012 have a strict superset of the behavior of an order-only prerequisite). 2013 2014 Consider an example where your targets are to be placed in a separate 2015 directory, and that directory might not exist before @code{make} is 2016 run. In this situation, you want the directory to be created before 2017 any targets are placed into it but, because the timestamps on 2018 directories change whenever a file is added, removed, or renamed, we 2019 certainly don't want to rebuild all the targets whenever the 2020 directory's timestamp changes. One way to manage this is with 2021 order-only prerequisites: make the directory an order-only 2022 prerequisite on all the targets: 2023 2024 @example 2025 OBJDIR := objdir 2026 OBJS := $(addprefix $(OBJDIR)/,foo.o bar.o baz.o) 2027 2028 $(OBJDIR)/%.o : %.c 2029 $(COMPILE.c) $(OUTPUT_OPTION) $< 2030 2031 all: $(OBJS) 2032 2033 $(OBJS): | $(OBJDIR) 2034 2035 $(OBJDIR): 2036 mkdir $(OBJDIR) 2037 @end example 2038 2039 Now the rule to create the @file{objdir} directory will be run, if 2040 needed, before any @samp{.o} is built, but no @samp{.o} will be built 2041 because the @file{objdir} directory timestamp changed. 2007 2042 2008 2043 @node Wildcards, Directory Search, Prerequisite Types, Rules … … 2906 2941 @xref{Secondary Expansion, ,Secondary Expansion}. 2907 2942 2908 The prerequisites of the special target @code{.SUFFIXES} are the list2909 of suffixes to be used in checking for suffix rules.2910 @xref{Suffix Rules, , Old-Fashioned Suffix Rules}.2911 2912 2943 @findex .DELETE_ON_ERROR 2913 2944 @item .DELETE_ON_ERROR … … 2996 3027 @cindex parallel execution, overriding 2997 3028 2998 If @code{.NOTPARALLEL} is mentioned as a target, then this invocation of2999 @code{make} will be run serially, even if the @samp{-j} option is3000 given. Any recursively invoked @code{make} command will still be run in3001 parallel (unless its makefile contains this target). Any prerequisites 3002 on this target are ignored.3029 If @code{.NOTPARALLEL} is mentioned as a target, then this invocation 3030 of @code{make} will be run serially, even if the @samp{-j} option is 3031 given. Any recursively invoked @code{make} command will still run 3032 commands in parallel (unless its makefile also contains this target). 3033 Any prerequisites on this target are ignored. 3003 3034 @end table 3004 3035 … … 3094 3125 if the file's name begins with a dot, no error message is printed. 3095 3126 This odd behavior is only for compatibility with other implementations 3096 of @code{make} ...you should avoid using it). Occasionally it is3127 of @code{make}@dots{} you should avoid using it). Occasionally it is 3097 3128 useful to have the same target invoke multiple commands which are 3098 3129 defined in different parts of your makefile; you can use … … 3653 3684 3654 3685 @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. 3686 Notice how the backslash/newline pair was removed inside the string 3687 quoted with double quotes (@code{"@dots{}"}), but not from the string 3688 quoted with single quotes (@code{'@dots{}'}). This is the way the 3689 default shell (@file{/bin/sh}) handles backslash/newline pairs. If 3690 you specify a different shell in your makefiles it may treat them 3691 differently. 3660 3692 3661 3693 Sometimes you want to split a long line inside of single quotes, but … … 3943 3975 for it to finish before executing the next. However, the @samp{-j} or 3944 3976 @samp{--jobs} option tells @code{make} to execute many commands 3945 simultaneously.@refill 3977 simultaneously. You can inhibit parallelism in a particular makefile 3978 with the @code{.NOTPARALLEL} pseudo-target (@pxref{Special 3979 Targets,Special Built-in Target Names}).@refill 3946 3980 3947 3981 On MS-DOS, the @samp{-j} option has no effect, since that system doesn't … … 8353 8387 the special target @code{.SUFFIXES}). The default suffix list is: 8354 8388 @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 8395 whose prerequisites have one of these suffixes are actually suffix 8396 rules. If you modify the suffix list, the only predefined suffix 8397 rules in effect will be those named by one or two of the suffixes that 8398 are on the list you specify; rules whose suffixes fail to be on the 8399 list are disabled. @xref{Suffix Rules, ,Old-Fashioned Suffix Rules}, 8400 for full details on suffix rules. 8366 8401 8367 8402 @table @asis … … 8694 8729 @pindex cc 8695 8730 8696 @item CO8697 @vindex CO8698 Program for checking out files from RCS; default @samp{co}.8699 @pindex cc8700 8701 8731 @item CXX 8702 8732 @vindex CXX 8703 8733 Program for compiling C++ programs; default @samp{g++}. 8704 8734 @pindex g++ 8705 8706 @item CO8707 @vindex CO8708 Program for extracting a file from RCS; default @samp{co}.8709 @pindex co8710 8735 8711 8736 @item CPP … … 8720 8745 @pindex f77 8721 8746 8747 @item M2C 8748 @vindex M2C 8749 Program to use to compile Modula-2 source code; default @samp{m2c}. 8750 @pindex m2c 8751 8752 @item PC 8753 @vindex PC 8754 Program for compiling Pascal programs; default @samp{pc}. 8755 @pindex pc 8756 8757 @item CO 8758 @vindex CO 8759 Program for extracting a file from RCS; default @samp{co}. 8760 @pindex co 8761 8722 8762 @item GET 8723 8763 @vindex GET … … 8739 8779 Program to use to run lint on source code; default @samp{lint}. 8740 8780 @pindex lint 8741 8742 @item M2C8743 @vindex M2C8744 Program to use to compile Modula-2 source code; default @samp{m2c}.8745 @pindex m2c8746 8747 @item PC8748 @vindex PC8749 Program for compiling Pascal programs; default @samp{pc}.8750 @pindex pc8751 8781 8752 8782 @item MAKEINFO -
vendor/gnumake/current/expand.c
r501 r900 56 56 57 57 char * 58 variable_buffer_output (char *ptr, c har *string, unsigned int length)58 variable_buffer_output (char *ptr, const char *string, unsigned int length) 59 59 { 60 60 register unsigned int newlen = length + (ptr - variable_buffer); … … 66 66 ? newlen + 100 67 67 : 2 * variable_buffer_length); 68 variable_buffer = (char *) xrealloc (variable_buffer, 69 variable_buffer_length); 68 variable_buffer = xrealloc (variable_buffer, variable_buffer_length); 70 69 ptr = variable_buffer + offset; 71 70 } 72 71 73 bcopy (string, ptr, length);72 memcpy (ptr, string, length); 74 73 return ptr + length; 75 74 } … … 85 84 { 86 85 variable_buffer_length = 200; 87 variable_buffer = (char *)xmalloc (variable_buffer_length);86 variable_buffer = xmalloc (variable_buffer_length); 88 87 variable_buffer[0] = '\0'; 89 88 } … … 95 94 /* Recursively expand V. The returned string is malloc'd. */ 96 95 97 static char *allocated_variable_append PARAMS ((const struct variable *v));96 static char *allocated_variable_append (const struct variable *v); 98 97 99 98 char * … … 162 161 #endif 163 162 static char * 164 reference_variable (char *o, c har *name, unsigned int length)165 { 166 registerstruct variable *v;163 reference_variable (char *o, const char *name, unsigned int length) 164 { 165 struct variable *v; 167 166 char *value; 168 167 … … 194 193 LINE is NULL, start at the beginning of the buffer. 195 194 Return a pointer to LINE, or to the beginning of the buffer if LINE is 196 NULL. */197 195 NULL. 196 */ 198 197 char * 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'; 198 variable_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; 204 204 unsigned int line_offset; 205 205 206 206 if (!line) 207 207 line = initialize_variable_output(); 208 209 p = string;210 208 o = line; 211 209 line_offset = line - variable_buffer; 212 210 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; 218 227 219 228 while (1) … … 246 255 char openparen = *p; 247 256 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; 252 262 253 263 op = o; … … 285 295 if (count < 0) 286 296 { 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; 289 299 end = strchr (beg, '\0'); 290 300 } … … 304 314 { 305 315 /* This looks like a substitution reference: $(FOO:A=B). */ 306 c har *subst_beg, *subst_end, *replace_beg, *replace_end;316 const char *subst_beg, *subst_end, *replace_beg, *replace_end; 307 317 308 318 subst_beg = colon + 1; … … 336 346 extra % at the beginning to use in case there 337 347 isn't one in the pattern. */ 338 pattern = (char *)alloca (subst_end - subst_beg + 2);348 pattern = alloca (subst_end - subst_beg + 2); 339 349 *(pattern++) = '%'; 340 bcopy (subst_beg, pattern, subst_end - subst_beg);350 memcpy (pattern, subst_beg, subst_end - subst_beg); 341 351 pattern[subst_end - subst_beg] = '\0'; 342 352 343 replace = (char *) alloca (replace_end 344 - replace_beg + 2); 353 replace = alloca (replace_end - replace_beg + 2); 345 354 *(replace++) = '%'; 346 bcopy (replace_beg, replace,355 memcpy (replace, replace_beg, 347 356 replace_end - replace_beg); 348 357 replace[replace_end - replace_beg] = '\0'; … … 354 363 { 355 364 ++ppercent; 356 rpercent = 0; 365 rpercent = find_percent (replace); 366 if (rpercent) 367 ++rpercent; 357 368 } 358 369 else … … 364 375 } 365 376 366 o = patsubst_expand (o, value, pattern, replace,367 ppercent, rpercent);377 o = patsubst_expand_pat (o, value, pattern, replace, 378 ppercent, rpercent); 368 379 369 380 if (v->recursive) … … 378 389 o = reference_variable (o, beg, end - beg); 379 390 380 if ( free_beg)381 free ( beg);391 if (abeg) 392 free (abeg); 382 393 } 383 394 break; … … 403 414 } 404 415 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); 409 420 return (variable_buffer + line_offset); 410 421 } … … 417 428 418 429 char * 419 variable_expand (c har *line)430 variable_expand (const char *line) 420 431 { 421 432 return variable_expand_string(NULL, line, (long)-1); … … 438 449 439 450 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); 444 455 tmp[end - str] = '\0'; 445 456 … … 452 463 453 464 char * 454 variable_expand_for_file (c har *line, struct file *file)465 variable_expand_for_file (const char *line, struct file *file) 455 466 { 456 467 char *result; … … 543 554 544 555 char * 545 allocated_variable_expand_for_file (c har *line, struct file *file)556 allocated_variable_expand_for_file (const char *line, struct file *file) 546 557 { 547 558 char *value; -
vendor/gnumake/current/file.c
r501 r900 70 70 /* Access the hash table of all file records. 71 71 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 */ 74 74 75 75 struct file * 76 lookup_file (c har *name)77 { 78 registerstruct file *f;76 lookup_file (const char *name) 77 { 78 struct file *f; 79 79 struct file file_key; 80 80 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS) 81 register char *lname, *ln;81 char *lname; 82 82 #endif 83 83 … … 91 91 if (*name != '.') 92 92 { 93 register char *n; 94 lname = (char *) malloc (strlen (name) + 1); 93 const char *n; 94 char *ln; 95 lname = xstrdup (name); 95 96 for (n = name, ln = lname; *n != '\0'; ++n, ++ln) 96 97 *ln = isupper ((unsigned char)*n) ? tolower ((unsigned char)*n) : *n; … … 113 114 if (*name == '\0') 114 115 /* It was all slashes after a dot. */ 115 #if def VMS116 #if defined(VMS) 116 117 name = "[]"; 117 #else 118 #ifdef _AMIGA 118 #elif defined(_AMIGA) 119 119 name = ""; 120 120 #else 121 121 name = "./"; 122 #endif /* AMIGA */ 123 #endif /* VMS */ 122 #endif 124 123 125 124 file_key.hname = name; 126 f = (struct file *)hash_find_item (&files, &file_key);125 f = hash_find_item (&files, &file_key); 127 126 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS) 128 127 if (*name != '.') 129 128 free (lname); 130 129 #endif 130 131 131 return f; 132 132 } 133 133 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 134 139 struct file * 135 enter_file (c har *name)136 { 137 registerstruct file *f;138 registerstruct file *new;139 registerstruct file **file_slot;140 enter_file (const char *name) 141 { 142 struct file *f; 143 struct file *new; 144 struct file **file_slot; 140 145 struct file file_key; 141 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS)142 char *lname, *ln;143 #endif144 146 145 147 assert (*name != '\0'); 148 assert (strcache_iscached (name)); 146 149 147 150 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS) 148 151 if (*name != '.') 149 152 { 150 register char *n; 151 lname = (char *) malloc (strlen (name) + 1); 153 const char *n; 154 char *lname, *ln; 155 lname = xstrdup (name); 152 156 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); 164 165 } 165 166 #endif … … 169 170 f = *file_slot; 170 171 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)); 181 176 new->name = new->hname = name; 182 177 new->update_status = -1; … … 199 194 200 195 201 /* Rename FILE to NAME. This is not as simple as resetting202 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 void206 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 216 196 /* Rehash FILE to NAME. This is not as simple as resetting 217 197 the `hname' member, since it must be put in a new hash bucket, … … 219 199 220 200 void 221 rehash_file (struct file *from_file, c har *to_hname)201 rehash_file (struct file *from_file, const char *to_hname) 222 202 { 223 203 struct file file_key; … … 227 207 struct file *f; 228 208 209 /* If it's already that name, we're done. */ 229 210 file_key.hname = to_hname; 230 if ( 0 ==file_hash_cmp (from_file, &file_key))211 if (! file_hash_cmp (from_file, &file_key)) 231 212 return; 232 213 214 /* Find the end of the renamed list for the "from" file. */ 233 215 file_key.hname = from_file->hname; 234 216 while (from_file->renamed != 0) 235 217 from_file = from_file->renamed; 236 218 if (file_hash_cmp (from_file, &file_key)) 237 /* hname changed unexpectedly */219 /* hname changed unexpectedly!! */ 238 220 abort (); 239 221 222 /* Remove the "from" file from the hash. */ 240 223 deleted_file = hash_delete (&files, from_file); 241 224 if (deleted_file != from_file) … … 243 226 abort (); 244 227 228 /* Find where the newly renamed file will go in the hash. */ 245 229 file_key.hname = to_hname; 246 230 file_slot = (struct file **) hash_find_slot (&files, &file_key); 247 231 to_file = *file_slot; 248 232 233 /* Change the hash name for this file. */ 249 234 from_file->hname = to_hname; 250 235 for (f = from_file->double_colon; f != 0; f = f->prev) 251 236 f->hname = to_hname; 252 237 238 /* If the new name doesn't exist yet just set it to the renamed file. */ 253 239 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; 255 279 else 256 280 { 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); 291 297 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; 318 306 319 307 #define MERGE(field) to_file->field |= from_file->field 320 321 322 323 324 325 326 327 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); 328 316 #undef MERGE 329 317 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 325 void 326 rename_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; 331 333 } 332 334 } … … 341 343 remove_intermediates (int sig) 342 344 { 343 registerstruct file **file_slot;344 registerstruct file **file_end;345 struct file **file_slot; 346 struct file **file_end; 345 347 int doneany = 0; 346 348 … … 357 359 if (! HASH_VACANT (*file_slot)) 358 360 { 359 registerstruct file *f = *file_slot;361 struct file *f = *file_slot; 360 362 /* Is this file eligible for automatic deletion? 361 363 Yes, IFF: it's marked intermediate, it's not secondary, it wasn't … … 448 450 } 449 451 450 451 452 /* Set the intermediate flag. */ 452 453 … … 464 465 struct dep *d; 465 466 struct dep *old = f->deps; 466 c har *file_stem = f->stem;467 const char *file_stem = f->stem; 467 468 unsigned int last_dep_has_cmds = f->updating; 468 469 int initialized = 0; … … 480 481 481 482 /* 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. */ 483 485 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 } 485 490 else 486 491 { … … 494 499 o = subst_expand (buffer, d->name, "%", "$*", 1, 2, 0); 495 500 496 free (d->name); 497 d->name = savestring (buffer, o - buffer); 501 d->name = strcache_add_len (buffer, o - buffer); 498 502 d->staticpattern = 0; /* Clear staticpattern so that we don't 499 503 re-expand %s below. */ … … 529 533 if (new && d->staticpattern) 530 534 { 531 c har *pattern = "%";535 const char *pattern = "%"; 532 536 char *buffer = variable_expand (""); 533 537 struct dep *dp = new, *dl = 0; … … 535 539 while (dp != 0) 536 540 { 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); 538 546 if (percent) 539 547 { 548 char *o; 549 540 550 /* We have to handle empty stems specially, because that 541 551 would be equivalent to $(patsubst %,dp->name,) which 542 552 will always be empty. */ 543 553 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 } 546 558 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); 559 561 560 562 /* If the name expanded to the empty string, ignore it. */ 561 if ( dp->name[0] == '\0')563 if (buffer[0] == '\0') 562 564 { 563 565 struct dep *df = dp; … … 566 568 else 567 569 dp = dl->next = dp->next; 568 /* @@ Are we leaking df->name here? */569 df->name = 0;570 570 free_dep (df); 571 571 continue; 572 572 } 573 574 /* Save the name. */ 575 dp->name = strcache_add_len (buffer, o - buffer); 573 576 } 574 577 dl = dp; … … 583 586 if (d1->file == 0) 584 587 d1->file = enter_file (d1->name); 585 else586 free (d1->name);587 588 d1->name = 0; 588 589 d1->staticpattern = 0; … … 639 640 struct file **file_end; 640 641 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. */ 646 645 for (f = lookup_file (".SUFFIXES"); f != 0; f = f->prev) 647 646 expand_deps (f); 648 647 649 /* We must use hash_dump (), because within this loop650 we might add new files to the table, possibly causing651 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. */ 652 651 file_slot_0 = (struct file **) hash_dump (&files, 0, 0); 653 652 file_end = file_slot_0 + files.ht_fill; 654 653 for (file_slot = file_slot_0; file_slot < file_end; file_slot++) 655 654 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); 660 657 free (file_slot_0); 658 659 /* Now manage all the special targets. */ 661 660 662 661 for (f = lookup_file (".PRECIOUS"); f != 0; f = f->prev) … … 682 681 683 682 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) 687 694 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 } 713 703 714 704 f = lookup_file (".EXPORT_ALL_VARIABLES"); … … 860 850 p += strlen (p); 861 851 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. */ 867 856 sprintf (p, ".%09d", FILE_TIMESTAMP_NS (ts)); 868 857 p += strlen (p) - 1; … … 880 869 print_file (const void *item) 881 870 { 882 struct file *f = (struct file *)item;871 const struct file *f = item; 883 872 struct dep *d; 884 873 struct dep *ood = 0; … … 1002 991 } 1003 992 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 1002 static void 1003 verify_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 1021 void 1022 verify_file_data_base (void) 1023 { 1024 hash_map (&files, verify_file); 1025 } 1026 1004 1027 #define EXPANSION_INCREMENT(_l) ((((_l) / 500) + 1) * 500) 1005 1028 … … 1038 1061 } 1039 1062 1040 bcopy (f->name, p, l);1063 memcpy (p, f->name, l); 1041 1064 p += l; 1042 1065 *(p++) = ' '; -
vendor/gnumake/current/filedef.h
r501 r900 26 26 struct file 27 27 { 28 c har *name;29 c har *hname;/* Hashed filename */30 c har *vpath;/* VPATH/vpath pathname */28 const char *name; 29 const char *hname; /* Hashed filename */ 30 const char *vpath; /* VPATH/vpath pathname */ 31 31 struct dep *deps; /* all dependencies, including duplicates */ 32 32 struct commands *cmds; /* Commands to execute for this target. */ 33 33 int command_flags; /* Flags OR'd in for cmds; see commands.h. */ 34 c har *stem;/* Implicit stem, if an implicit35 34 const char *stem; /* Implicit stem, if an implicit 35 rule has been used */ 36 36 struct dep *also_make; /* Targets that are made by making this. */ 37 37 FILE_TIMESTAMP last_mtime; /* File's modtime, if already known. */ … … 102 102 103 103 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));104 struct file *lookup_file (const char *name); 105 struct file *enter_file (const char *name); 106 struct dep *parse_prereqs (char *prereqs); 107 void remove_intermediates (int sig); 108 void snap_deps (void); 109 void rename_file (struct file *file, const char *name); 110 void rehash_file (struct file *file, const char *name); 111 void set_command_state (struct file *file, enum cmd_state state); 112 void notice_finished_file (struct file *file); 113 void init_hash_files (void); 114 char *build_target_list (char *old_list); 115 115 116 116 #if FILE_TIMESTAMP_HI_RES … … 153 153 + 1 + 1 + 4 + 25) 154 154 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)); 155 FILE_TIMESTAMP file_timestamp_cons (char const *, time_t, int); 156 FILE_TIMESTAMP file_timestamp_now (int *); 157 void file_timestamp_sprintf (char *p, FILE_TIMESTAMP ts); 159 158 160 159 /* Return the mtime of file F (a struct file *), caching it. … … 166 165 The value is NONEXISTENT_MTIME if the file does not exist. */ 167 166 #define file_mtime_no_search(f) file_mtime_1 ((f), 0) 168 extern FILE_TIMESTAMP f_mtime PARAMS ((struct file *file, int search));167 FILE_TIMESTAMP f_mtime (struct file *file, int search); 169 168 #define file_mtime_1(f, v) \ 170 169 ((f)->last_mtime == UNKNOWN_MTIME ? f_mtime ((f), v) : (f)->last_mtime) -
vendor/gnumake/current/function.c
r501 r900 37 37 unsigned char maximum_args; 38 38 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); 40 40 }; 41 41 … … 43 43 function_table_entry_hash_1 (const void *keyv) 44 44 { 45 struct function_table_entry const *key = (struct function_table_entry const *)keyv;45 const struct function_table_entry *key = keyv; 46 46 return_STRING_N_HASH_1 (key->name, key->len); 47 47 } … … 50 50 function_table_entry_hash_2 (const void *keyv) 51 51 { 52 struct function_table_entry const *key = (struct function_table_entry const *)keyv;52 const struct function_table_entry *key = keyv; 53 53 return_STRING_N_HASH_2 (key->name, key->len); 54 54 } … … 57 57 function_table_entry_hash_cmp (const void *xv, const void *yv) 58 58 { 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; 61 61 int result = x->len - y->len; 62 62 if (result) … … 76 76 77 77 char * 78 subst_expand (char *o, c har *text, char *subst,char *replace,78 subst_expand (char *o, const char *text, const char *subst, const char *replace, 79 79 unsigned int slen, unsigned int rlen, int by_word) 80 80 { 81 c har *t = text;82 c har *p;81 const char *t = text; 82 const char *p; 83 83 84 84 if (slen == 0 && !by_word) … … 125 125 126 126 /* Advance T past the string to be replaced. */ 127 { 128 char *nt = p + slen; 129 t = nt; 130 } 127 t = p + slen; 131 128 } while (*t != '\0'); 132 129 … … 147 144 148 145 char * 149 patsubst_expand (char *o, char *text, char *pattern, char *replace, 150 char *pattern_percent, char *replace_percent) 146 patsubst_expand_pat (char *o, const char *text, 147 const char *pattern, const char *replace, 148 const char *pattern_percent, const char *replace_percent) 151 149 { 152 150 unsigned int pattern_prepercent_len, pattern_postpercent_len; 153 151 unsigned int replace_prepercent_len, replace_postpercent_len; 154 c har *t;152 const char *t; 155 153 unsigned int len; 156 154 int doneany = 0; 157 158 /* We call find_percent on REPLACE before checking PATTERN so that REPLACE159 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 }166 155 167 156 /* Record the length of REPLACE before and after the % so we don't have to … … 178 167 } 179 168 180 if (!pattern_percent)181 {182 pattern_percent = find_percent (pattern);183 if (pattern_percent)184 ++pattern_percent;185 }186 169 if (!pattern_percent) 187 170 /* With no % in the pattern, this is just a simple substitution. */ … … 255 238 } 256 239 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 250 char * 251 patsubst_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 257 266 258 267 … … 282 291 283 292 int 284 pattern_matches (c har *pattern, char *percent,char *str)293 pattern_matches (const char *pattern, const char *percent, const char *str) 285 294 { 286 295 unsigned int sfxlen, strlength; … … 289 298 { 290 299 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); 293 305 pattern = new_chars; 294 percent = find_percent (pattern);295 if (percent == 0)296 return streq (pattern, str);297 306 } 298 307 … … 350 359 static char *result = 0; 351 360 static unsigned int length; 352 registerstruct nameseq *chain;353 registerunsigned int idx;361 struct nameseq *chain; 362 unsigned int idx; 354 363 355 364 chain = multi_glob (parse_file_seq … … 364 373 { 365 374 length = 100; 366 result = (char *)xmalloc (100);375 result = xmalloc (100); 367 376 } 368 377 … … 370 379 while (chain != 0) 371 380 { 372 registerchar *name = chain->name;381 const char *name = chain->name; 373 382 unsigned int len = strlen (name); 374 383 375 384 struct nameseq *next = chain->next; 376 free ( (char *)chain);385 free (chain); 377 386 chain = next; 378 387 … … 384 393 { 385 394 length += (len + 1) * 2; 386 result = (char *)xrealloc (result, length);395 result = xrealloc (result, length); 387 396 } 388 bcopy (name, &result[idx], len);397 memcpy (&result[idx], name, len); 389 398 idx += len; 390 399 result[idx++] = ' '; 391 400 } 392 393 free (name);394 401 } 395 402 … … 411 418 func_patsubst (char *o, char **argv, const char *funcname UNUSED) 412 419 { 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]); 414 421 return o; 415 422 } … … 425 432 If the two arguments have a different number of words, 426 433 the excess words are just output separated by blanks. */ 427 registerchar *tp;428 registerchar *pp;429 c har *list1_iterator = argv[0];430 c har *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]; 431 438 do 432 439 { … … 460 467 { 461 468 /* Expand the argument. */ 462 registerstruct variable *v = lookup_variable (argv[0], strlen (argv[0]));469 struct variable *v = lookup_variable (argv[0], strlen (argv[0])); 463 470 if (v == 0) 464 471 o = variable_buffer_output (o, "undefined", 9); … … 499 506 func_flavor (char *o, char **argv, const char *funcname UNUSED) 500 507 { 501 registerstruct variable *v = lookup_variable (argv[0], strlen (argv[0]));508 struct variable *v = lookup_variable (argv[0], strlen (argv[0])); 502 509 503 510 if (v == 0) … … 527 534 { 528 535 /* Expand the argument. */ 529 c har *list_iterator = argv[0];530 c har *p2 =0;536 const char *list_iterator = argv[0]; 537 const char *p2; 531 538 int doneany =0; 532 539 unsigned int len=0; … … 536 543 while ((p2 = find_next_token (&list_iterator, &len)) != 0) 537 544 { 538 c har *p = p2 + len;545 const char *p = p2 + len; 539 546 540 547 … … 571 578 } 572 579 } 580 573 581 if (doneany) 574 582 /* Kill last space. */ 575 583 --o; 576 584 577 578 return o; 579 585 return o; 580 586 } 581 587 … … 585 591 { 586 592 /* Expand the argument. */ 587 c har *p3 = argv[0];588 c har *p2=0;593 const char *p3 = argv[0]; 594 const char *p2; 589 595 int doneany=0; 590 596 unsigned int len=0; 591 char *p=0; 597 592 598 int is_basename= streq (funcname, "basename"); 593 599 int is_dir= !is_basename; 594 600 595 601 while ((p2 = find_next_token (&p3, &len)) != 0) 596 597 598 599 600 601 602 603 604 605 606 607 608 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); 609 615 #ifdef HAVE_DOS_PATHS 610 611 612 616 /* Handle the "d:foobar" case */ 617 else if (p2[0] && p2[1] == ':' && is_dir) 618 o = variable_buffer_output (o, p2, 2); 613 619 #endif 614 620 else if (is_dir) 615 621 #ifdef VMS 616 622 o = variable_buffer_output (o, "[]", 2); 617 623 #else 618 624 #ifndef _AMIGA 619 625 o = variable_buffer_output (o, "./", 2); 620 626 #else 621 627 ; /* Just a nop... */ 622 628 #endif /* AMIGA */ 623 629 #endif /* !VMS */ 624 625 626 627 628 629 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; 637 643 } 638 644 … … 641 647 { 642 648 int fixlen = strlen (argv[0]); 643 c har *list_iterator = argv[1];649 const char *list_iterator = argv[1]; 644 650 int is_addprefix = streq (funcname, "addprefix"); 645 651 int is_addsuffix = !is_addprefix; 646 652 647 653 int doneany = 0; 648 c har *p;654 const char *p; 649 655 unsigned int len; 650 656 … … 681 687 { 682 688 unsigned int i; 683 c har *words = argv[0]; /* Use a temp variable for find_next_token */684 c har *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); 685 691 686 692 if (p != 0) … … 694 700 { 695 701 unsigned int i; 696 c har *words = argv[0]; /* Use a temp variable for find_next_token */697 c har *p = 0;698 c har *t;702 const char *words = argv[0]; /* Use a temp variable for find_next_token */ 703 const char *p = NULL; 704 const char *t; 699 705 700 706 while ((t = find_next_token (&words, &i))) … … 711 717 { 712 718 int i = 0; 713 c har *word_iterator = argv[0];719 const char *word_iterator = argv[0]; 714 720 char buf[20]; 715 721 … … 719 725 sprintf (buf, "%d", i); 720 726 o = variable_buffer_output (o, buf, strlen (buf)); 721 722 727 723 728 return o; … … 740 745 741 746 static void 742 check_numeric (const char *s, const char *m essage)747 check_numeric (const char *s, const char *msg) 743 748 { 744 749 const char *end = s + strlen (s) - 1; … … 751 756 752 757 if (s <= end || end - beg < 0) 753 fatal (*expanding_var, "%s: '%s'", m essage, beg);758 fatal (*expanding_var, "%s: '%s'", msg, beg); 754 759 } 755 760 … … 759 764 func_word (char *o, char **argv, const char *funcname UNUSED) 760 765 { 761 c har *end_p=0;762 int i=0;763 char *p=0;766 const char *end_p; 767 const char *p; 768 int i; 764 769 765 770 /* Check the first argument. */ 766 771 check_numeric (argv[0], _("non-numeric first argument to `word' function")); 767 i = 772 i = atoi (argv[0]); 768 773 769 774 if (i == 0) 770 775 fatal (*expanding_var, 771 776 _("first argument to `word' function must be greater than 0")); 772 773 777 774 778 end_p = argv[1]; … … 803 807 if (count > 0) 804 808 { 805 c har *p;806 c har *end_p = argv[2];809 const char *p; 810 const char *end_p = argv[2]; 807 811 808 812 /* Find the beginning of the "start"th word. */ … … 824 828 } 825 829 826 static char *830 static char * 827 831 func_findstring (char *o, char **argv, const char *funcname UNUSED) 828 832 { … … 840 844 char *varname = expand_argument (argv[0], NULL); 841 845 char *list = expand_argument (argv[1], NULL); 842 c har *body = argv[2];846 const char *body = argv[2]; 843 847 844 848 int doneany = 0; 845 c har *list_iterator = list;846 c har *p;849 const char *list_iterator = list; 850 const char *p; 847 851 unsigned int len; 848 registerstruct variable *var;852 struct variable *var; 849 853 850 854 push_new_variable_scope (); … … 856 860 char *result = 0; 857 861 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); 866 864 867 865 result = allocated_variable_expand (body); … … 936 934 struct hash_table a_word_table; 937 935 int is_filter = streq (funcname, "filter"); 938 c har *pat_iterator = argv[0];939 c har *word_iterator = argv[1];936 const char *pat_iterator = argv[0]; 937 const char *word_iterator = argv[1]; 940 938 int literals = 0; 941 939 int words = 0; … … 949 947 while ((p = find_next_token (&pat_iterator, &len)) != 0) 950 948 { 951 struct a_pattern *pat = (struct a_pattern *)alloca (sizeof (struct a_pattern));949 struct a_pattern *pat = alloca (sizeof (struct a_pattern)); 952 950 953 951 *pattail = pat; … … 972 970 while ((p = find_next_token (&word_iterator, &len)) != 0) 973 971 { 974 struct a_word *word = (struct a_word *)alloca (sizeof (struct a_word));972 struct a_word *word = alloca (sizeof (struct a_word)); 975 973 976 974 *wordtail = word; … … 993 991 if (hashing) 994 992 { 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); 996 995 for (wp = wordhead; wp != 0; wp = wp->next) 997 996 { … … 1017 1016 a_word_key.str = pp->str; 1018 1017 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); 1020 1019 while (wp) 1021 1020 { … … 1057 1056 func_strip (char *o, char **argv, const char *funcname UNUSED) 1058 1057 { 1059 c har *p = argv[0];1060 int doneany = 0;1058 const char *p = argv[0]; 1059 int doneany = 0; 1061 1060 1062 1061 while (*p != '\0') 1063 1062 { 1064 1063 int i=0; 1065 c har *word_start=0;1064 const char *word_start; 1066 1065 1067 1066 while (isspace ((unsigned char)*p)) … … 1080 1079 /* Kill the last space. */ 1081 1080 --o; 1081 1082 1082 return o; 1083 1083 } … … 1099 1099 len += strlen (*argvp) + 2; 1100 1100 1101 p = msg = (char *)alloca (len + 1);1101 p = msg = alloca (len + 1); 1102 1102 1103 1103 for (argvp=argv; argvp[1] != 0; ++argvp) … … 1138 1138 func_sort (char *o, char **argv, const char *funcname UNUSED) 1139 1139 { 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; 1146 1143 char *p; 1147 1144 unsigned int len; 1148 1145 int i; 1149 1146 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; 1150 1168 while ((p = find_next_token (&t, &len)) != 0) 1151 1169 { 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) 1173 1182 { 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 } 1176 1190 } 1177 free (words[i]); 1178 }1179 /* Kill the last space. */1180 --o;1191 1192 /* Kill the last space. */ 1193 --o; 1194 } 1181 1195 1182 1196 free (words); … … 1224 1238 argv += 1 + !result; 1225 1239 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); 1231 1243 1232 1244 o = variable_buffer_output (o, expansion, strlen (expansion)); … … 1345 1357 func_wildcard (char *o, char **argv, const char *funcname UNUSED) 1346 1358 { 1347 1348 1359 #ifdef _AMIGA 1349 1360 o = wildcard_expansion (argv[0], o); … … 1585 1596 func_shell (char *o, char **argv, const char *funcname UNUSED) 1586 1597 { 1587 char *batch_filename = NULL;1598 char *batch_filename = NULL; 1588 1599 1589 1600 #ifdef __MSDOS__ … … 1591 1602 #endif 1592 1603 char **command_argv; 1593 c har *error_prefix;1604 const char *error_prefix; 1594 1605 char **envp; 1595 1606 int pipedes[2]; … … 1598 1609 #ifndef __MSDOS__ 1599 1610 /* 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); 1603 1612 if (command_argv == 0) 1604 1613 return o; … … 1612 1621 calling environment. 1613 1622 1623 See Savannah bug #10593. 1624 1614 1625 envp = target_environment (NILF); 1615 1626 */ … … 1620 1631 if (reading_file && reading_file->filenm) 1621 1632 { 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; 1625 1636 } 1626 1637 else 1627 1638 error_prefix = ""; 1628 1639 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__) 1642 1641 fpipe = msdos_openpipe (pipedes, &pid, argv[0]); 1643 1642 if (pipedes[0] < 0) … … 1646 1645 return o; 1647 1646 } 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 1649 1657 #else 1650 1651 1658 if (pipe (pipedes) < 0) 1652 1659 { … … 1656 1663 1657 1664 # ifdef __EMX__ 1658 1659 1665 /* close some handles that are unnecessary for the child process */ 1660 1666 CLOSE_ON_EXEC(pipedes[1]); … … 1664 1670 if (pid < 0) 1665 1671 perror_with_name (error_prefix, "spawn"); 1666 1667 1672 # else /* ! __EMX__ */ 1668 1669 1673 pid = vfork (); 1670 1674 if (pid < 0) … … 1673 1677 child_execute_job (0, pipedes[1], command_argv, envp); 1674 1678 else 1675 1676 1679 # endif 1677 1678 1680 #endif 1679 1681 { … … 1690 1692 /* Free the storage only the child needed. */ 1691 1693 free (command_argv[0]); 1692 free ( (char *)command_argv);1694 free (command_argv); 1693 1695 1694 1696 /* Close the write side of the pipe. */ 1695 (void)close (pipedes[1]);1697 close (pipedes[1]); 1696 1698 #endif 1697 1699 … … 1699 1701 1700 1702 maxlen = 200; 1701 buffer = (char *)xmalloc (maxlen + 1);1703 buffer = xmalloc (maxlen + 1); 1702 1704 1703 1705 /* Read from the pipe until it gets EOF. */ … … 1707 1709 { 1708 1710 maxlen += 512; 1709 buffer = (char *)xrealloc (buffer, maxlen + 1);1711 buffer = xrealloc (buffer, maxlen + 1); 1710 1712 } 1711 1713 … … 1834 1836 { 1835 1837 maxlen += 512; 1836 buffer = (char *)xrealloc (buffer, maxlen + 1);1838 buffer = xrealloc (buffer, maxlen + 1); 1837 1839 } 1838 1840 … … 1872 1874 func_not (char *o, char **argv, char *funcname) 1873 1875 { 1874 c har *s = argv[0];1876 const char *s = argv[0]; 1875 1877 int result = 0; 1876 1878 while (isspace ((unsigned char)*s)) … … 1966 1968 { 1967 1969 /* Expand the argument. */ 1968 c har *p = argv[0];1969 c har *path = 0;1970 const char *p = argv[0]; 1971 const char *path = 0; 1970 1972 int doneany = 0; 1971 1973 unsigned int len = 0; … … 1980 1982 in[len] = '\0'; 1981 1983 1982 if 1983 ( 1984 if ( 1984 1985 #ifdef HAVE_REALPATH 1985 realpath (in, out)1986 realpath (in, out) 1986 1987 #else 1987 abspath (in, out)1988 abspath (in, out) 1988 1989 #endif 1989 )1990 ) 1990 1991 { 1991 1992 o = variable_buffer_output (o, out, strlen (out)); … … 2000 2001 --o; 2001 2002 2002 return o;2003 return o; 2003 2004 } 2004 2005 … … 2007 2008 { 2008 2009 /* Expand the argument. */ 2009 c har *p = argv[0];2010 c har *path = 0;2010 const char *p = argv[0]; 2011 const char *path = 0; 2011 2012 int doneany = 0; 2012 2013 unsigned int len = 0; … … 2034 2035 --o; 2035 2036 2036 return o;2037 return o; 2037 2038 } 2038 2039 … … 2049 2050 Functions that do namespace tricks (foreach) don't automatically expand. */ 2050 2051 2051 static char *func_call PARAMS ((char *o, char **argv, const char *funcname));2052 static char *func_call (char *o, char **argv, const char *funcname); 2052 2053 2053 2054 … … 2131 2132 2132 2133 int 2133 handle_function (char **op, c har **stringp)2134 handle_function (char **op, const char **stringp) 2134 2135 { 2135 2136 const struct function_table_entry *entry_p; 2136 2137 char openparen = (*stringp)[0]; 2137 2138 char closeparen = openparen == '(' ? ')' : '}'; 2138 c har *beg;2139 c har *end;2139 const char *beg; 2140 const char *end; 2140 2141 int count = 0; 2141 register char *p;2142 char *abeg = NULL; 2142 2143 char **argv, **argvp; 2143 2144 int nargs; … … 2176 2177 2177 2178 /* 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)); 2179 2180 2180 2181 /* Chop the string into arguments, then a nul. As soon as we hit … … 2186 2187 each argument. */ 2187 2188 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 2189 2207 { 2190 2208 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) 2212 2217 { 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 2213 2226 *argvp = p; 2214 2227 *next = '\0'; 2228 p = next + 1; 2215 2229 } 2216 2217 p = next + 1;2218 2230 } 2219 2231 *argvp = NULL; … … 2226 2238 for (argvp=argv; *argvp != 0; ++argvp) 2227 2239 free (*argvp); 2228 else2229 free ( beg);2240 if (abeg) 2241 free (abeg); 2230 2242 2231 2243 return 1; … … 2269 2281 2270 2282 entry_p = lookup_function (fname); 2271 2272 2283 if (entry_p) 2273 2284 { 2274 2285 /* How many arguments do we have? */ 2275 2286 for (i=0; argv[i+1]; ++i) 2276 ; 2277 2287 ; 2278 2288 return expand_builtin_function (o, i, argv+1, entry_p); 2279 2289 } … … 2291 2301 return o; 2292 2302 2293 body = (char *)alloca (flen + 4);2303 body = alloca (flen + 4); 2294 2304 body[0] = '$'; 2295 2305 body[1] = '('; -
vendor/gnumake/current/getloadavg.c
r501 r900 707 707 { 708 708 struct class_stats stats; 709 bzero ((char *) &stats, sizeof stats);709 memset (&stats, '\0', sizeof stats); 710 710 711 711 desc.sd_type = CPUTYPE_CLASS; -
vendor/gnumake/current/hash.h
r501 r900 175 175 176 176 #define ISTRING_COMPARE(X, Y, RESULT) do { \ 177 RESULT = strc mpi((X), (Y)); \177 RESULT = strcasecmp ((X), (Y)); \ 178 178 } while (0) 179 179 #define return_ISTRING_COMPARE(X, Y) do { \ 180 return strc mpi((X), (Y)); \180 return strcasecmp ((X), (Y)); \ 181 181 } while (0) 182 182 -
vendor/gnumake/current/implicit.c
r501 r900 26 26 #include "commands.h" /* set_file_variables */ 27 27 28 static int 29 pattern_search PARAMS ((struct file *file, int archive, 30 unsigned int depth, unsigned int recursions)); 28 static int pattern_search (struct file *file, int archive, 29 unsigned int depth, unsigned int recursions); 31 30 32 31 … … 72 71 { 73 72 struct idep *next; /* struct dep -compatible interface */ 74 c har *name;/* name of the prerequisite */73 const char *name; /* name of the prerequisite */ 75 74 struct file *intermediate_file; /* intermediate file, 0 otherwise */ 76 c har *intermediate_pattern;/* pattern for intermediate file */75 const char *intermediate_pattern; /* pattern for intermediate file */ 77 76 unsigned char had_stem; /* had % substituted with stem */ 78 77 unsigned char ignore_mtime; /* ignore_mtime flag */ … … 87 86 { 88 87 n = p->next; 89 90 if (p->name)91 {92 struct file *f = p->intermediate_file;93 94 if (f != 095 && (f->stem < f->name || f->stem > f->name + strlen (f->name)))96 free (f->stem);97 98 free (p->name);99 }100 101 88 free (p); 102 89 } … … 109 96 110 97 static char * 111 get_next_word (c har *buffer, unsigned int *length)98 get_next_word (const char *buffer, unsigned int *length) 112 99 { 113 c har *p = buffer, *beg;100 const char *p = buffer, *beg; 114 101 char c; 115 102 … … 182 169 *length = p - beg; 183 170 184 return beg;171 return (char *)beg; 185 172 } 186 173 … … 204 191 { 205 192 /* Filename we are searching for a rule for. */ 206 c har *filename = archive ? strchr (file->name, '(') : file->name;193 const char *filename = archive ? strchr (file->name, '(') : file->name; 207 194 208 195 /* Length of FILENAME. */ … … 226 213 227 214 /* 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); 229 216 230 217 /* The start and length of the stem of FILENAME for the current rule. */ 231 registerchar *stem = 0;232 registerunsigned int stemlen = 0;233 registerunsigned int fullstemlen = 0;218 const char *stem = 0; 219 unsigned int stemlen = 0; 220 unsigned int fullstemlen = 0; 234 221 235 222 /* 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 *)); 239 225 240 226 /* Number of valid elements in TRYRULES. */ … … 243 229 /* The numbers of the rule targets of each rule 244 230 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)); 247 232 248 233 /* Each element is nonzero if LASTSLASH was used in 249 234 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)); 252 236 253 237 /* The index in TRYRULES of the rule we found. */ … … 261 245 int specific_rule_matched = 0; 262 246 263 unsigned int i = 0; /* uninit checks OK */247 unsigned int ri; /* uninit checks OK */ 264 248 struct rule *rule; 265 249 struct dep *dep, *expl_d; 266 267 char *p, *vname;268 250 269 251 struct idep *d; … … 310 292 for (rule = pattern_rules; rule != 0; rule = rule->next) 311 293 { 294 unsigned int ti; 295 312 296 /* If the pattern rule has deps but no commands, ignore it. 313 297 Users cancel built-in rules by redefining them without commands. */ … … 323 307 } 324 308 325 for ( i = 0; rule->targets[i] != 0; ++i)309 for (ti = 0; ti < rule->num; ++ti) 326 310 { 327 c har *target = rule->targets[i];328 c har *suffix = rule->suffixes[i];311 const char *target = rule->targets[ti]; 312 const char *suffix = rule->suffixes[ti]; 329 313 int check_lastslash; 330 314 … … 335 319 continue; 336 320 337 if (rule->lens[ i] > namelen)321 if (rule->lens[ti] > namelen) 338 322 /* It can't possibly match. */ 339 323 continue; … … 342 326 find the stem: the part of the filename that matches the %. */ 343 327 stem = filename + (suffix - target - 1); 344 stemlen = namelen - rule->lens[ i] + 1;328 stemlen = namelen - rule->lens[ti] + 1; 345 329 346 330 /* Set CHECK_LASTSLASH if FILENAME contains a directory … … 408 392 that rule will be in TRYRULES more than once. */ 409 393 tryrules[nrules] = rule; 410 matches[nrules] = i;394 matches[nrules] = ti; 411 395 checked_lastslash[nrules] = check_lastslash; 412 396 ++nrules; … … 417 401 retroactively reject any non-"terminal" rules that do always match. */ 418 402 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) 421 405 { 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 } 428 413 } 429 414 … … 439 424 and chain them in DEPS. */ 440 425 441 for ( i = 0; i < nrules;i++)426 for (ri = 0; ri < nrules; ri++) 442 427 { 443 428 struct file *f; … … 446 431 int file_variables_set = 0; 447 432 448 rule = tryrules[ i];433 rule = tryrules[ri]; 449 434 450 435 remove_explicit_deps = 0; … … 467 452 find the stem: the part of the filename that matches the %. */ 468 453 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]; 472 457 if (check_lastslash) 473 458 { … … 491 476 { 492 477 unsigned int len; 478 char *p; 493 479 char *p2; 494 480 unsigned int order_only = 0; /* Set if '|' was seen. */ … … 536 522 if (p2 < p + len) 537 523 { 538 registerunsigned 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); 542 528 depname[len + 2 - 1] = '\0'; 543 529 … … 549 535 else 550 536 { 551 bcopy (p, depname, len);537 memcpy (depname, p, len); 552 538 depname[len] = '\0'; 553 539 } … … 568 554 if (p2 < p + len) 569 555 { 570 registerunsigned 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); 574 560 depname[len + stemlen - 1] = '\0'; 575 561 … … 581 567 else 582 568 { 583 bcopy (p, depname, len);569 memcpy (depname, p, len); 584 570 depname[len] = '\0'; 585 571 } … … 619 605 if (add_dir) 620 606 { 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); 629 611 } 630 612 … … 658 640 for (d = deps; d != 0; d = d->next) 659 641 { 660 c har *name = d->name;642 const char *name = d->name; 661 643 662 644 if (file_impossible_p (name)) … … 670 652 : _("Rejecting impossible rule prerequisite `%s'.\n"), 671 653 name)); 672 tryrules[ i] = 0;654 tryrules[ri] = 0; 673 655 674 656 failed = 1; … … 706 688 /* This code, given FILENAME = "lib/foo.o", dependency name 707 689 "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 } 719 700 720 701 … … 726 707 { 727 708 if (intermediate_file == 0) 728 intermediate_file 729 = (struct file *) alloca (sizeof (struct file)); 709 intermediate_file = alloca (sizeof (struct file)); 730 710 731 711 DBS (DB_IMPLICIT, … … 733 713 name)); 734 714 735 bzero ((char *) intermediate_file, sizeof (struct file));715 memset (intermediate_file, '\0', sizeof (struct file)); 736 716 intermediate_file->name = name; 737 717 if (pattern_search (intermediate_file, … … 740 720 recursions + 1)) 741 721 { 722 d->intermediate_pattern = intermediate_file->name; 723 intermediate_file->name = strcache_add (name); 742 724 d->intermediate_file = intermediate_file; 743 d->intermediate_pattern = intermediate_file->name;744 745 intermediate_file->name = xstrdup (name);746 725 intermediate_file = 0; 747 726 … … 781 760 /* If we found an applicable rule without 782 761 intermediate files, don't try with them. */ 783 if ( i < nrules)762 if (ri < nrules) 784 763 break; 785 764 … … 792 771 goto done; 793 772 794 foundrule = i;773 foundrule = ri; 795 774 796 775 /* If we are recursing, store the pattern that matched … … 825 804 for (d = deps; d != 0; d = d->next) 826 805 { 827 registerchar *s;806 const char *s; 828 807 829 808 if (d->intermediate_file != 0) … … 845 824 f->precious = 1; 846 825 else 847 f = enter_file ( imf->name);826 f = enter_file (strcache_add (imf->name)); 848 827 849 828 f->deps = imf->deps; … … 865 844 { 866 845 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);870 846 dep->name = 0; 871 847 dep->file->tried_implicit |= dep->changed; … … 881 857 dep->file = lookup_file (s); 882 858 if (dep->file == 0) 883 /* enter_file consumes S's storage. */884 859 dep->file = enter_file (s); 885 else886 /* A copy of S is already allocated in DEP->file->name.887 So we can free S. */888 free (s);889 860 } 890 861 else 891 { 892 dep->name = s; 893 } 862 dep->name = s; 894 863 895 864 if (d->intermediate_file == 0 && tryrules[foundrule]->terminal) … … 916 885 /* Always allocate new storage, since STEM might be 917 886 on the stack for an intermediate file. */ 918 file->stem = s avestring(stem, stemlen);887 file->stem = strcache_add_len (stem, stemlen); 919 888 fullstemlen = stemlen; 920 889 } … … 922 891 { 923 892 int dirlen = (lastslash + 1) - filename; 893 char *sp; 924 894 925 895 /* We want to prepend the directory from 926 896 the original FILENAME onto the stem. */ 927 897 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); 932 903 } 933 904 … … 945 916 `also_make' member. */ 946 917 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]) 950 921 { 922 char *p = alloca (rule->lens[ri] + fullstemlen + 1); 951 923 struct file *f; 952 924 struct dep *new = alloc_dep (); 953 925 954 926 /* 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); 960 931 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); 963 935 new->file = enter_file (new->name); 964 936 new->next = file->also_make; 965 937 966 938 /* Set precious flag. */ 967 f = lookup_file (rule->targets[ i]);939 f = lookup_file (rule->targets[ri]); 968 940 if (f && f->precious) 969 941 new->file->precious = 1; -
vendor/gnumake/current/job.c
r501 r900 99 99 # include <starlet.h> 100 100 # include <lib$routines.h> 101 static void vmsWaitForChildren PARAMS ((int *));101 static void vmsWaitForChildren (int *); 102 102 #endif 103 103 … … 131 131 132 132 #if !defined (wait) && !defined (POSIX) 133 externint wait ();133 int wait (); 134 134 #endif 135 135 … … 176 176 177 177 #ifndef HAVE_UNISTD_H 178 externint dup2 ();179 externint execve ();180 externvoid _exit ();178 int dup2 (); 179 int execve (); 180 void _exit (); 181 181 # ifndef VMS 182 externint geteuid ();183 externint getegid ();184 externint setgid ();185 externint getgid ();182 int geteuid (); 183 int getegid (); 184 int setgid (); 185 int getgid (); 186 186 # endif 187 187 #endif 188 188 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 *)); 189 int getloadavg (double loadavg[], int nelem); 190 int start_remote_job (char **argv, char **envp, int stdin_fd, int *is_remote, 191 int *id_ptr, int *used_stdin); 192 int start_remote_job_p (int); 193 int remote_status (int *exit_code_ptr, int *signal_ptr, int *coredump_ptr, 194 int block); 195 196 RETSIGTYPE child_handler (int); 197 static void free_child (struct child *); 198 static void start_job_command (struct child *child); 199 static int load_too_high (void); 200 static int job_next_command (struct child *); 201 static int start_waiting_job (struct child *); 204 202 205 203 … … 304 302 { 305 303 const unsigned final_size = path_size + size + 1; 306 char *const path = (char *)xmalloc (final_size);304 char *const path = xmalloc (final_size); 307 305 memcpy (path, temp_path, final_size); 308 306 *fd = _open_osfhandle ((long)h, 0); … … 363 361 i = 0; 364 362 while (known_os2shells[i] != NULL) { 365 if (str icmp (name, known_os2shells[i]) == 0) /* strcasecmp() */363 if (strcasecmp (name, known_os2shells[i]) == 0) 366 364 return 0; /* not a unix shell */ 367 365 i++; … … 380 378 381 379 static void 382 child_error (c har *target_name, int exit_code, int exit_sig, int coredump,383 int ignored)380 child_error (const char *target_name, 381 int exit_code, int exit_sig, int coredump, int ignored) 384 382 { 385 383 if (ignored && silent_flag) … … 501 499 502 500 The test and decrement are not atomic; if it is compiled into: 503 501 register = dead_children - 1; 504 502 dead_children = register; 505 503 a SIGCHLD could come between the two instructions. … … 881 879 for (i = 0; i < child->file->cmds->ncommand_lines; ++i) 882 880 free (child->command_lines[i]); 883 free ( (char *)child->command_lines);881 free (child->command_lines); 884 882 } 885 883 … … 889 887 while (*ep != 0) 890 888 free (*ep++); 891 free ( (char *)child->environment);892 } 893 894 free ( (char *)child);889 free (child->environment); 890 } 891 892 free (child); 895 893 } 896 894 … … 938 936 #endif 939 937 940 bzero ((char *) &sa, sizeof sa);938 memset (&sa, '\0', sizeof sa); 941 939 sa.sa_handler = child_handler; 942 940 sa.sa_flags = set_handler ? 0 : SA_RESTART; … … 1044 1042 #ifndef VMS 1045 1043 free (argv[0]); 1046 free ( (char *)argv);1044 free (argv); 1047 1045 #endif 1048 1046 child->file->update_status = 1; … … 1059 1057 { 1060 1058 free (argv[0]); 1061 free ( (char *)argv);1059 free (argv); 1062 1060 } 1063 1061 #endif … … 1120 1118 { 1121 1119 free (argv[0]); 1122 free ( (char *)argv);1120 free (argv); 1123 1121 goto next_command; 1124 1122 } … … 1131 1129 #ifndef VMS 1132 1130 free (argv[0]); 1133 free ( (char *)argv);1131 free (argv); 1134 1132 #endif 1135 1133 goto next_command; … … 1409 1407 #ifndef VMS 1410 1408 free (argv[0]); 1411 free ( (char *)argv);1409 free (argv); 1412 1410 #endif 1413 1411 … … 1491 1489 new_job (struct file *file) 1492 1490 { 1493 registerstruct commands *cmds = file->cmds;1494 registerstruct child *c;1491 struct commands *cmds = file->cmds; 1492 struct child *c; 1495 1493 char **lines; 1496 registerunsigned int i;1494 unsigned int i; 1497 1495 1498 1496 /* Let any previously decided-upon jobs that are waiting … … 1507 1505 1508 1506 /* 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 *)); 1510 1508 for (i = 0; i < cmds->ncommand_lines; ++i) 1511 1509 { … … 1533 1531 we processed (where IN points) and the new chunk 1534 1532 we are about to process (where REF points). */ 1535 bcopy (in, out, ref - in);1533 memmove (out, in, ref - in); 1536 1534 1537 1535 /* Move both pointers past the boring stuff. */ … … 1611 1609 `struct child', and add that to the chain. */ 1612 1610 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)); 1615 1613 c->file = file; 1616 1614 c->command_lines = lines; … … 1732 1730 /* The job is now primed. Start it running. 1733 1731 (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); 1735 1742 1736 1743 if (job_slots == 1 || not_parallel) … … 2125 2132 # endif 2126 2133 2127 new_argv = (char **)alloca ((1 + argc + 1) * sizeof (char *));2134 new_argv = alloca ((1 + argc + 1) * sizeof (char *)); 2128 2135 new_argv[0] = shell; 2129 2136 … … 2318 2325 "shift", "switch", "test", "times", "trap", 2319 2326 "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; 2324 2337 char *end; 2325 2338 int instring, word_has_equals, seen_nonequals, last_argument_was_empty; … … 2353 2366 else if (strcmp (shell, default_shell)) 2354 2367 { 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 : "")); 2359 2372 2360 2373 if (s1) … … 2367 2380 #else /* not WINDOWS32 */ 2368 2381 #if defined (__MSDOS__) || defined (__EMX__) 2369 else if (str icmp (shell, default_shell))2382 else if (strcasecmp (shell, default_shell)) 2370 2383 { 2371 2384 extern int _is_unixy_shell (const char *_path); … … 2409 2422 2410 2423 /* More than 1 arg per character is impossible. */ 2411 new_argv = (char **)xmalloc (i * sizeof (char *));2424 new_argv = xmalloc (i * sizeof (char *)); 2412 2425 2413 2426 /* 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); 2415 2428 end = ap + i; 2416 2429 … … 2451 2464 *(ap++) = *p; 2452 2465 } 2453 /* If there's a TABhere, skip it. */2454 if (p[1] == '\t')2466 /* If there's a command prefix char here, skip it. */ 2467 if (p[1] == cmd_prefix) 2455 2468 ++p; 2456 2469 } … … 2501 2514 ++p; 2502 2515 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) 2505 2519 ++p; 2506 2520 … … 2629 2643 /* Line was empty. */ 2630 2644 free (argstr); 2631 free ( (char *)new_argv);2645 free (new_argv); 2632 2646 return 0; 2633 2647 } … … 2642 2656 /* Free the old argument list we were working on. */ 2643 2657 free (argstr); 2644 free ( (char *)new_argv);2658 free (new_argv); 2645 2659 } 2646 2660 … … 2655 2669 char *dptr; 2656 2670 2657 buffer = (char *)xmalloc (strlen (line)+1);2671 buffer = xmalloc (strlen (line)+1); 2658 2672 2659 2673 ptr = line; … … 2672 2686 *dptr = 0; 2673 2687 2674 new_argv = (char **)xmalloc (2 * sizeof (char *));2688 new_argv = xmalloc (2 * sizeof (char *)); 2675 2689 new_argv[0] = buffer; 2676 2690 new_argv[1] = 0; … … 2708 2722 unsigned int line_len = strlen (line); 2709 2723 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); 2712 2726 char *command_ptr = NULL; /* used for batch_mode_shell mode */ 2713 2727 … … 2718 2732 2719 2733 ap = new_line; 2720 bcopy (shell, ap, shell_len);2734 memcpy (ap, shell, shell_len); 2721 2735 ap += shell_len; 2722 bcopy (minus_c, ap, sizeof (minus_c) - 1);2736 memcpy (ap, minus_c, sizeof (minus_c) - 1); 2723 2737 ap += sizeof (minus_c) - 1; 2724 2738 command_ptr = ap; … … 2749 2763 2750 2764 ++p; 2751 if (p[1] == '\t')2765 if (p[1] == cmd_prefix) 2752 2766 ++p; 2753 2767 … … 2784 2798 /* Need to allocate new_argv, although it's unused, because 2785 2799 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 *)); 2787 2801 new_argv[0] = xstrdup (""); 2788 2802 new_argv[1] = NULL; … … 2811 2825 2812 2826 /* create argv */ 2813 new_argv = (char **)xmalloc(3 * sizeof (char *));2827 new_argv = xmalloc(3 * sizeof (char *)); 2814 2828 if (unixy_shell) { 2815 2829 new_argv[0] = xstrdup (shell); … … 2823 2837 #endif /* WINDOWS32 */ 2824 2838 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); 2828 2840 #ifdef __EMX__ 2829 2841 else if (!unixy_shell) … … 2842 2854 { 2843 2855 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++; 2846 2859 } 2847 2860 else … … 2883 2896 2884 2897 /* exactly 3 arguments + NULL */ 2885 new_argv = (char **)xmalloc (4 * sizeof (char *));2898 new_argv = xmalloc (4 * sizeof (char *)); 2886 2899 /* Exactly strlen(shell) + strlen("/c") + strlen(line) + 3 times 2887 2900 the trailing '\0' */ 2888 new_argv[0] = (char *)malloc (sh_len + line_len + 5);2901 new_argv[0] = xmalloc (sh_len + line_len + 5); 2889 2902 memcpy (new_argv[0], shell, sh_len + 1); 2890 2903 new_argv[1] = new_argv[0] + sh_len + 1; … … 2901 2914 instead of recursively calling ourselves, because we 2902 2915 cannot backslash-escape the special characters (see above). */ 2903 new_argv = (char **)xmalloc (sizeof (char *));2916 new_argv = xmalloc (sizeof (char *)); 2904 2917 line_len = strlen (new_line) - shell_len - sizeof (minus_c) + 1; 2905 2918 new_argv[0] = xmalloc (line_len + 1); … … 2959 2972 } 2960 2973 2961 argv = (char **)malloc (argc * sizeof (char *));2974 argv = xmalloc (argc * sizeof (char *)); 2962 2975 if (argv == 0) 2963 2976 abort (); -
vendor/gnumake/current/job.h
r501 r900 67 67 extern struct child *children; 68 68 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));69 void new_job (struct file *file); 70 void reap_children (int block, int err); 71 void start_waiting_jobs (void); 72 72 73 extern char **construct_command_argv PARAMS ((char *line, char **restp, struct file *file, char** batch_file));73 char **construct_command_argv (char *line, char **restp, struct file *file, char** batch_file); 74 74 #ifdef VMS 75 extern int child_execute_job PARAMS ((char *argv, struct child *child));75 int child_execute_job (char *argv, struct child *child); 76 76 #elif defined(__EMX__) 77 extern int child_execute_job PARAMS ((int stdin_fd, int stdout_fd, char **argv, char **envp));77 int child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp); 78 78 #else 79 extern void child_execute_job PARAMS ((int stdin_fd, int stdout_fd, char **argv, char **envp));79 void child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp); 80 80 #endif 81 81 #ifdef _AMIGA 82 extern void exec_command PARAMS ((char **argv));82 void exec_command (char **argv); 83 83 #elif defined(__EMX__) 84 extern int exec_command PARAMS ((char **argv, char **envp));84 int exec_command (char **argv, char **envp); 85 85 #else 86 extern void exec_command PARAMS ((char **argv, char **envp));86 void exec_command (char **argv, char **envp); 87 87 #endif 88 88 89 89 extern unsigned int job_slots_used; 90 90 91 extern void block_sigs PARAMS ((void));91 void block_sigs (void); 92 92 #ifdef POSIX 93 extern void unblock_sigs PARAMS ((void));93 void unblock_sigs (void); 94 94 #else 95 95 #ifdef HAVE_SIGSETMASK -
vendor/gnumake/current/main.c
r501 r900 1 1 /* Argument parsing and main program of GNU Make. 2 2 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software 4 4 Foundation, Inc. 5 5 This file is part of GNU Make. … … 57 57 #endif 58 58 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)); 59 void init_dir (void); 60 void remote_setup (void); 61 void remote_cleanup (void); 62 RETSIGTYPE fatal_error_signal (int sig); 63 64 void print_variable_data_base (void); 65 void print_dir_data_base (void); 66 void print_rule_data_base (void); 67 void print_file_data_base (void); 68 void print_vpath_data_base (void); 69 70 void verify_file_data_base (void); 69 71 70 72 #if defined HAVE_WAITPID || defined HAVE_WAIT3 … … 73 75 74 76 #ifndef HAVE_UNISTD_H 75 externint chdir ();77 int chdir (); 76 78 #endif 77 79 #ifndef STDC_HEADERS 78 80 # ifndef sun /* Sun has an incorrect decl in a header. */ 79 extern void exit PARAMS ((int)) __attribute__ ((noreturn));81 void exit (int) __attribute__ ((noreturn)); 80 82 # endif 81 externdouble 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));83 double atof (); 84 #endif 85 86 static void clean_jobserver (int status); 87 static void print_data_base (void); 88 static void print_version (void); 89 static void decode_switches (int argc, char **argv, int env); 90 static void decode_env_switches (char *envar, unsigned int len); 91 static void define_makeflags (int all, int makefile); 92 static char *quote_for_env (char *out, const char *in); 93 static void initialize_global_hash_tables (void); 92 94 93 95 … … 104 106 flag_off, /* Turn int flag off. */ 105 107 string, /* One string per switch. */ 108 filename, /* A string containing a file name. */ 106 109 positive_int, /* A positive integer. */ 107 110 floating, /* A floating-point number (double). */ … … 109 112 } type; 110 113 111 char*value_ptr; /* Pointer to the value-holding variable. */114 void *value_ptr; /* Pointer to the value-holding variable. */ 112 115 113 116 unsigned int env:1; /* Can come from MAKEFLAGS. */ … … 115 118 unsigned int no_makefile:1; /* Don't propagate when remaking makefiles. */ 116 119 117 c har *noarg_value; /* Pointer to value used if no argument isgiven. */118 c har *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. */ 119 122 120 123 char *long_name; /* Long option name. */ … … 130 133 struct stringlist 131 134 { 132 c har **list; /* Nil-terminated list of strings. */135 const char **list; /* Nil-terminated list of strings. */ 133 136 unsigned int idx; /* Index into above. */ 134 137 unsigned int max; /* Number of pointers allocated. */ … … 158 161 159 162 int db_level = 0; 163 164 /* Output level (--verbosity). */ 165 166 static struct stringlist *verbosity_flags; 160 167 161 168 #ifdef WINDOWS32 … … 282 289 283 290 struct variable shell_var; 291 292 /* This character introduces a command: it's the first char on the line. */ 293 294 char cmd_prefix = '\t'; 284 295 285 296 … … 365 376 { 366 377 { '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" }, 371 382 #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, 381 390 "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" }, 388 396 #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" }, 392 399 #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" }, 399 404 { '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, 408 411 "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, 417 421 "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, 420 424 "warn-undefined-variables" }, 421 425 { 0, 0, 0, 0, 0, 0, 0, 0, 0 } … … 547 551 } 548 552 549 static struct file*550 e nter_command_line_file (char *name)553 static const char * 554 expand_command_line_file (char *name) 551 555 { 556 const char *cp; 557 char *expanded = 0; 558 552 559 if (name[0] == '\0') 553 560 fatal (NILF, _("empty string invalid as file name")); … … 555 562 if (name[0] == '~') 556 563 { 557 char *expanded = tilde_expand (name);564 expanded = tilde_expand (name); 558 565 if (expanded != 0) 559 name = expanded; /* Memory leak; I don't care. */566 name = expanded; 560 567 } 561 568 … … 581 588 } 582 589 583 return enter_file (xstrdup (name)); 590 cp = strcache_add (name); 591 592 if (expanded) 593 free (expanded); 594 595 return cp; 584 596 } 585 597 … … 597 609 decode_debug_flags (void) 598 610 { 599 c har **pp;611 const char **pp; 600 612 601 613 if (debug_flag) … … 732 744 733 745 int 734 find_and_set_default_shell (c har *token)746 find_and_set_default_shell (const char *token) 735 747 { 736 748 int sh_found = 0; 749 char *atoken = 0; 737 750 char *search_token; 738 751 char *tokend; … … 743 756 search_token = default_shell; 744 757 else 745 search_token = token; 746 758 atoken = search_token = xstrdup (token); 747 759 748 760 /* If the user explicitly requests the DOS cmd shell, obey that request. … … 754 766 || (tokend > search_token 755 767 && (tokend[-1] == '/' || tokend[-1] == '\\'))) 756 && !strc mpi(tokend, "cmd"))768 && !strcasecmp (tokend, "cmd")) 757 769 || ((tokend - 4 == search_token 758 770 || (tokend - 4 > search_token 759 771 && (tokend[-5] == '/' || tokend[-5] == '\\'))) 760 && !strc mpi(tokend - 4, "cmd.exe"))) {772 && !strcasecmp (tokend - 4, "cmd.exe"))) { 761 773 batch_mode_shell = 1; 762 774 unixy_shell = 0; … … 770 782 /* no new information, path already set or known */ 771 783 sh_found = 1; 772 } else if (file_exists_p (search_token)) {784 } else if (file_exists_p (search_token)) { 773 785 /* 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)); 776 788 DB (DB_VERBOSE, 777 789 (_("find_and_set_shell setting default_shell = %s\n"), default_shell)); … … 786 798 787 799 p = v->value; 788 ep = strchr (p, PATH_SEPARATOR_CHAR);800 ep = strchr (p, PATH_SEPARATOR_CHAR); 789 801 790 802 while (ep && *ep) { 791 803 *ep = '\0'; 792 804 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)); 796 808 sh_found = 1; 797 809 *ep = PATH_SEPARATOR_CHAR; 798 810 799 811 /* terminate loop */ 800 p += strlen (p);812 p += strlen (p); 801 813 } else { 802 814 *ep = PATH_SEPARATOR_CHAR; … … 804 816 } 805 817 806 ep = strchr (p, PATH_SEPARATOR_CHAR);818 ep = strchr (p, PATH_SEPARATOR_CHAR); 807 819 } 808 820 809 821 /* 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)); 813 825 sh_found = 1; 814 826 } … … 823 835 /* naive test */ 824 836 if (!unixy_shell && sh_found && 825 (strstr (default_shell, "sh") || strstr(default_shell, "SH"))) {837 (strstr (default_shell, "sh") || strstr (default_shell, "SH"))) { 826 838 unixy_shell = 1; 827 839 batch_mode_shell = 0; … … 832 844 #endif 833 845 846 if (atoken) 847 free (atoken); 848 834 849 return (sh_found); 835 850 } 836 851 #endif /* WINDOWS32 */ 837 852 838 #ifdef __MSDOS__ 839 853 #ifdef __MSDOS__ 840 854 static void 841 855 msdos_return_to_initial_directory (void) … … 844 858 chdir (directory_before_chdir); 845 859 } 846 #endif 847 848 extern char *mktemp PARAMS ((char *template));849 extern int mkstemp PARAMS ((char *template));860 #endif /* __MSDOS__ */ 861 862 char *mktemp (char *template); 863 int mkstemp (char *template); 850 864 851 865 FILE * … … 900 914 { 901 915 static char *stdin_nm = 0; 902 struct file *f;903 int i;904 916 int makefile_status = MAKE_SUCCESS; 905 char **p;906 917 struct dep *read_makefiles; 907 918 PATH_VAR (current_directory); … … 1026 1037 # else /* setvbuf not reversed. */ 1027 1038 /* 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); 1029 1040 # endif /* setvbuf reversed. */ 1030 1041 #elif HAVE_SETLINEBUF … … 1134 1145 1135 1146 #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; 1143 1157 #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 } 1150 1202 } 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 } 1187 1204 #ifdef WINDOWS32 1188 1205 /* If we didn't find a correctly spelled PATH we define PATH as … … 1230 1247 #if 0 1231 1248 /* People write things like: 1232 1249 MFLAGS="CC=gcc -pipe" "CFLAGS=-g" 1233 1250 and we set the -p, -i and -e switches. Doesn't seem quite right. */ 1234 1251 decode_env_switches (STRING_SIZE_TUPLE ("MFLAGS")); … … 1293 1310 && argv[0] != 0 1294 1311 && (argv[0][0] != '/' && (argv[0][0] == '\0' || argv[0][1] != ':')) 1295 # ifdef __EMX__1312 # ifdef __EMX__ 1296 1313 /* do not prepend cwd if argv[0] contains no '/', e.g. "make" */ 1297 1314 && (strchr (argv[0], '/') != 0 || strchr (argv[0], '\\') != 0) 1298 1315 # endif 1299 1316 ) 1300 argv[0] = concat (current_directory, "/", argv[0]);1317 argv[0] = xstrdup (concat (current_directory, "/", argv[0])); 1301 1318 #else /* !__MSDOS__ */ 1302 1319 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])); 1305 1327 #endif /* !__MSDOS__ */ 1306 1328 #endif /* WINDOWS32 */ … … 1333 1355 1334 1356 /* Now allocate a buffer big enough and fill it. */ 1335 p = value = (char *)alloca (len);1357 p = value = alloca (len); 1336 1358 for (cv = command_variables; cv != 0; cv = cv->next) 1337 1359 { … … 1363 1385 /* If there were -C flags, move ourselves about. */ 1364 1386 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]; 1375 1392 #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); 1383 1404 } 1384 #endif 1385 if (chdir (dir) < 0) 1386 pfatal_with_name (dir); 1387 if (expanded) 1388 free (expanded); 1389 } 1405 } 1390 1406 1391 1407 #ifdef WINDOWS32 … … 1425 1441 /* Construct the list of include directories to search. */ 1426 1442 1427 construct_include_path (include_directories == 0 ? (char **) 01428 1443 construct_include_path (include_directories == 0 1444 ? 0 : include_directories->list); 1429 1445 1430 1446 /* Figure out where we are now, after chdir'ing. */ … … 1457 1473 if (makefiles != 0) 1458 1474 { 1459 registerunsigned int i;1475 unsigned int i; 1460 1476 for (i = 0; i < makefiles->idx; ++i) 1461 1477 if (makefiles->list[i][0] == '-' && makefiles->list[i][1] == '\0') … … 1490 1506 tmpdir = DEFAULT_TMPDIR; 1491 1507 1492 template = (char *) alloca (strlen (tmpdir) 1493 + sizeof (DEFAULT_TMPFILE) + 1); 1508 template = alloca (strlen (tmpdir) + sizeof (DEFAULT_TMPFILE) + 1); 1494 1509 strcpy (template, tmpdir); 1495 1510 … … 1515 1530 pfatal_with_name (_("fwrite (temporary file)")); 1516 1531 } 1517 (void)fclose (outfile);1532 fclose (outfile); 1518 1533 1519 1534 /* Replace the name that read_all_makefiles will 1520 1535 see with the name of the temporary file. */ 1521 makefiles->list[i] = xstrdup(stdin_nm);1536 makefiles->list[i] = strcache_add (stdin_nm); 1522 1537 1523 1538 /* 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 } 1532 1549 } 1533 1550 } … … 1548 1565 If none of these are true, we don't need a signal handler at all. */ 1549 1566 { 1550 extern RETSIGTYPE child_handler PARAMS ((int sig));1567 RETSIGTYPE child_handler (int sig); 1551 1568 # if defined SIGCHLD 1552 1569 bsd_signal (SIGCHLD, child_handler); … … 1588 1605 define_default_variables (); 1589 1606 1590 default_file = enter_file ( ".DEFAULT");1607 default_file = enter_file (strcache_add (".DEFAULT")); 1591 1608 1592 1609 { … … 1598 1615 1599 1616 read_makefiles 1600 = read_all_makefiles (makefiles == 0 ? (char **)0 : makefiles->list);1617 = read_all_makefiles (makefiles == 0 ? 0 : makefiles->list); 1601 1618 1602 1619 #ifdef WINDOWS32 … … 1653 1670 if (jobserver_fds) 1654 1671 { 1655 c har *cp;1672 const char *cp; 1656 1673 unsigned int ui; 1657 1674 … … 1667 1684 fatal (NILF, 1668 1685 _("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])); 1669 1689 1670 1690 /* The combination of a pipe + !job_slots means we're using the … … 1709 1729 if (job_slots > 1) 1710 1730 { 1731 char *cp; 1711 1732 char c = '+'; 1712 1733 … … 1732 1753 /* Fill in the jobserver_fds struct for our children. */ 1733 1754 1755 cp = xmalloc ((sizeof ("1024")*2)+1); 1756 sprintf (cp, "%d,%d", job_fds[0], job_fds[1]); 1757 1734 1758 jobserver_fds = (struct stringlist *) 1735 1759 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; 1740 1762 jobserver_fds->idx = 1; 1741 1763 jobserver_fds->max = 1; … … 1787 1809 1788 1810 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 } 1797 1822 1798 1823 if (!restarts && new_files != 0) 1799 1824 { 1825 const char **p; 1800 1826 for (p = new_files->list; *p != 0; ++p) 1801 1827 { 1802 f = enter_command_line_file (*p);1828 struct file *f = enter_file (*p); 1803 1829 f->last_mtime = f->mtime_before_update = NEW_MTIME; 1804 1830 } … … 1832 1858 while (d != 0) 1833 1859 { 1834 registerstruct file *f = d->file;1860 struct file *f = d->file; 1835 1861 if (f->double_colon) 1836 1862 for (f = f->double_colon; f != NULL; f = f->prev) … … 1865 1891 if (f == NULL || !f->double_colon) 1866 1892 { 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)); 1870 1896 makefile_mtimes[mm_idx++] = file_mtime_no_search (d->file); 1871 1897 last = d; … … 1986 2012 char *p = &argv[i][2]; 1987 2013 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]; 1989 2016 else 1990 argv[i] = concat ("-f", makefiles->list[j], "");2017 argv[i] = xstrdup (concat ("-f", makefiles->list[j], "")); 1991 2018 ++j; 1992 2019 } … … 1996 2023 if (stdin_nm) 1997 2024 { 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, "")); 2001 2028 nargv[nargc] = 0; 2002 2029 } … … 2004 2031 if (directories != 0 && directories->idx > 0) 2005 2032 { 2006 char bad;2033 int bad = 1; 2007 2034 if (directory_before_chdir != 0) 2008 2035 { 2009 2036 if (chdir (directory_before_chdir) < 0) 2010 {2011 2037 perror_with_name ("chdir", ""); 2012 bad = 1;2013 }2014 2038 else 2015 2039 bad = 0; 2016 2040 } 2017 else2018 bad = 1;2019 2041 if (bad) 2020 2042 fatal (NILF, _("Couldn't change back to original directory.")); … … 2033 2055 2034 2056 #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 } 2057 2075 #else /* AMIGA */ 2058 2076 { … … 2120 2138 /* Free the makefile mtimes (if we allocated any). */ 2121 2139 if (makefile_mtimes) 2122 free ( (char *)makefile_mtimes);2140 free (makefile_mtimes); 2123 2141 } 2124 2142 … … 2132 2150 if (restarts && new_files != 0) 2133 2151 { 2152 const char **p; 2134 2153 for (p = new_files->list; *p != 0; ++p) 2135 2154 { 2136 f = enter_command_line_file (*p);2155 struct file *f = enter_file (*p); 2137 2156 f->last_mtime = f->mtime_before_update = NEW_MTIME; 2138 2157 } … … 2173 2192 fatal (NILF, _(".DEFAULT_GOAL contains more than one target")); 2174 2193 2175 default_goal_file = enter_file ( ns->name);2194 default_goal_file = enter_file (strcache_add (ns->name)); 2176 2195 2177 2196 ns->name = 0; /* It was reused by enter_file(). */ … … 2277 2296 2278 2297 case string: 2298 case filename: 2279 2299 case positive_int: 2280 2300 case floating: … … 2321 2341 2322 2342 if (! cv) { 2323 cv = (struct command_variable *)xmalloc (sizeof (*cv));2343 cv = xmalloc (sizeof (*cv)); 2324 2344 cv->variable = v; 2325 2345 cv->next = command_variables; … … 2332 2352 target! Enter it as a file and add it to the dep chain of 2333 2353 goals. */ 2334 struct file *f = enter_ command_line_file (arg);2354 struct file *f = enter_file (strcache_add (expand_command_line_file (arg))); 2335 2355 f->cmd_target = 1; 2336 2356 … … 2350 2370 { 2351 2371 /* Add this target name to the MAKECMDGOALS variable. */ 2352 struct variable * v;2353 c har *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) 2357 2377 value = f->name; 2358 2378 else … … 2360 2380 /* Paste the old and new values together */ 2361 2381 unsigned int oldlen, newlen; 2362 2363 oldlen = strlen (v->value); 2382 char *vp; 2383 2384 oldlen = strlen (gv->value); 2364 2385 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; 2369 2391 } 2370 2392 define_variable ("MAKECMDGOALS", 12, value, o_default, 0); … … 2462 2484 2463 2485 case string: 2486 case filename: 2464 2487 if (!doit) 2465 2488 break; 2466 2489 2467 2490 if (optarg == 0) 2468 optarg = cs->noarg_value;2491 optarg = xstrdup (cs->noarg_value); 2469 2492 else if (*optarg == '\0') 2470 2493 { … … 2481 2504 sl->max = 5; 2482 2505 sl->idx = 0; 2483 sl->list = (char **)xmalloc (5 * sizeof (char *));2506 sl->list = xmalloc (5 * sizeof (char *)); 2484 2507 *(struct stringlist **) cs->value_ptr = sl; 2485 2508 } … … 2487 2510 { 2488 2511 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 *)); 2492 2514 } 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; 2494 2519 sl->list[sl->idx] = 0; 2495 2520 break; … … 2576 2601 decode_env_switches (char *envar, unsigned int len) 2577 2602 { 2578 char *varref = (char *)alloca (2 + len + 2);2603 char *varref = alloca (2 + len + 2); 2579 2604 char *value, *p; 2580 2605 int argc; … … 2584 2609 varref[0] = '$'; 2585 2610 varref[1] = '('; 2586 bcopy (envar, &varref[2], len);2611 memcpy (&varref[2], envar, len); 2587 2612 varref[2 + len] = ')'; 2588 2613 varref[2 + len + 1] = '\0'; … … 2596 2621 2597 2622 /* 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 *)); 2599 2624 2600 2625 /* Allocate a buffer to copy the value into while we split it into words 2601 2626 and unquote it. We must use permanent storage for this because 2602 2627 decode_switches may store pointers into the passed argument words. */ 2603 p = (char *)xmalloc (2 * len);2628 p = xmalloc (2 * len); 2604 2629 2605 2630 /* getopt will look at the arguments starting at ARGV[1]. … … 2632 2657 need permanent storage for this in case decode_switches saves 2633 2658 pointers into the value. */ 2634 argv[1] = concat ("-", argv[1], "");2659 argv[1] = xstrdup (concat ("-", argv[1], "")); 2635 2660 2636 2661 /* Parse those words. */ … … 2646 2671 2647 2672 static char * 2648 quote_for_env (char *out, c har *in)2673 quote_for_env (char *out, const char *in) 2649 2674 { 2650 2675 while (*in != '\0') … … 2684 2709 struct flag *next; 2685 2710 const struct command_switch *cs; 2686 c har *arg;2711 const char *arg; 2687 2712 }; 2688 2713 struct flag *flags = 0; … … 2690 2715 #define ADD_FLAG(ARG, LEN) \ 2691 2716 do { \ 2692 struct flag *new = (struct flag *) alloca (sizeof (struct flag));\2717 struct flag *new = alloca (sizeof (struct flag)); \ 2693 2718 new->cs = cs; \ 2694 2719 new->arg = (ARG); \ … … 2708 2733 switch (cs->type) 2709 2734 { 2710 default:2711 abort ();2712 2713 2735 case ignore: 2714 2736 break; … … 2738 2760 else 2739 2761 { 2740 char *buf = (char *)alloca (30);2762 char *buf = alloca (30); 2741 2763 sprintf (buf, "%u", *(unsigned int *) cs->value_ptr); 2742 2764 ADD_FLAG (buf, strlen (buf)); … … 2759 2781 else 2760 2782 { 2761 char *buf = (char *)alloca (100);2783 char *buf = alloca (100); 2762 2784 sprintf (buf, "%g", *(double *) cs->value_ptr); 2763 2785 ADD_FLAG (buf, strlen (buf)); … … 2767 2789 #endif 2768 2790 2791 case filename: 2769 2792 case string: 2770 2793 if (all) … … 2773 2796 if (sl != 0) 2774 2797 { 2775 /* Add the elements in reverse order, because 2776 all the flags get reversed below; and the order2777 matters for someswitches (like -I). */2778 registerunsigned 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; 2779 2802 while (i-- > 0) 2780 2803 ADD_FLAG (sl->list[i], strlen (sl->list[i])); … … 2782 2805 } 2783 2806 break; 2807 2808 default: 2809 abort (); 2784 2810 } 2785 2811 … … 2790 2816 /* Construct the value in FLAGSTRING. 2791 2817 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); 2794 2820 p = flagstring; 2795 2821 words = 1; … … 2883 2909 if (posix_pedantic) 2884 2910 { 2885 bcopy (posixref, p, sizeof posixref - 1);2911 memcpy (p, posixref, sizeof posixref - 1); 2886 2912 p += sizeof posixref - 1; 2887 2913 } 2888 2914 else 2889 2915 { 2890 bcopy (ref, p, sizeof ref - 1);2916 memcpy (p, ref, sizeof ref - 1); 2891 2917 p += sizeof ref - 1; 2892 2918 } … … 3066 3092 if (print_data_base_flag) 3067 3093 print_data_base (); 3094 3095 verify_file_data_base (); 3068 3096 3069 3097 clean_jobserver (status); -
vendor/gnumake/current/make.1
r501 r900 165 165 over variables from makefiles. 166 166 .TP 0.5i 167 +\fB\-f\fR \fIfile\fR, \fB\-\-file\fR=\fIfile\fR, \fB\-\-makefile\fR=\fIFILE\fR167 \fB\-f\fR \fIfile\fR, \fB\-\-file\fR=\fIfile\fR, \fB\-\-makefile\fR=\fIFILE\fR 168 168 Use 169 169 .I file -
vendor/gnumake/current/make.h
r501 r900 39 39 #endif 40 40 41 42 /* Use prototypes if available. */43 #if defined (__cplusplus) || defined (__STDC__)44 # undef PARAMS45 # define PARAMS(protos) protos46 #else /* Not C++ or ANSI C. */47 # undef PARAMS48 # define PARAMS(protos) ()49 #endif /* C++ or ANSI C. */50 41 51 42 /* Specify we want GNU source code. This must be defined before any … … 151 142 # define NEED_GET_PATH_MAX 1 152 143 # 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) 145 unsigned int get_path_max (void); 155 146 #endif 156 147 … … 228 219 # include <stdlib.h> 229 220 # 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));221 void *malloc (int); 222 void *realloc (void *, int); 223 void free (void *); 224 225 void abort (void) __attribute__ ((noreturn)); 226 void exit (int) __attribute__ ((noreturn)); 236 227 # endif /* HAVE_STDLIB_H. */ 237 228 … … 243 234 #endif 244 235 #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 276 240 277 241 /* SCO Xenix has a buggy macro definition in <string.h>. */ 278 242 #undef strerror 279 243 #if !defined(__DECC) 280 extern char *strerror PARAMS ((int errnum));244 char *strerror (int errnum); 281 245 #endif 282 246 … … 290 254 291 255 #if !defined(HAVE_STRSIGNAL) 292 extern char *strsignal PARAMS ((int signum));256 char *strsignal (int signum); 293 257 #endif 294 258 … … 309 273 (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1)))) 310 274 # ifdef HAVE_CASE_INSENSITIVE_FS 311 /* This is only used on Windows/DOS platforms, so we assume strcmpi(). */312 275 # define strieq(a, b) \ 313 276 ((a) == (b) \ 314 277 || (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \ 315 && (*(a) == '\0' || !strc mpi((a) + 1, (b) + 1))))278 && (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1)))) 316 279 # else 317 280 # define strieq(a, b) streq(a, b) … … 323 286 #endif 324 287 #define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0) 325 #ifdef VMS326 extern int strcmpi (const char *,const char *);327 #endif328 288 329 289 #if defined(__GNUC__) || defined(ENUM_BITFIELDS) … … 348 308 349 309 /* 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) 360 322 # include <direct.h> 361 323 #endif … … 364 326 # include <fcntl.h> 365 327 # 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 331 void sync_Path_environment (void); 332 int kill (int pid, int sig); 333 char *end_of_token_w32 (const char *s, char stopchar); 334 int find_and_set_default_shell (const char *token); 373 335 374 336 /* indicates whether or not we have Bourne shell */ … … 400 362 401 363 #if HAVE_ANSI_COMPILER && USE_VARIADIC && HAVE_STDARG_H 402 externvoid message (int prefix, const char *fmt, ...)403 404 externvoid error (const struct floc *flocp, const char *fmt, ...)405 406 externvoid fatal (const struct floc *flocp, const char *fmt, ...)364 void message (int prefix, const char *fmt, ...) 365 __attribute__ ((__format__ (__printf__, 2, 3))); 366 void error (const struct floc *flocp, const char *fmt, ...) 367 __attribute__ ((__format__ (__printf__, 2, 3))); 368 void fatal (const struct floc *flocp, const char *fmt, ...) 407 369 __attribute__ ((noreturn, __format__ (__printf__, 2, 3))); 408 370 #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 *)); 371 void message (); 372 void error (); 373 void fatal (); 374 #endif 375 376 void die (int) __attribute__ ((noreturn)); 377 void log_working_directory (int); 378 void pfatal_with_name (const char *) __attribute__ ((noreturn)); 379 void perror_with_name (const char *, const char *); 380 char *savestring (const char *, unsigned int); 381 char *concat (const char *, const char *, const char *); 382 void *xmalloc (unsigned int); 383 void *xrealloc (void *, unsigned int); 384 char *xstrdup (const char *); 385 char *find_next_token (const char **, unsigned int *); 386 char *next_token (const char *); 387 char *end_of_token (const char *); 388 void collapse_continuations (char *); 389 char *lindex (const char *, const char *, int); 390 int alpha_compare (const void *, const void *); 391 void print_spaces (unsigned int); 392 char *find_percent (char *); 393 const char *find_percent_cached (const char **); 394 FILE *open_tmpfile (char **, const char *); 432 395 433 396 #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)); 397 int ar_name (const char *); 398 void ar_parse_name (const char *, char **, char **); 399 int ar_touch (const char *); 400 time_t ar_member_date (const char *); 401 402 typedef 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 407 long int ar_scan (const char *archive, ar_member_func_t function, const void *arg); 408 int ar_name_equal (const char *name, const char *mem, int truncated); 409 #ifndef VMS 410 int ar_member_touch (const char *arname, const char *memname); 411 #endif 412 #endif 413 414 int dir_file_exists_p (const char *, const char *); 415 int file_exists_p (const char *); 416 int file_impossible_p (const char *); 417 void file_impossible (const char *); 418 const char *dir_name (const char *); 419 void hash_init_directories (void); 420 421 void define_default_variables (void); 422 void set_default_suffixes (void); 423 void install_default_suffix_rules (void); 424 void install_default_implicit_rules (void); 425 426 void build_vpath_lists (void); 427 void construct_vpath_list (char *pattern, char *dirpath); 428 const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr); 429 int gpath_search (const char *file, unsigned int len); 430 431 void construct_include_path (const char **arg_dirs); 432 433 void user_access (void); 434 void make_access (void); 435 void child_access (void); 436 437 void close_stdout (void); 438 439 char *strip_whitespace (const char **begpp, const char **endpp); 466 440 467 441 /* 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));442 void strcache_init (void); 443 void strcache_print_stats (const char *prefix); 444 int strcache_iscached (const char *str); 445 const char *strcache_add (const char *str); 446 const char *strcache_add_len (const char *str, int len); 447 int strcache_setbufsize (int size); 474 448 475 449 #ifdef HAVE_VFORK_H … … 482 456 #if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32) 483 457 484 externlong int atol ();458 long int atol (); 485 459 # ifndef VMS 486 externlong int lseek ();460 long int lseek (); 487 461 # endif 488 462 … … 491 465 #ifdef HAVE_GETCWD 492 466 # if !defined(VMS) && !defined(__DECC) 493 externchar *getcwd ();494 # endif 495 #else 496 externchar *getwd ();467 char *getcwd (); 468 # endif 469 #else 470 char *getwd (); 497 471 # 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 */ 481 int strcasecmp (const char *s1, const char *s2); 482 # endif 498 483 #endif 499 484 … … 513 498 extern int batch_mode_shell; 514 499 500 extern char cmd_prefix; 501 515 502 extern unsigned int job_slots; 516 503 extern int job_fds[2]; … … 564 551 #endif 565 552 566 567 553 #ifdef __EMX__ 568 # if !HAVE_STRCASECMP569 # define strcasecmp stricmp570 # endif571 572 554 # if !defined chdir 573 555 # define chdir _chdir2 … … 608 590 to do it ourselves here. */ 609 591 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 162 162 163 163 164 /* Return a newly-allocated string whose contents165 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. */ 166 166 167 167 char * … … 169 169 { 170 170 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'; 186 189 187 190 return result; … … 341 344 #undef xstrdup 342 345 343 char*346 void * 344 347 xmalloc (unsigned int size) 345 348 { 346 349 /* 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); 348 351 if (result == 0) 349 352 fatal (NILF, _("virtual memory exhausted")); … … 352 355 353 356 354 char*355 xrealloc ( char*ptr, unsigned int size)356 { 357 char*result;357 void * 358 xrealloc (void *ptr, unsigned int size) 359 { 360 void *result; 358 361 359 362 /* Some older implementations of realloc() don't conform to ANSI. */ … … 375 378 result = strdup (ptr); 376 379 #else 377 result = (char *)malloc (strlen (ptr) + 1);380 result = malloc (strlen (ptr) + 1); 378 381 #endif 379 382 … … 384 387 return result; 385 388 #else 386 return strcpy (result, ptr);389 return strcpy (result, ptr); 387 390 #endif 388 391 } … … 393 396 savestring (const char *str, unsigned int length) 394 397 { 395 register char *out = (char *)xmalloc (length + 1);398 char *out = xmalloc (length + 1); 396 399 if (length > 0) 397 bcopy (str, out, length);400 memcpy (out, str, length); 398 401 out[length] = '\0'; 399 402 return out; … … 434 437 */ 435 438 char * 436 end_of_token_w32 (c har *s, char stopchar)437 { 438 registerchar *p = s;439 registerint backslash = 0;439 end_of_token_w32 (const char *s, char stopchar) 440 { 441 const char *p = s; 442 int backslash = 0; 440 443 441 444 while (*p != '\0' && *p != stopchar … … 455 458 } 456 459 457 return p;460 return (char *)p; 458 461 } 459 462 #endif … … 469 472 } 470 473 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. */ 473 477 474 478 char * 475 find_next_token (char **ptr, unsigned int *lengthptr) 476 { 477 char *p = next_token (*ptr); 478 char *end; 479 find_next_token (const char **ptr, unsigned int *lengthptr) 480 { 481 const char *p = next_token (*ptr); 479 482 480 483 if (*p == '\0') 481 484 return 0; 482 485 483 *ptr = end = end_of_token (p);486 *ptr = end_of_token (p); 484 487 if (lengthptr != 0) 485 *lengthptr = end - p; 486 return p; 488 *lengthptr = *ptr - p; 489 490 return (char *)p; 487 491 } 488 492 … … 494 498 alloc_dep () 495 499 { 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)); 498 502 return d; 499 503 } … … 505 509 free_dep (struct dep *d) 506 510 { 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); 514 512 } 515 513 … … 520 518 copy_dep_chain (const struct dep *d) 521 519 { 522 register struct dep *c;523 520 struct dep *firstnew = 0; 524 521 struct dep *lastnew = 0; … … 526 523 while (d != 0) 527 524 { 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)); 535 527 536 528 c->next = 0; … … 559 551 } 560 552 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 556 void 557 free_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 574 int 575 strcasecmp (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 } 591 592 } 592 593 #endif -
vendor/gnumake/current/read.c
r501 r900 38 38 #include <pwd.h> 39 39 #else 40 struct passwd *getpwnam PARAMS ((char *name));40 struct passwd *getpwnam (char *name); 41 41 #endif 42 42 #endif … … 89 89 /* Default directories to search for include files in */ 90 90 91 static c har *default_include_directories[] =91 static const char *default_include_directories[] = 92 92 { 93 93 #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 "." 99 97 #endif 100 98 INCLUDEDIR, … … 109 107 /* List of directories to search for include files in */ 110 108 111 static c har **include_directories;109 static const char **include_directories; 112 110 113 111 /* Maximum length of an element of the above. */ … … 124 122 static struct dep *read_makefiles = 0; 125 123 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)); 124 static int eval_makefile (const char *filename, int flags); 125 static int eval (struct ebuffer *buffer, int flags); 126 127 static long readline (struct ebuffer *ebuf); 128 static void do_define (char *name, unsigned int namelen, 129 enum variable_origin origin, struct ebuffer *ebuf); 130 static int conditional_line (char *line, int len, const struct floc *flocp); 131 static 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); 136 static void record_target_var (struct nameseq *filenames, char *defn, 137 enum variable_origin origin, int enabled, 138 const struct floc *flocp); 139 static enum make_word_type get_next_mword (char *buffer, char *delim, 140 char **startp, unsigned int *length); 141 static void remove_comments (char *line); 142 static char *find_char_unquote (char *string, int stop1, int stop2, 143 int blank, int ignorevars); 147 144 148 145 … … 150 147 151 148 struct dep * 152 read_all_makefiles (c har **makefiles)149 read_all_makefiles (const char **makefiles) 153 150 { 154 151 unsigned int num_makefiles = 0; … … 184 181 p = value; 185 182 186 while ((name = find_next_token ( &p, &length)) != 0)183 while ((name = find_next_token ((const char **)&p, &length)) != 0) 187 184 { 188 185 if (*p != '\0') … … 251 248 { 252 249 struct dep *d = alloc_dep (); 253 d->file = enter_file ( *p);250 d->file = enter_file (strcache_add (*p)); 254 251 d->file->dontcare = 1; 255 252 /* Tell update_goal_chain to bail out as soon as this file is … … 278 275 struct conditionals *save = conditionals; 279 276 280 bzero ((char *) new, sizeof (*new));277 memset (new, '\0', sizeof (*new)); 281 278 conditionals = new; 282 279 … … 301 298 302 299 static int 303 eval_makefile (c har *filename, int flags)300 eval_makefile (const char *filename, int flags) 304 301 { 305 302 struct dep *deps; … … 307 304 const struct floc *curfile; 308 305 char *expanded = 0; 309 char *included = 0;310 306 int makefile_errno; 311 307 int r; 312 308 313 ebuf.floc.filenm = strcache_add (filename); 309 filename = strcache_add (filename); 310 ebuf.floc.filenm = filename; 314 311 ebuf.floc.lineno = 1; 315 312 … … 348 345 if (ebuf.fp == 0 && (flags & RM_INCLUDED) && *filename != '/') 349 346 { 350 registerunsigned int i;347 unsigned int i; 351 348 for (i = 0; include_directories[i] != 0; ++i) 352 349 { 353 included = concat (include_directories[i], "/", filename);350 const char *included = concat (include_directories[i], "/", filename); 354 351 ebuf.fp = fopen (included, "r"); 355 352 if (ebuf.fp) 356 353 { 357 filename = included;354 filename = strcache_add (included); 358 355 break; 359 356 } 360 free (included); 361 } 362 /* If we're not using it, we already freed it above. */ 363 if (filename != included) 364 included = 0; 357 } 365 358 } 366 359 … … 371 364 deps->file = lookup_file (filename); 372 365 if (deps->file == 0) 373 deps->file = enter_file ( xstrdup (filename));366 deps->file = enter_file (filename); 374 367 filename = deps->file->name; 375 368 deps->changed = flags; … … 379 372 if (expanded) 380 373 free (expanded); 381 if (included)382 free (included);383 374 384 375 /* If the makefile can't be found at all, give up entirely. */ … … 470 461 long nlines = 0; 471 462 int two_colon = 0; 472 char *pattern = 0, *pattern_percent; 463 const char *pattern = 0; 464 const char *pattern_percent; 473 465 struct floc *fstart; 474 466 struct floc fi; … … 487 479 commands_idx = 0; \ 488 480 no_targets = 0; \ 489 if (pattern) { free(pattern); pattern = 0; }\481 pattern = 0; \ 490 482 } while (0) 491 483 … … 512 504 unsigned int linelen; 513 505 char *line; 514 intlen;506 unsigned int wlen; 515 507 char *p; 516 508 char *p2; … … 533 525 /* Check for a shell command line first. 534 526 If it is not one, we can stop treating tab specially. */ 535 if (line[0] == '\t')527 if (line[0] == cmd_prefix) 536 528 { 537 529 if (no_targets) … … 558 550 commands = xrealloc (commands, commands_len); 559 551 } 560 bcopy (line, &commands[commands_idx], linelen);552 memcpy (&commands[commands_idx], line, linelen); 561 553 commands_idx += linelen; 562 554 commands[commands_idx++] = '\n'; … … 574 566 collapsed_length = linelen+1; 575 567 if (collapsed) 576 free ( (char *)collapsed);577 collapsed = (char *)xmalloc (collapsed_length);568 free (collapsed); 569 collapsed = xmalloc (collapsed_length); 578 570 } 579 571 strcpy (collapsed, line); … … 583 575 584 576 /* 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)) 586 578 p = collapsed; 587 579 while (isspace ((unsigned char)*p)) … … 598 590 for (p2 = p+1; *p2 != '\0' && !isspace ((unsigned char)*p2); ++p2) 599 591 ; 600 len = p2 - p;592 wlen = p2 - p; 601 593 602 594 /* Find the start of the second token. If it looks like a target or … … 621 613 if (!in_ignored_define) 622 614 { 623 int i = conditional_line (p, len, fstart);615 int i = conditional_line (p, wlen, fstart); 624 616 if (i != -2) 625 617 { … … 713 705 else 714 706 { 715 unsigned int len; 707 unsigned int l; 708 const char *cp; 716 709 char *ap; 717 710 718 711 /* Expand the line so we can use indirect and constructed 719 712 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)) 724 717 { 725 v = lookup_variable (p, l en);718 v = lookup_variable (p, l); 726 719 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); 729 721 v->export = v_export; 730 722 } … … 742 734 else 743 735 { 744 unsigned int l en;736 unsigned int l; 745 737 struct variable *v; 738 const char *cp; 746 739 char *ap; 747 740 748 741 /* Expand the line so we can use indirect and constructed 749 742 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)) 754 747 { 755 v = lookup_variable (p, l en);748 v = lookup_variable (p, l); 756 749 if (v == 0) 757 v = define_variable_loc (p, l en, "", o_file, 0, fstart);750 v = define_variable_loc (p, l, "", o_file, 0, fstart); 758 751 759 752 v->export = v_noexport; … … 768 761 if (word1eq ("vpath")) 769 762 { 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); 774 768 if (p != 0) 775 769 { 776 pattern = savestring (p, len);777 p = find_next_token (& p2, &len);770 vpat = savestring (p, l); 771 p = find_next_token (&cp, &l); 778 772 /* No searchpath means remove all previous 779 773 selective VPATH's with the same pattern. */ … … 781 775 else 782 776 /* 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); 787 781 788 782 goto rule_complete; … … 829 823 { 830 824 struct nameseq *next = files->next; 831 c har *name = files->name;825 const char *name = files->name; 832 826 int r; 833 827 834 free ( (char *)files);828 free (files); 835 829 files = next; 836 830 … … 839 833 if (!r && !noerror) 840 834 error (fstart, "%s: %s", name, strerror (errno)); 841 free (name);842 835 } 843 836 … … 855 848 was no preceding target, and the line might have been usable as a 856 849 variable definition. But now we know it is definitely lossage. */ 857 if (line[0] == '\t')850 if (line[0] == cmd_prefix) 858 851 fatal(fstart, _("commands commence before first target")); 859 852 … … 873 866 int exported; 874 867 char *cmdleft, *semip, *lb_next; 875 unsigned int len,plen = 0;868 unsigned int plen = 0; 876 869 char *colonp; 877 870 const char *end, *beg; /* Helpers for whitespace stripping. */ … … 902 895 beginning, expanding as we go, and looking for "interesting" 903 896 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); 905 898 switch (wtype) 906 899 { … … 923 916 } 924 917 925 p2 = variable_expand_string(NULL, lb_next, len);918 p2 = variable_expand_string(NULL, lb_next, wlen); 926 919 927 920 while (1) 928 921 { 929 lb_next += len;922 lb_next += wlen; 930 923 if (cmdleft == 0) 931 924 { … … 972 965 break; 973 966 974 wtype = get_next_mword(lb_next, NULL, &lb_next, & len);967 wtype = get_next_mword(lb_next, NULL, &lb_next, &wlen); 975 968 if (wtype == w_eol) 976 969 break; … … 978 971 p2 += strlen(p2); 979 972 *(p2++) = ' '; 980 p2 = variable_expand_string(p2, lb_next, len);973 p2 = variable_expand_string(p2, lb_next, wlen); 981 974 /* We don't need to worry about cmdleft here, because if it was 982 975 found in the variable_buffer the entire buffer has already … … 1033 1026 unsigned int l = p2 - variable_buffer; 1034 1027 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); 1037 1029 p2 = variable_buffer + l; 1038 1030 } … … 1041 1033 comes after it looks like a variable definition. */ 1042 1034 1043 wtype = get_next_mword (p2, NULL, &p, & len);1035 wtype = get_next_mword (p2, NULL, &p, &wlen); 1044 1036 1045 1037 v_origin = o_file; … … 1050 1042 { 1051 1043 v_origin = o_override; 1052 wtype = get_next_mword (p+ len, NULL, &p, &len);1044 wtype = get_next_mword (p+wlen, NULL, &p, &wlen); 1053 1045 } 1054 1046 else if (word1eq ("export")) 1055 1047 { 1056 1048 exported = 1; 1057 wtype = get_next_mword (p+ len, NULL, &p, &len);1049 wtype = get_next_mword (p+wlen, NULL, &p, &wlen); 1058 1050 } 1059 1051 } 1060 1052 1061 1053 if (wtype != w_eol) 1062 wtype = get_next_mword (p+ len, NULL, NULL, NULL);1054 wtype = get_next_mword (p+wlen, NULL, NULL, NULL); 1063 1055 1064 1056 if (wtype == w_varassign) … … 1135 1127 { 1136 1128 int check_again; 1137 1138 1129 do { 1139 1130 check_again = 0; … … 1157 1148 else if (target->next != 0) 1158 1149 fatal (fstart, _("multiple target patterns")); 1150 pattern_percent = find_percent_cached (&target->name); 1159 1151 pattern = target->name; 1160 pattern_percent = find_percent (pattern);1161 1152 if (pattern_percent == 0) 1162 1153 fatal (fstart, _("target pattern contains no `%%'")); 1163 free ( (char *)target);1154 free (target); 1164 1155 } 1165 1156 else … … 1175 1166 /* Put all the prerequisites here; they'll be parsed later. */ 1176 1167 deps = alloc_dep (); 1177 deps->name = s avestring(beg, end - beg + 1);1168 deps->name = strcache_add_len (beg, end - beg + 1); 1178 1169 } 1179 1170 else … … 1184 1175 { 1185 1176 /* Semicolon means rest of line is a command. */ 1186 unsigned int l en= strlen (cmdleft);1177 unsigned int l = strlen (cmdleft); 1187 1178 1188 1179 cmds_started = fstart->lineno; 1189 1180 1190 1181 /* Add this command line to the buffer. */ 1191 if (l en+ 2 > commands_len)1182 if (l + 2 > commands_len) 1192 1183 { 1193 commands_len = (l en+ 2) * 2;1194 commands = (char *)xrealloc (commands, commands_len);1184 commands_len = (l + 2) * 2; 1185 commands = xrealloc (commands, commands_len); 1195 1186 } 1196 bcopy (cmdleft, commands, len);1197 commands_idx += l en;1187 memcpy (commands, cmdleft, l); 1188 commands_idx += l; 1198 1189 commands[commands_idx++] = '\n'; 1199 1190 } … … 1217 1208 if (**default_goal_name == '\0' && set_default) 1218 1209 { 1219 c har*name;1210 const char *name; 1220 1211 struct dep *d; 1221 1212 struct nameseq *t = filenames; … … 1252 1243 for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next) 1253 1244 { 1254 register unsigned int len= strlen (dep_name (d2));1255 if (!strneq (name, dep_name (d2), l en))1245 unsigned int l = strlen (dep_name (d2)); 1246 if (!strneq (name, dep_name (d2), l)) 1256 1247 continue; 1257 if (streq (name + l en, dep_name (d)))1248 if (streq (name + l, dep_name (d))) 1258 1249 { 1259 1250 reject = 1; … … 1294 1285 1295 1286 if (collapsed) 1296 free ( (char *)collapsed);1297 free ( (char *)commands);1287 free (collapsed); 1288 free (commands); 1298 1289 1299 1290 return 1; … … 1329 1320 int nlevels = 1; 1330 1321 unsigned int length = 100; 1331 char *definition = (char *)xmalloc (length);1322 char *definition = xmalloc (length); 1332 1323 unsigned int idx = 0; 1333 1324 char *p; 1334 1325 1335 1326 /* 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); 1338 1329 var[namelen] = '\0'; 1339 1330 var = variable_expand (var); … … 1361 1352 1362 1353 /* Stop if we find an 'endef' */ 1363 if (line[0] != '\t')1354 if (line[0] != cmd_prefix) 1364 1355 { 1365 1356 p = next_token (line); … … 1404 1395 { 1405 1396 length = (idx + len) * 2; 1406 definition = (char *)xrealloc (definition, length + 1);1397 definition = xrealloc (definition, length + 1); 1407 1398 } 1408 1399 1409 bcopy (line, &definition[idx], len);1400 memcpy (&definition[idx], line, len); 1410 1401 idx += len; 1411 1402 /* Separate lines with a newline. */ … … 1535 1526 { 1536 1527 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); 1539 1530 } 1540 1531 … … 1543 1534 { 1544 1535 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); 1549 1540 } 1550 1541 … … 1590 1581 else 1591 1582 { 1592 /* " Ifeq" or "ifneq". */1583 /* "ifeq" or "ifneq". */ 1593 1584 char *s1, *s2; 1594 unsigned int l en;1585 unsigned int l; 1595 1586 char termin = *line == '(' ? ',' : *line; 1596 1587 … … 1632 1623 /* We must allocate a new copy of the expanded string because 1633 1624 variable_expand re-uses the same buffer. */ 1634 l en= 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); 1637 1628 1638 1629 if (termin != ',') … … 1647 1638 if (termin == ')') 1648 1639 { 1649 registerint count = 0;1640 int count = 0; 1650 1641 s2 = next_token (line); 1651 1642 for (line = s2; *line != '\0'; ++line) … … 1782 1773 { 1783 1774 struct variable *v; 1784 registerchar *name = filenames->name;1785 c har *fname;1786 c har *percent;1775 const char *name = filenames->name; 1776 const char *fname; 1777 const char *percent; 1787 1778 struct pattern_var *p; 1788 1779 1789 1780 nextf = filenames->next; 1790 free ( (char *)filenames);1781 free (filenames); 1791 1782 1792 1783 /* If it's a pattern target, then add it to the pattern-specific 1793 1784 variable list. */ 1794 percent = find_percent (name);1785 percent = find_percent_cached (&name); 1795 1786 if (percent) 1796 1787 { … … 1820 1811 f = lookup_file (name); 1821 1812 if (!f) 1822 f = enter_file ( name);1813 f = enter_file (strcache_add (name)); 1823 1814 else if (f->double_colon) 1824 1815 f = f->double_colon; … … 1857 1848 } 1858 1849 } 1859 1860 /* Free name if not needed further. */1861 if (name != fname && (name < fname || name > fname + strlen (fname)))1862 free (name);1863 1850 } 1864 1851 } … … 1877 1864 1878 1865 static void 1879 record_files (struct nameseq *filenames, char *pattern, char *pattern_percent, 1880 struct dep *deps, unsigned int cmds_started, char *commands, 1866 record_files (struct nameseq *filenames, const char *pattern, 1867 const char *pattern_percent, struct dep *deps, 1868 unsigned int cmds_started, char *commands, 1881 1869 unsigned int commands_idx, int two_colon, 1882 1870 const struct floc *flocp) … … 1885 1873 int implicit = 0; 1886 1874 unsigned int max_targets = 0, target_idx = 0; 1887 c har **targets = 0, **target_percents = 0;1875 const char **targets = 0, **target_percents = 0; 1888 1876 struct commands *cmds; 1889 1877 … … 1897 1885 if (commands_idx > 0) 1898 1886 { 1899 cmds = (struct commands *)xmalloc (sizeof (struct commands));1887 cmds = xmalloc (sizeof (struct commands)); 1900 1888 cmds->fileinfo.filenm = flocp->filenm; 1901 1889 cmds->fileinfo.lineno = cmds_started; … … 1908 1896 for (; filenames != 0; filenames = nextf) 1909 1897 { 1910 c har *name = filenames->name;1898 const char *name = filenames->name; 1911 1899 struct file *f; 1912 1900 struct dep *this = 0; 1913 c har *implicit_percent;1901 const char *implicit_percent; 1914 1902 1915 1903 nextf = filenames->next; … … 1924 1912 second_expansion = 1; 1925 1913 1926 implicit_percent = find_percent (name);1914 implicit_percent = find_percent_cached (&name); 1927 1915 implicit |= implicit_percent != 0; 1928 1916 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 1935 1917 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 1937 1925 if (targets == 0) 1938 1926 { 1939 1927 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 *)); 1942 1930 target_idx = 0; 1943 1931 } … … 1945 1933 { 1946 1934 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 *)); 1952 1938 } 1953 1939 targets[target_idx] = name; … … 1976 1962 /* Single-colon. Combine these dependencies 1977 1963 with others in file's existing record, if any. */ 1978 f = enter_file ( name);1964 f = enter_file (strcache_add (name)); 1979 1965 1980 1966 if (f->double_colon) … … 2082 2068 fatal (flocp, 2083 2069 _("target file `%s' has both : and :: entries"), f->name); 2084 f = enter_file ( name);2070 f = enter_file (strcache_add (name)); 2085 2071 /* If there was an existing entry and it was a double-colon entry, 2086 2072 enter_file will have returned a new one, making it the prev … … 2101 2087 if (pattern) 2102 2088 { 2103 static c har *percent = "%";2089 static const char *percent = "%"; 2104 2090 char *buffer = variable_expand (""); 2105 char *o = patsubst_expand (buffer, name, pattern, percent,2106 pattern_percent+1, percent+1);2107 f->stem = s avestring(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); 2108 2094 if (this) 2109 2095 { 2110 2096 this->staticpattern = 1; 2111 this->stem = xstrdup (f->stem);2097 this->stem = f->stem; 2112 2098 } 2113 2099 } 2114 2100 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; 2122 2102 2123 2103 /* If this target is a default target, update DEFAULT_GOAL_FILE. */ … … 2130 2110 if (implicit) 2131 2111 { 2132 targets[target_idx] = 0;2133 target_percents[target_idx] = 0;2134 2112 if (deps) 2135 2113 deps->need_2nd_expansion = second_expansion; 2136 create_pattern_rule (targets, target_percents, t wo_colon, deps, cmds, 1);2137 free ((char *) target_percents);2114 create_pattern_rule (targets, target_percents, target_idx, 2115 two_colon, deps, cmds, 1); 2138 2116 } 2139 2117 } … … 2154 2132 { 2155 2133 unsigned int string_len = 0; 2156 registerchar *p = string;2134 char *p = string; 2157 2135 2158 2136 if (ignorevars) … … 2213 2191 { 2214 2192 /* Search for more backslashes. */ 2215 registerint i = -2;2193 int i = -2; 2216 2194 while (&p[i] >= string && p[i] == '\\') 2217 2195 --i; … … 2222 2200 /* The number of backslashes is now -I. 2223 2201 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; 2226 2204 if (i % 2 == 0) 2227 2205 /* All the backslashes quoted each other; the STOPCHAR was … … 2240 2218 } 2241 2219 2242 /* Search PATTERN for an unquoted % . */2220 /* Search PATTERN for an unquoted % and handle quoting. */ 2243 2221 2244 2222 char * … … 2246 2224 { 2247 2225 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 2234 const char * 2235 find_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; 2248 2302 } 2249 2303 … … 2268 2322 struct nameseq *new1, *lastnew1; 2269 2323 char *p = *stringp; 2270 char *q;2271 char *name;2272 2324 2273 2325 #ifdef VMS … … 2279 2331 while (1) 2280 2332 { 2333 const char *name; 2334 char *q; 2335 2281 2336 /* Skip whitespace; see if any more names are left. */ 2282 2337 p = next_token (p); … … 2286 2341 break; 2287 2342 2288 /* Yes, find end ofnext name. */2343 /* There are, so find the end of the next name. */ 2289 2344 q = p; 2290 2345 p = find_char_unquote (q, stopchar, VMS_COMMA, 1, 0); … … 2298 2353 && !(isspace ((unsigned char)p[1]) || !p[1] 2299 2354 || isspace ((unsigned char)p[-1]))) 2300 {2301 2355 p = find_char_unquote (p+1, stopchar, VMS_COMMA, 1, 0); 2302 }2303 2356 #endif 2304 2357 #ifdef HAVE_DOS_PATHS … … 2334 2387 if (q == p) 2335 2388 /* ".///" was stripped to "". */ 2336 #if def VMS2389 #if defined(VMS) 2337 2390 continue; 2391 #elif defined(_AMIGA) 2392 name = ""; 2338 2393 #else 2339 #ifdef _AMIGA 2340 name = savestring ("", 0); 2341 #else 2342 name = savestring ("./", 2); 2343 #endif 2394 name = "./"; 2344 2395 #endif 2345 2396 else … … 2365 2416 *q2++ = *q1++; 2366 2417 } 2367 name = s avestring(qbase, p1 - qbase);2418 name = strcache_add_len (qbase, p1 - qbase); 2368 2419 free (qbase); 2369 2420 } 2370 2421 #else 2371 name = s avestring(q, p - q);2422 name = strcache_add_len (q, p - q); 2372 2423 #endif 2373 2424 2374 2425 /* Add it to the front of the chain. */ 2375 new1 = (struct nameseq *)xmalloc (size);2426 new1 = xmalloc (size); 2376 2427 new1->name = name; 2377 2428 new1->next = new; … … 2416 2467 /* Copy "lib(" into LIBNAME. */ 2417 2468 ++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); 2420 2471 libname[paren - n->name] = '\0'; 2421 2472 … … 2425 2476 Edit it out of the chain and free its storage. */ 2426 2477 lastn->next = n->next; 2427 free (n->name); 2428 free ((char *) n); 2478 free (n); 2429 2479 /* LASTN->next is the new stopping elt for the loop below. */ 2430 2480 n = lastn->next; … … 2433 2483 { 2434 2484 /* 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, ")")); 2438 2486 } 2439 2487 … … 2448 2496 lastn = new1; 2449 2497 new1 = new1->next; 2450 free (lastn->name); 2451 free ((char *) lastn); 2498 free (lastn); 2452 2499 } 2453 2500 else 2454 2501 { 2455 2502 /* 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, "")); 2459 2504 new1 = new1->next; 2460 2505 } … … 2466 2511 while (new1 != n) 2467 2512 { 2468 name = concat (libname, new1->name, ")"); 2469 free (new1->name); 2470 new1->name = name; 2513 new1->name = strcache_add (concat (libname, new1->name, ")")); 2471 2514 lastnew1 = new1; 2472 2515 new1 = new1->next; … … 2636 2679 unsigned long off = p - start; 2637 2680 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); 2640 2682 p = start + off; 2641 2683 end = start + ebuf->size; … … 2840 2882 2841 2883 void 2842 construct_include_path (c har **arg_dirs)2884 construct_include_path (const char **arg_dirs) 2843 2885 { 2844 register unsigned int i;2845 2886 #ifdef VAXC /* just don't ask ... */ 2846 2887 stat_t stbuf; … … 2848 2889 struct stat stbuf; 2849 2890 #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; 2857 2900 2858 2901 #ifdef __MSDOS__ 2859 defsize++; 2902 /* Add one for $DJDIR. */ 2903 ++idx; 2860 2904 #endif 2861 2905 2906 dirs = xmalloc (idx * sizeof (const char *)); 2907 2908 idx = 0; 2909 max_incl_len = 0; 2910 2862 2911 /* 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) 2866 2915 while (*arg_dirs != 0) 2867 2916 { 2868 char *dir = *arg_dirs++; 2917 const char *dir = *(arg_dirs++); 2918 char *expanded = 0; 2869 2919 int e; 2870 2920 2871 2921 if (dir[0] == '~') 2872 2922 { 2873 char *expanded = tilde_expand (dir);2923 expanded = tilde_expand (dir); 2874 2924 if (expanded != 0) 2875 2925 dir = expanded; … … 2878 2928 EINTRLOOP (e, stat (dir, &stbuf)); 2879 2929 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); 2891 2942 } 2892 2943 2893 /* Now add at the end the standard default dirs. */2944 /* Now add the standard default dirs at the end. */ 2894 2945 2895 2946 #ifdef __MSDOS__ 2896 2947 { 2897 /* The environment variable $DJDIR holds the root of the 2898 DJGPP directorytree; add ${DJDIR}/include. */2948 /* The environment variable $DJDIR holds the root of the DJGPP directory 2949 tree; add ${DJDIR}/include. */ 2899 2950 struct variable *djdir = lookup_variable ("DJDIR", 5); 2900 2951 2901 2952 if (djdir) 2902 2953 { 2903 char *defdir = (char *) xmalloc (strlen (djdir->value) + 8 + 1); 2954 unsigned int len = strlen (djdir->value) + 8; 2955 char *defdir = alloca (len + 1); 2904 2956 2905 2957 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; 2907 2962 } 2908 2963 } 2909 2964 #endif 2910 2965 2911 for ( i = 0; default_include_directories[i] != 0; ++i)2966 for (cpp = default_include_directories; *cpp != 0; ++cpp) 2912 2967 { 2913 2968 int e; 2914 2969 2915 EINTRLOOP (e, stat ( default_include_directories[i], &stbuf));2970 EINTRLOOP (e, stat (*cpp, &stbuf)); 2916 2971 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 } 2918 2981 } 2919 2982 2920 2983 dirs[idx] = 0; 2921 2984 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); 2941 2990 2942 2991 include_directories = dirs; … … 2948 2997 2949 2998 char * 2950 tilde_expand (c har *name)2999 tilde_expand (const char *name) 2951 3000 { 2952 3001 #ifndef VMS … … 2973 3022 home_dir = getenv ("HOME"); 2974 3023 } 2975 # if !defined(_AMIGA) && !defined(WINDOWS32)3024 # if !defined(_AMIGA) && !defined(WINDOWS32) 2976 3025 if (home_dir == 0 || home_dir[0] == '\0') 2977 3026 { … … 2986 3035 } 2987 3036 } 2988 # endif /* !AMIGA && !WINDOWS32 */3037 # endif /* !AMIGA && !WINDOWS32 */ 2989 3038 if (home_dir != 0) 2990 3039 { 2991 char *new = concat (home_dir, "", name + 1);3040 char *new = xstrdup (concat (home_dir, "", name + 1)); 2992 3041 if (is_variable) 2993 3042 free (home_dir); … … 2995 3044 } 2996 3045 } 2997 # if !defined(_AMIGA) && !defined(WINDOWS32)3046 # if !defined(_AMIGA) && !defined(WINDOWS32) 2998 3047 else 2999 3048 { … … 3008 3057 return xstrdup (pwent->pw_dir); 3009 3058 else 3010 return concat (pwent->pw_dir, "/", userend + 1);3059 return xstrdup (concat (pwent->pw_dir, "/", userend + 1)); 3011 3060 } 3012 3061 else if (userend != 0) 3013 3062 *userend = '/'; 3014 3063 } 3015 # endif /* !AMIGA && !WINDOWS32 */3064 # endif /* !AMIGA && !WINDOWS32 */ 3016 3065 #endif /* !VMS */ 3017 3066 return 0; … … 3031 3080 multi_glob (struct nameseq *chain, unsigned int size) 3032 3081 { 3033 extern void dir_setup_glob ();3034 registerstruct nameseq *new = 0;3035 registerstruct nameseq *old;3082 void dir_setup_glob (glob_t *); 3083 struct nameseq *new = 0; 3084 struct nameseq *old; 3036 3085 struct nameseq *nexto; 3037 3086 glob_t gl; … … 3041 3090 for (old = chain; old != 0; old = nexto) 3042 3091 { 3092 const char *gname; 3043 3093 #ifndef NO_ARCHIVES 3044 char *memname; 3094 char *arname = 0; 3095 char *memname = 0; 3045 3096 #endif 3046 3047 3097 nexto = old->next; 3048 3049 if (old->name[0] == '~') 3098 gname = old->name; 3099 3100 if (gname[0] == '~') 3050 3101 { 3051 3102 char *newname = tilde_expand (old->name); 3052 3103 if (newname != 0) 3053 { 3054 free (old->name); 3055 old->name = newname; 3056 } 3104 gname = newname; 3057 3105 } 3058 3106 3059 3107 #ifndef NO_ARCHIVES 3060 if (ar_name ( old->name))3108 if (ar_name (gname)) 3061 3109 { 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 } 3074 3116 #endif /* !NO_ARCHIVES */ 3075 3117 3076 switch (glob ( old->name, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl))3118 switch (glob (gname, GLOB_NOCHECK|GLOB_ALTDIRFUNC, NULL, &gl)) 3077 3119 { 3078 3120 case 0: /* Success. */ 3079 3121 { 3080 registerint i = gl.gl_pathc;3122 int i = gl.gl_pathc; 3081 3123 while (i-- > 0) 3082 3124 { … … 3087 3129 struct nameseq *found 3088 3130 = ar_glob (gl.gl_pathv[i], memname, size); 3089 if ( found == 0)3131 if (! found) 3090 3132 { 3091 3133 /* No matches. Use MEMNAME as-is. */ 3092 3134 unsigned int alen = strlen (gl.gl_pathv[i]); 3093 3135 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); 3105 3147 elt->next = new; 3106 3148 new = elt; … … 3118 3160 new = found; 3119 3161 } 3120 3121 free (memname);3122 3162 } 3123 3163 else 3124 3164 #endif /* !NO_ARCHIVES */ 3125 3165 { 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]); 3131 3169 elt->next = new; 3132 3170 new = elt; … … 3134 3172 } 3135 3173 globfree (&gl); 3136 free (old->name); 3137 free ((char *)old); 3174 free (old); 3138 3175 break; 3139 3176 } … … 3148 3185 break; 3149 3186 } 3187 3188 #ifndef NO_ARCHIVES 3189 if (arname) 3190 free (arname); 3191 #endif 3150 3192 } 3151 3193 -
vendor/gnumake/current/remake.c
r501 r900 40 40 #endif 41 41 42 extern int try_implicit_rule PARAMS ((struct file *file, unsigned int depth));42 extern int try_implicit_rule (struct file *file, unsigned int depth); 43 43 44 44 … … 61 61 static unsigned int considered; 62 62 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)); 63 static int update_file (struct file *file, unsigned int depth); 64 static int update_file_1 (struct file *file, unsigned int depth); 65 static int check_dep (struct file *file, unsigned int depth, 66 FILE_TIMESTAMP this_mtime, int *must_make_ptr); 67 static int touch_file (struct file *file); 68 static void remake_file (struct file *file); 69 static FILE_TIMESTAMP name_mtime (const char *name); 70 static const char *library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr); 70 71 71 72 … … 239 240 240 241 /* Free the storage. */ 241 free ( (char *)g);242 free (g); 242 243 243 244 g = lastgoal == 0 ? goals : lastgoal->next; … … 538 539 if (!running) 539 540 /* 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. */ 543 542 d->changed = ((file_mtime (d->file) != mtime) 544 /* || (mtime == NONEXISTENT_MTIME) */);543 || (mtime == NONEXISTENT_MTIME)); 545 544 546 545 lastd = d; … … 809 808 if (touch_flag 810 809 /* The update status will be: 811 810 -1 if this target was not remade; 812 811 0 if 0 or more commands (+ or ${MAKE}) were run and won; 813 812 1 if some commands were run and lost. … … 919 918 so that a vpath_search can happen. Otherwise, it would 920 919 never be done because the target is already updated. */ 921 (void)f_mtime (d->file, 0);920 f_mtime (d->file, 0); 922 921 } 923 922 else if (file->update_status == -1) … … 928 927 929 928 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. */ 936 934 937 935 static int … … 947 945 if (file->phony || !file->intermediate) 948 946 { 949 /* If this is a non-intermediate file, update it and record 950 whether itis newer than THIS_MTIME. */947 /* If this is a non-intermediate file, update it and record whether it 948 is newer than THIS_MTIME. */ 951 949 FILE_TIMESTAMP mtime; 952 950 dep_status = update_file (file, depth); … … 977 975 } 978 976 979 /* If the intermediate file actually exists980 and is newer, then we should remake from it. */981 977 check_renamed (file); 982 978 mtime = file_mtime (file); 983 979 check_renamed (file); 984 980 if (mtime != NONEXISTENT_MTIME && mtime > this_mtime) 981 /* If the intermediate file actually exists and is newer, then we 982 should remake from it. */ 985 983 *must_make_ptr = 1; 986 /* Otherwise, update all non-intermediate files we depend on,987 if necessary, and see whether any of them is more988 recent than the file on whose behalf we are checking. */989 984 else 990 985 { 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. */ 991 989 struct dep *lastd; 992 990 … … 1067 1065 { 1068 1066 struct stat statbuf; 1069 char buf ;1067 char buf = 'x'; 1070 1068 int e; 1071 1069 … … 1163 1161 char *arname, *memname; 1164 1162 struct file *arfile; 1165 int arname_used = 0;1166 1163 time_t member_date; 1167 1164 … … 1173 1170 arfile = lookup_file (arname); 1174 1171 if (arfile == 0) 1175 { 1176 arfile = enter_file (arname); 1177 arname_used = 1; 1178 } 1172 arfile = enter_file (strcache_add (arname)); 1179 1173 mtime = f_mtime (arfile, search); 1180 1174 check_renamed (arfile); … … 1187 1181 unsigned int arlen, memlen; 1188 1182 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); 1197 1184 memlen = strlen (memname); 1198 1185 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); 1203 1188 name[arlen] = '('; 1204 bcopy (memname, name + arlen + 1, memlen);1189 memcpy (name + arlen + 1, memname, memlen); 1205 1190 name[arlen + 1 + memlen] = ')'; 1206 1191 name[arlen + 1 + memlen + 1] = '\0'; … … 1215 1200 } 1216 1201 1217 if (!arname_used) 1218 free (arname); 1219 free (memname); 1202 free (arname); 1220 1203 1221 1204 file->low_resolution_time = 1; … … 1238 1221 { 1239 1222 /* If name_mtime failed, search VPATH. */ 1240 c har *name = file->name;1241 if ( vpath_search (&name, &mtime)1223 const char *name = vpath_search (file->name, &mtime); 1224 if (name 1242 1225 /* 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)) 1245 1228 { 1246 1229 if (mtime != UNKNOWN_MTIME) … … 1361 1344 1362 1345 static FILE_TIMESTAMP 1363 name_mtime (c har *name)1346 name_mtime (const char *name) 1364 1347 { 1365 1348 FILE_TIMESTAMP mtime; … … 1455 1438 directories. */ 1456 1439 1457 static int1458 library_search (c har **lib, FILE_TIMESTAMP *mtime_ptr)1440 static const char * 1441 library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr) 1459 1442 { 1460 1443 static char *dirs[] = … … 1477 1460 static char *libpatterns = NULL; 1478 1461 1479 c har *libname = &(*lib)[2]; /* Name without the `-l'. */1462 const char *libname = lib+2; /* Name without the '-l'. */ 1480 1463 FILE_TIMESTAMP mtime; 1481 1464 1482 1465 /* Loop variables for the libpatterns value. */ 1483 char *p, *p2; 1466 char *p; 1467 const char *p2; 1484 1468 unsigned int len; 1485 1469 1486 char * file, **dp;1470 char **dp; 1487 1471 1488 1472 /* If we don't have libpatterns, get it. */ … … 1533 1517 if (mtime != NONEXISTENT_MTIME) 1534 1518 { 1535 *lib = xstrdup (libbuf);1536 1519 if (mtime_ptr != 0) 1537 1520 *mtime_ptr = mtime; 1538 return 1;1521 return strcache_add (libbuf); 1539 1522 } 1540 1523 1541 1524 /* Now try VPATH search on that. */ 1542 1525 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 } 1549 1531 1550 1532 /* Now try the standard set of directories. */ … … 1573 1555 if (mtime != NONEXISTENT_MTIME) 1574 1556 { 1575 *lib = xstrdup (buf);1576 1557 if (mtime_ptr != 0) 1577 1558 *mtime_ptr = mtime; 1578 return 1;1559 return strcache_add (buf); 1579 1560 } 1580 1561 } -
vendor/gnumake/current/remote-cstms.c
r501 r900 100 100 that should work on all machines exported to. */ 101 101 102 normalized_cwd = (char *)xmalloc (GET_PATH_MAX);102 normalized_cwd = xmalloc (GET_PATH_MAX); 103 103 strcpy (normalized_cwd, starting_directory); 104 104 if (Customs_NormPath (normalized_cwd, GET_PATH_MAX) < 0) -
vendor/gnumake/current/rule.c
r501 r900 18 18 19 19 #include "make.h" 20 21 #include <assert.h> 22 20 23 #include "dep.h" 21 24 #include "filedef.h" … … 25 28 #include "rule.h" 26 29 27 static void freerule PARAMS ((struct rule *rule, struct rule *lastrule));30 static void freerule (struct rule *rule, struct rule *lastrule); 28 31 29 32 … … 72 75 char *name; 73 76 int namelen; 74 registerstruct rule *rule, *lastrule;77 struct rule *rule, *lastrule; 75 78 76 79 num_pattern_rules = max_pattern_targets = max_pattern_deps = 0; … … 84 87 { 85 88 unsigned int ndeps = 0; 86 registerstruct dep *dep;89 struct dep *dep; 87 90 struct rule *next = rule->next; 88 unsigned int ntargets;89 91 90 92 ++num_pattern_rules; 91 93 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; 98 96 99 97 for (dep = rule->deps; dep != 0; dep = dep->next) … … 102 100 103 101 #ifdef VMS 104 c har *p = strrchr (dep->name, ']');105 c har *p2;102 const char *p = strrchr (dep->name, ']'); 103 const char *p2; 106 104 if (p == 0) 107 105 p = strrchr (dep->name, ':'); 108 106 p2 = p != 0 ? strchr (dep->name, '%') : 0; 109 107 #else 110 c har *p = strrchr (dep->name, '/');111 c har *p2 = p != 0 ? strchr (dep->name, '%') : 0;108 const char *p = strrchr (dep->name, '/'); 109 const char *p2 = p != 0 ? strchr (dep->name, '%') : 0; 112 110 #endif 113 111 ndeps++; … … 124 122 if (p - dep->name > namelen) 125 123 { 126 if (name != 0)127 free (name);128 124 namelen = p - dep->name; 129 name = (char *) xmalloc (namelen + 1);125 name = xrealloc (name, namelen + 1); 130 126 } 131 bcopy (dep->name,name, p - dep->name);127 memcpy (name, dep->name, p - dep->name); 132 128 name[p - dep->name] = '\0'; 133 129 … … 162 158 163 159 static void 164 convert_suffix_rule (c har *target, char *source, struct commands *cmds)165 { 166 char *targname, *targpercent, *depname; 167 c har **names, **percents;160 convert_suffix_rule (const char *target, const char *source, 161 struct commands *cmds) 162 { 163 const char **names, **percents; 168 164 struct dep *deps; 169 unsigned int len; 165 166 names = xmalloc (sizeof (const char *)); 167 percents = xmalloc (sizeof (const char *)); 170 168 171 169 if (target == 0) 172 /* Special case: TARGET being nil means we are defining a173 `.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)'. */ 175 173 #ifdef VMS 176 targname = savestring("(%.obj)", 7);174 *names = strcache_add_len ("(%.obj)", 7); 177 175 #else 178 targname = savestring("(%.o)", 5);176 *names = strcache_add_len ("(%.o)", 5); 179 177 #endif 180 targpercent = targname+ 1;178 *percents = *names + 1; 181 179 } 182 180 else 183 181 { 184 182 /* 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 } 197 190 198 191 if (source == 0) … … 201 194 { 202 195 /* 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); 207 200 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); 212 205 } 213 206 214 207 /* Convert old-style suffix rules to pattern rules. 215 All rules for the suffixes on the .SUFFIXES list 216 are converted and added tothe 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. */ 217 210 218 211 void 219 212 convert_to_pattern (void) 220 213 { 221 registerstruct dep *d, *d2;222 register struct file *f;223 register char *rulename; 224 register unsigned int slen, s2len;225 226 /* Compute maximum length of allthe 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. */ 227 220 228 221 maxsuffix = 0; 229 222 for (d = suffix_file->deps; d != 0; d = d->next) 230 223 { 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); 237 231 238 232 for (d = suffix_file->deps; d != 0; d = d->next) 239 233 { 234 unsigned int slen; 235 240 236 /* Make a rule that is just the suffix, with no deps or commands. 241 237 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) 246 241 /* 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. */ 250 246 slen = strlen (dep_name (d)); 251 bcopy (dep_name (d), rulename, slen); 247 memcpy (rulename, dep_name (d), slen); 248 252 249 for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next) 253 250 { 251 struct file *f; 252 unsigned int s2len; 253 254 254 s2len = strlen (dep_name (d2)); 255 255 256 /* Can't build something from itself. */ 256 257 if (slen == s2len && streq (dep_name (d), dep_name (d2))) 257 258 continue; 258 259 259 bcopy (dep_name (d2), rulename + slen, s2len + 1);260 memcpy (rulename + slen, dep_name (d2), s2len + 1); 260 261 f = lookup_file (rulename); 261 262 if (f == 0 || f->cmds == 0) … … 265 266 /* A suffix rule `.X.a:' generates the pattern rule `(%.o): %.X'. 266 267 It also generates a normal `%.a: %.X' rule below. */ 267 convert_suffix_rule ( (char *) 0, /* Indicates `(%.o)'. */268 convert_suffix_rule (NULL, /* Indicates `(%.o)'. */ 268 269 dep_name (d), 269 270 f->cmds); … … 277 278 278 279 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 287 static int 288 288 new_pattern_rule (struct rule *rule, int override) 289 289 { 290 registerstruct rule *r, *lastrule;291 registerunsigned int i, j;290 struct rule *r, *lastrule; 291 unsigned int i, j; 292 292 293 293 rule->in_use = 0; … … 299 299 lastrule = 0; 300 300 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) 302 302 { 303 for (j = 0; r->targets[j] != 0; ++j)303 for (j = 0; j < r->num; ++j) 304 304 if (!streq (rule->targets[i], r->targets[j])) 305 305 break; 306 if (r->targets[j] == 0) 307 /* All the targets matched. */306 /* If all the targets matched... */ 307 if (j == r->num) 308 308 { 309 registerstruct dep *d, *d2;309 struct dep *d, *d2; 310 310 for (d = rule->deps, d2 = r->deps; 311 311 d != 0 && d2 != 0; d = d->next, d2 = d2->next) … … 363 363 install_pattern_rule (struct pspec *p, int terminal) 364 364 { 365 registerstruct rule *r;365 struct rule *r; 366 366 char *ptr; 367 367 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)); 377 374 378 375 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]; 388 380 389 381 ptr = p->dep; … … 395 387 { 396 388 r->terminal = terminal; 397 r->cmds = (struct commands *)xmalloc (sizeof (struct commands));389 r->cmds = xmalloc (sizeof (struct commands)); 398 390 r->cmds->fileinfo.filenm = 0; 399 391 r->cmds->fileinfo.lineno = 0; … … 414 406 { 415 407 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; 421 409 422 410 dep = rule->deps; 423 411 while (dep) 424 412 { 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; 431 414 free_dep (dep); 432 415 dep = t; 433 416 } 434 417 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); 438 421 439 422 /* We can't free the storage for the commands because there … … 448 431 pointer from the `struct file' for the suffix rule. */ 449 432 450 free ( (char *)rule);433 free (rule); 451 434 452 435 if (pattern_rules == rule) … … 462 445 463 446 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 of466 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. 468 451 It is a terminal rule if TERMINAL is nonzero. This rule overrides 469 452 identical rules with different commands if OVERRIDE is nonzero. 470 453 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. */ 474 456 475 457 void 476 create_pattern_rule (c har **targets,char **target_percents,477 458 create_pattern_rule (const char **targets, const char **target_percents, 459 unsigned int n, int terminal, struct dep *deps, 478 460 struct commands *commands, int override) 479 461 { 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; 483 466 r->cmds = commands; 484 467 r->deps = deps; 485 468 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 { 500 474 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]; 513 477 } 514 478 … … 523 487 print_rule (struct rule *r) 524 488 { 525 registerunsigned int i;526 registerstruct 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) 529 493 { 530 494 fputs (r->targets[i], stdout); 531 if (r->targets[i + 1] != 0) 532 putchar (' '); 533 else 534 putchar (':'); 495 putchar ((i + 1 == r->num) ? ':' : ' '); 535 496 } 536 497 if (r->terminal) … … 548 509 print_rule_data_base (void) 549 510 { 550 registerunsigned int rules, terminal;551 registerstruct rule *r;511 unsigned int rules, terminal; 512 struct rule *r; 552 513 553 514 puts (_("\n# Implicit Rules")); -
vendor/gnumake/current/rule.h
r501 r900 17 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ 18 18 19 /* Structure used for pattern rules. */ 19 20 /* Structure used for pattern (implicit) rules. */ 20 21 21 22 struct rule 22 23 { 23 24 struct rule *next; 24 c har **targets;/* Targets of the rule. */25 const char **targets; /* Targets of the rule. */ 25 26 unsigned int *lens; /* Lengths of each target. */ 26 c har **suffixes;/* Suffixes (after `%') of each target. */27 const char **suffixes; /* Suffixes (after `%') of each target. */ 27 28 struct dep *deps; /* Dependencies of the rule. */ 28 29 struct commands *cmds; /* Commands to execute. */ 30 unsigned short num; /* Number of targets. */ 29 31 char terminal; /* If terminal (double-colon). */ 30 32 char in_use; /* If in use by a parent pattern_search. */ … … 50 52 51 53 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)); 54 void count_implicit_rule_limits (void); 55 void convert_to_pattern (void); 56 void install_pattern_rule (struct pspec *p, int terminal); 57 void 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 21 21 #include "hash.h" 22 22 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) 25 26 26 27 … … 40 41 static struct strcache *strcache = NULL; 41 42 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 */ 42 48 static struct strcache * 43 49 new_cache() 44 50 { 45 51 struct strcache *new; 46 new = (struct strcache *)xmalloc (sizeof (*new) + bufsize);52 new = xmalloc (sizeof (*new) + bufsize); 47 53 new->end = new->buffer; 48 54 new->count = 0; … … 62 68 const char *res; 63 69 64 /* If the string we want is too large to fit into a single buffer, then we're65 screwed; nothing will ever fit! Change the maximum size of the cache to66 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. */ 67 73 if (len > bufsize) 68 74 bufsize = len * 2; … … 114 120 115 121 static struct hash_table strings; 122 static unsigned long total_adds = 0; 116 123 117 124 static const char * … … 119 126 { 120 127 /* 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); 122 129 const char *key = *slot; 130 131 /* Count the total number of adds we performed. */ 132 ++total_adds; 123 133 124 134 if (!HASH_VACANT (key)) … … 156 166 strcache_add_len (const char *str, int len) 157 167 { 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); 163 179 } 164 180 … … 174 190 strcache_init (void) 175 191 { 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); 177 193 } 178 194 … … 186 202 int totsize = 0, avgsize, maxsize = 0, minsize = bufsize; 187 203 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) 191 207 { 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 } 205 230 } 206 231 … … 208 233 avgfree = numbuffs ? (int)(totfree / numbuffs) : 0; 209 234 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 1 2006-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 8 2006-09-30 Paul Smith <[email protected]> 9 10 * scripts/variables/automatic: Add back the test for bug #8154. 11 1 12 2006-04-01 Paul D. Smith <[email protected]> 2 13 -
vendor/gnumake/current/tests/run_make_tests.pl
r501 r900 191 191 sub print_usage 192 192 { 193 &print_standard_usage ("run_make_tests", "[-make_path make_pathname]"); 193 &print_standard_usage ("run_make_tests", 194 "[-make_path make_pathname] [-valgrind]",); 194 195 } 195 196 … … 229 230 local($index); 230 231 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 236 232 # find the type of the port. We do this up front to have a single 237 233 # point of change if it needs to be tweaked. -
vendor/gnumake/current/tests/scripts/features/patternrules
r501 r900 11 11 12 12 13 # TEST #1: Make sure that multiple patterns where the same target14 # 15 # 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. 16 16 # 17 17 … … 46 46 ''); 47 47 48 # TEST # 2: make sure files that are built via implicit rules are marked48 # TEST #1: make sure files that are built via implicit rules are marked 49 49 # as targets (Savannah bug #12202). 50 50 # … … 70 70 71 71 72 # TEST # 3: make sure intermidite files that also happened to be72 # TEST #2: make sure intermediate files that also happened to be 73 73 # prerequisites are not removed (Savannah bug #12267). 74 74 # … … 97 97 98 98 99 # TEST # 4: make sure precious flag is set properly for targets99 # TEST #3: make sure precious flag is set properly for targets 100 100 # that are built via implicit rules (Savannah bug #13218). 101 101 # … … 117 117 118 118 119 # TEST # 5: make sure targets of a macthed implicit pattern rule never119 # TEST #4: make sure targets of a matched implicit pattern rule are 120 120 # never considered intermediate (Savannah bug #13022). 121 121 # -
vendor/gnumake/current/tests/scripts/variables/automatic
r501 r900 96 96 # considered reasons for the target to be rebuilt. 97 97 # 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. 100 99 101 #touch('foo');102 # 103 #run_make_test('104 #foo: bar ; @echo "\$$? = $?"105 #bar: ;',106 #'',107 #'$? = bar');108 # 109 #unlink('foo');100 touch('foo'); 101 102 run_make_test(' 103 foo: bar ; @echo "\$$? = $?" 104 bar: ;', 105 '', 106 '$? = bar'); 107 108 unlink('foo'); 110 109 111 110 1; -
vendor/gnumake/current/tests/test_driver.pl
r501 r900 29 29 # variables and then calls &toplevel, which does all the real work. 30 30 31 # $Id: test_driver.pl,v 1. 19 2006/03/10 02:20:45psmith Exp $31 # $Id: test_driver.pl,v 1.21 2007/03/20 03:02:26 psmith Exp $ 32 32 33 33 … … 79 79 { 80 80 # Pull in benign variables from the user's environment 81 # 81 82 82 foreach (# UNIX-specific things 83 'TZ', ' LANG', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH',83 'TZ', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH', 84 84 # Purify things 85 85 'PURIFYOPTIONS', … … 92 92 $makeENV{$_} = $ENV{$_} if $ENV{$_}; 93 93 } 94 95 # Make sure our compares are not foiled by locale differences 96 97 $makeENV{LC_ALL} = 'C'; 94 98 95 99 # Replace the environment with the new one … … 544 548 local($line); 545 549 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"; 552 554 } 553 555 } -
vendor/gnumake/current/variable.c
r501 r900 43 43 44 44 struct 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)); 45 create_pattern_var (const char *target, const char *suffix) 46 { 47 register struct pattern_var *p = xmalloc (sizeof (struct pattern_var)); 49 48 50 49 if (last_pattern_var != 0) … … 65 64 66 65 static struct pattern_var * 67 lookup_pattern_var (struct pattern_var *start, c har *target)66 lookup_pattern_var (struct pattern_var *start, const char *target) 68 67 { 69 68 struct pattern_var *p; … … 72 71 for (p = start ? start->next : pattern_vars; p != 0; p = p->next) 73 72 { 74 c har *stem;73 const char *stem; 75 74 unsigned int stemlen; 76 75 … … 163 162 struct variable * 164 163 define_variable_in_set (const char *name, unsigned int length, 165 c har *value, enum variable_origin origin,164 const char *value, enum variable_origin origin, 166 165 int recursive, struct variable_set *set, 167 166 const struct floc *flocp) … … 209 208 /* Create a new variable definition and add it to the hash table. */ 210 209 211 v = (struct variable *)xmalloc (sizeof (struct variable));210 v = xmalloc (sizeof (struct variable)); 212 211 v->name = savestring (name, length); 213 212 v->length = length; … … 318 317 } 319 318 320 bcopy (v->name, p, l);319 memcpy (p, v->name, l); 321 320 p += l; 322 321 *(p++) = ' '; … … 445 444 parent of FILE's variable set. 446 445 447 If we're READ inga makefile, don't do the pattern variable search now,446 If we're READING a makefile, don't do the pattern variable search now, 448 447 since the pattern variable might not have been defined yet. */ 449 448 … … 457 456 l = (struct variable_set_list *) 458 457 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)); 460 459 hash_init (&l->set->table, PERFILE_VARIABLE_BUCKETS, 461 460 variable_hash_1, variable_hash_2, variable_hash_cmp); … … 553 552 register struct variable_set *set; 554 553 555 set = (struct variable_set *)xmalloc (sizeof (struct variable_set));554 set = xmalloc (sizeof (struct variable_set)); 556 555 hash_init (&set->table, SMALL_SCOPE_VARIABLE_BUCKETS, 557 556 variable_hash_1, variable_hash_2, variable_hash_cmp); … … 578 577 hash_map (&list->set->table, free_variable_name_and_value); 579 578 hash_free (&list->set->table, 1); 580 free ( (char *)list->set);581 free ( (char *)list);579 free (list->set); 580 free (list); 582 581 } 583 582 … … 635 634 636 635 /* Free the one we no longer need. */ 637 free ( (char *)setlist);636 free (setlist); 638 637 hash_map (&set->table, free_variable_name_and_value); 639 638 hash_free (&set->table, 1); 640 free ( (char *)set);639 free (set); 641 640 } 642 641 … … 953 952 hash_delete (&table, &makelevel_key); 954 953 955 result = result_0 = (char **)xmalloc ((table.ht_fill + 2) * sizeof (char *));954 result = result_0 = xmalloc ((table.ht_fill + 2) * sizeof (char *)); 956 955 957 956 v_slot = (struct variable **) table.ht_vec; … … 974 973 convert_Path_to_windows32(value, ';'); 975 974 #endif 976 *result++ = concat (v->name, "=", value);975 *result++ = xstrdup (concat (v->name, "=", value)); 977 976 free (value); 978 977 } … … 984 983 convert_Path_to_windows32(v->value, ';'); 985 984 #endif 986 *result++ = concat (v->name, "=", v->value);985 *result++ = xstrdup (concat (v->name, "=", v->value)); 987 986 } 988 987 } 989 988 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); 992 991 *++result = 0; 993 992 … … 1003 1002 struct variable * 1004 1003 do_variable_definition (const struct floc *flocp, const char *varname, 1005 c har *value, enum variable_origin origin,1004 const char *value, enum variable_origin origin, 1006 1005 enum variable_flavor flavor, int target_var) 1007 1006 { 1008 char *p, *alloc_value = NULL; 1007 const char *p; 1008 char *alloc_value = NULL; 1009 1009 struct variable *v; 1010 1010 int append = 0; … … 1071 1071 1072 1072 unsigned int oldlen, vallen; 1073 char *val; 1073 const char *val; 1074 char *tp; 1074 1075 1075 1076 val = value; … … 1088 1089 oldlen = strlen (v->value); 1089 1090 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; 1094 1096 } 1095 1097 } … … 1117 1119 1118 1120 /* 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)) 1120 1122 { 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 1128 1129 v = define_variable_loc (varname, strlen (varname), 1129 1130 shellpath, origin, flavor == f_recursive, … … 1132 1133 else 1133 1134 { 1134 c har *shellbase, *bslash;1135 const char *shellbase, *bslash; 1135 1136 struct variable *pathv = lookup_variable ("PATH", 4); 1136 1137 char *path_string; … … 1153 1154 if (pathv) 1154 1155 pathlen = strlen (pathv->value); 1155 path_string = (char *)xmalloc (5 + pathlen + 2 + 1);1156 path_string = xmalloc (5 + pathlen + 2 + 1); 1156 1157 /* On MSDOS, current directory is considered as part of $PATH. */ 1157 1158 sprintf (path_string, "PATH=.;%s", pathv ? pathv->value : ""); 1158 1159 fake_env[0] = path_string; 1159 fake_env[1] = (char *)0;1160 fake_env[1] = 0; 1160 1161 if (__dosexec_find_on_path (shellbase, fake_env, shellpath)) 1161 1162 { 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 1169 1169 v = define_variable_loc (varname, strlen (varname), 1170 1170 shellpath, origin, … … 1320 1320 1321 1321 /* 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); 1324 1324 name[end - beg] = '\0'; 1325 1325 v->name = allocated_variable_expand (name); … … 1374 1374 print_variable (const void *item, void *arg) 1375 1375 { 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; 1378 1378 const char *origin; 1379 1379 … … 1489 1489 1490 1490 void 1491 print_file_variables ( struct file *file)1491 print_file_variables (const struct file *file) 1492 1492 { 1493 1493 if (file->variables != 0) … … 1516 1516 */ 1517 1517 convert_Path_to_windows32 (path, ';'); 1518 environ_path = concat ("PATH", "=", path);1518 environ_path = xstrdup (concat ("PATH", "=", path)); 1519 1519 putenv (environ_path); 1520 1520 free (path); -
vendor/gnumake/current/variable.h
r501 r900 100 100 { 101 101 struct pattern_var *next; 102 char *target; 102 const char *suffix; 103 const char *target; 103 104 unsigned int len; 104 char *suffix;105 105 struct variable variable; 106 106 }; … … 110 110 111 111 /* 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));112 char *variable_buffer_output (char *ptr, const char *string, unsigned int length); 113 char *variable_expand (const char *line); 114 char *variable_expand_for_file (const char *line, struct file *file); 115 char *allocated_variable_expand_for_file (const char *line, struct file *file); 116 116 #define allocated_variable_expand(line) \ 117 117 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)); 118 char *expand_argument (const char *str, const char *end); 119 char *variable_expand_string (char *line, const char *string, long length); 120 void install_variable_buffer (char **bufp, unsigned int *lenp); 121 void restore_variable_buffer (char *buf, unsigned int len); 123 122 124 123 /* 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)); 124 int handle_function (char **op, const char **stringp); 125 int pattern_matches (const char *pattern, const char *percent, const char *str); 126 char *subst_expand (char *o, const char *text, const char *subst, 127 const char *replace, unsigned int slen, unsigned int rlen, 128 int by_word); 129 char *patsubst_expand_pat (char *o, const char *text, const char *pattern, 130 const char *replace, const char *pattern_percent, 131 const char *replace_percent); 132 char *patsubst_expand (char *o, const char *text, char *pattern, char *replace); 131 133 132 134 /* expand.c */ 133 extern char *recursively_expand_for_file PARAMS ((struct variable *v, 134 struct file *file)); 135 char *recursively_expand_for_file (struct variable *v, struct file *file); 135 136 #define recursively_expand(v) recursively_expand_for_file (v, NULL) 136 137 137 138 /* 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)); 139 struct variable_set_list *create_new_variable_set (void); 140 void free_variable_set (struct variable_set_list *); 141 struct variable_set_list *push_new_variable_scope (void); 142 void pop_variable_scope (void); 143 void define_automatic_variables (void); 144 void initialize_file_variables (struct file *file, int reading); 145 void print_file_variables (const struct file *file); 146 void print_variable_set (struct variable_set *set, char *prefix); 147 void merge_variable_set_lists (struct variable_set_list **to_list, 148 struct variable_set_list *from_list); 149 struct 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); 154 struct variable *parse_variable_definition (struct variable *v, char *line); 155 struct variable *try_variable_definition (const struct floc *flocp, char *line, 156 enum variable_origin origin, 157 int target_var); 158 void init_hash_global_variable_set (void); 159 void hash_init_function_table (void); 160 struct variable *lookup_variable (const char *name, unsigned int length); 161 struct variable *lookup_variable_in_set (const char *name, unsigned int length, 162 const struct variable_set *set); 163 164 struct 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); 161 170 162 171 /* Define a variable in the current variable set. */ … … 191 200 }while(0) 192 201 193 extern char **target_environment PARAMS ((struct file *file)); 194 195 extern struct pattern_var *create_pattern_var PARAMS ((char *target, char *suffix)); 202 char **target_environment (struct file *file); 203 204 struct pattern_var *create_pattern_var (const char *target, 205 const char *suffix); 196 206 197 207 extern int export_all_variables; -
vendor/gnumake/current/vmsdir.h
r501 r900 68 68 #endif 69 69 70 extern DIR *opendir PARAMS (());71 extern struct direct *readdir PARAMS ((DIR *dfd));72 70 #define rewinddir(dirp) seekdir((dirp), (long)0) 73 extern int closedir PARAMS ((DIR *dfd)); 74 extern char *vmsify PARAMS ((char *name, int type)); 71 72 DIR *opendir (); 73 struct direct *readdir (DIR *dfd); 74 int closedir (DIR *dfd); 75 const char *vmsify (const char *name, int type); 75 76 76 77 #endif /* VMSDIR_H */ -
vendor/gnumake/current/vmsfunctions.c
r501 r900 38 38 struct NAM *dnam = (struct NAM *)xmalloc (sizeof (struct NAM)); 39 39 struct FAB *dfab = &dir->fab; 40 char *searchspec = (char *)xmalloc (MAXNAMLEN + 1);40 char *searchspec = xmalloc (MAXNAMLEN + 1); 41 41 42 42 memset (dir, 0, sizeof *dir); … … 258 258 return (str); 259 259 } 260 261 int262 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 64 64 65 65 static int 66 copyto (char **to, c har **from, char upto, int as_dir)66 copyto (char **to, const char **from, char upto, int as_dir) 67 67 { 68 c har *s;68 const char *s; 69 69 70 70 s = strrchr (*from, '.'); … … 112 112 113 113 static char * 114 trnlog (c har *name)114 trnlog (const char *name) 115 115 { 116 116 int stat; … … 135 135 reslt[resltlen] = '\0'; 136 136 137 s = (char *)malloc (resltlen+1);137 s = malloc (resltlen+1); 138 138 if (s == 0) 139 139 return ""; … … 206 206 26 filenames with a single pair of '[' ']' are left unchanged 207 207 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. 209 210 */ 210 211 211 c har *212 vmsify (c har *name, int type)212 const char * 213 vmsify (const char *name, int type) 213 214 { 214 215 /* max 255 device … … 222 223 enum namestate nstate; 223 224 static char vmsname[MAXPATHLEN+1]; 224 char *fptr; 225 const char *fptr; 226 const char *t; 225 227 char *vptr; 226 char *s,*s1;227 228 int as_dir; 228 229 int count; … … 235 236 236 237 /* case 25a */ 237 238 s = strpbrk (name, "$:"); 239 if ( s!= 0)240 { 241 c har *s1;242 c har *s2;238 t = strpbrk (name, "$:"); 239 240 if (t != 0) 241 { 242 const char *s1; 243 const char *s2; 243 244 244 245 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 } 264 261 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 } 275 268 } 276 269 277 270 /* 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, '['); 284 277 if (s1 == 0) 285 278 { 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; 295 283 } 296 284 s1--; 297 285 if (*s1 != ']') 298 286 { 299 return name; /* not ][, keep unchanged */ 287 strcpy (vmsname, name); 288 return vmsname; /* not ][, keep unchanged */ 300 289 } 301 290 … … 306 295 /* s -> starting char 307 296 s1 -> ending ']' */ 308 309 297 do 310 298 { … … 330 318 331 319 } 332 333 320 else /* no [ in name */ 334 335 { 336 337 int state; 321 { 322 int state = 0; 338 323 int rooted = 1; /* flag if logical is rooted, else insert [000000] */ 339 340 state = 0;341 324 342 325 do 343 326 { 344 345 327 switch (state) 346 328 { … … 371 353 372 354 case 2: /* no '/' at start */ 373 s = strchr (fptr, '/'); 355 { 356 const char *s = strchr (fptr, '/'); 374 357 if (s == 0) /* no '/' (16) */ 375 358 { … … 402 385 } 403 386 break; 387 } 404 388 405 389 case 3: /* '//' at start */ 390 { 391 const char *s; 392 const char *s1; 393 char *vp; 406 394 while (*fptr == '/') /* collapse all '/' */ 407 395 fptr++; … … 413 401 if (s1 == 0) 414 402 { 415 return ""; /* FIXME, err getcwd */ 403 vmsname[0] = '\0'; 404 return vmsname; /* FIXME, err getcwd */ 416 405 } 417 406 s = strchr (s1, ':'); 418 407 if (s == 0) 419 408 { 420 return ""; /* FIXME, err no device */ 409 vmsname[0] = '\0'; 410 return vmsname; /* FIXME, err no device */ 421 411 } 422 412 strncpy (vptr, s1, s-s1+1); … … 445 435 *vptr = 0; 446 436 /* check logical for [000000] insertion */ 447 s1= trnlog (s);448 if (* s1 != 0)437 vp = trnlog (s); 438 if (*vp != '\0') 449 439 { /* found translation */ 450 char *s2;451 440 for (;;) /* loop over all nested logicals */ 452 441 { 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) 459 448 { 460 449 rooted = 0; 461 450 break; 462 451 } 463 s1 = s2;452 vp = vp2; 464 453 continue; /* next iteration */ 465 454 } 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 '.]' */ 469 458 { 470 459 if (strncmp (fptr, "000000", 6) != 0) … … 474 463 { 475 464 strcpy (vmsname, s1); 476 s= strchr (vmsname, ']');477 * s= '.';465 vp = strchr (vmsname, ']'); 466 *vp = '.'; 478 467 nstate = N_DOT; 479 vptr = s;468 vptr = vp; 480 469 } 481 470 } 482 471 break; 483 472 } 484 free ( s1);473 free (vp); 485 474 } 486 475 else … … 497 486 if (rooted == 0) 498 487 { 488 nstate = N_DOT; 499 489 strcpy (vptr, "[000000."); 500 490 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 */ 508 497 509 498 s = strchr (fptr, '/'); … … 532 521 else 533 522 if ((nstate == N_DOT) 534 && ( s1!= 0)523 && (vp != 0) 535 524 && (*(s+1) == 0)) 536 525 { 537 526 if (type == 2) 538 527 { 539 * s1= ']';528 *vp = ']'; 540 529 nstate = N_CLOSED; 541 530 } … … 543 532 state = 9; 544 533 break; 545 534 } 546 535 case 4: /* single '/' at start (9..15) */ 547 536 if (*fptr == 0) … … 565 554 break; 566 555 567 case 6: /* chars following '/' at start 10..15 */ 556 case 6: /* chars following '/' at start 10..15 */ 557 { 558 const char *s; 568 559 *vptr++ = '['; 569 560 nstate = N_OPEN; … … 596 587 } 597 588 break; 589 } 598 590 599 591 case 7: /* add '.dir' and exit */ … … 601 593 || (nstate == N_DOT)) 602 594 { 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 == ']') 607 599 { 608 600 break; 609 601 } 610 if (* s== '.')611 { 612 * s= ']';602 if (*vp == '.') 603 { 604 *vp = ']'; 613 605 break; 614 606 } 615 s--;607 vp--; 616 608 } 617 609 } … … 626 618 break; 627 619 628 case 9: /* 17..21, fptr -> 1st '/' + 1 */ 620 case 9: /* 17..21, fptr -> 1st '/' + 1 */ 621 { 622 const char *s; 629 623 if (*fptr == 0) 630 624 { … … 688 682 || (*(fptr+2) == 0)) ) 689 683 { 684 char *vp; 690 685 fptr += 2; 691 686 if (*fptr == '/') … … 700 695 type = 1; 701 696 vptr--; /* vptr -> '.' or ']' */ 702 s1= vptr;697 vp = vptr; 703 698 for (;;) 704 699 { 705 s1--;706 if (* s1== '.') /* one back */707 { 708 vptr = s1;700 vp--; 701 if (*vp == '.') /* one back */ 702 { 703 vptr = vp; 709 704 nstate = N_OPEN; 710 705 break; 711 706 } 712 if (* s1== '[') /* top level reached */707 if (*vp == '[') /* top level reached */ 713 708 { 714 709 if (*fptr == 0) 715 710 { 716 strcpy ( s1, "[000000]");717 vptr = s1+ 8;711 strcpy (vp, "[000000]"); 712 vptr = vp + 8; 718 713 nstate = N_CLOSED; 719 714 s = 0; … … 722 717 else 723 718 { 724 vptr = s1+1;719 vptr = vp+1; 725 720 nstate = N_OPEN; 726 721 break; … … 757 752 } 758 753 break; 754 } 759 755 760 756 case 10: /* 1,2 first is '.' */ … … 774 770 if (*fptr != '/') /* got ..xxx */ 775 771 { 776 return name; 772 strcpy (vmsname, name); 773 return vmsname; 777 774 } 778 775 do /* got ../ */ … … 792 789 } 793 790 { /* got '..' or '../' */ 791 char *vp; 794 792 char cwdbuf[MAXPATHLEN+1]; 795 793 796 s1= getcwd(cwdbuf, MAXPATHLEN);797 if ( s1== 0)794 vp = getcwd(cwdbuf, MAXPATHLEN); 795 if (vp == 0) 798 796 { 799 return ""; /* FIXME, err getcwd */ 797 vmsname[0] = '\0'; 798 return vmsname; /* FIXME, err getcwd */ 800 799 } 801 strcpy (vptr, s1);802 s= strchr (vptr, ']');803 if ( s!= 0)800 strcpy (vptr, vp); 801 vp = strchr (vptr, ']'); 802 if (vp != 0) 804 803 { 805 804 nstate = N_OPEN; 806 while ( s> vptr)805 while (vp > vptr) 807 806 { 808 s--;809 if (* s== '[')807 vp--; 808 if (*vp == '[') 810 809 { 811 s++;812 strcpy ( s, "000000]");810 vp++; 811 strcpy (vp, "000000]"); 813 812 state = -1; 814 813 break; 815 814 } 816 else if (* s== '.')815 else if (*vp == '.') 817 816 { 818 817 if (--count == 0) … … 820 819 if (*fptr == 0) /* had '..' or '../' */ 821 820 { 822 * s++ = ']';821 *vp++ = ']'; 823 822 state = -1; 824 823 } … … 827 826 state = 9; 828 827 } 829 * s = 0;828 *vp = '\0'; 830 829 break; 831 830 } … … 842 841 if (*fptr != '/') 843 842 { 844 return name; 843 strcpy (vmsname, name); 844 return vmsname; 845 845 } 846 846 while (*fptr == '/') … … 849 849 850 850 { 851 char *vp; 851 852 char cwdbuf[MAXPATHLEN+1]; 852 853 853 s1= getcwd(cwdbuf, MAXPATHLEN);854 if ( s1== 0)854 vp = getcwd(cwdbuf, MAXPATHLEN); 855 if (vp == 0) 855 856 { 856 return ""; /*FIXME, err getcwd */ 857 vmsname[0] = '\0'; 858 return vmsname; /*FIXME, err getcwd */ 857 859 } 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 } 878 880 break; 879 881 } … … 904 906 */ 905 907 906 c har *907 unixify (c har *name)908 const char * 909 unixify (const char *name) 908 910 { 909 911 static char piece[512]; 910 char *s, *p; 912 const char *s; 913 char *p; 911 914 912 915 if (strchr (name, '/') != 0) /* already in unix style */ 913 return name; 916 { 917 strcpy (piece, name); 918 return piece; 919 } 914 920 915 921 p = piece; … … 922 928 if (s != 0) 923 929 { 924 *s = 0;930 int l = s - name; 925 931 *p++ = '/'; 926 932 *p++ = '/'; 927 strcpy (p, name); 928 p += strlen (p); 929 *s = ':'; 933 strncpy (p, name, l); 934 p += l; 930 935 } 931 936 -
vendor/gnumake/current/vmsjobs.c
r501 r900 22 22 #include <clidef.h> 23 23 24 extern char *vmsify PARAMS ((char *name, int type));24 char *vmsify (char *name, int type); 25 25 26 26 static int vms_jobsefnmask = 0; -
vendor/gnumake/current/vpath.c
r501 r900 30 30 { 31 31 struct vpath *next; /* Pointer to next struct in the linked list. */ 32 c har *pattern;/* The pattern to match. */33 c har *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. */ 34 34 unsigned int patlen;/* Length of the pattern. */ 35 c har **searchpath;/* Null-terminated list of directories. */35 const char **searchpath; /* Null-terminated list of directories. */ 36 36 unsigned int maxlen;/* Maximum length of any entry in the list. */ 37 37 }; … … 50 50 51 51 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. */ 57 56 58 57 void … … 91 90 /* Save the list of vpaths. */ 92 91 struct vpath *save_vpaths = vpaths; 92 char gp[] = "%"; 93 93 94 94 /* Empty `vpaths' so the new one will have no next, and `vpaths' … … 97 97 98 98 /* Parse P. */ 99 construct_vpath_list ( "%", p);99 construct_vpath_list (gp, p); 100 100 101 101 /* Store the created path as the general path, … … 123 123 /* Save the list of vpaths. */ 124 124 struct vpath *save_vpaths = vpaths; 125 char gp[] = "%"; 125 126 126 127 /* Empty `vpaths' so the new one will have no next, and `vpaths' … … 129 130 130 131 /* Parse P. */ 131 construct_vpath_list ( "%", p);132 construct_vpath_list (gp, p); 132 133 133 134 /* Store the created path as the GPATH, … … 161 162 construct_vpath_list (char *pattern, char *dirpath) 162 163 { 163 registerunsigned int elem;164 registerchar *p;165 registerchar **vpath;166 registerunsigned int maxvpath;164 unsigned int elem; 165 char *p; 166 const char **vpath; 167 unsigned int maxvpath; 167 168 unsigned int maxelem; 168 c har *percent = NULL;169 const char *percent = NULL; 169 170 170 171 if (pattern != 0) 171 { 172 pattern = xstrdup (pattern); 173 percent = find_percent (pattern); 174 } 172 percent = find_percent (pattern); 175 173 176 174 if (dirpath == 0) 177 175 { 178 176 /* Remove matching listings. */ 179 registerstruct vpath *path, *lastpath;177 struct vpath *path, *lastpath; 180 178 181 179 lastpath = 0; … … 197 195 198 196 /* Free its unused storage. */ 199 free (path->pattern); 200 free ((char *) path->searchpath); 201 free ((char *) path); 197 free (path->searchpath); 198 free (path); 202 199 } 203 200 else … … 207 204 } 208 205 209 if (pattern != 0)210 free (pattern);211 206 return; 212 207 } … … 215 210 convert_vpath_to_windows32(dirpath, ';'); 216 211 #endif 212 213 /* Skip over any initial separators and blanks. */ 214 while (*dirpath == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*dirpath)) 215 ++dirpath; 217 216 218 217 /* Figure out the maximum number of VPATH entries and put it in … … 226 225 ++maxelem; 227 226 228 vpath = (char **) xmalloc (maxelem * sizeof (char *));227 vpath = xmalloc (maxelem * sizeof (const char *)); 229 228 maxvpath = 0; 230 229 231 /* Skip over any initial separators and blanks. */230 elem = 0; 232 231 p = dirpath; 233 while (*p == PATH_SEPARATOR_CHAR || isblank ((unsigned char)*p))234 ++p;235 236 elem = 0;237 232 while (*p != '\0') 238 233 { … … 256 251 --len; 257 252 253 /* Put the directory on the vpath list. */ 258 254 if (len > 1 || *v != '.') 259 255 { 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; 275 259 } 276 260 … … 287 271 Usually this is maxelem - 1. If not, shrink down. */ 288 272 if (elem < (maxelem - 1)) 289 vpath = (char **) xrealloc ((char *) vpath, 290 (elem + 1) * sizeof (char *)); 273 vpath = xrealloc (vpath, (elem+1) * sizeof (const char *)); 291 274 292 275 /* Put the nil-pointer terminator on the end of the VPATH list. */ 293 vpath[elem] = 0;276 vpath[elem] = NULL; 294 277 295 278 /* 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)); 297 280 path->searchpath = vpath; 298 281 path->maxlen = maxvpath; … … 301 284 302 285 /* Set up the members. */ 303 path->pattern = pattern; 304 path->percent = percent; 286 path->pattern = strcache_add (pattern); 305 287 path->patlen = strlen (pattern); 288 path->percent = percent ? path->pattern + (percent - pattern) : 0; 306 289 } 307 290 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); 314 293 } 315 294 … … 319 298 320 299 int 321 gpath_search (c har *file, unsigned int len)300 gpath_search (const char *file, unsigned int len) 322 301 { 323 c har **gp;302 const char **gp; 324 303 325 304 if (gpaths && (len <= gpaths->maxlen)) … … 332 311 333 312 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 319 static const char * 320 selective_vpath_search (struct vpath *path, const char *file, 377 321 FILE_TIMESTAMP *mtime_ptr) 378 322 { 379 323 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; 383 328 unsigned int maxvpath = path->maxlen; 384 registerunsigned int i;329 unsigned int i; 385 330 unsigned int flen, vlen, name_dplen; 386 331 int exists = 0; … … 390 335 files that don't exist but are mentioned in a makefile. */ 391 336 { 392 struct file *f = lookup_file ( *file);337 struct file *f = lookup_file (file); 393 338 not_target = f == 0 || !f->is_target; 394 339 } 395 340 396 flen = strlen ( *file);341 flen = strlen (file); 397 342 398 343 /* 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 tothe 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, '/'); 403 348 #ifdef HAVE_DOS_PATHS 404 349 /* We need the rightmost slash or backslash. */ 405 350 { 406 c har *bslash = strrchr(*file, '\\');351 const char *bslash = strrchr(file, '\\'); 407 352 if (!n || bslash > n) 408 353 n = bslash; 409 354 } 410 355 #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; 413 358 if (name_dplen > 0) 414 359 flen -= name_dplen + 1; 415 360 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); 421 365 422 366 /* Try each VPATH entry. */ … … 424 368 { 425 369 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. */ 430 375 vlen = strlen (vpath[i]); 431 bcopy (vpath[i], n, vlen);432 n+= vlen;376 memcpy (p, vpath[i], vlen); 377 p += vlen; 433 378 434 379 /* Add the directory prefix already in *FILE. */ … … 436 381 { 437 382 #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; 442 387 } 443 388 444 389 #ifdef HAVE_DOS_PATHS 445 390 /* 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] = '/'; 448 393 #endif 449 394 /* Now add the name-within-directory at the end of NAME. */ 450 395 #ifndef VMS 451 if ( n != name && n[-1] != '/')396 if (p != name && p[-1] != '/') 452 397 { 453 * n= '/';454 bcopy (filename, n + 1, flen + 1);398 *p = '/'; 399 memcpy (p + 1, filename, flen + 1); 455 400 } 456 401 else 457 402 #endif 458 bcopy (filename, n, flen + 1);403 memcpy (p, filename, flen + 1); 459 404 460 405 /* Check if the file is mentioned in a makefile. If *FILE is not … … 503 448 /* Clobber a null into the name at the last slash. 504 449 Now NAME is the name of the directory to look in. */ 505 * n= '\0';450 *p = '\0'; 506 451 507 452 /* We know the directory is in the hash table now because either … … 524 469 #ifndef VMS 525 470 /* Put the slash back in NAME. */ 526 * n= '/';471 *p = '/'; 527 472 #endif 528 473 … … 547 492 548 493 /* 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 554 495 UNKNOWN_MTIME to indicate this. */ 555 496 if (mtime_ptr != 0) 556 497 *mtime_ptr = UNKNOWN_MTIME; 557 498 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); 560 502 } 561 503 } 562 504 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 514 const char * 515 vpath_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 564 544 return 0; 565 545 } … … 571 551 print_vpath_data_base (void) 572 552 { 573 registerunsigned int nvpaths;574 registerstruct vpath *v;553 unsigned int nvpaths; 554 struct vpath *v; 575 555 576 556 puts (_("\n# VPATH Search Paths\n")); … … 599 579 else 600 580 { 601 registerchar **path = general_vpath->searchpath;602 registerunsigned int i;581 const char **path = general_vpath->searchpath; 582 unsigned int i; 603 583 604 584 fputs (_("\n# General (`VPATH' variable) search path:\n# "), stdout); -
vendor/gnumake/current/w32/include/pathstuff.h
r501 r900 19 19 #define _PATHSTUFF_H 20 20 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);21 char *convert_Path_to_windows32(char *Path, char to_delim); 22 char *convert_vpath_to_windows32(char *Path, char to_delim); 23 char *w32ify(const char *file, int resolve); 24 char *getcwd_fs(char *buf, int len); 25 25 26 26 #endif -
vendor/gnumake/current/w32/pathstuff.c
r501 r900 84 84 */ 85 85 char * 86 w32ify(c har *filename, int resolve)86 w32ify(const char *filename, int resolve) 87 87 { 88 88 static char w32_path[FILENAME_MAX];
Note:
See TracChangeset
for help on using the changeset viewer.