From 2f2a05798db85432f4b6dd4856c1a97195c0696f Mon Sep 17 00:00:00 2001 From: jjgarcia Date: Mon, 18 Nov 2002 11:31:53 +0000 Subject: [PATCH] Replace static C variable sharp_eq_context with special lisp variable si::*sharp-eq-context* --- src/c/lwp.d | 1 - src/c/read.d | 51 +++++++++++++++++++------------------------- src/c/symbols_list.h | 1 + src/h/external.h | 1 - 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/src/c/lwp.d b/src/c/lwp.d index 1c9f8b92b..844e9ba15 100644 --- a/src/c/lwp.d +++ b/src/c/lwp.d @@ -136,7 +136,6 @@ make_pd() npd->lwp_detect_eos_flag = FALSE; npd->lwp_in_list_flag = FALSE; npd->lwp_dot_flag = FALSE; - npd->lwp_sharp_eq_context_max = 0; /* for gc */ npd->lwp_token = OBJNULL; diff --git a/src/c/read.d b/src/c/read.d index b74470602..2d3241a4a 100644 --- a/src/c/read.d +++ b/src/c/read.d @@ -32,7 +32,6 @@ bool preserving_whitespace_flag; bool escape_flag; cl_object delimiting_char; bool detect_eos_flag; -cl_object sharp_eq_context; #endif /* THREADS */ /******************************* ------- ******************************/ @@ -81,20 +80,15 @@ static cl_object patch_sharp(cl_object x); cl_object read_object_non_recursive(cl_object in) { - volatile cl_object x; - cl_object old_sharp_eq_context; + cl_object x; - old_sharp_eq_context = sharp_eq_context; - CL_UNWIND_PROTECT_BEGIN { - bds_bind(@'si::*backq-level*', MAKE_FIXNUM(0)); - sharp_eq_context = Cnil; - x = read_object(in); - if (!Null(sharp_eq_context)) - x = patch_sharp(x); - bds_unwind1; - } CL_UNWIND_PROTECT_EXIT { - sharp_eq_context = old_sharp_eq_context; - } CL_UNWIND_PROTECT_END; + bds_bind(@'si::*sharp-eq-context*', Cnil); + bds_bind(@'si::*backq-level*', MAKE_FIXNUM(0)); + x = read_object(in); + if (!Null(SYM_VAL(@'si::*sharp-eq-context*'))) + x = patch_sharp(x); + bds_unwind1; + bds_unwind1; return(x); } @@ -1047,6 +1041,7 @@ static cl_object sharp_eq_reader(cl_object in, cl_object c, cl_object d) { cl_object pair, value; + cl_object sharp_eq_context = SYM_VAL(@'si::*sharp-eq-context*'); if (read_suppress) @(return) if (Null(d)) @@ -1054,7 +1049,7 @@ sharp_eq_reader(cl_object in, cl_object c, cl_object d) if (assql(d, sharp_eq_context) != Cnil) FEerror("Duplicate definitions for #~D=.", 1, d); pair = CONS(d, Cnil); - sharp_eq_context = CONS(pair, sharp_eq_context); + SYM_VAL(@'si::*sharp-eq-context*') = CONS(pair, sharp_eq_context); value = read_object(in); if (value == pair) FEerror("#~D# is defined by itself.", 1, d); @@ -1069,7 +1064,7 @@ sharp_sharp_reader(cl_object in, cl_object c, cl_object d) if (read_suppress) @(return) if (Null(d)) FEerror("The ## readmacro requires an argument.", 0); - pair = assq(d, sharp_eq_context); + pair = assq(d, SYM_VAL(@'si::*sharp-eq-context*')); if (pair != Cnil) @(return pair) FEerror("#~D# is undefined.", 1, d); @@ -1119,7 +1114,9 @@ do_patch_sharp(cl_object x) static cl_object patch_sharp(cl_object x) { - cl_object pair = sharp_eq_context; + cl_object pair, sharp_eq_context = SYM_VAL(@'si::*sharp-eq-context*'); + + pair = sharp_eq_context; loop_for_in(pair) { CAAR(pair) = OBJNULL; } end_loop_for_in; @@ -1389,17 +1386,13 @@ do_read_delimited_list(cl_object d, cl_object strm) if (Null(recursivep)) l = do_read_delimited_list(d, strm); else { - volatile cl_object old_sharp_eq_context = sharp_eq_context; - CL_UNWIND_PROTECT_BEGIN { - bds_bind(@'si::*backq-level*', MAKE_FIXNUM(0)); - sharp_eq_context = Cnil; - l = do_read_delimited_list(d, strm); - if (!Null(sharp_eq_context)) - l = patch_sharp(l); - bds_unwind1; - } CL_UNWIND_PROTECT_EXIT { - sharp_eq_context = old_sharp_eq_context; - } CL_UNWIND_PROTECT_END; + bds_bind(@'si::*sharp-eq-context*', Cnil); + bds_bind(@'si::*backq-level*', MAKE_FIXNUM(0)); + l = do_read_delimited_list(d, strm); + if (!Null(SYM_VAL(@'si::*sharp-eq-context*'))) + l = patch_sharp(l); + bds_unwind1; + bds_unwind1; } @(return l) @) @@ -1897,7 +1890,7 @@ init_read(void) SYM_VAL(@'*read_base*') = MAKE_FIXNUM(10); SYM_VAL(@'*read_suppress*') = Cnil; - sharp_eq_context = Cnil; + SYM_VAL(@'si::*sharp-eq-context*') = Cnil; delimiting_char = OBJNULL; register_root(&delimiting_char); diff --git a/src/c/symbols_list.h b/src/c/symbols_list.h index b005c6df4..50017c568 100644 --- a/src/c/symbols_list.h +++ b/src/c/symbols_list.h @@ -929,6 +929,7 @@ cl_symbols[] = { {"SI::*MAKE-SPECIAL", SI_ORDINARY, si_Xmake_special, 1}, {"SI::*PRINT-PACKAGE*", SI_SPECIAL, NULL, -1}, {"SI::*PRINT-STRUCTURE*", SI_SPECIAL, NULL, -1}, +{"SI::*SHARP-EQ-CONTEXT*", SI_SPECIAL, NULL, -1}, {"SI::.", SI_ORDINARY, NULL, -1}, {"SI::,", SI_ORDINARY, NULL, -1}, {"SI::,.", SI_ORDINARY, NULL, -1}, diff --git a/src/h/external.h b/src/h/external.h index f5a7d743b..999de93e5 100644 --- a/src/h/external.h +++ b/src/h/external.h @@ -1085,7 +1085,6 @@ extern bool preserving_whitespace_flag; extern bool escape_flag; extern cl_object delimiting_char; extern bool detect_eos_flag; -extern cl_object sharp_eq_context; #endif extern cl_object read_char(cl_object in); extern void unread_char(cl_object c, cl_object in);