--- main.c.orig 2005-01-10 13:31:28.000000000 -0800 +++ main.c 2005-02-21 14:38:49.000000000 -0800 @@ -40,6 +40,11 @@ public int secure; public int dohelp; public int more_mode = 0; +public int file_errors = 0; +public int unix2003_compat = 0; +public int add_newline = 0; +public char * active_dashp_command = NULL; +public char * dashp_commands = NULL; #if LOGFILE public int logfile = -1; @@ -78,6 +83,9 @@ char *s; extern char *__progname; + if (COMPAT_MODE("bin/more", "unix2003")) { + unix2003_compat = 1; + } #ifdef __EMX__ _response(&argc, &argv); _wildcard(&argc, &argv); @@ -129,7 +137,9 @@ init_option(); if (more_mode) { - scan_option("-E"); + if (!unix2003_compat) { + scan_option("-E"); + } scan_option("-m"); scan_option("-G"); scan_option("-f"); @@ -172,13 +182,19 @@ editproto = lgetenv("LESSEDIT"); if (editproto == NULL || *editproto == '\0') { - if (COMPAT_MODE("bin/more", "unix2003")) { + if (unix2003_compat) { editproto = "%E ?l+%l. %f"; } else { editproto = "%E ?lm+%lm. %f"; } } #endif + if (more_mode) { + if (unix2003_compat) { + /* If -n option appears, force screen size override */ + get_term(); + } + } /* * Call get_ifile with all the command line filenames @@ -232,11 +248,18 @@ { if (edit_stdin() == 0) cat_file(); + else + file_errors++; } else if (edit_first() == 0) { do { cat_file(); } while (edit_next(1) == 0); + } else + file_errors++; + if (file_errors) { + if (unix2003_compat) + quit(QUIT_ERROR); } quit(QUIT_OK); } @@ -254,16 +277,21 @@ #if TAGS if (tagoption != NULL || strcmp(tags, "-") == 0) { + int tags_skip_other_files = 1; /* * A -t option was given. * Verify that no filenames were also given. * Edit the file selected by the "tags" search, * and search for the proper line in the file. */ - if (nifile() > 0) - { - error("No filenames allowed with -t option", NULL_PARG); - quit(QUIT_ERROR); + if (unix2003_compat) { + tags_skip_other_files = 0; + } else { + if (nifile() > 0) + { + error("No filenames allowed with -t option", NULL_PARG); + quit(QUIT_ERROR); + } } findtag(tagoption); if (edit_tagfile()) /* Edit file which contains the tag */ @@ -276,7 +304,14 @@ if (initial_scrpos.pos == NULL_POSITION) quit(QUIT_ERROR); initial_scrpos.ln = jump_sline; - } else + if (!tags_skip_other_files) { + /* TBD: -t under unix2003 requires other files on + command line to be processed after tagfile, but + conformance tests do not test this feature + */ + } + } + else #endif if (nifile() == 0) { @@ -290,6 +325,10 @@ init(); commands(); + if (file_errors) { + if (unix2003_compat) + quit(QUIT_ERROR); + } quit(QUIT_OK); /*NOTREACHED*/ return (0);