From 9fd9a3d91ea2dea1d846a462e2778b8f69a57330 Mon Sep 17 00:00:00 2001 From: Gunnar Ritter Date: Thu, 17 Feb 2005 14:48:49 +0000 Subject: [PATCH] * When the name of a nonexisting file is given with the 'edit' ex command, the command now succeeds and prints a "[New file]" message. --- Changes | 5 ++++- ex_addr.c | 15 +++++++++++---- ex_io.c | 7 +++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Changes b/Changes index 4901874..e1b209f 100644 --- a/Changes +++ b/Changes @@ -17,7 +17,8 @@ Release ... * The argument to the -w option is correctly recognized now. * If the SHELL environment variable is set to the empty string, it is now ignored. -* A non-null exit status is now returned if a file could not be opened. +* A non-null exit status is now returned if a file could not be opened, or + if an invalid address is given for a command. * If the match for a substitution is of length zero, a line overflow is now avoided when compiled with the 'UNIX(R) Regular Expression Library'. * When moving left while the cursor is positioned over a multicolumn @@ -30,6 +31,8 @@ Release ... processed first, i.e. the command is executed at the position where the tag was found. * The -w option now also sets the scroll size for the 'z' command. +* When the name of a nonexisting file is given with the 'edit' ex command, + the command now succeeds and prints a "[New file]" message. Release 1/19/05 * The last release erroneously made 'X' work like 'x' in visual mode. It now diff --git a/ex_addr.c b/ex_addr.c index 225eb9c..ffd8db8 100644 --- a/ex_addr.c +++ b/ex_addr.c @@ -73,7 +73,7 @@ #ifndef lint #ifdef DOSCCS -static char sccsid[] = "@(#)ex_addr.c 1.9 (gritter) 11/23/04"; +static char sccsid[] = "@(#)ex_addr.c 1.10 (gritter) 2/17/05"; #endif #endif /* not lint */ @@ -123,6 +123,7 @@ setdot1(void) addr1 = addr2 = dot; if (addr1 > addr2) { notempty(); + failed = 1; error(catgets(catd, 1, 6, "Addr1 > addr2|First address exceeds second")); } @@ -197,9 +198,11 @@ void setnoaddr(void) { - if (addr2 != 0) + if (addr2 != 0) { + failed = 1; error(catgets(catd, 1, 8, "No address allowed@on this command")); + } } /* @@ -366,12 +369,16 @@ error(catgets(catd, 1, 11, "No match to TOP|Address search hit TOP without match if (addr != zero) notempty(); addr += lastsign; - if (addr < zero) + if (addr < zero) { + failed = 1; error(catgets(catd, 1, 15, "Negative address@- first buffer line is 1")); - if (addr > dol) + } + if (addr > dol) { + failed = 1; error(catgets(catd, 1, 16, "Not that many lines@in buffer")); + } return (addr); } } diff --git a/ex_io.c b/ex_io.c index fa5a29b..4d9c3db 100644 --- a/ex_io.c +++ b/ex_io.c @@ -73,7 +73,7 @@ #ifndef lint #ifdef DOSCCS -static char sccsid[] = "@(#)ex_io.c 1.38 (gritter) 2/13/05"; +static char sccsid[] = "@(#)ex_io.c 1.39 (gritter) 2/17/05"; #endif #endif @@ -421,8 +421,11 @@ rop(int c) * If the user just did "ex foo" he is probably * creating a new file. Don't be an error, since * this is ugly, and it screws up the + option. + * + * POSIX.2 specifies that this be done for all + * "edit" commands, not just for the first one. */ - if (!seenprompt) { + if (1 || !seenprompt) { printf(catgets(catd, 1, 90, " [New file]")); noonl(); return;