Merge branch 'master' into blender2.8
This commit is contained in:
commit
b6be8c0394
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue