fix [#26803] Libs paths are case sensitive in windows
authorCampbell Barton <ideasman42@gmail.com>
Wed, 6 Apr 2011 06:03:48 +0000 (06:03 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 6 Apr 2011 06:03:48 +0000 (06:03 +0000)
use case insensitive path comparison on windows: BLI_path_cmp

17 files changed:
source/blender/blenfont/intern/blf_dir.c
source/blender/blenlib/BLI_path_util.h
source/blender/blenlib/intern/path_util.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/gpencil/gpencil_buttons.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/space_file/file_panels.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_file/fsmenu.c
source/blender/imbuf/intern/thumbs.c
source/blender/makesdna/intern/dna_genfile.c
source/blender/python/intern/bpy.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/intern/wm_operators.c
source/gameengine/Converter/KX_BlenderSceneConverter.cpp

index 3786de9..857ead0 100644 (file)
@@ -60,7 +60,7 @@ static DirBLF *blf_dir_find(const char *path)
        
        p= global_font_dir.first;
        while (p) {
        
        p= global_font_dir.first;
        while (p) {
-               if (!strcmp(p->path, path))
+               if (BLI_path_cmp(p->path, path) == 0)
                        return(p);
                p= p->next;
        }
                        return(p);
                p= p->next;
        }
index ed52bf3..41e784a 100644 (file)
@@ -158,9 +158,16 @@ int BLI_path_abs(char *path, const char *basepath);
 int BLI_path_frame(char *path, int frame, int digits);
 int BLI_path_frame_range(char *path, int sta, int end, int digits);
 int BLI_path_cwd(char *path);
 int BLI_path_frame(char *path, int frame, int digits);
 int BLI_path_frame_range(char *path, int sta, int end, int digits);
 int BLI_path_cwd(char *path);
-
 void BLI_path_rel(char *file, const char *relfile);
 
 void BLI_path_rel(char *file, const char *relfile);
 
+#ifdef WIN32
+#  define BLI_path_cmp BLI_strcasecmp
+#  define BLI_path_ncmp BLI_strncasecmp
+#else
+#  define BLI_path_cmp strcmp
+#  define BLI_path_ncmp strncmp
+#endif
+
        /**
         * Change every @a from in @a string into @a to. The
         * result will be in @a string
        /**
         * Change every @a from in @a string into @a to. The
         * result will be in @a string
index 689c639..bc5e20f 100644 (file)
@@ -1481,7 +1481,7 @@ int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char
        if (!strncmp(path, blend_dir, len)) {
 
                /* if image is _in_ current .blend file directory */
        if (!strncmp(path, blend_dir, len)) {
 
                /* if image is _in_ current .blend file directory */
-               if (!strcmp(dir, blend_dir)) {
+               if (BLI_path_cmp(dir, blend_dir) == 0) {
                        BLI_join_dirfile(dest_path, sizeof(dest_path), dest_dir, base);
                }
                /* "below" */
                        BLI_join_dirfile(dest_path, sizeof(dest_path), dest_dir, base);
                }
                /* "below" */
@@ -1508,7 +1508,7 @@ int BKE_rebase_path(char *abs, int abs_size, char *rel, int rel_size, const char
        }
 
        /* return 2 if src=dest */
        }
 
        /* return 2 if src=dest */
-       if (!strcmp(path, dest_path)) {
+       if (BLI_path_cmp(path, dest_path) == 0) {
                // if (G.f & G_DEBUG) printf("%s and %s are the same file\n", path, dest_path);
                return 2;
        }
                // if (G.f & G_DEBUG) printf("%s and %s are the same file\n", path, dest_path);
                return 2;
        }
index 54feaed..779e08e 100644 (file)
@@ -500,7 +500,7 @@ static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *name, c
        for (m= mainlist->first; m; m= m->next) {
                char *libname= (m->curlib)?m->curlib->filepath:m->name;
                
        for (m= mainlist->first; m; m= m->next) {
                char *libname= (m->curlib)?m->curlib->filepath:m->name;
                
-               if (BLI_streq(name1, libname)) {
+               if (BLI_path_cmp(name1, libname) == 0) {
                        if(G.f & G_DEBUG) printf("blo_find_main: found library %s\n", libname);
                        return m;
                }
                        if(G.f & G_DEBUG) printf("blo_find_main: found library %s\n", libname);
                        return m;
                }
@@ -5449,7 +5449,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
        
        for(newmain= fd->mainlist.first; newmain; newmain= newmain->next) {
                if(newmain->curlib) {
        
        for(newmain= fd->mainlist.first; newmain; newmain= newmain->next) {
                if(newmain->curlib) {
-                       if(strcmp(newmain->curlib->filepath, lib->filepath)==0) {
+                       if(BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) {
                                printf("Fixed error in file; multiple instances of lib:\n %s\n", lib->filepath);
                                BKE_reportf(fd->reports, RPT_WARNING, "Library '%s', '%s' had multiple instances, save and reload!", lib->name, lib->filepath);
 
                                printf("Fixed error in file; multiple instances of lib:\n %s\n", lib->filepath);
                                BKE_reportf(fd->reports, RPT_WARNING, "Library '%s', '%s' had multiple instances, save and reload!", lib->name, lib->filepath);
 
index 50968cb..7f79159 100644 (file)
@@ -2547,7 +2547,7 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report
        }
 
        BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
        }
 
        BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
-       write_user_block= BLI_streq(dir, userfilename);
+       write_user_block= (BLI_path_cmp(dir, userfilename) == 0);
 
        if(write_flags & G_FILE_RELATIVE_REMAP)
                makeFilesRelative(mainvar, dir, NULL); /* note, making relative to something OTHER then G.main->name */
 
        if(write_flags & G_FILE_RELATIVE_REMAP)
                makeFilesRelative(mainvar, dir, NULL); /* note, making relative to something OTHER then G.main->name */
index 67b732f..79fcbb0 100644 (file)
@@ -73,8 +73,9 @@
 /* make layer active one after being clicked on */
 static void gp_ui_activelayer_cb (bContext *C, void *gpd, void *gpl)
 {
 /* make layer active one after being clicked on */
 static void gp_ui_activelayer_cb (bContext *C, void *gpd, void *gpl)
 {
+       /* make sure the layer we want to remove is the active one */
        gpencil_layer_setactive(gpd, gpl);
        gpencil_layer_setactive(gpd, gpl);
-       
+
        WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work!
 }
 
        WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work!
 }
 
@@ -88,13 +89,7 @@ static void gp_ui_dellayer_cb (bContext *C, void *gpd, void *gpl)
        WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work!
 }
 
        WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work!
 }
 
-static void gp_ui_actlayer_cb (bContext *C, void *gpd, void *gpl)
-{
-       /* make sure the layer we want to remove is the active one */
-       gpencil_layer_setactive(gpd, gpl);
 
 
-       WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work!
-}
 
 /* ------- Drawing Code ------- */
 
 
 /* ------- Drawing Code ------- */
 
index 37af293..9507a1a 100644 (file)
@@ -686,7 +686,7 @@ int UI_iconfile_get_index(const char *filename)
        ListBase *list=&(iconfilelist);
        
        for(ifile=list->first; ifile; ifile=ifile->next) {
        ListBase *list=&(iconfilelist);
        
        for(ifile=list->first; ifile; ifile=ifile->next) {
-               if ( BLI_streq(filename, ifile->filename)) {
+               if (BLI_path_cmp(filename, ifile->filename) == 0) {
                        return ifile->index;
                }
        }
                        return ifile->index;
                }
        }
index 2963f09..959b1dd 100644 (file)
@@ -101,7 +101,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat
                
                /* set this list item as active if we have a match */
                if(sfile->params) {
                
                /* set this list item as active if we have a match */
                if(sfile->params) {
-                       if(strcmp(sfile->params->dir, entry) == 0) {
+                       if(BLI_path_cmp(sfile->params->dir, entry) == 0) {
                                *nr= i;
                        }
                }
                                *nr= i;
                        }
                }
index a32cfe2..f0ffe34 100644 (file)
@@ -459,7 +459,7 @@ int folderlist_clear_next(struct SpaceFile *sfile)
 
        // if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next
        folder = sfile->folders_prev->last;
 
        // if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next
        folder = sfile->folders_prev->last;
-       if ((!folder) ||(!strcmp(folder->foldername, sfile->params->dir)))
+       if ((!folder) ||(BLI_path_cmp(folder->foldername, sfile->params->dir) == 0))
                return 0;
 
        // eventually clear flist->folders_next
                return 0;
 
        // eventually clear flist->folders_next
@@ -697,7 +697,7 @@ int filelist_find(struct FileList* filelist, char *file)
 
        
        for (i = 0; i < filelist->numfiles; ++i) {
 
        
        for (i = 0; i < filelist->numfiles; ++i) {
-               if ( strcmp(filelist->filelist[i].relname, file) == 0) {
+               if ( strcmp(filelist->filelist[i].relname, file) == 0) { /* not dealing with user input so dont need BLI_path_cmp */
                        index = i;
                        break;
                }
                        index = i;
                        break;
                }
@@ -880,7 +880,7 @@ static void filelist_read_library(struct FileList* filelist)
                                strcat(name, file->relname);
                                
                                /* prevent current file being used as acceptable dir */
                                strcat(name, file->relname);
                                
                                /* prevent current file being used as acceptable dir */
-                               if (BLI_streq(G.main->name, name)==0) {
+                               if (BLI_path_cmp(G.main->name, name) != 0) {
                                        file->type &= ~S_IFMT;
                                        file->type |= S_IFDIR;
                                }
                                        file->type &= ~S_IFMT;
                                        file->type |= S_IFDIR;
                                }
index ffe1677..a6e84b0 100644 (file)
@@ -173,9 +173,11 @@ void fsmenu_insert_entry(struct FSMenu* fsmenu, FSMenuCategory category, const c
 
        for (; fsme; prev= fsme, fsme= fsme->next) {
                if (fsme->path) {
 
        for (; fsme; prev= fsme, fsme= fsme->next) {
                if (fsme->path) {
-                       if (BLI_streq(path, fsme->path)) {
+                       const int cmp_ret= BLI_path_cmp(path, fsme->path);
+                       if (cmp_ret == 0) {
                                return;
                                return;
-                       } else if (sorted && strcmp(path, fsme->path)<0) {
+                       }
+                       else if (sorted && cmp_ret < 0) {
                                break;
                        }
                } else {
                                break;
                        }
                } else {
index a9abcec..20276ae 100644 (file)
@@ -281,7 +281,7 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im
                BLI_snprintf(tpath, FILE_MAX, "%s%s", tdir, thumb);
                thumb[8] = '\0'; /* shorten for tempname, not needed anymore */
                BLI_snprintf(temp, FILE_MAX, "%sblender_%d_%s.png", tdir, abs(getpid()), thumb);
                BLI_snprintf(tpath, FILE_MAX, "%s%s", tdir, thumb);
                thumb[8] = '\0'; /* shorten for tempname, not needed anymore */
                BLI_snprintf(temp, FILE_MAX, "%sblender_%d_%s.png", tdir, abs(getpid()), thumb);
-               if (strncmp(path, tdir, strlen(tdir)) == 0) {
+               if (BLI_path_ncmp(path, tdir, sizeof(tdir)) == 0) {
                        return NULL;
                }
                if (size == THB_FAIL) {
                        return NULL;
                }
                if (size == THB_FAIL) {
@@ -387,7 +387,7 @@ void IMB_thumb_delete(const char* path, ThumbSize size)
                return;
        }
        if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
                return;
        }
        if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
-               if (strncmp(path, thumb, strlen(thumb)) == 0) {
+               if (BLI_path_ncmp(path, thumb, sizeof(thumb)) == 0) {
                        return;
                }
                if (BLI_exists(thumb)) {
                        return;
                }
                if (BLI_exists(thumb)) {
@@ -419,7 +419,7 @@ ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source)
        }
 
        if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
        }
 
        if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) {
-               if (strncmp(path, thumb, strlen(thumb)) == 0) {
+               if (BLI_path_ncmp(path, thumb, sizeof(thumb)) == 0) {
                        img = IMB_loadiffname(path, IB_rect);
                } else {
                        img = IMB_loadiffname(thumb, IB_rect | IB_metadata);
                        img = IMB_loadiffname(path, IB_rect);
                } else {
                        img = IMB_loadiffname(thumb, IB_rect | IB_metadata);
index 967effa..e0e521a 100644 (file)
@@ -194,7 +194,7 @@ int DNA_elem_array_size(const char *astr, int len)
 void DNA_sdna_free(SDNA *sdna)
 {
        MEM_freeN(sdna->data);
 void DNA_sdna_free(SDNA *sdna)
 {
        MEM_freeN(sdna->data);
-       MEM_freeN(sdna->names);
+       MEM_freeN((void *)sdna->names);
        MEM_freeN(sdna->types);
        MEM_freeN(sdna->structs);
        
        MEM_freeN(sdna->types);
        MEM_freeN(sdna->structs);
        
index 169d8a8..b247781 100644 (file)
@@ -115,7 +115,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
                }
                else {
                        lib= BLI_bpathIterator_getLib(bpi);
                }
                else {
                        lib= BLI_bpathIterator_getLib(bpi);
-                       if (lib && (strcmp(lib, BLI_bpathIterator_getBasePath(bpi)))) { /* relative path to the library is NOT the same as our blendfile path, return an absolute path */
+                       if (lib && (BLI_path_cmp(lib, BLI_bpathIterator_getBasePath(bpi)))) { /* relative path to the library is NOT the same as our blendfile path, return an absolute path */
                                BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
                        }
                        else {
                                BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
                        }
                        else {
index 35bb874..51a04b2 100644 (file)
@@ -510,7 +510,7 @@ static void write_history(void)
 
        recent = G.recent_files.first;
        /* refresh recent-files.txt of recent opened files, when current file was changed */
 
        recent = G.recent_files.first;
        /* refresh recent-files.txt of recent opened files, when current file was changed */
-       if(!(recent) || (strcmp(recent->filepath, G.main->name)!=0)) {
+       if(!(recent) || (BLI_path_cmp(recent->filepath, G.main->name)!=0)) {
                fp= fopen(name, "w");
                if (fp) {
                        /* add current file to the beginning of list */
                fp= fopen(name, "w");
                if (fp) {
                        /* add current file to the beginning of list */
@@ -524,7 +524,7 @@ static void write_history(void)
                        /* write rest of recent opened files to recent-files.txt */
                        while((i<U.recent_files) && (recent)){
                                /* this prevents to have duplicities in list */
                        /* write rest of recent opened files to recent-files.txt */
                        while((i<U.recent_files) && (recent)){
                                /* this prevents to have duplicities in list */
-                               if (strcmp(recent->filepath, G.main->name)!=0) {
+                               if (BLI_path_cmp(recent->filepath, G.main->name)!=0) {
                                        fprintf(fp, "%s\n", recent->filepath);
                                        recent = recent->next;
                                }
                                        fprintf(fp, "%s\n", recent->filepath);
                                        recent = recent->next;
                                }
@@ -656,7 +656,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
        
        /* send the OnSave event */
        for (li= G.main->library.first; li; li= li->id.next) {
        
        /* send the OnSave event */
        for (li= G.main->library.first; li; li= li->id.next) {
-               if (strcmp(li->filepath, di) == 0) {
+               if (BLI_path_cmp(li->filepath, di) == 0) {
                        BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.200s'", di);
                        return -1;
                }
                        BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.200s'", di);
                        return -1;
                }
index 57b84fc..336acd9 100644 (file)
@@ -104,7 +104,7 @@ wmKeyConfig *WM_keyconfig_new_user(wmWindowManager *wm, const char *idname)
 void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
 {
        if (keyconf) {
 void WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
 {
        if (keyconf) {
-               if (BLI_streq(U.keyconfigstr, keyconf->idname)) {
+               if (strncmp(U.keyconfigstr, keyconf->idname, sizeof(U.keyconfigstr)) == 0) {
                        BLI_strncpy(U.keyconfigstr, wm->defaultconf->idname, sizeof(U.keyconfigstr));
                }
 
                        BLI_strncpy(U.keyconfigstr, wm->defaultconf->idname, sizeof(U.keyconfigstr));
                }
 
index 0938999..4350b05 100644 (file)
@@ -1133,8 +1133,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
        sprintf(revision_str, "r%s", build_rev);
        
        BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi);
        sprintf(revision_str, "r%s", build_rev);
        
        BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi);
-       ver_width = BLF_width(style->widgetlabel.uifont_id, version_str)+5;
-       rev_width = BLF_width(style->widgetlabel.uifont_id, revision_str)+5;
+       ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_str) + 5;
+       rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_str) + 5;
 #endif //NAN_BUILDINFO
 
        block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
 #endif //NAN_BUILDINFO
 
        block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
@@ -1522,7 +1522,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
                BKE_report(op->reports, RPT_ERROR, "Nothing indicated");
                return OPERATOR_CANCELLED;
        }
                BKE_report(op->reports, RPT_ERROR, "Nothing indicated");
                return OPERATOR_CANCELLED;
        }
-       else if(BLI_streq(bmain->name, libname)) {
+       else if(BLI_path_cmp(bmain->name, libname) == 0) {
                BKE_report(op->reports, RPT_ERROR, "Cannot use current file as library");
                return OPERATOR_CANCELLED;
        }
                BKE_report(op->reports, RPT_ERROR, "Cannot use current file as library");
                return OPERATOR_CANCELLED;
        }
index 99cd30c..0af6470 100644 (file)
@@ -926,7 +926,7 @@ vector<Main*> &KX_BlenderSceneConverter::GetMainDynamic()
 Main* KX_BlenderSceneConverter::GetMainDynamicPath(const char *path)
 {
        for (vector<Main*>::iterator it=m_DynamicMaggie.begin(); !(it==m_DynamicMaggie.end()); it++)
 Main* KX_BlenderSceneConverter::GetMainDynamicPath(const char *path)
 {
        for (vector<Main*>::iterator it=m_DynamicMaggie.begin(); !(it==m_DynamicMaggie.end()); it++)
-               if(strcmp((*it)->name, path)==0)
+               if(BLI_path_cmp((*it)->name, path) == 0)
                        return *it;
        
        return NULL;
                        return *it;
        
        return NULL;