@@ -3358,19 +3358,6 @@ source_callback(char_u *fname, void *cookie UNUSED)
33583358 (void )do_source (fname , FALSE, DOSO_NONE );
33593359}
33603360
3361- /*
3362- * Source the file "name" from all directories in 'runtimepath'.
3363- * "name" can contain wildcards.
3364- * When "flags" has DIP_ALL: source all files, otherwise only the first one.
3365- *
3366- * return FAIL when no file could be sourced, OK otherwise.
3367- */
3368- int
3369- source_runtime (char_u * name , int flags )
3370- {
3371- return do_in_runtimepath (name , flags , source_callback , NULL );
3372- }
3373-
33743361/*
33753362 * Find the file "name" in all directories in "path" and invoke
33763363 * "callback(fname, cookie)".
@@ -3508,18 +3495,19 @@ do_in_path(
35083495}
35093496
35103497/*
3511- * Find "name" in 'runtimepath' . When found, invoke the callback function for
3498+ * Find "name" in "path" . When found, invoke the callback function for
35123499 * it: callback(fname, "cookie")
35133500 * When "flags" has DIP_ALL repeat for all matches, otherwise only the first
35143501 * one is used.
35153502 * Returns OK when at least one match found, FAIL otherwise.
35163503 *
3517- * If "name" is NULL calls callback for each entry in runtimepath . Cookie is
3504+ * If "name" is NULL calls callback for each entry in "path" . Cookie is
35183505 * passed by reference in this case, setting it to NULL indicates that callback
35193506 * has done its job.
35203507 */
3521- int
3522- do_in_runtimepath (
3508+ static int
3509+ do_in_path_and_pp (
3510+ char_u * path ,
35233511 char_u * name ,
35243512 int flags ,
35253513 void (* callback )(char_u * fname , void * ck ),
@@ -3532,7 +3520,7 @@ do_in_runtimepath(
35323520 char * opt_dir = "pack/*/opt/*/%s" ;
35333521
35343522 if ((flags & DIP_NORTP ) == 0 )
3535- done = do_in_path (p_rtp , name , flags , callback , cookie );
3523+ done = do_in_path (path , name , flags , callback , cookie );
35363524
35373525 if ((done == FAIL || (flags & DIP_ALL )) && (flags & DIP_START ))
35383526 {
@@ -3559,6 +3547,42 @@ do_in_runtimepath(
35593547 return done ;
35603548}
35613549
3550+ /*
3551+ * Just like do_in_path_and_pp(), using 'runtimepath' for "path".
3552+ */
3553+ int
3554+ do_in_runtimepath (
3555+ char_u * name ,
3556+ int flags ,
3557+ void (* callback )(char_u * fname , void * ck ),
3558+ void * cookie )
3559+ {
3560+ return do_in_path_and_pp (p_rtp , name , flags , callback , cookie );
3561+ }
3562+
3563+ /*
3564+ * Source the file "name" from all directories in 'runtimepath'.
3565+ * "name" can contain wildcards.
3566+ * When "flags" has DIP_ALL: source all files, otherwise only the first one.
3567+ *
3568+ * return FAIL when no file could be sourced, OK otherwise.
3569+ */
3570+ int
3571+ source_runtime (char_u * name , int flags )
3572+ {
3573+ return source_in_path (p_rtp , name , flags );
3574+ }
3575+
3576+ /*
3577+ * Just like source_runtime(), but use "path" instead of 'runtimepath'.
3578+ */
3579+ int
3580+ source_in_path (char_u * path , char_u * name , int flags )
3581+ {
3582+ return do_in_path_and_pp (path , name , flags , source_callback , NULL );
3583+ }
3584+
3585+
35623586/*
35633587 * Expand wildcards in "pat" and invoke do_source() for each match.
35643588 */
0 commit comments