summaryrefslogtreecommitdiff
path: root/dln.c
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-12 11:03:24 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-12 11:03:24 +0000
commit4409f88ad81e5a9317caa554deb26c770d34d95f (patch)
tree53fbe7d62d46be4b12a32fdefcce7a70e7a4fa88 /dln.c
parent7ecb12dc27fa57b7d0ebae0584f9cef86c8dcb65 (diff)
* dln.c: avoid warning of const to non-const convertion.
[ruby-dev:27041] * eval.c, io.c, ruby.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r--dln.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/dln.c b/dln.c
index 6a3f969..33b1f6b 100644
--- a/dln.c
+++ b/dln.c
@@ -1603,7 +1603,7 @@ dln_load(const char *file)
return 0; /* dummy return */
}
-static char *dln_find_1(char *fname, char *path, int exe_flag);
+static char *dln_find_1(const char *fname, const char *path, int exe_flag);
char *
dln_find_exe(const char *fname, const char *path)
@@ -1665,31 +1665,33 @@ conv_to_posix_path(win32, posix, len)
static char fbuf[MAXPATHLEN];
static char *
-dln_find_1(char *fname, char *path, int exe_flag /* non 0 if looking for executable. */)
+dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking for executable. */)
{
- register char *dp;
- register char *ep;
+ register const char *dp;
+ register const char *ep;
register char *bp;
struct stat st;
#ifdef __MACOS__
const char* mac_fullpath;
#endif
- if (!fname) return fname;
- if (fname[0] == '/') return fname;
- if (strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0)
- return fname;
- if (exe_flag && strchr(fname, '/')) return fname;
+#define RETURN_IF(expr) if (expr) return (char *)fname;
+
+ RETURN_IF(!fname);
+ RETURN_IF(fname[0] == '/');
+ RETURN_IF(strncmp("./", fname, 2) == 0 || strncmp("../", fname, 3) == 0);
+ RETURN_IF(exe_flag && strchr(fname, '/'));
#ifdef DOSISH
- if (fname[0] == '\\') return fname;
+ RETURN_IF(fname[0] == '\\');
# ifdef DOSISH_DRIVE_LETTER
- if (strlen(fname) > 2 && fname[1] == ':') return fname;
+ RETURN_IF(strlen(fname) > 2 && fname[1] == ':');
# endif
- if (strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0)
- return fname;
- if (exe_flag && strchr(fname, '\\')) return fname;
+ RETURN_IF(strncmp(".\\", fname, 2) == 0 || strncmp("..\\", fname, 3) == 0);
+ RETURN_IF(exe_flag && strchr(fname, '\\'));
#endif
+#undef RETURN_IF
+
for (dp = path;; dp = ++ep) {
register int l;
int i;