forked from bartvdbraak/blender
MSVC compiler is non-posix for some string operations...
Created a BLI_strcasestr and used existing BLI_strcasecmp in code now.
This commit is contained in:
parent
0de4c3c0eb
commit
7de24b7ea8
@ -243,25 +243,6 @@ Bone *get_named_bone (bArmature *arm, const char *name)
|
||||
return bone;
|
||||
}
|
||||
|
||||
static char *strcasestr_(register char *s, register char *find)
|
||||
{
|
||||
register char c, sc;
|
||||
register size_t len;
|
||||
|
||||
if ((c = *find++) != 0) {
|
||||
c= tolower(c);
|
||||
len = strlen(find);
|
||||
do {
|
||||
do {
|
||||
if ((sc = *s++) == 0)
|
||||
return (NULL);
|
||||
sc= tolower(sc);
|
||||
} while (sc != c);
|
||||
} while (BLI_strncasecmp(s, find, len) != 0);
|
||||
s--;
|
||||
}
|
||||
return ((char *) s);
|
||||
}
|
||||
|
||||
#define IS_SEPARATOR(a) (a=='.' || a==' ' || a=='-' || a=='_')
|
||||
|
||||
@ -340,7 +321,7 @@ void bone_flip_name (char *name, int strip_number)
|
||||
}
|
||||
else if(len > 5) {
|
||||
/* hrms, why test for a separator? lets do the rule 'ultimate left or right' */
|
||||
index = strcasestr_(prefix, "right");
|
||||
index = BLI_strcasestr(prefix, "right");
|
||||
if (index==prefix || index==prefix+len-5) {
|
||||
if(index[0]=='r')
|
||||
strcpy (replace, "left");
|
||||
@ -354,7 +335,7 @@ void bone_flip_name (char *name, int strip_number)
|
||||
strcpy (suffix, index+5);
|
||||
}
|
||||
else {
|
||||
index = strcasestr_(prefix, "left");
|
||||
index = BLI_strcasestr(prefix, "left");
|
||||
if (index==prefix || index==prefix+len-4) {
|
||||
if(index[0]=='l')
|
||||
strcpy (replace, "right");
|
||||
|
@ -349,6 +349,7 @@ void BLI_setErrorCallBack(void (*f)(char*));
|
||||
*/
|
||||
void BLI_setInterruptCallBack(int (*f)(void));
|
||||
|
||||
char *BLI_strcasestr(const char *s, const char *find);
|
||||
int BLI_strcasecmp(const char *s1, const char *s2);
|
||||
int BLI_strncasecmp(const char *s1, const char *s2, int n);
|
||||
void BLI_timestr(double time, char *str);
|
||||
|
@ -1382,6 +1382,28 @@ char* BLI_getbundle(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
/* strcasestr not available in MSVC */
|
||||
char *BLI_strcasestr(const char *s, const char *find)
|
||||
{
|
||||
register char c, sc;
|
||||
register size_t len;
|
||||
|
||||
if ((c = *find++) != 0) {
|
||||
c= tolower(c);
|
||||
len = strlen(find);
|
||||
do {
|
||||
do {
|
||||
if ((sc = *s++) == 0)
|
||||
return (NULL);
|
||||
sc= tolower(sc);
|
||||
} while (sc != c);
|
||||
} while (BLI_strncasecmp(s, find, len) != 0);
|
||||
s--;
|
||||
}
|
||||
return ((char *) s);
|
||||
}
|
||||
|
||||
|
||||
int BLI_strcasecmp(const char *s1, const char *s2) {
|
||||
int i;
|
||||
|
||||
|
@ -1910,11 +1910,11 @@ static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *na
|
||||
|
||||
/* determine if match */
|
||||
if(flags==OL_FIND)
|
||||
found= strcasestr(te->name, name)!=NULL;
|
||||
found= BLI_strcasestr(te->name, name)!=NULL;
|
||||
else if(flags==OL_FIND_CASE)
|
||||
found= strstr(te->name, name)!=NULL;
|
||||
else if(flags==OL_FIND_COMPLETE)
|
||||
found= strcasecmp(te->name, name)==0;
|
||||
found= BLI_strcasecmp(te->name, name)==0;
|
||||
else
|
||||
found= strcmp(te->name, name)==0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user