for.c (146048) | for.c (177545) |
---|---|
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. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)for.c 8.1 (Berkeley) 6/6/93 33 */ 34 35#include <sys/cdefs.h> | 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. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 19 unchanged lines hidden (view full) --- 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)for.c 8.1 (Berkeley) 6/6/93 33 */ 34 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: head/usr.bin/make/for.c 146048 2005-05-10 12:02:15Z harti $"); | 36__FBSDID("$FreeBSD: head/usr.bin/make/for.c 177545 2008-03-24 12:33:28Z ru $"); |
37 38/*- 39 * for.c -- 40 * Functions to handle loops in a makefile. 41 * 42 * Interface: 43 * For_Eval Evaluate the loop in the passed line. 44 * For_Run Run accumulated loop --- 6 unchanged lines hidden (view full) --- 51 52#include "buf.h" 53#include "dir.h" 54#include "for.h" 55#include "globals.h" 56#include "lst.h" 57#include "make.h" 58#include "parse.h" | 37 38/*- 39 * for.c -- 40 * Functions to handle loops in a makefile. 41 * 42 * Interface: 43 * For_Eval Evaluate the loop in the passed line. 44 * For_Run Run accumulated loop --- 6 unchanged lines hidden (view full) --- 51 52#include "buf.h" 53#include "dir.h" 54#include "for.h" 55#include "globals.h" 56#include "lst.h" 57#include "make.h" 58#include "parse.h" |
59#include "str.h" |
|
59#include "util.h" 60#include "var.h" 61 62/* 63 * For statements are of the form: 64 * 65 * .for <variable> in <varlist> 66 * ... --- 25 unchanged lines hidden (view full) --- 92Boolean 93For_For(char *line) 94{ 95 char *ptr; 96 char *wrd; 97 char *sub; 98 Buffer *buf; 99 size_t varlen; | 60#include "util.h" 61#include "var.h" 62 63/* 64 * For statements are of the form: 65 * 66 * .for <variable> in <varlist> 67 * ... --- 25 unchanged lines hidden (view full) --- 93Boolean 94For_For(char *line) 95{ 96 char *ptr; 97 char *wrd; 98 char *sub; 99 Buffer *buf; 100 size_t varlen; |
101 int i; 102 ArgArray words; |
|
100 101 ptr = line; 102 103 /* 104 * Skip space between for and the variable. 105 */ 106 for (ptr++; *ptr && isspace((u_char)*ptr); ptr++) 107 ; --- 35 unchanged lines hidden (view full) --- 143 /* 144 * Skip to values 145 */ 146 while (*ptr && isspace((u_char)*ptr)) 147 ptr++; 148 149 /* 150 * Make a list with the remaining words | 103 104 ptr = line; 105 106 /* 107 * Skip space between for and the variable. 108 */ 109 for (ptr++; *ptr && isspace((u_char)*ptr); ptr++) 110 ; --- 35 unchanged lines hidden (view full) --- 146 /* 147 * Skip to values 148 */ 149 while (*ptr && isspace((u_char)*ptr)) 150 ptr++; 151 152 /* 153 * Make a list with the remaining words |
151 * XXX should use brk_string here. | |
152 */ 153 sub = Buf_Peel(Var_Subst(ptr, VAR_CMD, FALSE)); | 154 */ 155 sub = Buf_Peel(Var_Subst(ptr, VAR_CMD, FALSE)); |
154 for (ptr = sub; *ptr != '\0' && isspace((u_char)*ptr); ptr++) 155 ; 156 | 156 brk_string(&words, sub, FALSE); |
157 Lst_Init(&forLst); | 157 Lst_Init(&forLst); |
158 buf = Buf_Init(0); 159 for (wrd = ptr; *ptr != '\0'; ptr++) { 160 if (isspace((u_char)*ptr)) { 161 Buf_AppendRange(buf, wrd, ptr); 162 Lst_AtFront(&forLst, Buf_Peel(buf)); 163 164 buf = Buf_Init(0); 165 while (*ptr != '\0' && isspace((u_char)*ptr)) 166 ptr++; 167 wrd = ptr--; 168 } | 158 for (i = 1; i < words.argc; i++) { 159 if (words.argv[i][0] != '\0') 160 Lst_AtFront(&forLst, estrdup(words.argv[i])); |
169 } | 161 } |
162 ArgArray_Done(&words); |
|
170 DEBUGF(FOR, ("For: Iterator %s List %s\n", forVar, sub)); | 163 DEBUGF(FOR, ("For: Iterator %s List %s\n", forVar, sub)); |
171 172 if (ptr - wrd > 0) { 173 Buf_AppendRange(buf, wrd, ptr); 174 Lst_AtFront(&forLst, Buf_Peel(buf)); 175 } else { 176 Buf_Destroy(buf, TRUE); 177 } | |
178 free(sub); 179 180 forBuf = Buf_Init(0); 181 forLevel++; 182 return (TRUE); 183} 184 185/** --- 98 unchanged lines hidden --- | 164 free(sub); 165 166 forBuf = Buf_Init(0); 167 forLevel++; 168 return (TRUE); 169} 170 171/** --- 98 unchanged lines hidden --- |