From d3ee995eafa9640bad51f6bb0c3f69b6d6aca4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 20 Mar 2019 13:39:27 +0100 Subject: 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. --- source/blender/blenlib/intern/path_util.c | 62 ++++++++++++++++--------------- 1 file changed, 32 insertions(+), 30 deletions(-) (limited to 'source/blender/blenlib') 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'; } -- cgit v1.2.3