diff options
Diffstat (limited to 'src/fileio.c')
-rw-r--r-- | src/fileio.c | 108 |
1 files changed, 16 insertions, 92 deletions
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 = '.'; } |