[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57679] trunk/blender/source/blender: use booleans for bpath api.

Campbell Barton ideasman42 at gmail.com
Mon Jun 24 05:06:35 CEST 2013


Revision: 57679
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57679
Author:   campbellbarton
Date:     2013-06-24 03:06:32 +0000 (Mon, 24 Jun 2013)
Log Message:
-----------
use booleans for bpath api.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_bpath.h
    trunk/blender/source/blender/blenkernel/intern/blender.c
    trunk/blender/source/blender/blenkernel/intern/bpath.c
    trunk/blender/source/blender/python/intern/bpy.c

Modified: trunk/blender/source/blender/blenkernel/BKE_bpath.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_bpath.h	2013-06-24 02:57:06 UTC (rev 57678)
+++ trunk/blender/source/blender/blenkernel/BKE_bpath.h	2013-06-24 03:06:32 UTC (rev 57679)
@@ -41,12 +41,12 @@
 
 /* Function that does something with an ID's file path. Should return 1 if the
  * path has changed, and in that case, should write the result to pathOut. */
-typedef int (*BPathVisitor)(void *userdata, char *path_dst, const char *path_src);
+typedef bool (*BPathVisitor)(void *userdata, char *path_dst, const char *path_src);
 /* Executes 'visit' for each path associated with 'id'. */
 void BKE_bpath_traverse_id(struct Main *bmain, struct ID *id, BPathVisitor visit_cb, const int flag, void *userdata);
 void BKE_bpath_traverse_id_list(struct Main *bmain, struct ListBase *lb, BPathVisitor visit_cb, const int flag, void *userdata);
 void BKE_bpath_traverse_main(struct Main *bmain, BPathVisitor visit_cb, const int flag, void *userdata);
-int  BKE_bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src);
+bool BKE_bpath_relocate_visitor(void *oldbasepath, char *path_dst, const char *path_src);
 
 /* Functions for temp backup/restore of paths, path count must NOT change */
 void *BKE_bpath_list_backup(struct Main *bmain, const int flag);

Modified: trunk/blender/source/blender/blenkernel/intern/blender.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/blender.c	2013-06-24 02:57:06 UTC (rev 57678)
+++ trunk/blender/source/blender/blenkernel/intern/blender.c	2013-06-24 03:06:32 UTC (rev 57679)
@@ -170,11 +170,11 @@
 	G.main = NULL;
 }
 
-static int clean_paths_visit_cb(void *UNUSED(userdata), char *path_dst, const char *path_src)
+static bool clean_paths_visit_cb(void *UNUSED(userdata), char *path_dst, const char *path_src)
 {
 	strcpy(path_dst, path_src);
 	BLI_clean(path_dst);
-	return (strcmp(path_dst, path_src) == 0) ? FALSE : TRUE;
+	return !STREQ(path_dst, path_src);
 }
 
 /* make sure path names are correct for OS */

Modified: trunk/blender/source/blender/blenkernel/intern/bpath.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/bpath.c	2013-06-24 02:57:06 UTC (rev 57678)
+++ trunk/blender/source/blender/blenkernel/intern/bpath.c	2013-06-24 03:06:32 UTC (rev 57679)
@@ -85,7 +85,7 @@
 
 #include "BKE_bpath.h"  /* own include */
 
-static int checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src)
+static bool checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src)
 {
 	ReportList *reports = (ReportList *)userdata;
 
@@ -93,7 +93,7 @@
 		BKE_reportf(reports, RPT_WARNING, "Path '%s' not found", path_src);
 	}
 
-	return FALSE;
+	return false;
 }
 
 /* high level function */
@@ -111,14 +111,14 @@
 	int count_failed;
 } BPathRemap_Data;
 
-static int makeFilesRelative_visit_cb(void *userdata, char *path_dst, const char *path_src)
+static bool makeFilesRelative_visit_cb(void *userdata, char *path_dst, const char *path_src)
 {
 	BPathRemap_Data *data = (BPathRemap_Data *)userdata;
 
 	data->count_tot++;
 
 	if (BLI_path_is_rel(path_src)) {
-		return FALSE; /* already relative */
+		return false; /* already relative */
 	}
 	else {
 		strcpy(path_dst, path_src);
@@ -130,7 +130,7 @@
 			BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made relative", path_src);
 			data->count_failed++;
 		}
-		return TRUE;
+		return true;
 	}
 }
 
@@ -153,26 +153,26 @@
 	            data.count_tot, data.count_changed, data.count_failed);
 }
 
-static int makeFilesAbsolute_visit_cb(void *userdata, char *path_dst, const char *path_src)
+static bool makeFilesAbsolute_visit_cb(void *userdata, char *path_dst, const char *path_src)
 {
 	BPathRemap_Data *data = (BPathRemap_Data *)userdata;
 
 	data->count_tot++;
 
-	if (BLI_path_is_rel(path_src) == FALSE) {
-		return FALSE; /* already absolute */
+	if (BLI_path_is_rel(path_src) == false) {
+		return false; /* already absolute */
 	}
 	else {
 		strcpy(path_dst, path_src);
 		BLI_path_abs(path_dst, data->basedir);
-		if (BLI_path_is_rel(path_dst) == FALSE) {
+		if (BLI_path_is_rel(path_dst) == false) {
 			data->count_changed++;
 		}
 		else {
 			BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made absolute", path_src);
 			data->count_failed++;
 		}
-		return TRUE;
+		return true;
 	}
 }
 
@@ -218,7 +218,7 @@
 	struct stat status;
 	char path[FILE_MAX];
 	int size;
-	int found = FALSE;
+	bool found = false;
 
 	dir = opendir(dirname);
 
@@ -230,7 +230,7 @@
 
 	while ((de = readdir(dir)) != NULL) {
 
-		if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0)
+		if (STREQ(".", de->d_name) || STREQ("..", de->d_name))
 			continue;
 
 		BLI_join_dirfile(path, sizeof(path), dirname, de->d_name);
@@ -239,13 +239,13 @@
 			continue;  /* cant stat, don't bother with this file, could print debug info here */
 
 		if (S_ISREG(status.st_mode)) { /* is file */
-			if (strncmp(filename, de->d_name, FILE_MAX) == 0) { /* name matches */
+			if (STREQLEN(filename, de->d_name, FILE_MAX)) { /* name matches */
 				/* open the file to read its size */
 				size = status.st_size;
 				if ((size > 0) && (size > *filesize)) { /* find the biggest file */
 					*filesize = size;
 					BLI_strncpy(filename_new, path, FILE_MAX);
-					found = TRUE;
+					found = true;
 				}
 			}
 		}
@@ -268,7 +268,7 @@
 	bool find_all;
 } BPathFind_Data;
 
-static int findMissingFiles_visit_cb(void *userdata, char *path_dst, const char *path_src)
+static bool findMissingFiles_visit_cb(void *userdata, char *path_dst, const char *path_src)
 {
 	BPathFind_Data *data = (BPathFind_Data *)userdata;
 	char filename_new[FILE_MAX];
@@ -293,17 +293,17 @@
 		BKE_reportf(data->reports, RPT_WARNING,
 		            "Could not open directory '%s'",
 		            BLI_path_basename(data->searchdir));
-		return FALSE;
+		return false;
 	}
-	else if (found == FALSE) {
+	else if (found == false) {
 		BKE_reportf(data->reports, RPT_WARNING,
 		            "Could not find '%s' in '%s'",
 		            BLI_path_basename((char *)path_src), data->searchdir);
-		return FALSE;
+		return false;
 	}
 	else {
 		BLI_strncpy(path_dst, filename_new, FILE_MAX);
-		return TRUE;
+		return true;
 	}
 }
 
@@ -320,7 +320,7 @@
 }
 
 /* Run a visitor on a string, replacing the contents of the string as needed. */
-static int rewrite_path_fixed(char *path, BPathVisitor visit_cb, const char *absbase, void *userdata)
+static bool rewrite_path_fixed(char *path, BPathVisitor visit_cb, const char *absbase, void *userdata)
 {
 	char path_src_buf[FILE_MAX];
 	const char *path_src;
@@ -337,18 +337,18 @@
 
 	if (visit_cb(userdata, path_dst, path_src)) {
 		BLI_strncpy(path, path_dst, FILE_MAX);
-		return TRUE;
+		return true;
 	}
 	else {
-		return FALSE;
+		return false;
 	}
 }
 
-static int rewrite_path_fixed_dirfile(char path_dir[FILE_MAXDIR],
-                                      char path_file[FILE_MAXFILE],
-                                      BPathVisitor visit_cb,
-                                      const char *absbase,
-                                      void *userdata)
+static bool rewrite_path_fixed_dirfile(char path_dir[FILE_MAXDIR],
+                                       char path_file[FILE_MAXFILE],
+                                       BPathVisitor visit_cb,
+                                       const char *absbase,
+                                       void *userdata)
 {
 	char path_src[FILE_MAX];
 	char path_dst[FILE_MAX];
@@ -361,14 +361,14 @@
 
 	if (visit_cb(userdata, path_dst, (const char *)path_src)) {
 		BLI_split_dirfile(path_dst, path_dir, path_file, FILE_MAXDIR, FILE_MAXFILE);
-		return TRUE;
+		return true;
 	}
 	else {
-		return FALSE;
+		return false;
 	}
 }
 
-static int rewrite_path_alloc(char **path, BPathVisitor visit_cb, const char *absbase, void *userdata)
+static bool rewrite_path_alloc(char **path, BPathVisitor visit_cb, const char *absbase, void *userdata)
 {
 	char path_src_buf[FILE_MAX];
 	const char *path_src;
@@ -386,10 +386,10 @@
 	if (visit_cb(userdata, path_dst, path_src)) {
 		MEM_freeN((*path));
 		(*path) = BLI_strdup(path_dst);
-		return TRUE;
+		return true;
 	}
 	else {
-		return FALSE;
+		return false;
 	}
 }
 
@@ -504,7 +504,7 @@
 		{
 			VFont *vfont = (VFont *)id;
 			if (vfont->packedfile == NULL || (flag & BKE_BPATH_TRAVERSE_SKIP_PACKED) == 0) {
-				if (BKE_vfont_is_builtin(vfont) == FALSE) {
+				if (BKE_vfont_is_builtin(vfont) == false) {
 					rewrite_path_fixed(((VFont *)id)->name, visit_cb, absbase, bpath_user_data);
 				}
 			}
@@ -641,7 +641,7 @@
 
 /* Rewrites a relative path to be relative to the main file - unless the path is
  * absolute, in which case it is not altered. */
-int BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src)
+bool BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src)
 {
 	/* be sure there is low chance of the path being too short */
 	char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE];
@@ -651,7 +651,7 @@
 	if (BLI_path_is_rel(base_old)) {
 		printf("%s: error, old base path '%s' is not absolute.\n",
 		       __func__, base_old);
-		return FALSE;
+		return false;
 	}
 
 	/* Make referenced file absolute. This would be a side-effect of
@@ -664,11 +664,11 @@
 		BLI_cleanup_file(base_new, filepath);
 		BLI_path_rel(filepath, base_new);
 		BLI_strncpy(path_dst, filepath, FILE_MAX);
-		return TRUE;
+		return true;
 	}
 	else {
 		/* Path was not relative to begin with. */
-		return FALSE;
+		return false;
 	}
 }
 
@@ -683,7 +683,7 @@
 	struct PathStore *next, *prev;
 };
 
-static int bpath_list_append(void *userdata, char *UNUSED(path_dst), const char *path_src)
+static bool bpath_list_append(void *userdata, char *UNUSED(path_dst), const char *path_src)
 {
 	/* store the path and string in a single alloc */
 	ListBase *ls = userdata;
@@ -693,24 +693,24 @@
 
 	memcpy(filepath, path_src, path_size);
 	BLI_addtail(ls, path_store);
-	return FALSE;
+	return false;
 }
 
-static int bpath_list_restore(void *userdata, char *path_dst, const char *path_src)
+static bool bpath_list_restore(void *userdata, char *path_dst, const char *path_src)
 {
 	/* assume ls->first wont be NULL because the number of paths can't change!
 	 * (if they do caller is wrong) */

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list