From 33a9f6ab73c5cd49f65ba4389ec32216bbe5fee3 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 26 Nov 2007 08:57:30 +0000 Subject: [PATCH] Virgin import of less v416. --- contrib/less/NEWS | 2 +- contrib/less/README | 4 +- contrib/less/less.man | 80 ++++++++++++++++++++------------------- contrib/less/less.nro | 21 +++++----- contrib/less/lessecho.man | 2 +- contrib/less/lessecho.nro | 2 +- contrib/less/lesskey.man | 2 +- contrib/less/lesskey.nro | 2 +- contrib/less/search.c | 13 ++++--- contrib/less/version.c | 3 +- 10 files changed, 70 insertions(+), 61 deletions(-) diff --git a/contrib/less/NEWS b/contrib/less/NEWS index 3d6b0983c203..e6cec6969bb7 100644 --- a/contrib/less/NEWS +++ b/contrib/less/NEWS @@ -13,7 +13,7 @@ ====================================================================== - Major changes between "less" versions 409 and 415 + Major changes between "less" versions 409 and 416 * New --follow-name option makes F command follow the name of a file rather than the file descriptor if an open file is renamed. diff --git a/contrib/less/README b/contrib/less/README index a456aa631ebe..2cab3474667b 100644 --- a/contrib/less/README +++ b/contrib/less/README @@ -1,7 +1,7 @@ - Less, version 415 + Less, version 416 - This is the distribution of less, version 415, released 15 Nov 2007. + This is the distribution of less, version 416, released 22 Nov 2007. This program is part of the GNU project (http://www.gnu.org). This program is free software. You may redistribute it and/or diff --git a/contrib/less/less.man b/contrib/less/less.man index f9dda92259c0..af19a477fac2 100644 --- a/contrib/less/less.man +++ b/contrib/less/less.man @@ -445,8 +445,8 @@ LESS(1) LESS(1) buffer space is used for each file (unless the file is a pipe; see the -B option). The -b option specifies instead that n kilobytes of buffer space should be used for each file. If n is - -1, buffer space is unlimited; that is, the entire file is read - into memory. + -1, buffer space is unlimited; that is, the entire file can be + read into memory. -B or --auto-buffers By default, when data is read from a pipe, buffers are allocated @@ -456,8 +456,8 @@ LESS(1) LESS(1) buffers for pipes, so that only 64K (or the amount of space specified by the -b option) is used for the pipe. Warning: use of -B can result in erroneous display, since only the most - recently viewed part of the file is kept in memory; any earlier - data is lost. + recently viewed part of the piped data is kept in memory; any + earlier data is lost. -c or --clear-screen Causes full screen repaints to be painted from the top line @@ -533,42 +533,44 @@ LESS(1) LESS(1) -jn or --jump-target=n Specifies a line on the screen where the "target" line is to be - positioned. A target line is the object of a text search, tag - search, jump to a line number, jump to a file percentage, or - jump to a marked position. The screen line may be specified by - a number: the top line on the screen is 1, the next is 2, and so - on. The number may be negative to specify a line relative to - the bottom of the screen: the bottom line on the screen is -1, - the second to the bottom is -2, and so on. Alternately, the - screen line may be specified as a fraction of the height of the - screen, starting with a decimal point: .5 is in the middle of - the screen, .3 is three tenths down from the first line, and so - on. If the line is specified as a fraction, the actual line + positioned. The target line is the line specified by any com- + mand to search for a pattern, jump to a line number, jump to a + file percentage or jump to a tag. The screen line may be speci- + fied by a number: the top line on the screen is 1, the next is + 2, and so on. The number may be negative to specify a line rel- + ative to the bottom of the screen: the bottom line on the screen + is -1, the second to the bottom is -2, and so on. Alternately, + the screen line may be specified as a fraction of the height of + the screen, starting with a decimal point: .5 is in the middle + of the screen, .3 is three tenths down from the first line, and + so on. If the line is specified as a fraction, the actual line number is recalculated if the terminal window is resized, so that the target line remains at the specified fraction of the - screen height. If the -j option is used, searches begin at the - line immediately after the target line. For example, if "-j4" - is used, the target line is the fourth line on the screen, so - searches begin at the fifth line on the screen. + screen height. If any form of the -j option is used, forward + searches begin at the line immediately after the target line, + and backward searches begin at the target line. For example, if + "-j4" is used, the target line is the fourth line on the screen, + so forward searches begin at the fifth line on the screen. -J or --status-column - Displays a status column at the left edge of the screen. The - status column shows the lines that matched the current search. - The status column is also used if the -w or -W option is in + Displays a status column at the left edge of the screen. The + status column shows the lines that matched the current search. + The status column is also used if the -w or -W option is in effect. -kfilename or --lesskey-file=filename - Causes less to open and interpret the named file as a lesskey + Causes less to open and interpret the named file as a lesskey (1) file. Multiple -k options may be specified. If the LESSKEY - or LESSKEY_SYSTEM environment variable is set, or if a lesskey + or LESSKEY_SYSTEM environment variable is set, or if a lesskey file is found in a standard place (see KEY BINDINGS), it is also used as a lesskey file. -K or --quit-on-intr - Causes less to exit immediately when an interrupt character - (usually ^C) is typed. Normally, an interrupt character causes - less to stop whatever it is doing and return to its command - prompt. + Causes less to exit immediately when an interrupt character + (usually ^C) is typed. Normally, an interrupt character causes + less to stop whatever it is doing and return to its command + prompt. Note that use of this option makes it impossible to + return to the command prompt from the "F" command. -L or --no-lessopen Ignore the LESSOPEN environment variable (see the INPUT PREPRO- @@ -739,8 +741,8 @@ LESS(1) LESS(1) -xn,... or --tabs=n,... Sets tab stops. If only one n is specified, tab stops are set at multiples of n. If multiple values separated by commas are - specified, tab stops are set at those positions, and then - continue with the same spacing as the last two. For example, + specified, tab stops are set at those positions, and then con- + tinue with the same spacing as the last two. For example, -x9,17 will set tabs at positions 9, 17, 25, 33, etc. The default for n is 8. @@ -1159,10 +1161,10 @@ LESS(1) LESS(1) is followed by a single character (shown as X above) which spec- ifies the line whose byte offset is to be used. If the charac- ter is a "t", the byte offset of the top line in the display is - used, an "m" means use the middle line, a "b" means use the - bottom line, a "B" means use the line just after the bottom - line, and a "j" means use the "target" line, as specified by the - -j option. + used, an "m" means use the middle line, a "b" means use the bot- + tom line, a "B" means use the line just after the bottom line, + and a "j" means use the "target" line, as specified by the -j + option. %B Replaced by the size of the current input file. @@ -1509,10 +1511,10 @@ LESS(1) LESS(1) expressions turned off via ^R, and also does not occur when less is compiled to use the PCRE regular expression library. - In certain cases, when search highlighting is enabled and a search - pattern begins with a ^, more text than the matching string may be - highlighted. (This problem does not occur when less is compiled to use - the POSIX regular expression package.) + In certain cases, when search highlighting is enabled and a search pat- + tern begins with a ^, more text than the matching string may be high- + lighted. (This problem does not occur when less is compiled to use the + POSIX regular expression package.) On some systems, setlocale claims that ASCII characters 0 thru 31 are control characters rather than binary characters. This causes less to @@ -1554,4 +1556,4 @@ LESS(1) LESS(1) - Version 415: 15 Nov 2007 LESS(1) + Version 416: 22 Nov 2007 LESS(1) diff --git a/contrib/less/less.nro b/contrib/less/less.nro index d2261811c409..d5dfb053498e 100644 --- a/contrib/less/less.nro +++ b/contrib/less/less.nro @@ -1,4 +1,4 @@ -.TH LESS 1 "Version 415: 15 Nov 2007" +.TH LESS 1 "Version 416: 22 Nov 2007" .SH NAME less \- opposite of more .SH SYNOPSIS @@ -462,7 +462,7 @@ By default 64K of buffer space is used for each file The \-b option specifies instead that \fIn\fP kilobytes of buffer space should be used for each file. If \fIn\fP is \-1, buffer space is unlimited; that is, -the entire file is read into memory. +the entire file can be read into memory. .IP "\-B or \-\-auto-buffers" By default, when data is read from a pipe, buffers are allocated automatically as needed. @@ -473,7 +473,7 @@ so that only 64K (or the amount of space specified by the \-b option) is used for the pipe. Warning: use of \-B can result in erroneous display, since only the -most recently viewed part of the file is kept in memory; +most recently viewed part of the piped data is kept in memory; any earlier data is lost. .IP "\-c or \-\-clear-screen" Causes full screen repaints to be painted from the top line down. @@ -555,9 +555,9 @@ the pattern contains uppercase letters. .IP "\-j\fIn\fP or \-\-jump-target=\fIn\fP" Specifies a line on the screen where the "target" line is to be positioned. -A target line is the object of a text search, -tag search, jump to a line number, -jump to a file percentage, or jump to a marked position. +The target line is the line specified by any command to +search for a pattern, jump to a line number, +jump to a file percentage or jump to a tag. The screen line may be specified by a number: the top line on the screen is 1, the next is 2, and so on. The number may be negative to specify a line relative to the bottom @@ -569,10 +569,11 @@ screen, .3 is three tenths down from the first line, and so on. If the line is specified as a fraction, the actual line number is recalculated if the terminal window is resized, so that the target line remains at the specified fraction of the screen height. -If the \-j option is used, searches begin at the line immediately -after the target line. +If any form of the \-j option is used, +forward searches begin at the line immediately after the target line, +and backward searches begin at the target line. For example, if "\-j4" is used, the target line is the -fourth line on the screen, so searches begin at the fifth line +fourth line on the screen, so forward searches begin at the fifth line on the screen. .IP "\-J or \-\-status-column" Displays a status column at the left edge of the screen. @@ -597,6 +598,8 @@ to exit immediately when an interrupt character (usually ^C) is typed. Normally, an interrupt character causes .I less to stop whatever it is doing and return to its command prompt. +Note that use of this option makes it impossible to return to the +command prompt from the "F" command. .IP "\-L or \-\-no-lessopen" Ignore the LESSOPEN environment variable (see the INPUT PREPROCESSOR section below). diff --git a/contrib/less/lessecho.man b/contrib/less/lessecho.man index 98bbf677c351..98f059144b2e 100644 --- a/contrib/less/lessecho.man +++ b/contrib/less/lessecho.man @@ -46,4 +46,4 @@ LESSECHO(1) LESSECHO(1) - Version 415: 15 Nov 2007 LESSECHO(1) + Version 416: 22 Nov 2007 LESSECHO(1) diff --git a/contrib/less/lessecho.nro b/contrib/less/lessecho.nro index d31b83d05495..05542f79f4ee 100644 --- a/contrib/less/lessecho.nro +++ b/contrib/less/lessecho.nro @@ -1,4 +1,4 @@ -.TH LESSECHO 1 "Version 415: 15 Nov 2007" +.TH LESSECHO 1 "Version 416: 22 Nov 2007" .SH NAME lessecho \- expand metacharacters .SH SYNOPSIS diff --git a/contrib/less/lesskey.man b/contrib/less/lesskey.man index 8f77d55cda53..bdc2ebae2bb6 100644 --- a/contrib/less/lesskey.man +++ b/contrib/less/lesskey.man @@ -357,4 +357,4 @@ LESSKEY(1) LESSKEY(1) - Version 415: 15 Nov 2007 LESSKEY(1) + Version 416: 22 Nov 2007 LESSKEY(1) diff --git a/contrib/less/lesskey.nro b/contrib/less/lesskey.nro index a757bab7efad..47033212b7cf 100644 --- a/contrib/less/lesskey.nro +++ b/contrib/less/lesskey.nro @@ -1,4 +1,4 @@ -.TH LESSKEY 1 "Version 415: 15 Nov 2007" +.TH LESSKEY 1 "Version 416: 22 Nov 2007" .SH NAME lesskey \- specify key bindings for less .SH SYNOPSIS diff --git a/contrib/less/search.c b/contrib/less/search.c index b983334c7d82..3a153808429c 100644 --- a/contrib/less/search.c +++ b/contrib/less/search.c @@ -118,13 +118,16 @@ cvt_length(len, ops) int len; int ops; { - if (utf_mode && (ops & CVT_TO_LC)) + if (utf_mode) /* - * Converting case can cause a UTF-8 string to increase in length. - * Multiplying by 3 is the worst case. + * Just copying a string in UTF-8 mode can cause it to grow + * in length. + * Six output bytes for one input byte is the worst case + * (and unfortunately is far more than is needed in any + * non-pathological situation, so this is very wasteful). */ - len *= 3; - return len+1; + len *= 6; + return len + 1; } /* diff --git a/contrib/less/version.c b/contrib/less/version.c index 578dc55e07a6..bce2f82c07cf 100644 --- a/contrib/less/version.c +++ b/contrib/less/version.c @@ -701,6 +701,7 @@ v412 11/6/07 Use symbolic SEEK constants. v413 11/6/07 Fix search highlight bug with non-ASCII text. v414 11/6/07 Fix display bug with no-wrap terminals. v415 11/14/07 Add --follow-name option. +v416 11/22/07 Fix crash when searching text with invalid UTF-8 sequences. */ -char version[] = "415"; +char version[] = "416";