Remove char_u: ex_docmd:get_view_file()

This commit is contained in:
Michael Reed
2015-05-13 15:29:49 -04:00
parent 743a0aa7f1
commit d666b0e48f

View File

@@ -7409,7 +7409,6 @@ static void ex_mkrc(exarg_T *eap)
{ {
FILE *fd; FILE *fd;
int failed = FALSE; int failed = FALSE;
char_u *fname;
int view_session = FALSE; int view_session = FALSE;
int using_vdir = FALSE; /* using 'viewdir'? */ int using_vdir = FALSE; /* using 'viewdir'? */
char_u *viewFile = NULL; char_u *viewFile = NULL;
@@ -7423,12 +7422,13 @@ static void ex_mkrc(exarg_T *eap)
* short file name when 'acd' is set, that is checked later. */ * short file name when 'acd' is set, that is checked later. */
did_lcd = FALSE; did_lcd = FALSE;
char_u *fname;
/* ":mkview" or ":mkview 9": generate file name with 'viewdir' */ /* ":mkview" or ":mkview 9": generate file name with 'viewdir' */
if (eap->cmdidx == CMD_mkview if (eap->cmdidx == CMD_mkview
&& (*eap->arg == NUL && (*eap->arg == NUL
|| (ascii_isdigit(*eap->arg) && eap->arg[1] == NUL))) { || (ascii_isdigit(*eap->arg) && eap->arg[1] == NUL))) {
eap->forceit = TRUE; eap->forceit = TRUE;
fname = get_view_file(*eap->arg); fname = (char_u *)get_view_file(*eap->arg);
if (fname == NULL) if (fname == NULL)
return; return;
viewFile = fname; viewFile = fname;
@@ -9050,48 +9050,40 @@ static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp)
*/ */
static void ex_loadview(exarg_T *eap) static void ex_loadview(exarg_T *eap)
{ {
char_u *fname; char *fname = get_view_file(*eap->arg);
fname = get_view_file(*eap->arg);
if (fname != NULL) { if (fname != NULL) {
if (do_source(fname, FALSE, DOSO_NONE) == FAIL) { if (do_source((char_u *)fname, FALSE, DOSO_NONE) == FAIL) {
EMSG2(_(e_notopen), fname); EMSG2(_(e_notopen), fname);
} }
xfree(fname); xfree(fname);
} }
} }
/* /// Get the name of the view file for the current buffer.
* Get the name of the view file for the current buffer. static char *get_view_file(int c)
*/
static char_u *get_view_file(int c)
{ {
int len = 0;
char_u *p, *s;
char_u *retval;
char_u *sname;
if (curbuf->b_ffname == NULL) { if (curbuf->b_ffname == NULL) {
EMSG(_(e_noname)); EMSG(_(e_noname));
return NULL; return NULL;
} }
sname = home_replace_save(NULL, curbuf->b_ffname); char *sname = (char *)home_replace_save(NULL, curbuf->b_ffname);
/* // We want a file name without separators, because we're not going to make
* We want a file name without separators, because we're not going to make // a directory.
* a directory. // "normal" path separator -> "=+"
* "normal" path separator -> "=+" // "=" -> "=="
* "=" -> "==" // ":" path separator -> "=-"
* ":" path separator -> "=-" size_t len = 0;
*/ for (char *p = sname; *p; p++) {
for (p = sname; *p; ++p) if (*p == '=' || vim_ispathsep(*p)) {
if (*p == '=' || vim_ispathsep(*p))
++len; ++len;
retval = xmalloc(STRLEN(sname) + len + STRLEN(p_vdir) + 9); }
}
char *retval = xmalloc(strlen(sname) + len + STRLEN(p_vdir) + 9);
STRCPY(retval, p_vdir); STRCPY(retval, p_vdir);
add_pathsep((char *)retval); add_pathsep(retval);
s = retval + STRLEN(retval); char *s = retval + strlen(retval);
for (p = sname; *p; ++p) { for (char *p = sname; *p; p++) {
if (*p == '=') { if (*p == '=') {
*s++ = '='; *s++ = '=';
*s++ = '='; *s++ = '=';
@@ -9108,7 +9100,7 @@ static char_u *get_view_file(int c)
} }
*s++ = '='; *s++ = '=';
*s++ = c; *s++ = c;
STRCPY(s, ".vim"); strcpy(s, ".vim");
xfree(sname); xfree(sname);
return retval; return retval;