aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-04-27 21:49:36 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-05-02 15:58:33 -0300
commit89e07185e96bcbaeb8009b1dbad161f6b7c8b74c (patch)
tree73c1d43cce77dd6d0ecefed7e82fd7219d334730
parent8500eeed86f1cc19f7d038031436a09f80cc6ce9 (diff)
downloadrneovim-89e07185e96bcbaeb8009b1dbad161f6b7c8b74c.tar.gz
rneovim-89e07185e96bcbaeb8009b1dbad161f6b7c8b74c.tar.bz2
rneovim-89e07185e96bcbaeb8009b1dbad161f6b7c8b74c.zip
Remove the code related to the shortname option
-rw-r--r--src/buffer.c3
-rw-r--r--src/buffer_defs.h3
-rw-r--r--src/ex_cmds.c5
-rw-r--r--src/fileio.c108
-rw-r--r--src/memline.c182
-rw-r--r--src/option.c7
-rw-r--r--src/option_defs.h1
7 files changed, 19 insertions, 290 deletions
diff --git a/src/buffer.c b/src/buffer.c
index f672938077..35d5582340 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -466,7 +466,6 @@ void buf_clear_file(buf_T *buf)
{
buf->b_ml.ml_line_count = 1;
unchanged(buf, TRUE);
- buf->b_shortname = FALSE;
buf->b_p_eol = TRUE;
buf->b_start_eol = TRUE;
buf->b_p_bomb = FALSE;
@@ -2289,8 +2288,6 @@ setfname (
}
#endif
- buf->b_shortname = FALSE;
-
buf_name_changed(buf);
return OK;
}
diff --git a/src/buffer_defs.h b/src/buffer_defs.h
index cbc8ab148c..fd28368b4d 100644
--- a/src/buffer_defs.h
+++ b/src/buffer_defs.h
@@ -596,7 +596,6 @@ struct file_buffer {
char_u *b_p_qe; /* 'quoteescape' */
int b_p_ro; /* 'readonly' */
long b_p_sw; /* 'shiftwidth' */
- int b_p_sn; /* 'shortname' */
int b_p_si; /* 'smartindent' */
long b_p_sts; /* 'softtabstop' */
long b_p_sts_nopaste; /* b_p_sts saved for paste mode */
@@ -698,8 +697,6 @@ struct file_buffer {
are not used! Use the B_SPELL macro to
access b_spell without #ifdef. */
- int b_shortname; /* this file has an 8.3 file name */
-
synblock_T b_s; /* Info related to syntax highlighting. w_s
* normally points to this, but some windows
* may use a different synblock_T. */
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index c65ff6dbbf..77523a043f 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1510,7 +1510,6 @@ void write_viminfo(char_u *file, int forceit)
mode_t umask_save;
#endif
#ifdef UNIX
- int shortname = FALSE; /* use 8.3 file name */
struct stat st_old; /* mch_stat() of existing viminfo file */
#endif
@@ -1579,9 +1578,7 @@ void write_viminfo(char_u *file, int forceit)
if (mch_stat((char *)tempname, &st_new) == 0) {
/*
* Try another name. Change one character, just before
- * the extension. This should also work for an 8.3
- * file name, when after adding the extension it still is
- * the same file as the original.
+ * the extension.
*/
wp = tempname + STRLEN(tempname) - 5;
if (wp < path_tail(tempname)) /* empty file name? */
diff --git a/src/fileio.c b/src/fileio.c
index acefdfa9c5..39fd97e21d 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2997,9 +2997,6 @@ buf_write (
struct stat st_new;
char_u *dirp;
char_u *rootname;
-#if defined(UNIX)
- int did_set_shortname;
-#endif
copybuf = verbose_try_malloc(BUFSIZE + 1);
if (copybuf == NULL) {
@@ -3038,20 +3035,11 @@ buf_write (
goto nobackup;
}
-#if defined(UNIX)
- did_set_shortname = FALSE;
-#endif
-
- /*
- * May try twice if 'shortname' not set.
- */
- for (;; ) {
+ {
/*
* Make backup file name.
*/
- backup = buf_modname(
- (buf->b_p_sn || buf->b_shortname),
- rootname, backup_ext, FALSE);
+ backup = buf_modname(FALSE, rootname, backup_ext, FALSE);
if (backup == NULL) {
vim_free(rootname);
some_error = TRUE; /* out of memory */
@@ -3065,27 +3053,14 @@ buf_write (
#ifdef UNIX
/*
* Check if backup file is same as original file.
- * May happen when modname() gave the same file back.
- * E.g. silly link, or file name-length reached.
- * If we don't check here, we either ruin the file
- * when copying or erase it after writing. jw.
+ * May happen when modname() gave the same file back (e.g. silly
+ * link). If we don't check here, we either ruin the file when
+ * copying or erase it after writing.
*/
if (st_new.st_dev == st_old.st_dev
&& st_new.st_ino == st_old.st_ino) {
vim_free(backup);
backup = NULL; /* no backup file to delete */
- /*
- * may try again with 'shortname' set
- */
- if (!(buf->b_shortname || buf->b_p_sn)) {
- buf->b_shortname = TRUE;
- did_set_shortname = TRUE;
- continue;
- }
- /* setting shortname didn't help */
- if (did_set_shortname)
- buf->b_shortname = FALSE;
- break;
}
#endif
@@ -3110,7 +3085,6 @@ buf_write (
}
}
}
- break;
}
vim_free(rootname);
@@ -3241,9 +3215,7 @@ nobackup:
if (rootname == NULL)
backup = NULL;
else {
- backup = buf_modname(
- (buf->b_p_sn || buf->b_shortname),
- rootname, backup_ext, FALSE);
+ backup = buf_modname(FALSE, rootname, backup_ext, FALSE);
vim_free(rootname);
}
@@ -3880,9 +3852,7 @@ restore_backup:
* the backup file our 'original' file.
*/
if (*p_pm && dobackup) {
- char *org = (char *)buf_modname(
- (buf->b_p_sn || buf->b_shortname),
- fname, p_pm, FALSE);
+ char *org = (char *)buf_modname(FALSE, fname, p_pm, FALSE);
if (backup != NULL) {
struct stat st;
@@ -4658,8 +4628,7 @@ void shorten_fnames(int force)
}
/*
- * add extension to file name - change path/fo.o.h to path/fo.o.h.ext or
- * fo_o_h.ext when shortname option set.
+ * add extension to file name - change path/fo.o.h to path/fo.o.h.ext
*
* Assumed that fname is a valid name found in the filesystem we assure that
* the return value is a different name and ends in 'ext'.
@@ -4675,14 +4644,12 @@ modname (
int prepend_dot /* may prepend a '.' to file name */
)
{
- return buf_modname(
- (curbuf->b_p_sn || curbuf->b_shortname),
- fname, ext, prepend_dot);
+ return buf_modname(FALSE, fname, ext, prepend_dot);
}
char_u *
buf_modname (
- int shortname, /* use 8.3 file name */
+ int shortname, // use 8.3 file name, should always be FALSE now
char_u *fname,
char_u *ext,
int prepend_dot /* may prepend a '.' to file name */
@@ -4696,6 +4663,8 @@ buf_modname (
extlen = (int)STRLEN(ext);
+ assert(!shortname);
+
/*
* If there is no file name we must get the name of the current directory
* (we need the full path in case :cd is used).
@@ -4719,16 +4688,10 @@ buf_modname (
}
/*
- * search backwards until we hit a '/', '\' or ':' replacing all '.'
- * by '_' when shortname option set and ext starts with a dot.
- * Then truncate what is after the '/', '\' or ':'.
+ * search backwards until we hit a '/', '\' or ':'.
+ * Then truncate what is after the '/', '\' or ':' to BASENAMELEN characters.
*/
for (ptr = retval + fnamelen; ptr > retval; mb_ptr_back(retval, ptr)) {
- if (*ext == '.'
- && shortname
- )
- if (*ptr == '.') /* replace '.' by '_' */
- *ptr = '_';
if (vim_ispathsep(*ptr)) {
++ptr;
break;
@@ -4736,49 +4699,11 @@ buf_modname (
}
/* the file name has at most BASENAMELEN characters. */
- if (STRLEN(ptr) > (unsigned)BASENAMELEN)
+ if (STRLEN(ptr) > BASENAMELEN)
ptr[BASENAMELEN] = '\0';
s = ptr + STRLEN(ptr);
- /*
- * For 8.3 file names we may have to reduce the length.
- */
- if (shortname)
- {
- /*
- * If there is no file name, or the file name ends in '/', and the
- * extension starts with '.', put a '_' before the dot, because just
- * ".ext" is invalid.
- */
- if (fname == NULL || *fname == NUL
- || vim_ispathsep(fname[STRLEN(fname) - 1])) {
- if (*ext == '.')
- *s++ = '_';
- }
- /*
- * If the extension starts with '.', truncate the base name at 8
- * characters
- */
- else if (*ext == '.') {
- if ((size_t)(s - ptr) > (size_t)8) {
- s = ptr + 8;
- *s = '\0';
- }
- }
- /*
- * If the extension doesn't start with '.', and the file name
- * doesn't have an extension yet, append a '.'
- */
- else if ((e = vim_strchr(ptr, '.')) == NULL)
- *s++ = '.';
- /*
- * If the extension doesn't start with '.', and there already is an
- * extension, it may need to be truncated
- */
- else if ((int)STRLEN(e) + extlen > 4)
- s = e + 4 - extlen;
- }
#if defined(WIN3264)
/*
* If there is no file name, and the extension starts with '.', put a
@@ -4798,8 +4723,7 @@ buf_modname (
/*
* Prepend the dot.
*/
- if (prepend_dot && !shortname && *(e = path_tail(retval)) != '.'
- ) {
+ if (prepend_dot && *(e = path_tail(retval)) != '.') {
STRMOVE(e + 1, e);
*e = '.';
}
diff --git a/src/memline.c b/src/memline.c
index 6db8a17579..0978e10cc1 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -1808,16 +1808,8 @@ static time_t swapfile_info(char_u *fname)
static int recov_file_names(char_u **names, char_u *path, int prepend_dot)
{
int num_names;
- /*
- * (Win32 and Win64) never short names, but do prepend a dot.
- * (Not MS-DOS or Win32 or Win64) maybe short name, maybe not: Try both.
- * Only use the short name if it is different.
- */
char_u *p;
int i;
- int shortname = curbuf->b_shortname;
-
- curbuf->b_shortname = FALSE;
num_names = 0;
@@ -1828,7 +1820,7 @@ static int recov_file_names(char_u **names, char_u *path, int prepend_dot)
if (prepend_dot) {
names[num_names] = modname(path, (char_u *)".sw?", TRUE);
if (names[num_names] == NULL)
- goto end;
+ return num_names;
++num_names;
}
@@ -1847,30 +1839,6 @@ static int recov_file_names(char_u **names, char_u *path, int prepend_dot)
} else
++num_names;
- /*
- * Also try with 'shortname' set, in case the file is on a DOS filesystem.
- */
- curbuf->b_shortname = TRUE;
- names[num_names] = modname(path, (char_u *)".sw?", FALSE);
- if (names[num_names] == NULL)
- goto end;
-
- /*
- * Remove the one from 'shortname', if it's the same as with 'noshortname'.
- */
- p = names[num_names];
- i = STRLEN(names[num_names]) - STRLEN(names[num_names - 1]);
- if (i > 0)
- p += i; /* file name has been expanded to full path */
- if (STRCMP(names[num_names - 1], p) == 0)
- vim_free(names[num_names]);
- else
- ++num_names;
-
-end:
- curbuf->b_shortname = shortname;
-
-
return num_names;
}
@@ -3404,7 +3372,7 @@ char_u *makeswapname(char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name
#endif
r = buf_modname(
- (buf->b_p_sn || buf->b_shortname),
+ FALSE,
fname_res,
(char_u *)
".swp",
@@ -3574,26 +3542,8 @@ findswapname (
char_u *fname;
int n;
char_u *dir_name;
- int r;
char_u *buf_fname = buf->b_fname;
-#if !defined(UNIX)
-# define CREATE_DUMMY_FILE
- FILE *dummyfd = NULL;
-
-
- /*
- * If we start editing a new file, e.g. "test.doc", which resides on an
- * MSDOS compatible filesystem, it is possible that the file
- * "test.doc.swp" which we create will be exactly the same file. To avoid
- * this problem we temporarily create "test.doc". Don't do this when the
- * check below for a 8.3 file name is used.
- */
- if (!(buf->b_p_sn || buf->b_shortname) && buf_fname != NULL
- && !os_file_exists(buf_fname))
- dummyfd = mch_fopen((char *)buf_fname, "w");
-#endif
-
/*
* Isolate a directory name from *dirp and put it in dir_name.
* First allocate some memory to put the directory name in.
@@ -3617,89 +3567,6 @@ findswapname (
fname = NULL;
break;
}
-#if defined(UNIX)
- /*
- * Some systems have a MS-DOS compatible filesystem that use 8.3 character
- * file names. If this is the first try and the swap file name does not fit in
- * 8.3, detect if this is the case, set shortname and try again.
- */
- if (fname[n - 2] == 'w' && fname[n - 1] == 'p'
- && !(buf->b_p_sn || buf->b_shortname)) {
- char_u *tail;
- char_u *fname2;
- struct stat s1, s2;
- int f1, f2;
- int created1 = FALSE, created2 = FALSE;
- int same = FALSE;
-
- /*
- * Check if swapfile name does not fit in 8.3:
- * It either contains two dots, is longer than 8 chars, or starts
- * with a dot.
- */
- tail = path_tail(buf_fname);
- if ( vim_strchr(tail, '.') != NULL
- || STRLEN(tail) > (size_t)8
- || *path_tail(fname) == '.') {
- fname2 = alloc(n + 2);
- STRCPY(fname2, fname);
- /* if fname == "xx.xx.swp", fname2 = "xx.xx.swx"
- * if fname == ".xx.swp", fname2 = ".xx.swpx"
- * if fname == "123456789.swp", fname2 = "12345678x.swp"
- */
- if (vim_strchr(tail, '.') != NULL)
- fname2[n - 1] = 'x';
- else if (*path_tail(fname) == '.') {
- fname2[n] = 'x';
- fname2[n + 1] = NUL;
- } else
- fname2[n - 5] += 1;
- /*
- * may need to create the files to be able to use mch_stat()
- */
- f1 = mch_open((char *)fname, O_RDONLY, 0);
- if (f1 < 0) {
- f1 = mch_open_rw((char *)fname,
- O_RDWR|O_CREAT|O_EXCL);
- created1 = TRUE;
- }
- if (f1 >= 0) {
- f2 = mch_open((char *)fname2, O_RDONLY, 0);
- if (f2 < 0) {
- f2 = mch_open_rw((char *)fname2,
- O_RDWR|O_CREAT|O_EXCL);
- created2 = TRUE;
- }
- if (f2 >= 0) {
- /*
- * Both files exist now. If mch_stat() returns the
- * same device and inode they are the same file.
- */
- if (mch_fstat(f1, &s1) != -1
- && mch_fstat(f2, &s2) != -1
- && s1.st_dev == s2.st_dev
- && s1.st_ino == s2.st_ino)
- same = TRUE;
- close(f2);
- if (created2)
- os_remove((char *)fname2);
- }
- close(f1);
- if (created1) {
- os_remove((char *)fname);
- }
- }
- vim_free(fname2);
- if (same) {
- buf->b_shortname = TRUE;
- vim_free(fname);
- fname = makeswapname(buf_fname, buf->b_ffname,
- buf, dir_name);
- continue; /* try again with b_shortname set */
- }
- }
- }
-#endif
/*
* check if the swapfile already exists
*/
@@ -3728,26 +3595,6 @@ findswapname (
*/
if (fname[n - 2] == 'w' && fname[n - 1] == 'p') { /* first try */
/*
- * on MS-DOS compatible filesystems (e.g. messydos) file.doc.swp
- * and file.doc are the same file. To guess if this problem is
- * present try if file.doc.swx exists. If it does, we set
- * buf->b_shortname and try file_doc.swp (dots replaced by
- * underscores for this file), and try again. If it doesn't we
- * assume that "file.doc.swp" already exists.
- */
- if (!(buf->b_p_sn || buf->b_shortname)) { /* not tried yet */
- fname[n - 1] = 'x';
- r = os_getperm(fname); /* try "file.swx" */
- fname[n - 1] = 'p';
- if (r >= 0) { /* "file.swx" seems to exist */
- buf->b_shortname = TRUE;
- vim_free(fname);
- fname = makeswapname(buf_fname, buf->b_ffname,
- buf, dir_name);
- continue; /* try again with '.' replaced with '_' */
- }
- }
- /*
* If we get here the ".swp" file really exists.
* Give an error message, unless recovering, no file name, we are
* viewing a help file or when the path of the file is different
@@ -3811,20 +3658,6 @@ findswapname (
#if defined(HAS_SWAP_EXISTS_ACTION)
int choice = 0;
#endif
-#ifdef CREATE_DUMMY_FILE
- int did_use_dummy = FALSE;
-
- /* Avoid getting a warning for the file being created
- * outside of Vim, it was created at the start of this
- * function. Delete the file now, because Vim might exit
- * here if the window is closed. */
- if (dummyfd != NULL) {
- fclose(dummyfd);
- dummyfd = NULL;
- os_remove(buf_fname);
- did_use_dummy = TRUE;
- }
-#endif
#if defined(UNIX) && (defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG))
process_still_running = FALSE;
@@ -3917,11 +3750,6 @@ findswapname (
need_wait_return = TRUE;
}
-#ifdef CREATE_DUMMY_FILE
- /* Going to try another name, need the dummy file again. */
- if (did_use_dummy)
- dummyfd = mch_fopen((char *)buf_fname, "w");
-#endif
}
}
}
@@ -3946,12 +3774,6 @@ findswapname (
}
vim_free(dir_name);
-#ifdef CREATE_DUMMY_FILE
- if (dummyfd != NULL) { /* file has been created temporarily */
- fclose(dummyfd);
- os_remove(buf_fname);
- }
-#endif
return fname;
}
diff --git a/src/option.c b/src/option.c
index 94e81b1441..82de35125c 100644
--- a/src/option.c
+++ b/src/option.c
@@ -150,7 +150,6 @@
# define PV_QE OPT_BUF(BV_QE)
#define PV_RO OPT_BUF(BV_RO)
# define PV_SI OPT_BUF(BV_SI)
-# define PV_SN OPT_BUF(BV_SN)
# define PV_SMC OPT_BUF(BV_SMC)
# define PV_SYN OPT_BUF(BV_SYN)
# define PV_SPC OPT_BUF(BV_SPC)
@@ -263,7 +262,6 @@ static int p_pi;
static char_u *p_qe;
static int p_ro;
static int p_si;
-static int p_sn;
static long p_sts;
static char_u *p_sua;
static long p_sw;
@@ -1414,9 +1412,6 @@ static struct vimoption
(char_u *)&p_shm, PV_NONE,
{(char_u *)"", (char_u *)"filnxtToO"}
SCRIPTID_INIT},
- {"shortname", "sn", P_BOOL|P_VI_DEF,
- (char_u *)&p_sn, PV_SN,
- {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
{"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
(char_u *)&p_sbr, PV_NONE,
{(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
@@ -6777,7 +6772,6 @@ static char_u *get_varp(struct vimoption *p)
case PV_QE: return (char_u *)&(curbuf->b_p_qe);
case PV_RO: return (char_u *)&(curbuf->b_p_ro);
case PV_SI: return (char_u *)&(curbuf->b_p_si);
- case PV_SN: return (char_u *)&(curbuf->b_p_sn);
case PV_STS: return (char_u *)&(curbuf->b_p_sts);
case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
@@ -7003,7 +6997,6 @@ void buf_copy_options(buf_T *buf, int flags)
buf->b_p_ofu = vim_strsave(p_ofu);
buf->b_p_sts = p_sts;
buf->b_p_sts_nopaste = p_sts_nopaste;
- buf->b_p_sn = p_sn;
buf->b_p_com = vim_strsave(p_com);
buf->b_p_cms = vim_strsave(p_cms);
buf->b_p_fo = vim_strsave(p_fo);
diff --git a/src/option_defs.h b/src/option_defs.h
index 2935943cf2..72a5836b2d 100644
--- a/src/option_defs.h
+++ b/src/option_defs.h
@@ -691,7 +691,6 @@ enum {
, BV_QE
, BV_RO
, BV_SI
- , BV_SN
, BV_SMC
, BV_SYN
, BV_SPC