=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/prompt.c,v retrieving revision 1.11 retrieving revision 1.12 diff -c -r1.11 -r1.12 *** src/usr.bin/less/prompt.c 2010/08/09 20:40:08 1.11 --- src/usr.bin/less/prompt.c 2011/09/16 18:12:09 1.12 *************** *** 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. *************** *** 22,28 **** #include "position.h" extern int pr_type; - extern int hit_eof; extern int new_file; extern int sc_width; extern int so_s_width, so_e_width; --- 22,27 ---- *************** *** 30,35 **** --- 29,35 ---- extern int hshift; extern int sc_height; extern int jump_sline; + extern int less_is_more; extern IFILE curr_ifile; #if EDITOR extern char *editor; *************** *** 164,170 **** POSITION pos; pos = position(where); ! while (pos == NULL_POSITION && where >= 0 && where < sc_height) pos = position(++where); if (pos == NULL_POSITION) pos = ch_length(); --- 164,170 ---- POSITION pos; pos = position(where); ! while (pos == NULL_POSITION && where >= 0 && where < sc_height-1) pos = position(++where); if (pos == NULL_POSITION) pos = ch_length(); *************** *** 193,206 **** case 'c': return (hshift != 0); case 'e': /* At end of file? */ ! return (hit_eof); case 'f': /* Filename known? */ return (strcmp(get_filename(curr_ifile), "-") != 0); case 'l': /* Line number known? */ case 'd': /* Same as l */ return (linenums); case 'L': /* Final line number known? */ ! case 'D': /* Same as L */ return (linenums && ch_length() != NULL_POSITION); case 'm': /* More than one file? */ #if TAGS --- 193,206 ---- case 'c': return (hshift != 0); case 'e': /* At end of file? */ ! return (eof_displayed()); case 'f': /* Filename known? */ return (strcmp(get_filename(curr_ifile), "-") != 0); case 'l': /* Line number known? */ case 'd': /* Same as l */ return (linenums); case 'L': /* Final line number known? */ ! case 'D': /* Final page number known? */ return (linenums && ch_length() != NULL_POSITION); case 'm': /* More than one file? */ #if TAGS *************** *** 254,259 **** --- 254,262 ---- LINENUM last_linenum; IFILE h; + #undef PAGE_NUM + #define PAGE_NUM(linenum) ((((linenum) - 1) / (sc_height - 1)) + 1) + switch (c) { case 'b': /* Current byte offset */ *************** *** 269,285 **** case 'd': /* Current page number */ linenum = currline(where); if (linenum > 0 && sc_height > 1) ! ap_linenum(((linenum - 1) / (sc_height - 1)) + 1); else ap_quest(); break; ! case 'D': /* Last page number */ len = ch_length(); ! if (len == NULL_POSITION || len == ch_zero() || ! (linenum = find_linenum(len)) <= 0) ap_quest(); else ! ap_linenum(((linenum - 1) / (sc_height - 1)) + 1); break; #if EDITOR case 'E': /* Editor name */ --- 272,297 ---- case 'd': /* Current page number */ linenum = currline(where); if (linenum > 0 && sc_height > 1) ! ap_linenum(PAGE_NUM(linenum)); else ap_quest(); break; ! case 'D': /* Final page number */ ! /* Find the page number of the last byte in the file (len-1). */ len = ch_length(); ! if (len == NULL_POSITION) ap_quest(); + else if (len == 0) + /* An empty file has no pages. */ + ap_linenum(0); else ! { ! linenum = find_linenum(len - 1); ! if (linenum <= 0) ! ap_quest(); ! else ! ap_linenum(PAGE_NUM(linenum)); ! } break; #if EDITOR case 'E': /* Editor name */ *************** *** 289,294 **** --- 301,309 ---- case 'f': /* File name */ ap_str(get_filename(curr_ifile)); break; + case 'F': /* Last component of file name */ + ap_str(last_component(get_filename(curr_ifile))); + break; case 'i': /* Index into list of files */ #if TAGS if (ntags()) *************** *** 519,525 **** } if (mp == message) ! return (NULL); if (maxwidth > 0 && mp >= message + maxwidth) { /* --- 534,540 ---- } if (mp == message) ! return (""); if (maxwidth > 0 && mp >= message + maxwidth) { /* *************** *** 550,557 **** pr_string() { char *prompt; ! prompt = pr_expand(prproto[pr_type], sc_width-so_s_width-so_e_width-2); new_file = 0; return (prompt); } --- 565,576 ---- pr_string() { char *prompt; + int type; ! type = (!less_is_more) ? pr_type : pr_type ? 0 : 1; ! prompt = pr_expand((ch_getflags() & CH_HELPFILE) ? ! hproto : prproto[type], ! sc_width-so_s_width-so_e_width-2); new_file = 0; return (prompt); }