fix issues with parse.cm and tokenize.cm
This commit is contained in:
@@ -6283,8 +6283,8 @@ static JSValue js_cell_number (JSContext *ctx, JSValue this_val, int argc, JSVal
|
||||
return val;
|
||||
}
|
||||
|
||||
/* Handle string */
|
||||
if (tag == JS_TAG_STRING || tag == JS_TAG_STRING_IMM) {
|
||||
/* Handle string (immediate ASCII or heap JSText) */
|
||||
if (JS_IsText (val)) {
|
||||
const char *str = JS_ToCString (ctx, val);
|
||||
if (!str) return JS_EXCEPTION;
|
||||
|
||||
@@ -6925,7 +6925,7 @@ JSValue js_cell_character (JSContext *ctx, JSValue this_val, int argc, JSValue *
|
||||
int tag = JS_VALUE_GET_TAG (arg);
|
||||
|
||||
/* Handle string - return first character */
|
||||
if (tag == JS_TAG_STRING || tag == JS_TAG_STRING_IMM) {
|
||||
if (JS_IsText (arg)) {
|
||||
if (js_string_value_len (arg) == 0) return JS_NewString (ctx, "");
|
||||
return js_sub_string_val (ctx, arg, 0, 1);
|
||||
}
|
||||
@@ -6978,7 +6978,7 @@ static JSValue js_cell_text (JSContext *ctx, JSValue this_val, int argc, JSValue
|
||||
int tag = JS_VALUE_GET_TAG (arg);
|
||||
|
||||
/* Handle string / rope */
|
||||
if (tag == JS_TAG_STRING || tag == JS_TAG_STRING_IMM) {
|
||||
if (JS_IsText (arg)) {
|
||||
JSValue str = JS_ToString (ctx, arg); /* owned + flattens rope */
|
||||
if (JS_IsException (str)) return JS_EXCEPTION;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user