diff options
-rw-r--r-- | cppawk-include/cons-priv.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/cppawk-include/cons-priv.h b/cppawk-include/cons-priv.h index 95c8cee..1e32624 100644 --- a/cppawk-include/cons-priv.h +++ b/cppawk-include/cons-priv.h @@ -172,8 +172,15 @@ function __symbolp(__obj) #define __symbolp(obj) (substr(obj, 1, 1) ~ /^S?$/) function __box(__raw, + __check, __case_temps) { + if (!__present(__raw)) + return "U"; + + if (__present(__check)) + __error("box; excess argument %s", __check) + __case (__typecode(__raw)) { __of ("T", "S", "C") __cret ("T" __raw) // represent as unescaped string @@ -183,17 +190,25 @@ function __box(__raw, } function __unbox(__obj, + __check, __case_temps) { + if (__present(__check)) + __error("unbox; excess argument %s", __check) + __case (__typecode(__obj)) { __of ("T", "S") __cret (substr(__obj, 2)) __of ("C") - __error("unbox: %s looks like a cons", __obj, i) + __error("unbox: %s looks like a cons", __obj) __cbreak + __of ("U") + __cret(__check) __of ("") __cret("nil") __otherwise + if (!__numberp(__obj)) + __error("unbox: %s isn't symbol, number or boxed string", __obj) __cret (__obj) } } @@ -246,6 +261,9 @@ function __cdr(__cell, function __sexp(__obj, __d, __x, __y, __case_temps) { + if (!__present(__obj)) + __error("sexp: missing or undefined argument") + __case (__typecode(__obj)) { __of ("C") __d = __cdr(__obj) @@ -264,6 +282,8 @@ function __sexp(__obj, __cret ("\"" __bs_esc(substr(__obj, 2)) "\"") __of ("S") __cret (__bs_esc(substr(__obj, 2))) + __of ("U") + __cret ("#U") } if (__numberp(__obj)) { |