diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2019-03-20 15:39:27 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2019-03-20 15:45:14 +0300 |
commit | d3ee995eafa9640bad51f6bb0c3f69b6d6aca4e6 (patch) | |
tree | dddebf9a8b733b77b514f1de4821619f8cf5cf19 /source/blender/blenlib/intern/path_util.c | |
parent | 0333cf00baf4d5b796347334af1f15d5bb9a2df4 (diff) |
Cleanup: return early in BLI_path_frame_get
Instead of making the entire body of the function conditional, it now
returns early, unindenting the entire function and preventing the reader
from searching for a non-existent `else` clause.
No semantic changes.
Diffstat (limited to 'source/blender/blenlib/intern/path_util.c')
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 6d69f29a228..34fb7112789 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -864,47 +864,49 @@ bool BLI_path_frame_get(char *path, int *r_frame, int *r_numdigits) void BLI_path_frame_strip(char *path, char *r_ext) { - if (*path) { - char *file = (char *)BLI_last_slash(path); - char *c, *suffix; - int len; - int numdigits = 0; - - if (file == NULL) - file = path; + if (*path == '\0') { + return; + } - /* first get the extension part */ - len = strlen(file); + char *file = (char *)BLI_last_slash(path); + char *c, *suffix; + int len; + int numdigits = 0; - c = file + len; + if (file == NULL) + file = path; - /* isolate extension */ - while (--c != file) { - if (*c == '.') { - c--; - break; - } - } + /* first get the extension part */ + len = strlen(file); - suffix = c + 1; + c = file + len; - /* find start of number */ - while (c != (file - 1) && isdigit(*c)) { + /* isolate extension */ + while (--c != file) { + if (*c == '.') { c--; - numdigits++; + break; } + } - c++; + suffix = c + 1; - int suffix_length = len - (suffix - file); - BLI_strncpy(r_ext, suffix, suffix_length+1); + /* find start of number */ + while (c != (file - 1) && isdigit(*c)) { + c--; + numdigits++; + } - /* replace the number with the suffix and terminate the string */ - while (numdigits--) { - *c++ = '#'; - } - *c = '\0'; + c++; + + int suffix_length = len - (suffix - file); + BLI_strncpy(r_ext, suffix, suffix_length+1); + + /* replace the number with the suffix and terminate the string */ + while (numdigits--) { + *c++ = '#'; } + *c = '\0'; } |