From f4d6756fc009a3d52c65c8df6425eaca568cc987 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Sat, 26 Oct 2019 08:53:42 +0200 Subject: [PATCH] core: Prepare for M2-Planet: if (foo). Rewrite C-constructs not supported by M2-Planet if (foo) -> if (foo != 0) * src/posix.c: Rewrite C-constructs not supported by M2-Planet. (current_input_port): Likewise. * src/display.c (display_helper): : Likewise. * src/eval-apply.c (expand_variable_): : Likewise. (eval_apply): : Likewise. * src/mes.c (open_boot): : Likewise. * src/reader.c (reader_read_identifier_or_number): : Likewise. * src/symbols.c (init_symbol): : Likewise. --- src/display.c | 2 +- src/eval-apply.c | 6 +++--- src/mes.c | 6 +++--- src/posix.c | 2 +- src/reader.c | 2 +- src/symbol.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/display.c b/src/display.c index c2597902..cce570d3 100644 --- a/src/display.c +++ b/src/display.c @@ -115,7 +115,7 @@ display_helper (SCM x, int cont, char *sep, int fd, int write_p) { if (write_p == 0) fdputc (VALUE (x), fd); - else if (1) + else { fdputs ("#", fd); fdwrite_char (VALUE (x), fd); diff --git a/src/eval-apply.c b/src/eval-apply.c index c8ffb08a..0b9e8960 100644 --- a/src/eval-apply.c +++ b/src/eval-apply.c @@ -259,7 +259,7 @@ expand_variable_ (SCM x, SCM formals, int top_p) /*:((internal)) */ else if (a == cell_symbol_define || a == cell_symbol_define_macro) { SCM f = CADR (x); - if (top_p && TYPE (f) == TPAIR) + if (top_p != 0 && TYPE (f) == TPAIR) f = CDR (f); formals = add_formals (formals, f); x = CDR (x); @@ -270,7 +270,7 @@ expand_variable_ (SCM x, SCM formals, int top_p) /*:((internal)) */ && a != cell_symbol_boot_module && a != cell_symbol_current_module && a != cell_symbol_primitive_load - && formal_p (a, formals)) + && formal_p (CAR (x), formals) == 0) { SCM v = module_variable (R0, a); if (v != cell_f) @@ -671,7 +671,7 @@ eval: formals = CDADR (R1); body = CDDR (R1); - if (macro_p || global_p) + if (macro_p != 0 || global_p != 0) expand_variable (body, formals); R1 = cons (cell_symbol_lambda, cons (formals, body)); push_cc (R1, R2, p, cell_vm_eval_define); diff --git a/src/mes.c b/src/mes.c index b929fc3b..317f4bfb 100644 --- a/src/mes.c +++ b/src/mes.c @@ -372,11 +372,11 @@ open_boot () char *boot = __open_boot_buf; char *file_name = __open_boot_file_name; strcpy (g_datadir, "."); - if (getenv ("MES_BOOT")) + if (getenv ("MES_BOOT") != 0) strcpy (boot, getenv ("MES_BOOT")); else strcpy (boot, "boot-0.scm"); - if (getenv ("MES_PREFIX")) + if (getenv ("MES_PREFIX") != 0) { strcpy (g_datadir, getenv ("MES_PREFIX")); strcpy (g_datadir + strlen (g_datadir), "/mes"); @@ -395,7 +395,7 @@ open_boot () if (__stdin < 0) { g_datadir[0] = 0; - if (getenv ("srcdest")) + if (getenv ("srcdest") != 0) strcpy (g_datadir, getenv ("srcdest")); strcpy (g_datadir + strlen (g_datadir), "mes"); strcpy (file_name, g_datadir); diff --git a/src/posix.c b/src/posix.c index 69f47115..8b2ff9c8 100644 --- a/src/posix.c +++ b/src/posix.c @@ -197,7 +197,7 @@ current_input_port () if (__stdin >= 0) return make_number (__stdin); SCM x = g_ports; - while (x) + while (x != 0) { SCM a = CAR (x); if (PORT (a) == __stdin) diff --git a/src/reader.c b/src/reader.c index 1722f031..da0a66e8 100644 --- a/src/reader.c +++ b/src/reader.c @@ -91,7 +91,7 @@ reader_read_identifier_or_number (int c) n = n + c - '0'; c = readchar (); } - if (reader_end_of_word_p (c)) + if (reader_end_of_word_p (c) != 0) { unreadchar (c); if (negative_p != 0) diff --git a/src/symbol.c b/src/symbol.c index b69321b7..e420f4e8 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -43,7 +43,7 @@ SCM init_symbol (SCM x, long type, char const *name) { TYPE (x) = type; - if (!g_symbols) + if (g_symbols == 0) g_free = g_free + M2_CELL_SIZE; else {