@@ -317,8 +317,6 @@ static void listModules(bool pretty)
317317 }
318318}
319319
320- static void parseOption (FFdata * data , const char * key , const char * value );
321-
322320// Temporary copy before new release of yyjson
323321static bool ffyyjson_locate_pos (const char * str , size_t len , size_t pos ,
324322 size_t * line , size_t * col , size_t * chr ) {
@@ -402,104 +400,6 @@ static bool parseJsoncFile(const char* path)
402400 return true;
403401}
404402
405- static bool parseConfigFile (FFdata * data , const char * path )
406- {
407- FF_AUTO_CLOSE_FILE FILE * file = fopen (path , "r" );
408- if (file == NULL )
409- return false;
410-
411- char * line = NULL ;
412- size_t len = 0 ;
413- ssize_t read ;
414- FF_STRBUF_AUTO_DESTROY unescaped = ffStrbufCreate ();
415-
416- while ((read = getline (& line , & len , file )) != -1 )
417- {
418- char * lineStart = line ;
419- char * lineEnd = line + read - 1 ;
420-
421- //Trim line left
422- while (isspace (* lineStart ))
423- ++ lineStart ;
424-
425- //Continue if line is empty or a comment
426- if (* lineStart == '\0' || * lineStart == '#' )
427- continue ;
428-
429- //Trim line right
430- while (lineEnd > lineStart && isspace (* lineEnd ))
431- -- lineEnd ;
432- * (lineEnd + 1 ) = '\0' ;
433-
434- char * valueStart = strchr (lineStart , ' ' );
435-
436- //If the line has no white space, it is only a key
437- if (valueStart == NULL )
438- {
439- parseOption (data , lineStart , NULL );
440- continue ;
441- }
442-
443- //separate the key from the value
444- * valueStart = '\0' ;
445- ++ valueStart ;
446-
447- //Trim space of value left
448- while (isspace (* valueStart ))
449- ++ valueStart ;
450-
451- //If we want whitespace in values, we need to quote it. This is done to keep consistency with shell.
452- if ((* valueStart == '"' || * valueStart == '\'' ) && * valueStart == * lineEnd && lineEnd > valueStart )
453- {
454- ++ valueStart ;
455- * lineEnd = '\0' ;
456- -- lineEnd ;
457- }
458-
459- if (strchr (valueStart , '\\' ))
460- {
461- // Unescape all `\x`s
462- const char * value = valueStart ;
463- while (* value != '\0' )
464- {
465- if (* value != '\\' )
466- {
467- ffStrbufAppendC (& unescaped , * value );
468- ++ value ;
469- continue ;
470- }
471-
472- ++ value ;
473-
474- switch (* value )
475- {
476- case 'n' : ffStrbufAppendC (& unescaped , '\n' ); break ;
477- case 't' : ffStrbufAppendC (& unescaped , '\t' ); break ;
478- case 'e' : ffStrbufAppendC (& unescaped , '\e' ); break ;
479- case '\\' : ffStrbufAppendC (& unescaped , '\\' ); break ;
480- default :
481- ffStrbufAppendC (& unescaped , '\\' );
482- ffStrbufAppendC (& unescaped , * value );
483- break ;
484- }
485-
486- ++ value ;
487- }
488- parseOption (data , lineStart , unescaped .chars );
489- ffStrbufClear (& unescaped );
490- }
491- else
492- {
493- parseOption (data , lineStart , valueStart );
494- }
495- }
496-
497- if (line != NULL )
498- free (line );
499-
500- return true;
501- }
502-
503403static void generateConfigFile (bool force , const char * filePath )
504404{
505405 if (!filePath )
@@ -509,11 +409,6 @@ static void generateConfigFile(bool force, const char* filePath)
509409 }
510410 else
511411 {
512- if (ffStrEqualsIgnCase (filePath , "conf" ) || ffStrEqualsIgnCase (filePath , "jsonc" ))
513- {
514- fputs ("Error: specifying file type is no longer supported\n" , stderr );
515- exit (477 );
516- }
517412 ffStrbufSetS (& instance .state .genConfigPath , filePath );
518413 }
519414
@@ -549,19 +444,15 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
549444 if (ffStrEqualsIgnCase (value , "none" ))
550445 return ;
551446
552- bool isJsonConfig = fileNameLen > strlen (".jsonc" ) && strcasecmp (value + fileNameLen - strlen (".jsonc" ), ".jsonc" ) == 0 ;
447+ if (ffStrEndsWithIgnCase (value , ".conf" ))
448+ {
449+ fprintf (stderr , "Error: flag based config files are no longer not supported: %s\n" , value );
450+ exit (414 );
451+ }
553452
554453 //Try to load as an absolute path
555454
556- if (isJsonConfig ? parseJsoncFile (value ) : parseConfigFile (data , value ))
557- return ;
558-
559- {
560- bool success = isJsonConfig ? parseJsoncFile (value ) : parseConfigFile (data , value );
561-
562- if (success )
563- return ;
564- }
455+ if (parseJsoncFile (value )) return ;
565456
566457 //Try to load as a relative path
567458
@@ -573,15 +464,14 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
573464 ffStrbufAppendS (& absolutePath , "fastfetch/presets/" );
574465 ffStrbufAppendS (& absolutePath , value );
575466
576- bool success = isJsonConfig ? parseJsoncFile (absolutePath . chars ) : parseConfigFile ( data , absolutePath .chars );
467+ bool success = parseJsoncFile (absolutePath .chars );
577468 if (!success )
578469 {
579470 ffStrbufAppendS (& absolutePath , ".jsonc" );
580471 success = parseJsoncFile (absolutePath .chars );
581472 }
582473
583- if (success )
584- return ;
474+ if (success ) return ;
585475 }
586476
587477 {
@@ -591,15 +481,14 @@ static void optionParseConfigFile(FFdata* data, const char* key, const char* val
591481 ffStrbufAppendS (& absolutePath , "/presets/" );
592482 ffStrbufAppendS (& absolutePath , value );
593483
594- bool success = isJsonConfig ? parseJsoncFile (absolutePath . chars ) : parseConfigFile ( data , absolutePath .chars );
484+ bool success = parseJsoncFile (absolutePath .chars );
595485 if (!success )
596486 {
597487 ffStrbufAppendS (& absolutePath , ".jsonc" );
598488 success = parseJsoncFile (absolutePath .chars );
599489 }
600490
601- if (success )
602- return ;
491+ if (success ) return ;
603492 }
604493
605494 //File not found
@@ -755,7 +644,7 @@ static void parseOption(FFdata* data, const char* key, const char* value)
755644 }
756645}
757646
758- static void parseConfigFiles (FFdata * data )
647+ static void parseConfigFiles (void )
759648{
760649 if (__builtin_expect (instance .state .genConfigPath .length == 0 , true))
761650 {
@@ -769,15 +658,6 @@ static void parseConfigFiles(FFdata* data)
769658 if (success ) return ;
770659 }
771660 }
772- FF_LIST_FOR_EACH (FFstrbuf , dir , instance .state .platform .configDirs )
773- {
774- uint32_t dirLength = dir -> length ;
775-
776- ffStrbufAppendS (dir , "fastfetch/config.conf" );
777- bool success = parseConfigFile (data , dir -> chars );
778- ffStrbufSubstrBefore (dir , dirLength );
779- if (success ) return ;
780- }
781661}
782662
783663static void parseArguments (FFdata * data , int argc , char * * argv , void (* parser )(FFdata * data , char * key , char * value ))
@@ -884,7 +764,7 @@ int main(int argc, char** argv)
884764
885765 parseArguments (& data , argc , argv , parseCommand );
886766 if (!data .configLoaded && !getenv ("NO_CONFIG" ))
887- parseConfigFiles (& data );
767+ parseConfigFiles ();
888768 parseArguments (& data , argc , argv , (void * ) parseOption );
889769
890770 if (__builtin_expect (instance .state .genConfigPath .length == 0 , true))
0 commit comments