You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2012/12/28 22:34:30 UTC
[lucy-commits] [12/12] git commit: refs/heads/master - Use defines from DirManip and
Headers probes in CFC
Updated Branches:
refs/heads/master d874b33ea -> 80640cd6b
Use defines from DirManip and Headers probes in CFC
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/80640cd6
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/80640cd6
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/80640cd6
Branch: refs/heads/master
Commit: 80640cd6b6a7b416779df8f92c9abfcd4e48714b
Parents: 3b1ae28
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Dec 27 00:16:48 2012 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Fri Dec 28 22:23:11 2012 +0100
----------------------------------------------------------------------
clownfish/compiler/src/CFCBindCore.c | 8 +++---
clownfish/compiler/src/CFCBindFile.c | 4 ++-
clownfish/compiler/src/CFCFile.c | 6 +++-
clownfish/compiler/src/CFCHierarchy.c | 14 +++++-----
clownfish/compiler/src/CFCPerl.c | 16 +++++++-----
clownfish/compiler/src/CFCUtil.c | 37 +++++++++++++--------------
clownfish/compiler/src/CFCUtil.h | 10 -------
7 files changed, 45 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/80640cd6/clownfish/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindCore.c b/clownfish/compiler/src/CFCBindCore.c
index e4c9491..f5d2afb 100644
--- a/clownfish/compiler/src/CFCBindCore.c
+++ b/clownfish/compiler/src/CFCBindCore.c
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "charmony.h"
+
#include <string.h>
#include <stdio.h>
@@ -255,8 +257,7 @@ S_write_parcel_h(CFCBindCore *self) {
// Unlink then write file.
const char *inc_dest = CFCHierarchy_get_include_dest(hierarchy);
- char *filepath = CFCUtil_sprintf("%s" CFCUTIL_PATH_SEP "parcel.h",
- inc_dest);
+ char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "parcel.h", inc_dest);
remove(filepath);
CFCUtil_write_file(filepath, file_content, strlen(file_content));
FREEMEM(filepath);
@@ -347,8 +348,7 @@ S_write_parcel_c(CFCBindCore *self) {
// Unlink then open file.
const char *src_dest = CFCHierarchy_get_source_dest(hierarchy);
- char *filepath = CFCUtil_sprintf("%s" CFCUTIL_PATH_SEP "parcel.c",
- src_dest);
+ char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "parcel.c", src_dest);
remove(filepath);
CFCUtil_write_file(filepath, file_content, strlen(file_content));
FREEMEM(filepath);
http://git-wip-us.apache.org/repos/asf/lucy/blob/80640cd6/clownfish/compiler/src/CFCBindFile.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCBindFile.c b/clownfish/compiler/src/CFCBindFile.c
index ad98bb3..e7c9843 100644
--- a/clownfish/compiler/src/CFCBindFile.c
+++ b/clownfish/compiler/src/CFCBindFile.c
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "charmony.h"
+
#include <stdio.h>
#include <string.h>
#include "CFCBindFile.h"
@@ -36,7 +38,7 @@ CFCBindFile_write_h(CFCFile *file, const char *dest, const char *header,
char *h_path = CFCFile_h_path(file, dest);
char *h_dir = CFCUtil_strdup(h_path);
for (size_t len = strlen(h_dir); len--;) {
- if (h_dir[len] == CFCUTIL_PATH_SEP_CHAR) {
+ if (h_dir[len] == CHY_DIR_SEP_CHAR) {
h_dir[len] = 0;
break;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/80640cd6/clownfish/compiler/src/CFCFile.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCFile.c b/clownfish/compiler/src/CFCFile.c
index 6daec86..6aa3abc 100644
--- a/clownfish/compiler/src/CFCFile.c
+++ b/clownfish/compiler/src/CFCFile.c
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "charmony.h"
+
#include <string.h>
#include <stdio.h>
#include <ctype.h>
@@ -71,7 +73,7 @@ CFCFile_init(CFCFile *self, CFCFileSpec *spec) {
size_t i, j;
for (i = 0, j = 2; i < len; i++) {
char c = path_part[i];
- if (c == CFCUTIL_PATH_SEP_CHAR) {
+ if (c == CHY_DIR_SEP_CHAR) {
self->guard_name[j++] = '_';
}
else if (isalnum(c)) {
@@ -147,7 +149,7 @@ S_some_path(CFCFile *self, const char *base_dir, const char *ext) {
const char *path_part = CFCFileSpec_get_path_part(self->spec);
char *buf;
if (base_dir) {
- buf = CFCUtil_sprintf("%s" CFCUTIL_PATH_SEP "%s%s", base_dir,
+ buf = CFCUtil_sprintf("%s" CHY_DIR_SEP "%s%s", base_dir,
path_part, ext);
}
else {
http://git-wip-us.apache.org/repos/asf/lucy/blob/80640cd6/clownfish/compiler/src/CFCHierarchy.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCHierarchy.c b/clownfish/compiler/src/CFCHierarchy.c
index 5e90c16..973dfa0 100644
--- a/clownfish/compiler/src/CFCHierarchy.c
+++ b/clownfish/compiler/src/CFCHierarchy.c
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "charmony.h"
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -114,10 +116,8 @@ CFCHierarchy_init(CFCHierarchy *self, const char *dest) {
self->num_classes = 0;
self->parser = CFCParser_new();
- self->inc_dest = CFCUtil_sprintf("%s" CFCUTIL_PATH_SEP "include",
- self->dest);
- self->src_dest = CFCUtil_sprintf("%s" CFCUTIL_PATH_SEP "source",
- self->dest);
+ self->inc_dest = CFCUtil_sprintf("%s" CHY_DIR_SEP "include", self->dest);
+ self->src_dest = CFCUtil_sprintf("%s" CHY_DIR_SEP "source", self->dest);
S_do_make_path(self->inc_dest);
S_do_make_path(self->src_dest);
@@ -208,7 +208,7 @@ S_parse_parcel_files(const char *path, void *context) {
(void)context; // unused
// Ignore hidden files.
- if (strstr(path, CFCUTIL_PATH_SEP ".") != NULL) {
+ if (strstr(path, CHY_DIR_SEP ".") != NULL) {
return;
}
@@ -235,7 +235,7 @@ S_find_cfh(const char *path, void *context) {
char ***cfh_ptr = (char***)context;
char **cfh_list = *cfh_ptr;
// Ignore updirs and hidden files.
- if (strstr(path, CFCUTIL_PATH_SEP ".") != NULL) {
+ if (strstr(path, CHY_DIR_SEP ".") != NULL) {
return;
}
size_t path_len = strlen(path);
@@ -276,7 +276,7 @@ S_parse_cf_files(CFCHierarchy *self, const char *source_dir, int is_included) {
path_part = (char*)REALLOCATE(path_part, path_part_max);
}
const char *src = source_path + source_dir_len;
- while (*src == CFCUTIL_PATH_SEP_CHAR) {
+ while (*src == CHY_DIR_SEP_CHAR) {
++src;
--path_part_len;
}
http://git-wip-us.apache.org/repos/asf/lucy/blob/80640cd6/clownfish/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCPerl.c b/clownfish/compiler/src/CFCPerl.c
index f7bc313..92e4261 100644
--- a/clownfish/compiler/src/CFCPerl.c
+++ b/clownfish/compiler/src/CFCPerl.c
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "charmony.h"
+
#include <string.h>
#include <stdio.h>
#include <ctype.h>
@@ -83,9 +85,9 @@ CFCPerl_init(CFCPerl *self, CFCParcel *parcel, CFCHierarchy *hierarchy,
self->footer = CFCUtil_strdup(footer);
// Derive path to generated .xs file.
- self->xs_path = CFCUtil_sprintf("%s" CFCUTIL_PATH_SEP "%s.xs", lib_dir,
+ self->xs_path = CFCUtil_sprintf("%s" CHY_DIR_SEP "%s.xs", lib_dir,
boot_class);
- S_replace_double_colons(self->xs_path, CFCUTIL_PATH_SEP_CHAR);
+ S_replace_double_colons(self->xs_path, CHY_DIR_SEP_CHAR);
// Derive the name of the files containing bootstrapping code.
const char *prefix = CFCParcel_get_prefix(parcel);
@@ -93,9 +95,9 @@ CFCPerl_init(CFCPerl *self, CFCParcel *parcel, CFCHierarchy *hierarchy,
const char *src_dest = CFCHierarchy_get_source_dest(hierarchy);
self->boot_h_file = CFCUtil_sprintf("%sboot.h", prefix);
self->boot_c_file = CFCUtil_sprintf("%sboot.c", prefix);
- self->boot_h_path = CFCUtil_sprintf("%s" CFCUTIL_PATH_SEP "%s", inc_dest,
+ self->boot_h_path = CFCUtil_sprintf("%s" CHY_DIR_SEP "%s", inc_dest,
self->boot_h_file);
- self->boot_c_path = CFCUtil_sprintf("%s" CFCUTIL_PATH_SEP "%s", src_dest,
+ self->boot_c_path = CFCUtil_sprintf("%s" CHY_DIR_SEP "%s", src_dest,
self->boot_c_file);
// Derive the name of the bootstrap function.
@@ -156,9 +158,9 @@ CFCPerl_write_pod(CFCPerl *self) {
const char *class_name = CFCPerlClass_get_class_name(registry[i]);
char *pod = CFCPerlClass_create_pod(registry[i]);
if (!pod) { continue; }
- char *pod_path = CFCUtil_sprintf("%s" CFCUTIL_PATH_SEP "%s.pod",
+ char *pod_path = CFCUtil_sprintf("%s" CHY_DIR_SEP "%s.pod",
self->lib_dir, class_name);
- S_replace_double_colons(pod_path, CFCUTIL_PATH_SEP_CHAR);
+ S_replace_double_colons(pod_path, CHY_DIR_SEP_CHAR);
pods[count] = pod;
pod_paths[count] = pod_path;
@@ -575,7 +577,7 @@ CFCPerl_write_callbacks(CFCPerl *self) {
// Write if changed.
const char *src_dest = CFCHierarchy_get_source_dest(self->hierarchy);
- char *filepath = CFCUtil_sprintf("%s" CFCUTIL_PATH_SEP "callbacks.c",
+ char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "callbacks.c",
src_dest);
CFCUtil_write_if_changed(filepath, content, strlen(content));
http://git-wip-us.apache.org/repos/asf/lucy/blob/80640cd6/clownfish/compiler/src/CFCUtil.c
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCUtil.c b/clownfish/compiler/src/CFCUtil.c
index 3f56cd0..cb89a18 100644
--- a/clownfish/compiler/src/CFCUtil.c
+++ b/clownfish/compiler/src/CFCUtil.c
@@ -24,6 +24,11 @@
#include <errno.h>
#include <sys/stat.h>
+// For mkdir.
+#ifdef CHY_HAS_DIRECT_H
+ #include <direct.h>
+#endif
+
#ifndef true
#define true 1
#define false 0
@@ -335,7 +340,7 @@ CFCUtil_make_path(const char *path) {
continue;
}
#endif
- if (target[i] == CFCUTIL_PATH_SEP_CHAR || i == len) {
+ if (target[i] == CHY_DIR_SEP_CHAR || i == len) {
target[i] = 0; // NULL-terminate.
struct stat stat_buf;
int stat_check = stat(target, &stat_buf);
@@ -351,7 +356,7 @@ CFCUtil_make_path(const char *path) {
return false;
}
}
- target[i] = CFCUTIL_PATH_SEP_CHAR;
+ target[i] = CHY_DIR_SEP_CHAR;
}
}
@@ -380,18 +385,21 @@ CFCUtil_walk(const char *path, CFCUtil_walk_callback_t callback,
if (strcmp(entry, ".") == 0 || strcmp(entry, "..") == 0) {
continue;
}
- char *subpath = CFCUtil_sprintf("%s" CFCUTIL_PATH_SEP "%s", path,
- entry);
+ char *subpath = CFCUtil_sprintf("%s" CHY_DIR_SEP "%s", path, entry);
CFCUtil_walk(subpath, callback, context);
FREEMEM(subpath);
}
CFCUtil_closedir(dirhandle, path);
}
+int
+CFCUtil_make_dir(const char *dir) {
+ return !chy_makedir(dir, 0777);
+}
+
/******************************** WINDOWS **********************************/
-#ifdef _WIN32
+#if (defined(CHY_HAS_WINDOWS_H) && !defined(__CYGWIN__))
-#include <direct.h>
#include <windows.h>
typedef struct WinDH {
@@ -401,11 +409,6 @@ typedef struct WinDH {
int first_time;
} WinDH;
-int
-CFCUtil_make_dir(const char *dir) {
- return !mkdir(dir);
-}
-
void*
CFCUtil_opendir(const char *dir) {
size_t dirlen = strlen(dir);
@@ -456,16 +459,10 @@ CFCUtil_closedir(void *dirhandle, const char *dir) {
}
/******************************** UNIXEN ***********************************/
-#else
+#elif defined(CHY_HAS_DIRENT_H)
#include <dirent.h>
-int
-CFCUtil_make_dir(const char *dir) {
- return !mkdir(dir, 0777);
-}
-
-
void*
CFCUtil_opendir(const char *dir) {
DIR *dirhandle = opendir(dir);
@@ -488,7 +485,9 @@ CFCUtil_closedir(void *dirhandle, const char *dir) {
}
}
-#endif /* Windows vs. Unix. */
+#else
+ #error "Need either dirent.h or windows.h"
+#endif // CHY_HAS_DIRENT_H vs. CHY_HAS_WINDOWS_H
/***************************************************************************/
http://git-wip-us.apache.org/repos/asf/lucy/blob/80640cd6/clownfish/compiler/src/CFCUtil.h
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCUtil.h b/clownfish/compiler/src/CFCUtil.h
index df78500..961bccf 100644
--- a/clownfish/compiler/src/CFCUtil.h
+++ b/clownfish/compiler/src/CFCUtil.h
@@ -134,16 +134,6 @@ CFCUtil_slurp_text(const char *file_path, size_t *len_ptr);
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*