=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/main.c,v retrieving revision 1.10 retrieving revision 1.11 diff -c -r1.10 -r1.11 *** src/usr.bin/less/main.c 2010/07/03 16:29:46 1.10 --- src/usr.bin/less/main.c 2011/09/16 18:12:09 1.11 *************** *** 1,5 **** /* ! * Copyright (C) 1984-2002 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. --- 1,5 ---- /* ! * Copyright (C) 1984-2011 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. *************** *** 31,37 **** public char * progname; public int quitting; public int secure; ! public int ismore; #if LOGFILE public int logfile = -1; --- 31,37 ---- public char * progname; public int quitting; public int secure; ! public int dohelp; #if LOGFILE public int logfile = -1; *************** *** 54,63 **** static char consoleTitle[256]; #endif extern int missing_cap; extern int know_dumb; - extern char * __progname; /* * Entry point. --- 54,65 ---- static char consoleTitle[256]; #endif + extern int less_is_more; extern int missing_cap; extern int know_dumb; + extern int quit_if_one_screen; + extern int pr_type; /* * Entry point. *************** *** 109,130 **** * Process command line arguments and LESS environment arguments. * Command line arguments override environment arguments. */ - ismore = !strcmp(__progname, "more"); is_tty = isatty(1); get_term(); init_cmds(); - init_prompt(); init_charset(); init_line(); init_option(); ! if (ismore) { ! scan_option("-E"); scan_option("-G"); scan_option("-L"); ! scan_option("-m"); ! s = lgetenv("MORE"); ! } else ! s = lgetenv("LESS"); if (s != NULL) scan_option(save(s)); --- 111,146 ---- * Process command line arguments and LESS environment arguments. * Command line arguments override environment arguments. */ is_tty = isatty(1); get_term(); init_cmds(); init_charset(); init_line(); + init_cmdhist(); init_option(); ! init_search(); ! ! /* ! * If the name of the executable program is "more", ! * act like LESS_IS_MORE is set. ! */ ! for (s = progname + strlen(progname); s > progname; s--) ! { ! if (s[-1] == PATHNAME_SEP[0]) ! break; ! } ! if (strcmp(s, "more") == 0) ! less_is_more = 1; ! ! init_prompt(); ! ! if (less_is_more) { scan_option("-G"); scan_option("-L"); ! scan_option("-X"); ! } ! ! s = lgetenv(less_is_more ? "MORE" : "LESS"); if (s != NULL) scan_option(save(s)); *************** *** 149,154 **** --- 165,173 ---- quit(QUIT_OK); } + if (less_is_more && get_quit_at_eof()) + quit_if_one_screen = TRUE; + #if EDITOR editor = lgetenv("VISUAL"); if (editor == NULL || *editor == '\0') *************** *** 167,172 **** --- 186,195 ---- * to "register" them with the ifile system. */ ifile = NULL_IFILE; + #if !SMALL + if (dohelp) + ifile = get_ifile(HELPFILE, ifile); + #endif /* !SMALL */ while (argc-- > 0) { char *filename; *************** *** 221,227 **** quit(QUIT_OK); } ! if (missing_cap && !know_dumb && !ismore) error("WARNING: terminal is not fully functional", NULL_PARG); init_mark(); open_getchr(); --- 244,250 ---- quit(QUIT_OK); } ! if (missing_cap && !know_dumb && !less_is_more) error("WARNING: terminal is not fully functional", NULL_PARG); init_mark(); open_getchr(); *************** *** 284,292 **** char *s; { register char *p; ! size_t len; - len = strlen(s)+1, sizeof(char); p = (char *) ecalloc(len, sizeof(char)); strlcpy(p, s, len); return (p); --- 307,314 ---- char *s; { register char *p; ! size_t len = strlen(s) + 1; p = (char *) ecalloc(len, sizeof(char)); strlcpy(p, s, len); return (p); *************** *** 324,330 **** return (s); } ! #ifndef SMALL_PROGRAM /* * See how many characters of two strings are identical. * If uppercase is true, the first string must begin with an uppercase --- 346,352 ---- return (s); } ! #if GNU_OPTIONS /* * See how many characters of two strings are identical. * If uppercase is true, the first string must begin with an uppercase *************** *** 345,365 **** c = *ps; if (uppercase) { ! if (len == 0 && SIMPLE_IS_LOWER(c)) return (-1); ! if (SIMPLE_IS_UPPER(c)) ! c = SIMPLE_TO_LOWER(c); } sc = *s; ! if (len > 0 && SIMPLE_IS_UPPER(sc)) ! sc = SIMPLE_TO_LOWER(sc); if (c != sc) break; len++; } return (len); } ! #endif /* SMALL_PROGRAM */ /* * Exit the program. --- 367,387 ---- c = *ps; if (uppercase) { ! if (len == 0 && ASCII_IS_LOWER(c)) return (-1); ! if (ASCII_IS_UPPER(c)) ! c = ASCII_TO_LOWER(c); } sc = *s; ! if (len > 0 && ASCII_IS_UPPER(sc)) ! sc = ASCII_TO_LOWER(sc); if (c != sc) break; len++; } return (len); } ! #endif /* GNU_OPTIONS */ /* * Exit the program. *************** *** 380,385 **** --- 402,408 ---- save_status = status; quitting = 1; edit((char*)NULL); + save_cmdhist(); if (any_display && is_tty) clear_bot(); deinit(); *************** *** 394,400 **** */ close(2); #endif ! #if WIN32 SetConsoleTitle(consoleTitle); #endif close_getchr(); --- 417,423 ---- */ close(2); #endif ! #ifdef WIN32 SetConsoleTitle(consoleTitle); #endif close_getchr();