Skip to content

Instantly share code, notes, and snippets.

@ichizok
Last active December 30, 2015 04:49
Show Gist options
  • Save ichizok/7778227 to your computer and use it in GitHub Desktop.
Save ichizok/7778227 to your computer and use it in GitHub Desktop.
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -22409,18 +22409,14 @@
* Return value must be allocated memory when succeeded.
*/
static char_u *
-autoload_cache_split_scriptname(fname)
+autoload_cache_split_scriptname(fname, rtplen)
char_u *fname;
+ int rtplen;
{
char_u *p, *q, *r;
/* Find start of package name. */
- p = (char_u *)strstr((char *)fname, "/autoload/");
- if (!p)
- p = (char_u *)strstr((char *)fname, "\\autoload\\");
- if (!p)
- return NULL;
- p += 10;
+ p = fname + rtplen + (int)STRLEN("autoload/");
/* Replace '\\' with '/'. */
r = vim_strnsave(p, (int)STRLEN(p));
@@ -22458,13 +22454,14 @@
* Add an entry to autoload_cache.
*/
static void
-autoload_cache_add(fname)
+autoload_cache_add(fname, rtplen)
char_u *fname;
+ int rtplen;
{
char_u *key;
hashitem_T *hi;
- key = autoload_cache_split_scriptname(fname);
+ key = autoload_cache_split_scriptname(fname, rtplen);
if (key)
{
/* check duplication of key (scriptname). */
@@ -22475,17 +22472,18 @@
}
}
-static void autoload_cache_add_callback __ARGS((char_u *fname, void *cookie));
+static void autoload_cache_add_callback __ARGS((char_u *fname, int rtplen, void *cookie));
/*
* Glue function between do_in_runtimepath() and autoload_cache_add().
*/
static void
-autoload_cache_add_callback(fname, cookie)
+autoload_cache_add_callback(fname, rtplen, cookie)
char_u *fname;
+ int rtplen;
void *cookie UNUSED;
{
- autoload_cache_add(fname);
+ autoload_cache_add(fname, rtplen);
}
/*
@@ -22496,7 +22494,7 @@
{
if (autoload_cache_built == TRUE)
return;
- do_in_runtimepath("autoload/**/*.vim", TRUE, autoload_cache_add_callback,
+ do_in_runtimepath((char_u *)"autoload/**/*.vim", TRUE, autoload_cache_add_callback,
NULL);
autoload_cache_built = TRUE;
}
@@ -22582,7 +22580,7 @@
pkgname = autoload_to_pkgname(hi->hi_key);
if (pkgname)
{
- dict_add_nr_str(dict, pkgname, 0,
+ dict_add_nr_str(dict, (char *)pkgname, 0,
hi->hi_key + STRLEN(hi->hi_key) + 1);
vim_free(pkgname);
}
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -2719,11 +2719,12 @@
source_runtime(eap->arg, eap->forceit);
}
-static void source_callback __ARGS((char_u *fname, void *cookie));
+static void source_callback __ARGS((char_u *fname, int rtplen, void *cookie));
static void
-source_callback(fname, cookie)
+source_callback(fname, rtplen, cookie)
char_u *fname;
+ int rtplen;
void *cookie UNUSED;
{
(void)do_source(fname, FALSE, DOSO_NONE);
@@ -2758,7 +2759,7 @@
do_in_runtimepath(name, all, callback, cookie)
char_u *name;
int all;
- void (*callback)__ARGS((char_u *fname, void *ck));
+ void (*callback)__ARGS((char_u *fname, int rtplen, void *ck));
void *cookie;
{
char_u *rtp;
@@ -2770,6 +2771,7 @@
char_u **files;
int i;
int did_one = FALSE;
+ int rtplen;
#ifdef AMIGA
struct Process *proc = (struct Process *)FindTask(0L);
APTR save_winptr = proc->pr_WindowPtr;
@@ -2800,7 +2802,7 @@
copy_option_part(&rtp, buf, MAXPATHL, ",");
if (name == NULL)
{
- (*callback)(buf, (void *) &cookie);
+ (*callback)(buf, (int)STRLEN(buf), (void *) &cookie);
if (!did_one)
did_one = (cookie == NULL);
}
@@ -2808,6 +2810,7 @@
{
add_pathsep(buf);
tail = buf + STRLEN(buf);
+ rtplen = (int)STRLEN(buf);
/* Loop over all patterns in "name" */
np = name;
@@ -2830,7 +2833,7 @@
{
for (i = 0; i < num_files; ++i)
{
- (*callback)(files[i], cookie);
+ (*callback)(files[i], rtplen, cookie);
did_one = TRUE;
if (!all)
break;
diff --git a/src/gui.c b/src/gui.c
--- a/src/gui.c
+++ b/src/gui.c
@@ -4998,14 +4998,15 @@
/*
* This is shared between Athena, Motif and GTK.
*/
-static void gfp_setname __ARGS((char_u *fname, void *cookie));
+static void gfp_setname __ARGS((char_u *fname, int rtplen, void *cookie));
/*
* Callback function for do_in_runtimepath().
*/
static void
-gfp_setname(fname, cookie)
+gfp_setname(fname, rtplen, cookie)
char_u *fname;
+ int rtplen;
void *cookie;
{
char_u *gfp_buffer = cookie;
diff --git a/src/hardcopy.c b/src/hardcopy.c
--- a/src/hardcopy.c
+++ b/src/hardcopy.c
@@ -1348,7 +1348,7 @@
static void prt_write_real __ARGS((double val, int prec));
static void prt_def_var __ARGS((char *name, double value, int prec));
static void prt_flush_buffer __ARGS((void));
-static void prt_resource_name __ARGS((char_u *filename, void *cookie));
+static void prt_resource_name __ARGS((char_u *filename, int rtplen, void *cookie));
static int prt_find_resource __ARGS((char *name, struct prt_ps_resource_S *resource));
static int prt_open_resource __ARGS((struct prt_ps_resource_S *resource));
static int prt_check_resource __ARGS((struct prt_ps_resource_S *resource, char_u *version));
@@ -1742,8 +1742,9 @@
static void
-prt_resource_name(filename, cookie)
+prt_resource_name(filename, rtplen, cookie)
char_u *filename;
+ int rtplen;
void *cookie;
{
char_u *resource_filename = cookie;
diff --git a/src/if_py_both.h b/src/if_py_both.h
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -981,7 +981,7 @@
} map_rtp_data;
static void
-map_rtp_callback(char_u *path, void *_data)
+map_rtp_callback(char_u *path, int rtplen, void *_data)
{
void **data = (void **) _data;
PyObject *pathObject;
@@ -1035,7 +1035,7 @@
*/
static void
-map_finder_callback(char_u *path, void *_data)
+map_finder_callback(char_u *path, int rtplen, void *_data)
{
void **data = (void **) _data;
PyObject *list = *((PyObject **) data);
diff --git a/src/proto/ex_cmds2.pro b/src/proto/ex_cmds2.pro
--- a/src/proto/ex_cmds2.pro
+++ b/src/proto/ex_cmds2.pro
@@ -60,7 +60,7 @@
void ex_compiler __ARGS((exarg_T *eap));
void ex_runtime __ARGS((exarg_T *eap));
int source_runtime __ARGS((char_u *name, int all));
-int do_in_runtimepath __ARGS((char_u *name, int all, void (*callback)(char_u *fname, void *ck), void *cookie));
+int do_in_runtimepath __ARGS((char_u *name, int all, void (*callback)(char_u *fname, int rtplen, void *ck), void *cookie));
void ex_options __ARGS((exarg_T *eap));
void ex_source __ARGS((exarg_T *eap));
linenr_T *source_breakpoint __ARGS((void *cookie));
diff --git a/src/spell.c b/src/spell.c
--- a/src/spell.c
+++ b/src/spell.c
@@ -858,7 +858,7 @@
static void spell_load_lang __ARGS((char_u *lang));
static char_u *spell_enc __ARGS((void));
static void int_wordlist_spl __ARGS((char_u *fname));
-static void spell_load_cb __ARGS((char_u *fname, void *cookie));
+static void spell_load_cb __ARGS((char_u *fname, int rtplen, void *cookie));
static slang_T *spell_load_file __ARGS((char_u *fname, char_u *lang, slang_T *old_lp, int silent));
static char_u *read_cnt_string __ARGS((FILE *fd, int cnt_bytes, int *lenp));
static int read_region_section __ARGS((FILE *fd, slang_T *slang, int len));
@@ -2722,8 +2722,9 @@
* Invoked through do_in_runtimepath().
*/
static void
-spell_load_cb(fname, cookie)
+spell_load_cb(fname, rtplen, cookie)
char_u *fname;
+ int rtplen;
void *cookie;
{
spelload_T *slp = (spelload_T *)cookie;
diff --git a/src/tag.c b/src/tag.c
--- a/src/tag.c
+++ b/src/tag.c
@@ -2555,15 +2555,16 @@
}
static garray_T tag_fnames = GA_EMPTY;
-static void found_tagfile_cb __ARGS((char_u *fname, void *cookie));
+static void found_tagfile_cb __ARGS((char_u *fname, int rtplen, void *cookie));
/*
* Callback function for finding all "tags" and "tags-??" files in
* 'runtimepath' doc directories.
*/
static void
-found_tagfile_cb(fname, cookie)
+found_tagfile_cb(fname, rtplen, cookie)
char_u *fname;
+ int rtplen;
void *cookie UNUSED;
{
if (ga_grow(&tag_fnames, 1) == OK)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment