diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-11 11:46:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-11 11:46:33 +0300 |
commit | b6be8c03942bc254921117e77e406ca225a47aa7 (patch) | |
tree | b3a36a237d630bc30bf71972034522d7af5f36a6 /source/blender/blenlib | |
parent | ca36364a6a9a720e8b19e8a500519236e4851855 (diff) | |
parent | 9e8bd3a072cff37fcc7808bdbefa1fb78ab94c22 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index f59ef7fd39f..a3651de73a2 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -83,7 +83,7 @@ static bool BLI_path_is_abs(const char *name); * \param tail Optional area to return copy of part of string following digits, or from dot if no digits. * \param numlen Optional to return number of digits found. */ -int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *numlen) +int BLI_stringdec(const char *string, char *head, char *tail, ushort *r_num_len) { uint nums = 0, nume = 0; int i; @@ -93,8 +93,12 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu const uint lslash_len = lslash != NULL ? (int)(lslash - string) : 0; uint name_end = string_len; - while (name_end > lslash_len && string[--name_end] != '.') {} /* name ends at dot if present */ - if (name_end == lslash_len && string[name_end] != '.') name_end = string_len; + while (name_end > lslash_len && string[--name_end] != '.') { + /* name ends at dot if present */ + } + if (name_end == lslash_len && string[name_end] != '.') { + name_end = string_len; + } for (i = name_end - 1; i >= (int)lslash_len; i--) { if (isdigit(string[i])) { @@ -113,28 +117,34 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu } if (found_digit) { - char *ptr; - long ret; - ret = strtoll(&(string[nums]), &ptr, 10); + const long long int ret = strtoll(&(string[nums]), NULL, 10); if (ret >= INT_MIN && ret <= INT_MAX) { - if (tail) strcpy(tail, &string[nume + 1]); + 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 (r_num_len) { + *r_num_len = nume - nums + 1; + } + return (int)ret; } } - if (tail) strcpy(tail, string + name_end); + 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; + if (r_num_len) { + *r_num_len = 0; + } return 0; } |