move slashifying of PATH, TMPDIR and two OS/2-specific variables from
OS/2-specific to common DOSPATH-specific code (ifdef for the latter two) also gets us rid of the use of getenv
This commit is contained in:
parent
524e63b4a1
commit
5468d726b3
35
os2.c
35
os2.c
|
@ -31,14 +31,13 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/os2.c,v 1.5 2017/10/13 11:54:06 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/os2.c,v 1.6 2017/10/13 23:34:49 tg Exp $");
|
||||||
|
|
||||||
static char *remove_trailing_dots(char *);
|
static char *remove_trailing_dots(char *);
|
||||||
static int access_stat_ex(int (*)(), const char *, void *);
|
static int access_stat_ex(int (*)(), const char *, void *);
|
||||||
static int test_exec_exist(const char *, char *);
|
static int test_exec_exist(const char *, char *);
|
||||||
static void response(int *, const char ***);
|
static void response(int *, const char ***);
|
||||||
static char *make_response_file(char * const *);
|
static char *make_response_file(char * const *);
|
||||||
static void env_slashify(void);
|
|
||||||
static void add_temp(const char *);
|
static void add_temp(const char *);
|
||||||
static void cleanup_temps(void);
|
static void cleanup_temps(void);
|
||||||
static void cleanup(void);
|
static void cleanup(void);
|
||||||
|
@ -170,44 +169,12 @@ init_extlibpath(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Convert backslashes of environmental variables to forward slahes.
|
|
||||||
* A backslash may be used as an escaped character when doing 'echo'.
|
|
||||||
* This leads to an unexpected behavior.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
env_slashify(void)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* PATH and TMPDIR are used by OS/2 as well. That is, they may
|
|
||||||
* have backslashes as a directory separator.
|
|
||||||
* BEGINLIBPATH and ENDLIBPATH are special variables on OS/2.
|
|
||||||
*/
|
|
||||||
const char *var_list[] = {
|
|
||||||
"PATH",
|
|
||||||
"TMPDIR",
|
|
||||||
"BEGINLIBPATH",
|
|
||||||
"ENDLIBPATH",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
const char **var;
|
|
||||||
char *value;
|
|
||||||
|
|
||||||
for (var = var_list; *var; var++) {
|
|
||||||
value = getenv(*var);
|
|
||||||
|
|
||||||
if (value)
|
|
||||||
_fnslashify(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
os2_init(int *argcp, const char ***argvp)
|
os2_init(int *argcp, const char ***argvp)
|
||||||
{
|
{
|
||||||
response(argcp, argvp);
|
response(argcp, argvp);
|
||||||
|
|
||||||
init_extlibpath();
|
init_extlibpath();
|
||||||
env_slashify();
|
|
||||||
|
|
||||||
if (!isatty(STDIN_FILENO))
|
if (!isatty(STDIN_FILENO))
|
||||||
setmode(STDIN_FILENO, O_BINARY);
|
setmode(STDIN_FILENO, O_BINARY);
|
||||||
|
|
26
var.c
26
var.c
|
@ -28,7 +28,7 @@
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.220 2017/07/26 23:02:28 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.221 2017/10/13 23:34:49 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Variables
|
* Variables
|
||||||
|
@ -1294,9 +1294,29 @@ setspec(struct tbl *vp)
|
||||||
{
|
{
|
||||||
mksh_ari_u num;
|
mksh_ari_u num;
|
||||||
char *s;
|
char *s;
|
||||||
int st;
|
int st = special(vp->name);
|
||||||
|
|
||||||
switch ((st = special(vp->name))) {
|
#ifdef MKSH_DOSPATH
|
||||||
|
switch (st) {
|
||||||
|
case V_PATH:
|
||||||
|
case V_TMPDIR:
|
||||||
|
#ifdef __OS2__
|
||||||
|
case V_BEGINLIBPATH:
|
||||||
|
case V_ENDLIBPATH:
|
||||||
|
#endif
|
||||||
|
/* convert backslashes to slashes for convenience */
|
||||||
|
if (!(vp->flag&INTEGER)) {
|
||||||
|
s = str_val(vp);
|
||||||
|
do {
|
||||||
|
if (*s == ord('\\'))
|
||||||
|
*s = '/';
|
||||||
|
} while (*s++);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (st) {
|
||||||
#ifdef __OS2__
|
#ifdef __OS2__
|
||||||
case V_BEGINLIBPATH:
|
case V_BEGINLIBPATH:
|
||||||
case V_ENDLIBPATH:
|
case V_ENDLIBPATH:
|
||||||
|
|
Loading…
Reference in New Issue