@@ -3285,19 +3285,6 @@ source_callback(char_u *fname, void *cookie UNUSED)
32853285 (void )do_source (fname , FALSE, DOSO_NONE );
32863286}
32873287
3288- /*
3289- * Source the file "name" from all directories in 'runtimepath'.
3290- * "name" can contain wildcards.
3291- * When "flags" has DIP_ALL: source all files, otherwise only the first one.
3292- *
3293- * return FAIL when no file could be sourced, OK otherwise.
3294- */
3295- int
3296- source_runtime (char_u * name , int flags )
3297- {
3298- return do_in_runtimepath (name , flags , source_callback , NULL );
3299- }
3300-
33013288/*
33023289 * Find the file "name" in all directories in "path" and invoke
33033290 * "callback(fname, cookie)".
@@ -3435,18 +3422,19 @@ do_in_path(
34353422}
34363423
34373424/*
3438- * Find "name" in 'runtimepath' . When found, invoke the callback function for
3425+ * Find "name" in "path" . When found, invoke the callback function for
34393426 * it: callback(fname, "cookie")
34403427 * When "flags" has DIP_ALL repeat for all matches, otherwise only the first
34413428 * one is used.
34423429 * Returns OK when at least one match found, FAIL otherwise.
34433430 *
3444- * If "name" is NULL calls callback for each entry in runtimepath . Cookie is
3431+ * If "name" is NULL calls callback for each entry in "path" . Cookie is
34453432 * passed by reference in this case, setting it to NULL indicates that callback
34463433 * has done its job.
34473434 */
3448- int
3449- do_in_runtimepath (
3435+ static int
3436+ do_in_path_and_pp (
3437+ char_u * path ,
34503438 char_u * name ,
34513439 int flags ,
34523440 void (* callback )(char_u * fname , void * ck ),
@@ -3459,7 +3447,7 @@ do_in_runtimepath(
34593447 char * opt_dir = "pack/*/opt/*/%s" ;
34603448
34613449 if ((flags & DIP_NORTP ) == 0 )
3462- done = do_in_path (p_rtp , name , flags , callback , cookie );
3450+ done = do_in_path (path , name , flags , callback , cookie );
34633451
34643452 if ((done == FAIL || (flags & DIP_ALL )) && (flags & DIP_START ))
34653453 {
@@ -3486,6 +3474,42 @@ do_in_runtimepath(
34863474 return done ;
34873475}
34883476
3477+ /*
3478+ * Just like do_in_path_and_pp(), using 'runtimepath' for "path".
3479+ */
3480+ int
3481+ do_in_runtimepath (
3482+ char_u * name ,
3483+ int flags ,
3484+ void (* callback )(char_u * fname , void * ck ),
3485+ void * cookie )
3486+ {
3487+ return do_in_path_and_pp (p_rtp , name , flags , callback , cookie );
3488+ }
3489+
3490+ /*
3491+ * Source the file "name" from all directories in 'runtimepath'.
3492+ * "name" can contain wildcards.
3493+ * When "flags" has DIP_ALL: source all files, otherwise only the first one.
3494+ *
3495+ * return FAIL when no file could be sourced, OK otherwise.
3496+ */
3497+ int
3498+ source_runtime (char_u * name , int flags )
3499+ {
3500+ return source_in_path (p_rtp , name , flags );
3501+ }
3502+
3503+ /*
3504+ * Just like source_runtime(), but use "path" instead of 'runtimepath'.
3505+ */
3506+ int
3507+ source_in_path (char_u * path , char_u * name , int flags )
3508+ {
3509+ return do_in_path_and_pp (path , name , flags , source_callback , NULL );
3510+ }
3511+
3512+
34893513/*
34903514 * Expand wildcards in "pat" and invoke do_source() for each match.
34913515 */
0 commit comments