diff options
author | Stefan Hoffmann <stefan991@gmail.com> | 2014-03-06 23:53:15 +0100 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-03-13 17:18:44 -0300 |
commit | ad77ff53d3ad5f1c4fdf2938bab2c9999df2c82b (patch) | |
tree | 5aa808ca8b97281545f2c4a1e191f3c914e24b7a | |
parent | ce31410c7953a19421a2f2df2d3e6654601da930 (diff) | |
download | rneovim-ad77ff53d3ad5f1c4fdf2938bab2c9999df2c82b.tar.gz rneovim-ad77ff53d3ad5f1c4fdf2938bab2c9999df2c82b.tar.bz2 rneovim-ad77ff53d3ad5f1c4fdf2938bab2c9999df2c82b.zip |
removed get_user_name() and replaced calls with mch_get_user_name()
-rw-r--r-- | src/hardcopy.c | 4 | ||||
-rw-r--r-- | src/memline.c | 14 | ||||
-rw-r--r-- | src/misc2.c | 21 | ||||
-rw-r--r-- | src/misc2.h | 1 |
4 files changed, 10 insertions, 30 deletions
diff --git a/src/hardcopy.c b/src/hardcopy.c index 34435c4791..1237230f0a 100644 --- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -31,6 +31,7 @@ #include "syntax.h" #include "term.h" #include "ui.h" +#include "os/os.h" /* * To implement printing on a platform, the following functions must be @@ -2500,8 +2501,9 @@ int mch_print_begin(prt_settings_T *psettings) */ prt_dsc_start(); prt_dsc_textline("Title", (char *)psettings->jobname); - if (!get_user_name((char_u *)buffer, 256)) + if (mch_get_user_name(buffer, 256) == FAIL) { STRCPY(buffer, "Unknown"); + } prt_dsc_textline("For", buffer); prt_dsc_textline("Creator", VIM_VERSION_LONG); /* Note: to ensure Clean8bit I don't think we can use LC_TIME */ diff --git a/src/memline.c b/src/memline.c index 2126b4109a..e5700ce62c 100644 --- a/src/memline.c +++ b/src/memline.c @@ -343,7 +343,7 @@ int ml_open(buf_T *buf) b0p->b0_dirty = buf->b_changed ? B0_DIRTY : 0; b0p->b0_flags = get_fileformat(buf) + 1; set_b0_fname(b0p, buf); - (void)get_user_name(b0p->b0_uname, B0_UNAME_SIZE); + (void)mch_get_user_name((char *)b0p->b0_uname, B0_UNAME_SIZE); b0p->b0_uname[B0_UNAME_SIZE - 1] = NUL; mch_get_host_name(b0p->b0_hname, B0_HNAME_SIZE); b0p->b0_hname[B0_HNAME_SIZE - 1] = NUL; @@ -833,8 +833,7 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf) if (buf->b_ffname == NULL) b0p->b0_fname[0] = NUL; else { - size_t flen, ulen; - char_u uname[B0_UNAME_SIZE]; + char uname[B0_UNAME_SIZE]; /* * For a file under the home directory of the current user, we try to @@ -846,13 +845,14 @@ static void set_b0_fname(ZERO_BL *b0p, buf_T *buf) home_replace(NULL, buf->b_ffname, b0p->b0_fname, B0_FNAME_SIZE_CRYPT, TRUE); if (b0p->b0_fname[0] == '~') { - flen = STRLEN(b0p->b0_fname); /* If there is no user name or it is too long, don't use "~/" */ - if (get_user_name(uname, B0_UNAME_SIZE) == FAIL - || (ulen = STRLEN(uname)) + flen > B0_FNAME_SIZE_CRYPT - 1) + int retval = mch_get_user_name(uname, B0_UNAME_SIZE); + size_t ulen = STRLEN(uname); + size_t flen = STRLEN(b0p->b0_fname); + if (retval == FAIL || ulen + flen > B0_FNAME_SIZE_CRYPT - 1) { vim_strncpy(b0p->b0_fname, buf->b_ffname, B0_FNAME_SIZE_CRYPT - 1); - else { + } else { mch_memmove(b0p->b0_fname + ulen + 1, b0p->b0_fname + 1, flen); mch_memmove(b0p->b0_fname + 1, uname, ulen); } diff --git a/src/misc2.c b/src/misc2.c index d97393e699..2ede5d38ee 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -47,8 +47,6 @@ #include "window.h" #include "os/os.h" -static char_u *username = NULL; /* cached result of mch_get_user_name() */ - static int coladvance2(pos_T *pos, int addspaces, int finetune, colnr_T wcol); @@ -935,7 +933,6 @@ void free_all_mem(void) { clear_sb_text(); /* free any scrollback text */ /* Free some global vars. */ - vim_free(username); vim_free(last_cmdline); vim_free(new_last_cmdline); set_keep_msg(NULL, 0); @@ -1876,24 +1873,6 @@ int vim_chdir(char_u *new_dir) return r; } -/* - * Get user name from machine-specific function. - * Returns the user name in "buf[len]". - * Some systems are quite slow in obtaining the user name (Windows NT), thus - * cache the result. - * Returns OK or FAIL. - */ -int get_user_name(char_u *buf, int len) -{ - if (username == NULL) { - if (mch_get_user_name((char *)buf, len) == FAIL) - return FAIL; - username = vim_strsave(buf); - } else - vim_strncpy(buf, username, len - 1); - return OK; -} - #ifndef HAVE_QSORT /* * Our own qsort(), for systems that don't have it. diff --git a/src/misc2.h b/src/misc2.h index 791981688e..a5ef378bcd 100644 --- a/src/misc2.h +++ b/src/misc2.h @@ -66,7 +66,6 @@ int same_directory(char_u *f1, char_u *f2); int vim_chdirfile(char_u *fname); int illegal_slash(char *name); int vim_chdir(char_u *new_dir); -int get_user_name(char_u *buf, int len); void sort_strings(char_u **files, int count); int pathcmp(const char *p, const char *q, int maxlen); int filewritable(char_u *fname); |