diff --git a/ch.c b/ch.c index 13f06982..1559a836 100644 --- a/ch.c +++ b/ch.c @@ -34,7 +34,7 @@ struct bufnode { struct bufnode *hnext, *hprev; }; -#define LBUFSIZE 8192 +#define LBUFSIZE 8192 struct buf { struct bufnode node; BLOCKNUM block; @@ -47,7 +47,7 @@ struct buf { * The file state is maintained in a filestate structure. * A pointer to the filestate is kept in the ifile structure. */ -#define BUFHASH_SIZE 1024 +#define BUFHASH_SIZE 1024 struct filestate { struct bufnode buflist; struct bufnode hashtbl[BUFHASH_SIZE]; @@ -60,24 +60,24 @@ struct filestate { POSITION fsize; }; -#define ch_bufhead thisfile->buflist.next -#define ch_buftail thisfile->buflist.prev -#define ch_nbufs thisfile->nbufs -#define ch_block thisfile->block -#define ch_offset thisfile->offset -#define ch_fpos thisfile->fpos -#define ch_fsize thisfile->fsize -#define ch_flags thisfile->flags -#define ch_file thisfile->file +#define ch_bufhead thisfile->buflist.next +#define ch_buftail thisfile->buflist.prev +#define ch_nbufs thisfile->nbufs +#define ch_block thisfile->block +#define ch_offset thisfile->offset +#define ch_fpos thisfile->fpos +#define ch_fsize thisfile->fsize +#define ch_flags thisfile->flags +#define ch_file thisfile->file -#define END_OF_CHAIN (&thisfile->buflist) -#define END_OF_HCHAIN(h) (&thisfile->hashtbl[h]) -#define BUFHASH(blk) ((blk) & (BUFHASH_SIZE-1)) +#define END_OF_CHAIN (&thisfile->buflist) +#define END_OF_HCHAIN(h) (&thisfile->hashtbl[h]) +#define BUFHASH(blk) ((blk) & (BUFHASH_SIZE-1)) /* * Macros to manipulate the list of buffers in thisfile->buflist. */ -#define FOR_BUFS(bn) \ +#define FOR_BUFS(bn) \ for (bn = ch_bufhead; bn != END_OF_CHAIN; bn = bn->next) #define BUF_RM(bn) \ @@ -99,15 +99,15 @@ struct filestate { /* * Macros to manipulate the list of buffers in thisfile->hashtbl[n]. */ -#define FOR_BUFS_IN_CHAIN(h,bn) \ +#define FOR_BUFS_IN_CHAIN(h,bn) \ for (bn = thisfile->hashtbl[h].hnext; \ bn != END_OF_HCHAIN(h); bn = bn->hnext) -#define BUF_HASH_RM(bn) \ +#define BUF_HASH_RM(bn) \ (bn)->hnext->hprev = (bn)->hprev; \ (bn)->hprev->hnext = (bn)->hnext; -#define BUF_HASH_INS(bn,h) \ +#define BUF_HASH_INS(bn,h) \ (bn)->hnext = thisfile->hashtbl[h].hnext; \ (bn)->hprev = END_OF_HCHAIN(h); \ thisfile->hashtbl[h].hnext->hprev = (bn); \ @@ -233,12 +233,12 @@ ch_get(VOID_PARAM) return ('?'); if (lseek(ch_file, (off_t)pos, SEEK_SET) == BAD_LSEEK) { - error("seek error", NULL_PARG); + error("seek error", NULL_PARG); clear_eol(); return (EOI); - } - ch_fpos = pos; - } + } + ch_fpos = pos; + } /* * Read the block. @@ -304,7 +304,7 @@ ch_get(VOID_PARAM) parg.p_string = wait_message(); ierror("%s", &parg); } - sleep_ms(2); /* Reduce system load */ + sleep_ms(2); /* Reduce system load */ slept = TRUE; #if HAVE_STAT_INO diff --git a/charset.c b/charset.c index 1b74b2bf..08e301d2 100644 --- a/charset.c +++ b/charset.c @@ -33,27 +33,27 @@ struct charset { int *p_flag; char *desc; } charsets[] = { - { "ascii", NULL, "8bcccbcc18b95.b" }, - { "utf-8", &utf_mode, "8bcccbcc18b95.b126.bb" }, - { "iso8859", NULL, "8bcccbcc18b95.33b." }, - { "latin3", NULL, "8bcccbcc18b95.33b5.b8.b15.b4.b12.b18.b12.b." }, - { "arabic", NULL, "8bcccbcc18b95.33b.3b.7b2.13b.3b.b26.5b19.b" }, - { "greek", NULL, "8bcccbcc18b95.33b4.2b4.b3.b35.b44.b" }, - { "greek2005", NULL, "8bcccbcc18b95.33b14.b35.b44.b" }, - { "hebrew", NULL, "8bcccbcc18b95.33b.b29.32b28.2b2.b" }, - { "koi8-r", NULL, "8bcccbcc18b95.b." }, - { "KOI8-T", NULL, "8bcccbcc18b95.b8.b6.b8.b.b.5b7.3b4.b4.b3.b.b.3b." }, - { "georgianps", NULL, "8bcccbcc18b95.3b11.4b12.2b." }, - { "tcvn", NULL, "b..b...bcccbccbbb7.8b95.b48.5b." }, - { "TIS-620", NULL, "8bcccbcc18b95.b.4b.11b7.8b." }, - { "next", NULL, "8bcccbcc18b95.bb125.bb" }, - { "dos", NULL, "8bcccbcc12bc5b95.b." }, - { "windows-1251", NULL, "8bcccbcc12bc5b95.b24.b." }, - { "windows-1252", NULL, "8bcccbcc12bc5b95.b.b11.b.2b12.b." }, - { "windows-1255", NULL, "8bcccbcc12bc5b95.b.b8.b.5b9.b.4b." }, - { "ebcdic", NULL, "5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." }, - { "IBM-1047", NULL, "4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" }, - { NULL, NULL, NULL } + { "ascii", NULL, "8bcccbcc18b95.b" }, + { "utf-8", &utf_mode, "8bcccbcc18b95.b126.bb" }, + { "iso8859", NULL, "8bcccbcc18b95.33b." }, + { "latin3", NULL, "8bcccbcc18b95.33b5.b8.b15.b4.b12.b18.b12.b." }, + { "arabic", NULL, "8bcccbcc18b95.33b.3b.7b2.13b.3b.b26.5b19.b" }, + { "greek", NULL, "8bcccbcc18b95.33b4.2b4.b3.b35.b44.b" }, + { "greek2005", NULL, "8bcccbcc18b95.33b14.b35.b44.b" }, + { "hebrew", NULL, "8bcccbcc18b95.33b.b29.32b28.2b2.b" }, + { "koi8-r", NULL, "8bcccbcc18b95.b." }, + { "KOI8-T", NULL, "8bcccbcc18b95.b8.b6.b8.b.b.5b7.3b4.b4.b3.b.b.3b." }, + { "georgianps", NULL, "8bcccbcc18b95.3b11.4b12.2b." }, + { "tcvn", NULL, "b..b...bcccbccbbb7.8b95.b48.5b." }, + { "TIS-620", NULL, "8bcccbcc18b95.b.4b.11b7.8b." }, + { "next", NULL, "8bcccbcc18b95.bb125.bb" }, + { "dos", NULL, "8bcccbcc12bc5b95.b." }, + { "windows-1251", NULL, "8bcccbcc12bc5b95.b24.b." }, + { "windows-1252", NULL, "8bcccbcc12bc5b95.b.b11.b.2b12.b." }, + { "windows-1255", NULL, "8bcccbcc12bc5b95.b.b8.b.5b9.b.4b." }, + { "ebcdic", NULL, "5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b." }, + { "IBM-1047", NULL, "4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc191.b" }, + { NULL, NULL, NULL } }; /* @@ -63,53 +63,53 @@ struct cs_alias { char *name; char *oname; } cs_aliases[] = { - { "UTF-8", "utf-8" }, - { "utf8", "utf-8" }, - { "UTF8", "utf-8" }, - { "ANSI_X3.4-1968", "ascii" }, - { "US-ASCII", "ascii" }, - { "latin1", "iso8859" }, - { "ISO-8859-1", "iso8859" }, - { "latin9", "iso8859" }, - { "ISO-8859-15", "iso8859" }, - { "latin2", "iso8859" }, - { "ISO-8859-2", "iso8859" }, - { "ISO-8859-3", "latin3" }, - { "latin4", "iso8859" }, - { "ISO-8859-4", "iso8859" }, - { "cyrillic", "iso8859" }, - { "ISO-8859-5", "iso8859" }, - { "ISO-8859-6", "arabic" }, - { "ISO-8859-7", "greek" }, - { "IBM9005", "greek2005" }, - { "ISO-8859-8", "hebrew" }, - { "latin5", "iso8859" }, - { "ISO-8859-9", "iso8859" }, - { "latin6", "iso8859" }, - { "ISO-8859-10", "iso8859" }, - { "latin7", "iso8859" }, - { "ISO-8859-13", "iso8859" }, - { "latin8", "iso8859" }, - { "ISO-8859-14", "iso8859" }, - { "latin10", "iso8859" }, - { "ISO-8859-16", "iso8859" }, - { "IBM437", "dos" }, - { "EBCDIC-US", "ebcdic" }, - { "IBM1047", "IBM-1047" }, - { "KOI8-R", "koi8-r" }, - { "KOI8-U", "koi8-r" }, - { "GEORGIAN-PS", "georgianps" }, - { "TCVN5712-1", "tcvn" }, - { "NEXTSTEP", "next" }, - { "windows", "windows-1252" }, /* backward compatibility */ - { "CP1251", "windows-1251" }, - { "CP1252", "windows-1252" }, - { "CP1255", "windows-1255" }, - { NULL, NULL } + { "UTF-8", "utf-8" }, + { "utf8", "utf-8" }, + { "UTF8", "utf-8" }, + { "ANSI_X3.4-1968", "ascii" }, + { "US-ASCII", "ascii" }, + { "latin1", "iso8859" }, + { "ISO-8859-1", "iso8859" }, + { "latin9", "iso8859" }, + { "ISO-8859-15", "iso8859" }, + { "latin2", "iso8859" }, + { "ISO-8859-2", "iso8859" }, + { "ISO-8859-3", "latin3" }, + { "latin4", "iso8859" }, + { "ISO-8859-4", "iso8859" }, + { "cyrillic", "iso8859" }, + { "ISO-8859-5", "iso8859" }, + { "ISO-8859-6", "arabic" }, + { "ISO-8859-7", "greek" }, + { "IBM9005", "greek2005" }, + { "ISO-8859-8", "hebrew" }, + { "latin5", "iso8859" }, + { "ISO-8859-9", "iso8859" }, + { "latin6", "iso8859" }, + { "ISO-8859-10", "iso8859" }, + { "latin7", "iso8859" }, + { "ISO-8859-13", "iso8859" }, + { "latin8", "iso8859" }, + { "ISO-8859-14", "iso8859" }, + { "latin10", "iso8859" }, + { "ISO-8859-16", "iso8859" }, + { "IBM437", "dos" }, + { "EBCDIC-US", "ebcdic" }, + { "IBM1047", "IBM-1047" }, + { "KOI8-R", "koi8-r" }, + { "KOI8-U", "koi8-r" }, + { "GEORGIAN-PS", "georgianps" }, + { "TCVN5712-1", "tcvn" }, + { "NEXTSTEP", "next" }, + { "windows", "windows-1252" }, /* backward compatibility */ + { "CP1251", "windows-1251" }, + { "CP1252", "windows-1252" }, + { "CP1255", "windows-1255" }, + { NULL, NULL } }; -#define IS_BINARY_CHAR 01 -#define IS_CONTROL_CHAR 02 +#define IS_BINARY_CHAR 01 +#define IS_CONTROL_CHAR 02 static char chardef[256]; static char *binfmt = NULL; @@ -127,9 +127,9 @@ public int binattr = AT_STANDOUT; * repetition of the letter. * * Each letter is one of: - * . normal character - * b binary character - * c control character + * . normal character + * b binary character + * c control character */ static void ichardef(s) @@ -450,16 +450,16 @@ prchar(c) SNPRINTF1(buf, sizeof(buf), "^%c", /* * This array roughly inverts CONTROL() #defined in less.h, - * and should be kept in sync with CONTROL() and IBM-1047. - */ + * and should be kept in sync with CONTROL() and IBM-1047. + */ "@ABC.I.?...KLMNO" "PQRS.JH.XY.." "\\]^_" "......W[.....EFG" "..V....D....TU.Z"[c]); #else - else if (c < 128 && !control_char(c ^ 0100)) - SNPRINTF1(buf, sizeof(buf), "^%c", (int) (c ^ 0100)); + else if (c < 128 && !control_char(c ^ 0100)) + SNPRINTF1(buf, sizeof(buf), "^%c", (int) (c ^ 0100)); #endif else SNPRINTF1(buf, sizeof(buf), binfmt, c); @@ -477,7 +477,7 @@ prutfchar(ch) if (ch == ESC) strcpy(buf, "ESC"); - else if (ch < 128 && control_char(ch)) + else if (ch < 128 && control_char(ch)) { if (!control_char(ch ^ 0100)) SNPRINTF1(buf, sizeof(buf), "^%c", ((char) ch) ^ 0100); diff --git a/cmdbuf.c b/cmdbuf.c index 3e659bac..fc7667ef 100644 --- a/cmdbuf.c +++ b/cmdbuf.c @@ -19,12 +19,12 @@ extern int no_hist_dups; extern int marks_modified; static char cmdbuf[CMDBUF_SIZE]; /* Buffer for holding a multi-char command */ -static int cmd_col; /* Current column of the cursor */ -static int prompt_col; /* Column of cursor just after prompt */ -static char *cp; /* Pointer into cmdbuf */ -static int cmd_offset; /* Index into cmdbuf of first displayed char */ -static int literal; /* Next input char should not be interpreted */ -static int updown_match = -1; /* Prefix length in up/down movement */ +static int cmd_col; /* Current column of the cursor */ +static int prompt_col; /* Column of cursor just after prompt */ +static char *cp; /* Pointer into cmdbuf */ +static int cmd_offset; /* Index into cmdbuf of first displayed char */ +static int literal; /* Next input char should not be interpreted */ +static int updown_match = -1; /* Prefix length in up/down movement */ #if TAB_COMPLETE_FILENAME static int cmd_complete LESSPARAMS((int action)); @@ -216,7 +216,7 @@ cmd_step_common(p, ch, len, pwidth, bswidth) } } if (pwidth != NULL) - *pwidth = width; + *pwidth = width; if (bswidth != NULL) *bswidth = width; return (pr); @@ -824,9 +824,9 @@ cmd_accept(VOID_PARAM) * Try to perform a line-edit function on the command buffer, * using a specified char as a line-editing command. * Returns: - * CC_PASS The char does not invoke a line edit function. - * CC_OK Line edit function done. - * CC_QUIT The char requests the current command to be aborted. + * CC_PASS The char does not invoke a line edit function. + * CC_OK Line edit function done. + * CC_QUIT The char requests the current command to be aborted. */ static int cmd_edit(c) @@ -836,9 +836,9 @@ cmd_edit(c) int flags; #if TAB_COMPLETE_FILENAME -#define not_in_completion() in_completion = 0 +#define not_in_completion() in_completion = 0 #else -#define not_in_completion(VOID_PARAM) +#define not_in_completion(VOID_PARAM) #endif /* @@ -1235,9 +1235,9 @@ cmd_complete(action) * Process a single character of a multi-character command, such as * a number, or the pattern of a search command. * Returns: - * CC_OK The char was accepted. - * CC_QUIT The char requests the command to be aborted. - * CC_ERROR The char could not be accepted due to an error. + * CC_OK The char was accepted. + * CC_QUIT The char requests the command to be aborted. + * CC_ERROR The char could not be accepted due to an error. */ public int cmd_char(c) diff --git a/command.c b/command.c index 9ba77098..8c4ac888 100644 --- a/command.c +++ b/command.c @@ -48,7 +48,7 @@ extern void *ml_shell; extern char *editor; extern char *editproto; #endif -extern int screen_trashed; /* The screen has been overwritten */ +extern int screen_trashed; /* The screen has been overwritten */ extern int shift_count; extern int oldbot; extern int forw_prompt; @@ -58,12 +58,12 @@ extern int utf_mode; #endif #if SHELL_ESCAPE -static char *shellcmd = NULL; /* For holding last shell command for "!!" */ +static char *shellcmd = NULL; /* For holding last shell command for "!!" */ #endif -static int mca; /* The multicharacter command (action) */ -static int search_type; /* The previous type of search */ -static LINENUM number; /* The number typed by the user */ -static long fraction; /* The fractional part of the number */ +static int mca; /* The multicharacter command (action) */ +static int search_type; /* The previous type of search */ +static LINENUM number; /* The number typed by the user */ +static long fraction; /* The fractional part of the number */ static struct loption *curropt; static int opt_lower; static int optflag; @@ -512,9 +512,9 @@ mca_search_char(c) /* * 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 NO_MATCH flag + * * Toggle the PAST_EOF flag + * @ Toggle the FIRST_FILE flag */ if (len_cmdbuf() > 0) return (NO_MCA); @@ -1578,10 +1578,10 @@ commands(VOID_PARAM) /* * Define abbreviation for a commonly used sequence below. */ -#define DO_SEARCH() \ - if (number <= 0) number = 1; \ - mca_search(); \ - cmd_exec(); \ +#define DO_SEARCH() \ + if (number <= 0) number = 1; \ + mca_search(); \ + cmd_exec(); \ multi_search((char *)NULL, (int) number, 0); diff --git a/decode.c b/decode.c index de8d6205..4b227b9b 100644 --- a/decode.c +++ b/decode.c @@ -7,7 +7,7 @@ * This is all table driven. * A command table is a sequence of command descriptors. * Each command descriptor is a sequence of bytes with the following format: - * ...<0> + * ...<0> * The characters c1,c2,...,cN are the command string; that is, * the characters which the user must type. * It is terminated by a null <0> byte. @@ -935,7 +935,7 @@ editchar(c, flags) */ nch = 0; do { - if (nch > 0) + if (nch > 0) c = getcc(); usercmd[nch] = c; usercmd[nch+1] = '\0'; diff --git a/filename.c b/filename.c index e5b76998..d9a473ac 100644 --- a/filename.c +++ b/filename.c @@ -16,7 +16,7 @@ #if MSDOS_COMPILER==DJGPPC #include #include -#define _MAX_PATH PATH_MAX +#define _MAX_PATH PATH_MAX #endif #endif #ifdef _OSK @@ -29,10 +29,10 @@ #if HAVE_STAT #include #ifndef S_ISDIR -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif #ifndef S_ISREG -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif #endif @@ -305,7 +305,7 @@ fexpand(s) char *e; IFILE ifile; -#define fchar_ifile(c) \ +#define fchar_ifile(c) \ ((c) == '%' ? curr_ifile : \ (c) == '#' ? old_ifile : NULL_IFILE) @@ -642,7 +642,7 @@ lglob(filename) qfilename = shell_quote(p); if (qfilename != NULL) { - length += strlen(qfilename) + 1; + length += strlen(qfilename) + 1; free(qfilename); } } diff --git a/ifile.c b/ifile.c index 13ba9e63..b3967f75 100644 --- a/ifile.c +++ b/ifile.c @@ -14,7 +14,7 @@ #include "less.h" -extern IFILE curr_ifile; +extern IFILE curr_ifile; struct ifile { struct ifile *h_next; /* Links for command line list */ @@ -34,8 +34,8 @@ struct ifile { * Convert an IFILE (external representation) * to a struct file (internal representation), and vice versa. */ -#define int_ifile(h) ((struct ifile *)(h)) -#define ext_ifile(h) ((IFILE)(h)) +#define int_ifile(h) ((struct ifile *)(h)) +#define ext_ifile(h) ((IFILE)(h)) /* * Anchor for linked list. diff --git a/input.c b/input.c index 984f69c5..26960205 100644 --- a/input.c +++ b/input.c @@ -98,7 +98,7 @@ forw_line(curr_pos) /* * Read forward again to the position we should start at. */ - prewind(); + prewind(); plinestart(base_pos); (void) ch_seek(base_pos); new_pos = base_pos; diff --git a/lessecho.c b/lessecho.c index 4b435e30..1fa2968f 100644 --- a/lessecho.c +++ b/lessecho.c @@ -6,16 +6,16 @@ * Simply echos its filename arguments on standard output. * But any argument containing spaces is enclosed in quotes. * - * -ox Specifies "x" to be the open quote character. - * -cx Specifies "x" to be the close quote character. - * -pn Specifies "n" to be the open quote character, as an integer. - * -dn Specifies "n" to be the close quote character, as an integer. + * -ox Specifies "x" to be the open quote character. + * -cx Specifies "x" to be the close quote character. + * -pn Specifies "n" to be the open quote character, as an integer. + * -dn Specifies "n" to be the close quote character, as an integer. * -mx Specifies "x" to be a metachar. * -nn Specifies "n" to be a metachar, as an integer. * -ex Specifies "x" to be the escape char for metachars. * -fn Specifies "x" to be the escape char for metachars, as an integer. - * -a Specifies that all arguments are to be quoted. - * The default is that only arguments containing spaces are quoted. + * -a Specifies that all arguments are to be quoted. + * The default is that only arguments containing spaces are quoted. */ #include "less.h" diff --git a/lesskey.c b/lesskey.c index c72b2670..7c2bf969 100644 --- a/lesskey.c +++ b/lesskey.c @@ -2,73 +2,73 @@ /* - * lesskey [-o output] [input] + * lesskey [-o output] [input] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Make a .less file. - * If no input file is specified, standard input is used. - * If no output file is specified, $HOME/.less is used. + * Make a .less file. + * If no input file is specified, standard input is used. + * If no output file is specified, $HOME/.less is used. * - * The .less file is used to specify (to "less") user-defined - * key bindings. Basically any sequence of 1 to MAX_CMDLEN - * keystrokes may be bound to an existing less function. + * The .less file is used to specify (to "less") user-defined + * key bindings. Basically any sequence of 1 to MAX_CMDLEN + * keystrokes may be bound to an existing less function. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * The input file is an ascii file consisting of a - * sequence of lines of the form: - * string action [chars] + * The input file is an ascii file consisting of a + * sequence of lines of the form: + * string action [chars] * - * "string" is a sequence of command characters which form - * the new user-defined command. The command - * characters may be: - * 1. The actual character itself. - * 2. A character preceded by ^ to specify a - * control character (e.g. ^X means control-X). - * 3. A backslash followed by one to three octal digits - * to specify a character by its octal value. - * 4. A backslash followed by b, e, n, r or t - * to specify \b, ESC, \n, \r or \t, respectively. - * 5. Any character (other than those mentioned above) preceded - * by a \ to specify the character itself (characters which - * must be preceded by \ include ^, \, and whitespace. - * "action" is the name of a "less" action, from the table below. - * "chars" is an optional sequence of characters which is treated - * as keyboard input after the command is executed. + * "string" is a sequence of command characters which form + * the new user-defined command. The command + * characters may be: + * 1. The actual character itself. + * 2. A character preceded by ^ to specify a + * control character (e.g. ^X means control-X). + * 3. A backslash followed by one to three octal digits + * to specify a character by its octal value. + * 4. A backslash followed by b, e, n, r or t + * to specify \b, ESC, \n, \r or \t, respectively. + * 5. Any character (other than those mentioned above) preceded + * by a \ to specify the character itself (characters which + * must be preceded by \ include ^, \, and whitespace. + * "action" is the name of a "less" action, from the table below. + * "chars" is an optional sequence of characters which is treated + * as keyboard input after the command is executed. * - * Blank lines and lines which start with # are ignored, - * except for the special control lines: - * #command Signals the beginning of the command - * keys section. - * #line-edit Signals the beginning of the line-editing - * keys section. - * #env Signals the beginning of the environment - * variable section. - * #stop Stops command parsing in less; - * causes all default keys to be disabled. + * Blank lines and lines which start with # are ignored, + * except for the special control lines: + * #command Signals the beginning of the command + * keys section. + * #line-edit Signals the beginning of the line-editing + * keys section. + * #env Signals the beginning of the environment + * variable section. + * #stop Stops command parsing in less; + * causes all default keys to be disabled. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * The output file is a non-ascii file, consisting of a header, - * one or more sections, and a trailer. - * Each section begins with a section header, a section length word - * and the section data. Normally there are three sections: - * CMD_SECTION Definition of command keys. - * EDIT_SECTION Definition of editing keys. - * END_SECTION A special section header, with no - * length word or section data. + * The output file is a non-ascii file, consisting of a header, + * one or more sections, and a trailer. + * Each section begins with a section header, a section length word + * and the section data. Normally there are three sections: + * CMD_SECTION Definition of command keys. + * EDIT_SECTION Definition of editing keys. + * END_SECTION A special section header, with no + * length word or section data. * - * Section data consists of zero or more byte sequences of the form: - * string <0> - * or - * string <0> chars <0> + * Section data consists of zero or more byte sequences of the form: + * string <0> + * or + * string <0> chars <0> * - * "string" is the command string. - * "<0>" is one null byte. - * "" is one byte containing the action code (the A_xxx value). - * If action is ORed with A_EXTRA, the action byte is followed - * by the null-terminated "chars" string. + * "string" is the command string. + * "<0>" is one null byte. + * "" is one byte containing the action code (the A_xxx value). + * If action is ORed with A_EXTRA, the action byte is followed + * by the null-terminated "chars" string. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -154,27 +154,27 @@ struct cmdname cmdnames[] = struct cmdname editnames[] = { - { "back-complete", EC_B_COMPLETE }, - { "backspace", EC_BACKSPACE }, - { "delete", EC_DELETE }, - { "down", EC_DOWN }, - { "end", EC_END }, - { "expand", EC_EXPAND }, - { "forw-complete", EC_F_COMPLETE }, - { "home", EC_HOME }, - { "insert", EC_INSERT }, - { "invalid", EC_UINVALID }, - { "kill-line", EC_LINEKILL }, - { "abort", EC_ABORT }, - { "left", EC_LEFT }, - { "literal", EC_LITERAL }, - { "right", EC_RIGHT }, - { "up", EC_UP }, - { "word-backspace", EC_W_BACKSPACE }, - { "word-delete", EC_W_DELETE }, - { "word-left", EC_W_LEFT }, - { "word-right", EC_W_RIGHT }, - { NULL, 0 } + { "back-complete", EC_B_COMPLETE }, + { "backspace", EC_BACKSPACE }, + { "delete", EC_DELETE }, + { "down", EC_DOWN }, + { "end", EC_END }, + { "expand", EC_EXPAND }, + { "forw-complete", EC_F_COMPLETE }, + { "home", EC_HOME }, + { "insert", EC_INSERT }, + { "invalid", EC_UINVALID }, + { "kill-line", EC_LINEKILL }, + { "abort", EC_ABORT }, + { "left", EC_LEFT }, + { "literal", EC_LITERAL }, + { "right", EC_RIGHT }, + { "up", EC_UP }, + { "word-backspace", EC_W_BACKSPACE }, + { "word-delete", EC_W_DELETE }, + { "word-left", EC_W_LEFT }, + { "word-right", EC_W_RIGHT }, + { NULL, 0 } }; struct table @@ -200,10 +200,10 @@ char filetrailer[] = { C1_END_LESSKEY_MAGIC, C2_END_LESSKEY_MAGIC }; -char cmdsection[1] = { CMD_SECTION }; -char editsection[1] = { EDIT_SECTION }; -char varsection[1] = { VAR_SECTION }; -char endsection[1] = { END_SECTION }; +char cmdsection[1] = { CMD_SECTION }; +char editsection[1] = { EDIT_SECTION }; +char varsection[1] = { VAR_SECTION }; +char endsection[1] = { END_SECTION }; char *infile = NULL; char *outfile = NULL ; @@ -472,7 +472,7 @@ tstr(pp, xlate) skipsp(s) char *s; { - while (*s == ' ' || *s == '\t') + while (*s == ' ' || *s == '\t') s++; return (s); } @@ -540,7 +540,7 @@ add_cmd_str(s) control_line(s) char *s; { -#define PREFIX(str,pat) (strncmp(str,pat,strlen(pat)) == 0) +#define PREFIX(str,pat) (strncmp(str,pat,strlen(pat)) == 0) if (PREFIX(s, "#line-edit")) { diff --git a/line.c b/line.c index b71aecc9..0c6dbeb3 100644 --- a/line.c +++ b/line.c @@ -596,7 +596,7 @@ ansi_done(pansi) /* * Append a character and attribute to the line buffer. */ -#define STORE_CHAR(ch,a,rep,pos) \ +#define STORE_CHAR(ch,a,rep,pos) \ do { \ if (store_char((ch),(a),(rep),(pos))) return (1); \ } while (0) @@ -710,7 +710,7 @@ store_char(ch, a, rep, pos) * Append a tab to the line buffer. * Store spaces to represent the tab. */ -#define STORE_TAB(a,pos) \ +#define STORE_TAB(a,pos) \ do { if (store_tab((a),(pos))) return (1); } while (0) static int @@ -860,7 +860,7 @@ pappend(c, pos) /* Handle new char. */ if (!r) goto retry; - } + } } if (r) { @@ -1035,11 +1035,11 @@ do_append(ch, rep, pos) char *s = prutfchar(ch); for ( ; *s != 0; s++) STORE_CHAR(*s, AT_BINARY, NULL, pos); - } else + } else { STORE_CHAR(ch, a, rep, pos); } - return (0); + return (0); } /* diff --git a/linenum.c b/linenum.c index 3e697038..bf5bad62 100644 --- a/linenum.c +++ b/linenum.c @@ -33,11 +33,11 @@ */ struct linenum_info { - struct linenum_info *next; /* Link to next in the list */ - struct linenum_info *prev; /* Line to previous in the list */ - POSITION pos; /* File position */ - POSITION gap; /* Gap between prev and next */ - LINENUM line; /* Line number */ + struct linenum_info *next; /* Link to next in the list */ + struct linenum_info *prev; /* Line to previous in the list */ + POSITION pos; /* File position */ + POSITION gap; /* Gap between prev and next */ + LINENUM line; /* Line number */ }; /* * "gap" needs some explanation: the gap of any particular line number @@ -48,14 +48,14 @@ struct linenum_info * when we have a new one to insert and the table is full. */ -#define NPOOL 200 /* Size of line number pool */ +#define NPOOL 200 /* Size of line number pool */ -#define LONGTIME (2) /* In seconds */ +#define LONGTIME (2) /* In seconds */ -static struct linenum_info anchor; /* Anchor of the list */ -static struct linenum_info *freelist; /* Anchor of the unused entries */ -static struct linenum_info pool[NPOOL]; /* The pool itself */ -static struct linenum_info *spare; /* We always keep one spare entry */ +static struct linenum_info anchor; /* Anchor of the list */ +static struct linenum_info *freelist; /* Anchor of the unused entries */ +static struct linenum_info pool[NPOOL]; /* The pool itself */ +static struct linenum_info *spare; /* We always keep one spare entry */ extern int linenums; extern int sigs; diff --git a/lsystem.c b/lsystem.c index 1d8ecdec..002ff7be 100644 --- a/lsystem.c +++ b/lsystem.c @@ -90,7 +90,7 @@ lsystem(cmd, donemsg) * De-initialize the terminal and take out of raw mode. */ deinit(); - flush(); /* Make sure the deinit chars get out */ + flush(); /* Make sure the deinit chars get out */ raw_mode(0); #if MSDOS_COMPILER==WIN32C close_getchr(); @@ -162,7 +162,7 @@ lsystem(cmd, donemsg) * also makes trouble with some DPMI servers). */ __djgpp_exception_toggle(); - system(cmd); + system(cmd); __djgpp_exception_toggle(); #else system(cmd); @@ -267,14 +267,14 @@ pipe_mark(c, cmd) tpos = ch_zero(); bpos = position(BOTTOM); - if (c == '.') - return (pipe_data(cmd, tpos, bpos)); - else if (mpos <= tpos) - return (pipe_data(cmd, mpos, bpos)); - else if (bpos == NULL_POSITION) - return (pipe_data(cmd, tpos, bpos)); - else - return (pipe_data(cmd, tpos, mpos)); + if (c == '.') + return (pipe_data(cmd, tpos, bpos)); + else if (mpos <= tpos) + return (pipe_data(cmd, mpos, bpos)); + else if (bpos == NULL_POSITION) + return (pipe_data(cmd, tpos, bpos)); + else + return (pipe_data(cmd, tpos, mpos)); } /* @@ -339,14 +339,14 @@ pipe_data(cmd, spos, epos) /* * Finish up the last line. */ - while (c != '\n' && c != EOI ) - { - c = ch_forw_get(); - if (c == EOI) - break; - if (putc(c, f) == EOF) - break; - } + while (c != '\n' && c != EOI ) + { + c = ch_forw_get(); + if (c == EOI) + break; + if (putc(c, f) == EOF) + break; + } pclose(f); diff --git a/main.c b/main.c index 15d65657..206935bc 100644 --- a/main.c +++ b/main.c @@ -11,48 +11,48 @@ #include #endif -public char * every_first_cmd = NULL; -public int new_file; -public int is_tty; -public IFILE curr_ifile = NULL_IFILE; -public IFILE old_ifile = NULL_IFILE; +public char * every_first_cmd = NULL; +public int new_file; +public int is_tty; +public IFILE curr_ifile = NULL_IFILE; +public IFILE old_ifile = NULL_IFILE; public struct scrpos initial_scrpos; -public POSITION start_attnpos = NULL_POSITION; -public POSITION end_attnpos = NULL_POSITION; -public int wscroll; -public char * progname; -public int quitting; -public int secure; -public int dohelp; +public POSITION start_attnpos = NULL_POSITION; +public POSITION end_attnpos = NULL_POSITION; +public int wscroll; +public char * progname; +public int quitting; +public int secure; +public int dohelp; #if LOGFILE -public int logfile = -1; -public int force_logfile = FALSE; -public char * namelogfile = NULL; +public int logfile = -1; +public int force_logfile = FALSE; +public char * namelogfile = NULL; #endif #if EDITOR -public char * editor; -public char * editproto; +public char * editor; +public char * editproto; #endif #if TAGS -extern char * tags; -extern char * tagoption; -extern int jump_sline; +extern char * tags; +extern char * tagoption; +extern int jump_sline; #endif #ifdef WIN32 static char consoleTitle[256]; #endif -public int one_screen; -extern int less_is_more; -extern int missing_cap; -extern int know_dumb; -extern int pr_type; -extern int quit_if_one_screen; -extern int no_init; +public int one_screen; +extern int less_is_more; +extern int missing_cap; +extern int know_dumb; +extern int pr_type; +extern int quit_if_one_screen; +extern int no_init; extern int errmsgs; @@ -130,7 +130,7 @@ main(argc, argv) if (s != NULL) scan_option(save(s)); -#define isoptstring(s) (((s)[0] == '-' || (s)[0] == '+') && (s)[1] != '\0') +#define isoptstring(s) (((s)[0] == '-' || (s)[0] == '+') && (s)[1] != '\0') while (argc > 0 && (isoptstring(*argv) || isoptpending())) { s = *argv++; @@ -337,7 +337,7 @@ ecalloc(count, size) skipsp(s) char *s; { - while (*s == ' ' || *s == '\t') + while (*s == ' ' || *s == '\t') s++; return (s); } diff --git a/mark.c b/mark.c index 8e3c1430..c8cfafe2 100644 --- a/mark.c +++ b/mark.c @@ -31,10 +31,10 @@ struct mark * Each mark is identified by a lowercase or uppercase letter. * The final one is lmark, for the "last mark"; addressed by the apostrophe. */ -#define NMARKS ((2*26)+2) /* a-z, A-Z, mousemark, lastmark */ -#define NUMARKS ((2*26)+1) /* user marks (not lastmark) */ -#define MOUSEMARK (NMARKS-2) -#define LASTMARK (NMARKS-1) +#define NMARKS ((2*26)+2) /* a-z, A-Z, mousemark, lastmark */ +#define NUMARKS ((2*26)+1) /* user marks (not lastmark) */ +#define MOUSEMARK (NMARKS-2) +#define LASTMARK (NMARKS-1) static struct mark marks[NMARKS]; public int marks_modified = 0; diff --git a/optfunc.c b/optfunc.c index a721bd73..ba7a9c97 100644 --- a/optfunc.c +++ b/optfunc.c @@ -12,9 +12,9 @@ * Each handling function is passed a "type" and, if it is a string * option, the string which should be "assigned" to the option. * The type may be one of: - * INIT The option is being initialized from the command line. - * TOGGLE The option is being changed from within the program. - * QUERY The setting of the option is merely being queried. + * INIT The option is being initialized from the command line. + * TOGGLE The option is being changed from within the program. + * QUERY The setting of the option is merely being queried. */ #include "less.h" @@ -422,13 +422,13 @@ opt__P(type, s) */ switch (*s) { - case 's': proto = &prproto[PR_SHORT]; s++; break; - case 'm': proto = &prproto[PR_MEDIUM]; s++; break; - case 'M': proto = &prproto[PR_LONG]; s++; break; - case '=': proto = &eqproto; s++; break; - case 'h': proto = &hproto; s++; break; - case 'w': proto = &wproto; s++; break; - default: proto = &prproto[PR_SHORT]; break; + case 's': proto = &prproto[PR_SHORT]; s++; break; + case 'm': proto = &prproto[PR_MEDIUM]; s++; break; + case 'M': proto = &prproto[PR_LONG]; s++; break; + case '=': proto = &eqproto; s++; break; + case 'h': proto = &hproto; s++; break; + case 'w': proto = &wproto; s++; break; + default: proto = &prproto[PR_SHORT]; break; } free(*proto); *proto = save(s); @@ -508,7 +508,7 @@ opt__V(type, s) { char constant *copyright = "@@copyright_oneline@@\n\n"; if (copyright[0] == '@') - copyright = "Copyright (C) 1984 Mark Nudelman\n\n"; + copyright = "Copyright (C) 2021 Mark Nudelman\n\n"; putstr(copyright); } if (version[strlen(version)-1] == 'x') @@ -520,7 +520,7 @@ opt__V(type, s) putstr("less comes with NO WARRANTY, to the extent permitted by law.\n"); putstr("For information about the terms of redistribution,\n"); putstr("see the file named README in the less distribution.\n"); - putstr("Home page: https://greenwoodsoftware.com/less\n"); + putstr("Home page: https://www.greenwoodsoftware.com/less\n"); quit(QUIT_OK); break; } @@ -530,7 +530,7 @@ opt__V(type, s) /* * Parse an MSDOS color descriptor. */ - static void + static void colordesc(s, fg_color, bg_color) char *s; int *fg_color; @@ -540,7 +540,7 @@ colordesc(s, fg_color, bg_color) int err; #if MSDOS_COMPILER==WIN32C int ul = 0; - + if (*s == 'u') { ul = COMMON_LVB_UNDERSCORE; diff --git a/option.c b/option.c index 7baf8a52..05999619 100644 --- a/option.c +++ b/option.c @@ -290,10 +290,10 @@ scan_option(s) * Toggle command line flags from within the program. * Used by the "-" and "_" commands. * how_toggle may be: - * OPT_NO_TOGGLE just report the current setting, without changing it. - * OPT_TOGGLE invert the current setting - * OPT_UNSET set to the default value - * OPT_SET set to the inverse of the default value + * OPT_NO_TOGGLE just report the current setting, without changing it. + * OPT_TOGGLE invert the current setting + * OPT_UNSET set to the default value + * OPT_SET set to the inverse of the default value */ public void toggle_option(o, lower, s, how_toggle) @@ -377,11 +377,11 @@ toggle_option(o, lower, s, how_toggle) case TRIPLE: /* * Triple: - * If user gave the lower case letter, then switch - * to 1 unless already 1, in which case make it 0. - * If user gave the upper case letter, then switch - * to 2 unless already 2, in which case make it 0. - */ + * If user gave the lower case letter, then switch + * to 1 unless already 1, in which case make it 0. + * If user gave the upper case letter, then switch + * to 2 unless already 2, in which case make it 0. + */ switch (how_toggle) { case OPT_TOGGLE: @@ -398,7 +398,7 @@ toggle_option(o, lower, s, how_toggle) case STRING: /* * String: don't do anything here. - * The handling function will do everything. + * The handling function will do everything. */ switch (how_toggle) { diff --git a/os.c b/os.c index 59254d8b..4414e77e 100644 --- a/os.c +++ b/os.c @@ -42,11 +42,11 @@ * _setjmp() does not exist; we just use setjmp(). */ #if HAVE__SETJMP && HAVE_SIGSETMASK -#define SET_JUMP _setjmp -#define LONG_JUMP _longjmp +#define SET_JUMP _setjmp +#define LONG_JUMP _longjmp #else -#define SET_JUMP setjmp -#define LONG_JUMP longjmp +#define SET_JUMP setjmp +#define LONG_JUMP longjmp #endif public int reading; diff --git a/output.c b/output.c index 09019e43..483c7f8b 100644 --- a/output.c +++ b/output.c @@ -13,7 +13,7 @@ #endif #endif -public int errmsgs; /* Count of messages displayed by error() */ +public int errmsgs; /* Count of messages displayed by error() */ public int need_clr; public int final_attr; public int at_prompt; @@ -250,11 +250,11 @@ flush(VOID_PARAM) bgi = nm_bg_color & 8; } break; - case 1: /* bold on */ + case 1: /* bold on */ fgi = 8; at |= 1; break; - case 3: /* italic on */ + case 3: /* italic on */ case 7: /* inverse on */ at |= 2; break; @@ -267,7 +267,7 @@ flush(VOID_PARAM) bgi = 8; at |= 8; break; - case 8: /* concealed on */ + case 8: /* concealed on */ at |= 16; break; case 22: /* bold off */ @@ -355,7 +355,7 @@ flush(VOID_PARAM) if (at & 16) f = b ^ 8; f &= 0xf; - b &= 0xf; + b &= 0xf; WIN32setcolors(f, b); p_next = anchor = p + 1; } else diff --git a/position.c b/position.c index e8d762a8..386537b7 100644 --- a/position.c +++ b/position.c @@ -14,7 +14,7 @@ #include "less.h" #include "position.h" -static POSITION *table = NULL; /* The position table */ +static POSITION *table = NULL; /* The position table */ static int table_size = 0; extern int sc_width, sc_height; @@ -23,10 +23,10 @@ extern int sc_width, sc_height; * Return the starting file position of a line displayed on the screen. * The line may be specified as a line number relative to the top * of the screen, but is usually one of these special cases: - * the top (first) line on the screen - * the second line on the screen - * the bottom line on the screen - * the line after the bottom line on the screen + * the top (first) line on the screen + * the second line on the screen + * the bottom line on the screen + * the line after the bottom line on the screen */ public POSITION position(sindex) diff --git a/prompt.c b/prompt.c index ec536a29..81014d03 100644 --- a/prompt.c +++ b/prompt.c @@ -116,7 +116,7 @@ ap_pos(pos) /* * Append a line number to the end of the message. */ - static void + static void ap_linenum(linenum) LINENUM linenum; { @@ -180,48 +180,48 @@ cond(c, where) switch (c) { - case 'a': /* Anything in the message yet? */ + case 'a': /* Anything in the message yet? */ return (mp > message); - case 'b': /* Current byte offset known? */ + case 'b': /* Current byte offset known? */ return (curr_byte(where) != NULL_POSITION); case 'c': return (hshift != 0); - case 'e': /* At end of file? */ + case 'e': /* At end of file? */ return (eof_displayed()); - case 'f': /* Filename known? */ + case 'f': /* Filename known? */ case 'g': return (strcmp(get_filename(curr_ifile), "-") != 0); - case 'l': /* Line number known? */ - case 'd': /* Same as l */ + case 'l': /* Line number known? */ + case 'd': /* Same as l */ if (!linenums) return 0; return (currline(where) != 0); - case 'L': /* Final line number known? */ - case 'D': /* Final page number known? */ + case 'L': /* Final line number known? */ + case 'D': /* Final page number known? */ return (linenums && ch_length() != NULL_POSITION); - case 'm': /* More than one file? */ + case 'm': /* More than one file? */ #if TAGS return (ntags() ? (ntags() > 1) : (nifile() > 1)); #else return (nifile() > 1); #endif - case 'n': /* First prompt in a new file? */ + case 'n': /* First prompt in a new file? */ #if TAGS return (ntags() ? 1 : new_file); #else return (new_file); #endif - case 'p': /* Percent into file (bytes) known? */ + case 'p': /* Percent into file (bytes) known? */ return (curr_byte(where) != NULL_POSITION && ch_length() > 0); - case 'P': /* Percent into file (lines) known? */ + case 'P': /* Percent into file (lines) known? */ return (currline(where) != 0 && (len = ch_length()) > 0 && find_linenum(len) != 0); - case 's': /* Size of file known? */ + case 's': /* Size of file known? */ case 'B': return (ch_length() != NULL_POSITION); - case 'x': /* Is there a "next" file? */ + case 'x': /* Is there a "next" file? */ #if TAGS if (ntags()) return (0); @@ -257,7 +257,7 @@ protochar(c, where, iseditproto) switch (c) { - case 'b': /* Current byte offset */ + case 'b': /* Current byte offset */ pos = curr_byte(where); if (pos != NULL_POSITION) ap_pos(pos); @@ -267,14 +267,14 @@ protochar(c, where, iseditproto) case 'c': ap_int(hshift); break; - case 'd': /* Current page number */ + 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 */ + 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) @@ -292,22 +292,22 @@ protochar(c, where, iseditproto) } break; #if EDITOR - case 'E': /* Editor name */ + case 'E': /* Editor name */ ap_str(editor); break; #endif - case 'f': /* File name */ + case 'f': /* File name */ ap_str(get_filename(curr_ifile)); break; - case 'F': /* Last component of file name */ + case 'F': /* Last component of file name */ ap_str(last_component(get_filename(curr_ifile))); break; - case 'g': /* Shell-escaped file name */ + case 'g': /* Shell-escaped file name */ s = shell_quote(get_filename(curr_ifile)); ap_str(s); free(s); break; - case 'i': /* Index into list of files */ + case 'i': /* Index into list of files */ #if TAGS if (ntags()) ap_int(curr_tag()); @@ -315,14 +315,14 @@ protochar(c, where, iseditproto) #endif ap_int(get_index(curr_ifile)); break; - case 'l': /* Current line number */ + case 'l': /* Current line number */ linenum = currline(where); if (linenum != 0) ap_linenum(linenum); else ap_quest(); break; - case 'L': /* Final line number */ + case 'L': /* Final line number */ len = ch_length(); if (len == NULL_POSITION || len == ch_zero() || (linenum = find_linenum(len)) <= 0) @@ -330,7 +330,7 @@ protochar(c, where, iseditproto) else ap_linenum(linenum-1); break; - case 'm': /* Number of files */ + case 'm': /* Number of files */ #if TAGS n = ntags(); if (n) @@ -339,7 +339,7 @@ protochar(c, where, iseditproto) #endif ap_int(nifile()); break; - case 'p': /* Percent into file (bytes) */ + case 'p': /* Percent into file (bytes) */ pos = curr_byte(where); len = ch_length(); if (pos != NULL_POSITION && len > 0) @@ -347,7 +347,7 @@ protochar(c, where, iseditproto) else ap_quest(); break; - case 'P': /* Percent into file (lines) */ + case 'P': /* Percent into file (lines) */ linenum = currline(where); if (linenum == 0 || (len = ch_length()) == NULL_POSITION || len == ch_zero() || @@ -356,7 +356,7 @@ protochar(c, where, iseditproto) else ap_int(percentage(linenum, last_linenum)); break; - case 's': /* Size of file */ + case 's': /* Size of file */ case 'B': len = ch_length(); if (len != NULL_POSITION) @@ -364,12 +364,12 @@ protochar(c, where, iseditproto) else ap_quest(); break; - case 't': /* Truncate trailing spaces in the message */ + case 't': /* Truncate trailing spaces in the message */ while (mp > message && mp[-1] == ' ') mp--; *mp = '\0'; break; - case 'T': /* Type of list */ + case 'T': /* Type of list */ #if TAGS if (ntags()) ap_str("tag"); @@ -377,7 +377,7 @@ protochar(c, where, iseditproto) #endif ap_str("file"); break; - case 'x': /* Name of next file */ + case 'x': /* Name of next file */ h = next_ifile(curr_ifile); if (h != NULL_IFILE) ap_str(get_filename(h)); @@ -462,13 +462,13 @@ wherechar(p, wp) case 'b': case 'd': case 'l': case 'p': case 'P': switch (*++p) { - case 't': *wp = TOP; break; - case 'm': *wp = MIDDLE; break; - case 'b': *wp = BOTTOM; break; - case 'B': *wp = BOTTOM_PLUS_ONE; break; - case 'j': *wp = sindex_from_sline(jump_sline); break; - default: *wp = TOP; p--; break; - } + case 't': *wp = TOP; break; + case 'm': *wp = MIDDLE; break; + case 'b': *wp = BOTTOM; break; + case 'B': *wp = BOTTOM_PLUS_ONE; break; + case 'j': *wp = sindex_from_sline(jump_sline); break; + default: *wp = TOP; p--; break; + } } return (p); } @@ -494,14 +494,14 @@ pr_expand(proto, maxwidth) { switch (*p) { - default: /* Just put the character in the message */ + default: /* Just put the character in the message */ ap_char(*p); break; - case '\\': /* Backslash escapes the next character */ + case '\\': /* Backslash escapes the next character */ p++; ap_char(*p); break; - case '?': /* Conditional (IF) */ + case '?': /* Conditional (IF) */ if ((c = *++p) == '\0') --p; else @@ -512,12 +512,12 @@ pr_expand(proto, maxwidth) p = skipcond(p); } break; - case ':': /* ELSE */ + case ':': /* ELSE */ p = skipcond(p); break; - case '.': /* ENDIF */ + case '.': /* ENDIF */ break; - case '%': /* Percent escape */ + case '%': /* Percent escape */ if ((c = *++p) == '\0') --p; else diff --git a/screen.c b/screen.c index 788c707c..15c9e561 100644 --- a/screen.c +++ b/screen.c @@ -78,17 +78,17 @@ extern int fd0; #endif #if OS2 -#define DEFAULT_TERM "ansi" +#define DEFAULT_TERM "ansi" static char *windowid; #else -#define DEFAULT_TERM "unknown" +#define DEFAULT_TERM "unknown" #endif #if MSDOS_COMPILER==MSOFTC static int videopages; static long msec_loops; static int flash_created = 0; -#define SETCOLORS(fg,bg) { _settextcolor(fg); _setbkcolor(bg); } +#define SETCOLORS(fg,bg) { _settextcolor(fg); _setbkcolor(bg); } #endif #if MSDOS_COMPILER==BORLANDC @@ -99,15 +99,15 @@ static int flash_created = 0; #define _settextposition(y,x) gotoxy(x,y) #define _clearscreen(m) clrscr() #define _outtext(s) cputs(s) -#define SETCOLORS(fg,bg) { textcolor(fg); textbackground(bg); } +#define SETCOLORS(fg,bg) { textcolor(fg); textbackground(bg); } extern int sc_height; #endif #if MSDOS_COMPILER==WIN32C struct keyRecord { - int ascii; - int scan; + int ascii; + int scan; } currentKey; static int keyCount = 0; @@ -131,29 +131,29 @@ static void win32_deinit_term(); #define FG_COLORS (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY) #define BG_COLORS (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY) -#define MAKEATTR(fg,bg) ((WORD)((fg)|((bg)<<4))) -#define SETCOLORS(fg,bg) { curr_attr = MAKEATTR(fg,bg); \ - if (SetConsoleTextAttribute(con_out, curr_attr) == 0) \ - error("SETCOLORS failed", NULL_PARG); } +#define MAKEATTR(fg,bg) ((WORD)((fg)|((bg)<<4))) +#define SETCOLORS(fg,bg) { curr_attr = MAKEATTR(fg,bg); \ + if (SetConsoleTextAttribute(con_out, curr_attr) == 0) \ + error("SETCOLORS failed", NULL_PARG); } #endif #if MSDOS_COMPILER -public int nm_fg_color; /* Color of normal text */ +public int nm_fg_color; /* Color of normal text */ public int nm_bg_color; -public int bo_fg_color; /* Color of bold text */ +public int bo_fg_color; /* Color of bold text */ public int bo_bg_color; -public int ul_fg_color; /* Color of underlined text */ +public int ul_fg_color; /* Color of underlined text */ public int ul_bg_color; -public int so_fg_color; /* Color of standout text */ +public int so_fg_color; /* Color of standout text */ public int so_bg_color; -public int bl_fg_color; /* Color of blinking text */ +public int bl_fg_color; /* Color of blinking text */ public int bl_bg_color; -static int sy_fg_color; /* Color of system text (before less) */ +static int sy_fg_color; /* Color of system text (before less) */ static int sy_bg_color; -public int sgr_mode; /* Honor ANSI sequences rather than using above */ +public int sgr_mode; /* Honor ANSI sequences rather than using above */ #if MSDOS_COMPILER==WIN32C -static DWORD init_output_mode; /* The initial console output mode */ -public int vt_enabled = -1; /* Is virtual terminal processing available? */ +static DWORD init_output_mode; /* The initial console output mode */ +public int vt_enabled = -1; /* Is virtual terminal processing available? */ #endif #else @@ -161,51 +161,51 @@ public int vt_enabled = -1; /* Is virtual terminal processing available? */ * Strings passed to tputs() to do various terminal functions. */ static char - *sc_pad, /* Pad string */ - *sc_home, /* Cursor home */ - *sc_addline, /* Add line, scroll down following lines */ - *sc_lower_left, /* Cursor to last line, first column */ - *sc_return, /* Cursor to beginning of current line */ - *sc_move, /* General cursor positioning */ - *sc_clear, /* Clear screen */ - *sc_eol_clear, /* Clear to end of line */ - *sc_eos_clear, /* Clear to end of screen */ - *sc_s_in, /* Enter standout (highlighted) mode */ - *sc_s_out, /* Exit standout mode */ - *sc_u_in, /* Enter underline mode */ - *sc_u_out, /* Exit underline mode */ - *sc_b_in, /* Enter bold mode */ - *sc_b_out, /* Exit bold mode */ - *sc_bl_in, /* Enter blink mode */ - *sc_bl_out, /* Exit blink mode */ - *sc_visual_bell, /* Visual bell (flash screen) sequence */ - *sc_backspace, /* Backspace cursor */ - *sc_s_keypad, /* Start keypad mode */ - *sc_e_keypad, /* End keypad mode */ - *sc_s_mousecap, /* Start mouse capture mode */ - *sc_e_mousecap, /* End mouse capture mode */ - *sc_init, /* Startup terminal initialization */ - *sc_deinit; /* Exit terminal de-initialization */ + *sc_pad, /* Pad string */ + *sc_home, /* Cursor home */ + *sc_addline, /* Add line, scroll down following lines */ + *sc_lower_left, /* Cursor to last line, first column */ + *sc_return, /* Cursor to beginning of current line */ + *sc_move, /* General cursor positioning */ + *sc_clear, /* Clear screen */ + *sc_eol_clear, /* Clear to end of line */ + *sc_eos_clear, /* Clear to end of screen */ + *sc_s_in, /* Enter standout (highlighted) mode */ + *sc_s_out, /* Exit standout mode */ + *sc_u_in, /* Enter underline mode */ + *sc_u_out, /* Exit underline mode */ + *sc_b_in, /* Enter bold mode */ + *sc_b_out, /* Exit bold mode */ + *sc_bl_in, /* Enter blink mode */ + *sc_bl_out, /* Exit blink mode */ + *sc_visual_bell, /* Visual bell (flash screen) sequence */ + *sc_backspace, /* Backspace cursor */ + *sc_s_keypad, /* Start keypad mode */ + *sc_e_keypad, /* End keypad mode */ + *sc_s_mousecap, /* Start mouse capture mode */ + *sc_e_mousecap, /* End mouse capture mode */ + *sc_init, /* Startup terminal initialization */ + *sc_deinit; /* Exit terminal de-initialization */ #endif static int init_done = 0; -public int auto_wrap; /* Terminal does \r\n when write past margin */ -public int ignaw; /* Terminal ignores \n immediately after wrap */ -public int erase_char; /* The user's erase char */ -public int erase2_char; /* The user's other erase char */ -public int kill_char; /* The user's line-kill char */ -public int werase_char; /* The user's word-erase char */ -public int sc_width, sc_height; /* Height & width of screen */ -public int bo_s_width, bo_e_width; /* Printing width of boldface seq */ -public int ul_s_width, ul_e_width; /* Printing width of underline seq */ -public int so_s_width, so_e_width; /* Printing width of standout seq */ -public int bl_s_width, bl_e_width; /* Printing width of blink seq */ -public int above_mem, below_mem; /* Memory retained above/below screen */ -public int can_goto_line; /* Can move cursor to any line */ -public int clear_bg; /* Clear fills with background color */ -public int missing_cap = 0; /* Some capability is missing */ -public char *kent = NULL; /* Keypad ENTER sequence */ +public int auto_wrap; /* Terminal does \r\n when write past margin */ +public int ignaw; /* Terminal ignores \n immediately after wrap */ +public int erase_char; /* The user's erase char */ +public int erase2_char; /* The user's other erase char */ +public int kill_char; /* The user's line-kill char */ +public int werase_char; /* The user's word-erase char */ +public int sc_width, sc_height; /* Height & width of screen */ +public int bo_s_width, bo_e_width; /* Printing width of boldface seq */ +public int ul_s_width, ul_e_width; /* Printing width of underline seq */ +public int so_s_width, so_e_width; /* Printing width of standout seq */ +public int bl_s_width, bl_e_width; /* Printing width of blink seq */ +public int above_mem, below_mem; /* Memory retained above/below screen */ +public int can_goto_line; /* Can move cursor to any line */ +public int clear_bg; /* Clear fills with background color */ +public int missing_cap = 0; /* Some capability is missing */ +public char *kent = NULL; /* Keypad ENTER sequence */ static int attrmode = AT_NORMAL; static int termcap_debug = -1; @@ -223,15 +223,15 @@ static void tmodes LESSPARAMS((char *incap, char *outcap, char **instr, * and needed by, the termcap library. */ #if MUST_DEFINE_OSPEED -extern short ospeed; /* Terminal output baud rate */ -extern char PC; /* Pad character */ +extern short ospeed; /* Terminal output baud rate */ +extern char PC; /* Pad character */ #endif #ifdef _OSK short ospeed; char PC_, *UP, *BC; #endif -extern int quiet; /* If VERY_QUIET, use visual bell for bell */ +extern int quiet; /* If VERY_QUIET, use visual bell for bell */ extern int no_back_scroll; extern int swindow; extern int no_init; @@ -265,28 +265,28 @@ extern char *tgoto(); /* * Change terminal to "raw mode", or restore to "normal" mode. * "Raw mode" means - * 1. An outstanding read will complete on receipt of a single keystroke. - * 2. Input is not echoed. - * 3. On output, \n is mapped to \r\n. - * 4. \t is NOT expanded into spaces. - * 5. Signal-causing characters such as ctrl-C (interrupt), - * etc. are NOT disabled. + * 1. An outstanding read will complete on receipt of a single keystroke. + * 2. Input is not echoed. + * 3. On output, \n is mapped to \r\n. + * 4. \t is NOT expanded into spaces. + * 5. Signal-causing characters such as ctrl-C (interrupt), + * etc. are NOT disabled. * It doesn't matter whether an input \n is mapped to \r, or vice versa. */ - public void + public void raw_mode(on) - int on; + int on; { - static int curr_on = 0; + static int curr_on = 0; - if (on == curr_on) - return; - erase2_char = '\b'; /* in case OS doesn't know about erase2 */ + if (on == curr_on) + return; + erase2_char = '\b'; /* in case OS doesn't know about erase2 */ #if HAVE_TERMIOS_H && HAVE_TERMIOS_FUNCS { - struct termios s; - static struct termios save_term; - static int saved_term = 0; + struct termios s; + static struct termios save_term; + static int saved_term = 0; if (on) { @@ -718,11 +718,11 @@ scrsize(VOID_PARAM) int n; #endif -#define DEF_SC_WIDTH 80 +#define DEF_SC_WIDTH 80 #if MSDOS_COMPILER -#define DEF_SC_HEIGHT 25 +#define DEF_SC_HEIGHT 25 #else -#define DEF_SC_HEIGHT 24 +#define DEF_SC_HEIGHT 24 #endif @@ -817,7 +817,7 @@ scrsize(VOID_PARAM) sc_height = atoi(s); #if !MSDOS_COMPILER else if ((n = ltgetnum("li")) > 0) - sc_height = n; + sc_height = n; #endif if (sc_height <= 0) sc_height = DEF_SC_HEIGHT; @@ -828,7 +828,7 @@ scrsize(VOID_PARAM) sc_width = atoi(s); #if !MSDOS_COMPILER else if ((n = ltgetnum("co")) > 0) - sc_width = n; + sc_width = n; #endif if (sc_width <= 0) sc_width = DEF_SC_WIDTH; @@ -890,176 +890,176 @@ special_key_str(key) static char tbuf[40]; char *s; #if MSDOS_COMPILER || OS2 - static char k_right[] = { '\340', PCK_RIGHT, 0 }; - static char k_left[] = { '\340', PCK_LEFT, 0 }; - static char k_ctl_right[] = { '\340', PCK_CTL_RIGHT, 0 }; - static char k_ctl_left[] = { '\340', PCK_CTL_LEFT, 0 }; - static char k_insert[] = { '\340', PCK_INSERT, 0 }; - static char k_delete[] = { '\340', PCK_DELETE, 0 }; - static char k_ctl_delete[] = { '\340', PCK_CTL_DELETE, 0 }; - static char k_ctl_backspace[] = { '\177', 0 }; - static char k_home[] = { '\340', PCK_HOME, 0 }; - static char k_end[] = { '\340', PCK_END, 0 }; - static char k_up[] = { '\340', PCK_UP, 0 }; - static char k_down[] = { '\340', PCK_DOWN, 0 }; - static char k_backtab[] = { '\340', PCK_SHIFT_TAB, 0 }; - static char k_pagedown[] = { '\340', PCK_PAGEDOWN, 0 }; - static char k_pageup[] = { '\340', PCK_PAGEUP, 0 }; - static char k_f1[] = { '\340', PCK_F1, 0 }; + static char k_right[] = { '\340', PCK_RIGHT, 0 }; + static char k_left[] = { '\340', PCK_LEFT, 0 }; + static char k_ctl_right[] = { '\340', PCK_CTL_RIGHT, 0 }; + static char k_ctl_left[] = { '\340', PCK_CTL_LEFT, 0 }; + static char k_insert[] = { '\340', PCK_INSERT, 0 }; + static char k_delete[] = { '\340', PCK_DELETE, 0 }; + static char k_ctl_delete[] = { '\340', PCK_CTL_DELETE, 0 }; + static char k_ctl_backspace[] = { '\177', 0 }; + static char k_home[] = { '\340', PCK_HOME, 0 }; + static char k_end[] = { '\340', PCK_END, 0 }; + static char k_up[] = { '\340', PCK_UP, 0 }; + static char k_down[] = { '\340', PCK_DOWN, 0 }; + static char k_backtab[] = { '\340', PCK_SHIFT_TAB, 0 }; + static char k_pagedown[] = { '\340', PCK_PAGEDOWN, 0 }; + static char k_pageup[] = { '\340', PCK_PAGEUP, 0 }; + static char k_f1[] = { '\340', PCK_F1, 0 }; #endif #if !MSDOS_COMPILER - char *sp = tbuf; + char *sp = tbuf; #endif - switch (key) - { + switch (key) + { #if OS2 - /* - * If windowid is not NULL, assume less is executed in - * the XFree86 environment. - */ - case SK_RIGHT_ARROW: - s = windowid ? ltgetstr("kr", &sp) : k_right; - break; - case SK_LEFT_ARROW: - s = windowid ? ltgetstr("kl", &sp) : k_left; - break; - case SK_UP_ARROW: - s = windowid ? ltgetstr("ku", &sp) : k_up; - break; - case SK_DOWN_ARROW: - s = windowid ? ltgetstr("kd", &sp) : k_down; - break; - case SK_PAGE_UP: - s = windowid ? ltgetstr("kP", &sp) : k_pageup; - break; - case SK_PAGE_DOWN: - s = windowid ? ltgetstr("kN", &sp) : k_pagedown; - break; - case SK_HOME: - s = windowid ? ltgetstr("kh", &sp) : k_home; - break; - case SK_END: - s = windowid ? ltgetstr("@7", &sp) : k_end; - break; - case SK_DELETE: - s = windowid ? ltgetstr("kD", &sp) : k_delete; - if (s == NULL) - { - tbuf[0] = '\177'; - tbuf[1] = '\0'; - s = tbuf; - } - break; + /* + * If windowid is not NULL, assume less is executed in + * the XFree86 environment. + */ + case SK_RIGHT_ARROW: + s = windowid ? ltgetstr("kr", &sp) : k_right; + break; + case SK_LEFT_ARROW: + s = windowid ? ltgetstr("kl", &sp) : k_left; + break; + case SK_UP_ARROW: + s = windowid ? ltgetstr("ku", &sp) : k_up; + break; + case SK_DOWN_ARROW: + s = windowid ? ltgetstr("kd", &sp) : k_down; + break; + case SK_PAGE_UP: + s = windowid ? ltgetstr("kP", &sp) : k_pageup; + break; + case SK_PAGE_DOWN: + s = windowid ? ltgetstr("kN", &sp) : k_pagedown; + break; + case SK_HOME: + s = windowid ? ltgetstr("kh", &sp) : k_home; + break; + case SK_END: + s = windowid ? ltgetstr("@7", &sp) : k_end; + break; + case SK_DELETE: + s = windowid ? ltgetstr("kD", &sp) : k_delete; + if (s == NULL) + { + tbuf[0] = '\177'; + tbuf[1] = '\0'; + s = tbuf; + } + break; #endif #if MSDOS_COMPILER - case SK_RIGHT_ARROW: - s = k_right; - break; - case SK_LEFT_ARROW: - s = k_left; - break; - case SK_UP_ARROW: - s = k_up; - break; - case SK_DOWN_ARROW: - s = k_down; - break; - case SK_PAGE_UP: - s = k_pageup; - break; - case SK_PAGE_DOWN: - s = k_pagedown; - break; - case SK_HOME: - s = k_home; - break; - case SK_END: - s = k_end; - break; - case SK_DELETE: - s = k_delete; - break; + case SK_RIGHT_ARROW: + s = k_right; + break; + case SK_LEFT_ARROW: + s = k_left; + break; + case SK_UP_ARROW: + s = k_up; + break; + case SK_DOWN_ARROW: + s = k_down; + break; + case SK_PAGE_UP: + s = k_pageup; + break; + case SK_PAGE_DOWN: + s = k_pagedown; + break; + case SK_HOME: + s = k_home; + break; + case SK_END: + s = k_end; + break; + case SK_DELETE: + s = k_delete; + break; #endif #if MSDOS_COMPILER || OS2 - case SK_INSERT: - s = k_insert; - break; - case SK_CTL_LEFT_ARROW: - s = k_ctl_left; - break; - case SK_CTL_RIGHT_ARROW: - s = k_ctl_right; - break; - case SK_CTL_BACKSPACE: - s = k_ctl_backspace; - break; - case SK_CTL_DELETE: - s = k_ctl_delete; - break; - case SK_F1: - s = k_f1; - break; - case SK_BACKTAB: - s = k_backtab; - break; -#else - case SK_RIGHT_ARROW: - s = ltgetstr("kr", &sp); - break; - case SK_LEFT_ARROW: - s = ltgetstr("kl", &sp); - break; - case SK_UP_ARROW: - s = ltgetstr("ku", &sp); - break; - case SK_DOWN_ARROW: - s = ltgetstr("kd", &sp); - break; - case SK_PAGE_UP: - s = ltgetstr("kP", &sp); - break; - case SK_PAGE_DOWN: - s = ltgetstr("kN", &sp); - break; - case SK_HOME: - s = ltgetstr("kh", &sp); - break; - case SK_END: - s = ltgetstr("@7", &sp); - break; - case SK_DELETE: - s = ltgetstr("kD", &sp); - if (s == NULL) - { - tbuf[0] = '\177'; - tbuf[1] = '\0'; - s = tbuf; - } - break; -#endif - case SK_CONTROL_K: - tbuf[0] = CONTROL('K'); - tbuf[1] = '\0'; - s = tbuf; - break; - default: - return (NULL); - } - return (s); + case SK_INSERT: + s = k_insert; + break; + case SK_CTL_LEFT_ARROW: + s = k_ctl_left; + break; + case SK_CTL_RIGHT_ARROW: + s = k_ctl_right; + break; + case SK_CTL_BACKSPACE: + s = k_ctl_backspace; + break; + case SK_CTL_DELETE: + s = k_ctl_delete; + break; + case SK_F1: + s = k_f1; + break; + case SK_BACKTAB: + s = k_backtab; + break; +#else + case SK_RIGHT_ARROW: + s = ltgetstr("kr", &sp); + break; + case SK_LEFT_ARROW: + s = ltgetstr("kl", &sp); + break; + case SK_UP_ARROW: + s = ltgetstr("ku", &sp); + break; + case SK_DOWN_ARROW: + s = ltgetstr("kd", &sp); + break; + case SK_PAGE_UP: + s = ltgetstr("kP", &sp); + break; + case SK_PAGE_DOWN: + s = ltgetstr("kN", &sp); + break; + case SK_HOME: + s = ltgetstr("kh", &sp); + break; + case SK_END: + s = ltgetstr("@7", &sp); + break; + case SK_DELETE: + s = ltgetstr("kD", &sp); + if (s == NULL) + { + tbuf[0] = '\177'; + tbuf[1] = '\0'; + s = tbuf; + } + break; +#endif + case SK_CONTROL_K: + tbuf[0] = CONTROL('K'); + tbuf[1] = '\0'; + s = tbuf; + break; + default: + return (NULL); + } + return (s); } /* * Get terminal capabilities via termcap. */ - public void + public void get_term(VOID_PARAM) { - termcap_debug = !isnullenv(lgetenv("LESS_TERMCAP_DEBUG")); + termcap_debug = !isnullenv(lgetenv("LESS_TERMCAP_DEBUG")); #if MSDOS_COMPILER - auto_wrap = 1; - ignaw = 0; - can_goto_line = 1; + auto_wrap = 1; + ignaw = 0; + can_goto_line = 1; clear_bg = 1; /* * Set up default colors. diff --git a/search.c b/search.c index 1165ba3d..77c5f4a5 100644 --- a/search.c +++ b/search.c @@ -9,8 +9,8 @@ #include "position.h" #include "charset.h" -#define MINPOS(a,b) (((a) < (b)) ? (a) : (b)) -#define MAXPOS(a,b) (((a) > (b)) ? (a) : (b)) +#define MINPOS(a,b) (((a) < (b)) ? (a) : (b)) +#define MAXPOS(a,b) (((a) > (b)) ? (a) : (b)) extern int sigs; extern int how_search; @@ -1158,13 +1158,13 @@ search_pos(search_type) */ static int matches_filters(pos, cline, line_len, chpos, linepos, sp, ep) - POSITION pos; - char *cline; - int line_len; - int *chpos; - POSITION linepos; - char **sp; - char **ep; + POSITION pos; + char *cline; + int line_len; + int *chpos; + POSITION linepos; + char **sp; + char **ep; { struct pattern_info *filter; @@ -1331,11 +1331,11 @@ search_range(pos, endpos, search_type, matches, maxlines, plinepos, pendpos) cvt_text(cline, line, chpos, &line_len, cvt_ops); #if HILITE_SEARCH - /* - * If any filters are in effect, ignore non-matching lines. - */ + /* + * If any filters are in effect, ignore non-matching lines. + */ if (filter_infos != NULL && - ((search_type & SRCH_FIND_ALL) || + ((search_type & SRCH_FIND_ALL) || prep_startpos == NULL_POSITION || linepos < prep_startpos || linepos >= prep_endpos)) { if (matches_filters(pos, cline, line_len, chpos, linepos, &sp, &ep)) @@ -1413,7 +1413,7 @@ hist_pattern(search_type) return (0); if (set_pattern(&search_info, pattern, search_type, 1) < 0) - return (-1); + return (0); #if HILITE_SEARCH if (hilite_search == OPT_ONPLUS && !hide_hilite) @@ -1446,7 +1446,7 @@ chg_caseless(VOID_PARAM) * Regenerate the pattern using the new state. */ clear_pattern(&search_info); - (void) hist_pattern(search_info.search_type); + hist_pattern(search_info.search_type); } } @@ -1474,13 +1474,10 @@ search(search_type, pattern, n) * A null pattern means use the previously compiled pattern. */ search_type |= SRCH_AFTER_TARGET; - if (!prev_pattern(&search_info)) + if (!prev_pattern(&search_info) && !hist_pattern(search_type)) { - int r = hist_pattern(search_type); - if (r == 0) - error("No previous regular expression", NULL_PARG); - if (r <= 0) - return (-1); + error("No previous regular expression", NULL_PARG); + return (-1); } if ((search_type & SRCH_NO_REGEX) != (search_info.search_type & SRCH_NO_REGEX)) @@ -1622,7 +1619,7 @@ prep_hilite(spos, epos, maxlines) * Search beyond where we're asked to search, so the prep region covers * more than we need. Do one big search instead of a bunch of small ones. */ -#define SEARCH_MORE (3*size_linebuf) +#define SEARCH_MORE (3*size_linebuf) if (!prev_pattern(&search_info) && !is_filtering()) return; diff --git a/tags.c b/tags.c index f037f9c0..14f6b890 100644 --- a/tags.c +++ b/tags.c @@ -3,7 +3,7 @@ #include "less.h" -#define WHITESP(c) ((c)==' ' || (c)=='\t') +#define WHITESP(c) ((c)==' ' || (c)=='\t') #if TAGS @@ -18,23 +18,23 @@ extern int sigs; extern int ctldisp; enum tag_result { - TAG_FOUND, - TAG_NOFILE, - TAG_NOTAG, - TAG_NOTYPE, - TAG_INTR + TAG_FOUND, + TAG_NOFILE, + TAG_NOTAG, + TAG_NOTYPE, + TAG_INTR }; /* * Tag type */ enum { - T_CTAGS, /* 'tags': standard and extended format (ctags) */ - T_CTAGS_X, /* stdin: cross reference format (ctags) */ - T_GTAGS, /* 'GTAGS': function definition (global) */ - T_GRTAGS, /* 'GRTAGS': function reference (global) */ - T_GSYMS, /* 'GSYMS': other symbols (global) */ - T_GPATH /* 'GPATH': path name (global) */ + T_CTAGS, /* 'tags': standard and extended format (ctags) */ + T_CTAGS_X, /* stdin: cross reference format (ctags) */ + T_GTAGS, /* 'GTAGS': function definition (global) */ + T_GRTAGS, /* 'GRTAGS': function reference (global) */ + T_GSYMS, /* 'GSYMS': other symbols (global) */ + T_GPATH /* 'GPATH': path name (global) */ }; static enum tag_result findctag LESSPARAMS((char *tag)); @@ -55,107 +55,107 @@ static int getentry LESSPARAMS((char *buf, char **tag, char **file, * or line number (in which case pattern is NULL). */ struct taglist { - struct tag *tl_first; - struct tag *tl_last; + struct tag *tl_first; + struct tag *tl_last; }; struct tag { - struct tag *next, *prev; /* List links */ - char *tag_file; /* Source file containing the tag */ - LINENUM tag_linenum; /* Appropriate line number in source file */ - char *tag_pattern; /* Pattern used to find the tag */ - char tag_endline; /* True if the pattern includes '$' */ + struct tag *next, *prev; /* List links */ + char *tag_file; /* Source file containing the tag */ + LINENUM tag_linenum; /* Appropriate line number in source file */ + char *tag_pattern; /* Pattern used to find the tag */ + char tag_endline; /* True if the pattern includes '$' */ }; #define TAG_END ((struct tag *) &taglist) static struct taglist taglist = { TAG_END, TAG_END }; static struct tag *curtag; #define TAG_INS(tp) \ - (tp)->next = TAG_END; \ - (tp)->prev = taglist.tl_last; \ - taglist.tl_last->next = (tp); \ - taglist.tl_last = (tp); + (tp)->next = TAG_END; \ + (tp)->prev = taglist.tl_last; \ + taglist.tl_last->next = (tp); \ + taglist.tl_last = (tp); #define TAG_RM(tp) \ - (tp)->next->prev = (tp)->prev; \ - (tp)->prev->next = (tp)->next; + (tp)->next->prev = (tp)->prev; \ + (tp)->prev->next = (tp)->next; /* * Delete tag structures. */ - public void + public void cleantags(VOID_PARAM) { - struct tag *tp; - - /* - * Delete any existing tag list. - * {{ Ideally, we wouldn't do this until after we know that we - * can load some other tag information. }} - */ - while ((tp = taglist.tl_first) != TAG_END) - { - TAG_RM(tp); - free(tp->tag_file); - free(tp->tag_pattern); - free(tp); - } - curtag = NULL; - total = curseq = 0; + struct tag *tp; + + /* + * Delete any existing tag list. + * {{ Ideally, we wouldn't do this until after we know that we + * can load some other tag information. }} + */ + while ((tp = taglist.tl_first) != TAG_END) + { + TAG_RM(tp); + free(tp->tag_file); + free(tp->tag_pattern); + free(tp); + } + curtag = NULL; + total = curseq = 0; } /* * Create a new tag entry. */ - static struct tag * + static struct tag * maketagent(name, file, linenum, pattern, endline) - char *name; - char *file; - LINENUM linenum; - char *pattern; - int endline; + char *name; + char *file; + LINENUM linenum; + char *pattern; + int endline; { - struct tag *tp; - - tp = (struct tag *) ecalloc(sizeof(struct tag), 1); - tp->tag_file = (char *) ecalloc(strlen(file) + 1, sizeof(char)); - strcpy(tp->tag_file, file); - tp->tag_linenum = linenum; - tp->tag_endline = endline; - if (pattern == NULL) - tp->tag_pattern = NULL; - else - { - tp->tag_pattern = (char *) ecalloc(strlen(pattern) + 1, sizeof(char)); - strcpy(tp->tag_pattern, pattern); - } - return (tp); + struct tag *tp; + + tp = (struct tag *) ecalloc(sizeof(struct tag), 1); + tp->tag_file = (char *) ecalloc(strlen(file) + 1, sizeof(char)); + strcpy(tp->tag_file, file); + tp->tag_linenum = linenum; + tp->tag_endline = endline; + if (pattern == NULL) + tp->tag_pattern = NULL; + else + { + tp->tag_pattern = (char *) ecalloc(strlen(pattern) + 1, sizeof(char)); + strcpy(tp->tag_pattern, pattern); + } + return (tp); } /* * Get tag mode. */ - public int + public int gettagtype(VOID_PARAM) { - int f; - - if (strcmp(tags, "GTAGS") == 0) - return T_GTAGS; - if (strcmp(tags, "GRTAGS") == 0) - return T_GRTAGS; - if (strcmp(tags, "GSYMS") == 0) - return T_GSYMS; - if (strcmp(tags, "GPATH") == 0) - return T_GPATH; - if (strcmp(tags, "-") == 0) - return T_CTAGS_X; - f = open(tags, OPEN_READ); - if (f >= 0) - { - close(f); - return T_CTAGS; - } - return T_GTAGS; + int f; + + if (strcmp(tags, "GTAGS") == 0) + return T_GTAGS; + if (strcmp(tags, "GRTAGS") == 0) + return T_GRTAGS; + if (strcmp(tags, "GSYMS") == 0) + return T_GSYMS; + if (strcmp(tags, "GPATH") == 0) + return T_GPATH; + if (strcmp(tags, "-") == 0) + return T_CTAGS_X; + f = open(tags, OPEN_READ); + if (f >= 0) + { + close(f); + return T_CTAGS; + } + return T_GTAGS; } /* @@ -165,92 +165,92 @@ gettagtype(VOID_PARAM) * and "tagpattern" to the search pattern which should be used * to find the tag. */ - public void + public void findtag(tag) - char *tag; + char *tag; { - int type = gettagtype(); - enum tag_result result; - - if (type == T_CTAGS) - result = findctag(tag); - else - result = findgtag(tag, type); - switch (result) - { - case TAG_FOUND: - case TAG_INTR: - break; - case TAG_NOFILE: - error("No tags file", NULL_PARG); - break; - case TAG_NOTAG: - error("No such tag in tags file", NULL_PARG); - break; - case TAG_NOTYPE: - error("unknown tag type", NULL_PARG); - break; - } + int type = gettagtype(); + enum tag_result result; + + if (type == T_CTAGS) + result = findctag(tag); + else + result = findgtag(tag, type); + switch (result) + { + case TAG_FOUND: + case TAG_INTR: + break; + case TAG_NOFILE: + error("No tags file", NULL_PARG); + break; + case TAG_NOTAG: + error("No such tag in tags file", NULL_PARG); + break; + case TAG_NOTYPE: + error("unknown tag type", NULL_PARG); + break; + } } /* * Search for a tag. */ - public POSITION + public POSITION tagsearch(VOID_PARAM) { - if (curtag == NULL) - return (NULL_POSITION); /* No gtags loaded! */ - if (curtag->tag_linenum != 0) - return gtagsearch(); - else - return ctagsearch(); + if (curtag == NULL) + return (NULL_POSITION); /* No gtags loaded! */ + if (curtag->tag_linenum != 0) + return gtagsearch(); + else + return ctagsearch(); } /* * Go to the next tag. */ - public char * + public char * nexttag(n) - int n; + int n; { - char *tagfile = (char *) NULL; + char *tagfile = (char *) NULL; - while (n-- > 0) - tagfile = nextgtag(); - return tagfile; + while (n-- > 0) + tagfile = nextgtag(); + return tagfile; } /* * Go to the previous tag. */ - public char * + public char * prevtag(n) - int n; + int n; { - char *tagfile = (char *) NULL; + char *tagfile = (char *) NULL; - while (n-- > 0) - tagfile = prevgtag(); - return tagfile; + while (n-- > 0) + tagfile = prevgtag(); + return tagfile; } /* * Return the total number of tags. */ - public int + public int ntags(VOID_PARAM) { - return total; + return total; } /* * Return the sequence number of current tag. */ - public int + public int curr_tag(VOID_PARAM) { - return curseq; + return curseq; } /***************************************************************************** @@ -261,221 +261,221 @@ curr_tag(VOID_PARAM) * Find tags in the "tags" file. * Sets curtag to the first tag entry. */ - static enum tag_result + static enum tag_result findctag(tag) - char *tag; + char *tag; { - char *p; - FILE *f; - int taglen; - LINENUM taglinenum; - char *tagfile; - char *tagpattern; - int tagendline; - int search_char; - int err; - char tline[TAGLINE_SIZE]; - struct tag *tp; - - p = shell_unquote(tags); - f = fopen(p, "r"); - free(p); - if (f == NULL) - return TAG_NOFILE; - - cleantags(); - total = 0; - taglen = (int) strlen(tag); - - /* - * Search the tags file for the desired tag. - */ - while (fgets(tline, sizeof(tline), f) != NULL) - { - if (tline[0] == '!') - /* Skip header of extended format. */ - continue; - if (strncmp(tag, tline, taglen) != 0 || !WHITESP(tline[taglen])) - continue; - - /* - * Found it. - * The line contains the tag, the filename and the - * location in the file, separated by white space. - * The location is either a decimal line number, - * or a search pattern surrounded by a pair of delimiters. - * Parse the line and extract these parts. - */ - tagpattern = NULL; - - /* - * Skip over the whitespace after the tag name. - */ - p = skipsp(tline+taglen); - if (*p == '\0') - /* File name is missing! */ - continue; - - /* - * Save the file name. - * Skip over the whitespace after the file name. - */ - tagfile = p; - while (!WHITESP(*p) && *p != '\0') - p++; - *p++ = '\0'; - p = skipsp(p); - if (*p == '\0') - /* Pattern is missing! */ - continue; - - /* - * First see if it is a line number. - */ - tagendline = 0; - taglinenum = getnum(&p, 0, &err); - if (err) - { - /* - * No, it must be a pattern. - * Delete the initial "^" (if present) and - * the final "$" from the pattern. - * Delete any backslash in the pattern. - */ - taglinenum = 0; - search_char = *p++; - if (*p == '^') - p++; - tagpattern = p; - while (*p != search_char && *p != '\0') - { - if (*p == '\\') - p++; - p++; - } - tagendline = (p[-1] == '$'); - if (tagendline) - p--; - *p = '\0'; - } - tp = maketagent(tag, tagfile, taglinenum, tagpattern, tagendline); - TAG_INS(tp); - total++; - } - fclose(f); - if (total == 0) - return TAG_NOTAG; - curtag = taglist.tl_first; - curseq = 1; - return TAG_FOUND; + char *p; + FILE *f; + int taglen; + LINENUM taglinenum; + char *tagfile; + char *tagpattern; + int tagendline; + int search_char; + int err; + char tline[TAGLINE_SIZE]; + struct tag *tp; + + p = shell_unquote(tags); + f = fopen(p, "r"); + free(p); + if (f == NULL) + return TAG_NOFILE; + + cleantags(); + total = 0; + taglen = (int) strlen(tag); + + /* + * Search the tags file for the desired tag. + */ + while (fgets(tline, sizeof(tline), f) != NULL) + { + if (tline[0] == '!') + /* Skip header of extended format. */ + continue; + if (strncmp(tag, tline, taglen) != 0 || !WHITESP(tline[taglen])) + continue; + + /* + * Found it. + * The line contains the tag, the filename and the + * location in the file, separated by white space. + * The location is either a decimal line number, + * or a search pattern surrounded by a pair of delimiters. + * Parse the line and extract these parts. + */ + tagpattern = NULL; + + /* + * Skip over the whitespace after the tag name. + */ + p = skipsp(tline+taglen); + if (*p == '\0') + /* File name is missing! */ + continue; + + /* + * Save the file name. + * Skip over the whitespace after the file name. + */ + tagfile = p; + while (!WHITESP(*p) && *p != '\0') + p++; + *p++ = '\0'; + p = skipsp(p); + if (*p == '\0') + /* Pattern is missing! */ + continue; + + /* + * First see if it is a line number. + */ + tagendline = 0; + taglinenum = getnum(&p, 0, &err); + if (err) + { + /* + * No, it must be a pattern. + * Delete the initial "^" (if present) and + * the final "$" from the pattern. + * Delete any backslash in the pattern. + */ + taglinenum = 0; + search_char = *p++; + if (*p == '^') + p++; + tagpattern = p; + while (*p != search_char && *p != '\0') + { + if (*p == '\\') + p++; + p++; + } + tagendline = (p[-1] == '$'); + if (tagendline) + p--; + *p = '\0'; + } + tp = maketagent(tag, tagfile, taglinenum, tagpattern, tagendline); + TAG_INS(tp); + total++; + } + fclose(f); + if (total == 0) + return TAG_NOTAG; + curtag = taglist.tl_first; + curseq = 1; + return TAG_FOUND; } /* * Edit current tagged file. */ - public int + public int edit_tagfile(VOID_PARAM) { - if (curtag == NULL) - return (1); - return (edit(curtag->tag_file)); + if (curtag == NULL) + return (1); + return (edit(curtag->tag_file)); } - static int + static int curtag_match(char const *line, POSITION linepos) { - /* - * Test the line to see if we have a match. - * Use strncmp because the pattern may be - * truncated (in the tags file) if it is too long. - * If tagendline is set, make sure we match all - * the way to end of line (no extra chars after the match). - */ - int len = (int) strlen(curtag->tag_pattern); - if (strncmp(curtag->tag_pattern, line, len) == 0 && - (!curtag->tag_endline || line[len] == '\0' || line[len] == '\r')) - { - curtag->tag_linenum = find_linenum(linepos); - return 1; - } - return 0; + /* + * Test the line to see if we have a match. + * Use strncmp because the pattern may be + * truncated (in the tags file) if it is too long. + * If tagendline is set, make sure we match all + * the way to end of line (no extra chars after the match). + */ + int len = (int) strlen(curtag->tag_pattern); + if (strncmp(curtag->tag_pattern, line, len) == 0 && + (!curtag->tag_endline || line[len] == '\0' || line[len] == '\r')) + { + curtag->tag_linenum = find_linenum(linepos); + return 1; + } + return 0; } /* * Search for a tag. * This is a stripped-down version of search(). * We don't use search() for several reasons: - * - We don't want to blow away any search string we may have saved. - * - The various regular-expression functions (from different systems: - * regcmp vs. re_comp) behave differently in the presence of - * parentheses (which are almost always found in a tag). + * - We don't want to blow away any search string we may have saved. + * - The various regular-expression functions (from different systems: + * regcmp vs. re_comp) behave differently in the presence of + * parentheses (which are almost always found in a tag). */ - static POSITION + static POSITION ctagsearch(VOID_PARAM) { - POSITION pos, linepos; - LINENUM linenum; - int line_len; - char *line; - int found; - - pos = ch_zero(); - linenum = find_linenum(pos); - - for (found = 0; !found;) - { - /* - * Get lines until we find a matching one or - * until we hit end-of-file. - */ - if (ABORT_SIGS()) - return (NULL_POSITION); - - /* - * Read the next line, and save the - * starting position of that line in linepos. - */ - linepos = pos; - pos = forw_raw_line(pos, &line, &line_len); - if (linenum != 0) - linenum++; - - if (pos == NULL_POSITION) - { - /* - * We hit EOF without a match. - */ - error("Tag not found", NULL_PARG); - return (NULL_POSITION); - } - - /* - * If we're using line numbers, we might as well - * remember the information we have now (the position - * and line number of the current line). - */ - if (linenums) - add_lnum(linenum, pos); - - if (ctldisp != OPT_ONPLUS) - { - if (curtag_match(line, linepos)) - found = 1; - } else - { - int cvt_ops = CVT_ANSI; - int cvt_len = cvt_length(line_len, cvt_ops); - int *chpos = cvt_alloc_chpos(cvt_len); - char *cline = (char *) ecalloc(1, cvt_len); - cvt_text(cline, line, chpos, &line_len, cvt_ops); - if (curtag_match(cline, linepos)) - found = 1; - free(chpos); - free(cline); - } - } - - return (linepos); + POSITION pos, linepos; + LINENUM linenum; + int line_len; + char *line; + int found; + + pos = ch_zero(); + linenum = find_linenum(pos); + + for (found = 0; !found;) + { + /* + * Get lines until we find a matching one or + * until we hit end-of-file. + */ + if (ABORT_SIGS()) + return (NULL_POSITION); + + /* + * Read the next line, and save the + * starting position of that line in linepos. + */ + linepos = pos; + pos = forw_raw_line(pos, &line, &line_len); + if (linenum != 0) + linenum++; + + if (pos == NULL_POSITION) + { + /* + * We hit EOF without a match. + */ + error("Tag not found", NULL_PARG); + return (NULL_POSITION); + } + + /* + * If we're using line numbers, we might as well + * remember the information we have now (the position + * and line number of the current line). + */ + if (linenums) + add_lnum(linenum, pos); + + if (ctldisp != OPT_ONPLUS) + { + if (curtag_match(line, linepos)) + found = 1; + } else + { + int cvt_ops = CVT_ANSI; + int cvt_len = cvt_length(line_len, cvt_ops); + int *chpos = cvt_alloc_chpos(cvt_len); + char *cline = (char *) ecalloc(1, cvt_len); + cvt_text(cline, line, chpos, &line_len, cvt_ops); + if (curtag_match(cline, linepos)) + found = 1; + free(chpos); + free(cline); + } + } + + return (linepos); } /******************************************************************************* @@ -489,164 +489,164 @@ ctagsearch(VOID_PARAM) * for future use by gtagsearch(). * Sets curtag to the first tag entry. */ - static enum tag_result + static enum tag_result findgtag(tag, type) - char *tag; /* tag to load */ - int type; /* tags type */ + char *tag; /* tag to load */ + int type; /* tags type */ { - char buf[256]; - FILE *fp; - struct tag *tp; - - if (type != T_CTAGS_X && tag == NULL) - return TAG_NOFILE; - - cleantags(); - total = 0; - - /* - * If type == T_CTAGS_X then read ctags's -x format from stdin - * else execute global(1) and read from it. - */ - if (type == T_CTAGS_X) - { - fp = stdin; - /* Set tag default because we cannot read stdin again. */ - tags = ztags; - } else - { + char buf[256]; + FILE *fp; + struct tag *tp; + + if (type != T_CTAGS_X && tag == NULL) + return TAG_NOFILE; + + cleantags(); + total = 0; + + /* + * If type == T_CTAGS_X then read ctags's -x format from stdin + * else execute global(1) and read from it. + */ + if (type == T_CTAGS_X) + { + fp = stdin; + /* Set tag default because we cannot read stdin again. */ + tags = ztags; + } else + { #if !HAVE_POPEN - return TAG_NOFILE; + return TAG_NOFILE; #else - char *command; - char *flag; - char *qtag; - char *cmd = lgetenv("LESSGLOBALTAGS"); - - if (isnullenv(cmd)) - return TAG_NOFILE; - /* Get suitable flag value for global(1). */ - switch (type) - { - case T_GTAGS: - flag = "" ; - break; - case T_GRTAGS: - flag = "r"; - break; - case T_GSYMS: - flag = "s"; - break; - case T_GPATH: - flag = "P"; - break; - default: - return TAG_NOTYPE; - } - - /* Get our data from global(1). */ - qtag = shell_quote(tag); - if (qtag == NULL) - qtag = tag; - command = (char *) ecalloc(strlen(cmd) + strlen(flag) + - strlen(qtag) + 5, sizeof(char)); - sprintf(command, "%s -x%s %s", cmd, flag, qtag); - if (qtag != tag) - free(qtag); - fp = popen(command, "r"); - free(command); + char *command; + char *flag; + char *qtag; + char *cmd = lgetenv("LESSGLOBALTAGS"); + + if (isnullenv(cmd)) + return TAG_NOFILE; + /* Get suitable flag value for global(1). */ + switch (type) + { + case T_GTAGS: + flag = "" ; + break; + case T_GRTAGS: + flag = "r"; + break; + case T_GSYMS: + flag = "s"; + break; + case T_GPATH: + flag = "P"; + break; + default: + return TAG_NOTYPE; + } + + /* Get our data from global(1). */ + qtag = shell_quote(tag); + if (qtag == NULL) + qtag = tag; + command = (char *) ecalloc(strlen(cmd) + strlen(flag) + + strlen(qtag) + 5, sizeof(char)); + sprintf(command, "%s -x%s %s", cmd, flag, qtag); + if (qtag != tag) + free(qtag); + fp = popen(command, "r"); + free(command); #endif - } - if (fp != NULL) - { - while (fgets(buf, sizeof(buf), fp)) - { - char *name, *file, *line; - int len; - - if (sigs) - { + } + if (fp != NULL) + { + while (fgets(buf, sizeof(buf), fp)) + { + char *name, *file, *line; + int len; + + if (sigs) + { #if HAVE_POPEN - if (fp != stdin) - pclose(fp); + if (fp != stdin) + pclose(fp); #endif - return TAG_INTR; - } - len = (int) strlen(buf); - if (len > 0 && buf[len-1] == '\n') - buf[len-1] = '\0'; - else - { - int c; - do { - c = fgetc(fp); - } while (c != '\n' && c != EOF); - } - - if (getentry(buf, &name, &file, &line)) - { - /* - * Couldn't parse this line for some reason. - * We'll just pretend it never happened. - */ - break; - } - - /* Make new entry and add to list. */ - tp = maketagent(name, file, (LINENUM) atoi(line), NULL, 0); - TAG_INS(tp); - total++; - } - if (fp != stdin) - { - if (pclose(fp)) - { - curtag = NULL; - total = curseq = 0; - return TAG_NOFILE; - } - } - } - - /* Check to see if we found anything. */ - tp = taglist.tl_first; - if (tp == TAG_END) - return TAG_NOTAG; - curtag = tp; - curseq = 1; - return TAG_FOUND; + return TAG_INTR; + } + len = (int) strlen(buf); + if (len > 0 && buf[len-1] == '\n') + buf[len-1] = '\0'; + else + { + int c; + do { + c = fgetc(fp); + } while (c != '\n' && c != EOF); + } + + if (getentry(buf, &name, &file, &line)) + { + /* + * Couldn't parse this line for some reason. + * We'll just pretend it never happened. + */ + break; + } + + /* Make new entry and add to list. */ + tp = maketagent(name, file, (LINENUM) atoi(line), NULL, 0); + TAG_INS(tp); + total++; + } + if (fp != stdin) + { + if (pclose(fp)) + { + curtag = NULL; + total = curseq = 0; + return TAG_NOFILE; + } + } + } + + /* Check to see if we found anything. */ + tp = taglist.tl_first; + if (tp == TAG_END) + return TAG_NOTAG; + curtag = tp; + curseq = 1; + return TAG_FOUND; } -static int circular = 0; /* 1: circular tag structure */ +static int circular = 0; /* 1: circular tag structure */ /* * Return the filename required for the next gtag in the queue that was setup * by findgtag(). The next call to gtagsearch() will try to position at the * appropriate tag. */ - static char * + static char * nextgtag(VOID_PARAM) { - struct tag *tp; - - if (curtag == NULL) - /* No tag loaded */ - return NULL; - - tp = curtag->next; - if (tp == TAG_END) - { - if (!circular) - return NULL; - /* Wrapped around to the head of the queue */ - curtag = taglist.tl_first; - curseq = 1; - } else - { - curtag = tp; - curseq++; - } - return (curtag->tag_file); + struct tag *tp; + + if (curtag == NULL) + /* No tag loaded */ + return NULL; + + tp = curtag->next; + if (tp == TAG_END) + { + if (!circular) + return NULL; + /* Wrapped around to the head of the queue */ + curtag = taglist.tl_first; + curseq = 1; + } else + { + curtag = tp; + curseq++; + } + return (curtag->tag_file); } /* @@ -654,29 +654,29 @@ nextgtag(VOID_PARAM) * setup by findgtat(). The next call to gtagsearch() will try to position * at the appropriate tag. */ - static char * + static char * prevgtag(VOID_PARAM) { - struct tag *tp; - - if (curtag == NULL) - /* No tag loaded */ - return NULL; - - tp = curtag->prev; - if (tp == TAG_END) - { - if (!circular) - return NULL; - /* Wrapped around to the tail of the queue */ - curtag = taglist.tl_last; - curseq = total; - } else - { - curtag = tp; - curseq--; - } - return (curtag->tag_file); + struct tag *tp; + + if (curtag == NULL) + /* No tag loaded */ + return NULL; + + tp = curtag->prev; + if (tp == TAG_END) + { + if (!circular) + return NULL; + /* Wrapped around to the tail of the queue */ + curtag = taglist.tl_last; + curseq = total; + } else + { + curtag = tp; + curseq--; + } + return (curtag->tag_file); } /* @@ -684,12 +684,12 @@ prevgtag(VOID_PARAM) * using either findtag() or one of nextgtag() and prevgtag(). Returns -1 * if it was unable to position at the tag, 0 if successful. */ - static POSITION + static POSITION gtagsearch(VOID_PARAM) { - if (curtag == NULL) - return (NULL_POSITION); /* No gtags loaded! */ - return (find_pos(curtag->tag_linenum)); + if (curtag == NULL) + return (NULL_POSITION); /* No gtags loaded! */ + return (find_pos(curtag->tag_linenum)); } /* @@ -702,9 +702,9 @@ gtagsearch(VOID_PARAM) * |func 21 subr.c func(arg) * * The following commands write this format. - * o Traditinal Ctags with -x option - * o Global with -x option - * See + * o Traditinal Ctags with -x option + * o Global with -x option + * See * * [extended format] * @@ -713,65 +713,65 @@ gtagsearch(VOID_PARAM) * |func function 21 subr.c func(arg) * * The following commands write this format. - * o Exuberant Ctags with -x option - * See + * o Exuberant Ctags with -x option + * See * * Returns 0 on success, -1 on error. * The tag, file, and line will each be NUL-terminated pointers * into buf. */ - static int + static int getentry(buf, tag, file, line) - char *buf; /* standard or extended ctags -x format data */ - char **tag; /* name of the tag we actually found */ - char **file; /* file in which to find this tag */ - char **line; /* line number of file where this tag is found */ + char *buf; /* standard or extended ctags -x format data */ + char **tag; /* name of the tag we actually found */ + char **file; /* file in which to find this tag */ + char **line; /* line number of file where this tag is found */ { - char *p = buf; - - for (*tag = p; *p && !IS_SPACE(*p); p++) /* tag name */ - ; - if (*p == 0) - return (-1); - *p++ = 0; - for ( ; *p && IS_SPACE(*p); p++) /* (skip blanks) */ - ; - if (*p == 0) - return (-1); - /* - * If the second part begin with other than digit, - * it is assumed tag type. Skip it. - */ - if (!IS_DIGIT(*p)) - { - for ( ; *p && !IS_SPACE(*p); p++) /* (skip tag type) */ - ; - for (; *p && IS_SPACE(*p); p++) /* (skip blanks) */ - ; - } - if (!IS_DIGIT(*p)) - return (-1); - *line = p; /* line number */ - for (*line = p; *p && !IS_SPACE(*p); p++) - ; - if (*p == 0) - return (-1); - *p++ = 0; - for ( ; *p && IS_SPACE(*p); p++) /* (skip blanks) */ - ; - if (*p == 0) - return (-1); - *file = p; /* file name */ - for (*file = p; *p && !IS_SPACE(*p); p++) - ; - if (*p == 0) - return (-1); - *p = 0; - - /* value check */ - if (strlen(*tag) && strlen(*line) && strlen(*file) && atoi(*line) > 0) - return (0); - return (-1); + char *p = buf; + + for (*tag = p; *p && !IS_SPACE(*p); p++) /* tag name */ + ; + if (*p == 0) + return (-1); + *p++ = 0; + for ( ; *p && IS_SPACE(*p); p++) /* (skip blanks) */ + ; + if (*p == 0) + return (-1); + /* + * If the second part begin with other than digit, + * it is assumed tag type. Skip it. + */ + if (!IS_DIGIT(*p)) + { + for ( ; *p && !IS_SPACE(*p); p++) /* (skip tag type) */ + ; + for (; *p && IS_SPACE(*p); p++) /* (skip blanks) */ + ; + } + if (!IS_DIGIT(*p)) + return (-1); + *line = p; /* line number */ + for (*line = p; *p && !IS_SPACE(*p); p++) + ; + if (*p == 0) + return (-1); + *p++ = 0; + for ( ; *p && IS_SPACE(*p); p++) /* (skip blanks) */ + ; + if (*p == 0) + return (-1); + *file = p; /* file name */ + for (*file = p; *p && !IS_SPACE(*p); p++) + ; + if (*p == 0) + return (-1); + *p = 0; + + /* value check */ + if (strlen(*tag) && strlen(*line) && strlen(*file) && atoi(*line) > 0) + return (0); + return (-1); } #endif