diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-27 11:24:00 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-27 11:24:54 +0300 |
commit | ecb6a6df52a9f3852c9bec12e63b4ab8b06fe5f4 (patch) | |
tree | ac72d0455f12ccba943a7444f1e9fd562ea5bb79 /source | |
parent | ff7a46cfad5eb824682594122afa6d2bf0e59ae4 (diff) |
OpenEXR cleanup: get rid of public `IMB_exr_split_token`, use BLI str helpers instead of own cooking.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_api.cpp | 37 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_multi.h | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/openexr/openexr_stub.cpp | 1 |
3 files changed, 21 insertions, 19 deletions
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index ba197948f7d..eb25ca811f2 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -769,16 +769,19 @@ static const char *imb_exr_insert_view_name(const char *passname, const char *vi return passname; static char retstr[EXR_PASS_MAXNAME]; - const char *end = passname + strlen(passname); - const char *token; + const char delims[] = {'.', '\0'}; + char *sep; + char *token; + size_t len; - int len = IMB_exr_split_token(passname, end, &token); + len = BLI_str_rpartition(passname, delims, &sep, &token); - if (len == 0) + if (sep) { + BLI_snprintf(retstr, sizeof(retstr), "%.*s.%s.%s", (int)len, passname, viewname, token); + } + else { BLI_snprintf(retstr, sizeof(retstr), "%s.%s", passname, viewname); - else - BLI_snprintf(retstr, sizeof(retstr), "%.*s%s.%s", - (int)(end - passname) - len, passname, viewname, token); + } return retstr; } @@ -1413,16 +1416,18 @@ void IMB_exr_close(void *handle) /* ********* */ /* get a substring from the end of the name, separated by '.' */ -int IMB_exr_split_token(const char *str, const char *end, const char **token) +static int imb_exr_split_token(const char *str, const char *end, const char **token) { - ptrdiff_t maxlen = end - str; - int len = 0; - while (len < maxlen && *(end - len - 1) != '.') { - len++; + const char delims[] = {'.', '\0'}; + char *sep; + + BLI_str_partition_ex(str, end, delims, &sep, (char **)token, true); + + if (!sep) { + *token = str; } - *token = end - len; - return len; + return (int)(end - *token); } static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *passname) @@ -1449,7 +1454,7 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa } /* last token is single character channel identifier */ - len = IMB_exr_split_token(name, end, &token); + len = imb_exr_split_token(name, end, &token); if (len == 0) { printf("multilayer read: bad channel name: %s\n", name); return 0; @@ -1487,7 +1492,7 @@ static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *pa end -= len + 1; /* +1 to skip '.' separator */ /* second token is pass name */ - len = IMB_exr_split_token(name, end, &token); + len = imb_exr_split_token(name, end, &token); if (len == 0) { printf("multilayer read: bad channel name: %s\n", name); return 0; diff --git a/source/blender/imbuf/intern/openexr/openexr_multi.h b/source/blender/imbuf/intern/openexr/openexr_multi.h index 97e8042caa6..70ba4978124 100644 --- a/source/blender/imbuf/intern/openexr/openexr_multi.h +++ b/source/blender/imbuf/intern/openexr/openexr_multi.h @@ -93,8 +93,6 @@ void IMB_exr_close(void *handle); void IMB_exr_add_view(void *handle, const char *name); -int IMB_exr_split_token(const char *str, const char *end, const char **token); - bool IMB_exr_has_multilayer(void *handle); bool IMB_exr_has_singlelayer_multiview(void *handle); diff --git a/source/blender/imbuf/intern/openexr/openexr_stub.cpp b/source/blender/imbuf/intern/openexr/openexr_stub.cpp index 3ad23456b9f..c198cac6357 100644 --- a/source/blender/imbuf/intern/openexr/openexr_stub.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_stub.cpp @@ -79,6 +79,5 @@ bool IMB_exr_multiview_save( void IMB_exr_close (void * /*handle*/) { } void IMB_exr_add_view(void * /*handle*/, const char * /*name*/) { } -int IMB_exr_split_token(const char * /*str*/, const char * /*end*/, const char ** /*token*/) { return 1; } bool IMB_exr_has_multilayer(void * /*handle*/) { return false; } bool IMB_exr_has_singlelayer_multiview(void * /*handle*/) { return false; } |