diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2018-06-11 11:03:42 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2018-06-11 11:03:42 +0300 |
commit | 0ec6196ae3ebab4f8cb90bc997c85d14c098aaef (patch) | |
tree | 57cf01b04bb33157555c598fcea41575c9958419 /source/blender/blenlib | |
parent | 05e7802a97360a49d59ddc6647d7169457ff9745 (diff) | |
parent | 7ac0272b776a18cbf4de2aa447cadd50909606c2 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 0533126fe56..f59ef7fd39f 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -113,25 +113,29 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu } if (found_digit) { - if (tail) strcpy(tail, &string[nume + 1]); - if (head) { - strcpy(head, string); - head[nums] = 0; + char *ptr; + long ret; + ret = strtoll(&(string[nums]), &ptr, 10); + if (ret >= INT_MIN && ret <= INT_MAX) { + if (tail) strcpy(tail, &string[nume + 1]); + if (head) { + strcpy(head, string); + head[nums] = 0; + } + if (numlen) *numlen = nume - nums + 1; + return ((int)ret); } - if (numlen) *numlen = nume - nums + 1; - return ((int)atoi(&(string[nums]))); } - else { - if (tail) strcpy(tail, string + name_end); - if (head) { - /* name_end points to last character of head, - * make it +1 so null-terminator is nicely placed - */ - BLI_strncpy(head, string, name_end + 1); - } - if (numlen) *numlen = 0; - return 0; + + if (tail) strcpy(tail, string + name_end); + if (head) { + /* name_end points to last character of head, + * make it +1 so null-terminator is nicely placed + */ + BLI_strncpy(head, string, name_end + 1); } + if (numlen) *numlen = 0; + return 0; } |