[Winbash-checkins] CVS: winbash nt_execute_cmd.c,1.5,1.6
Brought to you by:
enricobrunetta,
xks
From: kevin s. <xk...@us...> - 2002-03-26 16:06:40
|
Update of /cvsroot/winbash/winbash In directory usw-pr-cvs1:/tmp/cvs-serv27844 Modified Files: nt_execute_cmd.c Log Message: * move initialization of list of suffixes for "executable" files to function * don't reset the list of suffixes to try (to_try) to the default (base_to_try) after it's been initialized. Index: nt_execute_cmd.c =================================================================== RCS file: /cvsroot/winbash/winbash/nt_execute_cmd.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- nt_execute_cmd.c 26 Mar 2002 03:34:34 -0000 1.5 +++ nt_execute_cmd.c 26 Mar 2002 16:06:37 -0000 1.6 @@ -1189,6 +1189,25 @@ static const char *base_to_try[] = {".exe", ".com", ".bat", ".sh", ".pl", 0}; static const char **to_try = 0; +/** + * One-time initialization of list to_try list. + */ +static void +initialize_to_try() +{ + if (!to_try) + { + const char * nt_exe_suf = getenv("NT_BASH_EXE_SUF"); + + if (nt_exe_suf) + to_try = nt_split(nt_exe_suf); + else if (nt_exe_suf = getenv("NT_BASH_EXE_ADD_SUF")) + to_try=nt_add_split(base_to_try, nt_exe_suf); + if (!to_try) + to_try = base_to_try; + } +} + /* Call repeatedly to get all names to try */ /* base = 0 on all but first call */ static const char * @@ -1201,15 +1220,7 @@ if (!to_try) { - const char * nt_exe_suf = getenv("NT_BASH_EXE_SUF"); - - if (nt_exe_suf) - to_try = nt_split(nt_exe_suf); - else if (nt_exe_suf = getenv("NT_BASH_EXE_ADD_SUF")) - to_try=nt_add_split(base_to_try, nt_exe_suf); - if (!to_try) - to_try = base_to_try ; - curr = to_try ; + initialize_to_try(); } if (base) @@ -1219,7 +1230,6 @@ char *pt; curr = to_try; orig = base; - to_try = base_to_try; for (dest = buf, pt = orig; *pt && (length < MAX_PATH_ALLOWED); pt++, length++) { *dest++ = *pt; @@ -1255,15 +1265,9 @@ { if (!to_try) { - const char * nt_exe_suf = getenv("NT_BASH_EXE_SUF"); - - if (nt_exe_suf) - to_try = nt_split(nt_exe_suf); - else if (nt_exe_suf = getenv("NT_BASH_EXE_ADD_SUF")) - to_try=nt_add_split(base_to_try, nt_exe_suf); - if (!to_try) - to_try = base_to_try ; + initialize_to_try(); } + if (file) { int i,len; |