@@ -160,6 +160,7 @@ static BOOL my_isdigit(int c)
160160 return (c >= '0' && c <= '9' );
161161}
162162
163+ /* XXX: use 'o' and 'O' for object using JS_PrintValue() ? */
163164static JSValue js_printf_internal (JSContext * ctx ,
164165 int argc , JSValueConst * argv , FILE * fp )
165166{
@@ -1083,10 +1084,16 @@ static JSValue js_std_file_printf(JSContext *ctx, JSValueConst this_val,
10831084 return js_printf_internal (ctx , argc , argv , f );
10841085}
10851086
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+
10861093static JSValue js_std_file_printObject (JSContext * ctx , JSValueConst this_val ,
10871094 int argc , JSValueConst * argv )
10881095{
1089- JS_PrintValue (ctx , stdout , argv [0 ], NULL );
1096+ JS_PrintValue (ctx , js_print_value_write , stdout , argv [0 ], NULL );
10901097 return JS_UNDEFINED ;
10911098}
10921099
@@ -3914,7 +3921,7 @@ static JSValue js_print(JSContext *ctx, JSValueConst this_val,
39143921 fwrite (str , 1 , len , stdout );
39153922 JS_FreeCString (ctx , str );
39163923 } else {
3917- JS_PrintValue (ctx , stdout , v , NULL );
3924+ JS_PrintValue (ctx , js_print_value_write , stdout , v , NULL );
39183925 }
39193926 }
39203927 putchar ('\n' );
@@ -4028,7 +4035,7 @@ void js_std_free_handlers(JSRuntime *rt)
40284035
40294036static void js_std_dump_error1 (JSContext * ctx , JSValueConst exception_val )
40304037{
4031- JS_PrintValue (ctx , stderr , exception_val , NULL );
4038+ JS_PrintValue (ctx , js_print_value_write , stderr , exception_val , NULL );
40324039 fputc ('\n' , stderr );
40334040}
40344041
0 commit comments