From: Ben Pfaff Date: Mon, 17 Apr 2006 01:37:51 +0000 (+0000) Subject: We don't really support anything but Unix-like environments well, so X-Git-Tag: v0.6.0~977 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7a18bd636d11d167c1ebe54c9893a0c23d44bc9;p=pspp-builds.git We don't really support anything but Unix-like environments well, so we might as well de-obfuscate by writing directory and path separators explicitly. --- diff --git a/src/data/ChangeLog b/src/data/ChangeLog index 53067496..0c46e401 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,17 @@ +Sun Apr 16 18:35:33 2006 Ben Pfaff + + We don't really support anything but Unix-like environments well, + so we might as well de-obfuscate by writing directory and path + separators explicitly. + + * file-name.h: (macro DIR_SEPARATOR) Removed. Changed all usages + to just '/'. + (macro PATH_SEPARATOR) Removed. Changed all usages to just ':'. + (macro DIR_SEPARATOR_STRING) Removed. Changed all usages to just + "/". + (macro PATH_SEPARATOR_STRING) Removed. Changed all usages to just + ":" + Sun Apr 16 18:28:35 2006 Ben Pfaff GNU standards require "file name" instead of "filename" in diff --git a/src/data/file-name.c b/src/data/file-name.c index a88f83cf..e0c6e7b4 100644 --- a/src/data/file-name.c +++ b/src/data/file-name.c @@ -204,11 +204,11 @@ fn_tilde_expand (const char *input) } #endif /* !unix */ -/* Searches for a configuration file with name NAME in the path given - by PATH, which is tilde- and environment-interpolated. Directories - in PATH are delimited by PATH_DELIMITER, defined in . - Returns the malloc'd full name of the first file found, or NULL if - none is found. +/* Searches for a configuration file with name NAME in the path + given by PATH, which is tilde- and environment-interpolated. + Directories in PATH are delimited by ':'. Returns the + malloc'd full name of the first file found, or NULL if none is + found. If PREFIX is non-NULL, then it is prefixed to each filename; i.e., it looks like PREFIX/PATH_COMPONENT/NAME. This is not done @@ -230,7 +230,7 @@ fn_search_path (const char *base_name, const char *path_, const char *prefix) verbose_msg (2, _("searching for \"%s\" in path \"%s\""), base_name, ds_c_str (&path)); - while (ds_separate (&path, &dir, PATH_DELIMITER_STRING, &save_idx)) + while (ds_separate (&path, &dir, ":", &save_idx)) { /* Do tilde expansion. */ if (ds_first (&dir) == '~') @@ -245,11 +245,11 @@ fn_search_path (const char *base_name, const char *path_, const char *prefix) if (prefix != NULL && !fn_is_absolute (ds_c_str (&dir))) { ds_puts (&file, prefix); - ds_putc (&file, DIR_SEPARATOR); + ds_putc (&file, '/'); } ds_puts (&file, ds_c_str (&dir)); - if (ds_length (&dir) && ds_last (&file) != DIR_SEPARATOR) - ds_putc (&file, DIR_SEPARATOR); + if (ds_length (&dir) && ds_last (&file) != '/') + ds_putc (&file, '/'); ds_puts (&file, base_name); /* Check whether file exists. */ @@ -307,7 +307,7 @@ fn_normalize (const char *filename) dest = fn2 = xmalloc (maxlen + 1); src = fn1; - if (*src == DIR_SEPARATOR) + if (*src == '/') *dest++ = *src++; else { @@ -332,8 +332,8 @@ fn_normalize (const char *filename) fn2 = xrealloc (fn2, maxlen + 1); dest = fn2 + ofs; } - if (dest[-1] != DIR_SEPARATOR) - *dest++ = DIR_SEPARATOR; + if (dest[-1] != '/') + *dest++ = '/'; } for (;;) @@ -343,25 +343,25 @@ fn_normalize (const char *filename) c = *src++; f = 0; - if (c == DIR_SEPARATOR || c == 0) + if (c == '/' || c == 0) { /* remove `./', `../' from directory */ - if (dest[-1] == '.' && dest[-2] == DIR_SEPARATOR) + if (dest[-1] == '.' && dest[-2] == '/') dest--; - else if (dest[-1] == '.' && dest[-2] == '.' && dest[-3] == DIR_SEPARATOR) + else if (dest[-1] == '.' && dest[-2] == '.' && dest[-3] == '/') { dest -= 3; if (dest == fn2) dest++; - while (dest[-1] != DIR_SEPARATOR) + while (dest[-1] != '/') dest--; } - else if (dest[-1] != DIR_SEPARATOR) /* remove extra slashes */ + else if (dest[-1] != '/') /* remove extra slashes */ f = 1; if (c == 0) { - if (dest[-1] == DIR_SEPARATOR && dest > fn2 + 1) + if (dest[-1] == '/' && dest > fn2 + 1) dest--; *dest = 0; free (fn1); @@ -459,10 +459,10 @@ fn_dir_name (const char *filename) len = strlen (filename); if (len == 1 && filename[0] == '/') p = filename + 1; - else if (len && filename[len - 1] == DIR_SEPARATOR) + else if (len && filename[len - 1] == '/') p = buf_find_reverse (filename, len - 1, filename + len - 1, 1); else - p = strrchr (filename, DIR_SEPARATOR); + p = strrchr (filename, '/'); if (p == NULL) p = filename; diff --git a/src/data/file-name.h b/src/data/file-name.h index f9620b03..d4540ffe 100644 --- a/src/data/file-name.h +++ b/src/data/file-name.h @@ -22,19 +22,6 @@ #include -/* Directory separator and path delimiter for this OS. */ -#ifndef __MSDOS__ -#define DIR_SEPARATOR '/' -#define PATH_DELIMITER ':' -#define DIR_SEPARATOR_STRING "/" -#define PATH_DELIMITER_STRING ":" -#else -#define DIR_SEPARATOR '\\' -#define PATH_DELIMITER ';' -#define DIR_SEPARATOR_STRING "\\" -#define PATH_DELIMITER_STRING ";" -#endif - /* Search path for configuration files. */ extern const char *config_path; diff --git a/src/data/make-file.c b/src/data/make-file.c index 5f5a224a..f3cfdfbf 100644 --- a/src/data/make-file.c +++ b/src/data/make-file.c @@ -53,7 +53,7 @@ make_temp_file (int *fd, char **filename) parent_dir = P_tmpdir; *filename = xmalloc (strlen (parent_dir) + 32); - sprintf (*filename, "%s%cpsppXXXXXX", parent_dir, DIR_SEPARATOR); + sprintf (*filename, "%s/psppXXXXXX", parent_dir); *fd = mkstemp (*filename); if (*fd < 0) { @@ -93,7 +93,7 @@ make_unique_file_stream (FILE **fp, char **filename) *filename = xmalloc (strlen (parent_dir) + 32); - sprintf (*filename, "%s%cpspp%d.png", parent_dir, DIR_SEPARATOR, serial++); + sprintf (*filename, "%s/pspp%d.png", parent_dir, serial++); *fp = fopen(*filename, "w"); diff --git a/src/language/line-buffer.c b/src/language/line-buffer.c index f5a8b30d..aeb99e0a 100644 --- a/src/language/line-buffer.c +++ b/src/language/line-buffer.c @@ -123,7 +123,7 @@ void getl_add_include_dir (const char *path) { if (ds_length (&getl_include_path)) - ds_putc (&getl_include_path, PATH_DELIMITER); + ds_putc (&getl_include_path, ':'); ds_puts (&getl_include_path, path); } diff --git a/src/message.c b/src/message.c index 6985b261..dbd3c638 100644 --- a/src/message.c +++ b/src/message.c @@ -243,8 +243,8 @@ compulsory_break(int c) static inline int char_is_break (int quote, int c) { - return ((quote && c == DIR_SEPARATOR) - || (!quote && (isspace (c) || c == '-' || c == '/'))); + return ((quote && c == '/') + || (!quote && (isspace (c) || c == '-' || c == '/'))); } /* Returns 1 if C is a break character where the break should be made diff --git a/src/output/postscript.c b/src/output/postscript.c index 7fea6374..6c9cc860 100644 --- a/src/output/postscript.c +++ b/src/output/postscript.c @@ -433,7 +433,7 @@ find_ps_file (const char *name) return xstrdup (name); else { - char *base_name = xasprintf ("psfonts%c%s", DIR_SEPARATOR, name); + char *base_name = xasprintf ("psfonts/%s", name); char *file_name = fn_search_path (base_name, config_path, NULL); free (base_name); return file_name;