summaryrefslogtreecommitdiff
path: root/dln.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-07 21:43:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-07 21:43:54 +0000
commit4264ca9436a7b1496dbd6c9ca6e2e043f0c48630 (patch)
tree9c152e1a97a38c069d33785719148e5723278694 /dln.c
parent86afcfe4021d3ee7a9d290f2b351ae9e7aa52021 (diff)
* dln.c (dln_find_exe_r, dln_find_file_r): reentrant versions.
* file.c (rb_find_file_ext, rb_find_file), process.c (proc_exec_v), (rb_proc_exec, proc_spawn_v, proc_spawn), ruby.c (process_options): use reentrant versions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dln.c')
-rw-r--r--dln.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/dln.c b/dln.c
index 33b912d..13f6e29 100644
--- a/dln.c
+++ b/dln.c
@@ -1568,10 +1568,10 @@ dln_load(const char *file)
return 0; /* dummy return */
}
-static char *dln_find_1(const char *fname, const char *path, int exe_flag);
+static char *dln_find_1(const char *fname, const char *path, char *buf, int size, int exe_flag);
char *
-dln_find_exe(const char *fname, const char *path)
+dln_find_exe_r(const char *fname, const char *path, char *buf, int size)
{
if (!path) {
path = getenv(PATH_ENV);
@@ -1584,25 +1584,38 @@ dln_find_exe(const char *fname, const char *path)
path = "/usr/local/bin:/usr/ucb:/usr/bin:/bin:.";
#endif
}
- return dln_find_1(fname, path, 1);
+ return dln_find_1(fname, path, buf, size, 1);
}
char *
-dln_find_file(const char *fname, const char *path)
+dln_find_file_r(const char *fname, const char *path, char *buf, int size)
{
#ifndef __MACOS__
if (!path) path = ".";
- return dln_find_1(fname, path, 0);
+ return dln_find_1(fname, path, buf, size, 0);
#else
if (!path) path = ".";
- return _macruby_path_conv_posix_to_macos(dln_find_1(fname, path, 0));
+ return _macruby_path_conv_posix_to_macos(dln_find_1(fname, path, buf, size, 0));
#endif
}
static char fbuf[MAXPATHLEN];
+char *
+dln_find_exe(const char *fname, const char *path)
+{
+ return dln_find_exe_r(fname, path, fbuf, sizeof(fbuf));
+}
+
+char *
+dln_find_file(const char *fname, const char *path)
+{
+ return dln_find_file_r(fname, path, fbuf, sizeof(fbuf));
+}
+
static char *
-dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking for executable. */)
+dln_find_1(const char *fname, const char *path, char *fbuf, int size,
+ int exe_flag /* non 0 if looking for executable. */)
{
register const char *dp;
register const char *ep;
@@ -1642,7 +1655,7 @@ dln_find_1(const char *fname, const char *path, int exe_flag /* non 0 if looking
/* find the length of that component */
l = ep - dp;
bp = fbuf;
- fspace = sizeof fbuf - 2;
+ fspace = size - 2;
if (l > 0) {
/*
** If the length of the component is zero length,