aboutsummaryrefslogtreecommitdiffstats
path: root/scm.c
diff options
context:
space:
mode:
Diffstat (limited to 'scm.c')
-rwxr-xr-x[-rw-r--r--]scm.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/scm.c b/scm.c
index f226db1..5c0f8e1 100644..100755
--- a/scm.c
+++ b/scm.c
@@ -166,7 +166,7 @@ void process_signals()
/* printf("process_signals; output_deferred=%d\n", output_deferred); fflush(stdout); */
if (output_deferred) {
output_deferred = 0;
- /* if (NIMP(sys_errp) && OPOUTPORTP(sys_errp)) lfflush(sys_errp); */
+ if (NIMP(sys_errp) && OPOUTPORTP(sys_errp)) lfflush(sys_errp);
}
for (n = 0; SIG_deferred && n < NUM_SIGNALS; n++) {
if (SIG_deferred & mask) {
@@ -544,6 +544,8 @@ static void init_sig1(scm_err, signo, handler)
void init_signals()
{
#ifdef WINSIGNALS
+ /* Added to allow gcc -O2 to work. */
+ volatile unsigned long dont_optimize_me = (unsigned long)scmable_signal;
init_sig1(INT_SIGNAL, SIGINT, win32_sigint);
#else
# ifdef SIGINT
@@ -861,6 +863,7 @@ SCM scm_execpath(newpath)
strncpy(execpath, CHARS(newpath), LENGTH(newpath) + 1);
return retval;
}
+/* Return 0 if getcwd() returns 0. */
char *scm_find_execpath(argc, argv, script_arg)
int argc;
const char * const *argv;
@@ -916,12 +919,26 @@ SCM lsystem(cmd)
}
#endif
+extern char **environ; /* The Linux man page says this
+ declaration is necessary. */
char s_getenv[] = "getenv";
char *getenv();
-SCM lgetenv(nam)
+SCM scm_getenv(nam)
SCM nam;
{
char *val;
+ if (UNBNDP(nam)) {
+ char **nvrnmnt = environ;
+ SCM lst = EOL;
+ do {
+ char *eql = strchr(*nvrnmnt, '=');
+ ASRTER(eql, makfrom0str(*nvrnmnt), "Bad environ", s_getenv);
+ lst = cons(cons(makfromstr(*nvrnmnt, eql - *nvrnmnt),
+ makfrom0str(eql + 1)),
+ lst);
+ } while (*++nvrnmnt);
+ return lst;
+ }
ASRTER(NIMP(nam) && STRINGP(nam), nam, ARG1, s_getenv);
val = getenv(CHARS(nam));
if (!val) return BOOL_F;
@@ -968,7 +985,6 @@ static iproc subr0s[] = {
#endif
{0, 0}};
static iproc subr1s[] = {
- {s_getenv, lgetenv},
#ifndef _Windows
{s_system, lsystem},
#endif
@@ -1002,6 +1018,7 @@ void init_features()
init_iprocs(subr0s, tc7_subr_0);
init_iprocs(subr1s, tc7_subr_1);
make_subr(s_execpath, tc7_subr_1o, scm_execpath);
+ make_subr(s_getenv, tc7_subr_1o, scm_getenv);
#ifdef SIGALRM
# ifdef SIGPROF
make_subr(s_setitimer, tc7_subr_3, scm_setitimer);