Changeset 2153 in kBuild
- Timestamp:
- Dec 29, 2008 12:11:30 AM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/function.c
r2152 r2153 2469 2469 } 2470 2470 } 2471 length = math_int_from_string (argv[ 1]);2471 length = math_int_from_string (argv[2]); 2472 2472 if (length < 0 || (pad != NULL && length > 16*1024*1024 /* 16MB */)) 2473 2473 fatal (NILF, _("$(substr ): length=%s is out of bounds\n"), argv[3]); … … 2479 2479 if (pad == NULL) 2480 2480 { 2481 if (start > str_len)2481 if (start > 0) 2482 2482 { 2483 2483 start--; /* one-origin */ … … 2498 2498 start = 0; 2499 2499 } 2500 else if (length == 0 )2500 else if (length == 0 || start + length > str_len) 2501 2501 length = str_len - start; 2502 2502 } … … 2506 2506 else 2507 2507 { 2508 if (start > str_len)2508 if (start > 0) 2509 2509 { 2510 2510 start--; /* one-origin */ … … 2520 2520 { 2521 2521 if (start + length <= 0) 2522 return o;2522 return length ? helper_insert_pad (o, length, pad, pad_len) : o; 2523 2523 o = helper_insert_pad (o, -start, pad, pad_len); 2524 return variable_buffer_output (o, str, length + length);2524 return variable_buffer_output (o, str, length + start); 2525 2525 } 2526 2526 if (length == 0) … … 2532 2532 { 2533 2533 o = variable_buffer_output (o, str + start, str_len - start); 2534 o = helper_insert_pad (o, start + length - st art, pad, pad_len);2534 o = helper_insert_pad (o, start + length - str_len, pad, pad_len); 2535 2535 } 2536 2536 }
Note:
See TracChangeset
for help on using the changeset viewer.