@@ -382,16 +382,25 @@ static bool parseJsoncFile(const char* path, bool strictJson)
382
382
383
383
{
384
384
yyjson_read_err error ;
385
- instance .state .configDoc = yyjson_read_file (path , strictJson ? 0 : YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS , NULL , & error );
385
+ yyjson_read_flag flg = strictJson ? 0 : YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS ;
386
+ instance .state .configDoc = path
387
+ ? yyjson_read_file (path , flg , NULL , & error )
388
+ : yyjson_read_fp (stdin , flg , NULL , & error );
386
389
if (!instance .state .configDoc )
387
390
{
388
391
if (error .code != YYJSON_READ_ERROR_FILE_OPEN )
389
392
{
390
- size_t row = 0 , col = error .pos ;
391
- FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate ();
392
- if (ffAppendFileBuffer (path , & content ))
393
- yyjson_locate_pos (content .chars , content .length , error .pos , & row , & col , NULL );
394
- fprintf (stderr , "Error: failed to parse JSON config file `%s` at (%zu, %zu): %s\n" , path , row , col , error .msg );
393
+ if (path )
394
+ {
395
+ size_t row = 0 , col = error .pos ;
396
+ FF_STRBUF_AUTO_DESTROY content = ffStrbufCreate ();
397
+ if (ffAppendFileBuffer (path , & content ))
398
+ yyjson_locate_pos (content .chars , content .length , error .pos , & row , & col , NULL );
399
+ fprintf (stderr , "Error: failed to parse JSON config file `%s` at (%zu, %zu): %s\n" , path , row , col , error .msg );
400
+ }
401
+ else
402
+ fprintf (stderr , "Error: failed to parse JSON from stdin at %zu: %s\n" , error .pos , error .msg );
403
+
395
404
exit (477 );
396
405
}
397
406
return false;
@@ -461,6 +470,12 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
461
470
if (value [0 ] == '\0' || ffStrEqualsIgnCase (value , "none" ))
462
471
return ;
463
472
473
+ if (value [0 ] == '-' && value [1 ] == '\0' )
474
+ {
475
+ parseJsoncFile (NULL , false);
476
+ return ;
477
+ }
478
+
464
479
//Try to load as an absolute path
465
480
466
481
FF_STRBUF_AUTO_DESTROY absolutePath = ffStrbufCreateS (value );
0 commit comments