command.c.diff2   [plain text]


--- command.c.orig	2005-02-17 09:00:05.000000000 -0800
+++ command.c	2005-02-21 17:22:18.000000000 -0800
@@ -55,6 +55,11 @@
 #endif
 extern int screen_trashed;	/* The screen has been overwritten */
 extern int shift_count;
+extern int file_errors;
+extern int unix2003_compat;
+extern int add_newline;
+extern char * active_dashp_command;
+extern int display_next_file_or_exit;
 
 static char ungot[UNGOT_SIZE];
 static char *ungotp = NULL;
@@ -217,7 +222,14 @@
 	case A_EXAMINE:
 		if (secure)
 			break;
-		edit_list(cbuf);
+		if (edit_list(cbuf)) {
+			/* means cbuf is empty, so it's the current file */
+			if (unix2003_compat) {
+				/* Test 114: expects :e to reset linenum */
+				number = 1;
+				jump_back(number);
+			}
+		}
 #if TAGS
 		/* If tag structure is loaded then clean it up. */
 		cleantags();
@@ -468,6 +480,9 @@
 		 *	*  Toggle the PAST_EOF flag
 		 *	@  Toggle the FIRST_FILE flag
 		 */
+		if (active_dashp_command) {
+			add_newline = 1;
+		}
 		if (len_cmdbuf() > 0)
 			/*
 			 * Only works for the first char of the pattern.
@@ -608,7 +623,12 @@
 	if ((quit_at_eof == OPT_ONPLUS || quit_if_one_screen) &&
 	    hit_eof && !(ch_getflags() & CH_HELPFILE) && 
 	    next_ifile(curr_ifile) == NULL_IFILE)
+		{
+		if (file_errors)
+			if (unix2003_compat)
+				quit(QUIT_ERROR);
 		quit(QUIT_OK);
+		}
 	quit_if_one_screen = FALSE;
 #if 0 /* This doesn't work well because some "te"s clear the screen. */
 	/*
@@ -854,7 +874,11 @@
 	char *tagfile;
 
 	search_type = SRCH_FORW;
-	wscroll = (sc_height + 1) / 2;
+	if (unix2003_compat) {
+		wscroll = (sc_height) / 2;
+	} else {
+		wscroll = (sc_height + 1) / 2;
+	}
 	newaction = A_NOACTION;
 
 	for (;;)
@@ -974,6 +998,7 @@
 		if (action != A_PREFIX)
 			cmd_reset();
 
+		display_next_file_or_exit = 0;
 		switch (action)
 		{
 		case A_DIGIT:
@@ -994,6 +1019,7 @@
 			/*
 			 * Forward one screen.
 			 */
+			display_next_file_or_exit = 1;
 			if (number <= 0)
 				number = get_swindow();
 			cmd_exec();
@@ -1023,6 +1049,7 @@
 			/*
 			 * Forward N (default 1) line.
 			 */
+			display_next_file_or_exit = 1;
 			if (number <= 0)
 				number = 1;
 			cmd_exec();
@@ -1101,6 +1128,7 @@
 			 * Forward N lines 
 			 * (default same as last 'd' or 'u' command).
 			 */
+			display_next_file_or_exit = 1;
 			if (number > 0)
 				wscroll = (int) number;
 			cmd_exec();
@@ -1221,6 +1249,9 @@
 			}
 			if (extra != NULL)
 				quit(*extra);
+			if (file_errors)
+				if (unix2003_compat)
+					quit(QUIT_ERROR);
 			quit(QUIT_OK);
 			break;