diff --git a/femtolisp/builtins.c b/femtolisp/builtins.c index 3d457ca..1140fc1 100644 --- a/femtolisp/builtins.c +++ b/femtolisp/builtins.c @@ -127,7 +127,7 @@ static value_t fl_exit(value_t *args, u_int32_t nargs) static value_t fl_symbol(value_t *args, u_int32_t nargs) { argcount("symbol", nargs, 1); - if (!isstring(args[0])) + if (!fl_isstring(args[0])) type_error("symbol", "string", args[0]); return symbol(cvalue_data(args[0])); } diff --git a/femtolisp/cvalues.c b/femtolisp/cvalues.c index ba77688..91b71b8 100644 --- a/femtolisp/cvalues.c +++ b/femtolisp/cvalues.c @@ -220,7 +220,7 @@ value_t string_from_cstr(char *str) return string_from_cstrn(str, strlen(str)); } -int isstring(value_t v) +int fl_isstring(value_t v) { return (iscvalue(v) && cv_isstr((cvalue_t*)ptr(v))); } diff --git a/femtolisp/flisp.c b/femtolisp/flisp.c index 22c1067..dbc856a 100644 --- a/femtolisp/flisp.c +++ b/femtolisp/flisp.c @@ -214,6 +214,7 @@ void bounds_error(char *fname, value_t arr, value_t ind) // safe cast operators -------------------------------------------------------- +#define isstring fl_isstring #define SAFECAST_OP(type,ctype,cnvt) \ ctype to##type(value_t v, char *fname) \ { \ @@ -226,6 +227,7 @@ SAFECAST_OP(symbol,symbol_t*,ptr) SAFECAST_OP(fixnum,fixnum_t, numval) SAFECAST_OP(cvalue,cvalue_t*,ptr) SAFECAST_OP(string,char*, cvalue_data) +#undef isstring // symbol table --------------------------------------------------------------- @@ -711,7 +713,7 @@ value_t fl_cons(value_t a, value_t b) return c; } -int isnumber(value_t v) +int fl_isnumber(value_t v) { if (isfixnum(v)) return 1; if (iscprim(v)) { @@ -1235,7 +1237,7 @@ static value_t apply_cl(uint32_t nargs) Stack[SP-1] = (issymbol(Stack[SP-1]) ? FL_T : FL_F); NEXT_OP; OP(OP_NUMBERP) v = Stack[SP-1]; - Stack[SP-1] = (isnumber(v) ? FL_T:FL_F); NEXT_OP; + Stack[SP-1] = (fl_isnumber(v) ? FL_T:FL_F); NEXT_OP; OP(OP_FIXNUMP) Stack[SP-1] = (isfixnum(Stack[SP-1]) ? FL_T : FL_F); NEXT_OP; OP(OP_BOUNDP) @@ -1947,7 +1949,7 @@ static value_t fl_function(value_t *args, uint32_t nargs) { if (nargs < 2 || nargs > 4) argcount("function", nargs, 2); - if (!isstring(args[0])) + if (!fl_isstring(args[0])) type_error("function", "string", args[0]); if (!isvector(args[1])) type_error("function", "vector", args[1]); diff --git a/femtolisp/flisp.h b/femtolisp/flisp.h index dacc32b..7b5a2b5 100644 --- a/femtolisp/flisp.h +++ b/femtolisp/flisp.h @@ -280,9 +280,9 @@ value_t cvalue_string(size_t sz); value_t cvalue_static_cstring(const char *str); value_t string_from_cstr(char *str); value_t string_from_cstrn(char *str, size_t n); -int isstring(value_t v); -int isnumber(value_t v); -int isiostream(value_t v); +int fl_isstring(value_t v); +int fl_isnumber(value_t v); +int fl_isiostream(value_t v); value_t cvalue_compare(value_t a, value_t b); int numeric_compare(value_t a, value_t b, int eq, int eqnans, char *fname); diff --git a/femtolisp/iostream.c b/femtolisp/iostream.c index f8cd27a..14c011b 100644 --- a/femtolisp/iostream.c +++ b/femtolisp/iostream.c @@ -38,7 +38,7 @@ void relocate_iostream(value_t oldv, value_t newv) cvtable_t iostream_vtable = { print_iostream, relocate_iostream, free_iostream, NULL }; -int isiostream(value_t v) +int fl_isiostream(value_t v) { return iscvalue(v) && cv_class((cvalue_t*)ptr(v)) == iostreamtype; } @@ -46,7 +46,7 @@ int isiostream(value_t v) value_t fl_iostreamp(value_t *args, uint32_t nargs) { argcount("iostream?", nargs, 1); - return isiostream(args[0]) ? FL_T : FL_F; + return fl_isiostream(args[0]) ? FL_T : FL_F; } value_t fl_eof_object(value_t *args, uint32_t nargs) @@ -64,7 +64,7 @@ value_t fl_eof_objectp(value_t *args, uint32_t nargs) static ios_t *toiostream(value_t v, char *fname) { - if (!isiostream(v)) + if (!fl_isiostream(v)) type_error(fname, "iostream", v); return value2c(ios_t*, v); } diff --git a/femtolisp/print.c b/femtolisp/print.c index 82e1e2c..26b7100 100644 --- a/femtolisp/print.c +++ b/femtolisp/print.c @@ -166,7 +166,7 @@ static inline int tinyp(value_t v) { if (issymbol(v)) return (u8_strwidth(symbol_name(v)) < SMALL_STR_LEN); - if (isstring(v)) + if (fl_isstring(v)) return (cv_len((cvalue_t*)ptr(v)) < SMALL_STR_LEN); return (isfixnum(v) || isbuiltin(v)); } @@ -174,7 +174,7 @@ static inline int tinyp(value_t v) static int smallp(value_t v) { if (tinyp(v)) return 1; - if (isnumber(v)) return 1; + if (fl_isnumber(v)) return 1; if (iscons(v)) { if (tinyp(car_(v)) && (tinyp(cdr_(v)) || (iscons(cdr_(v)) && tinyp(car_(cdr_(v))) && diff --git a/femtolisp/string.c b/femtolisp/string.c index 465323c..3c518da 100644 --- a/femtolisp/string.c +++ b/femtolisp/string.c @@ -19,7 +19,7 @@ value_t fl_stringp(value_t *args, u_int32_t nargs) { argcount("string?", nargs, 1); - return isstring(args[0]) ? FL_T : FL_F; + return fl_isstring(args[0]) ? FL_T : FL_F; } value_t fl_string_count(value_t *args, u_int32_t nargs) @@ -27,7 +27,7 @@ value_t fl_string_count(value_t *args, u_int32_t nargs) size_t start = 0; if (nargs < 1 || nargs > 3) argcount("string.count", nargs, 1); - if (!isstring(args[0])) + if (!fl_isstring(args[0])) type_error("string.count", "string", args[0]); size_t len = cv_len((cvalue_t*)ptr(args[0])); size_t stop = len; @@ -66,7 +66,7 @@ value_t fl_string_width(value_t *args, u_int32_t nargs) value_t fl_string_reverse(value_t *args, u_int32_t nargs) { argcount("string.reverse", nargs, 1); - if (!isstring(args[0])) + if (!fl_isstring(args[0])) type_error("string.reverse", "string", args[0]); size_t len = cv_len((cvalue_t*)ptr(args[0])); value_t ns = cvalue_string(len); @@ -102,7 +102,7 @@ value_t fl_string_decode(value_t *args, u_int32_t nargs) else { argcount("string.decode", nargs, 1); } - if (!isstring(args[0])) + if (!fl_isstring(args[0])) type_error("string.decode", "string", args[0]); cvalue_t *cv = (cvalue_t*)ptr(args[0]); char *ptr = (char*)cv_data(cv); @@ -123,7 +123,7 @@ extern value_t stream_to_string(value_t *ps); value_t fl_string(value_t *args, u_int32_t nargs) { - if (nargs == 1 && isstring(args[0])) + if (nargs == 1 && fl_isstring(args[0])) return args[0]; value_t arg, buf = fl_buffer(NULL, 0); ios_t *s = value2c(ios_t*,buf); @@ -276,7 +276,7 @@ value_t fl_string_find(value_t *args, u_int32_t nargs) else if (iscprim(v) && cp_class(cp) == bytetype) { return mem_find_byte(s, *(char*)cp_data(cp), start, len); } - else if (isstring(v)) { + else if (fl_isstring(v)) { cvalue_t *cv = (cvalue_t*)ptr(v); needlesz = cv_len(cv); needle = (char*)cv_data(cv);