diff --git a/ChangeLog b/ChangeLog index 5675cd3d53393def6ee3a03a2c6bcc466528f39f..85ee292b62a506fd167d8785901ff1a4ab83b30b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,9 @@ General - - removed skipping . and .. when tabulating matches. - Added the (char *) sizeof when allocating memory for the filename array (Rocco). + do_writeout() + - Now takes an argument so the string typed in can be retained + when calling the browser. do_browser() - Don't decrement longest by the length of path. Fixes crashes on entering various dirs (Rocco). @@ -40,6 +43,7 @@ General - mallocstrcpy() - Takes char pointers now instead of void (makes debugging a helluva lot easier) + - Duh, don't do anything if src == dest! - es.po: - Updates for file browser (Jordi). diff --git a/files.c b/files.c index f325166b32c1776591fc19ff4f97dd085287358b..1a1c2eeeb5511643aea0a4197cf3c5af770ec348 100644 --- a/files.c +++ b/files.c @@ -374,7 +374,7 @@ int write_file(char *name, int tmp) if (fd == -1) { if (!tmp && ISSET(TEMP_OPT)) { UNSET(TEMP_OPT); - return do_writeout(1); + return do_writeout(filename, 1); } statusbar(_("Could not open file for writing: %s"), strerror(errno)); @@ -391,7 +391,7 @@ int write_file(char *name, int tmp) if ((fd = mkstemp(buf)) == -1) { if (ISSET(TEMP_OPT)) { UNSET(TEMP_OPT); - return do_writeout(1); + return do_writeout(filename, 1); } statusbar(_("Could not open file for writing: %s"), strerror(errno)); @@ -495,15 +495,16 @@ int write_file(char *name, int tmp) return 1; } -int do_writeout(int exiting) +int do_writeout(char *path, int exiting) { int i = 0; #ifdef NANO_EXTRA static int did_cred = 0; #endif +fprintf(stderr, "answer = %s, path = %s\n", answer, path); - answer = mallocstrcpy(answer, filename); + answer = mallocstrcpy(answer, path); if ((exiting) && (ISSET(TEMP_OPT))) { if (filename[0]) { @@ -532,8 +533,11 @@ int do_writeout(int exiting) if (tmp != NULL) answer = mallocstrcpy(answer, tmp); - else - return do_writeout(exiting); + else { +fprintf(stderr, "Answer = %s\n", answer); + + return do_writeout(answer, exiting); + } } #endif @@ -572,7 +576,7 @@ int do_writeout(int exiting) int do_writeout_void(void) { - return do_writeout(0); + return do_writeout(filename, 0); } #ifndef DISABLE_TABCOMP diff --git a/nano.c b/nano.c index 8370de538e7067a341d4556817ba95526676f3a5..dc775d600fc307c5f46598c15d04beb6c1c512bf 100644 --- a/nano.c +++ b/nano.c @@ -1421,7 +1421,7 @@ int do_exit(void) #endif if (i == 1) { - if (do_writeout(1) > 0) + if (do_writeout(filename, 1) > 0) finish(0); } else if (i == 0) finish(0); diff --git a/proto.h b/proto.h index 96965dde1a77ea9d237d16268643209dddb033aa..c9709701955d308d5a4b41e5748d738e9d7f0b9e 100644 --- a/proto.h +++ b/proto.h @@ -81,7 +81,7 @@ int do_uncut_text(void); int no_help(void); int renumber_all(void); int open_file(char *filename, int insert, int quiet); -int do_writeout(int exiting); +int do_writeout(char *path, int exiting); int do_gotoline(long defline); int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx, int wholewords, int *i); diff --git a/utils.c b/utils.c index f624a103810ec9ed0389c7769b4d8592e7290eab..a13964198fa8c9a9eb4ea8dfaba8b655a9e09d43 100644 --- a/utils.c +++ b/utils.c @@ -126,6 +126,10 @@ void *nrealloc(void *ptr, size_t howmuch) void *mallocstrcpy(char *dest, char *src) { + + if (src == dest) + return src; + if (dest != NULL) free(dest);