Port to Elk 3.99 and modern C

This commit is contained in:
Lassi Kortela 2023-02-15 14:36:40 +02:00
parent 0d0d0afbfd
commit 861bc7c177
6 changed files with 8 additions and 22 deletions

View File

@ -273,9 +273,9 @@
(loop (read-line))))))
(cond
((string=? delim "##")
(with-output-to-stream '[##]
(with-output-to-stream 'hash-hash
(copy-exec ".##\n" "inline Scheme execution"))
(let ((p (open-input-string (stream->string '[##]))))
(let ((p (open-input-string (stream->string 'hash-hash))))
(copy-apply (lambda () (read p)) \##-eval)))
((string=? delim ">>")
(copy-exec ".>>\n" "transparent output"))

View File

@ -37,10 +37,7 @@ void fatal_error(char *fmt, ...) {
exit(1);
}
static char *strerr(void) {
extern int sys_nerr;
extern char *sys_errlist[];
static const char *strerr(void) {
return errno > 0 && errno < sys_nerr ?
sys_errlist[errno] : "unknown error";
}

View File

@ -12,9 +12,5 @@ void read_error(char *) NORETURN;
void write_error(char *) NORETURN;
void open_error(char *) NORETURN;
/* Redefined to add NORETURN
*/
extern Primitive_Error() NORETURN;
char *printable_string(char *, int);
char *printable_char(char);

View File

@ -170,7 +170,7 @@ err: *p = 0;
assert(0);
}
}
if (!finite(acc)) {
if (!isfinite(acc)) {
warn("expression evaluates to infinity"); goto err;
}
return acc;

View File

@ -154,7 +154,8 @@ int main(int ac, char **av) {
directory = DEFAULT_DIR;
if ((format = getenv(DEFAULT_FORMAT_ENV)) == 0)
format = DEFAULT_FORMAT;
eav = safe_malloc((ac+1+2) * sizeof(char *)); /* ac + -p xxx + 0-ptr */
/* av[0] "-g", "-p", "xxx", av[1...] NULL */
eav = safe_malloc((ac+3+1) * sizeof(char *));
eav[0] = av[0];
opterr = 0;
while ((c = getopt(ac, av, "h:gm:f:tC")) != EOF) {
@ -180,6 +181,7 @@ int main(int ac, char **av) {
return 1;
}
}
eav[eac++] = "-g"; /* We need symbols to be case-sensitive. */
/* Set the Elk load-path to $(directory)/elk, so that a minimal,
* self-contained Elk runtime environment can be shipped with
* binary distributions. Sites with a full Elk can symlink

View File

@ -26,18 +26,9 @@ extern long strtol(const char *s, char **endp, int base);
extern double strtod(const char *s, char **endp);
extern int pclose(FILE *);
extern int system(const char *);
#ifndef tolower
extern int tolower(int);
#endif
/* Prototypes for IEEE FP functions that may be missing:
*/
#ifndef finite
extern int finite(double);
#endif
#include "scheme.h"
#include <elk/scheme.h>
/* Prototypes that were missing from "scheme.h" in some Elk releases:
*/