Support BEGINLIBPATH, ENDLIBPATH and LIBPATHSTRICT on OS/2
This commit is contained in:
48
os2.c
48
os2.c
@ -18,6 +18,9 @@
|
|||||||
* of said person's immediate fault when using the work as intended.
|
* of said person's immediate fault when using the work as intended.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define INCL_DOS
|
||||||
|
#include <os2.h>
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
#include <klibc/startup.h>
|
#include <klibc/startup.h>
|
||||||
@ -141,6 +144,20 @@ exit_out_of_memory:
|
|||||||
exit(255);
|
exit(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_extlibpath(void)
|
||||||
|
{
|
||||||
|
const char *vars[] = {"BEGINLIBPATH", "ENDLIBPATH", "LIBPATHSTRICT", NULL};
|
||||||
|
char val[512];
|
||||||
|
int flag;
|
||||||
|
|
||||||
|
for (flag = 0; vars[flag]; flag++) {
|
||||||
|
DosQueryExtLIBPATH(val, flag + 1);
|
||||||
|
if (val[0])
|
||||||
|
setenv(vars[flag], val, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert backslashes of environmental variables to forward slahes.
|
* Convert backslashes of environmental variables to forward slahes.
|
||||||
* A backslash may be used as an escaped character when do 'echo'. This leads
|
* A backslash may be used as an escaped character when do 'echo'. This leads
|
||||||
@ -152,8 +169,10 @@ env_slashify(void)
|
|||||||
/*
|
/*
|
||||||
* PATH and TMPDIR are used by OS/2 as well. That is, they may have
|
* PATH and TMPDIR are used by OS/2 as well. That is, they may have
|
||||||
* backslashes as a directory separator.
|
* backslashes as a directory separator.
|
||||||
|
* BEGINLIBPATH and ENDLIBPATH are special variables on OS/2.
|
||||||
*/
|
*/
|
||||||
const char *var_list[] = {"PATH", "TMPDIR", NULL};
|
const char *var_list[] = {"PATH", "TMPDIR",
|
||||||
|
"BEGINLIBPATH", "ENDLIBPATH", NULL};
|
||||||
const char **var;
|
const char **var;
|
||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
@ -169,6 +188,7 @@ void os2_init(int *argcp, const char ***argvp)
|
|||||||
{
|
{
|
||||||
response(argcp, argvp);
|
response(argcp, argvp);
|
||||||
|
|
||||||
|
init_extlibpath();
|
||||||
env_slashify();
|
env_slashify();
|
||||||
|
|
||||||
setmode(STDIN_FILENO, O_TEXT);
|
setmode(STDIN_FILENO, O_TEXT);
|
||||||
@ -180,6 +200,32 @@ void os2_init(int *argcp, const char ***argvp)
|
|||||||
atexit(cleanup);
|
atexit(cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setextlibpath(const char *name, const char *val)
|
||||||
|
{
|
||||||
|
int flag;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if (!strcmp(name, "BEGINLIBPATH"))
|
||||||
|
flag = BEGIN_LIBPATH;
|
||||||
|
else if (!strcmp(name, "ENDLIBPATH"))
|
||||||
|
flag = END_LIBPATH;
|
||||||
|
else if (!strcmp(name, "LIBPATHSTRICT"))
|
||||||
|
flag = LIBPATHSTRICT;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Convert slashes to backslashes. */
|
||||||
|
strdupx(p, val, ATEMP);
|
||||||
|
for (val = p; *p; p++) {
|
||||||
|
if (*p == '/')
|
||||||
|
*p = '\\';
|
||||||
|
}
|
||||||
|
|
||||||
|
DosSetExtLIBPATH(val, flag);
|
||||||
|
|
||||||
|
afree((char *)val, ATEMP);
|
||||||
|
}
|
||||||
|
|
||||||
/* Remove trailing dots. */
|
/* Remove trailing dots. */
|
||||||
static char *
|
static char *
|
||||||
remove_trailing_dots(char *name)
|
remove_trailing_dots(char *name)
|
||||||
|
1
sh.h
1
sh.h
@ -1954,6 +1954,7 @@ int unbksl(bool, int (*)(void), void (*)(int));
|
|||||||
#ifdef __OS2__
|
#ifdef __OS2__
|
||||||
/* os2.c */
|
/* os2.c */
|
||||||
void os2_init(int *, const char ***);
|
void os2_init(int *, const char ***);
|
||||||
|
void setextlibpath(const char *, const char *);
|
||||||
int access_ex(int (*)(const char *, int), const char *, int);
|
int access_ex(int (*)(const char *, int), const char *, int);
|
||||||
int stat_ex(const char *, struct stat *);
|
int stat_ex(const char *, struct stat *);
|
||||||
const char *real_exec_name(const char *);
|
const char *real_exec_name(const char *);
|
||||||
|
10
var.c
10
var.c
@ -698,6 +698,11 @@ exportprep(struct tbl *vp, const char *val)
|
|||||||
char *op = (vp->flag&ALLOC) ? vp->val.s : NULL;
|
char *op = (vp->flag&ALLOC) ? vp->val.s : NULL;
|
||||||
size_t namelen, vallen;
|
size_t namelen, vallen;
|
||||||
|
|
||||||
|
#ifdef __OS2__
|
||||||
|
/* On OS/2, BEGIN/ENDLIBPATH and LIBPATHSTRICT are special variables. */
|
||||||
|
setextlibpath(vp->name, val);
|
||||||
|
#endif
|
||||||
|
|
||||||
namelen = strlen(vp->name);
|
namelen = strlen(vp->name);
|
||||||
vallen = strlen(val) + 1;
|
vallen = strlen(val) + 1;
|
||||||
|
|
||||||
@ -996,6 +1001,11 @@ typeset(const char *var, uint32_t set, uint32_t clr, int field, int base)
|
|||||||
void
|
void
|
||||||
unset(struct tbl *vp, int flags)
|
unset(struct tbl *vp, int flags)
|
||||||
{
|
{
|
||||||
|
#ifdef __OS2__
|
||||||
|
/* On OS/2, BEGIN/ENDLIBPATH and LIBPATHSTRICT are special variables. */
|
||||||
|
setextlibpath(vp->name, "");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (vp->flag & ALLOC)
|
if (vp->flag & ALLOC)
|
||||||
afree(vp->val.s, vp->areap);
|
afree(vp->val.s, vp->areap);
|
||||||
if ((vp->flag & ARRAY) && (flags & 1)) {
|
if ((vp->flag & ARRAY) && (flags & 1)) {
|
||||||
|
Reference in New Issue
Block a user