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.
This commit is contained in:
Jan Nieuwenhuizen 2019-10-26 08:53:42 +02:00
parent 04126ad14a
commit 69cff15c1b
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
6 changed files with 10 additions and 10 deletions

View File

@ -115,7 +115,7 @@ display_helper (SCM x, int cont, char *sep, int fd, int write_p)
{ {
if (write_p == 0) if (write_p == 0)
fdputc (VALUE (x), fd); fdputc (VALUE (x), fd);
else if (1) else
{ {
fdputs ("#", fd); fdputs ("#", fd);
fdwrite_char (VALUE (x), fd); fdwrite_char (VALUE (x), fd);

View File

@ -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) else if (a == cell_symbol_define || a == cell_symbol_define_macro)
{ {
SCM f = CADR (x); SCM f = CADR (x);
if (top_p && TYPE (f) == TPAIR) if (top_p != 0 && TYPE (f) == TPAIR)
f = CDR (f); f = CDR (f);
formals = add_formals (formals, f); formals = add_formals (formals, f);
x = CDR (x); 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_boot_module
&& a != cell_symbol_current_module && a != cell_symbol_current_module
&& a != cell_symbol_primitive_load && a != cell_symbol_primitive_load
&& formal_p (a, formals)) && formal_p (CAR (x), formals) == 0)
{ {
SCM v = module_variable (R0, a); SCM v = module_variable (R0, a);
if (v != cell_f) if (v != cell_f)
@ -671,7 +671,7 @@ eval:
formals = CDADR (R1); formals = CDADR (R1);
body = CDDR (R1); body = CDDR (R1);
if (macro_p || global_p) if (macro_p != 0 || global_p != 0)
expand_variable (body, formals); expand_variable (body, formals);
R1 = cons (cell_symbol_lambda, cons (formals, body)); R1 = cons (cell_symbol_lambda, cons (formals, body));
push_cc (R1, R2, p, cell_vm_eval_define); push_cc (R1, R2, p, cell_vm_eval_define);

View File

@ -378,11 +378,11 @@ open_boot ()
eputs (MES_PKGDATADIR); eputs (MES_PKGDATADIR);
eputs ("\n"); eputs ("\n");
} }
if (getenv ("MES_BOOT")) if (getenv ("MES_BOOT") != 0)
strcpy (boot, getenv ("MES_BOOT")); strcpy (boot, getenv ("MES_BOOT"));
else else
strcpy (boot, "boot-0.scm"); strcpy (boot, "boot-0.scm");
if (getenv ("MES_PREFIX")) if (getenv ("MES_PREFIX") != 0)
{ {
strcpy (g_datadir, getenv ("MES_PREFIX")); strcpy (g_datadir, getenv ("MES_PREFIX"));
strcpy (g_datadir + strlen (g_datadir), "/mes"); strcpy (g_datadir + strlen (g_datadir), "/mes");
@ -408,7 +408,7 @@ open_boot ()
if (__stdin < 0) if (__stdin < 0)
{ {
g_datadir[0] = 0; g_datadir[0] = 0;
if (getenv ("srcdest")) if (getenv ("srcdest") != 0)
strcpy (g_datadir, getenv ("srcdest")); strcpy (g_datadir, getenv ("srcdest"));
strcpy (g_datadir + strlen (g_datadir), "mes"); strcpy (g_datadir + strlen (g_datadir), "mes");
strcpy (file_name, g_datadir); strcpy (file_name, g_datadir);

View File

@ -193,7 +193,7 @@ current_input_port ()
if (__stdin >= 0) if (__stdin >= 0)
return make_number (__stdin); return make_number (__stdin);
SCM x = g_ports; SCM x = g_ports;
while (x) while (x != 0)
{ {
SCM a = CAR (x); SCM a = CAR (x);
if (PORT (a) == __stdin) if (PORT (a) == __stdin)

View File

@ -91,7 +91,7 @@ reader_read_identifier_or_number (int c)
n = n + c - '0'; n = n + c - '0';
c = readchar (); c = readchar ();
} }
if (reader_end_of_word_p (c)) if (reader_end_of_word_p (c) != 0)
{ {
unreadchar (c); unreadchar (c);
if (negative_p != 0) if (negative_p != 0)

View File

@ -43,7 +43,7 @@ SCM
init_symbol (SCM x, long type, char const *name) init_symbol (SCM x, long type, char const *name)
{ {
TYPE (x) = type; TYPE (x) = type;
if (!g_symbols) if (g_symbols == 0)
g_free = g_free + M2_CELL_SIZE; g_free = g_free + M2_CELL_SIZE;
else else
{ {