Changeset 24 for branches/FREEBSD/src/kmk/for.c
- Timestamp:
- Nov 26, 2002, 10:24:54 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/FREEBSD/src/kmk/for.c
r10 r24 1 1 /* 2 * Copyright (c) 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Christos Zoulas. 2 * Copyright (c) 1992, The Regents of the University of California. 3 * All rights reserved. 7 4 * 8 5 * Redistribution and use in source and binary forms, with or without … … 33 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 31 * SUCH DAMAGE. 35 * 36 * @(#)for.c 8.1 (Berkeley) 6/6/93 37 */ 38 39 #include <sys/cdefs.h> 40 __FBSDID("$FreeBSD: src/usr.bin/make/for.c,v 1.19 2002/10/09 03:42:10 jmallett Exp $"); 32 */ 33 34 #ifndef lint 35 #if 0 36 static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93"; 37 #else 38 static const char rcsid[] = 39 "$FreeBSD: src/usr.bin/make/for.c,v 1.10 1999/09/11 13:08:01 hoek Exp $"; 40 #endif 41 #endif /* not lint */ 41 42 42 43 /*- … … 84 85 } For; 85 86 86 static int ForExec (void *, void *);87 static int ForExec __P((ClientData, ClientData)); 87 88 88 89 … … 108 109 */ 109 110 int 110 For_Eval (char *line) 111 For_Eval (line) 112 char *line; /* Line to parse */ 111 113 { 112 114 char *ptr = line, *sub, *wrd; … … 176 178 sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE); 177 179 178 #define 180 #define ADDWORD() \ 179 181 Buf_AddBytes(buf, ptr - wrd, (Byte *) wrd), \ 180 182 Buf_AddByte(buf, (Byte) '\0'), \ 181 Lst_AtFront(forLst, ( void *) Buf_GetAll(buf, &varlen)), \183 Lst_AtFront(forLst, (ClientData) Buf_GetAll(buf, &varlen)), \ 182 184 Buf_Destroy(buf, FALSE) 183 185 … … 193 195 wrd = ptr--; 194 196 } 195 DEBUGF(FOR, ("For: Iterator %s List %s\n", forVar, sub)); 197 if (DEBUG(FOR)) 198 (void) fprintf(stderr, "For: Iterator %s List %s\n", forVar, sub); 196 199 if (ptr - wrd > 0) 197 200 ADDWORD(); 198 201 else 199 202 Buf_Destroy(buf, TRUE); 200 free( sub);203 free((Address) sub); 201 204 202 205 forBuf = Buf_Init(0); … … 211 214 if (strncmp(ptr, "endfor", 6) == 0 && 212 215 (isspace((unsigned char) ptr[6]) || !ptr[6])) { 213 DEBUGF(FOR, ("For: end for %d\n", forLevel)); 216 if (DEBUG(FOR)) 217 (void) fprintf(stderr, "For: end for %d\n", forLevel); 214 218 if (--forLevel < 0) { 215 219 Parse_Error (level, "for-less endfor"); … … 220 224 isspace((unsigned char) ptr[3])) { 221 225 forLevel++; 222 DEBUGF(FOR, ("For: new loop %d\n", forLevel)); 226 if (DEBUG(FOR)) 227 (void) fprintf(stderr, "For: new loop %d\n", forLevel); 223 228 } 224 229 } … … 248 253 */ 249 254 static int 250 ForExec(void *namep, void *argp) 255 ForExec(namep, argp) 256 ClientData namep; 257 ClientData argp; 251 258 { 252 259 char *name = (char *) namep; … … 254 261 int len; 255 262 Var_Set(arg->var, name, VAR_GLOBAL); 256 DEBUGF(FOR, ("--- %s = %s\n", arg->var, name)); 263 if (DEBUG(FOR)) 264 (void) fprintf(stderr, "--- %s = %s\n", arg->var, name); 257 265 Parse_FromString(Var_Subst(arg->var, (char *) Buf_GetAll(arg->buf, &len), 258 266 VAR_GLOBAL, FALSE)); … … 278 286 */ 279 287 void 280 For_Run( void)288 For_Run() 281 289 { 282 290 For arg; … … 291 299 forLst = NULL; 292 300 293 Lst_ForEach(arg.lst, ForExec, ( void *) &arg);294 295 free( arg.var);296 Lst_Destroy(arg.lst, (void (*) (void *)) free);301 Lst_ForEach(arg.lst, ForExec, (ClientData) &arg); 302 303 free((Address)arg.var); 304 Lst_Destroy(arg.lst, (void (*) __P((ClientData))) free); 297 305 Buf_Destroy(arg.buf, TRUE); 298 306 }
Note:
See TracChangeset
for help on using the changeset viewer.