Changeset 526 for trunk/src/gmake/function.c
- Timestamp:
- Sep 16, 2006, 4:37:51 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gmake/function.c
r520 r526 32 32 # include "pathstuff.h" 33 33 #endif 34 #include <assert.h> /* bird */ 34 35 35 36 … … 261 262 262 263 264 /* The maximum length of a function, once reached there is 265 it can't be function and we can skip the hash lookup drop out. */ 266 267 #define MAX_FUNCTION_LENGTH 10 /* bird */ 268 263 269 /* Look up a function by name. */ 264 270 #if defined(__GNUC__) || defined(_MSC_VER) 271 __inline 272 #endif 265 273 static const struct function_table_entry * 266 274 lookup_function (const char *s) 267 275 { 268 276 const char *e = s; 269 277 #ifdef MAX_FUNCTION_LENGTH 278 int left = MAX_FUNCTION_LENGTH; 279 int ch; 280 while (((ch = *e) >= 'a' && ch <='z') || ch == '-') 281 { 282 if (!left--) 283 return 0; 284 e++; 285 } 286 #else 270 287 while (*e && ( (*e >= 'a' && *e <= 'z') || *e == '-')) 271 288 e++; 289 #endif 272 290 if (*e == '\0' || isblank ((unsigned char) *e)) 273 291 { … … 2198 2216 *STRINGP past the reference and returning nonzero. If not, return zero. */ 2199 2217 2200 int 2201 handle_function (char **op, char **stringp) 2202 { 2203 const struct function_table_entry *entry_p; 2218 static int 2219 handle_function2 (const struct function_table_entry *entry_p, char **op, char **stringp) /* bird split it up. */ 2220 { 2204 2221 char openparen = (*stringp)[0]; 2205 2222 char closeparen = openparen == '(' ? ')' : '}'; … … 2213 2230 beg = *stringp + 1; 2214 2231 2215 entry_p = lookup_function (beg);2216 2217 if (!entry_p)2218 return 0;2219 2220 2232 /* We found a builtin function. Find the beginning of its arguments (skip 2221 2233 whitespace after the name). */ … … 2298 2310 2299 2311 return 1; 2312 } 2313 2314 int 2315 handle_function (char **op, char **stringp) /* bird split it up */ 2316 { 2317 const struct function_table_entry *entry_p = lookup_function (*stringp + 1); 2318 if (!entry_p) 2319 return 0; 2320 return handle_function2 (entry_p, op, stringp); 2300 2321 } 2301 2322 … … 2416 2437 hash_load (&function_table, function_table_init, 2417 2438 FUNCTION_TABLE_ENTRIES, sizeof (struct function_table_entry)); 2418 } 2439 #ifdef MAX_FUNCTION_LENGTH /* bird */ 2440 { 2441 unsigned i; 2442 for (i = 0; i < FUNCTION_TABLE_ENTRIES; i++) 2443 assert(function_table_init[i].len <= MAX_FUNCTION_LENGTH); 2444 } 2445 #endif 2446 }
Note:
See TracChangeset
for help on using the changeset viewer.