@@ -337,6 +337,7 @@ void help(void)
337
337
"usage: " PROG_NAME " [options] [files]\n"
338
338
"\n"
339
339
"options are:\n"
340
+ "-b output raw bytecode instead of C code\n"
340
341
"-e output main() and bytecode in a C file\n"
341
342
"-o output set the output filename\n"
342
343
"-n script_name set the script name (as used in stack traces)\n"
@@ -345,7 +346,6 @@ void help(void)
345
346
"-D module_name compile a dynamically loaded module or worker\n"
346
347
"-M module_name[,cname] add initialization code for an external C module\n"
347
348
"-p prefix set the prefix of the generated C names\n"
348
- "-r output raw bytecode instead of C code\n"
349
349
"-s strip the source code, specify twice to also strip debug info\n"
350
350
"-S n set the maximum stack size to 'n' bytes (default=%d)\n" ,
351
351
JS_GetVersion (),
@@ -380,12 +380,15 @@ int main(int argc, char **argv)
380
380
namelist_add (& cmodule_list , "os" , "os" , 0 );
381
381
382
382
for (;;) {
383
- c = getopt (argc , argv , "ho:N:mn:rxesvM :p:S:D:" );
383
+ c = getopt (argc , argv , "ho:N:mn:bxesvM :p:S:D:" );
384
384
if (c == -1 )
385
385
break ;
386
386
switch (c ) {
387
387
case 'h' :
388
388
help ();
389
+ case 'b' :
390
+ output_type = OUTPUT_RAW ;
391
+ break ;
389
392
case 'o' :
390
393
out_filename = optarg ;
391
394
break ;
@@ -429,9 +432,6 @@ int main(int argc, char **argv)
429
432
case 'p' :
430
433
c_ident_prefix = optarg ;
431
434
break ;
432
- case 'r' :
433
- output_type = OUTPUT_RAW ;
434
- break ;
435
435
case 'S' :
436
436
stack_size = (size_t )strtod (optarg , NULL );
437
437
break ;
@@ -448,7 +448,11 @@ int main(int argc, char **argv)
448
448
449
449
pstrcpy (cfilename , sizeof (cfilename ), out_filename );
450
450
451
- fo = fopen (cfilename , "w" );
451
+ if (output_type == OUTPUT_RAW )
452
+ fo = fopen (cfilename , "wb" );
453
+ else
454
+ fo = fopen (cfilename , "w" );
455
+
452
456
if (!fo ) {
453
457
perror (cfilename );
454
458
exit (1 );
0 commit comments