@@ -194,8 +194,8 @@ typedef enum eOptionLoadingStage {
194194 OptionLoadingStageNone ,
195195 OptionLoadingStageCustom ,
196196 OptionLoadingStageXdg ,
197- OptionLoadingStageHomeRecursive ,
198- OptionLoadingStageCurrentRecursive ,
197+ OptionLoadingStageHomeDir ,
198+ OptionLoadingStageCurrentDir ,
199199 OptionLoadingStageEnvVar ,
200200 OptionLoadingStageCmdline ,
201201} OptionLoadingStage ;
@@ -613,8 +613,8 @@ static const char *const StageDescription [] = {
613613 [OptionLoadingStageNone ] = "not initialized" ,
614614 [OptionLoadingStageCustom ] = "custom file" ,
615615 [OptionLoadingStageXdg ] = "file(s) under $XDG_CONFIG_HOME and $HOME/.config" ,
616- [OptionLoadingStageHomeRecursive ] = "file(s) under $HOME" ,
617- [OptionLoadingStageCurrentRecursive ] = "file(s) under the current directory" ,
616+ [OptionLoadingStageHomeDir ] = "file(s) under $HOME" ,
617+ [OptionLoadingStageCurrentDir ] = "file(s) under the current directory" ,
618618 [OptionLoadingStageCmdline ] = "command line" ,
619619};
620620
@@ -3768,28 +3768,28 @@ static struct preloadPathElt preload_path_list [] = {
37683768 .isDirectory = true,
37693769 .makePath = prependEnvvar ,
37703770 .extra = "HOME" ,
3771- .stage = OptionLoadingStageHomeRecursive ,
3771+ .stage = OptionLoadingStageHomeDir ,
37723772 },
37733773#ifdef WIN32
37743774 {
37753775 .path = "ctags.d" ,
37763776 .isDirectory = true,
37773777 .makePath = getConfigAtHomeOnWindows ,
37783778 .extra = NULL ,
3779- .stage = OptionLoadingStageHomeRecursive ,
3779+ .stage = OptionLoadingStageHomeDir ,
37803780 },
37813781#endif
37823782 {
37833783 .path = ".ctags.d" ,
37843784 .isDirectory = true,
37853785 .makePath = NULL ,
3786- .stage = OptionLoadingStageCurrentRecursive ,
3786+ .stage = OptionLoadingStageCurrentDir ,
37873787 },
37883788 {
37893789 .path = "ctags.d" ,
37903790 .isDirectory = true,
37913791 .makePath = NULL ,
3792- .stage = OptionLoadingStageCurrentRecursive ,
3792+ .stage = OptionLoadingStageCurrentDir ,
37933793 },
37943794 {
37953795 .path = NULL ,
@@ -3808,14 +3808,47 @@ extern void readOptionConfiguration (void)
38083808 parseConfigurationFileOptions ();
38093809}
38103810
3811+ static stringList * optlibPathListNew (struct preloadPathElt * pathList )
3812+ {
3813+ stringList * appended = stringListNew ();
3814+
3815+ for (size_t i = 0 ; pathList [i ].path != NULL || pathList [i ].makePath != NULL ; ++ i )
3816+ {
3817+ struct preloadPathElt * elt = pathList + i ;
3818+ preloadMakePathFunc maker = elt -> makePath ;
3819+ const char * path = elt -> path ;
3820+
3821+ if (!elt -> isDirectory )
3822+ continue ;
3823+
3824+ if (elt -> stage == OptionLoadingStageCurrentDir )
3825+ continue ;
3826+
3827+ if (maker )
3828+ path = maker (elt -> path , elt -> extra );
3829+
3830+ if (path == NULL )
3831+ continue ;
3832+
3833+ vString * vpath ;
3834+ if (path == elt -> path )
3835+ vpath = vStringNewInit (path );
3836+ else
3837+ vpath = vStringNewOwn ((char * )path );
3838+ stringListAdd (appended , vpath );
3839+ }
3840+
3841+ return appended ;
3842+ }
3843+
38113844/*
38123845* Option initialization
38133846*/
38143847
38153848extern void initOptions (void )
38163849{
38173850 OptionFiles = stringListNew ();
3818- OptlibPathList = stringListNew ( );
3851+ OptlibPathList = optlibPathListNew ( preload_path_list );
38193852
38203853 verbose ("Setting option defaults\n" );
38213854 installHeaderListDefaults ();
0 commit comments