Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/string.c
| Show First 20 Lines • Show All 956 Lines • ▼ Show 20 Lines | for (commas = 2 - num_len % 3; *p_src; commas = (commas + 1) % 3) { | ||||
| if (commas == 1) { | if (commas == 1) { | ||||
| *p_dst++ = separator; | *p_dst++ = separator; | ||||
| } | } | ||||
| } | } | ||||
| *--p_dst = '\0'; | *--p_dst = '\0'; | ||||
| return (size_t)(p_dst - dst); | return (size_t)(p_dst - dst); | ||||
| } | } | ||||
| size_t BLI_str_remove_whitespace_trailing(char *dst, const char *src) | |||||
| { | |||||
| char *end_p = (char *)src + (strlen(src) - 1); /* position at last character */ | |||||
| size_t len; | |||||
| while(isspace(*end_p)) { | |||||
| end_p--; | |||||
| } | |||||
| end_p++; | |||||
| len = (size_t)(end_p - src); | |||||
| memcpy(dst, src, len); | |||||
| dst[len] = '\0'; | |||||
| return len; | |||||
| } | |||||
| size_t BLI_str_remove_whitespace_leading(char *dst, const char *src) | |||||
| { | |||||
| size_t len; | |||||
| while(isspace(*src)) { | |||||
| src++; | |||||
| } | |||||
| len = strlen(src); | |||||
| memcpy(dst, src, len); | |||||
| dst[strlen(src)] = '\0'; | |||||
| return len; | |||||
| } | |||||