@@ -160,6 +160,7 @@ static BOOL my_isdigit(int c)
160
160
return (c >= '0' && c <= '9' );
161
161
}
162
162
163
+ /* XXX: use 'o' and 'O' for object using JS_PrintValue() ? */
163
164
static JSValue js_printf_internal (JSContext * ctx ,
164
165
int argc , JSValueConst * argv , FILE * fp )
165
166
{
@@ -1083,10 +1084,16 @@ static JSValue js_std_file_printf(JSContext *ctx, JSValueConst this_val,
1083
1084
return js_printf_internal (ctx , argc , argv , f );
1084
1085
}
1085
1086
1087
+ static void js_print_value_write (void * opaque , const char * buf , size_t len )
1088
+ {
1089
+ FILE * fo = opaque ;
1090
+ fwrite (buf , 1 , len , fo );
1091
+ }
1092
+
1086
1093
static JSValue js_std_file_printObject (JSContext * ctx , JSValueConst this_val ,
1087
1094
int argc , JSValueConst * argv )
1088
1095
{
1089
- JS_PrintValue (ctx , stdout , argv [0 ], NULL );
1096
+ JS_PrintValue (ctx , js_print_value_write , stdout , argv [0 ], NULL );
1090
1097
return JS_UNDEFINED ;
1091
1098
}
1092
1099
@@ -3914,7 +3921,7 @@ static JSValue js_print(JSContext *ctx, JSValueConst this_val,
3914
3921
fwrite (str , 1 , len , stdout );
3915
3922
JS_FreeCString (ctx , str );
3916
3923
} else {
3917
- JS_PrintValue (ctx , stdout , v , NULL );
3924
+ JS_PrintValue (ctx , js_print_value_write , stdout , v , NULL );
3918
3925
}
3919
3926
}
3920
3927
putchar ('\n' );
@@ -4028,7 +4035,7 @@ void js_std_free_handlers(JSRuntime *rt)
4028
4035
4029
4036
static void js_std_dump_error1 (JSContext * ctx , JSValueConst exception_val )
4030
4037
{
4031
- JS_PrintValue (ctx , stderr , exception_val , NULL );
4038
+ JS_PrintValue (ctx , js_print_value_write , stderr , exception_val , NULL );
4032
4039
fputc ('\n' , stderr );
4033
4040
}
4034
4041
0 commit comments