comparison src/fileio.c @ 39:410fa1a31baf v7.0023

updated for version 7.0023
author vimboss
date Sun, 19 Dec 2004 22:46:22 +0000
parents 125e80798a85
children f1d2a58883b9
comparison
equal deleted inserted replaced
38:c524f99c7925 39:410fa1a31baf
368 * file may destroy it! Reported on MS-DOS and Win 95. 368 * file may destroy it! Reported on MS-DOS and Win 95.
369 * If the name is too long we might crash further on, quit here. 369 * If the name is too long we might crash further on, quit here.
370 */ 370 */
371 if (fname != NULL && *fname != NUL) 371 if (fname != NULL && *fname != NUL)
372 { 372 {
373 p = fname + STRLEN(fname) - 1; 373 p = fname + STRLEN(fname);
374 if ((vim_ispathsep(*p) 374 if (after_pathsep(fname, p) || STRLEN(fname) >= MAXPATHL)
375 #ifdef FEAT_MBYTE
376 /* Do not use a multi-byte char as path separator. */
377 && (!has_mbyte || (*mb_head_off)(fname, p) == 0)
378 #endif
379 ) || STRLEN(fname) >= MAXPATHL)
380 { 375 {
381 filemess(curbuf, fname, (char_u *)_("Illegal file name"), 0); 376 filemess(curbuf, fname, (char_u *)_("Illegal file name"), 0);
382 msg_end(); 377 msg_end();
383 msg_scroll = msg_save; 378 msg_scroll = msg_save;
384 return FAIL; 379 return FAIL;
2799 { 2794 {
2800 /* Assume the buffer was written, update the timestamp. */ 2795 /* Assume the buffer was written, update the timestamp. */
2801 ml_timestamp(buf); 2796 ml_timestamp(buf);
2802 buf->b_flags &= ~BF_WRITE_MASK; 2797 buf->b_flags &= ~BF_WRITE_MASK;
2803 } 2798 }
2804 if (reset_changed && buf->b_changed) 2799 if (reset_changed && buf->b_changed
2800 && (overwriting || vim_strchr(p_cpo, CPO_PLUS) != NULL))
2805 /* Buffer still changed, the autocommands didn't work 2801 /* Buffer still changed, the autocommands didn't work
2806 * properly. */ 2802 * properly. */
2807 return FAIL; 2803 return FAIL;
2808 return OK; 2804 return OK;
2809 } 2805 }
3524 * we crash in the middle of writing. Therefore the file is preserved now. 3520 * we crash in the middle of writing. Therefore the file is preserved now.
3525 * This makes all block numbers positive so that recovery does not need 3521 * This makes all block numbers positive so that recovery does not need
3526 * the original file. 3522 * the original file.
3527 * Don't do this if there is a backup file and we are exiting. 3523 * Don't do this if there is a backup file and we are exiting.
3528 */ 3524 */
3529 if (reset_changed && !newfile && !otherfile(ffname) 3525 if (reset_changed && !newfile && overwriting
3530 && !(exiting && backup != NULL)) 3526 && !(exiting && backup != NULL))
3531 { 3527 {
3532 ml_preserve(buf, FALSE); 3528 ml_preserve(buf, FALSE);
3533 if (got_int) 3529 if (got_int)
3534 { 3530 {
4190 4186
4191 set_keep_msg(msg_trunc_attr(IObuff, FALSE, 0)); 4187 set_keep_msg(msg_trunc_attr(IObuff, FALSE, 0));
4192 keep_msg_attr = 0; 4188 keep_msg_attr = 0;
4193 } 4189 }
4194 4190
4191 /* When written everything correctly: reset 'modified'. Unless not
4192 * writing to the original file and '+' is not in 'cpoptions'. */
4195 if (reset_changed && whole 4193 if (reset_changed && whole
4196 #ifdef FEAT_MBYTE 4194 #ifdef FEAT_MBYTE
4197 && !write_info.bw_conv_error 4195 && !write_info.bw_conv_error
4198 #endif 4196 #endif
4199 ) /* when written everything correctly */ 4197 && (overwriting || vim_strchr(p_cpo, CPO_PLUS) != NULL)
4198 )
4200 { 4199 {
4201 unchanged(buf, TRUE); 4200 unchanged(buf, TRUE);
4202 u_unchanged(buf); 4201 u_unchanged(buf);
4203 } 4202 }
4204 4203
5381 (fnamelen = (int)STRLEN(retval)) == 0) 5380 (fnamelen = (int)STRLEN(retval)) == 0)
5382 { 5381 {
5383 vim_free(retval); 5382 vim_free(retval);
5384 return NULL; 5383 return NULL;
5385 } 5384 }
5386 if (!vim_ispathsep(retval[fnamelen - 1])) 5385 if (!after_pathsep(retval, retval + fnamelen))
5387 { 5386 {
5388 retval[fnamelen++] = PATHSEP; 5387 retval[fnamelen++] = PATHSEP;
5389 retval[fnamelen] = NUL; 5388 retval[fnamelen] = NUL;
5390 } 5389 }
5391 #ifndef SHORT_FNAME 5390 #ifndef SHORT_FNAME
5408 * search backwards until we hit a '/', '\' or ':' replacing all '.' 5407 * search backwards until we hit a '/', '\' or ':' replacing all '.'
5409 * by '_' for MSDOS or when shortname option set and ext starts with a dot. 5408 * by '_' for MSDOS or when shortname option set and ext starts with a dot.
5410 * Then truncate what is after the '/', '\' or ':' to 8 characters for 5409 * Then truncate what is after the '/', '\' or ':' to 8 characters for
5411 * MSDOS and 26 characters for AMIGA, a lot more for UNIX. 5410 * MSDOS and 26 characters for AMIGA, a lot more for UNIX.
5412 */ 5411 */
5413 for (ptr = retval + fnamelen; ptr >= retval; ptr--) 5412 for (ptr = retval + fnamelen; ptr >= retval; mb_ptr_back(retval, ptr))
5414 { 5413 {
5415 #ifndef RISCOS 5414 #ifndef RISCOS
5416 if (*ext == '.' 5415 if (*ext == '.'
5417 #ifdef USE_LONG_FNAME 5416 #ifdef USE_LONG_FNAME
5418 && (!USE_LONG_FNAME || shortname) 5417 && (!USE_LONG_FNAME || shortname)