Module Name: src Committed By: tron Date: Sun Jul 3 20:14:13 UTC 2011
Modified Files: src/external/bsd/less/dist: brac.c ch.c charset.c cmdbuf.c command.c decode.c edit.c filename.c forwback.c funcs.h help.c ifile.c less.h lessecho.c lesskey.c lglob.h line.c linenum.c lsystem.c main.c option.c option.h opttbl.c os.c output.c pattern.h position.c prompt.c screen.c search.c signal.c tags.c Log Message: Apply NetBSD specific patches, mostly related to behaviour of less(1) as more(1). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/bsd/less/dist/brac.c \ src/external/bsd/less/dist/ch.c src/external/bsd/less/dist/charset.c \ src/external/bsd/less/dist/cmdbuf.c src/external/bsd/less/dist/command.c \ src/external/bsd/less/dist/decode.c src/external/bsd/less/dist/edit.c \ src/external/bsd/less/dist/filename.c \ src/external/bsd/less/dist/forwback.c src/external/bsd/less/dist/funcs.h \ src/external/bsd/less/dist/help.c src/external/bsd/less/dist/ifile.c \ src/external/bsd/less/dist/less.h src/external/bsd/less/dist/lessecho.c \ src/external/bsd/less/dist/lesskey.c src/external/bsd/less/dist/lglob.h \ src/external/bsd/less/dist/line.c src/external/bsd/less/dist/linenum.c \ src/external/bsd/less/dist/lsystem.c src/external/bsd/less/dist/main.c \ src/external/bsd/less/dist/option.c src/external/bsd/less/dist/option.h \ src/external/bsd/less/dist/opttbl.c src/external/bsd/less/dist/os.c \ src/external/bsd/less/dist/output.c src/external/bsd/less/dist/pattern.h \ src/external/bsd/less/dist/position.c src/external/bsd/less/dist/prompt.c \ src/external/bsd/less/dist/screen.c src/external/bsd/less/dist/search.c \ src/external/bsd/less/dist/signal.c src/external/bsd/less/dist/tags.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/bsd/less/dist/brac.c diff -u src/external/bsd/less/dist/brac.c:1.2 src/external/bsd/less/dist/brac.c:1.3 --- src/external/bsd/less/dist/brac.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/brac.c Sun Jul 3 20:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: brac.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: brac.c,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -36,9 +36,7 @@ register int c; register int nest; POSITION pos; - int (*chget)(); - - extern int ch_forw_get(), ch_back_get(); + int (*chget) __P((void)); /* * Seek to the line containing the open bracket. Index: src/external/bsd/less/dist/ch.c diff -u src/external/bsd/less/dist/ch.c:1.2 src/external/bsd/less/dist/ch.c:1.3 --- src/external/bsd/less/dist/ch.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/ch.c Sun Jul 3 20:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ch.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: ch.c,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -140,7 +140,9 @@ extern char *namelogfile; #endif -static int ch_addbuf(); +static int ch_addbuf __P((void)); +static int buffered __P((BLOCKNUM)); +static void ch_delbufs __P((void)); /* Index: src/external/bsd/less/dist/charset.c diff -u src/external/bsd/less/dist/charset.c:1.2 src/external/bsd/less/dist/charset.c:1.3 --- src/external/bsd/less/dist/charset.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/charset.c Sun Jul 3 20:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: charset.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: charset.c,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -117,6 +117,9 @@ static char *utfbinfmt = NULL; public int binattr = AT_STANDOUT; +static void ichardef __P((char *)); +static int icharset __P((char *, int)); +static void ilocale __P((void)); /* * Define a charset, given a description string. Index: src/external/bsd/less/dist/cmdbuf.c diff -u src/external/bsd/less/dist/cmdbuf.c:1.2 src/external/bsd/less/dist/cmdbuf.c:1.3 --- src/external/bsd/less/dist/cmdbuf.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/cmdbuf.c Sun Jul 3 20:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cmdbuf.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: cmdbuf.c,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -22,6 +22,9 @@ #if HAVE_STAT #include <sys/stat.h> #endif +#if HAVE_ERRNO_H +#include <errno.h> +#endif extern int sc_width; extern int utf_mode; @@ -34,7 +37,7 @@ static int literal; /* Next input char should not be interpreted */ #if TAB_COMPLETE_FILENAME -static int cmd_complete(); +static int cmd_complete __P((int)); /* * These variables are statics used by cmd_complete. */ @@ -46,8 +49,24 @@ static struct textlist tk_tlist; #endif -static int cmd_left(); -static int cmd_right(); +static void cmd_repaint __P((char *)); +static void cmd_home __P((void)); +static void cmd_lshift __P((void)); +static void cmd_rshift __P((void)); +static int cmd_right __P((void)); +static int cmd_left __P((void)); +static int cmd_ichar __P((char *, int)); +static int cmd_erase __P((void)); +static int cmd_delete __P((void)); +static int cmd_werase __P((void)); +static int cmd_wdelete __P((void)); +static int cmd_kill __P((void)); +static int cmd_updown __P((int)); +static int cmd_edit __P((int)); +static int cmd_istr __P((char *)); +static char *delimit_word __P((void)); +static void init_compl __P((void)); +static char *next_compl __P((int, char *)); #if SPACES_IN_FILENAMES public char openquote = '"'; @@ -930,7 +949,7 @@ static char * delimit_word() { - char *word; + char *word = NULL; #if SPACES_IN_FILENAMES char *p; int delim_quoted = 0; @@ -1374,10 +1393,20 @@ char *filename; FILE *f; char *p; +#ifdef HAVE_STAT + struct stat st; +#endif filename = histfile_name(); if (filename == NULL) return; +#ifdef HAVE_STAT + /* ignore devices/fifos; allow symlinks */ + if (stat(filename, &st) < 0) + return; + if (!S_ISREG(st.st_mode)) + return; +#endif f = fopen(filename, "r"); free(filename); if (f == NULL) Index: src/external/bsd/less/dist/command.c diff -u src/external/bsd/less/dist/command.c:1.2 src/external/bsd/less/dist/command.c:1.3 --- src/external/bsd/less/dist/command.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/command.c Sun Jul 3 20:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: command.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: command.c,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -56,6 +56,10 @@ extern int shift_count; extern int oldbot; extern int forw_prompt; +extern int be_helpful; +extern int more_mode; + +static int helpprompt; #if SHELL_ESCAPE static char *shellcmd = NULL; /* For holding last shell command for "!!" */ @@ -478,21 +482,25 @@ * Certain characters as the first char of * the pattern have special meaning: * ! Toggle the NO_MATCH flag - * * Toggle the PAST_EOF flag - * @ Toggle the FIRST_FILE flag + * * Toggle the PAST_EOF flag (less extension) + * @ Toggle the FIRST_FILE flag (less extension) */ if (len_cmdbuf() > 0) return (NO_MCA); switch (c) { - case CONTROL('E'): /* ignore END of file */ case '*': + if (more_mode) + break; + case CONTROL('E'): /* ignore END of file */ if (mca != A_FILTER) flag = SRCH_PAST_EOF; break; - case CONTROL('F'): /* FIRST file */ case '@': + if (more_mode) + break; + case CONTROL('F'): /* FIRST file */ if (mca != A_FILTER) flag = SRCH_FIRST_FILE; break; @@ -739,16 +747,23 @@ clear_bot(); clear_cmd(); forw_prompt = 0; - p = pr_string(); - if (is_filtering()) - putstr("& "); - if (p == NULL || *p == '\0') - putchr(':'); - else - { + if (helpprompt) { at_enter(AT_STANDOUT); - putstr(p); + putstr("[Press 'h' for instructions.]"); at_exit(); + helpprompt = 0; + } else { + p = pr_string(); + if (is_filtering()) + putstr("& "); + if (p == NULL || *p == '\0') + putchr(':'); + else + { + at_enter(AT_STANDOUT); + putstr(p); + at_exit(); + } } clear_eol(); } @@ -1758,7 +1773,10 @@ break; default: - bell(); + if (be_helpful) + helpprompt = 1; + else + bell(); break; } } Index: src/external/bsd/less/dist/decode.c diff -u src/external/bsd/less/dist/decode.c:1.2 src/external/bsd/less/dist/decode.c:1.3 --- src/external/bsd/less/dist/decode.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/decode.c Sun Jul 3 20:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: decode.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: decode.c,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -225,6 +225,11 @@ static struct tablelist *list_var_tables = NULL; static struct tablelist *list_sysvar_tables = NULL; +static int add_cmd_table __P((struct tablelist **, char *, int)); +static int cmd_decode __P((struct tablelist *, char *, char **)); +static int gint __P((char **)); +static int old_lesskey __P((char *, int)); +static int new_lesskey __P((char *, int, int)); /* * Expand special key abbreviations in a command table. @@ -749,7 +754,7 @@ { int action; int nch; - char *s; + char *s = NULL; /* XXX: GCC */ char usercmd[MAX_CMDLEN+1]; /* Index: src/external/bsd/less/dist/edit.c diff -u src/external/bsd/less/dist/edit.c:1.2 src/external/bsd/less/dist/edit.c:1.3 --- src/external/bsd/less/dist/edit.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/edit.c Sun Jul 3 20:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: edit.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: edit.c,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -29,7 +29,7 @@ extern IFILE curr_ifile; extern IFILE old_ifile; extern struct scrpos initial_scrpos; -extern void constant *ml_examine; +extern void *constant ml_examine; #if SPACES_IN_FILENAMES extern char openquote; extern char closequote; @@ -50,6 +50,11 @@ static void *curr_altpipe; +static void close_file __P((void)); +static int edit_istep __P((IFILE, int, int)); +static int edit_inext __P((IFILE, int)); +static int edit_iprev __P((IFILE, int)); + /* * Textlist functions deal with a list of words separated by spaces. * init_textlist sets up a textlist structure. @@ -322,7 +327,7 @@ * It looks like a bad file. Don't try to open it. */ error("%s", &parg); - free(parg.p_string); + free((void *)parg.p_string); err1: if (alt_filename != NULL) { @@ -352,7 +357,7 @@ */ parg.p_string = errno_message(filename); error("%s", &parg); - free(parg.p_string); + free((void *)parg.p_string); goto err1; } else { @@ -744,7 +749,8 @@ */ filename = shell_unquote(filename); exists = open(filename, OPEN_READ); - close(exists); + if (exists >= 0) + close(exists); exists = (exists >= 0); /* Index: src/external/bsd/less/dist/filename.c diff -u src/external/bsd/less/dist/filename.c:1.2 src/external/bsd/less/dist/filename.c:1.3 --- src/external/bsd/less/dist/filename.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/filename.c Sun Jul 3 20:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: filename.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: filename.c,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -62,6 +62,12 @@ extern char closequote; #endif +static char *dirfile __P((char *, char *)); +static POSITION seek_filesize __P((int)); +static char *readfd __P((FILE *)); +static int metachar __P((int)); +static FILE *shellcmd __P((char *)); + /* * Remove quotes around a filename. */ Index: src/external/bsd/less/dist/forwback.c diff -u src/external/bsd/less/dist/forwback.c:1.2 src/external/bsd/less/dist/forwback.c:1.3 --- src/external/bsd/less/dist/forwback.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/forwback.c Sun Jul 3 20:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: forwback.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: forwback.c,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -28,6 +28,7 @@ extern int top_scroll; extern int quiet; extern int sc_width, sc_height; +extern int more_mode; extern int plusoption; extern int forw_scroll; extern int back_scroll; @@ -39,6 +40,9 @@ extern char *tagoption; #endif +static void eof_bell __P((void)); +static void eof_check __P((void)); + /* * Sound the bell to indicate user is trying to move past end of file. */ @@ -240,7 +244,8 @@ * start the display after the beginning of the file, * and it is not appropriate to squish in that case. */ - if (first_time && pos == NULL_POSITION && !top_scroll && + if ((first_time || more_mode) && + pos == NULL_POSITION && !top_scroll && #if TAGS tagoption == NULL && #endif Index: src/external/bsd/less/dist/funcs.h diff -u src/external/bsd/less/dist/funcs.h:1.2 src/external/bsd/less/dist/funcs.h:1.3 --- src/external/bsd/less/dist/funcs.h:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/funcs.h Sun Jul 3 20:14:12 2011 @@ -1,10 +1,10 @@ -/* $NetBSD: funcs.h,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: funcs.h,v 1.3 2011/07/03 20:14:12 tron Exp $ */ public char * save (); public VOID_POINTER ecalloc (); public char * skipsp (); public int sprefix (); - public void quit (); + public void quit () __attribute__((__noreturn__)); public void raw_mode (); public void scrsize (); public char * special_key_str (); Index: src/external/bsd/less/dist/help.c diff -u src/external/bsd/less/dist/help.c:1.2 src/external/bsd/less/dist/help.c:1.3 --- src/external/bsd/less/dist/help.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/help.c Sun Jul 3 20:14:12 2011 @@ -1,7 +1,10 @@ -/* $NetBSD: help.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: help.c,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* This file was generated by mkhelp from less.hlp */ #include "less.h" +#ifdef SMALL +constant char helpdata[] = "\nNo help available\n"; +#else constant char helpdata[] = { '\n', ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','S','\b','S','U','\b','U','M','\b','M','M','\b','M','A','\b','A','R','\b','R','Y','\b','Y',' ','O','\b','O','F','\b','F',' ','L','\b','L','E','\b','E','S','\b','S','S','\b','S',' ','C','\b','C','O','\b','O','M','\b','M','M','\b','M','A','\b','A','N','\b','N','D','\b','D','S','\b','S','\n', @@ -235,4 +238,5 @@ '\n', '\n', 0 }; +#endif constant int size_helpdata = sizeof(helpdata) - 1; Index: src/external/bsd/less/dist/ifile.c diff -u src/external/bsd/less/dist/ifile.c:1.2 src/external/bsd/less/dist/ifile.c:1.3 --- src/external/bsd/less/dist/ifile.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/ifile.c Sun Jul 3 20:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: ifile.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: ifile.c,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -51,6 +51,12 @@ { NULL_POSITION, 0 } }; static int ifiles = 0; +static void incr_index __P((struct ifile *, int)); +static void link_ifile __P((struct ifile *, struct ifile *)); +static void unlink_ifile __P((struct ifile *)); +static struct ifile *new_ifile __P((char *, struct ifile *)); +static struct ifile *find_ifile __P((char *)); + static void incr_index(p, incr) register struct ifile *p; Index: src/external/bsd/less/dist/less.h diff -u src/external/bsd/less/dist/less.h:1.2 src/external/bsd/less/dist/less.h:1.3 --- src/external/bsd/less/dist/less.h:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/less.h Sun Jul 3 20:14:12 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: less.h,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: less.h,v 1.3 2011/07/03 20:14:12 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -300,7 +300,7 @@ typedef union parg { - char *p_string; + constant char *p_string; int p_int; LINENUM p_linenum; } PARG; Index: src/external/bsd/less/dist/lessecho.c diff -u src/external/bsd/less/dist/lessecho.c:1.2 src/external/bsd/less/dist/lessecho.c:1.3 --- src/external/bsd/less/dist/lessecho.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/lessecho.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: lessecho.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: lessecho.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -30,7 +30,7 @@ #include "less.h" -static char *version = "$Revision: 1.2 $"; +static char *version = "$Revision: 1.3 $"; static int quote_all = 0; static char openquote = '"'; @@ -40,6 +40,11 @@ static char metachars[64] = ""; static int num_metachars = 0; +static void pr_usage __P((void)); +static void pr_version __P((void)); +static void pr_error __P((char *)); +static long lstrtol __P((char *, int, char **)); + static void pr_usage() { Index: src/external/bsd/less/dist/lesskey.c diff -u src/external/bsd/less/dist/lesskey.c:1.2 src/external/bsd/less/dist/lesskey.c:1.3 --- src/external/bsd/less/dist/lesskey.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/lesskey.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: lesskey.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: lesskey.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -214,6 +214,8 @@ int linenum; int errors; +void terror(char *); + extern char version[]; void @@ -422,7 +424,7 @@ case 'e': ch = SK_END; break; case 'x': ch = SK_DELETE; break; default: - error("illegal char after \\k"); + terror("illegal char after \\k"); *pp = p+1; return (""); } @@ -519,7 +521,7 @@ { if (currtable->pbuffer >= currtable->buffer + MAX_USERCMD) { - error("too many commands"); + terror("too many commands"); exit(1); } *(currtable->pbuffer)++ = c; @@ -619,12 +621,12 @@ for (i = 0; currtable->names[i].cn_name != NULL; i++) if (strcmp(currtable->names[i].cn_name, actname) == 0) return (currtable->names[i].cn_action); - error("unknown action"); + terror("unknown action"); return (A_INVALID); } void -error(s) +terror(s) char *s; { fprintf(stderr, "line %d: %s\n", linenum, s); @@ -651,7 +653,7 @@ s = tstr(&p, 1); cmdlen += strlen(s); if (cmdlen > MAX_CMDLEN) - error("command too long"); + terror("command too long"); else add_cmd_str(s); } while (*p != ' ' && *p != '\t' && *p != '\0'); @@ -668,7 +670,7 @@ p = skipsp(p); if (*p == '\0') { - error("missing action"); + terror("missing action"); return; } actname = p; @@ -721,7 +723,7 @@ p = skipsp(p); if (*p++ != '=') { - error("missing ="); + terror("missing ="); return; } Index: src/external/bsd/less/dist/lglob.h diff -u src/external/bsd/less/dist/lglob.h:1.2 src/external/bsd/less/dist/lglob.h:1.3 --- src/external/bsd/less/dist/lglob.h:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/lglob.h Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: lglob.h,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: lglob.h,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -36,7 +36,7 @@ #else #if MSDOS_COMPILER==DJGPPC -#define DECL_GLOB_LIST(list) glob_t list; int i; +#define DECL_GLOB_LIST(list) glob_t list; size_t i; #define GLOB_LIST(filename,list) glob(filename,GLOB_NOCHECK,0,&list) #define GLOB_LIST_FAILED(list) 0 #define SCAN_GLOB_LIST(list,p) i = 0; i < list.gl_pathc; i++ Index: src/external/bsd/less/dist/line.c diff -u src/external/bsd/less/dist/line.c:1.2 src/external/bsd/less/dist/line.c:1.3 --- src/external/bsd/less/dist/line.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/line.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: line.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: line.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -42,10 +42,9 @@ static char *end_ansi_chars; static char *mid_ansi_chars; -static int attr_swidth(); -static int attr_ewidth(); -static int do_append(); - +static int attr_swidth(int); +static int attr_ewidth(int); +static int do_append(LWCHAR, char *, POSITION); extern int sigs; extern int bs_mode; extern int linenums; Index: src/external/bsd/less/dist/linenum.c diff -u src/external/bsd/less/dist/linenum.c:1.2 src/external/bsd/less/dist/linenum.c:1.3 --- src/external/bsd/less/dist/linenum.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/linenum.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linenum.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: linenum.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -72,6 +72,10 @@ extern int sc_height; extern int screen_trashed; +static void calcgap __P((struct linenum_info *)); +static void longloopmessage __P((void)); +static void longish __P((void)); + /* * Initialize the line number structures. */ Index: src/external/bsd/less/dist/lsystem.c diff -u src/external/bsd/less/dist/lsystem.c:1.2 src/external/bsd/less/dist/lsystem.c:1.3 --- src/external/bsd/less/dist/lsystem.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/lsystem.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: lsystem.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: lsystem.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -294,7 +294,6 @@ { register FILE *f; register int c; - extern FILE *popen(); /* * This is structured much like lsystem(). Index: src/external/bsd/less/dist/main.c diff -u src/external/bsd/less/dist/main.c:1.2 src/external/bsd/less/dist/main.c:1.3 --- src/external/bsd/less/dist/main.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/main.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: main.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -34,6 +34,7 @@ public int quitting; public int secure; public int dohelp; +public int more_mode = 0; #if LOGFILE public int logfile = -1; @@ -113,6 +114,9 @@ * Process command line arguments and LESS environment arguments. * Command line arguments override environment arguments. */ + if (strcmp(getprogname(), "more") == 0) + more_mode = 1; + is_tty = isatty(1); get_term(); init_cmds(); @@ -238,7 +242,7 @@ quit(QUIT_OK); } - if (missing_cap && !know_dumb) + if (missing_cap && !know_dumb && !more_mode) error("WARNING: terminal is not fully functional", NULL_PARG); init_mark(); open_getchr(); Index: src/external/bsd/less/dist/option.c diff -u src/external/bsd/less/dist/option.c:1.2 src/external/bsd/less/dist/option.c:1.3 --- src/external/bsd/less/dist/option.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/option.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: option.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: option.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -26,8 +26,9 @@ static struct loption *pendopt; public int plusoption = FALSE; -static char *optstring(); -static int flip_triple(); +static char *optstring __P((char *, char **, char *, char *)); +static int flip_triple __P((int, int)); +static void nostring __P((char *)); extern int screen_trashed; extern int less_is_more; @@ -448,6 +449,8 @@ { case BOOL: case TRIPLE: + if (*(o->ovar) < 0) + error("Negative option is invalid", NULL_PARG); /* * Print the odesc message. */ Index: src/external/bsd/less/dist/option.h diff -u src/external/bsd/less/dist/option.h:1.2 src/external/bsd/less/dist/option.h:1.3 --- src/external/bsd/less/dist/option.h:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/option.h Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: option.h,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: option.h,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -63,7 +63,8 @@ int otype; /* Type of the option */ int odefault; /* Default value */ int *ovar; /* Pointer to the associated variable */ - void (*ofunc)(); /* Pointer to special handling function */ + void (*ofunc) /* Pointer to special handling function */ + __P((int, char *)); char *odesc[3]; /* Description of each value */ }; Index: src/external/bsd/less/dist/opttbl.c diff -u src/external/bsd/less/dist/opttbl.c:1.2 src/external/bsd/less/dist/opttbl.c:1.3 --- src/external/bsd/less/dist/opttbl.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/opttbl.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: opttbl.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: opttbl.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -30,6 +30,7 @@ public int know_dumb; /* Don't complain about dumb terminals */ public int quit_at_eof; /* Quit after hitting end of file twice */ public int quit_if_one_screen; /* Quit if EOF on first screen */ +public int be_helpful; /* more(1) style -d */ public int squeeze; /* Squeeze multiple blank lines into one */ public int tabstop; /* Tab settings */ public int back_scroll; /* Repaint screen on backwards movement */ @@ -167,7 +168,15 @@ "Repaint by painting from top of screen" } }, +#if 1 { 'd', &d_optname, + BOOL, OPT_OFF, &be_helpful, NULL, + { "Be less helpful in prompts", + "Be helpful in prompts", + NULL } + }, +#endif + { -1, &d_optname, BOOL|NO_TOGGLE, OPT_OFF, &know_dumb, NULL, { "Assume intelligent terminal", Index: src/external/bsd/less/dist/os.c diff -u src/external/bsd/less/dist/os.c:1.2 src/external/bsd/less/dist/os.c:1.3 --- src/external/bsd/less/dist/os.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/os.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: os.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: os.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -63,6 +63,10 @@ extern int sigs; +#if !HAVE_STRERROR +static char *strerror __P((int)); +#endif + /* * Like read() system call, but is deliberately interruptible. * A call to intread() from a signal handler will interrupt @@ -235,7 +239,7 @@ errno_message(filename) char *filename; { - register char *p; + register const char *p; register char *m; int len; #if HAVE_ERRNO Index: src/external/bsd/less/dist/output.c diff -u src/external/bsd/less/dist/output.c:1.2 src/external/bsd/less/dist/output.c:1.3 --- src/external/bsd/less/dist/output.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/output.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: output.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: output.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -438,7 +438,7 @@ register char *fmt; PARG *parg; { - register char *s; + register constant char *s; register int col; col = 0; Index: src/external/bsd/less/dist/pattern.h diff -u src/external/bsd/less/dist/pattern.h:1.2 src/external/bsd/less/dist/pattern.h:1.3 --- src/external/bsd/less/dist/pattern.h:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/pattern.h Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pattern.h,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: pattern.h,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -13,7 +13,8 @@ #if HAVE_POSIX_REGCOMP #include <regex.h> #ifdef REG_EXTENDED -#define REGCOMP_FLAG REG_EXTENDED +extern int more_mode; +#define REGCOMP_FLAG (more_mode ? 0 : REG_EXTENDED) #else #define REGCOMP_FLAG 0 #endif Index: src/external/bsd/less/dist/position.c diff -u src/external/bsd/less/dist/position.c:1.2 src/external/bsd/less/dist/position.c:1.3 --- src/external/bsd/less/dist/position.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/position.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: position.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: position.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -109,6 +109,7 @@ pos_init() { struct scrpos scrpos; + scrpos.pos = scrpos.ln = 0; /* XXX: GCC */ if (sc_height <= table_size) return; Index: src/external/bsd/less/dist/prompt.c diff -u src/external/bsd/less/dist/prompt.c:1.2 src/external/bsd/less/dist/prompt.c:1.3 --- src/external/bsd/less/dist/prompt.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/prompt.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: prompt.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: prompt.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -57,7 +57,7 @@ static constant char more_proto[] = "--More--(?eEND ?x- Next\\: %x.:?pB%pB\\%:byte %bB?s/%s...%t)"; -public char *prproto[3]; +public char constant *prproto[3]; public char constant *eqproto = e_proto; public char constant *hproto = h_proto; public char constant *wproto = w_proto; @@ -65,6 +65,17 @@ static char message[PROMPT_SIZE]; static char *mp; +static void ap_pos __P((POSITION)); +static void ap_int __P((int)); +static void ap_str __P((char *)); +static void ap_char __P((int)); +static void ap_quest __P((void)); +static POSITION curr_byte __P((int)); +static int cond __P((int, int)); +static void protochar __P((int, int, int)); +static const char *skipcond __P((const char *)); +static const char *wherechar __P((const char *, int *)); + /* * Initialize the prompt prototype strings. */ @@ -100,10 +111,11 @@ * Append a character to the end of the message. */ static void -ap_char(c) - char c; +ap_char(i) + int i; { char buf[2]; + char c = (char)i; buf[0] = c; buf[1] = '\0'; @@ -395,9 +407,9 @@ * where to resume parsing the string. * We must keep track of nested IFs and skip them properly. */ - static char * + static const char * skipcond(p) - register char *p; + register const char *p; { register int iflevel; @@ -453,9 +465,9 @@ /* * Decode a char that represents a position on the screen. */ - static char * + static const char * wherechar(p, wp) - char *p; + const char *p; int *wp; { switch (*p) @@ -479,10 +491,10 @@ */ public char * pr_expand(proto, maxwidth) - char *proto; + const char *proto; int maxwidth; { - register char *p; + register const char *p; register int c; int where; Index: src/external/bsd/less/dist/screen.c diff -u src/external/bsd/less/dist/screen.c:1.2 src/external/bsd/less/dist/screen.c:1.3 --- src/external/bsd/less/dist/screen.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/screen.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: screen.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: screen.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -229,6 +229,8 @@ extern int no_back_scroll; extern int swindow; extern int no_init; +extern int quit_at_eof; +extern int more_mode; extern int no_keypad; extern int sigs; extern int wscroll; @@ -240,8 +242,10 @@ extern int hilite_search; #endif +#ifndef HAVE_TERMCAP_H extern char *tgetstr(); extern char *tgoto(); +#endif /* @@ -1210,11 +1214,21 @@ if (sc_e_keypad == NULL) sc_e_keypad = ""; - sc_init = ltgetstr("ti", &sp); + /* + * This loses for terminals with termcap entries with ti/te strings + * that switch to/from an alternate screen, and we're in quit_at_eof + * (eg, more(1)). + */ + if (quit_at_eof != OPT_ONPLUS && !more_mode) { + sc_init = ltgetstr("ti", &sp); + sc_deinit = ltgetstr("te", &sp); + } else { + sc_init = NULL; + sc_deinit = NULL; + } + if (sc_init == NULL) sc_init = ""; - - sc_deinit= ltgetstr("te", &sp); if (sc_deinit == NULL) sc_deinit = ""; Index: src/external/bsd/less/dist/search.c diff -u src/external/bsd/less/dist/search.c:1.2 src/external/bsd/less/dist/search.c:1.3 --- src/external/bsd/less/dist/search.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/search.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: search.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: search.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -701,7 +701,7 @@ char *cline; int line_len; LINENUM linenum; - char *sp, *ep; + char *sp = NULL, *ep = NULL; /* XXX: GCC */ int line_match; int cvt_ops; int cvt_len; Index: src/external/bsd/less/dist/signal.c diff -u src/external/bsd/less/dist/signal.c:1.2 src/external/bsd/less/dist/signal.c:1.3 --- src/external/bsd/less/dist/signal.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/signal.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: signal.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: signal.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -29,6 +29,12 @@ */ public int sigs; +static RETSIGTYPE u_interrupt __P((int)); +static RETSIGTYPE stop __P((int)); +#if MSDOS_COMPILER==WIN32C +static BOOL WINAPI wbreak_handler __P((DWORD)); +#endif + extern int sc_width, sc_height; extern int screen_trashed; extern int lnloop; Index: src/external/bsd/less/dist/tags.c diff -u src/external/bsd/less/dist/tags.c:1.2 src/external/bsd/less/dist/tags.c:1.3 --- src/external/bsd/less/dist/tags.c:1.2 Sun Jul 3 19:51:26 2011 +++ src/external/bsd/less/dist/tags.c Sun Jul 3 20:14:13 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tags.c,v 1.2 2011/07/03 19:51:26 tron Exp $ */ +/* $NetBSD: tags.c,v 1.3 2011/07/03 20:14:13 tron Exp $ */ /* * Copyright (C) 1984-2011 Mark Nudelman @@ -61,12 +61,6 @@ * findctag() uses either pattern (in which case line number is 0), * or line number (in which case pattern is NULL). */ -struct taglist { - struct tag *tl_first; - struct tag *tl_last; -}; -#define TAG_END ((struct tag *) &taglist) -static struct taglist taglist = { TAG_END, TAG_END }; struct tag { struct tag *next, *prev; /* List links */ char *tag_file; /* Source file containing the tag */ @@ -74,6 +68,12 @@ char *tag_pattern; /* Pattern used to find the tag */ char tag_endline; /* True if the pattern includes '$' */ }; +struct taglist { + struct tag *tl_first; + struct tag *tl_last; +}; +#define TAG_END ((struct tag *) &taglist) +static struct taglist taglist = { TAG_END, TAG_END }; static struct tag *curtag; #define TAG_INS(tp) \ @@ -544,7 +544,7 @@ while (fgets(buf, sizeof(buf), fp)) { char *name, *file, *line; - int len; + size_t len; if (sigs) {