summaryrefslogtreecommitdiffstats
path: root/ioext.c
diff options
context:
space:
mode:
Diffstat (limited to 'ioext.c')
-rw-r--r--ioext.c68
1 files changed, 40 insertions, 28 deletions
diff --git a/ioext.c b/ioext.c
index c653970..4e0002d 100644
--- a/ioext.c
+++ b/ioext.c
@@ -48,12 +48,13 @@
# include <sys/types.h>
#endif
-#ifndef THINK_C
+#ifndef macintosh
# ifdef vms
# include <stat.h>
# else
# include <sys/stat.h>
-# endif
+#endif
+
# ifdef __TURBOC__
# include <io.h>
# endif
@@ -74,6 +75,9 @@ SCM stat2scm P((struct stat *stat_temp));
# include <sys/types.h>
# include <unistd.h>
#endif
+#ifdef linux
+# include <unistd.h>
+#endif
#ifndef STDC_HEADERS
int chdir P((const char *path));
@@ -124,6 +128,7 @@ SCM read_line(port)
switch (c) {
case LINE_INCREMENTORS:
case EOF:
+ if (j>0 && '\r'==p[j-1]) j--;
if (len==j) return tok_buf;
return resizuve(tok_buf, (SCM)MAKINUM(j));
default:
@@ -222,7 +227,7 @@ SCM reopen_file(filename, modes, port)
}
#ifndef MCH_AMIGA
-
+# ifndef macintosh
static char s_dup[]="duplicate-port";
SCM l_dup(oldpt, modes)
SCM oldpt, modes;
@@ -262,6 +267,7 @@ SCM l_dup2(into_pt, from_pt)
ALLOW_INTS;
return into_pt;
}
+# endif
# ifndef vms
# ifndef _WIN32
@@ -293,7 +299,7 @@ SCM l_readdir(port)
if (!rdent) {ALLOW_INTS; return BOOL_F;}
ALLOW_INTS;
/* rdent could be overwritten by another readdir to the same handle */
- return makfrom0str(rdent->d_name);
+ return makfrom0str((char *)rdent->d_name);
}
static char s_rewinddir[]="rewinddir";
SCM l_rewinddir(port)
@@ -396,6 +402,7 @@ SCM l_getcwd()
# endif
}
+# ifndef __MWERKS__
static char s_chmod[] = "chmod";
SCM l_chmod(pathname, mode)
SCM pathname, mode;
@@ -406,6 +413,7 @@ SCM l_chmod(pathname, mode)
SYSCALL(val = chmod(CHARS(pathname), INUM(mode)););
return val ? BOOL_F : BOOL_T;
}
+# endif
# ifndef vms
# ifdef __EMX__
@@ -431,6 +439,7 @@ SCM l_utime(pathname, acctime, modtime)
}
# endif /* vms */
+# ifndef __MWERKS__
static char s_umask[] = "umask";
SCM l_umask(mode)
SCM mode;
@@ -438,6 +447,7 @@ SCM l_umask(mode)
ASSERT(INUMP(mode), mode, ARG1, s_umask);
return MAKINUM(umask(INUM(mode)));
}
+# endif
# endif /* MCH_AMIGA */
#endif /* THINK_C */
@@ -448,7 +458,7 @@ SCM ren_fil(oldname, newname)
SCM ans;
ASSERT(NIMP(oldname) && STRINGP(oldname), oldname, ARG1, s_ren_fil);
ASSERT(NIMP(newname) && STRINGP(newname), newname, ARG2, s_ren_fil);
-#ifdef STDC_HEADERS
+#if 1 /* def STDC_HEADERS */
SYSCALL(ans = (rename(CHARS(oldname), CHARS(newname))) ? BOOL_F: BOOL_T;);
return ans;
#else
@@ -471,20 +481,14 @@ SCM l_fileno(port)
if (tc16_fport != TYP16(port)) return BOOL_F;
return MAKINUM(fileno(STREAM(port)));
}
-static char s_isatty[] = "isatty?";
-SCM l_isatty(port)
- SCM port;
-{
- ASSERT(NIMP(port) && OPPORTP(port), port, ARG1, s_isatty);
- if (tc16_fport != TYP16(port)) return BOOL_F;
- return isatty(fileno(STREAM(port)))?BOOL_T:BOOL_F;
-}
-#ifndef F_OK
-# define F_OK 00
-# define X_OK 01
-# define W_OK 02
-# define R_OK 04
-#endif
+#ifndef THINK_C
+# ifndef __MWERKS__
+# ifndef F_OK
+# define F_OK 00
+# define X_OK 01
+# define W_OK 02
+# define R_OK 04
+# endif
static char s_access[] = "access";
SCM l_access(pathname, mode)
SCM pathname, mode;
@@ -502,8 +506,9 @@ SCM l_access(pathname, mode)
SYSCALL(val = access(CHARS(pathname), imodes););
return val ? BOOL_F : BOOL_T;
}
+# endif /* __MWERKS__ */
-#ifndef THINK_C
+SCM stat2scm P((struct stat *stat_temp));
char s_stat[] = "stat";
SCM l_stat(str)
@@ -563,10 +568,10 @@ SCM l_getpid()
return MAKINUM((unsigned long)getpid());
}
# endif /* MCH_AMIGA */
-#endif /* THINK_C */
+#endif /* THINK_C */
#ifndef __IBMC__
-# ifndef THINK_C
+# ifndef macintosh
# ifndef __WATCOMC__
# ifndef GO32
# ifndef _Windows
@@ -587,8 +592,10 @@ SCM i_execv(modes, path, args)
args = cons(path, args);
DEFER_INTS;
execargv = makargvfrmstrs(args, s_execv);
- ALLOW_INTS;
+ ignore_signals();
(strchr(modes, 'p') ? execvp : execv)(execargv[0], &execargv[1]);
+ unignore_signals();
+ ALLOW_INTS;
perror(execargv[0]);
return MAKINUM(errno);
}
@@ -628,7 +635,6 @@ SCM l_putenv(str)
static iproc subr1s[] = {
{s_file_position, file_position},
{s_fileno, l_fileno},
- {s_isatty, l_isatty},
#ifndef MCH_AMIGA
# ifndef vms
# ifndef _WIN32
@@ -642,10 +648,12 @@ static iproc subr1s[] = {
#endif
#ifndef THINK_C
# ifndef MCH_AMIGA
+# ifndef __MWERKS__
{s_umask, l_umask},
+# endif
# endif
- {s_chdir, lchdir},
{s_stat, l_stat},
+ {s_chdir, lchdir},
#endif
{0, 0}};
@@ -655,12 +663,14 @@ static iproc subr1os[] = {
static iproc subr2s[] = {
{s_ren_fil, ren_fil},
+#ifndef macintosh
{s_access, l_access},
+#endif
#ifndef MCH_AMIGA
+ {s_mkdir, l_mkdir},
+# ifndef macintosh
{s_dup, l_dup},
{s_dup2, l_dup2},
- {s_mkdir, l_mkdir},
-# ifndef THINK_C
{s_chmod, l_chmod},
# endif
#endif
@@ -681,7 +691,9 @@ void init_ioext()
make_subr(s_reopen_file, tc7_subr_3, reopen_file);
#ifndef THINK_C
# ifndef MCH_AMIGA
+# ifndef __MWERKS__
make_subr("getpid", tc7_subr_0, l_getpid);
+# endif
make_subr("getcwd", tc7_subr_0, l_getcwd);
# ifndef vms
# ifndef _WIN32
@@ -692,7 +704,7 @@ void init_ioext()
# endif
#endif
#ifndef __IBMC__
-# ifndef THINK_C
+# ifndef macintosh
# ifndef __WATCOMC__
# ifndef GO32
# ifndef _Windows