diff --git a/ChangeLog b/ChangeLog index 8fda9460f0..28a3e08176 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -Sun Jun 30 10:57:13 2013 Nobuyoshi Nakada +Sun Jun 30 10:58:47 2013 Nobuyoshi Nakada + + * dln.h (DLN_FIND_EXTRA_ARG, DLN_FIND_EXTRA_ARG_DECL): allow extra + arguments to dln_find_{exe,file}_r(). + + * dln_find.c (dln_find_exe_r, dln_find_file_r): add extract arguments. * process.c (EXPORT_STR, EXPORT_DUP): convert to default process encoding if defined. diff --git a/dln.h b/dln.h index 762517113f..d98b2607e2 100644 --- a/dln.h +++ b/dln.h @@ -30,8 +30,15 @@ RUBY_SYMBOL_EXPORT_BEGIN -char *dln_find_exe_r(const char*,const char*,char*,size_t); -char *dln_find_file_r(const char*,const char*,char*,size_t); +#ifndef DLN_FIND_EXTRA_ARG +#define DLN_FIND_EXTRA_ARG +#endif +#ifndef DLN_FIND_EXTRA_ARG_DECL +#define DLN_FIND_EXTRA_ARG_DECL +#endif + +char *dln_find_exe_r(const char*,const char*,char*,size_t DLN_FIND_EXTRA_ARG_DECL); +char *dln_find_file_r(const char*,const char*,char*,size_t DLN_FIND_EXTRA_ARG_DECL); #ifdef USE_DLN_A_OUT extern char *dln_argv0; diff --git a/dln_find.c b/dln_find.c index 3160235b74..f41ceb051d 100644 --- a/dln_find.c +++ b/dln_find.c @@ -63,10 +63,12 @@ char *dln_argv0; char *getenv(); #endif -static char *dln_find_1(const char *fname, const char *path, char *buf, size_t size, int exe_flag); +static char *dln_find_1(const char *fname, const char *path, char *buf, size_t size, int exe_flag + DLN_FIND_EXTRA_ARG_DECL); char * -dln_find_exe_r(const char *fname, const char *path, char *buf, size_t size) +dln_find_exe_r(const char *fname, const char *path, char *buf, size_t size + DLN_FIND_EXTRA_ARG_DECL) { char *envpath = 0; @@ -82,21 +84,23 @@ dln_find_exe_r(const char *fname, const char *path, char *buf, size_t size) path = "/usr/local/bin:/usr/ucb:/usr/bin:/bin:."; #endif } - buf = dln_find_1(fname, path, buf, size, 1); + buf = dln_find_1(fname, path, buf, size, 1 DLN_FIND_EXTRA_ARG); if (envpath) free(envpath); return buf; } char * -dln_find_file_r(const char *fname, const char *path, char *buf, size_t size) +dln_find_file_r(const char *fname, const char *path, char *buf, size_t size + DLN_FIND_EXTRA_ARG_DECL) { if (!path) path = "."; - return dln_find_1(fname, path, buf, size, 0); + return dln_find_1(fname, path, buf, size, 0 DLN_FIND_EXTRA_ARG); } static char * dln_find_1(const char *fname, const char *path, char *fbuf, size_t size, - int exe_flag /* non 0 if looking for executable. */) + int exe_flag /* non 0 if looking for executable. */ + DLN_FIND_EXTRA_ARG_DECL) { register const char *dp; register const char *ep;