diff options
author | Daniel Dunbar <daniel@zuster.org> | 2005-04-02 19:36:57 +0400 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2005-04-02 19:36:57 +0400 |
commit | 24c9f650565e6a016cca9d45c7daee94dfcb7130 (patch) | |
tree | 89becedccd6ed77790f6c5c5e35280d9a4e560b4 /source | |
parent | bdb86d7c6765724d297e7aa97dec4c0cc7d2bae9 (diff) |
- got tired of str[n]casecmp not declared warnings
- added BLI_str[n]casecmp, use instead of regular versions
- rewrote BLI_str[n]casecmp to not be stupid
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/property.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/writeavi.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_blenlib.h | 3 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_winstuff.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/util.c | 65 | ||||
-rw-r--r-- | source/blender/blenlib/intern/winstuff.c | 58 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/jpeg.c | 5 | ||||
-rw-r--r-- | source/blender/python/api2_2x/gen_utils.c | 8 | ||||
-rw-r--r-- | source/blender/python/api2_2x/sceneRender.c | 4 | ||||
-rw-r--r-- | source/blender/quicktime/apple/quicktime_export.c | 2 | ||||
-rw-r--r-- | source/blender/src/filesel.c | 6 | ||||
-rw-r--r-- | source/blender/src/imasel.c | 4 | ||||
-rw-r--r-- | source/blender/src/seqaudio.c | 2 | ||||
-rw-r--r-- | source/blender/src/writemovie.c | 2 | ||||
-rw-r--r-- | source/creator/creator.c | 6 |
18 files changed, 77 insertions, 108 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index efd0606904e..27d87ce9117 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -706,7 +706,7 @@ static void sort_alpha_id(ListBase *lb, ID *id) idtest= lb->first; while(idtest) { - if(strcasecmp(idtest->name, id->name)>0 || idtest->lib) { + if(BLI_strcasecmp(idtest->name, id->name)>0 || idtest->lib) { BLI_insertlinkbefore(lb, idtest, id); break; } diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index 51cbcf1a628..a60c03c4840 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -164,11 +164,11 @@ int compare_property(bProperty *prop, char *str) switch(prop->type) { case PROP_BOOL: - if(strcasecmp(str, "true")==0) { + if(BLI_strcasecmp(str, "true")==0) { if(prop->data==1) return 0; else return 1; } - else if(strcasecmp(str, "false")==0) { + else if(BLI_strcasecmp(str, "false")==0) { if(prop->data==0) return 0; else return 1; } @@ -200,8 +200,8 @@ void set_property(bProperty *prop, char *str) switch(prop->type) { case PROP_BOOL: - if(strcasecmp(str, "true")==0) prop->data= 1; - else if(strcasecmp(str, "false")==0) prop->data= 0; + if(BLI_strcasecmp(str, "true")==0) prop->data= 1; + else if(BLI_strcasecmp(str, "false")==0) prop->data= 0; else prop->data= (atoi(str)!=0); break; case PROP_INT: diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 097e6107af2..77c35cc46ab 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -70,7 +70,7 @@ void makeavistring (char *string) RE_make_existing_file(string); - if (strcasecmp(string + strlen(string) - 4, ".avi")) { + if (BLI_strcasecmp(string + strlen(string) - 4, ".avi")) { sprintf(txt, "%04d_%04d.avi", (G.scene->r.sfra) , (G.scene->r.efra) ); strcat(string, txt); } diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h index 2e2dda5ef95..d133038b044 100644 --- a/source/blender/blenlib/BLI_blenlib.h +++ b/source/blender/blenlib/BLI_blenlib.h @@ -328,6 +328,9 @@ void BLI_setScanFillObjectRef(void* ob); */ void BLI_setScanFillColourRef(char* c); +int BLI_strcasecmp(const char *s1, const char *s2); +int BLI_strncasecmp(const char *s1, const char *s2, int n); + #define PRNTSUB(type,arg) printf(#arg ": %" #type " ", arg) #ifndef PRINT diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h index d353c016751..1783443ea3b 100644 --- a/source/blender/blenlib/BLI_winstuff.h +++ b/source/blender/blenlib/BLI_winstuff.h @@ -110,10 +110,6 @@ typedef struct _DIR { } DIR; void RegisterBlendExtension(char * str); -#ifndef FREE_WINDOWS -int strcasecmp (char *s1, char *s2); -int strncasecmp (char *s1, char *s2, int n); -#endif DIR *opendir (const char *path); struct dirent *readdir(DIR *dp); int closedir (DIR *dp); diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 50ac321d353..2b91542855f 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -152,7 +152,7 @@ int BLI_compare(struct direntry *entry1, struct direntry *entry2) if( strcmp(entry2->relname, ".")==0 ) return (1); if( strcmp(entry1->relname, "..")==0 ) return (-1); - return (strcasecmp(entry1->relname,entry2->relname)); + return (BLI_strcasecmp(entry1->relname,entry2->relname)); } diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index 191309dac3e..859d8d007b8 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -107,23 +107,23 @@ int BLI_stringdec(char *string, char *kop, char *staart, unsigned short *numlen) len2 = len = strlen( string); if (len > 6) { - if (strncasecmp(string + len - 6, ".blend", 6) == 0) len -= 6; - else if (strncasecmp(string + len - 6, ".trace", 6) == 0) len -= 6; + if (BLI_strncasecmp(string + len - 6, ".blend", 6) == 0) len -= 6; + else if (BLI_strncasecmp(string + len - 6, ".trace", 6) == 0) len -= 6; } if (len == len2) { if (len > 4) { /* handle .jf0 en .jf1 for jstreams */ - if (strncasecmp(string + len - 4, ".jf", 3) == 0) len -= 4; - else if (strncasecmp(string + len - 4, ".tga", 4) == 0) len -= 4; - else if (strncasecmp(string + len - 4, ".jpg", 4) == 0) len -= 4; - else if (strncasecmp(string + len - 4, ".png", 4) == 0) len -= 4; - else if (strncasecmp(string + len - 4, ".txt", 4) == 0) len -= 4; - else if (strncasecmp(string + len - 4, ".cyc", 4) == 0) len -= 4; - else if (strncasecmp(string + len - 4, ".enh", 4) == 0) len -= 4; - else if (strncasecmp(string + len - 4, ".rgb", 4) == 0) len -= 4; - else if (strncasecmp(string + len - 4, ".psx", 4) == 0) len -= 4; - else if (strncasecmp(string + len - 4, ".ble", 4) == 0) len -= 4; + if (BLI_strncasecmp(string + len - 4, ".jf", 3) == 0) len -= 4; + else if (BLI_strncasecmp(string + len - 4, ".tga", 4) == 0) len -= 4; + else if (BLI_strncasecmp(string + len - 4, ".jpg", 4) == 0) len -= 4; + else if (BLI_strncasecmp(string + len - 4, ".png", 4) == 0) len -= 4; + else if (BLI_strncasecmp(string + len - 4, ".txt", 4) == 0) len -= 4; + else if (BLI_strncasecmp(string + len - 4, ".cyc", 4) == 0) len -= 4; + else if (BLI_strncasecmp(string + len - 4, ".enh", 4) == 0) len -= 4; + else if (BLI_strncasecmp(string + len - 4, ".rgb", 4) == 0) len -= 4; + else if (BLI_strncasecmp(string + len - 4, ".psx", 4) == 0) len -= 4; + else if (BLI_strncasecmp(string + len - 4, ".ble", 4) == 0) len -= 4; } } @@ -413,7 +413,7 @@ int BLI_streq(char *a, char *b) { return (strcmp(a, b)==0); } int BLI_strcaseeq(char *a, char *b) { - return (strcasecmp(a, b)==0); + return (BLI_strcasecmp(a, b)==0); } void BLI_makestringcode(char *fromfile, char *str) @@ -641,7 +641,7 @@ int BLI_testextensie(char *str, char *ext) if(a==0 || b==0 || b>=a) { retval = 0; - } else if (strcasecmp(ext, str + a - b)) { + } else if (BLI_strcasecmp(ext, str + a - b)) { retval = 0; } else { retval = 1; @@ -894,3 +894,40 @@ char* BLI_getbundle(void) { } #endif +int BLI_strcasecmp(const char *s1, const char *s2) { + int i; + + for (i=0; ; i++) { + char c1 = tolower(s1[i]); + char c2 = tolower(s2[i]); + + if (c1<c2) { + return -1; + } else if (c1>c2) { + return 1; + } else if (c1==0) { + break; + } + } + + return 0; +} + +int BLI_strncasecmp(const char *s1, const char *s2, int n) { + int i; + + for (i=0; i<n; i++) { + char c1 = tolower(s1[i]); + char c2 = tolower(s2[i]); + + if (c1<c2) { + return -1; + } else if (c1>c2) { + return 1; + } else if (c1==0) { + break; + } + } + + return 0; +} diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 960bc69d797..34b9d9cf9b9 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -99,64 +99,6 @@ void RegisterBlendExtension(char * str) { } } -static void strlower (char *str) { - while (*str) { - *str= tolower(*str); - str++; - } -} - -static void strnlower (char *str, int n) { - while (n>0 && *str) { - *str= tolower(*str); - str++; - n--; - } -} - -#ifndef FREE_WINDOWS -int strcasecmp (char *s1, char *s2) { - char *st1, *st2; - int r; - - st1= MEM_mallocN(strlen(s1)+1, "temp string"); - strcpy(st1, s1); - - st2= MEM_mallocN(strlen(s2)+1, "temp string"); - strcpy(st2, s2); - - strlower(st1); - strlower(st2); - r= strcmp (st1, st2); - - MEM_freeN(st1); - MEM_freeN(st2); - - return r; -} - -int strncasecmp (char *s1, char *s2, int n) { - char *st1, *st2; - int r; - - st1= MEM_mallocN(n, "temp string"); - memcpy(st1, s1, n); - - st2= MEM_mallocN(n, "temp string"); - memcpy(st2, s2, n); - - strnlower(st1, n); - strnlower(st2, n); - - r= strncmp (st1, st2, n); - - MEM_freeN(st1); - MEM_freeN(st2); - - return r; -} -#endif - DIR *opendir (const char *path) { if (GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY) { DIR *newd= MEM_mallocN(sizeof(DIR), "opendir"); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 000a9261d37..d10d970e0d4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -47,7 +47,7 @@ #include <stdio.h> // for printf fopen fwrite fclose sprintf FILE #include <stdlib.h> // for getenv atoi #include <fcntl.h> // for open -#include <string.h> // for strcasecmp strrchr strncmp strstr +#include <string.h> // for strrchr strncmp strstr #include <math.h> // for fabs #ifndef WIN32 diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 1a5bb68832e..34796bac9d5 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -55,11 +55,6 @@ static boolean handle_app1 (j_decompress_ptr cinfo); static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int flags); -/* strncasecmp hack */ -#ifdef WIN32 -#define strncasecmp(a, b, n) strncmp(a, b, n) -#endif - /* * In principle there are 4 jpeg formats. * diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c index b8e8f92b83e..e23f652641b 100644 --- a/source/blender/python/api2_2x/gen_utils.c +++ b/source/blender/python/api2_2x/gen_utils.c @@ -30,13 +30,9 @@ * ***** END GPL/BL DUAL LICENSE BLOCK ***** */ -#if defined(__WIN32__) || defined(WIN32) || defined(_WIN32) - #include <string.h> -#else - #include <strings.h> /*for strcasecmp */ -#endif #include <DNA_text_types.h> #include <MEM_guardedalloc.h> +#include <BLI_blenlib.h> #include "gen_utils.h" #include "constant.h" @@ -234,7 +230,7 @@ int EXPP_map_case_getIntVal( const EXPP_map_pair * map, const char *sval, int *ival ) { while( map->sval ) { - if( !strcasecmp( sval, map->sval ) ) { + if( !BLI_strcasecmp( sval, map->sval ) ) { *ival = map->ival; return 1; } diff --git a/source/blender/python/api2_2x/sceneRender.c b/source/blender/python/api2_2x/sceneRender.c index 6c2fedd94f1..23137d85341 100644 --- a/source/blender/python/api2_2x/sceneRender.c +++ b/source/blender/python/api2_2x/sceneRender.c @@ -928,7 +928,7 @@ PyObject *RenderData_Play( BPy_RenderData * self ) BLI_convertstringcode( file, (char *) self->scene, self->renderContext->cfra ); RE_make_existing_file( file ); - if( strcasecmp( file + strlen( file ) - 4, ".mov" ) ) { + if( BLI_strcasecmp( file + strlen( file ) - 4, ".mov" ) ) { sprintf( txt, "%04d_%04d.mov", ( self->renderContext->sfra ), ( self->renderContext->efra ) ); @@ -942,7 +942,7 @@ PyObject *RenderData_Play( BPy_RenderData * self ) BLI_convertstringcode( file, G.sce, self->renderContext->cfra ); RE_make_existing_file( file ); - if( strcasecmp( file + strlen( file ) - 4, ".avi" ) ) { + if( BLI_strcasecmp( file + strlen( file ) - 4, ".avi" ) ) { sprintf( txt, "%04d_%04d.avi", ( self->renderContext->sfra ), ( self->renderContext->efra ) ); diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c index dd97cec736b..5c59f734345 100644 --- a/source/blender/quicktime/apple/quicktime_export.c +++ b/source/blender/quicktime/apple/quicktime_export.c @@ -417,7 +417,7 @@ void makeqtstring (char *string) { RE_make_existing_file(string); - if (strcasecmp(string + strlen(string) - 4, ".mov")) { + if (BLI_strcasecmp(string + strlen(string) - 4, ".mov")) { sprintf(txt, "%04d_%04d.mov", (G.scene->r.sfra) , (G.scene->r.efra) ); strcat(string, txt); } diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c index 01d44def531..219783f54fc 100644 --- a/source/blender/src/filesel.c +++ b/source/blender/src/filesel.c @@ -321,7 +321,7 @@ static int compare_name(const void *a1, const void *a2) if( strcmp(entry2->relname, ".")==0 ) return (1); if( strcmp(entry1->relname, "..")==0 ) return (-1); - return (strcasecmp(entry1->relname,entry2->relname)); + return (BLI_strcasecmp(entry1->relname,entry2->relname)); } static int compare_date(const void *a1, const void *a2) @@ -351,7 +351,7 @@ static int compare_date(const void *a1, const void *a2) if ( entry1->s.st_mtime < entry2->s.st_mtime) return 1; if ( entry1->s.st_mtime > entry2->s.st_mtime) return -1; - else return strcasecmp(entry1->relname,entry2->relname); + else return BLI_strcasecmp(entry1->relname,entry2->relname); } static int compare_size(const void *a1, const void *a2) @@ -380,7 +380,7 @@ static int compare_size(const void *a1, const void *a2) if ( entry1->s.st_size < entry2->s.st_size) return 1; if ( entry1->s.st_size > entry2->s.st_size) return -1; - else return strcasecmp(entry1->relname,entry2->relname); + else return BLI_strcasecmp(entry1->relname,entry2->relname); } diff --git a/source/blender/src/imasel.c b/source/blender/src/imasel.c index 2c233bfe613..c39fe83954e 100644 --- a/source/blender/src/imasel.c +++ b/source/blender/src/imasel.c @@ -105,7 +105,7 @@ int dir_compare(const void *a1, const void *a2) use1 = *in1; use2 = *in2; - return strcasecmp(use1->name, use2->name); + return BLI_strcasecmp(use1->name, use2->name); } void issort( int te, ImaDir **firstentry) @@ -148,7 +148,7 @@ int ima_compare(const void *a1, const void *a2) in2= (OneSelectableIma **)a2; use1 = *in1; use2 = *in2; - return strcasecmp(use1->file_name, use2->file_name); + return BLI_strcasecmp(use1->file_name, use2->file_name); } void imsort(OneSelectableIma **firstentry) diff --git a/source/blender/src/seqaudio.c b/source/blender/src/seqaudio.c index 794f00ebd7f..463d0244d1e 100644 --- a/source/blender/src/seqaudio.c +++ b/source/blender/src/seqaudio.c @@ -108,7 +108,7 @@ static void makewavstring (char *string) RE_make_existing_file(string); - if (strcasecmp(string + strlen(string) - 4, ".wav")) { + if (BLI_strcasecmp(string + strlen(string) - 4, ".wav")) { sprintf(txt, "%04d_%04d.wav", (G.scene->r.sfra) , (G.scene->r.efra) ); strcat(string, txt); } diff --git a/source/blender/src/writemovie.c b/source/blender/src/writemovie.c index b6d5b64de6f..a57728fc69c 100644 --- a/source/blender/src/writemovie.c +++ b/source/blender/src/writemovie.c @@ -107,7 +107,7 @@ static void make_movie_name(char *string) RE_make_existing_file(string); - if (strcasecmp(string + len - 3, ".mv")) { + if (BLI_strcasecmp(string + len - 3, ".mv")) { sprintf(txt, "%04d_%04d.mv", sfra, efra); strcat(string, txt); } diff --git a/source/creator/creator.c b/source/creator/creator.c index 6875a4ace89..7eecabca456 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -267,7 +267,7 @@ int main(int argc, char **argv) // need this. BLI_where_am_i(bprogname, argv[0]); - + /* Hack - force inclusion of the plugin api functions, * see blenpluginapi:pluginapi.c */ @@ -422,7 +422,7 @@ int main(int argc, char **argv) break; case 'n': case 'N': - if (strcasecmp(argv[a], "-noaudio") == 0|| strcasecmp(argv[a], "-nosound") == 0) { + if (BLI_strcasecmp(argv[a], "-noaudio") == 0|| BLI_strcasecmp(argv[a], "-nosound") == 0) { /** notify the gameengine that no audio is wanted, even if the user didn't give the flag -g noaudio. @@ -432,7 +432,7 @@ int main(int argc, char **argv) audio = 0; if (G.f & G_DEBUG) printf("setting audio to: %d\n", audio); } - else if (strcasecmp(argv[a], "-nofrozen") == 0) { + else if (BLI_strcasecmp(argv[a], "-nofrozen") == 0) { /* disable initialization of frozen python modules */ if (G.f & G_DEBUG) printf("disable frozen modules\n"); G.f |= G_NOFROZEN; |