You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/07/10 06:15:01 UTC
[lucy-commits] svn commit: r1144775 - in /incubator/lucy/trunk/clownfish/src: CFCBindCore.c
CFCBindFile.c CFCFile.c CFCHierarchy.c CFCUtil.c CFCUtil.h
Author: marvin
Date: Sun Jul 10 04:15:00 2011
New Revision: 1144775
URL: http://svn.apache.org/viewvc?rev=1144775&view=rev
Log:
Consolidate PATH_SEP definition in CFCUtil.
Modified:
incubator/lucy/trunk/clownfish/src/CFCBindCore.c
incubator/lucy/trunk/clownfish/src/CFCBindFile.c
incubator/lucy/trunk/clownfish/src/CFCFile.c
incubator/lucy/trunk/clownfish/src/CFCHierarchy.c
incubator/lucy/trunk/clownfish/src/CFCUtil.c
incubator/lucy/trunk/clownfish/src/CFCUtil.h
Modified: incubator/lucy/trunk/clownfish/src/CFCBindCore.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCBindCore.c?rev=1144775&r1=1144774&r2=1144775&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCBindCore.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCBindCore.c Sun Jul 10 04:15:00 2011
@@ -36,14 +36,6 @@ struct CFCBindCore {
char *footer;
};
-#ifdef _WIN32
-#define PATH_SEP "\\"
-#define PATH_SEP_CHAR '\\'
-#else
-#define PATH_SEP "/"
-#define PATH_SEP_CHAR '/'
-#endif
-
/* Write the "parcel.h" header file, which contains common symbols needed by
* all classes, plus typedefs for all class structs.
*/
@@ -232,8 +224,8 @@ S_write_parcel_h(CFCBindCore *self) {
self->footer);
// Unlink then write file.
- char *filepath = CFCUtil_cat(CFCUtil_strdup(""), self->dest, PATH_SEP,
- "parcel.h", NULL);
+ char *filepath = CFCUtil_cat(CFCUtil_strdup(""), self->dest,
+ CFCUTIL_PATH_SEP, "parcel.h", NULL);
remove(filepath);
CFCUtil_write_file(filepath, file_content, strlen(file_content));
@@ -296,8 +288,8 @@ S_write_parcel_c(CFCBindCore *self) {
content, self->footer);
// Unlink then open file.
- char *filepath = CFCUtil_cat(CFCUtil_strdup(""), self->dest, PATH_SEP,
- "parcel.c", NULL);
+ char *filepath = CFCUtil_cat(CFCUtil_strdup(""), self->dest,
+ CFCUTIL_PATH_SEP, "parcel.c", NULL);
remove(filepath);
CFCUtil_write_file(filepath, file_content, strlen(file_content));
Modified: incubator/lucy/trunk/clownfish/src/CFCBindFile.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCBindFile.c?rev=1144775&r1=1144774&r2=1144775&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCBindFile.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCBindFile.c Sun Jul 10 04:15:00 2011
@@ -24,14 +24,6 @@
#include "CFCCBlock.h"
#include "CFCUtil.h"
-#ifdef _WIN32
-#define PATH_SEP "\\"
-#define PATH_SEP_CHAR '\\'
-#else
-#define PATH_SEP "/"
-#define PATH_SEP_CHAR '/'
-#endif
-
void
CFCBindFile_write_h(CFCFile *file, const char *dest, const char *header,
const char *footer) {
@@ -46,7 +38,7 @@ CFCBindFile_write_h(CFCFile *file, const
CFCFile_h_path(file, h_path, h_path_buf_size, dest);
char *h_dir = CFCUtil_strdup(h_path);
for (size_t len = h_path_buf_size; len--; ) {
- if (h_dir[len] == PATH_SEP_CHAR) {
+ if (h_dir[len] == CFCUTIL_PATH_SEP_CHAR) {
h_dir[len] = 0;
break;
}
Modified: incubator/lucy/trunk/clownfish/src/CFCFile.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCFile.c?rev=1144775&r1=1144774&r2=1144775&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCFile.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCFile.c Sun Jul 10 04:15:00 2011
@@ -25,14 +25,6 @@
#define false 0
#endif
-#ifdef _WIN32
-#define PATH_SEP "\\"
-#define PATH_SEP_CHAR '\\'
-#else
-#define PATH_SEP "/"
-#define PATH_SEP_CHAR '/'
-#endif
-
#define CFC_NEED_BASE_STRUCT_DEF
#include "CFCBase.h"
#include "CFCFile.h"
@@ -95,7 +87,7 @@ CFCFile_init(CFCFile *self, const char *
for (i = 0, j = 0; i < len; i++, j++) {
char c = source_class[i];
if (c == ':') {
- self->path_part[j] = PATH_SEP_CHAR;
+ self->path_part[j] = CFCUTIL_PATH_SEP_CHAR;
i++;
}
else {
@@ -176,7 +168,8 @@ S_some_path(CFCFile *self, char *buf, si
croak("Need buf_size of %lu, but got %lu", needed, buf_size);
}
if (base_dir) {
- sprintf(buf, "%s" PATH_SEP "%s%s", base_dir, self->path_part, ext);
+ sprintf(buf, "%s" CFCUTIL_PATH_SEP "%s%s", base_dir, self->path_part,
+ ext);
}
else {
sprintf(buf, "%s%s", self->path_part, ext);
@@ -198,7 +191,7 @@ CFCFile_path_buf_size(CFCFile *self, con
size += 1; // NULL-termination.
if (base_dir) {
size += strlen(base_dir);
- size += strlen(PATH_SEP);
+ size += strlen(CFCUTIL_PATH_SEP);
}
return size;
}
Modified: incubator/lucy/trunk/clownfish/src/CFCHierarchy.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCHierarchy.c?rev=1144775&r1=1144774&r2=1144775&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCHierarchy.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCHierarchy.c Sun Jul 10 04:15:00 2011
@@ -25,12 +25,6 @@
#define false 0
#endif
-#ifdef WIN32
- #define PATH_SEP "\\"
-#else
- #define PATH_SEP "/"
-#endif
-
#define CFC_NEED_BASE_STRUCT_DEF
#include "CFCBase.h"
#include "CFCHierarchy.h"
@@ -173,7 +167,8 @@ S_find_cfh(char *dir, char **cfh_list, s
full_path_cap = needed;
full_path = (char*)MALLOCATE(full_path_cap);
}
- int full_path_len = sprintf(full_path, "%s" PATH_SEP "%s", dir, entry);
+ int full_path_len = sprintf(full_path, "%s" CFCUTIL_PATH_SEP "%s",
+ dir, entry);
const char *cfh_suffix = strstr(full_path, ".cfh");
if (cfh_suffix == full_path + (full_path_len - 4)) {
Modified: incubator/lucy/trunk/clownfish/src/CFCUtil.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCUtil.c?rev=1144775&r1=1144774&r2=1144775&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCUtil.c (original)
+++ incubator/lucy/trunk/clownfish/src/CFCUtil.c Sun Jul 10 04:15:00 2011
@@ -294,12 +294,6 @@ CFCUtil_is_dir(const char *path) {
return (stat_buf.st_mode & S_IFDIR) ? true : false;
}
-#ifdef WIN32
- #define DIR_SEP_CHAR '\\'
-#else
- #define DIR_SEP_CHAR '/'
-#endif
-
int
CFCUtil_make_path(const char *path) {
CFCUTIL_NULL_CHECK(path);
@@ -313,7 +307,7 @@ CFCUtil_make_path(const char *path) {
continue;
}
#endif
- if (target[i] == DIR_SEP_CHAR || i == len) {
+ if (target[i] == CFCUTIL_PATH_SEP_CHAR || i == len) {
target[i] = 0; // NULL-terminate.
struct stat stat_buf;
int stat_check = stat(target, &stat_buf);
@@ -329,7 +323,7 @@ CFCUtil_make_path(const char *path) {
return false;
}
}
- target[i] = DIR_SEP_CHAR;
+ target[i] = CFCUTIL_PATH_SEP_CHAR;
}
}
Modified: incubator/lucy/trunk/clownfish/src/CFCUtil.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCUtil.h?rev=1144775&r1=1144774&r2=1144775&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCUtil.h (original)
+++ incubator/lucy/trunk/clownfish/src/CFCUtil.h Sun Jul 10 04:15:00 2011
@@ -113,6 +113,16 @@ CFCUtil_slurp_text(const char *file_path
long
CFCUtil_flength(void *file);
+/* A string and a char representing the path separator for this OS.
+ */
+#ifdef _WIN32
+ #define CFCUTIL_PATH_SEP "\\"
+ #define CFCUTIL_PATH_SEP_CHAR '\\'
+#else
+ #define CFCUTIL_PATH_SEP "/"
+ #define CFCUTIL_PATH_SEP_CHAR '/'
+#endif
+
/* Platform-agnostic opendir wrapper.
*/
void*