@@ -2872,7 +2872,7 @@ ex_compiler(exarg_T *eap)
28722872 do_unlet ((char_u * )"b:current_compiler" , TRUE);
28732873
28742874 sprintf ((char * )buf , "compiler/%s.vim" , eap -> arg );
2875- if (source_runtime (buf , TRUE ) == FAIL )
2875+ if (source_runtime (buf , DIP_ALL ) == FAIL )
28762876 EMSG2 (_ ("E666: compiler not supported: %s" ), eap -> arg );
28772877 vim_free (buf );
28782878
@@ -2906,7 +2906,7 @@ ex_compiler(exarg_T *eap)
29062906 void
29072907ex_runtime (exarg_T * eap )
29082908{
2909- source_runtime (eap -> arg , eap -> forceit );
2909+ source_runtime (eap -> arg , eap -> forceit ? DIP_ALL : 0 );
29102910}
29112911
29122912 static void
@@ -2918,14 +2918,14 @@ source_callback(char_u *fname, void *cookie UNUSED)
29182918/*
29192919 * Source the file "name" from all directories in 'runtimepath'.
29202920 * "name" can contain wildcards.
2921- * When "all" is TRUE : source all files, otherwise only the first one.
2921+ * When "flags" has DIP_ALL : source all files, otherwise only the first one.
29222922 *
29232923 * return FAIL when no file could be sourced, OK otherwise.
29242924 */
29252925 int
2926- source_runtime (char_u * name , int all )
2926+ source_runtime (char_u * name , int flags )
29272927{
2928- return do_in_runtimepath (name , all , source_callback , NULL );
2928+ return do_in_runtimepath (name , flags , source_callback , NULL );
29292929}
29302930
29312931/*
@@ -3052,8 +3052,8 @@ do_in_path(
30523052/*
30533053 * Find "name" in 'runtimepath'. When found, invoke the callback function for
30543054 * it: callback(fname, "cookie")
3055- * When "all" is TRUE repeat for all matches, otherwise only the first one is
3056- * used.
3055+ * When "flags" has DIP_ALL repeat for all matches, otherwise only the first
3056+ * one is used.
30573057 * Returns OK when at least one match found, FAIL otherwise.
30583058 *
30593059 * If "name" is NULL calls callback for each entry in runtimepath. Cookie is
@@ -3063,11 +3063,41 @@ do_in_path(
30633063 int
30643064do_in_runtimepath (
30653065 char_u * name ,
3066- int all ,
3066+ int flags ,
30673067 void (* callback )(char_u * fname , void * ck ),
30683068 void * cookie )
30693069{
3070- return do_in_path (p_rtp , name , all ? DIP_ALL : 0 , callback , cookie );
3070+ int done ;
3071+ char_u * s ;
3072+ int len ;
3073+ char * start_dir = "pack/*/start/*/%s" ;
3074+ char * opt_dir = "pack/*/opt/*/%s" ;
3075+
3076+ done = do_in_path (p_rtp , name , flags , callback , cookie );
3077+
3078+ if (done == FAIL && (flags & DIP_START ))
3079+ {
3080+ len = STRLEN (start_dir ) + STRLEN (name );
3081+ s = alloc (len );
3082+ if (s == NULL )
3083+ return FAIL ;
3084+ vim_snprintf ((char * )s , len , start_dir , name );
3085+ done = do_in_path (p_pp , s , flags , callback , cookie );
3086+ vim_free (s );
3087+ }
3088+
3089+ if (done == FAIL && (flags & DIP_OPT ))
3090+ {
3091+ len = STRLEN (opt_dir ) + STRLEN (name );
3092+ s = alloc (len );
3093+ if (s == NULL )
3094+ return FAIL ;
3095+ vim_snprintf ((char * )s , len , opt_dir , name );
3096+ done = do_in_path (p_pp , s , flags , callback , cookie );
3097+ vim_free (s );
3098+ }
3099+
3100+ return done ;
30713101}
30723102
30733103/*
0 commit comments