Changeset 2697 in kBuild
- Timestamp:
- Sep 16, 2013 10:30:08 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/function.c
r2594 r2697 2868 2868 } 2869 2869 length = math_int_from_string (argv[2]); 2870 if (length < 0 || (pad != NULL && length > 16*1024*1024 /* 16MB */)) 2871 fatal (NILF, _("$(substr ): length=%s is out of bounds\n"), argv[3]); 2870 if (pad != NULL && length > 16*1024*1024 /* 16MB */) 2871 fatal (NILF, _("$(substr ): length=%s is out of bounds\n"), argv[2]); 2872 if (pad != NULL && length < 0) 2873 fatal (NILF, _("$(substr ): negative length (%s) and padding doesn't mix.\n"), argv[2]); 2872 2874 if (length == 0) 2873 2875 return o; 2874 2876 } 2875 2877 2876 /* adjust start and length. */ 2878 /* Note that negative start is and length are used for referencing from the 2879 end of the string. */ 2877 2880 if (pad == NULL) 2878 2881 { 2879 2882 if (start > 0) 2880 { 2881 start--; /* one-origin */ 2882 if (start >= str_len) 2883 return o; 2884 if (length == 0 || start + length > str_len) 2885 length = str_len - start; 2886 } 2883 start--; /* one-origin */ 2887 2884 else 2888 2885 { … … 2890 2887 if (start <= 0) 2891 2888 { 2889 if (length < 0) 2890 return o; 2892 2891 start += length; 2893 2892 if (start <= 0) … … 2896 2895 start = 0; 2897 2896 } 2898 else if (length == 0 || start + length > str_len) 2899 length = str_len - start; 2900 } 2897 } 2898 2899 if (start >= str_len) 2900 return o; 2901 if (length == 0) 2902 length = str_len - start; 2903 else if (length < 0 && start >= -length) 2904 return o; 2905 else if (length < 0) 2906 length = str_len - start + length; 2907 else if (start + length > str_len) 2908 length = str_len - start; 2901 2909 2902 2910 o = variable_buffer_output (o, str + start, length);
Note:
See TracChangeset
for help on using the changeset viewer.