util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/14] various: clean ups and fixes
@ 2012-10-08  7:08 Sami Kerola
  2012-10-08  7:08 ` [PATCH 01/14] ddate: remove from util-linux Sami Kerola
                   ` (13 more replies)
  0 siblings, 14 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Here comes half random bunch of patches, where most of them should make
you yawn.

I guess the most noticable is ddate removal, which will outrage
disordians.  Perhaps getting loads of 'signed-off-by' lines from
distribution packagers & active contributors will make it clear that UL
project is tired to keep such pointless garbage in source.

[PATCH 01/14] ddate: remove from util-linux
[PATCH 02/14] column: add --output-separator option
[PATCH 03/14] docs: fix column.1 groff syntax error
[PATCH 04/14] pg: refactor argument handing
[PATCH 05/14] pg: use libc error printing facilities
[PATCH 06/14] pg: add const qualifiers where suitable
[PATCH 07/14] pg: add noreturn function attributes
[PATCH 08/14] pg: use unistd.h STDOUT_FILENO
[PATCH 09/14] pg: do not turn off warnigns artificially
[PATCH 10/14] pg: fix coding style
[PATCH 11/14] more: fix coding style
[PATCH 12/14] more: align void in functions with prototypes, and
[PATCH 13/14] more: remove few memory leaks
[PATCH 14/14] swapon: remove loop declaration [smatch scan]

-- 
   Sami Kerola
   http://www.iki.fi/kerolasa/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/14] ddate: remove from util-linux
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  9:06   ` Petr Uzel
  2012-10-08  7:08 ` [PATCH 02/14] column: add --output-separator option Sami Kerola
                   ` (12 subsequent siblings)
  13 siblings, 1 reply; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

See RedHat bug for reasons why the ddate is cleaned up.  The reference is
where to get the command in future.

Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=823156
References: https://github.com/bo0ts/ddate
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 .gitignore                                      |   1 -
 Documentation/howto-usage-function.txt          |   2 +-
 Makefile.am                                     |   3 +-
 configure.ac                                    |  11 -
 man/ru/ddate.1                                  | 123 --------
 misc-utils/Makemodule.am                        |   7 -
 misc-utils/ddate.1                              | 114 --------
 misc-utils/ddate.c                              | 374 ------------------------
 tests/expected/build-sys/config-all             |   1 -
 tests/expected/build-sys/config-all-devel       |   1 -
 tests/expected/build-sys/config-all-non-nls     |   1 -
 tests/expected/build-sys/config-devel           |   1 -
 tests/expected/build-sys/config-devel-new-mount |   1 -
 tools/checkmans.sh                              |   2 +-
 14 files changed, 3 insertions(+), 639 deletions(-)
 delete mode 100644 man/ru/ddate.1
 delete mode 100644 misc-utils/ddate.1
 delete mode 100644 misc-utils/ddate.c

diff --git a/.gitignore b/.gitignore
index a777d16..e85eb07 100644
--- a/.gitignore
+++ b/.gitignore
@@ -80,7 +80,6 @@ tests/run.sh.trs
 /column
 /ctrlaltdel
 /cytune
-/ddate
 /delpart
 /dmesg
 /eject
diff --git a/Documentation/howto-usage-function.txt b/Documentation/howto-usage-function.txt
index 70116b2..1944bb7 100644
--- a/Documentation/howto-usage-function.txt
+++ b/Documentation/howto-usage-function.txt
@@ -134,7 +134,7 @@ Some commands use peculiar options and arguments. These are supported,
 but such will not be accepted in future. See list bellow for a hint what
 are meant this.
 
-- Other than `-' used to define an option. See `+' for `more' or `ddate'
+- Other than `-' used to define an option. See `+' for `more'
   commands.
 - Option string used as an option argument. See `more' command and `-num'.
 - Short long option. See `setterm'.
diff --git a/Makefile.am b/Makefile.am
index a540f0e..6188f49 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,7 +39,6 @@ bin_PROGRAMS =
 sbin_PROGRAMS =
 dist_usrbin_exec_SCRIPTS =
 systemdsystemunit_DATA =
-ruman1_DATA =
 check_PROGRAMS =
 TESTS =
 
@@ -51,7 +50,7 @@ INSTALL_DATA_HOOKS =
 CLEAN_LOCALS =
 CHECK_LOCALS =
 
-EXTRA_DIST = man/ru/ddate.1
+EXTRA_DIST =
 CLEANFILES =
 
 SUBDIRS = po
diff --git a/configure.ac b/configure.ac
index 9d2f589..d0a7b57 100644
--- a/configure.ac
+++ b/configure.ac
@@ -678,7 +678,6 @@ AC_ARG_ENABLE([most-builds],
 )
 if test "x$enable_most_builds" = xyes; then
   enable_arch=check
-  enable_ddate=yes
   enable_elvtune=check
   enable_last=yes
   enable_line=yes
@@ -880,16 +879,6 @@ UL_REQUIRES_LINUX([arch])
 AM_CONDITIONAL(BUILD_ARCH, test "x$build_arch" = xyes)
 
 
-AC_ARG_ENABLE([ddate],
-  AS_HELP_STRING([--enable-ddate], [do build ddate]),
-  [], enable_ddate=no
-)
-UL_BUILD_INIT([ddate])
-AM_CONDITIONAL(BUILD_DDATE, test "x$build_ddate" = xyes)
-ruman1dir='${mandir}/ru/man1'
-AC_SUBST([ruman1dir])
-
-
 AC_ARG_ENABLE([eject],
   AS_HELP_STRING([--disable-eject], [do not build eject]),
   [], enable_eject=check
diff --git a/man/ru/ddate.1 b/man/ru/ddate.1
deleted file mode 100644
index cb10c57..0000000
--- a/man/ru/ddate.1
+++ /dev/null
@@ -1,123 +0,0 @@
-.\" All Rites Reversed.  This file is in the PUBLIC DOMAIN.
-.\" Kallisti.
-.TH DDATE 1 "59 Bureaucracy 3161" "" "Emperor Norton Utilities"
-.SH ИМЯ
-ddate \- преобразует дату в григорианском формате в соответствующую дату в 
-дискордианском формате
-.SH ОБЗОР
-.B ddate
-.RI [ \fB+\fPформат]
-.RI [ дата ]
-.SH ОПИСАНИЕ
-.B ddate
-выводит дату в дискордианском формате.
-.PP
-Если команда 
-.B ddate
-вызвана без параметров, она получает текущую системную дату, преобразует её в
-дискордианский формат и выводит на стандартный вывод. Также можно указать в
-командной строке дату в григорианском формате, указав в числовом виде день, 
-месяц и год.
-.PP
-Если указан спецификатор формата вывода, дата в дискордианском формате будет
-отображена в том виде, как это определено спецификатором. Этот механизм 
-работает подобно механизму форматирования команды
-.B date(1),
-но почти полностью иначе. Поля спецификатора следующие:
-.IP %A
-Полное название дня недели (например, Sweetmorn)
-.IP %a
-День недели в сокращенном формате (например, SM)
-.IP %B
-Полное название сезона (времени года) (например, Chaos)
-.IP %b
-Сокращенное название сезона (например, Chs)
-.IP %d
-Порядковый номер дня в сезоне (например, 23)
-.IP %e
-Числовое представление номера дня в сезоне (например, 23rd)
-.IP %H
-Название текущего праздника, если таковой имеется
-.IP %N
-Волшебный код для предотвращения вывода следующего за ним форматирования,
-в случае, если дата не является праздником.
-.IP %n
-Новая строка
-.IP %t
-Табуляция
-.IP %X
-Число дней до наступления Дня X (X-Day). Опция не действует, если утилита 
-без опции SubGenius.
-.IP %{
-.IP %}
-Используется для указания части строки, которая будет заменена словами 
-"St. Tib's Day", если текущий день является Днем святого Тиба (St. Tib's day).
-.IP %\.
-Попробуйте и увидите.
-.bp
-.SH ПРИМЕРЫ
-.nf
-% ddate
-.br
-Sweetmorn, Bureaucracy 42, 3161 YOLD
-.PP
-% ddate +'Today is %{%A, the %e of %B%}, %Y. %N%nCelebrate %H'
-.br
-Today is Sweetmorn, the 42nd of Bureaucracy, 3161.
-.PP
-% ddate +"It's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 26 9 1995
-.br
-It's Prickle-Prickle, the 50th of Bureaucracy, 3161.
-.br
-Celebrate Bureflux
-.PP
-% ddate +"Today's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 29 2 1996
-.br
-Today's St. Tib's Day, 3162.
-.br
-
-.SH ОШИБКИ
-
-.B ddate(1)
-будет вести себя непредсказуемо, если попросить вывести дату Дня святого Тиба
-но строка спецификатора форматирования при этом не содержит разделителей,
-предусмотренных специально для этого случая (%{ и %}).
-
-.SH ЗАМЕЧАНИЯ
-
-После того, как День Икс (5 июля 1998 года - прим. пер.) прошел без 
-происшествий, Церковь СубГения (Church of the SubGenius) провозгласила,
-что он должен наступить в 'году вверх тормашками' - День Икс наступит в 8661
-году н. э., а не в 1998 н. э. Таким образом, Истинный День Икс - это 40 день
-сезона Замешательства 9827 года (Cfn 40, 9827).
-
-.SH АВТОРЫ
-.nh
-Автор оригинальной программы Druel the Chaotic aka Jeremy Johnson 
-(mpython@gnu.ai.mit.edu)
-.br
-Переписана преимущественно Lee H:. O:. Smith, KYTP, aka Andrew Bulhak 
-(acb@dev.null.org)
-.br
-Пять тонн льна.
-
-.SH РАСПРОСТРАНЕНИЕ
-
-Свободно распространяемое ПО. Все права защищены.
-
-.SH СМ. ТАКЖЕ
-
-date(1),
-.br
-http://www.subgenius.com/
-.br
-Малаклипс Младший (Malaclypse the Younger),
-.I "Principia Discordia, или Как я нашел Богиню и что я с Ней сделал когда 
-нашел"
-
-.SH ДОСТУПНОСТЬ
-Команда ddate является частью пакета util-linux и доступна по 
-ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
-
-.SH ПЕРЕВОД
-Перевод Rino_ap_Codkelden <mavladi@gmail.com> 2010
\ No newline at end of file
diff --git a/misc-utils/Makemodule.am b/misc-utils/Makemodule.am
index 910e428..4c88532 100644
--- a/misc-utils/Makemodule.am
+++ b/misc-utils/Makemodule.am
@@ -52,13 +52,6 @@ CLEANFILES += misc-utils/chkdupexe
 dist_man_MANS += misc-utils/chkdupexe.1
 endif
 
-if BUILD_DDATE
-usrbin_exec_PROGRAMS += ddate
-dist_man_MANS += misc-utils/ddate.1
-ddate_SOURCES = misc-utils/ddate.c
-ruman1_DATA += man/ru/ddate.1
-endif
-
 if BUILD_LSLOCKS
 usrbin_exec_PROGRAMS += lslocks
 dist_man_MANS += misc-utils/lslocks.8
diff --git a/misc-utils/ddate.1 b/misc-utils/ddate.1
deleted file mode 100644
index 0b01e09..0000000
--- a/misc-utils/ddate.1
+++ /dev/null
@@ -1,114 +0,0 @@
-.\" All Rites Reversed.  This file is in the PUBLIC DOMAIN.
-.\" Kallisti.
-.TH DDATE 1 "Bureaucracy 3161" "util-linux" "Emperor Norton User Command"
-.SH NAME
-ddate \- convert Gregorian dates to Discordian dates
-.SH SYNOPSIS
-.B ddate
-.RI [ \fB+\fPformat]
-.RI [ date ]
-.SH DESCRIPTION
-.B ddate
-prints the date in Discordian date format.
-.PP
-If called with no arguments,
-.B ddate
-will get the current system date, convert this to the Discordian
-date format and print this on the standard output. Alternatively, a
-Gregorian date may be specified on the command line, in the form of a numerical
-day, month and year.
-.PP
-If a format string is specified, the Discordian date will be printed in
-a format specified by the string. This mechanism works similarly to the
-format string mechanism of
-.B date(1),
-only almost completely differently. The fields are:
-.IP %A
-Full name of the day of the week (i.e., Sweetmorn)
-.IP %a
-Abbreviated name of the day of the week (i.e., SM)
-.IP %B
-Full name of the season (i.e., Chaos)
-.IP %b
-Abbreviated name of the season (i.e., Chs)
-.IP %d
-Ordinal number of day in season (i.e., 23)
-.IP %e
-Cardinal number of day in season (i.e., 23rd)
-.IP %H
-Name of current Holyday, if any
-.IP %N
-Magic code to prevent rest of format from being printed unless today is
-a Holyday.
-.IP %n
-Newline
-.IP %t
-Tab
-.IP %X
-Number of days remaining until X-Day. (Not valid if the SubGenius options
-are not compiled in.)
-.IP %{
-.IP %}
-Used to enclose the part of the string which is to be replaced with the
-words "St. Tib's Day" if the current day is St. Tib's Day.
-.IP %\.
-Try it and see.
-.bp
-.SH EXAMPLES
-.nf
-% ddate
-.br
-Sweetmorn, Bureaucracy 42, 3161 YOLD
-.PP
-% ddate +'Today is %{%A, the %e of %B%}, %Y. %N%nCelebrate %H'
-.br
-Today is Sweetmorn, the 42nd of Bureaucracy, 3161.
-.PP
-% ddate +"It's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 26 9 1995
-.br
-It's Prickle-Prickle, the 50th of Bureaucracy, 3161.
-.br
-Celebrate Bureflux
-.PP
-% ddate +"Today's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 29 2 1996
-.br
-Today's St. Tib's Day, 3162.
-.br
-
-.SH BUGS
-
-.B ddate(1)
-will produce undefined behavior if asked to produce the date for St. Tib's
-day and its format string does not contain the St. Tib's Day delimiters
-%{ and %}.
-
-.SH NOTE
-
-After `X-Day' passed without incident, the Church of the SubGenius
-declared that it had got the year upside down - X-Day is actually in 8661 AD
-rather than 1998 AD.  Thus, the True X-Day is Cfn 40, 9827.
-
-.SH AUTHOR
-.nh
-Original program by Druel the Chaotic aka Jeremy Johnson (mpython@gnu.ai.mit.edu)
-.br
-Major rewrite by Lee H:. O:. Smith, KYTP, aka Andrew Bulhak (acb@dev.null.org)
-.br
-Five tons of flax.
-
-.SH DISTRIBUTION POLICY
-
-Public domain. All rites reversed.
-
-.SH SEE ALSO
-
-date(1),
-.br
-http://www.subgenius.com/
-.br
-Malaclypse the Younger,
-.I "Principia Discordia, Or How I Found Goddess And What I Did To Her When I Found Her"
-
-.SH AVAILABILITY
-The ddate command is part of the util-linux package and is available from
-ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
diff --git a/misc-utils/ddate.c b/misc-utils/ddate.c
deleted file mode 100644
index c0b4ce4..0000000
--- a/misc-utils/ddate.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/* $ DVCS ID: $jer|,523/lhos,KYTP!41023161\b"?" <<= DO NOT DELETE! */
-
-/* ddate.c .. converts boring normal dates to fun Discordian Date -><-
-   written  the 65th day of The Aftermath in the Year of Our Lady of 
-   Discord 3157 by Druel the Chaotic aka Jeremy Johnson aka
-   mpython@gnu.ai.mit.edu  
-      28 Sever St Apt #3
-      Worcester MA 01609
-
-   and I'm not responsible if this program messes anything up (except your 
-   mind, I'm responsible for that)
-
-   (k) YOLD 3161 and all time before and after.
-   Reprint, reuse, and recycle what you wish.
-   This program is in the public domain.  Distribute freely.  Or not.
-
-   Majorly hacked, extended and bogotified/debogotified on 
-   Sweetmorn, Bureaucracy 42, 3161 YOLD, by Lee H:. O:. Smith, KYTP, 
-   aka Andrew Bulhak, aka acb@dev.null.org
-
-   and I'm not responsible if this program messes anything up (except your 
-   mind, I'm responsible for that) (and that goes for me as well --lhos)
-
-   Version history:
-   Bureflux 3161:      First release of enhanced ddate with format strings
-   59 Bcy, 3161:       PRAISE_BOB and KILL_BOB options split, other minor
-                       changes.
-
-   1999-02-22 Arkadiusz Miskiewicz <misiek@pld.ORG.PL>
-   - added Native Language Support
-
-   2000-03-17 Burt Holzman <bnh@iname.com>
-   - added range checks for dates
-*/
-
-/* configuration options  VVVVV   READ THIS!!! */
-
-/* If you wish ddate(1) to print the date in the same format as Druel's 
- * original ddate when called in immediate mode, define OLD_IMMEDIATE_FMT 
- */
-
-#define OLD_IMMEDIATE_FMT
-
-/* If you wish to use the US format for aneristic dates (m-d-y), as opposed to
- * the Commonwealth format, define US_FORMAT.
- */
-
-/* #define US_FORMAT */
-
-/* If you are ideologically, theologically or otherwise opposed to the 
- * Church of the SubGenius and do not wish your copy of ddate(1) to contain
- * code for counting down to X-Day, undefine KILL_BOB */
-
-#define KILL_BOB 13013
-
-/* If you wish ddate(1) to contain SubGenius slogans, define PRAISE_BOB */
-
-/*#define PRAISE_BOB 13013*/
-
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <stdio.h>
-
-#include "nls.h"
-#include "closestream.h"
-#include "c.h"
-
-#ifndef __GNUC__
-#define inline /* foo */
-#endif
-
-#ifdef KILL_BOB
-int xday_countdown(int yday, int year);
-#endif
-
-
-/* string constants */
-
-char *day_long[5] = { 
-    "Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"
-};
-
-char *day_short[5] = {"SM","BT","PD","PP","SO"};
-
-char *season_long[5] = { 
-    "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"
-};
-
-char *season_short[5] = {"Chs", "Dsc", "Cfn", "Bcy", "Afm"};
-
-char *holyday[5][2] = { 
-    { "Mungday", "Chaoflux" },
-    { "Mojoday", "Discoflux" },
-    { "Syaday",  "Confuflux" },
-    { "Zaraday", "Bureflux" },
-    { "Maladay", "Afflux" }
-};
-
-struct disc_time {
-    int season; /* 0-4 */
-    int day; /* 0-72 */
-    int yday; /* 0-365 */
-    int year; /* 3066- */
-};
-
-char *excl[] = {
-    "Hail Eris!", "All Hail Discordia!", "Kallisti!", "Fnord.", "Or not.",
-    "Wibble.", "Pzat!", "P'tang!", "Frink!",
-#ifdef PRAISE_BOB
-    "Slack!", "Praise \"Bob\"!", "Or kill me.",
-#endif /* PRAISE_BOB */
-    /* randomness, from the Net and other places. Feel free to add (after
-       checking with the relevant authorities, of course). */
-    "Grudnuk demand sustenance!", "Keep the Lasagna flying!",
-    "You are what you see.",
-    "Or is it?", "This statement is false.",
-#if defined(linux) || defined (__linux__) || defined (__linux)
-    "Hail Eris, Hack Linux!",
-#endif
-    ""
-};
-
-char default_fmt[] = "%{%A, %B %d%}, %Y YOLD";
-char *default_immediate_fmt=
-#ifdef OLD_IMMEDIATE_FMT
-"Today is %{%A, the %e day of %B%} in the YOLD %Y%N%nCelebrate %H"
-#else
-default_fmt
-#endif
-;
-
-#define DY(y) (y+1166)
-
-static inline char *ending(int i) {
-	return i/10==1?"th":(i%10==1?"st":(i%10==2?"nd":(i%10==3?"rd":"th")));
-}
-
-static inline int leapp(int i) {
-	return (!(DY(i)%4))&&((DY(i)%100)||(!(DY(i)%400)));
-}
-
-/* select a random string */
-static inline char *sel(char **strings, int num) {
-	return(strings[random()%num]);
-}
-
-void print(struct disc_time,char **); /* old */
-void format(char *buf, const char* fmt, struct disc_time dt);
-/* read a fortune file */
-int load_fortunes(char *fn, char *delim, char** result);
-
-struct disc_time convert(int,int);
-struct disc_time makeday(int,int,int);
-
-int
-main (int argc, char *argv[]) {
-    long t;
-    struct tm *eris;
-    int bob,raw;
-    struct disc_time hastur;
-    char schwa[23*17], *fnord=0;
-    int pi;
-    char *progname, *p;
-
-    progname = argv[0];
-    if ((p = strrchr(progname, '/')) != NULL)
-	progname = p+1;
-
-    setlocale(LC_ALL, "");
-    bindtextdomain(PACKAGE, LOCALEDIR);
-    textdomain(PACKAGE);
-    atexit(close_stdout);
-
-    srandom(time(NULL));
-    /* do args here */
-    for(pi=1; pi<argc; pi++) {
-	switch(argv[pi][0]) {
-	case '+': fnord=argv[pi]+1; break;
-	case '-': 
-	    switch(argv[pi][1]) {
-	    case 'V':
-		printf(_("%s (%s)\n"), progname, PACKAGE_STRING);
-	    default: goto usage;
-	    }
-	default: goto thud;
-	}
-    }
-
-  thud:
-    if (argc-pi==3){ 
-	int moe=atoi(argv[pi]), larry=atoi(argv[pi+1]), curly=atoi(argv[pi+2]);
-	hastur=makeday(
-#ifdef US_FORMAT
-	    moe,larry,
-#else
-	    larry,moe,
-#endif
-	    curly);
-	if (hastur.season == -1) {
-		printf("Invalid date -- out of range\n");
-		return -1;
-	}
-	fnord=fnord?fnord:default_fmt;
-    } else if (argc!=pi) { 
-      usage:
-	fprintf(stderr,_("usage: %s [+format] [day month year]\n"), argv[0]);
-	exit(1);
-    } else {
-	t= time(NULL);
-	eris=localtime(&t);
-	bob=eris->tm_yday; /* days since Jan 1. */
-	raw=eris->tm_year; /* years since 1980 */
-	hastur=convert(bob,raw);
-	fnord=fnord?fnord:default_immediate_fmt;
-    }
-    format(schwa, fnord, hastur);
-    printf("%s\n", schwa);
-   
-    return 0;
-}
-
-void format(char *buf, const char* fmt, struct disc_time dt)
-{
-    int tib_start=-1, tib_end=0;
-    int i, fmtlen=strlen(fmt);
-    char *bufptr=buf;
-
-/*    fprintf(stderr, "format(%p, \"%s\", dt)\n", buf, fmt);*/
-
-    /* first, find extents of St. Tib's Day area, if defined */
-    for(i=0; i<fmtlen; i++) {
-	if(fmt[i]=='%') {
-	    switch(fmt[i+1]) {
-	    case 'A':
-	    case 'a':
-	    case 'd':
-	    case 'e':
-		if(tib_start>0)	    tib_end=i+1;
-		else		    tib_start=i;
-		break;
-	    case '{': tib_start=i; break;
-	    case '}': tib_end=i+1; break;
-	    }
-	}
-    }
-
-    /* now do the formatting */
-    buf[0]=0;
-
-    for(i=0; i<fmtlen; i++) {
-	if((i==tib_start) && (dt.day==-1)) {
-	    /* handle St. Tib's Day */
-	    strcpy(bufptr, _("St. Tib's Day"));
-	    bufptr += strlen(bufptr);
-	    i=tib_end;
-	} else {
-	    if(fmt[i]=='%') {
-		char *wibble=0, snarf[23];
-		switch(fmt[++i]) {
-		case 'A': wibble=day_long[dt.yday%5]; break;
-		case 'a': wibble=day_short[dt.yday%5]; break;
-		case 'B': wibble=season_long[dt.season]; break;
-		case 'b': wibble=season_short[dt.season]; break;
-		case 'd': sprintf(snarf, "%d", dt.day+1); wibble=snarf; break;
-		case 'e': sprintf(snarf, "%d%s", dt.day+1, ending(dt.day+1)); 
-		    wibble=snarf; break;
-		case 'H': if(dt.day==4||dt.day==49)
-		    wibble=holyday[dt.season][dt.day==49]; break;
-		case 'N': if(dt.day!=4&&dt.day!=49) goto eschaton; break;
-		case 'n': *(bufptr++)='\n'; break;
-		case 't': *(bufptr++)='\t'; break;
-
-		case 'Y': sprintf(snarf, "%d", dt.year); wibble=snarf; break;
-		case '.': wibble=sel(excl, ARRAY_SIZE(excl));
-		    break;
-#ifdef KILL_BOB
-		case 'X': sprintf(snarf, "%d", 
-				  xday_countdown(dt.yday, dt.year));
-				  wibble = snarf; break;
-#endif /* KILL_BOB */
-		}
-		if(wibble) {
-/*		    fprintf(stderr, "wibble = (%s)\n", wibble);*/
-		    strcpy(bufptr, wibble); bufptr+=strlen(wibble);
-		}
-	    } else {
-		*(bufptr++) = fmt[i];
-	    }
-	}
-    }
-  eschaton:
-    *(bufptr)=0;
-}
-
-struct disc_time makeday(int imonth,int iday,int iyear) /*i for input */
-{ 
-    struct disc_time funkychickens;
-    
-    int cal[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
-    int dayspast=0;
-
-    memset(&funkychickens,0,sizeof(funkychickens));
-    /* basic range checks */
-    if (imonth < 1 || imonth > 12) {
-	    funkychickens.season = -1;
-	    return funkychickens;
-    }
-    if (iday < 1 || iday > cal[imonth-1]) {
-	    if (!(imonth == 2 && iday == 29 && iyear%4 == 0 &&
-		  (iyear%100 != 0 || iyear%400 == 0))) {
-		    funkychickens.season = -1;
-		    return funkychickens;
-	    }
-    }
-    
-    imonth--;
-    funkychickens.year= iyear+1166;
-    while(imonth>0) { dayspast+=cal[--imonth]; }
-    funkychickens.day=dayspast+iday-1;
-    funkychickens.season=0;
-    if((funkychickens.year%4)==2) {
-	if (funkychickens.day==59 && iday==29)  funkychickens.day=-1;
-    }
-    funkychickens.yday=funkychickens.day;
-/*               note: EQUAL SIGN...hopefully that fixes it */
-    while(funkychickens.day>=73) {
-	funkychickens.season++;
-	funkychickens.day-=73;
-    }
-    return funkychickens;
-}
-
-struct disc_time convert(int nday, int nyear)
-{  struct disc_time funkychickens;
-   
-   funkychickens.year = nyear+3066;
-   funkychickens.day=nday;
-   funkychickens.season=0;
-   if ((funkychickens.year%4)==2)
-     {if (funkychickens.day==59)
-	funkychickens.day=-1;
-     else if (funkychickens.day >59)
-       funkychickens.day-=1;
-    }
-   funkychickens.yday=funkychickens.day;
-   while (funkychickens.day>=73)
-     { funkychickens.season++;
-       funkychickens.day-=73;
-     }
-   return funkychickens;
-  
- }
-
-#ifdef KILL_BOB
-
-/* Code for counting down to X-Day, X-Day being Cfn 40, 3164 
- *
- * After `X-Day' passed without incident, the CoSG declared that it had 
- * got the year upside down --- X-Day is actually in 8661 AD rather than 
- * 1998 AD.
- *
- * Thus, the True X-Day is Cfn 40, 9827.
- *
- */
-
-int xday_countdown(int yday, int year) {
-    int r=(185-yday)+(((yday<59)&&(leapp(year)))?1:0);
-    while(year<9827) r+=(leapp(++year)?366:365);
-    while(year>9827) r-=(leapp(year--)?366:365);
-    return r;
-}
-
-#endif
diff --git a/tests/expected/build-sys/config-all b/tests/expected/build-sys/config-all
index c31bc40..e5888dd 100644
--- a/tests/expected/build-sys/config-all
+++ b/tests/expected/build-sys/config-all
@@ -36,7 +36,6 @@ colrm:
 column:  
 ctrlaltdel:  
 cytune:  
-ddate:  
 delpart:  
 dmesg:  
 elvtune:  
diff --git a/tests/expected/build-sys/config-all-devel b/tests/expected/build-sys/config-all-devel
index 4b31e7e..1be319b 100644
--- a/tests/expected/build-sys/config-all-devel
+++ b/tests/expected/build-sys/config-all-devel
@@ -54,7 +54,6 @@ uuidd:  libuuid
 uuidgen:  libuuid 
 wipefs:  libblkid libuuid 
 cal:  libncursesw libtinfo 
-ddate:  
 kill:  
 logger:  
 look:  
diff --git a/tests/expected/build-sys/config-all-non-nls b/tests/expected/build-sys/config-all-non-nls
index c31bc40..e5888dd 100644
--- a/tests/expected/build-sys/config-all-non-nls
+++ b/tests/expected/build-sys/config-all-non-nls
@@ -36,7 +36,6 @@ colrm:
 column:  
 ctrlaltdel:  
 cytune:  
-ddate:  
 delpart:  
 dmesg:  
 elvtune:  
diff --git a/tests/expected/build-sys/config-devel b/tests/expected/build-sys/config-devel
index a2e0411..cb7fad3 100644
--- a/tests/expected/build-sys/config-devel
+++ b/tests/expected/build-sys/config-devel
@@ -36,7 +36,6 @@ colrm:
 column:  
 ctrlaltdel:  
 cytune:  
-ddate:  
 delpart:  
 dmesg:  
 elvtune:  
diff --git a/tests/expected/build-sys/config-devel-new-mount b/tests/expected/build-sys/config-devel-new-mount
index 74c35c7..7e83630 100644
--- a/tests/expected/build-sys/config-devel-new-mount
+++ b/tests/expected/build-sys/config-devel-new-mount
@@ -56,7 +56,6 @@ uuidgen:  libuuid
 wipefs:  libblkid libuuid 
 blkid.static: STATIC
 cal:  libncursesw libtinfo 
-ddate:  
 kill:  
 logger:  
 look:  
diff --git a/tools/checkmans.sh b/tools/checkmans.sh
index e54ebed..4b149d0 100755
--- a/tools/checkmans.sh
+++ b/tools/checkmans.sh
@@ -39,7 +39,7 @@ trap "rm -f ${ERROR_FILE}" 0
 
 for I in $(
 	find $(git rev-parse --show-toplevel) -name '*.[1-8]' |
-	egrep -v '(Documentation|.git|/.libs/|autom4te.cache|ru/ddate)'
+	egrep -v '(Documentation|.git|/.libs/|autom4te.cache)'
 ); do
 	# FIXME: the determination whether a manual does include
 	# should probably be somewhat smarter.
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 02/14] column: add --output-separator option
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
  2012-10-08  7:08 ` [PATCH 01/14] ddate: remove from util-linux Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 03/14] docs: fix column.1 groff syntax error Sami Kerola
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

The --output-separator option will allow user to define table column
separator.  This will allow for example to write back same delimeter as
which was used as input separator, for example

column -t -s : -o : /etc/passwd

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/column.1 |  2 ++
 text-utils/column.c | 20 +++++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/text-utils/column.1 b/text-utils/column.1
index 993f737..3727048 100644
--- a/text-utils/column.1
+++ b/text-utils/column.1
@@ -54,6 +54,8 @@ Columns are delimited with whitespace, by default, or with the characters
 supplied using the separator. Table output is useful for pretty-printing.
 .IP "\fB\-s, \-\-separator\fP \fIseparators\fP"
 Specify possible table delimiters (default is whitespace).
+.IP "\fB\-o, \-\-output-separator\fP \fIseparators\fP"
+Specify table output delimiter (default is two whitespaces).
 .IP "\fB\-x, \-\-fillrows\fP"
 Fill columns before filling rows.
 .IP "\fB\-h, \-\-help\fP"
diff --git a/text-utils/column.c b/text-utils/column.c
index d230979..33bc28d 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -76,7 +76,7 @@ static int input(FILE *fp, int *maxlength, wchar_t ***list, int *entries);
 static void c_columnate(int maxlength, long termwidth, wchar_t **list, int entries);
 static void r_columnate(int maxlength, long termwidth, wchar_t **list, int entries);
 static wchar_t *local_wcstok(wchar_t *p, const wchar_t *separator, int greedy, wchar_t **wcstok_state);
-static void maketbl(wchar_t **list, int entries, wchar_t *separator, int greedy);
+static void maketbl(wchar_t **list, int entries, wchar_t *separator, int greedy, wchar_t *colsep);
 static void print(wchar_t **list, int entries);
 
 typedef struct _tbl {
@@ -98,6 +98,8 @@ static void __attribute__((__noreturn__)) usage(int rc)
 	" -c, --columns <width>    width of output in number of characters\n"
 	" -t, --table              create a table\n"
 	" -s, --separator <string> possible table delimiters\n"
+	" -o, --output-separator <string>\n"
+	"                          table output column separator, default is two spaces\n"
 	" -x, --fillrows           fill rows before columns\n"));
 
 	fprintf(out, _("\nFor more information see column(1).\n"));
@@ -114,6 +116,7 @@ int main(int argc, char **argv)
 	int maxlength = 0;		/* longest record */
 	wchar_t **list = NULL;		/* array of pointers to records */
 	int greedy = 1;
+	wchar_t *colsep;		/* table column output separator */
 
 	/* field separator for table option */
 	wchar_t default_separator[] = { '\t', ' ', 0 };
@@ -126,6 +129,7 @@ int main(int argc, char **argv)
 		{ "columns",	1, 0, 'c' },
 		{ "table",	0, 0, 't' },
 		{ "separator",	1, 0, 's' },
+		{ "output-separator", 1, 0, 'o' },
 		{ "fillrows",	0, 0, 'x' },
 		{ NULL,		0, 0, 0 },
 	};
@@ -138,8 +142,9 @@ int main(int argc, char **argv)
 	termwidth = get_terminal_width();
 	if (termwidth <= 0)
 		termwidth = 80;
+	colsep = mbs_to_wcs("  ");
 
-	while ((ch = getopt_long(argc, argv, "hVc:s:tx", longopts, NULL)) != -1)
+	while ((ch = getopt_long(argc, argv, "hVc:s:txo:", longopts, NULL)) != -1)
 		switch(ch) {
 		case 'h':
 			usage(EXIT_SUCCESS);
@@ -155,6 +160,10 @@ int main(int argc, char **argv)
 			separator = mbs_to_wcs(optarg);
 			greedy = 0;
 			break;
+		case 'o':
+			free(colsep);
+			colsep = mbs_to_wcs(optarg);
+			break;
 		case 't':
 			tflag = 1;
 			break;
@@ -186,7 +195,7 @@ int main(int argc, char **argv)
 		exit(eval);
 
 	if (tflag)
-		maketbl(list, entries, separator, greedy);
+		maketbl(list, entries, separator, greedy, colsep);
 	else if (maxlength >= termwidth)
 		print(list, entries);
 	else if (xflag)
@@ -297,7 +306,7 @@ wchar_t *local_wcstok(wchar_t * p, const wchar_t * separator, int greedy,
 	return result;
 }
 
-static void maketbl(wchar_t **list, int entries, wchar_t *separator, int greedy)
+static void maketbl(wchar_t **list, int entries, wchar_t *separator, int greedy, wchar_t *colsep)
 {
 	TBL *t;
 	int cnt, i;
@@ -339,8 +348,9 @@ static void maketbl(wchar_t **list, int entries, wchar_t *separator, int greedy)
 	for (t = tbl, cnt = 0; cnt < entries; ++cnt, ++t) {
 		for (coloff = 0; coloff < t->cols - 1; ++coloff) {
 			fputws(t->list[coloff], stdout);
-			for (i = lens[coloff] - t->len[coloff] + 2; i > 0; i--)
+			for (i = lens[coloff] - t->len[coloff]; i > 0; i--)
 				putwchar(' ');
+			fputws(colsep, stdout);
 		}
 		if (coloff < t->cols) {
 			fputws(t->list[coloff], stdout);
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 03/14] docs: fix column.1 groff syntax error
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
  2012-10-08  7:08 ` [PATCH 01/14] ddate: remove from util-linux Sami Kerola
  2012-10-08  7:08 ` [PATCH 02/14] column: add --output-separator option Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 04/14] pg: refactor argument handing Sami Kerola
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Quote backslash which user is expected to see.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/column.1 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/text-utils/column.1 b/text-utils/column.1
index 3727048..b6da45f 100644
--- a/text-utils/column.1
+++ b/text-utils/column.1
@@ -73,7 +73,7 @@ The util-linux version 2.23 changed
 option to be non-greedy, for example:
 .PP
 .EX
-$ printf "a:b:c\n1::3\n" | column  -t -s ':'
+$ printf "a:b:c\\n1::3\\n" | column  -t -s ':'
 .EE
 .PP
 old output:
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 04/14] pg: refactor argument handing
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
                   ` (2 preceding siblings ...)
  2012-10-08  7:08 ` [PATCH 03/14] docs: fix column.1 groff syntax error Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 05/14] pg: use libc error printing facilities Sami Kerola
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Add function parse_arguments(), which has the same code block that was in
over long, and too deeply intended, main().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/pg.c | 159 ++++++++++++++++++++++++++++++--------------------------
 1 file changed, 84 insertions(+), 75 deletions(-)

diff --git a/text-utils/pg.c b/text-utils/pg.c
index c4a86ca..f9b6ac8 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -1581,12 +1581,91 @@ found_bw:
 		fclose(fbuf);
 }
 
+static int
+parse_arguments(int arg, int argc, char **argv)
+{
+	FILE *input;
+
+	files.first = arg;
+	files.last = arg + argc - 1;
+	for (; argv[arg]; arg += nextfile) {
+		nextfile = 1;
+		files.current = arg;
+		if (argc > 2) {
+			static int firsttime;
+			firsttime++;
+			if (firsttime > 1) {
+				mesg(_("(Next file: "));
+				mesg(argv[arg]);
+				mesg(")");
+ newfile:
+				if (ontty) {
+					prompt(-1);
+					switch (cmd.key) {
+					case 'n':
+						/*
+						 * Next file.
+						 */
+						if (cmd.count == 0)
+							cmd.count = 1;
+						nextfile = cmd.count;
+						if (checkf()) {
+							nextfile = 1;
+							mesg(":");
+							goto newfile;
+						}
+						continue;
+					case 'p':
+						/*
+						 * Previous file.
+						 */
+						if (cmd.count == 0)
+							cmd.count = 1;
+						nextfile = 0 - cmd.count;
+						if (checkf()) {
+							nextfile = 1;
+							mesg(":");
+							goto newfile;
+						}
+						continue;
+					case 'q':
+					case 'Q':
+						quit(exitstatus);
+					}
+				} else
+					mesg("\n");
+			}
+		}
+		if (strcmp(argv[arg], "-") == 0)
+			input = stdin;
+		else {
+			input = fopen(argv[arg], "r");
+			if (input == NULL) {
+				pgerror(errno, argv[arg]);
+				exitstatus++;
+				continue;
+			}
+		}
+		if (ontty == 0 && argc > 2) {
+			/*
+			 * Use the prefix as specified by SUSv2.
+			 */
+			write_all(1, "::::::::::::::\n", 15);
+			write_all(1, argv[arg], strlen(argv[arg]));
+			write_all(1, "\n::::::::::::::\n", 16);
+		}
+		pgfile(input, argv[arg]);
+		if (input != stdin)
+			fclose(input);
+	}
+	return exitstatus;
+}
+
 int
 main(int argc, char **argv)
 {
 	int arg, i;
 	char *p;
-	FILE *input;
 
 	progname = basename(argv[0]);
 	xasprintf(&copyright,
@@ -1703,81 +1782,11 @@ endargs:
 			invopt(argv[arg]);
 		}
 	}
-	if (argc == 1) {
+	if (argc == 1)
 		pgfile(stdin, "stdin");
-	} else {
-		files.first = arg;
-		files.last = arg + argc - 1;
-		for ( ; argv[arg]; arg += nextfile) {
-			nextfile = 1;
-			files.current = arg;
-			if (argc > 2) {
-				static int firsttime;
-				firsttime++;
-				if (firsttime > 1) {
-					mesg(_("(Next file: "));
-					mesg(argv[arg]);
-					mesg(")");
-newfile:
-					if (ontty) {
-					prompt(-1);
-					switch(cmd.key) {
-					case 'n':
-						/*
-					 	* Next file.
-					 	*/
-						if (cmd.count == 0)
-							cmd.count = 1;
-						nextfile = cmd.count;
-						if (checkf()) {
-							nextfile = 1;
-							mesg(":");
-							goto newfile;
-						}
-						continue;
-					case 'p':
-						/*
-					 	* Previous file.
-					 	*/
-						if (cmd.count == 0)
-							cmd.count = 1;
-						nextfile = 0 - cmd.count;
-						if (checkf()) {
-							nextfile = 1;
-							mesg(":");
-							goto newfile;
-						}
-						continue;
-					case 'q':
-					case 'Q':
-						quit(exitstatus);
-				}
-				} else mesg("\n");
-				}
-			}
-			if (strcmp(argv[arg], "-") == 0)
-				input = stdin;
-			else {
-				input = fopen(argv[arg], "r");
-				if (input == NULL) {
-					pgerror(errno, argv[arg]);
-					exitstatus++;
-					continue;
-				}
-			}
-			if (ontty == 0 && argc > 2) {
-				/*
-				 * Use the prefix as specified by SUSv2.
-				 */
-				write_all(1, "::::::::::::::\n", 15);
-				write_all(1, argv[arg], strlen(argv[arg]));
-				write_all(1, "\n::::::::::::::\n", 16);
-			}
-			pgfile(input, argv[arg]);
-			if (input != stdin)
-				fclose(input);
-		}
-	}
+	else
+		exitstatus = parse_arguments(arg, argc, argv);
+
 	quit(exitstatus);
 	/*NOTREACHED*/
 	return 0;
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 05/14] pg: use libc error printing facilities
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
                   ` (3 preceding siblings ...)
  2012-10-08  7:08 ` [PATCH 04/14] pg: refactor argument handing Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 06/14] pg: add const qualifiers where suitable Sami Kerola
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/pg.c | 39 ++++++++++++---------------------------
 1 file changed, 12 insertions(+), 27 deletions(-)

diff --git a/text-utils/pg.c b/text-utils/pg.c
index f9b6ac8..9f95eac 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -119,7 +119,6 @@ void		(*oldint)(int);		/* old SIGINT handler */
 void		(*oldquit)(int);	/* old SIGQUIT handler */
 void		(*oldterm)(int);	/* old SIGTERM handler */
 char		*tty;			/* result of ttyname(1) */
-char		*progname;		/* program name */
 unsigned	ontty;			/* whether running on tty device */
 unsigned	exitstatus;		/* exit status */
 int		pagelen = 23;		/* lines on a single screen page */
@@ -244,15 +243,14 @@ static void usage(FILE * out)
 static void
 needarg(char *s)
 {
-	fprintf(stderr, _("%s: option requires an argument -- %s\n"),
-		progname, s);
+	warnx(_("option requires an argument -- %s"), s);
 	usage(stderr);
 }
 
 static void
 invopt(char *s)
 {
-	fprintf(stderr, _("%s: illegal option -- %s\n"), progname, s);
+	warnx(_("illegal option -- %s"), s);
 	usage(stderr);
 }
 
@@ -932,30 +930,18 @@ static void
 tmperr(FILE *f, char *ftype)
 {
 	if (ferror(f))
-		fprintf(stderr, _("%s: Read error from %s file\n"),
-			progname, ftype);
+		warn(_("Read error from %s file"), ftype);
 	else if (feof(f))
 		/*
 		 * Most likely '\0' in input.
 		 */
-		fprintf(stderr, _("%s: Unexpected EOF in %s file\n"),
-			progname, ftype);
+		warnx(_("Unexpected EOF in %s file"), ftype);
 	else
-		fprintf(stderr, _("%s: Unknown error in %s file\n"),
-			progname, ftype);
+		warn(_("Unknown error in %s file"), ftype);
 	quit(++exitstatus);
 }
 
 /*
- * perror()-like, but showing the program's name.
- */
-static void
-pgerror(int eno, char *string)
-{
-	fprintf(stderr, "%s: %s: %s\n", progname, string, strerror(eno));
-}
-
-/*
  * Read the file and respond to user input.
  * Beware: long and ugly.
  */
@@ -1023,7 +1009,7 @@ pgfile(FILE *f, char *name)
 		while ((sz = fread(b, sizeof *b, READBUF, f)) != 0)
 			write_all(1, b, sz);
 		if (ferror(f)) {
-			pgerror(errno, name);
+			warn("%s", name);
 			exitstatus++;
 		}
 		return;
@@ -1036,7 +1022,7 @@ pgfile(FILE *f, char *name)
 	}
 	find = tmpfile();
 	if (fbuf == NULL || find == NULL) {
-		fprintf(stderr, _("%s: Cannot create tempfile\n"), progname);
+		warn(_("Cannot create tempfile"));
 		quit(++exitstatus);
 	}
 	if (searchfor) {
@@ -1088,12 +1074,12 @@ pgfile(FILE *f, char *name)
 					p = fgets(b, READBUF, f);
 					if (nobuf)
 						if ((fpos = ftello(f)) == -1)
-							pgerror(errno, name);
+							warn("%s", name);
 					canjump = 0;
 				}
 				if (p == NULL || *b == '\0') {
 					if (ferror(f))
-						pgerror(errno, name);
+						warn("%s", name);
 					eofline = fline;
 					eof = 1;
 					break;
@@ -1465,7 +1451,7 @@ found_bw:
 				 * Shell escape.
 				 */
 				if (rflag) {
-					mesg(progname);
+					mesg(program_invocation_short_name);
 					mesg(_(": !command not allowed in "
 					       "rflag mode.\n"));
 				} else {
@@ -1494,7 +1480,7 @@ found_bw:
 						my_sigset(SIGTERM, oldterm);
 						execl(p, p, "-c",
 							cmd.cmdline + 1, NULL);
-						pgerror(errno, p);
+						warn("%s", p);
 						_exit(0177);
 						/*NOTREACHED*/
 					case -1:
@@ -1641,7 +1627,7 @@ parse_arguments(int arg, int argc, char **argv)
 		else {
 			input = fopen(argv[arg], "r");
 			if (input == NULL) {
-				pgerror(errno, argv[arg]);
+				warn("%s", argv[arg]);
 				exitstatus++;
 				continue;
 			}
@@ -1667,7 +1653,6 @@ main(int argc, char **argv)
 	int arg, i;
 	char *p;
 
-	progname = basename(argv[0]);
 	xasprintf(&copyright,
 		  _("%s %s Copyright (c) 2000-2001 Gunnar Ritter. All rights reserved.\n"),
 		  program_invocation_short_name, PACKAGE_VERSION);
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 06/14] pg: add const qualifiers where suitable
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
                   ` (4 preceding siblings ...)
  2012-10-08  7:08 ` [PATCH 05/14] pg: use libc error printing facilities Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 07/14] pg: add noreturn function attributes Sami Kerola
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Includes a fix also to one assignment warning (see below).

text-utils/pg.c:1477:24: warning: assignment discards 'const' qualifier \
from pointer target type [enabled by default]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/pg.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/text-utils/pg.c b/text-utils/pg.c
index 9f95eac..0168ebc 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -134,7 +134,7 @@ int		fflag;			/* do not split lines */
 int		nflag;			/* no newline for commands required */
 int		rflag;			/* "restricted" pg */
 int		sflag;			/* use standout mode */
-char		*pstring = ":";		/* prompt string */
+const char	*pstring = ":";		/* prompt string */
 char		*searchfor;		/* search pattern from argv[] */
 int		havepagelen;		/* page length is manually defined */
 long		startline;		/* start line from argv[] */
@@ -241,14 +241,14 @@ static void usage(FILE * out)
 }
 
 static void
-needarg(char *s)
+needarg(const char *s)
 {
 	warnx(_("option requires an argument -- %s"), s);
 	usage(stderr);
 }
 
 static void
-invopt(char *s)
+invopt(const char *s)
 {
 	warnx(_("illegal option -- %s"), s);
 	usage(stderr);
@@ -295,7 +295,7 @@ outcap(int i)
  * Write messages to terminal.
  */
 static void
-mesg(char *message)
+mesg(const char *message)
 {
 	if (ontty == 0)
 		return;
@@ -927,7 +927,7 @@ makepat(void)
  * Process errors that occurred in temporary file operations.
  */
 static void
-tmperr(FILE *f, char *ftype)
+tmperr(FILE *f, const char *ftype)
 {
 	if (ferror(f))
 		warn(_("Read error from %s file"), ftype);
@@ -946,7 +946,7 @@ tmperr(FILE *f, char *ftype)
  * Beware: long and ugly.
  */
 static void
-pgfile(FILE *f, char *name)
+pgfile(FILE *f, const char *name)
 {
 	off_t pos, oldpos, fpos;
 	off_t line = 0, fline = 0, bline = 0, oldline = 0, eofline = 0;
@@ -1465,7 +1465,7 @@ found_bw:
 					switch (cpid = fork()) {
 					case 0:
 						p = getenv("SHELL");
-						if (p == NULL) p = "/bin/sh";
+						if (p == NULL) p = xstrdup("/bin/sh");
 						if (!nobuf)
 							fclose(fbuf);
 						fclose(find);
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 07/14] pg: add noreturn function attributes
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
                   ` (5 preceding siblings ...)
  2012-10-08  7:08 ` [PATCH 06/14] pg: add const qualifiers where suitable Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 08/14] pg: use unistd.h STDOUT_FILENO Sami Kerola
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/pg.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/text-utils/pg.c b/text-utils/pg.c
index 0168ebc..4b3b668 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -208,7 +208,7 @@ static my_sighandler_t my_sigset(int sig, my_sighandler_t disp) {
 /*
  * Quit pg.
  */
-static void
+static void __attribute__((__noreturn__))
 quit(int status)
 {
 	exit(status < 0100 ? status : 077);
@@ -217,7 +217,7 @@ quit(int status)
 /*
  * Usage message and similar routines.
  */
-static void usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(FILE * out)
 {
 	fputs(USAGE_HEADER, out);
 	fprintf(out,
@@ -240,14 +240,14 @@ static void usage(FILE * out)
 	quit(out == stderr ? 2 : 0);
 }
 
-static void
+static void __attribute__((__noreturn__))
 needarg(const char *s)
 {
 	warnx(_("option requires an argument -- %s"), s);
 	usage(stderr);
 }
 
-static void
+static void __attribute__((__noreturn__))
 invopt(const char *s)
 {
 	warnx(_("illegal option -- %s"), s);
@@ -926,7 +926,7 @@ makepat(void)
 /*
  * Process errors that occurred in temporary file operations.
  */
-static void
+static void __attribute__((__noreturn__))
 tmperr(FILE *f, const char *ftype)
 {
 	if (ferror(f))
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 08/14] pg: use unistd.h STDOUT_FILENO
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
                   ` (6 preceding siblings ...)
  2012-10-08  7:08 ` [PATCH 07/14] pg: add noreturn function attributes Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 09/14] pg: do not turn off warnigns artificially Sami Kerola
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/pg.c | 52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/text-utils/pg.c b/text-utils/pg.c
index 4b3b668..dedcfb9 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -288,7 +288,7 @@ static int
 outcap(int i)
 {
 	char c = i;
-	return write_all(1, &c, 1) == 0 ? 1 : -1;
+	return write_all(STDOUT_FILENO, &c, 1) == 0 ? 1 : -1;
 }
 
 /*
@@ -301,7 +301,7 @@ mesg(const char *message)
 		return;
 	if (*message != '\n' && sflag)
 		vidputs(A_STANDOUT, outcap);
-	write_all(1, message, strlen(message));
+	write_all(STDOUT_FILENO, message, strlen(message));
 	if (*message != '\n' && sflag)
 		vidputs(A_NORMAL, outcap);
 }
@@ -338,7 +338,7 @@ getwinsize(void)
 		initialized = 1;
 	}
 #ifdef	TIOCGWINSZ
-	badioctl = ioctl(1, TIOCGWINSZ, &winsz);
+	badioctl = ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsz);
 #endif
 	if (envcols)
 		ttycols = envcols - 1;
@@ -380,7 +380,7 @@ sighandler(int signum)
 {
 	if (canjump && (signum == SIGINT || signum == SIGQUIT))
 		longjmp(jmpenv, signum);
-	tcsetattr(1, TCSADRAIN, &otio);
+	tcsetattr(STDOUT_FILENO, TCSADRAIN, &otio);
 	quit(exitstatus);
 }
 
@@ -553,7 +553,7 @@ cline(void)
 	memset(buf, ' ', ttycols + 2);
 	buf[0] = '\r';
 	buf[ttycols + 1] = '\r';
-	write_all(1, buf, ttycols + 2);
+	write_all(STDOUT_FILENO, buf, ttycols + 2);
 	free(buf);
 }
 
@@ -583,7 +583,7 @@ getstate(int c)
 	default:
 #ifdef PG_BELL
 		if (bell)
-			tputs(bell, 1, outcap);
+			tputs(bell, STDOUT_FILENO, outcap);
 #endif  /*  PG_BELL  */
 		return INVALID;
 	}
@@ -649,21 +649,21 @@ prompt(long long pageno)
 	}
 	cmd.key = cmd.addon = cmd.cmdline[0] = '\0';
 	cmd.cmdlen = 0;
-	tcgetattr(1, &tio);
+	tcgetattr(STDOUT_FILENO, &tio);
 	tio.c_lflag &= ~(ICANON | ECHO);
 	tio.c_cc[VMIN] = 1;
 	tio.c_cc[VTIME] = 0;
-	tcsetattr(1, TCSADRAIN, &tio);
-	tcflush(1, TCIFLUSH);
+	tcsetattr(STDOUT_FILENO, TCSADRAIN, &tio);
+	tcflush(STDOUT_FILENO, TCIFLUSH);
 	for (;;) {
-		switch (read(1, &key, 1)) {
+		switch (read(STDOUT_FILENO, &key, 1)) {
 		case 0: quit(0);
 			/*NOTREACHED*/
 		case -1: quit(1);
 		}
 		if (key == tio.c_cc[VERASE]) {
 			if (cmd.cmdlen) {
-				write_all(1, "\b \b", 3);
+				write_all(STDOUT_FILENO, "\b \b", 3);
 				cmd.cmdline[--cmd.cmdlen] = '\0';
 				switch (state) {
 				case ADDON_FIN:
@@ -766,14 +766,14 @@ prompt(long long pageno)
 				cmd.key = key;
 			}
 		}
-		write_all(1, &key, 1);
+		write_all(STDOUT_FILENO, &key, 1);
 		cmd.cmdline[cmd.cmdlen++] = key;
 		cmd.cmdline[cmd.cmdlen] = '\0';
 		if (nflag && state == CMD_FIN)
 			goto endprompt;
 	}
 endprompt:
-	tcsetattr(1, TCSADRAIN, &otio);
+	tcsetattr(STDOUT_FILENO, TCSADRAIN, &otio);
 	cline();
 	cmd.count = getcount(cmd.cmdline);
 }
@@ -1007,7 +1007,7 @@ pgfile(FILE *f, const char *name)
 		 * Just copy stdin to stdout.
 		 */
 		while ((sz = fread(b, sizeof *b, READBUF, f)) != 0)
-			write_all(1, b, sz);
+			write_all(STDOUT_FILENO, b, sz);
 		if (ferror(f)) {
 			warn("%s", name);
 			exitstatus++;
@@ -1147,7 +1147,7 @@ pgfile(FILE *f, const char *name)
 			if (cflag && clear_screen) {
 				switch (dline) {
 				case 0:
-					tputs(clear_screen, 1, outcap);
+					tputs(clear_screen, STDOUT_FILENO, outcap);
 					dline = 0;
 				}
 			}
@@ -1167,7 +1167,7 @@ pgfile(FILE *f, const char *name)
 				sz = p - b;
 				makeprint(b, sz);
 				canjump = 1;
-				write_all(1, b, sz);
+				write_all(STDOUT_FILENO, b, sz);
 				canjump = 0;
 			}
 		}
@@ -1457,9 +1457,9 @@ found_bw:
 				} else {
 					pid_t cpid;
 
-					write_all(1, cmd.cmdline,
+					write_all(STDOUT_FILENO, cmd.cmdline,
 					      strlen(cmd.cmdline));
-					write_all(1, "\n", 1);
+					write_all(STDOUT_FILENO, "\n", 1);
 					my_sigset(SIGINT, SIG_IGN);
 					my_sigset(SIGQUIT, SIG_IGN);
 					switch (cpid = fork()) {
@@ -1501,8 +1501,8 @@ found_bw:
 				 * Help!
 				 */
 				const char *help = _(helpscreen);
-				write_all(1, copyright, strlen(copyright));
-				write_all(1, help, strlen(help));
+				write_all(STDOUT_FILENO, copyright, strlen(copyright));
+				write_all(STDOUT_FILENO, help, strlen(help));
 				goto newcmd;
 			}
 			case 'n':
@@ -1636,9 +1636,9 @@ parse_arguments(int arg, int argc, char **argv)
 			/*
 			 * Use the prefix as specified by SUSv2.
 			 */
-			write_all(1, "::::::::::::::\n", 15);
-			write_all(1, argv[arg], strlen(argv[arg]));
-			write_all(1, "\n::::::::::::::\n", 16);
+			write_all(STDOUT_FILENO, "::::::::::::::\n", 15);
+			write_all(STDOUT_FILENO, argv[arg], strlen(argv[arg]));
+			write_all(STDOUT_FILENO, "\n::::::::::::::\n", 16);
 		}
 		pgfile(input, argv[arg]);
 		if (input != stdin)
@@ -1662,15 +1662,15 @@ main(int argc, char **argv)
 	textdomain(PACKAGE);
 	atexit(close_stdout);
 
-	if (tcgetattr(1, &otio) == 0) {
+	if (tcgetattr(STDOUT_FILENO, &otio) == 0) {
 		ontty = 1;
 		oldint = my_sigset(SIGINT, sighandler);
 		oldquit = my_sigset(SIGQUIT, sighandler);
 		oldterm = my_sigset(SIGTERM, sighandler);
 		setlocale(LC_CTYPE, "");
 		setlocale(LC_COLLATE, "");
-		tty = ttyname(1);
-		setupterm(NULL, 1, &tinfostat);
+		tty = ttyname(STDOUT_FILENO);
+		setupterm(NULL, STDOUT_FILENO, &tinfostat);
 		getwinsize();
 		helpscreen = _(helpscreen);
 	}
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 09/14] pg: do not turn off warnigns artificially
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
                   ` (7 preceding siblings ...)
  2012-10-08  7:08 ` [PATCH 08/14] pg: use unistd.h STDOUT_FILENO Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 10/14] pg: fix coding style Sami Kerola
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Compiler warnings often mean something, fiddling with them is not good
practise.  Besides the 'proglem' removed macro tried to 'fix' does not
even occur when compiling with modern gcc.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/pg.c | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/text-utils/pg.c b/text-utils/pg.c
index dedcfb9..3d278bf 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -70,11 +70,6 @@
 #define CMDBUF		255		/* size of command buffer */
 #define	TABSIZE		8		/* spaces consumed by tab character */
 
-/*
- * Avoid the message "`var' might be clobbered by `longjmp' or `vfork'"
- */
-#define	CLOBBGRD(a)	(void)(&(a));
-
 #define	cuc(c)		((c) & 0377)
 
 enum { FORWARD = 1, BACKWARD = 2 };	/* search direction */
@@ -986,22 +981,6 @@ pgfile(FILE *f, const char *name)
 	 */
 	FILE *fbuf, *find, *save;
 
-	/* silence compiler - it may warn about longjmp() */
-	CLOBBGRD(line);
-	CLOBBGRD(fline);
-	CLOBBGRD(bline);
-	CLOBBGRD(oldline);
-	CLOBBGRD(eofline);
-	CLOBBGRD(dline);
-	CLOBBGRD(ttycols);
-	CLOBBGRD(search);
-	CLOBBGRD(searchcount);
-	CLOBBGRD(seekeof);
-	CLOBBGRD(eof);
-	CLOBBGRD(fpos);
-	CLOBBGRD(nobuf);
-	CLOBBGRD(fbuf);
-
 	if (ontty == 0) {
 		/*
 		 * Just copy stdin to stdout.
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 10/14] pg: fix coding style
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
                   ` (8 preceding siblings ...)
  2012-10-08  7:08 ` [PATCH 09/14] pg: do not turn off warnigns artificially Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 11/14] more: " Sami Kerola
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/pg.c | 699 ++++++++++++++++++++++++--------------------------------
 1 file changed, 296 insertions(+), 403 deletions(-)

diff --git a/text-utils/pg.c b/text-utils/pg.c
index 3d278bf..cdee117 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -35,7 +35,7 @@
 #include <sys/wait.h>
 #include <sys/stat.h>
 #ifndef	TIOCGWINSZ
-#include <sys/ioctl.h>
+# include <sys/ioctl.h>
 #endif
 #include <sys/termios.h>
 #include <fcntl.h>
@@ -52,9 +52,9 @@
 #include <libgen.h>
 
 #ifdef HAVE_NCURSES_H
-#include <ncurses.h>
+# include <ncurses.h>
 #elif defined(HAVE_NCURSES_NCURSES_H)
-#include <ncurses/ncurses.h>
+# include <ncurses/ncurses.h>
 #endif
 
 #include <term.h>
@@ -75,9 +75,7 @@
 enum { FORWARD = 1, BACKWARD = 2 };	/* search direction */
 enum { TOP, MIDDLE, BOTTOM };		/* position of matching line */
 
-/*
- * States for syntax-aware command line editor.
- */
+/* States for syntax-aware command line editor. */
 enum {
 	COUNT,
 	SIGN,
@@ -89,9 +87,7 @@ enum {
 	INVALID
 };
 
-/*
- * Current command
- */
+/* Current command */
 struct {
 	char cmdline[CMDBUF];
 	size_t cmdlen;
@@ -101,42 +97,40 @@ struct {
 	char addon;
 } cmd;
 
-/*
- * Position of file arguments on argv[] to main()
- */
+/* Position of file arguments on argv[] to main() */
 struct {
 	int first;
 	int current;
 	int last;
 } files;
 
-void		(*oldint)(int);		/* old SIGINT handler */
-void		(*oldquit)(int);	/* old SIGQUIT handler */
-void		(*oldterm)(int);	/* old SIGTERM handler */
-char		*tty;			/* result of ttyname(1) */
-unsigned	ontty;			/* whether running on tty device */
-unsigned	exitstatus;		/* exit status */
-int		pagelen = 23;		/* lines on a single screen page */
-int		ttycols = 79;		/* screen columns (starting at 0) */
-struct termios	otio;			/* old termios settings */
-int		tinfostat = -1;		/* terminfo routines initialized */
-int		searchdisplay = TOP;	/* matching line position */
-regex_t		re;			/* regular expression to search for */
-int		remembered;		/* have a remembered search string */
-int		cflag;			/* clear screen before each page */
-int		eflag;			/* suppress (EOF) */
-int		fflag;			/* do not split lines */
-int		nflag;			/* no newline for commands required */
-int		rflag;			/* "restricted" pg */
-int		sflag;			/* use standout mode */
-const char	*pstring = ":";		/* prompt string */
-char		*searchfor;		/* search pattern from argv[] */
-int		havepagelen;		/* page length is manually defined */
-long		startline;		/* start line from argv[] */
-int		nextfile = 1;		/* files to advance */
-jmp_buf		jmpenv;			/* jump from signal handlers */
-int		canjump;		/* jmpenv is valid */
-wchar_t		wbuf[READBUF];		/* used in several widechar routines */
+void (*oldint) (int);		/* old SIGINT handler */
+void (*oldquit) (int);		/* old SIGQUIT handler */
+void (*oldterm) (int);		/* old SIGTERM handler */
+char *tty;			/* result of ttyname(1) */
+unsigned ontty;			/* whether running on tty device */
+unsigned exitstatus;		/* exit status */
+int pagelen = 23;		/* lines on a single screen page */
+int ttycols = 79;		/* screen columns (starting at 0) */
+struct termios otio;		/* old termios settings */
+int tinfostat = -1;		/* terminfo routines initialized */
+int searchdisplay = TOP;	/* matching line position */
+regex_t re;			/* regular expression to search for */
+int remembered;			/* have a remembered search string */
+int cflag;			/* clear screen before each page */
+int eflag;			/* suppress (EOF) */
+int fflag;			/* do not split lines */
+int nflag;			/* no newline for commands required */
+int rflag;			/* "restricted" pg */
+int sflag;			/* use standout mode */
+const char *pstring = ":";	/* prompt string */
+char *searchfor;		/* search pattern from argv[] */
+int havepagelen;		/* page length is manually defined */
+long startline;			/* start line from argv[] */
+int nextfile = 1;		/* files to advance */
+jmp_buf jmpenv;			/* jump from signal handlers */
+int canjump;			/* jmpenv is valid */
+wchar_t wbuf[READBUF];		/* used in several widechar routines */
 
 char *copyright;
 const char *helpscreen = N_("\
@@ -164,28 +158,34 @@ See pg(1) for more information.\n\
 -------------------------------------------------------\n");
 
 #ifndef HAVE_FSEEKO
-  static int fseeko(FILE *f, off_t off, int whence) {
-	return fseek(f, (long) off, whence);
-  }
-  static off_t ftello(FILE *f) {
+static int fseeko(FILE *f, off_t off, int whence)
+{
+	return fseek(f, (long)off, whence);
+}
+
+static off_t ftello(FILE *f)
+{
 	return (off_t) ftell(f);
-  }
+}
 #endif
 
 #ifdef USE_SIGSET	/* never defined */
 /* sigset and sigrelse are obsolete - use when POSIX stuff is unavailable */
-#define my_sigset	sigset
-#define my_sigrelse	sigrelse
+# define my_sigset	sigset
+# define my_sigrelse	sigrelse
 #else
-static int my_sigrelse(int sig) {
+static int my_sigrelse(int sig)
+{
 	sigset_t sigs;
 
 	if (sigemptyset(&sigs) || sigaddset(&sigs, sig))
 		return -1;
 	return sigprocmask(SIG_UNBLOCK, &sigs, NULL);
 }
-typedef void (*my_sighandler_t)(int);
-static my_sighandler_t my_sigset(int sig, my_sighandler_t disp) {
+
+typedef void (*my_sighandler_t) (int);
+static my_sighandler_t my_sigset(int sig, my_sighandler_t disp)
+{
 	struct sigaction act, oact;
 
 	act.sa_handler = disp;
@@ -198,25 +198,20 @@ static my_sighandler_t my_sigset(int sig, my_sighandler_t disp) {
 		return SIG_ERR;
 	return oact.sa_handler;
 }
-#endif
+#endif	/* USE_SIGSET */
 
-/*
- * Quit pg.
- */
-static void __attribute__((__noreturn__))
-quit(int status)
+/* Quit pg. */
+static void __attribute__((__noreturn__)) quit(int status)
 {
 	exit(status < 0100 ? status : 077);
 }
 
-/*
- * Usage message and similar routines.
- */
-static void __attribute__((__noreturn__)) usage(FILE * out)
+/* Usage message and similar routines. */
+static void __attribute__((__noreturn__)) usage(FILE *out)
 {
 	fputs(USAGE_HEADER, out);
 	fprintf(out,
-	      _(" %s [options] [+line] [+/pattern/] [files]\n"),
+		_(" %s [options] [+line] [+/pattern/] [files]\n"),
 		program_invocation_short_name);
 	fputs(USAGE_OPTIONS, out);
 	fputs(_(" -number      lines per page\n"), out);
@@ -235,31 +230,27 @@ static void __attribute__((__noreturn__)) usage(FILE * out)
 	quit(out == stderr ? 2 : 0);
 }
 
-static void __attribute__((__noreturn__))
-needarg(const char *s)
+static void __attribute__((__noreturn__)) needarg(const char *s)
 {
 	warnx(_("option requires an argument -- %s"), s);
 	usage(stderr);
 }
 
-static void __attribute__((__noreturn__))
-invopt(const char *s)
+static void __attribute__((__noreturn__)) invopt(const char *s)
 {
 	warnx(_("illegal option -- %s"), s);
 	usage(stderr);
 }
 
 #ifdef HAVE_WIDECHAR
-/*
- * A mbstowcs()-alike function that transparently handles invalid sequences.
- */
-static size_t
-xmbstowcs(wchar_t *pwcs, const char *s, size_t nwcs)
+/* A mbstowcs()-alike function that transparently handles invalid
+ * sequences. */
+static size_t xmbstowcs(wchar_t * pwcs, const char *s, size_t nwcs)
 {
 	size_t n = nwcs;
 	int c;
 
-	ignore_result( mbtowc(pwcs, NULL, MB_CUR_MAX) );	/* reset shift state */
+	ignore_result(mbtowc(pwcs, NULL, MB_CUR_MAX));	/* reset shift state */
 	while (*s && n) {
 		if ((c = mbtowc(pwcs, s, MB_CUR_MAX)) < 0) {
 			s++;
@@ -271,26 +262,20 @@ xmbstowcs(wchar_t *pwcs, const char *s, size_t nwcs)
 	}
 	if (n)
 		*pwcs = L'\0';
-	ignore_result( mbtowc(pwcs, NULL, MB_CUR_MAX) );
+	ignore_result(mbtowc(pwcs, NULL, MB_CUR_MAX));
 	return nwcs - n;
 }
 #endif
 
-/*
- * Helper function for tputs().
- */
-static int
-outcap(int i)
+/* Helper function for tputs(). */
+static int outcap(int i)
 {
 	char c = i;
 	return write_all(STDOUT_FILENO, &c, 1) == 0 ? 1 : -1;
 }
 
-/*
- * Write messages to terminal.
- */
-static void
-mesg(const char *message)
+/* Write messages to terminal. */
+static void mesg(const char *message)
 {
 	if (ontty == 0)
 		return;
@@ -301,11 +286,8 @@ mesg(const char *message)
 		vidputs(A_NORMAL, outcap);
 }
 
-/*
- * Get the window size.
- */
-static void
-getwinsize(void)
+/* Get the window size. */
+static void getwinsize(void)
 {
 	static int initialized, envlines, envcols, deflines, defcols;
 #ifdef	TIOCGWINSZ
@@ -355,11 +337,8 @@ getwinsize(void)
 	}
 }
 
-/*
- * Message if skipping parts of files.
- */
-static void
-skip(int direction)
+/* Message if skipping parts of files. */
+static void skip(int direction)
 {
 	if (direction > 0)
 		mesg(_("...skipping forward\n"));
@@ -367,11 +346,8 @@ skip(int direction)
 		mesg(_("...skipping backward\n"));
 }
 
-/*
- * Signal handler while reading from input file.
- */
-static void
-sighandler(int signum)
+/* Signal handler while reading from input file. */
+static void sighandler(int signum)
 {
 	if (canjump && (signum == SIGINT || signum == SIGQUIT))
 		longjmp(jmpenv, signum);
@@ -379,11 +355,8 @@ sighandler(int signum)
 	quit(exitstatus);
 }
 
-/*
- * Check whether the requested file was specified on the command line.
- */
-static int
-checkf(void)
+/* Check whether the requested file was specified on the command line. */
+static int checkf(void)
 {
 	if (files.current + nextfile >= files.last) {
 		mesg(_("No next file"));
@@ -397,12 +370,9 @@ checkf(void)
 }
 
 #ifdef HAVE_WIDECHAR
-/*
- * Return the last character that will fit on the line at col columns
- * in case MB_CUR_MAX > 1.
- */
-static char *
-endline_for_mb(unsigned col, char *s)
+/* Return the last character that will fit on the line at col columns in
+ * case MB_CUR_MAX > 1. */
+static char *endline_for_mb(unsigned col, char *s)
 {
 	size_t pos = 0;
 	wchar_t *p = wbuf;
@@ -415,30 +385,22 @@ endline_for_mb(unsigned col, char *s)
 	wbuf[wl] = L'\0';
 	while (*p != L'\0') {
 		switch (*p) {
-			/*
-			 * Cursor left.
-			 */
+			/* Cursor left. */
 		case L'\b':
 			if (pos > 0)
 				pos--;
 			break;
-			/*
-			 * No cursor movement.
-			 */
+			/* No cursor movement. */
 		case L'\a':
 			break;
-			/*
-			 * Special.
-			 */
+			/* Special. */
 		case L'\r':
 			pos = 0;
 			break;
 		case L'\n':
 			end = p + 1;
 			goto ended;
-			/*
-			 * Cursor right.
-			 */
+			/* Cursor right. */
 		case L'\t':
 			pos += TABSIZE - (pos % TABSIZE);
 			break;
@@ -452,13 +414,10 @@ endline_for_mb(unsigned col, char *s)
 			if (*p == L'\t')
 				p++;
 			else if (pos > col + 1)
-				/*
-				 * wcwidth() found a character that
-				 * has multiple columns. What happens
-				 * now? Assume the terminal will print
-				 * the entire character onto the next
-				 * row.
-				 */
+				/* wcwidth() found a character that has
+				 * multiple columns.  What happens now?
+				 * Assume the terminal will print the
+				 * entire character onto the next row. */
 				p--;
 			if (*++p == L'\n')
 				p++;
@@ -471,17 +430,14 @@ endline_for_mb(unsigned col, char *s)
  ended:
 	*end = L'\0';
 	p = wbuf;
-	if ((pos = wcstombs(NULL, p, READBUF)) == (size_t) -1)
+	if ((pos = wcstombs(NULL, p, READBUF)) == (size_t)-1)
 		return s + 1;
 	return s + pos;
 }
-#endif
+#endif	/* HAVE_WIDECHAR */
 
-/*
- * Return the last character that will fit on the line at col columns.
- */
-static char *
-endline(unsigned col, char *s)
+/* Return the last character that will fit on the line at col columns. */
+static char *endline(unsigned col, char *s)
 {
 	unsigned pos = 0;
 	char *t = s;
@@ -493,30 +449,22 @@ endline(unsigned col, char *s)
 
 	while (*s != '\0') {
 		switch (*s) {
-			/*
-			 * Cursor left.
-			 */
+			/* Cursor left. */
 		case '\b':
 			if (pos > 0)
 				pos--;
 			break;
-			/*
-			 * No cursor movement.
-			 */
+			/* No cursor movement. */
 		case '\a':
 			break;
-			/*
-			 * Special.
-			 */
+			/* Special. */
 		case '\r':
 			pos = 0;
 			break;
 		case '\n':
 			t = s + 1;
 			goto cend;
-			/*
-			 * Cursor right.
-			 */
+			/* Cursor right. */
 		case '\t':
 			pos += TABSIZE - (pos % TABSIZE);
 			break;
@@ -538,11 +486,8 @@ endline(unsigned col, char *s)
 	return t;
 }
 
-/*
- * Clear the current line on the terminal's screen.
- */
-static void
-cline(void)
+/* Clear the current line on the terminal's screen. */
+static void cline(void)
 {
 	char *buf = xmalloc(ttycols + 2);
 	memset(buf, ' ', ttycols + 2);
@@ -552,43 +497,62 @@ cline(void)
 	free(buf);
 }
 
-/*
- * Evaluate a command character's semantics.
- */
-static int
-getstate(int c)
+/* Evaluate a command character's semantics. */
+static int getstate(int c)
 {
 	switch (c) {
-	case '1': case '2': case '3': case '4': case '5':
-	case '6': case '7': case '8': case '9': case '0':
+	case '1':
+	case '2':
+	case '3':
+	case '4':
+	case '5':
+	case '6':
+	case '7':
+	case '8':
+	case '9':
+	case '0':
 	case '\0':
 		return COUNT;
-	case '-': case '+':
+	case '-':
+	case '+':
 		return SIGN;
-	case 'l': case 'd': case '\004': case 'f': case 'z':
-	case '.': case '\014': case '$': case 'n': case 'p':
-	case 'w': case 'h': case 'q': case 'Q':
+	case 'l':
+	case 'd':
+	case '\004':
+	case 'f':
+	case 'z':
+	case '.':
+	case '\014':
+	case '$':
+	case 'n':
+	case 'p':
+	case 'w':
+	case 'h':
+	case 'q':
+	case 'Q':
 		return CMD_FIN;
-	case '/': case '?': case '^':
+	case '/':
+	case '?':
+	case '^':
 		return SEARCH;
-	case 's': case '!':
+	case 's':
+	case '!':
 		return STRING;
-	case 'm': case 'b': case 't':
+	case 'm':
+	case 'b':
+	case 't':
 		return ADDON_FIN;
 	default:
 #ifdef PG_BELL
 		if (bell)
 			tputs(bell, STDOUT_FILENO, outcap);
-#endif  /*  PG_BELL  */
+#endif
 		return INVALID;
 	}
 }
 
-/*
- * Get the count and ignore last character of string.
- */
-static int
-getcount(char *cmdstr)
+/* Get the count and ignore last character of string. */
+static int getcount(char *cmdstr)
 {
 	char *buf;
 	char *p;
@@ -619,12 +583,9 @@ getcount(char *cmdstr)
 	return i;
 }
 
-/*
- * Read what the user writes at the prompt. This is tricky because
- * we check for valid input.
- */
-static void
-prompt(long long pageno)
+/* Read what the user writes at the prompt. This is tricky because we
+ * check for valid input. */
+static void prompt(long long pageno)
 {
 	struct termios tio;
 	char key;
@@ -652,9 +613,11 @@ prompt(long long pageno)
 	tcflush(STDOUT_FILENO, TCIFLUSH);
 	for (;;) {
 		switch (read(STDOUT_FILENO, &key, 1)) {
-		case 0: quit(0);
-			/*NOTREACHED*/
-		case -1: quit(1);
+		case 0:
+			quit(0);
+			/* NOTREACHED */
+		case -1:
+			quit(1);
 		}
 		if (key == tio.c_cc[VERASE]) {
 			if (cmd.cmdlen) {
@@ -671,20 +634,19 @@ prompt(long long pageno)
 					break;
 				case SEARCH_FIN:
 					state = SEARCH;
-					/*FALLTHRU*/
+					/* FALLTHRU */
 				case SEARCH:
-					if (cmd.cmdline[cmd.cmdlen - 1]
-							== '\\') {
+					if (cmd.cmdline[cmd.cmdlen - 1] == '\\') {
 						escape = 1;
-						while(cmd.cmdline[cmd.cmdlen
-								- escape - 1]
-							== '\\') escape++;
+						while (cmd.cmdline[cmd.cmdlen
+								   - escape - 1]
+						       == '\\')
+							escape++;
 						escape %= 2;
-					}
-					else {
+					} else {
 						escape = 0;
 						if (strchr(cmd.cmdline, cmd.key)
-							== NULL) {
+						    == NULL) {
 							cmd.key = '\0';
 							state = COUNT;
 						}
@@ -751,7 +713,7 @@ prompt(long long pageno)
 					continue;
 				}
 				state = COUNT;
-				/*FALLTHRU*/
+				/* FALLTHRU */
 			case COUNT:
 				break;
 			case ADDON_FIN:
@@ -767,19 +729,15 @@ prompt(long long pageno)
 		if (nflag && state == CMD_FIN)
 			goto endprompt;
 	}
-endprompt:
+ endprompt:
 	tcsetattr(STDOUT_FILENO, TCSADRAIN, &otio);
 	cline();
 	cmd.count = getcount(cmd.cmdline);
 }
 
 #ifdef HAVE_WIDECHAR
-/*
- * Remove backspace formatting, for searches
- * in case MB_CUR_MAX > 1.
- */
-static char *
-colb_for_mb(char *s)
+/* Remove backspace formatting, for searches in case MB_CUR_MAX > 1. */
+static char *colb_for_mb(char *s)
 {
 	char *p = s;
 	wchar_t *wp, *wq;
@@ -788,8 +746,7 @@ colb_for_mb(char *s)
 
 	if ((wl = xmbstowcs(wbuf, p, sizeof wbuf)) == (size_t)-1)
 		return s;
-	for (wp = wbuf, wq = wbuf, i = 0; *wp != L'\0' && i < wl;
-	     wp++, wq++) {
+	for (wp = wbuf, wq = wbuf, i = 0; *wp != L'\0' && i < wl; wp++, wq++) {
 		if (*wp == L'\b') {
 			if (wq != wbuf)
 				wq -= 2;
@@ -806,11 +763,8 @@ colb_for_mb(char *s)
 }
 #endif
 
-/*
- * Remove backspace formatting, for searches.
- */
-static char *
-colb(char *s)
+/* Remove backspace formatting, for searches. */
+static char *colb(char *s)
 {
 	char *p = s, *q;
 
@@ -834,12 +788,8 @@ colb(char *s)
 }
 
 #ifdef HAVE_WIDECHAR
-/*
- * Convert nonprintable characters to spaces
- * in case MB_CUR_MAX > 1.
- */
-static void
-makeprint_for_mb(char *s, size_t l)
+/* Convert nonprintable characters to spaces in case MB_CUR_MAX > 1.  */
+static void makeprint_for_mb(char *s, size_t l)
 {
 	char *t = s;
 	wchar_t *wp = wbuf;
@@ -858,11 +808,8 @@ makeprint_for_mb(char *s, size_t l)
 }
 #endif
 
-/*
- * Convert nonprintable characters to spaces.
- */
-static void
-makeprint(char *s, size_t l)
+/* Convert nonprintable characters to spaces. */
+static void makeprint(char *s, size_t l)
 {
 #ifdef HAVE_WIDECHAR
 	if (MB_CUR_MAX > 1) {
@@ -879,11 +826,8 @@ makeprint(char *s, size_t l)
 	}
 }
 
-/*
- * Strip backslash characters from the given string.
- */
-static void
-striprs(char *s)
+/* Strip backslash characters from the given string. */
+static void striprs(char *s)
 {
 	char *p = s;
 
@@ -895,11 +839,8 @@ striprs(char *s)
 	} while (*s++ != '\0');
 }
 
-/*
- * Extract the search pattern off the command line.
- */
-static char *
-makepat(void)
+/* Extract the search pattern off the command line. */
+static char *makepat(void)
 {
 	char *p;
 
@@ -918,73 +859,52 @@ makepat(void)
 	return p;
 }
 
-/*
- * Process errors that occurred in temporary file operations.
- */
-static void __attribute__((__noreturn__))
-tmperr(FILE *f, const char *ftype)
+/* Process errors that occurred in temporary file operations. */
+static void __attribute__((__noreturn__)) tmperr(FILE *f, const char *ftype)
 {
 	if (ferror(f))
 		warn(_("Read error from %s file"), ftype);
 	else if (feof(f))
-		/*
-		 * Most likely '\0' in input.
-		 */
+		/* Most likely '\0' in input. */
 		warnx(_("Unexpected EOF in %s file"), ftype);
 	else
 		warn(_("Unknown error in %s file"), ftype);
 	quit(++exitstatus);
 }
 
-/*
- * Read the file and respond to user input.
- * Beware: long and ugly.
- */
-static void
-pgfile(FILE *f, const char *name)
+/* Read the file and respond to user input.  Beware: long and ugly. */
+static void pgfile(FILE *f, const char *name)
 {
 	off_t pos, oldpos, fpos;
+	/* These are the line counters:
+	 *   line	the line desired to display
+	 *   fline	the current line of the input file
+	 *   bline	the current line of the file buffer
+	 *   oldline	the line before a search was started
+	 *   eofline	the last line of the file if it is already reached
+	 *   dline	the line on the display */
 	off_t line = 0, fline = 0, bline = 0, oldline = 0, eofline = 0;
 	int dline = 0;
-	/*
-	 * These are the line counters:
-	 * line		the line desired to display
-	 * fline	the current line of the input file
-	 * bline	the current line of the file buffer
-	 * oldline	the line before a search was started
-	 * eofline	the last line of the file if it is already reached
-	 * dline	the line on the display
-	 */
 	int search = 0;
 	unsigned searchcount = 0;
-	/*
-	 * Advance to EOF immediately.
-	 */
+	/* Advance to EOF immediately. */
 	int seekeof = 0;
-	/*
-	 * EOF has been reached by `line'.
-	 */
+	/* EOF has been reached by `line'. */
 	int eof = 0;
-	/*
-	 * f and fbuf refer to the same file.
-	 */
+	/* f and fbuf refer to the same file. */
 	int nobuf = 0;
 	int sig;
 	int rerror;
 	size_t sz;
 	char b[READBUF + 1];
 	char *p;
-	/*
-	 * fbuf		an exact copy of the input file as it gets read
-	 * find		index table for input, one entry per line
-	 * save		for the s command, to save to a file
-	 */
+	/*   fbuf	an exact copy of the input file as it gets read
+	 *   find	index table for input, one entry per line
+	 *   save	for the s command, to save to a file */
 	FILE *fbuf, *find, *save;
 
 	if (ontty == 0) {
-		/*
-		 * Just copy stdin to stdout.
-		 */
+		/* Just copy stdin to stdout. */
 		while ((sz = fread(b, sizeof *b, READBUF, f)) != 0)
 			write_all(STDOUT_FILENO, b, sz);
 		if (ferror(f)) {
@@ -1018,10 +938,8 @@ pgfile(FILE *f, const char *name)
 		remembered = 1;
 	}
 
-	for (line = startline; ; ) {
-		/*
-		 * Get a line from input file or buffer.
-		 */
+	for (line = startline;;) {
+		/* Get a line from input file or buffer. */
 		if (line < bline) {
 			fseeko(find, line * sizeof pos, SEEK_SET);
 			if (fread(&pos, sizeof pos, 1, find) == 0)
@@ -1037,9 +955,7 @@ pgfile(FILE *f, const char *name)
 					fseeko(fbuf, (off_t)0, SEEK_END);
 				pos = ftello(fbuf);
 				if ((sig = setjmp(jmpenv)) != 0) {
-					/*
-					 * We got a signal.
-					 */
+					/* We got a signal. */
 					canjump = 0;
 					my_sigrelse(sig);
 					fseeko(fbuf, pos, SEEK_SET);
@@ -1070,12 +986,12 @@ pgfile(FILE *f, const char *name)
 						oldpos = pos;
 						p = b;
 						while (*(p = endline(ttycols,
-									p))
-								!= '\0') {
+								     p))
+						       != '\0') {
 							pos = oldpos + (p - b);
 							fwrite_all(&pos,
-								sizeof pos,
-								1, find);
+								   sizeof pos,
+								   1, find);
 							fline++;
 							bline++;
 						}
@@ -1084,9 +1000,7 @@ pgfile(FILE *f, const char *name)
 				}
 			} while (line > bline++);
 		} else {
-			/*
-			 * eofline != 0
-			 */
+			/* eofline != 0 */
 			eof = 1;
 		}
 		if (search == FORWARD && remembered == 1) {
@@ -1118,15 +1032,15 @@ pgfile(FILE *f, const char *name)
 				skip(1);
 			}
 			continue;
-		} else if (eof)	{	/*
-					 * We are not searching.
-					 */
+		} else if (eof) {
+			/* We are not searching. */
 			line = bline;
 		} else if (*b != '\0') {
 			if (cflag && clear_screen) {
 				switch (dline) {
 				case 0:
-					tputs(clear_screen, STDOUT_FILENO, outcap);
+					tputs(clear_screen, STDOUT_FILENO,
+					      outcap);
 					dline = 0;
 				}
 			}
@@ -1135,9 +1049,7 @@ pgfile(FILE *f, const char *name)
 				eof = 1;
 			dline++;
 			if ((sig = setjmp(jmpenv)) != 0) {
-				/*
-				 * We got a signal.
-				 */
+				/* We got a signal. */
 				canjump = 0;
 				my_sigrelse(sig);
 				dline = pagelen;
@@ -1151,9 +1063,7 @@ pgfile(FILE *f, const char *name)
 			}
 		}
 		if (dline >= pagelen || eof) {
-			/*
-			 * Time for prompting!
-			 */
+			/* Time for prompting! */
 			if (eof && seekeof) {
 				eof = seekeof = 0;
 				if (line >= pagelen)
@@ -1163,7 +1073,7 @@ pgfile(FILE *f, const char *name)
 				dline = -1;
 				continue;
 			}
-newcmd:
+ newcmd:
 			if (eof) {
 				if (fline == 0 || eflag)
 					break;
@@ -1172,9 +1082,7 @@ newcmd:
 			prompt((line - 1) / pagelen + 1);
 			switch (cmd.key) {
 			case '/':
-				/*
-				 * Search forward.
-				 */
+				/* Search forward. */
 				search = FORWARD;
 				oldline = line;
 				searchcount = cmd.count;
@@ -1183,11 +1091,12 @@ newcmd:
 					if (remembered == 1)
 						regfree(&re);
 					rerror = regcomp(&re, p,
-						REG_NOSUB | REG_NEWLINE);
+							 REG_NOSUB |
+							 REG_NEWLINE);
 					if (rerror != 0) {
 						mesg(_("RE error: "));
 						sz = regerror(rerror, &re,
-								b, READBUF);
+							      b, READBUF);
 						mesg(b);
 						goto newcmd;
 					}
@@ -1199,9 +1108,7 @@ newcmd:
 				continue;
 			case '?':
 			case '^':
-				/*
-				 * Search backward.
-				 */
+				/* Search backward. */
 				search = BACKWARD;
 				oldline = line;
 				searchcount = cmd.count;
@@ -1210,11 +1117,12 @@ newcmd:
 					if (remembered == 1)
 						regfree(&re);
 					rerror = regcomp(&re, p,
-						REG_NOSUB | REG_NEWLINE);
+							 REG_NOSUB |
+							 REG_NEWLINE);
 					if (rerror != 0) {
 						mesg(_("RE error: "));
 						regerror(rerror, &re,
-								b, READBUF);
+							 b, READBUF);
 						mesg(b);
 						goto newcmd;
 					}
@@ -1228,8 +1136,9 @@ newcmd:
 					goto notfound_bw;
 				while (line) {
 					fseeko(find, --line * sizeof pos,
-							SEEK_SET);
-					if(fread(&pos, sizeof pos, 1,find)==0)
+					       SEEK_SET);
+					if (fread(&pos, sizeof pos, 1, find) ==
+					    0)
 						tmperr(find, "index");
 					fseeko(find, (off_t)0, SEEK_END);
 					fseeko(fbuf, pos, SEEK_SET);
@@ -1241,12 +1150,12 @@ newcmd:
 					if (searchcount == 0)
 						goto found_bw;
 				}
-notfound_bw:
+ notfound_bw:
 				line = oldline;
 				search = searchcount = 0;
 				mesg(_("Pattern not found"));
 				goto newcmd;
-found_bw:
+ found_bw:
 				eof = search = dline = 0;
 				skip(-1);
 				switch (searchdisplay) {
@@ -1266,11 +1175,9 @@ found_bw:
 					line = 0;
 				continue;
 			case 's':
-				/*
-				 * Save to file.
-				 */
+				/* Save to file. */
 				p = cmd.cmdline;
-				while (*++p == ' ');
+				while (*++p == ' ') ;
 				if (*p == '\0')
 					goto newcmd;
 				save = fopen(p, "wb");
@@ -1282,13 +1189,12 @@ found_bw:
 					mesg(strerror(cmd.count));
 					goto newcmd;
 				}
-				/*
-				 * Advance to EOF.
-				 */
+				/* Advance to EOF. */
 				fseeko(find, (off_t)0, SEEK_END);
 				for (;;) {
 					if (!nobuf)
-						fseeko(fbuf,(off_t)0,SEEK_END);
+						fseeko(fbuf, (off_t)0,
+						       SEEK_END);
 					pos = ftello(fbuf);
 					if (fgets(b, READBUF, f) == NULL) {
 						eofline = fline;
@@ -1301,12 +1207,12 @@ found_bw:
 						oldpos = pos;
 						p = b;
 						while (*(p = endline(ttycols,
-									p))
-								!= '\0') {
+								     p))
+						       != '\0') {
 							pos = oldpos + (p - b);
 							fwrite_all(&pos,
-								sizeof pos,
-								1, find);
+								   sizeof pos,
+								   1, find);
 							fline++;
 							bline++;
 						}
@@ -1316,10 +1222,8 @@ found_bw:
 				}
 				fseeko(fbuf, (off_t)0, SEEK_SET);
 				while ((sz = fread(b, sizeof *b, READBUF,
-							fbuf)) != 0) {
-					/*
-					 * No error check for compat.
-					 */
+						   fbuf)) != 0) {
+					/* No error check for compat. */
 					fwrite_all(b, sizeof *b, sz, save);
 				}
 				fclose(save);
@@ -1327,48 +1231,39 @@ found_bw:
 				mesg(_("saved"));
 				goto newcmd;
 			case 'l':
-				/*
-				 * Next line.
-				 */
+				/* Next line. */
 				if (*cmd.cmdline != 'l')
 					eof = 0;
 				if (cmd.count == 0)
-					cmd.count = 1; /* compat */
+					cmd.count = 1;	/* compat */
 				if (isdigit(cuc(*cmd.cmdline))) {
 					line = cmd.count - 2;
 					dline = 0;
 				} else {
 					if (cmd.count != 1) {
-						line += cmd.count - 1
-							- pagelen;
+						line += cmd.count - 1 - pagelen;
 						dline = -1;
 						skip(cmd.count);
 					}
-					/*
-					 * Nothing to do if count==1.
-					 */
+					/* Nothing to do if (count == 1) */
 				}
 				break;
 			case 'd':
-				/*
-				 * Half screen forward.
-				 */
+				/* Half screen forward. */
 			case '\004':	/* ^D */
 				if (*cmd.cmdline != cmd.key)
 					eof = 0;
 				if (cmd.count == 0)
-					cmd.count = 1; /* compat */
+					cmd.count = 1;	/* compat */
 				line += (cmd.count * pagelen / 2)
-					- pagelen - 1;
+				    - pagelen - 1;
 				dline = -1;
 				skip(cmd.count);
 				break;
 			case 'f':
-				/*
-				 * Skip forward.
-				 */
+				/* Skip forward. */
 				if (cmd.count <= 0)
-					cmd.count = 1; /* compat */
+					cmd.count = 1;	/* compat */
 				line += cmd.count * pagelen - 2;
 				if (eof)
 					line += 2;
@@ -1382,16 +1277,14 @@ found_bw:
 				skip(cmd.count);
 				break;
 			case '\0':
-				/*
-				 * Just a number, or '-', or <newline>.
-				 */
+				/* Just a number, or '-', or <newline>. */
 				if (cmd.count == 0)
-					cmd.count = 1; /* compat */
+					cmd.count = 1;	/* compat */
 				if (isdigit(cuc(*cmd.cmdline)))
 					line = (cmd.count - 1) * pagelen - 2;
 				else
 					line += (cmd.count - 1)
-						* (pagelen - 1) - 2;
+					    * (pagelen - 1) - 2;
 				if (*cmd.cmdline != '\0')
 					eof = 0;
 				if (cmd.count != 1) {
@@ -1403,9 +1296,7 @@ found_bw:
 				}
 				break;
 			case '$':
-				/*
-				 * Advance to EOF.
-				 */
+				/* Advance to EOF. */
 				if (!eof)
 					skip(1);
 				eof = 0;
@@ -1414,10 +1305,8 @@ found_bw:
 				dline = -1;
 				break;
 			case '.':
-			case '\014': /* ^L */
-				/*
-				 * Repaint screen.
-				 */
+			case '\014':	/* ^L */
+				/* Repaint screen. */
 				eof = 0;
 				if (line >= pagelen)
 					line -= pagelen;
@@ -1426,9 +1315,7 @@ found_bw:
 				dline = 0;
 				break;
 			case '!':
-				/*
-				 * Shell escape.
-				 */
+				/* Shell escape. */
 				if (rflag) {
 					mesg(program_invocation_short_name);
 					mesg(_(": !command not allowed in "
@@ -1437,14 +1324,15 @@ found_bw:
 					pid_t cpid;
 
 					write_all(STDOUT_FILENO, cmd.cmdline,
-					      strlen(cmd.cmdline));
+						  strlen(cmd.cmdline));
 					write_all(STDOUT_FILENO, "\n", 1);
 					my_sigset(SIGINT, SIG_IGN);
 					my_sigset(SIGQUIT, SIG_IGN);
 					switch (cpid = fork()) {
 					case 0:
 						p = getenv("SHELL");
-						if (p == NULL) p = xstrdup("/bin/sh");
+						if (p == NULL)
+							p = xstrdup("/bin/sh");
 						if (!nobuf)
 							fclose(fbuf);
 						fclose(find);
@@ -1458,16 +1346,16 @@ found_bw:
 						my_sigset(SIGQUIT, oldquit);
 						my_sigset(SIGTERM, oldterm);
 						execl(p, p, "-c",
-							cmd.cmdline + 1, NULL);
+						      cmd.cmdline + 1, NULL);
 						warn("%s", p);
 						_exit(0177);
-						/*NOTREACHED*/
+						/* NOTREACHED */
 					case -1:
 						mesg(_("fork() failed, "
 						       "try again later\n"));
 						break;
 					default:
-						while (wait(NULL) != cpid);
+						while (wait(NULL) != cpid) ;
 					}
 					my_sigset(SIGINT, sighandler);
 					my_sigset(SIGQUIT, sighandler);
@@ -1475,19 +1363,17 @@ found_bw:
 				}
 				goto newcmd;
 			case 'h':
-			{
-				/*
-				 * Help!
-				 */
-				const char *help = _(helpscreen);
-				write_all(STDOUT_FILENO, copyright, strlen(copyright));
-				write_all(STDOUT_FILENO, help, strlen(help));
-				goto newcmd;
-			}
+				{
+					/* Help! */
+					const char *help = _(helpscreen);
+					write_all(STDOUT_FILENO, copyright,
+						  strlen(copyright));
+					write_all(STDOUT_FILENO, help,
+						  strlen(help));
+					goto newcmd;
+				}
 			case 'n':
-				/*
-				 * Next file.
-				 */
+				/* Next file. */
 				if (cmd.count == 0)
 					cmd.count = 1;
 				nextfile = cmd.count;
@@ -1498,9 +1384,7 @@ found_bw:
 				eof = 1;
 				break;
 			case 'p':
-				/*
-				 * Previous file.
-				 */
+				/* Previous file. */
 				if (cmd.count == 0)
 					cmd.count = 1;
 				nextfile = 0 - cmd.count;
@@ -1512,16 +1396,12 @@ found_bw:
 				break;
 			case 'q':
 			case 'Q':
-				/*
-				 * Exit pg.
-				 */
+				/* Exit pg. */
 				quit(exitstatus);
-				/*NOTREACHED*/
+				/* NOTREACHED */
 			case 'w':
 			case 'z':
-				/*
-				 * Set window size.
-				 */
+				/* Set window size. */
 				if (cmd.count < 0)
 					cmd.count = 0;
 				if (*cmd.cmdline != cmd.key)
@@ -1546,8 +1426,7 @@ found_bw:
 		fclose(fbuf);
 }
 
-static int
-parse_arguments(int arg, int argc, char **argv)
+static int parse_arguments(int arg, int argc, char **argv)
 {
 	FILE *input;
 
@@ -1568,9 +1447,7 @@ parse_arguments(int arg, int argc, char **argv)
 					prompt(-1);
 					switch (cmd.key) {
 					case 'n':
-						/*
-						 * Next file.
-						 */
+						/* Next file. */
 						if (cmd.count == 0)
 							cmd.count = 1;
 						nextfile = cmd.count;
@@ -1581,9 +1458,7 @@ parse_arguments(int arg, int argc, char **argv)
 						}
 						continue;
 					case 'p':
-						/*
-						 * Previous file.
-						 */
+						/* Previous file. */
 						if (cmd.count == 0)
 							cmd.count = 1;
 						nextfile = 0 - cmd.count;
@@ -1612,9 +1487,7 @@ parse_arguments(int arg, int argc, char **argv)
 			}
 		}
 		if (ontty == 0 && argc > 2) {
-			/*
-			 * Use the prefix as specified by SUSv2.
-			 */
+			/* Use the prefix as specified by SUSv2. */
 			write_all(STDOUT_FILENO, "::::::::::::::\n", 15);
 			write_all(STDOUT_FILENO, argv[arg], strlen(argv[arg]));
 			write_all(STDOUT_FILENO, "\n::::::::::::::\n", 16);
@@ -1626,8 +1499,7 @@ parse_arguments(int arg, int argc, char **argv)
 	return exitstatus;
 }
 
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
 {
 	int arg, i;
 	char *p;
@@ -1665,9 +1537,19 @@ main(int argc, char **argv)
 				if (i != 1 || argv[arg][i + 1])
 					invopt(&argv[arg][i]);
 				goto endargs;
-			case '1': case '2': case '3': case '4': case '5':
-			case '6': case '7': case '8': case '9': case '0':
-				pagelen = strtol_or_err(argv[arg] + 1, _("failed to parse argument"));
+			case '1':
+			case '2':
+			case '3':
+			case '4':
+			case '5':
+			case '6':
+			case '7':
+			case '8':
+			case '9':
+			case '0':
+				pagelen =
+				    strtol_or_err(argv[arg] + 1,
+						  _("failed to parse argument"));
 				havepagelen = 1;
 				goto nextarg;
 			case 'c':
@@ -1706,10 +1588,10 @@ main(int argc, char **argv)
 				invopt(&argv[arg][i]);
 			}
 		}
-nextarg:
+ nextarg:
 		;
 	}
-endargs:
+ endargs:
 	for (arg = 1; argv[arg]; arg++) {
 		if (*argv[arg] == '-') {
 			if (argv[arg][1] == '-') {
@@ -1728,17 +1610,28 @@ endargs:
 		switch (*(argv[arg] + 1)) {
 		case '\0':
 			needarg("+");
-			/*NOTREACHED*/
-		case '1': case '2': case '3': case '4': case '5':
-		case '6': case '7': case '8': case '9': case '0':
-			startline = strtol_or_err(argv[arg] + 1, _("failed to parse argument"));
+			/* NOTREACHED */
+		case '1':
+		case '2':
+		case '3':
+		case '4':
+		case '5':
+		case '6':
+		case '7':
+		case '8':
+		case '9':
+		case '0':
+			startline =
+			    strtol_or_err(argv[arg] + 1,
+					  _("failed to parse argument"));
 			break;
 		case '/':
 			searchfor = argv[arg] + 2;
 			if (*searchfor == '\0')
 				needarg("+/");
 			p = searchfor + strlen(searchfor) - 1;
-			if (*p == '/') *p = '\0';
+			if (*p == '/')
+				*p = '\0';
 			if (*searchfor == '\0')
 				needarg("+/");
 			break;
@@ -1752,6 +1645,6 @@ endargs:
 		exitstatus = parse_arguments(arg, argc, argv);
 
 	quit(exitstatus);
-	/*NOTREACHED*/
+	/* NOTREACHED */
 	return 0;
 }
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 11/14] more: fix coding style
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
                   ` (9 preceding siblings ...)
  2012-10-08  7:08 ` [PATCH 10/14] pg: fix coding style Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 12/14] more: align void in functions with prototypes, and remove void casts Sami Kerola
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 93640 bytes --]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/more.c | 3408 ++++++++++++++++++++++++++---------------------------
 1 file changed, 1694 insertions(+), 1714 deletions(-)

diff --git a/text-utils/more.c b/text-utils/more.c
index 58c99cc..d056393 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -15,30 +15,33 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-/*
-** more.c - General purpose tty output filter and file perusal program
-**
-**	by Eric Shienbrood, UC Berkeley
-**
-**	modified by Geoff Peck, UCB to add underlining, single spacing
-**	modified by John Foderaro, UCB to add -c and MORE environment variable
-**	modified by Erik Troan <ewt@redhat.com> to be more posix and so compile
-**	  on linux/axp.
-**	modified by Kars de Jong <jongk@cs.utwente.nl> to use terminfo instead
-**	  of termcap.
-	1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
-	- added Native Language Support
-	1999-03-19 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
-	- more nls translatable strings
-	1999-05-09 aeb - applied a RedHat patch (setjmp->sigsetjmp); without it
-	a second ^Z would fail.
-	1999-05-09 aeb - undone Kars' work, so that more works without
-	libcurses (and hence can be in /bin with libcurses being in /usr/lib
-	which may not be mounted). However, when termcap is not present curses
-	can still be used.
-	2010-10-21 Davidlohr Bueso <dave@gnu.org>
-	- modified mem allocation handling for util-linux
-*/
+/* more.c - General purpose tty output filter and file perusal program
+ *
+ * by Eric Shienbrood, UC Berkeley
+ *
+ * modified by Geoff Peck
+ *	UCB to add underlining, single spacing
+ * modified by John Foderaro
+ *	UCB to add -c and MORE environment variable
+ * modified by Erik Troan <ewt@redhat.com>
+ *	to be more posix and so compile on linux/axp.
+ * modified by Kars de Jong <jongk@cs.utwente.nl>
+ *	to use terminfo instead of termcap.
+ * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
+ *	added Native Language Support
+ * 1999-03-19 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ *	more nls translatable strings
+ * 1999-05-09 aeb
+ *	applied a RedHat patch (setjmp->sigsetjmp); without it a second
+ *	^Z would fail.
+ * 1999-05-09 aeb
+ *	undone Kars' work, so that more works without libcurses (and
+ *	hence can be in /bin with libcurses being in
+ *	/usr/lib which may not be mounted).  However, when termcap is not
+ *	present curses can still be used.
+ * 2010-10-21 Davidlohr Bueso <dave@gnu.org>
+ *	modified mem allocation handling for util-linux
+ */
 
 #include <stdio.h>
 #include <string.h>
@@ -66,10 +69,10 @@
 #include <regex.h>
 
 #ifndef XTABS
-#define XTABS TAB3
-#endif /* XTABS */
+# define XTABS	TAB3
+#endif
 
-#define VI		"vi"	/* found on the user's path */
+#define VI	"vi"	/* found on the user's path */
 
 #define Fopen(s,m)	(Currline = 0,file_pos=0,fopen(s,m))
 #define Ftell(f)	file_pos
@@ -89,37 +92,37 @@ void doclear(void);
 void cleareol(void);
 void clreos(void);
 void home(void);
-void more_error (char *mess);
-void do_shell (char *filename);
-int  colon (char *filename, int cmd, int nlines);
-int  expand (char **outbuf, char *inbuf);
+void more_error(char *mess);
+void do_shell(char *filename);
+int colon(char *filename, int cmd, int nlines);
+int expand(char **outbuf, char *inbuf);
 void argscan(char *s);
-void rdline (register FILE *f);
+void rdline(register FILE *f);
 void copy_file(register FILE *f);
 void search(char buf[], FILE *file, register int n);
-void skipf (register int nskip);
+void skipf(register int nskip);
 void skiplns(register int n, register FILE *f);
-void screen (register FILE *f, register int num_lines);
-int  command (char *filename, register FILE *f);
-void erasep (register int col);
-void show (register char ch);
+void screen(register FILE *f, register int num_lines);
+int command(char *filename, register FILE *f);
+void erasep(register int col);
+void show(register char ch);
 void set_tty(void);
 void reset_tty(void);
-void ttyin (char buf[], register int nmax, char pchar);
-int  number(char *cmd);
-int  readch (void);
-int  get_line(register FILE *f, int *length);
-void prbuf (register char *s, register int n);
-void execute (char *filename, char *cmd, ...);
-FILE *checkf (char *, int *);
+void ttyin(char buf[], register int nmax, char pchar);
+int number(char *cmd);
+int readch(void);
+int get_line(register FILE *f, int *length);
+void prbuf(register char *s, register int n);
+void execute(char *filename, char *cmd, ...);
+FILE *checkf(char *, int *);
 void prepare_line_buffer(void);
 
-#define TBUFSIZ	1024
-#define LINSIZ	256	/* minimal Line buffer size */
+#define TBUFSIZ		1024
+#define LINSIZ		256	/* minimal Line buffer size */
 #define ctrl(letter)	(letter & 077)
-#define RUBOUT	'\177'
-#define ESC	'\033'
-#define QUIT	'\034'
+#define RUBOUT		'\177'
+#define ESC		'\033'
+#define QUIT		'\034'
 #define SCROLL_LEN	11
 #define LINES_PER_PAGE	24
 #define NUM_COLUMNS	80
@@ -129,419 +132,440 @@ void prepare_line_buffer(void);
 #define COMMAND_BUF	200
 #define REGERR_BUF	NUM_COLUMNS
 
-struct termios	otty, savetty0;
-long		file_pos, file_size;
-int		fnum, no_intty, no_tty, slow_tty;
-int		dum_opt, dlines;
-void		onquit(int), onsusp(int), chgwinsz(int), end_it(int);
-int		nscroll = SCROLL_LEN;	/* Number of lines scrolled by 'd' */
-int		fold_opt = 1;		/* Fold long lines */
-int		stop_opt = 1;		/* Stop after form feeds */
-int		ssp_opt = 0;		/* Suppress white space */
-int		ul_opt = 1;		/* Underline as best we can */
-int		promptlen;
-int		Currline;		/* Line we are currently at */
-int		startup = 1;
-int		firstf = 1;
-int		notell = 1;
-int		docrterase = 0;
-int		docrtkill = 0;
-int		bad_so;			/* True if overwriting does not turn
-					   off standout */
-int		inwait, Pause, errors;
-int		within;			/* true if we are within a file,
-					   false if we are between files */
-int		hard, dumb, noscroll, hardtabs, clreol, eatnl;
-int		catch_susp;		/* We should catch the SIGTSTP signal */
-char		**fnames;		/* The list of file names */
-int		nfiles;			/* Number of files left to process */
-char		*shell;			/* The name of the shell to use */
-int		shellp;			/* A previous shell command exists */
-sigjmp_buf	restore;
-char		*Line;			/* Line buffer */
-size_t		LineLen;		/* size of Line buffer */
-int		Lpp = LINES_PER_PAGE;	/* lines per page */
-char		*Clear;			/* clear screen */
-char		*eraseln;		/* erase line */
-char		*Senter, *Sexit;	/* enter and exit standout mode */
-char		*ULenter, *ULexit;	/* enter and exit underline mode */
-char		*chUL;			/* underline character */
-char		*chBS;			/* backspace character */
-char		*Home;			/* go to home */
-char		*cursorm;		/* cursor movement */
-char		cursorhome[40];		/* contains cursor movement to home */
-char		*EodClr;		/* clear rest of screen */
-int		Mcol = NUM_COLUMNS;	/* number of columns */
-int		Wrap = 1;		/* set if automargins */
-int		soglitch;		/* terminal has standout mode glitch */
-int		ulglitch;		/* terminal has underline mode glitch */
-int		pstate = 0;		/* current UL state */
-static int	magic(FILE *, char *);
-char		*previousre;		/* previous search() buf[] item */
+struct termios otty, savetty0;
+long file_pos, file_size;
+int fnum, no_intty, no_tty, slow_tty;
+int dum_opt, dlines;
+void onquit(int), onsusp(int), chgwinsz(int), end_it(int);
+int nscroll = SCROLL_LEN;	/* Number of lines scrolled by 'd' */
+int fold_opt = 1;		/* Fold long lines */
+int stop_opt = 1;		/* Stop after form feeds */
+int ssp_opt = 0;		/* Suppress white space */
+int ul_opt = 1;			/* Underline as best we can */
+int promptlen;
+int Currline;			/* Line we are currently at */
+int startup = 1;
+int firstf = 1;
+int notell = 1;
+int docrterase = 0;
+int docrtkill = 0;
+int bad_so;			/* True if overwriting does not turn
+				   off standout */
+int inwait, Pause, errors;
+int within;			/* true if we are within a file,
+				   false if we are between files */
+int hard, dumb, noscroll, hardtabs, clreol, eatnl;
+int catch_susp;			/* We should catch the SIGTSTP signal */
+char **fnames;			/* The list of file names */
+int nfiles;			/* Number of files left to process */
+char *shell;			/* The name of the shell to use */
+int shellp;			/* A previous shell command exists */
+sigjmp_buf restore;
+char *Line;			/* Line buffer */
+size_t LineLen;			/* size of Line buffer */
+int Lpp = LINES_PER_PAGE;	/* lines per page */
+char *Clear;			/* clear screen */
+char *eraseln;			/* erase line */
+char *Senter, *Sexit;		/* enter and exit standout mode */
+char *ULenter, *ULexit;		/* enter and exit underline mode */
+char *chUL;			/* underline character */
+char *chBS;			/* backspace character */
+char *Home;			/* go to home */
+char *cursorm;			/* cursor movement */
+char cursorhome[40];		/* contains cursor movement to home */
+char *EodClr;			/* clear rest of screen */
+int Mcol = NUM_COLUMNS;		/* number of columns */
+int Wrap = 1;			/* set if automargins */
+int soglitch;			/* terminal has standout mode glitch */
+int ulglitch;			/* terminal has underline mode glitch */
+int pstate = 0;			/* current UL state */
+static int magic(FILE *, char *);
+char *previousre;		/* previous search() buf[] item */
 struct {
-    long chrctr, line;
+	long chrctr, line;
 } context, screen_start;
-extern char	PC;		/* pad character */
+extern char PC;			/* pad character */
 
 #ifdef HAVE_NCURSES_H
 # include <ncurses.h>
 #elif defined(HAVE_NCURSES_NCURSES_H)
 # include <ncurses/ncurses.h>
-#endif /* HAVE_NCURSES_H */
+#endif
 
 #if defined(HAVE_NCURSES_H) || defined(HAVE_NCURSES_NCURSES_H)
-# include <term.h>			/* include after <curses.h> */
-
-#define TERM_AUTO_RIGHT_MARGIN    "am"
-#define TERM_CEOL                 "xhp"
-#define TERM_CLEAR                "clear"
-#define TERM_CLEAR_TO_LINE_END    "el"
-#define TERM_CLEAR_TO_SCREEN_END  "ed"
-#define TERM_COLS                 "cols"
-#define TERM_CURSOR_ADDRESS       "cup"
-#define TERM_EAT_NEW_LINE         "xenl"
-#define TERM_ENTER_UNDERLINE      "smul"
-#define TERM_EXIT_STANDARD_MODE   "rmso"
-#define TERM_EXIT_UNDERLINE       "rmul"
-#define TERM_HARD_COPY            "hc"
-#define TERM_HOME                 "home"
-#define TERM_LINE_DOWN            "cud1"
-#define TERM_LINES                "lines"
-#define TERM_OVER_STRIKE          "os"
-#define TERM_PAD_CHAR             "pad"
-#define TERM_STANDARD_MODE        "smso"
-#define TERM_STD_MODE_GLITCH      "xmc"
-#define TERM_UNDERLINE_CHAR       "uc"
-#define TERM_UNDERLINE            "ul"
-
-static void my_putstring(char *s) {
-	tputs (s, fileno(stdout), putchar);		/* putp(s); */
+# include <term.h>		/* include after <curses.h> */
+
+# define TERM_AUTO_RIGHT_MARGIN    "am"
+# define TERM_CEOL                 "xhp"
+# define TERM_CLEAR                "clear"
+# define TERM_CLEAR_TO_LINE_END    "el"
+# define TERM_CLEAR_TO_SCREEN_END  "ed"
+# define TERM_COLS                 "cols"
+# define TERM_CURSOR_ADDRESS       "cup"
+# define TERM_EAT_NEW_LINE         "xenl"
+# define TERM_ENTER_UNDERLINE      "smul"
+# define TERM_EXIT_STANDARD_MODE   "rmso"
+# define TERM_EXIT_UNDERLINE       "rmul"
+# define TERM_HARD_COPY            "hc"
+# define TERM_HOME                 "home"
+# define TERM_LINE_DOWN            "cud1"
+# define TERM_LINES                "lines"
+# define TERM_OVER_STRIKE          "os"
+# define TERM_PAD_CHAR             "pad"
+# define TERM_STANDARD_MODE        "smso"
+# define TERM_STD_MODE_GLITCH      "xmc"
+# define TERM_UNDERLINE_CHAR       "uc"
+# define TERM_UNDERLINE            "ul"
+
+static void my_putstring(char *s)
+{
+	tputs(s, fileno(stdout), putchar);	/* putp(s); */
 }
 
-static void my_setupterm(char *term, int fildes, int *errret) {
-     setupterm(term, fildes, errret);
+static void my_setupterm(char *term, int fildes, int *errret)
+{
+	setupterm(term, fildes, errret);
 }
 
-static int my_tgetnum(char *s) {
-     return tigetnum(s);
+static int my_tgetnum(char *s)
+{
+	return tigetnum(s);
 }
 
-static int my_tgetflag(char *s) {
-     return tigetflag(s);
+static int my_tgetflag(char *s)
+{
+	return tigetflag(s);
 }
 
-static char *my_tgetstr(char *s) {
-     return tigetstr(s);
+static char *my_tgetstr(char *s)
+{
+	return tigetstr(s);
 }
 
-static char *my_tgoto(char *cap, int col, int row) {
-     return tparm(cap, col, row);
+static char *my_tgoto(char *cap, int col, int row)
+{
+	return tparm(cap, col, row);
 }
 
-#elif defined(HAVE_LIBTERMCAP)          /* !ncurses */
-
-#include <termcap.h>
-
-#define TERM_AUTO_RIGHT_MARGIN    "am"
-#define TERM_CEOL                 "xs"
-#define TERM_CLEAR                "cl"
-#define TERM_CLEAR_TO_LINE_END    "ce"
-#define TERM_CLEAR_TO_SCREEN_END  "cd"
-#define TERM_COLS                 "co"
-#define TERM_CURSOR_ADDRESS       "cm"
-#define TERM_EAT_NEW_LINE         "xn"
-#define TERM_ENTER_UNDERLINE      "us"
-#define TERM_EXIT_STANDARD_MODE   "se"
-#define TERM_EXIT_UNDERLINE       "ue"
-#define TERM_HARD_COPY            "hc"
-#define TERM_HOME                 "ho"
-#define TERM_LINE_DOWN            "le"
-#define TERM_LINES                "li"
-#define TERM_OVER_STRIKE          "os"
-#define TERM_PAD_CHAR             "pc"
-#define TERM_STANDARD_MODE        "so"
-#define TERM_STD_MODE_GLITCH      "sg"
-#define TERM_UNDERLINE_CHAR       "uc"
-#define TERM_UNDERLINE            "ul"
+#elif defined(HAVE_LIBTERMCAP)	/* ncurses not found */
+
+# include <termcap.h>
+
+# define TERM_AUTO_RIGHT_MARGIN    "am"
+# define TERM_CEOL                 "xs"
+# define TERM_CLEAR                "cl"
+# define TERM_CLEAR_TO_LINE_END    "ce"
+# define TERM_CLEAR_TO_SCREEN_END  "cd"
+# define TERM_COLS                 "co"
+# define TERM_CURSOR_ADDRESS       "cm"
+# define TERM_EAT_NEW_LINE         "xn"
+# define TERM_ENTER_UNDERLINE      "us"
+# define TERM_EXIT_STANDARD_MODE   "se"
+# define TERM_EXIT_UNDERLINE       "ue"
+# define TERM_HARD_COPY            "hc"
+# define TERM_HOME                 "ho"
+# define TERM_LINE_DOWN            "le"
+# define TERM_LINES                "li"
+# define TERM_OVER_STRIKE          "os"
+# define TERM_PAD_CHAR             "pc"
+# define TERM_STANDARD_MODE        "so"
+# define TERM_STD_MODE_GLITCH      "sg"
+# define TERM_UNDERLINE_CHAR       "uc"
+# define TERM_UNDERLINE            "ul"
 
 char termbuffer[TERMINAL_BUF];
 char tcbuffer[TERMINAL_BUF];
 char *strbuf = termbuffer;
 
-static void my_putstring(char *s) {
-     tputs (s, fileno(stdout), putchar);
+static void my_putstring(char *s)
+{
+	tputs(s, fileno(stdout), putchar);
 }
 
-static void my_setupterm(char *term, int fildes, int *errret) {
-     *errret = tgetent(tcbuffer, term);
+static void my_setupterm(char *term, int fildes, int *errret)
+{
+	*errret = tgetent(tcbuffer, term);
 }
 
-static int my_tgetnum(char *s) {
-     return tgetnum(s);
+static int my_tgetnum(char *s)
+{
+	return tgetnum(s);
 }
 
-static int my_tgetflag(char *s) {
-     return tgetflag(s);
+static int my_tgetflag(char *s)
+{
+	return tgetflag(s);
 }
 
-static char *my_tgetstr(char *s) {
-     return tgetstr(s, &strbuf);
+static char *my_tgetstr(char *s)
+{
+	return tgetstr(s, &strbuf);
 }
 
-static char *my_tgoto(char *cap, int col, int row) {
-     return tgoto(cap, col, row);
+static char *my_tgoto(char *cap, int col, int row)
+{
+	return tgoto(cap, col, row);
 }
 
-#endif /* HAVE_LIBTERMCAP */
+#endif	/* HAVE_LIBTERMCAP */
 
-static void __attribute__ ((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(FILE *out)
 {
-     fprintf(out,
-            _("Usage: %s [options] file...\n\n"),
-	       program_invocation_short_name);
-     fprintf(out,
-	    _("Options:\n"
-	      "  -d        display help instead of ring bell\n"
-              "  -f        count logical, rather than screen lines\n"
-              "  -l        suppress pause after form feed\n"
-              "  -p        suppress scroll, clean screen and display text\n"
-              "  -c        suppress scroll, display text and clean line ends\n"
-              "  -u        suppress underlining\n"
-              "  -s        squeeze multiple blank lines into one\n"
-              "  -NUM      specify the number of lines per screenful\n"
-              "  +NUM      display file beginning from line number NUM\n"
-              "  +/STRING  display file beginning from search string match\n"
-              "  -V        output version information and exit\n"));
-       exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+	fprintf(out,
+		_("Usage: %s [options] file...\n\n"),
+		program_invocation_short_name);
+	fprintf(out,
+		_("Options:\n"
+		  "  -d        display help instead of ring bell\n"
+		  "  -f        count logical, rather than screen lines\n"
+		  "  -l        suppress pause after form feed\n"
+		  "  -p        suppress scroll, clean screen and display text\n"
+		  "  -c        suppress scroll, display text and clean line ends\n"
+		  "  -u        suppress underlining\n"
+		  "  -s        squeeze multiple blank lines into one\n"
+		  "  -NUM      specify the number of lines per screenful\n"
+		  "  +NUM      display file beginning from line number NUM\n"
+		  "  +/STRING  display file beginning from search string match\n"
+		  "  -V        output version information and exit\n"));
+	exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
 }
 
-int main(int argc, char **argv) {
-    FILE	*f;
-    char	*s;
-    int		ch;
-    int		left;
-    int		prnames = 0;
-    int		initopt = 0;
-    int		srchopt = 0;
-    int		clearit = 0;
-    int		initline = 0;
-    char	*initbuf = NULL;
-
-    setlocale(LC_ALL, "");
-    bindtextdomain(PACKAGE, LOCALEDIR);
-    textdomain(PACKAGE);
-    atexit(close_stdout);
-
-    nfiles = argc;
-    fnames = argv;
-    setlocale(LC_ALL, "");
-    initterm ();
-
-    /* Auto set no scroll on when binary is called page */
-    if (!(strcmp(program_invocation_short_name, "page")))
-       noscroll++;
-
-    prepare_line_buffer();
-
-    nscroll = Lpp/2 - 1;
-    if (nscroll <= 0)
-	nscroll = 1;
-
-    if ((s = getenv("MORE")) != NULL)
-	    argscan(s);
-
-    while (--nfiles > 0) {
-	if ((ch = (*++fnames)[0]) == '-') {
-	    argscan(*fnames+1);
+int main(int argc, char **argv)
+{
+	FILE *f;
+	char *s;
+	int ch;
+	int left;
+	int prnames = 0;
+	int initopt = 0;
+	int srchopt = 0;
+	int clearit = 0;
+	int initline = 0;
+	char *initbuf = NULL;
+
+	setlocale(LC_ALL, "");
+	bindtextdomain(PACKAGE, LOCALEDIR);
+	textdomain(PACKAGE);
+	atexit(close_stdout);
+
+	nfiles = argc;
+	fnames = argv;
+	setlocale(LC_ALL, "");
+	initterm();
+
+	/* Auto set no scroll on when binary is called page */
+	if (!(strcmp(program_invocation_short_name, "page")))
+		noscroll++;
+
+	prepare_line_buffer();
+
+	nscroll = Lpp / 2 - 1;
+	if (nscroll <= 0)
+		nscroll = 1;
+
+	if ((s = getenv("MORE")) != NULL)
+		argscan(s);
+
+	while (--nfiles > 0) {
+		if ((ch = (*++fnames)[0]) == '-') {
+			argscan(*fnames + 1);
+		} else if (ch == '+') {
+			s = *fnames;
+			if (*++s == '/') {
+				srchopt++;
+				initbuf = xstrdup(s + 1);
+			} else {
+				initopt++;
+				for (initline = 0; *s != '\0'; s++)
+					if (isdigit(*s))
+						initline =
+						    initline * 10 + *s - '0';
+				--initline;
+			}
+		} else
+			break;
 	}
-	else if (ch == '+') {
-	    s = *fnames;
-	    if (*++s == '/') {
-		srchopt++;
-		initbuf = xstrdup(s + 1);
-	    }
-	    else {
-		initopt++;
-		for (initline = 0; *s != '\0'; s++)
-		    if (isdigit (*s))
-			initline = initline*10 + *s -'0';
-		--initline;
-	    }
+	/* allow clreol only if Home and eraseln and EodClr strings are
+	 * defined, and in that case, make sure we are in noscroll mode */
+	if (clreol) {
+		if ((Home == NULL) || (*Home == '\0') ||
+		    (eraseln == NULL) || (*eraseln == '\0') ||
+		    (EodClr == NULL) || (*EodClr == '\0'))
+			clreol = 0;
+		else
+			noscroll = 1;
 	}
-	else break;
-    }
-    /* allow clreol only if Home and eraseln and EodClr strings are
-     *  defined, and in that case, make sure we are in noscroll mode
-     */
-    if (clreol) {
-        if((Home == NULL) || (*Home == '\0') ||
-	   (eraseln == NULL) || (*eraseln == '\0') ||
-           (EodClr == NULL) || (*EodClr == '\0') )
-	      clreol = 0;
-	else noscroll = 1;
-    }
-    if (dlines == 0)
-	    dlines = Lpp - 1;	/* was: Lpp - (noscroll ? 1 : 2) */
-    left = dlines;
-    if (nfiles > 1)
-	prnames++;
-    if (!no_intty && nfiles == 0)
-	usage(stderr);
-    else
-	f = stdin;
-    if (!no_tty) {
-	signal(SIGQUIT, onquit);
-	signal(SIGINT, end_it);
+	if (dlines == 0)
+		dlines = Lpp - 1;	/* was: Lpp - (noscroll ? 1 : 2) */
+	left = dlines;
+	if (nfiles > 1)
+		prnames++;
+	if (!no_intty && nfiles == 0)
+		usage(stderr);
+	else
+		f = stdin;
+	if (!no_tty) {
+		signal(SIGQUIT, onquit);
+		signal(SIGINT, end_it);
 #ifdef SIGWINCH
-	signal(SIGWINCH, chgwinsz);
-#endif /* SIGWINCH */
-	if (signal (SIGTSTP, SIG_IGN) == SIG_DFL) {
-	    signal(SIGTSTP, onsusp);
-	    catch_susp++;
-	}
-	stty (fileno(stderr), &otty);
-    }
-    if (no_intty) {
-	if (no_tty)
-	    copy_file (stdin);
-	else {
-	    if ((ch = Getc (f)) == '\f')
-		doclear();
-	    else {
-		Ungetc (ch, f);
-		if (noscroll && (ch != EOF)) {
-		    if (clreol)
-			home ();
-		    else
-			doclear ();
+		signal(SIGWINCH, chgwinsz);
+#endif
+		if (signal(SIGTSTP, SIG_IGN) == SIG_DFL) {
+			signal(SIGTSTP, onsusp);
+			catch_susp++;
 		}
-	    }
-	    if (srchopt)
-	    {
-		previousre = xstrdup(initbuf);
-		search (initbuf, stdin, 1);
-		if (noscroll)
-		    left--;
-	    }
-	    else if (initopt)
-		skiplns (initline, stdin);
-	    screen (stdin, left);
+		stty(fileno(stderr), &otty);
 	}
-	no_intty = 0;
-	prnames++;
-	firstf = 0;
-    }
-
-    while (fnum < nfiles) {
-	if ((f = checkf (fnames[fnum], &clearit)) != NULL) {
-	    context.line = context.chrctr = 0;
-	    Currline = 0;
-	    if (firstf) sigsetjmp (restore, 1);
-	    if (firstf) {
-		firstf = 0;
-		if (srchopt) {
-		    previousre = xstrdup(initbuf);
-		    search (initbuf, f, 1);
-		    if (noscroll)
-			left--;
-		}
-		else if (initopt)
-		    skiplns (initline, f);
-	    }
-	    else if (fnum < nfiles && !no_tty) {
-		sigsetjmp (restore, 1);
-		left = command (fnames[fnum], f);
-	    }
-	    if (left != 0) {
-		if ((noscroll || clearit) && (file_size != LONG_MAX)) {
-		    if (clreol)
-			home ();
-		    else
-			doclear ();
-		}
-		if (prnames) {
-		    if (bad_so)
-			erasep (0);
-		    if (clreol)
-			cleareol ();
-		    putsout("::::::::::::::");
-		    if (promptlen > 14)
-			erasep (14);
-		    putchar('\n');
-		    if(clreol) cleareol();
-		    puts(fnames[fnum]);
-		    if(clreol) cleareol();
-		    puts("::::::::::::::");
-		    if (left > Lpp - 4)
-			left = Lpp - 4;
-		}
+	if (no_intty) {
 		if (no_tty)
-		    copy_file (f);
+			copy_file(stdin);
 		else {
-		    within++;
-		    screen(f, left);
-		    within = 0;
+			if ((ch = Getc(f)) == '\f')
+				doclear();
+			else {
+				Ungetc(ch, f);
+				if (noscroll && (ch != EOF)) {
+					if (clreol)
+						home();
+					else
+						doclear();
+				}
+			}
+			if (srchopt) {
+				previousre = xstrdup(initbuf);
+				search(initbuf, stdin, 1);
+				if (noscroll)
+					left--;
+			} else if (initopt)
+				skiplns(initline, stdin);
+			screen(stdin, left);
+		}
+		no_intty = 0;
+		prnames++;
+		firstf = 0;
+	}
+
+	while (fnum < nfiles) {
+		if ((f = checkf(fnames[fnum], &clearit)) != NULL) {
+			context.line = context.chrctr = 0;
+			Currline = 0;
+			if (firstf)
+				sigsetjmp(restore, 1);
+			if (firstf) {
+				firstf = 0;
+				if (srchopt) {
+					previousre = xstrdup(initbuf);
+					search(initbuf, f, 1);
+					if (noscroll)
+						left--;
+				} else if (initopt)
+					skiplns(initline, f);
+			} else if (fnum < nfiles && !no_tty) {
+				sigsetjmp(restore, 1);
+				left = command(fnames[fnum], f);
+			}
+			if (left != 0) {
+				if ((noscroll || clearit)
+				    && (file_size != LONG_MAX)) {
+					if (clreol)
+						home();
+					else
+						doclear();
+				}
+				if (prnames) {
+					if (bad_so)
+						erasep(0);
+					if (clreol)
+						cleareol();
+					putsout("::::::::::::::");
+					if (promptlen > 14)
+						erasep(14);
+					putchar('\n');
+					if (clreol)
+						cleareol();
+					puts(fnames[fnum]);
+					if (clreol)
+						cleareol();
+					puts("::::::::::::::");
+					if (left > Lpp - 4)
+						left = Lpp - 4;
+				}
+				if (no_tty)
+					copy_file(f);
+				else {
+					within++;
+					screen(f, left);
+					within = 0;
+				}
+			}
+			sigsetjmp(restore, 1);
+			fflush(stdout);
+			fclose(f);
+			screen_start.line = screen_start.chrctr = 0L;
+			context.line = context.chrctr = 0L;
 		}
-	    }
-	    sigsetjmp (restore, 1);
-	    fflush(stdout);
-	    fclose(f);
-	    screen_start.line = screen_start.chrctr = 0L;
-	    context.line = context.chrctr = 0L;
+		fnum++;
+		firstf = 0;
 	}
-	fnum++;
-	firstf = 0;
-    }
-    free (previousre);
-    free (initbuf);
-    reset_tty ();
-    exit(EXIT_SUCCESS);
+	free(previousre);
+	free(initbuf);
+	reset_tty();
+	exit(EXIT_SUCCESS);
 }
 
-void argscan(char *s) {
+void argscan(char *s)
+{
 	int seen_num = 0;
 
 	while (*s != '\0') {
 		switch (*s) {
-		  case '0': case '1': case '2':
-		  case '3': case '4': case '5':
-		  case '6': case '7': case '8':
-		  case '9':
+		case '0':
+		case '1':
+		case '2':
+		case '3':
+		case '4':
+		case '5':
+		case '6':
+		case '7':
+		case '8':
+		case '9':
 			if (!seen_num) {
 				dlines = 0;
 				seen_num = 1;
 			}
-			dlines = dlines*10 + *s - '0';
+			dlines = dlines * 10 + *s - '0';
 			break;
-		  case 'd':
+		case 'd':
 			dum_opt = 1;
 			break;
-		  case 'l':
+		case 'l':
 			stop_opt = 0;
 			break;
-		  case 'f':
+		case 'f':
 			fold_opt = 0;
 			break;
-		  case 'p':
+		case 'p':
 			noscroll++;
 			break;
-		  case 'c':
+		case 'c':
 			clreol++;
 			break;
-		  case 's':
+		case 's':
 			ssp_opt = 1;
 			break;
-		  case 'u':
+		case 'u':
 			ul_opt = 0;
 			break;
-		  case '-': case ' ': case '\t':
+		case '-':
+		case ' ':
+		case '\t':
+			break;
+		case 'V':
+			printf(_("more (%s)\n"), PACKAGE_STRING);
+			exit(EXIT_SUCCESS);
 			break;
-                  case 'V':
-                        printf(_("more (%s)\n"), PACKAGE_STRING);
-                        exit(EXIT_SUCCESS);
-                        break;
-		  default:
-		        warnx(_("unknown option -%s"), s);
+		default:
+			warnx(_("unknown option -%s"), s);
 			usage(stderr);
 			break;
 		}
@@ -549,57 +573,46 @@ void argscan(char *s) {
 	}
 }
 
-
-/*
-** Check whether the file named by fs is an ASCII file which the user may
-** access.  If it is, return the opened file. Otherwise return NULL.
-*/
-
-FILE *
-checkf (fs, clearfirst)
-	register char *fs;
-	int *clearfirst;
+/* Check whether the file named by fs is an ASCII file which the user may
+ * access.  If it is, return the opened file.  Otherwise return NULL. */
+FILE *checkf(register char *fs, int *clearfirst)
 {
 	struct stat stbuf;
 	register FILE *f;
 	int c;
 
-	if (stat (fs, &stbuf) == -1) {
+	if (stat(fs, &stbuf) == -1) {
 		(void)fflush(stdout);
 		if (clreol)
-			cleareol ();
+			cleareol();
 		perror(fs);
-		return((FILE *)NULL);
+		return ((FILE *)NULL);
 	}
 	if ((stbuf.st_mode & S_IFMT) == S_IFDIR) {
 		printf(_("\n*** %s: directory ***\n\n"), fs);
-		return((FILE *)NULL);
+		return ((FILE *)NULL);
 	}
 	if ((f = Fopen(fs, "r")) == NULL) {
 		(void)fflush(stdout);
 		perror(fs);
-		return((FILE *)NULL);
+		return ((FILE *)NULL);
 	}
 	if (magic(f, fs))
-		return((FILE *)NULL);
-	fcntl(fileno(f), F_SETFD, FD_CLOEXEC );
+		return ((FILE *)NULL);
+	fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
 	c = Getc(f);
 	*clearfirst = (c == '\f');
-	Ungetc (c, f);
+	Ungetc(c, f);
 	if ((file_size = stbuf.st_size) == 0)
 		file_size = LONG_MAX;
-	return(f);
+	return (f);
 }
 
-/*
- * magic --
- *	check for file magic numbers.  This code would best be shared with
- *	the file(1) program or, perhaps, more should not try to be so smart.
- */
-static int
-magic(f, fs)
-	FILE *f;
-	char *fs;
+/* magic --
+ *	check for file magic numbers.  This code would best be shared
+ *	with the file(1) program or, perhaps, more should not try to be
+ *	so smart. */
+static int magic(FILE *f, char *fs)
 {
 	signed char twobytes[2];
 
@@ -608,930 +621,900 @@ magic(f, fs)
 		return 0;
 
 	if (fread(twobytes, 2, 1, f) == 1) {
-		switch(twobytes[0] + (twobytes[1]<<8)) {
+		switch (twobytes[0] + (twobytes[1] << 8)) {
 		case 0407:	/* a.out obj */
 		case 0410:	/* a.out exec */
 		case 0413:	/* a.out demand exec */
 		case 0405:
 		case 0411:
 		case 0177545:
-		case 0x457f:		/* simple ELF detection */
-			printf(_("\n******** %s: Not a text file ********\n\n"), fs);
+		case 0x457f:	/* simple ELF detection */
+			printf(_("\n******** %s: Not a text file ********\n\n"),
+			       fs);
 			(void)fclose(f);
 			return 1;
 		}
 	}
-	(void)fseek(f, 0L, SEEK_SET);		/* rewind() not necessary */
+	(void)fseek(f, 0L, SEEK_SET);	/* rewind() not necessary */
 	return 0;
 }
 
-/*
-** Print out the contents of the file f, one screenful at a time.
-*/
-
+/* Print out the contents of the file f, one screenful at a time. */
 #define STOP -10
-
-void screen (register FILE *f, register int num_lines)
+void screen(register FILE *f, register int num_lines)
 {
-    register int c;
-    register int nchars;
-    int length;			/* length of current line */
-    static int prev_len = 1;	/* length of previous line */
-
-    for (;;) {
-	while (num_lines > 0 && !Pause) {
-	    if ((nchars = get_line (f, &length)) == EOF)
-	    {
-		if (clreol)
-		    clreos();
-		return;
-	    }
-	    if (ssp_opt && length == 0 && prev_len == 0)
-		continue;
-	    prev_len = length;
-	    if (bad_so || ((Senter && *Senter == ' ') && (promptlen > 0)))
-		erasep (0);
-	    /* must clear before drawing line since tabs on some terminals
-	     * do not erase what they tab over.
-	     */
-	    if (clreol)
-		cleareol ();
-	    prbuf (Line, length);
-	    if (nchars < promptlen)
-		erasep (nchars);	/* erasep () sets promptlen to 0 */
-	    else promptlen = 0;
-	    /* is this needed?
-	     * if (clreol)
-	     *	cleareol();	* must clear again in case we wrapped *
-	     */
-	    if (nchars < Mcol || !fold_opt)
-		prbuf("\n", 1);	/* will turn off UL if necessary */
-	    if (nchars == STOP)
-		break;
-	    num_lines--;
-	}
-	if (pstate) {
-		my_putstring (ULexit);
-		pstate = 0;
-	}
-	fflush(stdout);
-	if ((c = Getc(f)) == EOF)
-	{
-	    if (clreol)
-		clreos ();
-	    return;
-	}
+	register int c;
+	register int nchars;
+	int length;			/* length of current line */
+	static int prev_len = 1;	/* length of previous line */
 
-	if (Pause && clreol)
-	    clreos ();
-	Ungetc (c, f);
-	sigsetjmp (restore, 1);
-	Pause = 0; startup = 0;
-	if ((num_lines = command (NULL, f)) == 0)
-	    return;
-	if (hard && promptlen > 0)
-		erasep (0);
-	if (noscroll && num_lines >= dlines)
-	{
-	    if (clreol)
-		home();
-	    else
-		doclear ();
+	for (;;) {
+		while (num_lines > 0 && !Pause) {
+			if ((nchars = get_line(f, &length)) == EOF) {
+				if (clreol)
+					clreos();
+				return;
+			}
+			if (ssp_opt && length == 0 && prev_len == 0)
+				continue;
+			prev_len = length;
+			if (bad_so
+			    || ((Senter && *Senter == ' ') && (promptlen > 0)))
+				erasep(0);
+			/* must clear before drawing line since tabs on
+			 * some terminals do not erase what they tab
+			 * over. */
+			if (clreol)
+				cleareol();
+			prbuf(Line, length);
+			if (nchars < promptlen)
+				erasep(nchars);	/* erasep () sets promptlen to 0 */
+			else
+				promptlen = 0;
+			/* is this needed?
+			 * if (clreol)
+			 *	cleareol();     * must clear again in case we wrapped *
+			 */
+			if (nchars < Mcol || !fold_opt)
+				prbuf("\n", 1);	/* will turn off UL if necessary */
+			if (nchars == STOP)
+				break;
+			num_lines--;
+		}
+		if (pstate) {
+			my_putstring(ULexit);
+			pstate = 0;
+		}
+		fflush(stdout);
+		if ((c = Getc(f)) == EOF) {
+			if (clreol)
+				clreos();
+			return;
+		}
+
+		if (Pause && clreol)
+			clreos();
+		Ungetc(c, f);
+		sigsetjmp(restore, 1);
+		Pause = 0;
+		startup = 0;
+		if ((num_lines = command(NULL, f)) == 0)
+			return;
+		if (hard && promptlen > 0)
+			erasep(0);
+		if (noscroll && num_lines >= dlines) {
+			if (clreol)
+				home();
+			else
+				doclear();
+		}
+		screen_start.line = Currline;
+		screen_start.chrctr = Ftell(f);
 	}
-	screen_start.line = Currline;
-	screen_start.chrctr = Ftell (f);
-    }
 }
 
-/*
-** Come here if a quit signal is received
-*/
-
-void onquit(int dummy __attribute__ ((__unused__)))
+/* Come here if a quit signal is received */
+void onquit(int dummy __attribute__((__unused__)))
 {
-    signal(SIGQUIT, SIG_IGN);
-    if (!inwait) {
-	putchar ('\n');
-	if (!startup) {
-	    signal(SIGQUIT, onquit);
-	    siglongjmp (restore, 1);
+	signal(SIGQUIT, SIG_IGN);
+	if (!inwait) {
+		putchar('\n');
+		if (!startup) {
+			signal(SIGQUIT, onquit);
+			siglongjmp(restore, 1);
+		} else
+			Pause++;
+	} else if (!dum_opt && notell) {
+		promptlen += fprintf(stderr, _("[Use q or Q to quit]"));
+		notell = 0;
 	}
-	else
-	    Pause++;
-    }
-    else if (!dum_opt && notell) {
-	promptlen += fprintf(stderr, _("[Use q or Q to quit]"));
-	notell = 0;
-    }
-    signal(SIGQUIT, onquit);
+	signal(SIGQUIT, onquit);
 }
 
-/*
-** Come here if a signal for a window size change is received
-*/
-
+/* Come here if a signal for a window size change is received */
 #ifdef SIGWINCH
-void chgwinsz(int dummy __attribute__ ((__unused__)))
+void chgwinsz(int dummy __attribute__((__unused__)))
 {
-    struct winsize win;
-
-    signal(SIGWINCH, SIG_IGN);
-    if (ioctl(fileno(stdout), TIOCGWINSZ, &win) != -1) {
-	if (win.ws_row != 0) {
-	    Lpp = win.ws_row;
-	    nscroll = Lpp/2 - 1;
-	    if (nscroll <= 0)
-		nscroll = 1;
-	    dlines = Lpp - 1;	/* was: Lpp - (noscroll ? 1 : 2) */
+	struct winsize win;
+
+	signal(SIGWINCH, SIG_IGN);
+	if (ioctl(fileno(stdout), TIOCGWINSZ, &win) != -1) {
+		if (win.ws_row != 0) {
+			Lpp = win.ws_row;
+			nscroll = Lpp / 2 - 1;
+			if (nscroll <= 0)
+				nscroll = 1;
+			dlines = Lpp - 1;	/* was: Lpp - (noscroll ? 1 : 2) */
+		}
+		if (win.ws_col != 0)
+			Mcol = win.ws_col;
 	}
-	if (win.ws_col != 0)
-	    Mcol = win.ws_col;
-    }
-    (void) signal(SIGWINCH, chgwinsz);
+	(void)signal(SIGWINCH, chgwinsz);
 }
-#endif /* SIGWINCH */
+#endif				/* SIGWINCH */
 
-/*
-** Clean up terminal state and exit. Also come here if interrupt signal received
-*/
-
-void __attribute__((__noreturn__))
-end_it (int dummy __attribute__ ((__unused__)))
+/* Clean up terminal state and exit. Also come here if interrupt signal received */
+void __attribute__((__noreturn__)) end_it(int dummy __attribute__((__unused__)))
 {
-    reset_tty ();
-    if (clreol) {
-	putchar ('\r');
-	clreos ();
-	fflush (stdout);
-    }
-    else if (!clreol && (promptlen > 0)) {
-	kill_line ();
-	fflush (stdout);
-    }
-    else
-	putcerr('\n');
-    _exit(EXIT_SUCCESS);
+	reset_tty();
+	if (clreol) {
+		putchar('\r');
+		clreos();
+		fflush(stdout);
+	} else if (!clreol && (promptlen > 0)) {
+		kill_line();
+		fflush(stdout);
+	} else
+		putcerr('\n');
+	_exit(EXIT_SUCCESS);
 }
 
-void copy_file(register FILE *f) {
-    register int c;
+void copy_file(register FILE *f)
+{
+	register int c;
 
-    while ((c = getc(f)) != EOF)
-	putchar(c);
+	while ((c = getc(f)) != EOF)
+		putchar(c);
 }
 
 #define ringbell()	putcerr('\007')
 
-static void prompt (char *filename)
+static void prompt(char *filename)
 {
-    if (clreol)
-	cleareol ();
-    else if (promptlen > 0)
-	kill_line ();
-    if (!hard) {
-	promptlen = 0;
-	if (Senter && Sexit) {
-	    my_putstring (Senter);
-	    promptlen += (2 * soglitch);
-	}
 	if (clreol)
-	    cleareol ();
-	promptlen += printf(_("--More--"));
-	if (filename != NULL) {
-	    promptlen += printf(_("(Next file: %s)"), filename);
-	} else if (!no_intty) {
-	    promptlen += printf("(%d%%)", (int) ((file_pos * 100) / file_size));
-	}
-	if (dum_opt) {
-	    promptlen += printf(_("[Press space to continue, 'q' to quit.]"));
-	}
-	if (Senter && Sexit)
-	    my_putstring (Sexit);
-	if (clreol)
-	    clreos ();
-	fflush(stdout);
-    }
-    else
-	ringbell();
-    inwait++;
+		cleareol();
+	else if (promptlen > 0)
+		kill_line();
+	if (!hard) {
+		promptlen = 0;
+		if (Senter && Sexit) {
+			my_putstring(Senter);
+			promptlen += (2 * soglitch);
+		}
+		if (clreol)
+			cleareol();
+		promptlen += printf(_("--More--"));
+		if (filename != NULL) {
+			promptlen += printf(_("(Next file: %s)"), filename);
+		} else if (!no_intty) {
+			promptlen +=
+			    printf("(%d%%)",
+				   (int)((file_pos * 100) / file_size));
+		}
+		if (dum_opt) {
+			promptlen +=
+			    printf(_("[Press space to continue, 'q' to quit.]"));
+		}
+		if (Senter && Sexit)
+			my_putstring(Sexit);
+		if (clreol)
+			clreos();
+		fflush(stdout);
+	} else
+		ringbell();
+	inwait++;
 }
 
 void prepare_line_buffer(void)
 {
-    char *nline;
-    size_t nsz = Mcol * 4;
+	char *nline;
+	size_t nsz = Mcol * 4;
 
-    if (LineLen >= nsz)
-        return;
+	if (LineLen >= nsz)
+		return;
 
-    if (nsz < LINSIZ)
-        nsz = LINSIZ;
+	if (nsz < LINSIZ)
+		nsz = LINSIZ;
 
-    nline = xrealloc(Line, nsz);
-    Line = nline;
-    LineLen = nsz;
+	nline = xrealloc(Line, nsz);
+	Line = nline;
+	LineLen = nsz;
 }
 
-/*
- * Get a logical line
- */
-
+/* Get a logical line */
 int get_line(register FILE *f, int *length)
 {
-    int	c;
-    char *p;
-    int	column;
-    static int colflg;
+	int c;
+	char *p;
+	int column;
+	static int colflg;
 
 #ifdef HAVE_WIDECHAR
-    size_t i;
-    wchar_t wc;
-    int wc_width;
-    mbstate_t state, state_bak;		/* Current status of the stream. */
-    char mbc[MB_LEN_MAX];		/* Buffer for one multibyte char. */
-    size_t mblength;			/* Byte length of multibyte char. */
-    size_t mbc_pos = 0;			/* Position of the MBC. */
-    int use_mbc_buffer_flag = 0;	/* If 1, mbc has data. */
-    int break_flag = 0;			/* If 1, exit while(). */
-    long file_pos_bak = Ftell (f);
-
-    memset (&state, '\0', sizeof (mbstate_t));
-#endif /* HAVE_WIDECHAR */
-
-    prepare_line_buffer();
-
-    p = Line;
-    column = 0;
-    c = Getc (f);
-    if (colflg && c == '\n') {
-	Currline++;
-	c = Getc (f);
-    }
-    while (p < &Line[LineLen - 1]) {
+	size_t i;
+	wchar_t wc;
+	int wc_width;
+	mbstate_t state, state_bak;	/* Current status of the stream. */
+	char mbc[MB_LEN_MAX];		/* Buffer for one multibyte char. */
+	size_t mblength;		/* Byte length of multibyte char. */
+	size_t mbc_pos = 0;		/* Position of the MBC. */
+	int use_mbc_buffer_flag = 0;	/* If 1, mbc has data. */
+	int break_flag = 0;		/* If 1, exit while(). */
+	long file_pos_bak = Ftell(f);
+
+	memset(&state, '\0', sizeof(mbstate_t));
+#endif
+
+	prepare_line_buffer();
+
+	p = Line;
+	column = 0;
+	c = Getc(f);
+	if (colflg && c == '\n') {
+		Currline++;
+		c = Getc(f);
+	}
+	while (p < &Line[LineLen - 1]) {
 #ifdef HAVE_WIDECHAR
-	if (fold_opt && use_mbc_buffer_flag && MB_CUR_MAX > 1) {
-	    use_mbc_buffer_flag = 0;
-	    state_bak = state;
-	    mbc[mbc_pos++] = c;
-process_mbc:
-	    mblength = mbrtowc (&wc, mbc, mbc_pos, &state);
-
-	    switch (mblength) {
-	      case (size_t)-2:	  /* Incomplete multibyte character. */
-		use_mbc_buffer_flag = 1;
-		state = state_bak;
-		break;
-
-	      case (size_t)-1:	  /* Invalid as a multibyte character. */
-		*p++ = mbc[0];
-		state = state_bak;
-		column++;
-		file_pos_bak++;
-		
-		if (column >= Mcol) {
-		    Fseek (f, file_pos_bak);
-		} else {
-		    memmove (mbc, mbc + 1, --mbc_pos);
-		    if (mbc_pos > 0) {
-			mbc[mbc_pos] = '\0';
-			goto process_mbc;
-		    }
-		}
-		break;
+		if (fold_opt && use_mbc_buffer_flag && MB_CUR_MAX > 1) {
+			use_mbc_buffer_flag = 0;
+			state_bak = state;
+			mbc[mbc_pos++] = c;
+ process_mbc:
+			mblength = mbrtowc(&wc, mbc, mbc_pos, &state);
+
+			switch (mblength) {
+			case (size_t)-2:	/* Incomplete multibyte character. */
+				use_mbc_buffer_flag = 1;
+				state = state_bak;
+				break;
+
+			case (size_t)-1:	/* Invalid as a multibyte character. */
+				*p++ = mbc[0];
+				state = state_bak;
+				column++;
+				file_pos_bak++;
+
+				if (column >= Mcol) {
+					Fseek(f, file_pos_bak);
+				} else {
+					memmove(mbc, mbc + 1, --mbc_pos);
+					if (mbc_pos > 0) {
+						mbc[mbc_pos] = '\0';
+						goto process_mbc;
+					}
+				}
+				break;
+
+			default:
+				wc_width = wcwidth(wc);
+
+				if (column + wc_width > Mcol) {
+					Fseek(f, file_pos_bak);
+					break_flag = 1;
+				} else {
+					for (i = 0; i < mbc_pos; i++)
+						*p++ = mbc[i];
+					if (wc_width > 0)
+						column += wc_width;
+				}
+			}
 
-	      default:
-		wc_width = wcwidth (wc);
+			if (break_flag || column >= Mcol)
+				break;
 
-		if (column + wc_width > Mcol) {
-		    Fseek (f, file_pos_bak);
-		    break_flag = 1;
-		} else {
-		    for (i = 0; i < mbc_pos; i++)
-		      *p++ = mbc[i];
-		    if (wc_width > 0)
-		      column += wc_width;
+			c = Getc(f);
+			continue;
+		}
+#endif	/* HAVE_WIDECHAR */
+		if (c == EOF) {
+			if (p > Line) {
+				*p = '\0';
+				*length = p - Line;
+				return (column);
+			}
+			*length = p - Line;
+			return (EOF);
+		}
+		if (c == '\n') {
+			Currline++;
+			break;
 		}
-	    }
-
-	    if (break_flag || column >= Mcol)
-	      break;
-
-	    c = Getc (f);
-	    continue;
-	}
-#endif /* HAVE_WIDECHAR */
-	if (c == EOF) {
-	    if (p > Line) {
-		*p = '\0';
-		*length = p - Line;
-		return (column);
-	    }
-	    *length = p - Line;
-	    return (EOF);
-	}
-	if (c == '\n') {
-	    Currline++;
-	    break;
-	}
 
-	*p++ = c;
+		*p++ = c;
 #if 0
-	if (c == '\033') {      /* ESC */
-		c = Getc(f);
-		while (c > ' ' && c < '0' && p < &Line[LineLen - 1]) {
-			*p++ = c;
+		if (c == '\033') {	/* ESC */
 			c = Getc(f);
+			while (c > ' ' && c < '0' && p < &Line[LineLen - 1]) {
+				*p++ = c;
+				c = Getc(f);
+			}
+			if (c >= '0' && c < '\177' && p < &Line[LineLen - 1]) {
+				*p++ = c;
+				c = Getc(f);
+				continue;
+			}
 		}
-		if (c >= '0' && c < '\177' && p < &Line[LineLen - 1]) {
-			*p++ = c;
-			c = Getc(f);
-			continue;
+#endif	/* 0 */
+		if (c == '\t') {
+			if (!hardtabs || (column < promptlen && !hard)) {
+				if (hardtabs && eraseln && !dumb) {
+					column = 1 + (column | 7);
+					my_putstring(eraseln);
+					promptlen = 0;
+				} else {
+					for (--p; p < &Line[LineLen - 1];) {
+						*p++ = ' ';
+						if ((++column & 7) == 0)
+							break;
+					}
+					if (column >= promptlen)
+						promptlen = 0;
+				}
+			} else
+				column = 1 + (column | 7);
+		} else if (c == '\b' && column > 0) {
+			column--;
+		} else if (c == '\r') {
+			int next = Getc(f);
+			if (next == '\n') {
+				p--;
+				Currline++;
+				break;
+			}
+			Ungetc(next, f);
+			column = 0;
+		} else if (c == '\f' && stop_opt) {
+			p[-1] = '^';
+			*p++ = 'L';
+			column += 2;
+			Pause++;
+		} else if (c == EOF) {
+			*length = p - Line;
+			return (column);
+		} else {
+#ifdef HAVE_WIDECHAR
+			if (fold_opt && MB_CUR_MAX > 1) {
+				memset(mbc, '\0', MB_LEN_MAX);
+				mbc_pos = 0;
+				mbc[mbc_pos++] = c;
+				state_bak = state;
+
+				mblength = mbrtowc(&wc, mbc, mbc_pos, &state);
+				/* The value of mblength is always less than 2 here. */
+				switch (mblength) {
+				case (size_t)-2:
+					p--;
+					file_pos_bak = Ftell(f) - 1;
+					state = state_bak;
+					use_mbc_buffer_flag = 1;
+					break;
+
+				case (size_t)-1:
+					state = state_bak;
+					column++;
+					break;
+
+				default:
+					wc_width = wcwidth(wc);
+					if (wc_width > 0)
+						column += wc_width;
+				}
+			} else
+#endif	/* HAVE_WIDECHAR */
+			{
+				if (isprint(c))
+					column++;
+			}
 		}
+
+		if (column >= Mcol && fold_opt)
+			break;
+		c = Getc(f);
 	}
-#endif /* 0 */
-	if (c == '\t') {
-	    if (!hardtabs || (column < promptlen && !hard)) {
-		if (hardtabs && eraseln && !dumb) {
-		    column = 1 + (column | 7);
-		    my_putstring (eraseln);
-		    promptlen = 0;
+	if (column >= Mcol && Mcol > 0) {
+		if (!Wrap) {
+			*p++ = '\n';
 		}
-		else {
-		    for (--p; p < &Line[LineLen - 1];) {
-			*p++ = ' ';
-			if ((++column & 7) == 0)
-			    break;
-		    }
-		    if (column >= promptlen) promptlen = 0;
-		}
-	    } else
-		column = 1 + (column | 7);
-	} else if (c == '\b' && column > 0) {
-	    column--;
-	} else if (c == '\r') {
-	    int next = Getc(f);
-	    if (next == '\n') {
-		p--;
-		Currline++;
-		break;
-	    }
-	    Ungetc(next,f);
-	    column = 0;
-	} else if (c == '\f' && stop_opt) {
-		p[-1] = '^';
-		*p++ = 'L';
-		column += 2;
-		Pause++;
-	} else if (c == EOF) {
-	    *length = p - Line;
-	    return (column);
-	} else {
-#ifdef HAVE_WIDECHAR
-	    if (fold_opt && MB_CUR_MAX > 1) {
-		memset (mbc, '\0', MB_LEN_MAX);
-		mbc_pos = 0;
-		mbc[mbc_pos++] = c;
-		state_bak = state;
-
-		mblength = mbrtowc (&wc, mbc, mbc_pos, &state);
-
-		/* The value of mblength is always less than 2 here. */
-		switch (mblength) {
-		  case (size_t)-2:
-		    p--;
-		    file_pos_bak = Ftell (f) - 1;
-		    state = state_bak;
-		    use_mbc_buffer_flag = 1;
-		    break;
-
-		  case (size_t)-1:
-		    state = state_bak;
-		    column++;
-		    break;
-
-		  default:
-		    wc_width = wcwidth (wc);
-		    if (wc_width > 0)
-		      column += wc_width;
-		}
-	    } else
-#endif /* HAVE_WIDECHAR */
-	      {
-		if (isprint(c))
-		   column++;
-	      }
 	}
-
-	if (column >= Mcol && fold_opt)
-		break;
-	c = Getc (f);
-    }
-    if (column >= Mcol && Mcol > 0) {
-	if (!Wrap) {
-	    *p++ = '\n';
+	colflg = column == Mcol && fold_opt;
+	if (colflg && eatnl && Wrap) {
+		*p++ = '\n';	/* simulate normal wrap */
 	}
-    }
-    colflg = column == Mcol && fold_opt;
-    if (colflg && eatnl && Wrap) {
-	*p++ = '\n'; /* simulate normal wrap */
-    }
-    *length = p - Line;
-    *p = 0;
-    return (column);
+	*length = p - Line;
+	*p = 0;
+	return (column);
 }
 
-/*
-** Erase the rest of the prompt, assuming we are starting at column col.
-*/
-
-void erasep (register int col)
+/* Erase the rest of the prompt, assuming we are starting at column col. */
+void erasep(register int col)
 {
 
-    if (promptlen == 0)
-	return;
-    if (hard) {
-	putchar ('\n');
-    }
-    else {
-	if (col == 0)
-	    putchar ('\r');
-	if (!dumb && eraseln)
-	    my_putstring (eraseln);
-	else
-	    for (col = promptlen - col; col > 0; col--)
-		putchar (' ');
-    }
-    promptlen = 0;
+	if (promptlen == 0)
+		return;
+	if (hard) {
+		putchar('\n');
+	} else {
+		if (col == 0)
+			putchar('\r');
+		if (!dumb && eraseln)
+			my_putstring(eraseln);
+		else
+			for (col = promptlen - col; col > 0; col--)
+				putchar(' ');
+	}
+	promptlen = 0;
 }
 
-/*
-** Erase the current line entirely
-*/
-
+/* Erase the current line entirely */
 void kill_line()
 {
-    erasep(0);
-    if (!eraseln || dumb)
-	putchar('\r');
+	erasep(0);
+	if (!eraseln || dumb)
+		putchar('\r');
 }
 
-/*
- * force clear to end of line
- */
+/* force clear to end of line */
 void cleareol()
 {
-    my_putstring(eraseln);
+	my_putstring(eraseln);
 }
 
 void clreos()
 {
-    my_putstring(EodClr);
+	my_putstring(EodClr);
 }
 
 /* Print a buffer of n characters */
-
-void prbuf (register char *s, register int n)
+void prbuf(register char *s, register int n)
 {
-    register char c;			/* next output character */
-    register int state;			/* next output char's UL state */
+	register char c;	/* next output character */
+	register int state;	/* next output char's UL state */
 #define wouldul(s,n)	((n) >= 2 && (((s)[0] == '_' && (s)[1] == '\b') || ((s)[1] == '\b' && (s)[2] == '_')))
 
-    while (--n >= 0)
-	if (!ul_opt)
-	    putchar (*s++);
-	else {
-	    if (*s == ' ' && pstate == 0 && ulglitch && wouldul(s+1, n-1)) {
-		s++;
-		continue;
-	    }
-	    if ((state = wouldul(s, n)) != 0) {
-		c = (*s == '_')? s[2] : *s ;
-		n -= 2;
-		s += 3;
-	    } else
-		c = *s++;
-	    if (state != pstate) {
-		if (c == ' ' && state == 0 && ulglitch && wouldul(s, n-1))
-		    state = 1;
-		else
-		    my_putstring(state ? ULenter : ULexit);
-	    }
-	    if (c != ' ' || pstate == 0 || state != 0 || ulglitch == 0)
+	while (--n >= 0)
+		if (!ul_opt)
+			putchar(*s++);
+		else {
+			if (*s == ' ' && pstate == 0 && ulglitch
+			    && wouldul(s + 1, n - 1)) {
+				s++;
+				continue;
+			}
+			if ((state = wouldul(s, n)) != 0) {
+				c = (*s == '_') ? s[2] : *s;
+				n -= 2;
+				s += 3;
+			} else
+				c = *s++;
+			if (state != pstate) {
+				if (c == ' ' && state == 0 && ulglitch
+				    && wouldul(s, n - 1))
+					state = 1;
+				else
+					my_putstring(state ? ULenter : ULexit);
+			}
+			if (c != ' ' || pstate == 0 || state != 0
+			    || ulglitch == 0)
 #ifdef HAVE_WIDECHAR
-	    {
-		wchar_t wc;
-		size_t mblength;
-		mbstate_t mbstate;
-		memset (&mbstate, '\0', sizeof (mbstate_t));
-		s--; n++;
-		mblength = mbrtowc (&wc, s, n, &mbstate);
-		if (mblength == (size_t) -2 || mblength == (size_t) -1)
-			mblength = 1;
-		while (mblength--)
-			putchar (*s++);
-		n += mblength;
-	    }
+			{
+				wchar_t wc;
+				size_t mblength;
+				mbstate_t mbstate;
+				memset(&mbstate, '\0', sizeof(mbstate_t));
+				s--;
+				n++;
+				mblength = mbrtowc(&wc, s, n, &mbstate);
+				if (mblength == (size_t)-2
+				    || mblength == (size_t)-1)
+					mblength = 1;
+				while (mblength--)
+					putchar(*s++);
+				n += mblength;
+			}
 #else
-	        putchar(c);
-#endif /* HAVE_WIDECHAR */
-	    if (state && *chUL) {
-		putsout(chBS);
-		my_putstring(chUL);
-	    }
-	    pstate = state;
-	}
+				putchar(c);
+#endif				/* HAVE_WIDECHAR */
+			if (state && *chUL) {
+				putsout(chBS);
+				my_putstring(chUL);
+			}
+			pstate = state;
+		}
 }
 
-/*
-**  Clear the screen
-*/
-void
-doclear()
+/*  Clear the screen */
+void doclear()
 {
-    if (Clear && !hard) {
-	my_putstring(Clear);
-
-	/* Put out carriage return so that system doesn't
-	** get confused by escape sequences when expanding tabs
-	*/
-	putchar ('\r');
-	promptlen = 0;
-    }
+	if (Clear && !hard) {
+		my_putstring(Clear);
+		/* Put out carriage return so that system doesn't get
+		 * confused by escape sequences when expanding tabs */
+		putchar('\r');
+		promptlen = 0;
+	}
 }
 
-/*
- * Go to home position
- */
-void
-home()
+/* Go to home position */
+void home()
 {
-    my_putstring(Home);
+	my_putstring(Home);
 }
 
 static int lastcmd, lastarg, lastp;
 static int lastcolon;
 char shell_line[SHELL_LINE];
 
-/*
-** Read a command and do it. A command consists of an optional integer
-** argument followed by the command character.  Return the number of lines
-** to display in the next screenful.  If there is nothing more to display
-** in the current file, zero is returned.
-*/
-
-int command (char *filename, register FILE *f)
+/* Read a command and do it.  A command consists of an optional integer
+ * argument followed by the command character.  Return the number of
+ * lines to display in the next screenful.  If there is nothing more to
+ * display in the current file, zero is returned. */
+int command(char *filename, register FILE *f)
 {
-    register int nlines;
-    register int retval = 0;
-    register int c;
-    char colonch;
-    int done;
-    char comchar, cmdbuf[INIT_BUF];
+	register int nlines;
+	register int retval = 0;
+	register int c;
+	char colonch;
+	int done;
+	char comchar, cmdbuf[INIT_BUF];
 
 #define ret(val) retval=val;done++;break
 
-    done = 0;
-    if (!errors)
-	prompt (filename);
-    else
-	errors = 0;
-    for (;;) {
-	nlines = number (&comchar);
-	lastp = colonch = 0;
-	if (comchar == '.') {	/* Repeat last command */
-		lastp++;
-		comchar = lastcmd;
-		nlines = lastarg;
-		if (lastcmd == ':')
-			colonch = lastcolon;
-	}
-	lastcmd = comchar;
-	lastarg = nlines;
-	if ((cc_t) comchar == otty.c_cc[VERASE]) {
-	    kill_line ();
-	    prompt (filename);
-	    continue;
-	}
-	switch (comchar) {
-	case ':':
-	    retval = colon (filename, colonch, nlines);
-	    if (retval >= 0)
-		done++;
-	    break;
-	case 'b':
-	case ctrl('B'):
-	    {
-		register int initline;
-
-		if (no_intty) {
-		    ringbell();
-		    return (-1);
+	done = 0;
+	if (!errors)
+		prompt(filename);
+	else
+		errors = 0;
+	for (;;) {
+		nlines = number(&comchar);
+		lastp = colonch = 0;
+		if (comchar == '.') {	/* Repeat last command */
+			lastp++;
+			comchar = lastcmd;
+			nlines = lastarg;
+			if (lastcmd == ':')
+				colonch = lastcolon;
 		}
+		lastcmd = comchar;
+		lastarg = nlines;
+		if ((cc_t) comchar == otty.c_cc[VERASE]) {
+			kill_line();
+			prompt(filename);
+			continue;
+		}
+		switch (comchar) {
+		case ':':
+			retval = colon(filename, colonch, nlines);
+			if (retval >= 0)
+				done++;
+			break;
+		case 'b':
+		case ctrl('B'):
+			{
+				register int initline;
+
+				if (no_intty) {
+					ringbell();
+					return (-1);
+				}
+
+				if (nlines == 0)
+					nlines++;
+
+				putchar('\r');
+				erasep(0);
+				putchar('\n');
+				if (clreol)
+					cleareol();
+				if (nlines != 1)
+					printf(_("...back %d pages"), nlines);
+				else
+					putsout(_("...back 1 page"));
+				if (clreol)
+					cleareol();
+				putchar('\n');
+
+				initline = Currline - dlines * (nlines + 1);
+				if (!noscroll)
+					--initline;
+				if (initline < 0)
+					initline = 0;
+				Fseek(f, 0L);
+				Currline = 0;	/* skiplns() will make Currline correct */
+				skiplns(initline, f);
+				if (!noscroll) {
+					ret(dlines + 1);
+				} else {
+					ret(dlines);
+				}
+			}
+		case ' ':
+		case 'z':
+			if (nlines == 0)
+				nlines = dlines;
+			else if (comchar == 'z')
+				dlines = nlines;
+			ret(nlines);
+		case 'd':
+		case ctrl('D'):
+			if (nlines != 0)
+				nscroll = nlines;
+			ret(nscroll);
+		case 'q':
+		case 'Q':
+			end_it(0);
+		case 's':
+		case 'f':
+		case ctrl('F'):
+			if (nlines == 0)
+				nlines++;
+			if (comchar == 'f')
+				nlines *= dlines;
+			putchar('\r');
+			erasep(0);
+			putchar('\n');
+			if (clreol)
+				cleareol();
+			if (nlines == 1)
+				putsout(_("...skipping one line"));
+			else
+				printf(_("...skipping %d lines"), nlines);
 
-		if (nlines == 0) nlines++;
-
-		putchar ('\r');
-		erasep (0);
-		putchar('\n');
-		if (clreol)
-			cleareol ();
-		if (nlines != 1)
-			printf(_("...back %d pages"), nlines);
-		else
-			putsout(_("...back 1 page"));
-		if (clreol)
-			cleareol ();
-		putchar('\n');
+			if (clreol)
+				cleareol();
+			putchar('\n');
 
-		initline = Currline - dlines * (nlines + 1);
-		if (! noscroll)
-		    --initline;
-		if (initline < 0) initline = 0;
-		Fseek(f, 0L);
-		Currline = 0;	/* skiplns() will make Currline correct */
-		skiplns(initline, f);
-		if (! noscroll) {
-		    ret(dlines + 1);
-		}
-		else {
-		    ret(dlines);
-		}
-	    }
-	case ' ':
-	case 'z':
-	    if (nlines == 0) nlines = dlines;
-	    else if (comchar == 'z') dlines = nlines;
-	    ret (nlines);
-	case 'd':
-	case ctrl('D'):
-	    if (nlines != 0) nscroll = nlines;
-	    ret (nscroll);
-	case 'q':
-	case 'Q':
-	    end_it (0);
-	case 's':
-	case 'f':
-	case ctrl('F'):
-	    if (nlines == 0) nlines++;
-	    if (comchar == 'f')
-		nlines *= dlines;
-	    putchar ('\r');
-	    erasep (0);
-	    putchar('\n');
-	    if (clreol)
-		cleareol ();
-	    if (nlines == 1)
-		    putsout(_("...skipping one line"));
-	    else
-		    printf(_("...skipping %d lines"), nlines);
-
-	    if (clreol)
-		cleareol ();
-	    putchar('\n');
-
-	    while (nlines > 0) {
-		while ((c = Getc (f)) != '\n')
-		    if (c == EOF) {
-			retval = 0;
-			done++;
-			goto endsw;
-		    }
-		    Currline++;
-		    nlines--;
-	    }
-	    ret (dlines);
-	case '\n':
-	    if (nlines != 0)
-		dlines = nlines;
-	    else
-		nlines = 1;
-	    ret (nlines);
-	case '\f':
-	    if (!no_intty) {
-		doclear ();
-		Fseek (f, screen_start.chrctr);
-		Currline = screen_start.line;
-		ret (dlines);
-	    }
-	    else {
-		ringbell();
-		break;
-	    }
-	case '\'':
-	    if (!no_intty) {
-		kill_line ();
-		putsout(_("\n***Back***\n\n"));
-		Fseek (f, context.chrctr);
-		Currline = context.line;
-		ret (dlines);
-	    }
-	    else {
-		ringbell();
-		break;
-	    }
-	case '=':
-	    kill_line ();
-	    promptlen = printf("%d", Currline);
-	    fflush (stdout);
-	    break;
-	case 'n':
-	    if (!previousre) {
-	        more_error (_("No previous regular expression"));
-	        break;
-            }
-	    lastp++;
-	    /* fallthrough */
-	case '/':
-	    if (nlines == 0) nlines++;
-	    kill_line ();
-	    putchar('/');
-	    promptlen = 1;
-	    fflush (stdout);
-	    if (lastp) {
-		putcerr('\r');
-		search (previousre, f, nlines);
-	    }
-	    else {
-		ttyin (cmdbuf, sizeof(cmdbuf)-2, '/');
-		putcerr('\r');
-		free (previousre);
-		previousre = xstrdup(cmdbuf);
-		search (cmdbuf, f, nlines);
-	    }
-	    ret (dlines-1);
-	case '!':
-	    do_shell (filename);
-	    break;
-	case '?':
-	case 'h':
-	    if (noscroll) doclear();
-	    putsout(_("\n"
-"Most commands optionally preceded by integer argument k.  "
-"Defaults in brackets.\n"
-"Star (*) indicates argument becomes new default.\n"));
-	    puts("---------------------------------------"
-		"----------------------------------------");
-	    putsout(_(
-"<space>                 Display next k lines of text [current screen size]\n"
-"z                       Display next k lines of text [current screen size]*\n"
-"<return>                Display next k lines of text [1]*\n"
-"d or ctrl-D             Scroll k lines [current scroll size, initially 11]*\n"
-"q or Q or <interrupt>   Exit from more\n"
-"s                       Skip forward k lines of text [1]\n"
-"f                       Skip forward k screenfuls of text [1]\n"
-"b or ctrl-B             Skip backwards k screenfuls of text [1]\n"
-"'                       Go to place where previous search started\n"
-"=                       Display current line number\n"
-"/<regular expression>   Search for kth occurrence of regular expression [1]\n"
-"n                       Search for kth occurrence of last r.e [1]\n"
-"!<cmd> or :!<cmd>       Execute <cmd> in a subshell\n"
-"v                       Start up /usr/bin/vi at current line\n"
-"ctrl-L                  Redraw screen\n"
-":n                      Go to kth next file [1]\n"
-":p                      Go to kth previous file [1]\n"
-":f                      Display current file name and line number\n"
-".                       Repeat previous command\n"));
-	    puts("---------------------------------------"
-		"----------------------------------------");
-	    prompt(filename);
-	    break;
-	case 'v':	/* This case should go right before default */
-	    if (!no_intty) {
-		    /*
-		     * Earlier: call vi +n file. This also works for emacs.
-		     * POSIX: call vi -c n file (when editor is vi or ex).
-		     */
-		    char *editor, *p;
-		    int n = (Currline - dlines <= 0 ? 1 :
-			     Currline - (dlines + 1) / 2);
-		    int split = 0;
-
-		    editor = getenv("VISUAL");
-		    if (editor == NULL || *editor == '\0')
-			    editor = getenv("EDITOR");
-		    if (editor == NULL || *editor == '\0')
-			    editor = VI;
-
-		    p = strrchr(editor, '/');
-		    if (p)
-			    p++;
-		    else
-			    p = editor;
-		    if (!strcmp(p, "vi") || !strcmp(p, "ex")) {
-			    sprintf(cmdbuf, "-c %d", n);
-			    split = 1;
-		    } else {
-			    sprintf(cmdbuf, "+%d", n);
-		    }
-
-		    kill_line();
-		    printf("%s %s %s", editor, cmdbuf, fnames[fnum]);
-		    if (split) {
-			    cmdbuf[2] = 0;
-			    execute(filename, editor, editor, cmdbuf,
-				    cmdbuf+3, fnames[fnum], (char *)0);
-		    } else
-			    execute(filename, editor, editor,
-				    cmdbuf, fnames[fnum], (char *)0);
-		    break;
-	    }
-	    /* fall through */
-	default:
-	    if (dum_opt) {
-   		kill_line ();
-		if (Senter && Sexit) {
-		    my_putstring (Senter);
-		    promptlen = printf(_("[Press 'h' for instructions.]"))
-			    + 2 * soglitch;
-		    my_putstring (Sexit);
+			while (nlines > 0) {
+				while ((c = Getc(f)) != '\n')
+					if (c == EOF) {
+						retval = 0;
+						done++;
+						goto endsw;
+					}
+				Currline++;
+				nlines--;
+			}
+			ret(dlines);
+		case '\n':
+			if (nlines != 0)
+				dlines = nlines;
+			else
+				nlines = 1;
+			ret(nlines);
+		case '\f':
+			if (!no_intty) {
+				doclear();
+				Fseek(f, screen_start.chrctr);
+				Currline = screen_start.line;
+				ret(dlines);
+			} else {
+				ringbell();
+				break;
+			}
+		case '\'':
+			if (!no_intty) {
+				kill_line();
+				putsout(_("\n***Back***\n\n"));
+				Fseek(f, context.chrctr);
+				Currline = context.line;
+				ret(dlines);
+			} else {
+				ringbell();
+				break;
+			}
+		case '=':
+			kill_line();
+			promptlen = printf("%d", Currline);
+			fflush(stdout);
+			break;
+		case 'n':
+			if (!previousre) {
+				more_error(_("No previous regular expression"));
+				break;
+			}
+			lastp++;
+			/* fall through */
+		case '/':
+			if (nlines == 0)
+				nlines++;
+			kill_line();
+			putchar('/');
+			promptlen = 1;
+			fflush(stdout);
+			if (lastp) {
+				putcerr('\r');
+				search(previousre, f, nlines);
+			} else {
+				ttyin(cmdbuf, sizeof(cmdbuf) - 2, '/');
+				putcerr('\r');
+				free(previousre);
+				previousre = xstrdup(cmdbuf);
+				search(cmdbuf, f, nlines);
+			}
+			ret(dlines - 1);
+		case '!':
+			do_shell(filename);
+			break;
+		case '?':
+		case 'h':
+			if (noscroll)
+				doclear();
+			putsout(_("\n"
+				  "Most commands optionally preceded by integer argument k.  "
+				  "Defaults in brackets.\n"
+				  "Star (*) indicates argument becomes new default.\n"));
+			puts("---------------------------------------"
+			     "----------------------------------------");
+			putsout(_
+				("<space>                 Display next k lines of text [current screen size]\n"
+				 "z                       Display next k lines of text [current screen size]*\n"
+				 "<return>                Display next k lines of text [1]*\n"
+				 "d or ctrl-D             Scroll k lines [current scroll size, initially 11]*\n"
+				 "q or Q or <interrupt>   Exit from more\n"
+				 "s                       Skip forward k lines of text [1]\n"
+				 "f                       Skip forward k screenfuls of text [1]\n"
+				 "b or ctrl-B             Skip backwards k screenfuls of text [1]\n"
+				 "'                       Go to place where previous search started\n"
+				 "=                       Display current line number\n"
+				 "/<regular expression>   Search for kth occurrence of regular expression [1]\n"
+				 "n                       Search for kth occurrence of last r.e [1]\n"
+				 "!<cmd> or :!<cmd>       Execute <cmd> in a subshell\n"
+				 "v                       Start up /usr/bin/vi at current line\n"
+				 "ctrl-L                  Redraw screen\n"
+				 ":n                      Go to kth next file [1]\n"
+				 ":p                      Go to kth previous file [1]\n"
+				 ":f                      Display current file name and line number\n"
+				 ".                       Repeat previous command\n"));
+			puts("---------------------------------------"
+			     "----------------------------------------");
+			prompt(filename);
+			break;
+		case 'v':	/* This case should go right before default */
+			if (!no_intty) {
+				/* Earlier: call vi +n file. This also
+				 * works for emacs.  POSIX: call vi -c n
+				 * file (when editor is vi or ex). */
+				char *editor, *p;
+				int n = (Currline - dlines <= 0 ? 1 :
+					 Currline - (dlines + 1) / 2);
+				int split = 0;
+
+				editor = getenv("VISUAL");
+				if (editor == NULL || *editor == '\0')
+					editor = getenv("EDITOR");
+				if (editor == NULL || *editor == '\0')
+					editor = VI;
+
+				p = strrchr(editor, '/');
+				if (p)
+					p++;
+				else
+					p = editor;
+				if (!strcmp(p, "vi") || !strcmp(p, "ex")) {
+					sprintf(cmdbuf, "-c %d", n);
+					split = 1;
+				} else {
+					sprintf(cmdbuf, "+%d", n);
+				}
+
+				kill_line();
+				printf("%s %s %s", editor, cmdbuf,
+				       fnames[fnum]);
+				if (split) {
+					cmdbuf[2] = 0;
+					execute(filename, editor, editor,
+						cmdbuf, cmdbuf + 3,
+						fnames[fnum], (char *)0);
+				} else
+					execute(filename, editor, editor,
+						cmdbuf, fnames[fnum],
+						(char *)0);
+				break;
+			}
+			/* fall through */
+		default:
+			if (dum_opt) {
+				kill_line();
+				if (Senter && Sexit) {
+					my_putstring(Senter);
+					promptlen =
+					    printf(_
+						   ("[Press 'h' for instructions.]"))
+					    + 2 * soglitch;
+					my_putstring(Sexit);
+				} else
+					promptlen =
+					    printf(_
+						   ("[Press 'h' for instructions.]"));
+				fflush(stdout);
+			} else
+				ringbell();
+			break;
 		}
-		else
-		    promptlen = printf(_("[Press 'h' for instructions.]"));
-		fflush (stdout);
-	    }
-	    else
-		ringbell();
-	    break;
+		if (done)
+			break;
 	}
-	if (done) break;
-    }
-    putchar ('\r');
-endsw:
-    inwait = 0;
-    notell++;
-    return (retval);
+	putchar('\r');
+ endsw:
+	inwait = 0;
+	notell++;
+	return (retval);
 }
 
 static char ch;
-
-/*
- * Execute a colon-prefixed command.
- * Returns <0 if not a command that should cause
- * more of the file to be printed.
- */
-
-int colon (char *filename, int cmd, int nlines) {
+/* Execute a colon-prefixed command.  Returns <0 if not a command that
+ * should cause more of the file to be printed. */
+int colon(char *filename, int cmd, int nlines)
+{
 	if (cmd == 0)
-		ch = readch ();
+		ch = readch();
 	else
 		ch = cmd;
 	lastcolon = ch;
 	switch (ch) {
 	case 'f':
-		kill_line ();
+		kill_line();
 		if (!no_intty)
-			promptlen = printf(_("\"%s\" line %d"), fnames[fnum], Currline);
+			promptlen =
+			    printf(_("\"%s\" line %d"), fnames[fnum], Currline);
 		else
 			promptlen = printf(_("[Not a file] line %d"), Currline);
-		fflush (stdout);
+		fflush(stdout);
 		return (-1);
 	case 'n':
 		if (nlines == 0) {
 			if (fnum >= nfiles - 1)
-				end_it (0);
+				end_it(0);
 			nlines++;
 		}
-		putchar ('\r');
-		erasep (0);
-		skipf (nlines);
+		putchar('\r');
+		erasep(0);
+		skipf(nlines);
 		return (0);
 	case 'p':
 		if (no_intty) {
 			ringbell();
 			return (-1);
 		}
-		putchar ('\r');
-		erasep (0);
+		putchar('\r');
+		erasep(0);
 		if (nlines == 0)
 			nlines++;
-		skipf (-nlines);
+		skipf(-nlines);
 		return (0);
 	case '!':
-		do_shell (filename);
+		do_shell(filename);
 		return (-1);
 	case 'q':
 	case 'Q':
-		end_it (0);
+		end_it(0);
 	default:
 		ringbell();
 		return (-1);
 	}
 }
 
-/*
-** Read a decimal number from the terminal. Set cmd to the non-digit which
-** terminates the number.
-*/
-
+/* Read a decimal number from the terminal.  Set cmd to the non-digit
+ * which terminates the number. */
 int number(char *cmd)
 {
 	register int i;
 
-	i = 0; ch = otty.c_cc[VKILL];
+	i = 0;
+	ch = otty.c_cc[VKILL];
 	for (;;) {
-		ch = readch ();
+		ch = readch();
 		if (isdigit(ch))
-			i = i*10 + ch - '0';
+			i = i * 10 + ch - '0';
 		else if ((cc_t) ch == otty.c_cc[VKILL])
 			i = 0;
 		else {
@@ -1542,22 +1525,22 @@ int number(char *cmd)
 	return (i);
 }
 
-void do_shell (char *filename)
+void do_shell(char *filename)
 {
 	char cmdbuf[COMMAND_BUF];
 	int rc;
 	char *expanded;
 
-	kill_line ();
+	kill_line();
 	putchar('!');
-	fflush (stdout);
+	fflush(stdout);
 	promptlen = 1;
 	if (lastp)
 		putsout(shell_line);
 	else {
-		ttyin (cmdbuf, sizeof(cmdbuf)-2, '!');
+		ttyin(cmdbuf, sizeof(cmdbuf) - 2, '!');
 		expanded = 0;
-		rc = expand (&expanded, cmdbuf);
+		rc = expand(&expanded, cmdbuf);
 		if (expanded) {
 			if (strlen(expanded) < sizeof(shell_line))
 				strcpy(shell_line, expanded);
@@ -1567,341 +1550,336 @@ void do_shell (char *filename)
 		}
 		if (rc < 0) {
 			putserr(_("  Overflow\n"));
-			prompt (filename);
+			prompt(filename);
 			return;
 		} else if (rc > 0) {
-			kill_line ();
+			kill_line();
 			promptlen = printf("!%s", shell_line);
 		}
 	}
-	fflush (stdout);
+	fflush(stdout);
 	putcerr('\n');
 	promptlen = 0;
 	shellp = 1;
-	execute (filename, shell, shell, "-c", shell_line, 0);
+	execute(filename, shell, shell, "-c", shell_line, 0);
 }
 
-/*
-** Search for nth occurrence of regular expression contained in buf in the file
-*/
-
+/* Search for nth occurrence of regular expression contained in buf in
+ * the file */
 void search(char buf[], FILE *file, register int n)
 {
-    long startline = Ftell (file);
-    register long line1 = startline;
-    register long line2 = startline;
-    register long line3 = startline;
-    register int lncount;
-    int saveln, rv, rc;
-    regex_t re;
-
-    context.line = saveln = Currline;
-    context.chrctr = startline;
-    lncount = 0;
-    if ((rc = regcomp (&re, buf, REG_NOSUB)) != 0) {
-	char s[REGERR_BUF];
-	regerror (rc, &re, s, sizeof s);
-	more_error (s);
-    }
-    while (!feof (file)) {
-	line3 = line2;
-	line2 = line1;
-	line1 = Ftell (file);
-	rdline (file);
-	lncount++;
-	if ((rv = regexec (&re, Line, 0, NULL, 0)) == 0) {
-		if (--n == 0) {
-		    if (lncount > 3 || (lncount > 1 && no_intty))
-		    {
-			putchar('\n');
-			if (clreol)
-			    cleareol ();
-			putsout(_("...skipping\n"));
-		    }
-		    if (!no_intty) {
-			Currline -= (lncount >= 3 ? 3 : lncount);
-			Fseek (file, line3);
-			if (noscroll) {
-			    if (clreol) {
-				home ();
-				cleareol ();
-			    }
-			    else
-				doclear ();
-			}
-		    }
-		    else {
-			kill_line ();
-			if (noscroll) {
-			    if (clreol) {
-			        home ();
-			        cleareol ();
-			    }
-			    else
-				doclear ();
+	long startline = Ftell(file);
+	register long line1 = startline;
+	register long line2 = startline;
+	register long line3 = startline;
+	register int lncount;
+	int saveln, rv, rc;
+	regex_t re;
+
+	context.line = saveln = Currline;
+	context.chrctr = startline;
+	lncount = 0;
+	if ((rc = regcomp(&re, buf, REG_NOSUB)) != 0) {
+		char s[REGERR_BUF];
+		regerror(rc, &re, s, sizeof s);
+		more_error(s);
+	}
+	while (!feof(file)) {
+		line3 = line2;
+		line2 = line1;
+		line1 = Ftell(file);
+		rdline(file);
+		lncount++;
+		if ((rv = regexec(&re, Line, 0, NULL, 0)) == 0) {
+			if (--n == 0) {
+				if (lncount > 3 || (lncount > 1 && no_intty)) {
+					putchar('\n');
+					if (clreol)
+						cleareol();
+					putsout(_("...skipping\n"));
+				}
+				if (!no_intty) {
+					Currline -=
+					    (lncount >= 3 ? 3 : lncount);
+					Fseek(file, line3);
+					if (noscroll) {
+						if (clreol) {
+							home();
+							cleareol();
+						} else
+							doclear();
+					}
+				} else {
+					kill_line();
+					if (noscroll) {
+						if (clreol) {
+							home();
+							cleareol();
+						} else
+							doclear();
+					}
+					puts(Line);
+				}
+				break;
 			}
-			puts(Line);
-		    }
-		    break;
 		}
 	}
-    }
-    if (feof (file)) {
-	if (!no_intty) {
-	    Currline = saveln;
-	    Fseek (file, startline);
-	}
-	else {
-	    putsout(_("\nPattern not found\n"));
-	    end_it (0);
+	if (feof(file)) {
+		if (!no_intty) {
+			Currline = saveln;
+			Fseek(file, startline);
+		} else {
+			putsout(_("\nPattern not found\n"));
+			end_it(0);
+		}
+		more_error(_("Pattern not found"));
+		free(previousre);
+		previousre = NULL;
 	}
-	more_error (_("Pattern not found"));
-	free (previousre);
-	previousre = NULL;
-    }
 }
 
-/*VARARGS2*/
-void execute (char *filename, char *cmd, ...)
+void execute(char *filename, char *cmd, ...)
 {
 	int id;
 	int n;
 	va_list argp;
-	char * arg;
- 	char ** args;
+	char *arg;
+	char **args;
 	int argcount;
 
-	fflush (stdout);
-	reset_tty ();
-	for (n = 10; (id = fork ()) < 0 && n > 0; n--)
-	    sleep (5);
+	fflush(stdout);
+	reset_tty();
+	for (n = 10; (id = fork()) < 0 && n > 0; n--)
+		sleep(5);
 	if (id == 0) {
-	    if (!isatty(0)) {
-		close(0);
-		open("/dev/tty", 0);
-	    }
-
-	    va_start(argp, cmd);
-	    arg = va_arg(argp, char *);
-	    argcount = 0;
-	    while (arg) {
-		argcount++;
-	        arg = va_arg(argp, char *);
-	    }
-	    va_end(argp);
-
-	    args = alloca(sizeof(char *) * (argcount + 1));
-	    args[argcount] = NULL;
-	    
-	    va_start(argp, cmd);
-	    arg = va_arg(argp, char *);
-	    argcount = 0;
-	    while (arg) {
-		args[argcount] = arg;
-		argcount++;
-	        arg = va_arg(argp, char *);
-	    }
-	    va_end(argp);
-	
-	    execvp (cmd, args);
-	    putserr(_("exec failed\n"));
-	    exit (EXIT_FAILURE);
+		if (!isatty(0)) {
+			close(0);
+			open("/dev/tty", 0);
+		}
+
+		va_start(argp, cmd);
+		arg = va_arg(argp, char *);
+		argcount = 0;
+		while (arg) {
+			argcount++;
+			arg = va_arg(argp, char *);
+		}
+		va_end(argp);
+
+		args = alloca(sizeof(char *) * (argcount + 1));
+		args[argcount] = NULL;
+
+		va_start(argp, cmd);
+		arg = va_arg(argp, char *);
+		argcount = 0;
+		while (arg) {
+			args[argcount] = arg;
+			argcount++;
+			arg = va_arg(argp, char *);
+		}
+		va_end(argp);
+
+		execvp(cmd, args);
+		putserr(_("exec failed\n"));
+		exit(EXIT_FAILURE);
 	}
 	if (id > 0) {
-	    signal (SIGINT, SIG_IGN);
-	    signal (SIGQUIT, SIG_IGN);
-	    if (catch_susp)
-		signal(SIGTSTP, SIG_DFL);
-	    while (wait(0) > 0);
-	    signal (SIGINT, end_it);
-	    signal (SIGQUIT, onquit);
-	    if (catch_susp)
-		signal(SIGTSTP, onsusp);
+		signal(SIGINT, SIG_IGN);
+		signal(SIGQUIT, SIG_IGN);
+		if (catch_susp)
+			signal(SIGTSTP, SIG_DFL);
+		while (wait(0) > 0) ;
+		signal(SIGINT, end_it);
+		signal(SIGQUIT, onquit);
+		if (catch_susp)
+			signal(SIGTSTP, onsusp);
 	} else
-	    putserr(_("can't fork\n"));
-	set_tty ();
+		putserr(_("can't fork\n"));
+	set_tty();
 	puts("------------------------");
-	prompt (filename);
+	prompt(filename);
 }
-/*
-** Skip n lines in the file f
-*/
 
-void skiplns (register int n, register FILE *f)
+/* Skip n lines in the file f */
+void skiplns(register int n, register FILE *f)
 {
-    register int c;
+	register int c;
 
-    while (n > 0) {
-	while ((c = Getc (f)) != '\n')
-	    if (c == EOF)
-		return;
-	    n--;
-	    Currline++;
-    }
+	while (n > 0) {
+		while ((c = Getc(f)) != '\n')
+			if (c == EOF)
+				return;
+		n--;
+		Currline++;
+	}
 }
 
-/*
-** Skip nskip files in the file list (from the command line). Nskip may be
-** negative.
-*/
-
-void skipf (register int nskip)
+/* Skip nskip files in the file list (from the command line).  Nskip may
+ * be negative. */
+void skipf(register int nskip)
 {
-    if (nskip == 0) return;
-    if (nskip > 0) {
-	if (fnum + nskip > nfiles - 1)
-	    nskip = nfiles - fnum - 1;
-    }
-    else if (within)
-	++fnum;
-    fnum += nskip;
-    if (fnum < 0)
-	fnum = 0;
-    puts(_("\n...Skipping "));
-    if (clreol)
-	cleareol ();
-    if (nskip > 0)
-	    putsout(_("...Skipping to file "));
-    else
-	    putsout(_("...Skipping back to file "));
-    puts(fnames[fnum]);
-    if (clreol)
-	cleareol ();
-    putchar('\n');
-    --fnum;
+	if (nskip == 0)
+		return;
+	if (nskip > 0) {
+		if (fnum + nskip > nfiles - 1)
+			nskip = nfiles - fnum - 1;
+	} else if (within)
+		++fnum;
+	fnum += nskip;
+	if (fnum < 0)
+		fnum = 0;
+	puts(_("\n...Skipping "));
+	if (clreol)
+		cleareol();
+	if (nskip > 0)
+		putsout(_("...Skipping to file "));
+	else
+		putsout(_("...Skipping back to file "));
+	puts(fnames[fnum]);
+	if (clreol)
+		cleareol();
+	putchar('\n');
+	--fnum;
 }
 
 /*----------------------------- Terminal I/O -------------------------------*/
-
 void initterm()
 {
-    int		ret;
-    char	*padstr;
-    char	*term;
-    struct winsize win;
+	int ret;
+	char *padstr;
+	char *term;
+	struct winsize win;
 
 #ifdef do_SIGTTOU
-retry:
-#endif /* do_SIGTTOU */
-    no_tty = tcgetattr(fileno(stdout), &otty);
-    if (!no_tty) {	
-	docrterase = (otty.c_cc[VERASE] != 255);
-	docrtkill =  (otty.c_cc[VKILL] != 255);
+ retry:
+#endif
+	no_tty = tcgetattr(fileno(stdout), &otty);
+	if (!no_tty) {
+		docrterase = (otty.c_cc[VERASE] != 255);
+		docrtkill = (otty.c_cc[VKILL] != 255);
 #ifdef do_SIGTTOU
-	{
-	    int tgrp;
-	    /*
-	     * Wait until we're in the foreground before we save the
-	     * the terminal modes.
-	     */
-	    if ((tgrp = tcgetpgrp(fileno(stdout))) < 0) {
-		perror("tcgetpgrp");
-		exit(EXIT_FAILURE);
-	    }
-	    if (tgrp != getpgrp(0)) {
-		kill(0, SIGTTOU);
-		goto retry;
-	    }
-	}
-#endif /* do_SIGTTOU */
-	if ((term = getenv("TERM")) == 0) {
-	    dumb++; ul_opt = 0;
-	}
-        my_setupterm(term, 1, &ret);
-	if (ret <= 0) {
-	    dumb++; ul_opt = 0;
-	}
-	else {
+		{
+			int tgrp;
+			/* Wait until we're in the foreground before we
+			 * save the the terminal modes. */
+			if ((tgrp = tcgetpgrp(fileno(stdout))) < 0) {
+				perror("tcgetpgrp");
+				exit(EXIT_FAILURE);
+			}
+			if (tgrp != getpgrp(0)) {
+				kill(0, SIGTTOU);
+				goto retry;
+			}
+		}
+#endif	/* do_SIGTTOU */
+		if ((term = getenv("TERM")) == 0) {
+			dumb++;
+			ul_opt = 0;
+		}
+		my_setupterm(term, 1, &ret);
+		if (ret <= 0) {
+			dumb++;
+			ul_opt = 0;
+		} else {
 #ifdef TIOCGWINSZ
-	    if (ioctl(fileno(stdout), TIOCGWINSZ, &win) < 0) {
-#endif /* TIOCGWINSZ */
-		Lpp = my_tgetnum(TERM_LINES);
-		Mcol = my_tgetnum(TERM_COLS);
+			if (ioctl(fileno(stdout), TIOCGWINSZ, &win) < 0) {
+#endif
+				Lpp = my_tgetnum(TERM_LINES);
+				Mcol = my_tgetnum(TERM_COLS);
 #ifdef TIOCGWINSZ
-	    } else {
-		if ((Lpp = win.ws_row) == 0)
-		    Lpp = my_tgetnum(TERM_LINES);
-		if ((Mcol = win.ws_col) == 0)
-		    Mcol = my_tgetnum(TERM_COLS);
-	    }
-#endif /* TIOCGWINSZ */
-	    if ((Lpp <= 0) || my_tgetflag(TERM_HARD_COPY)) {
-		hard++;	/* Hard copy terminal */
-		Lpp = LINES_PER_PAGE;
-	    }
-
-	    if (my_tgetflag(TERM_EAT_NEW_LINE))
-		eatnl++; /* Eat newline at last column + 1; dec, concept */
-	    if (Mcol <= 0)
-		Mcol = NUM_COLUMNS;
-
-	    Wrap = my_tgetflag(TERM_AUTO_RIGHT_MARGIN);
-	    bad_so = my_tgetflag (TERM_CEOL);
-	    eraseln = my_tgetstr(TERM_CLEAR_TO_LINE_END);
-	    Clear = my_tgetstr(TERM_CLEAR);
-	    Senter = my_tgetstr(TERM_STANDARD_MODE);
-	    Sexit = my_tgetstr(TERM_EXIT_STANDARD_MODE);
-	    if ((soglitch = my_tgetnum(TERM_STD_MODE_GLITCH)) < 0)
-		soglitch = 0;
-
-	    /*
-	     *  Set up for underlining:  some terminals don't need it;
-	     *  others have start/stop sequences, still others have an
-	     *  underline char sequence which is assumed to move the
-	     *  cursor forward one character.  If underline sequence
-	     *  isn't available, settle for standout sequence.
-	     */
-
-	    if (my_tgetflag(TERM_UNDERLINE) || my_tgetflag(TERM_OVER_STRIKE))
-		ul_opt = 0;
-	    if ((chUL = my_tgetstr(TERM_UNDERLINE_CHAR)) == NULL )
-		chUL = "";
-	    if (((ULenter = my_tgetstr(TERM_ENTER_UNDERLINE)) == NULL ||
-	         (ULexit = my_tgetstr(TERM_EXIT_UNDERLINE)) == NULL) && !*chUL) {
-	        if ((ULenter = Senter) == NULL || (ULexit = Sexit) == NULL) {
-			ULenter = "";
-			ULexit = "";
-		} else
-			ulglitch = soglitch;
-	    } else {
-		ulglitch = 0;
-	    }
-
-	    if ((padstr = my_tgetstr(TERM_PAD_CHAR)) != NULL)
-		PC = *padstr;
-	    Home = my_tgetstr(TERM_HOME);
-	    if (Home == 0 || *Home == '\0') {
-		if ((cursorm = my_tgetstr(TERM_CURSOR_ADDRESS)) != NULL) {
-		    const char *t = (const char *)my_tgoto(cursorm, 0, 0);
-		    xstrncpy(cursorhome, t, sizeof(cursorhome));
-		    Home = cursorhome;
-		}
-	    }
-	    EodClr = my_tgetstr(TERM_CLEAR_TO_SCREEN_END);
-	    if ((chBS = my_tgetstr(TERM_LINE_DOWN)) == NULL)
-		chBS = "\b";
+			} else {
+				if ((Lpp = win.ws_row) == 0)
+					Lpp = my_tgetnum(TERM_LINES);
+				if ((Mcol = win.ws_col) == 0)
+					Mcol = my_tgetnum(TERM_COLS);
+			}
+#endif
+			if ((Lpp <= 0) || my_tgetflag(TERM_HARD_COPY)) {
+				hard++;	/* Hard copy terminal */
+				Lpp = LINES_PER_PAGE;
+			}
+
+			if (my_tgetflag(TERM_EAT_NEW_LINE))
+				/* Eat newline at last column + 1; dec, concept */
+				eatnl++;
+			if (Mcol <= 0)
+				Mcol = NUM_COLUMNS;
+
+			Wrap = my_tgetflag(TERM_AUTO_RIGHT_MARGIN);
+			bad_so = my_tgetflag(TERM_CEOL);
+			eraseln = my_tgetstr(TERM_CLEAR_TO_LINE_END);
+			Clear = my_tgetstr(TERM_CLEAR);
+			Senter = my_tgetstr(TERM_STANDARD_MODE);
+			Sexit = my_tgetstr(TERM_EXIT_STANDARD_MODE);
+			if ((soglitch = my_tgetnum(TERM_STD_MODE_GLITCH)) < 0)
+				soglitch = 0;
+
+			/* Set up for underlining:  some terminals don't
+			 * need it; others have start/stop sequences,
+			 * still others have an underline char sequence
+			 * which is assumed to move the cursor forward
+			 * one character.  If underline sequence isn't
+			 * available, settle for standout sequence. */
+			if (my_tgetflag(TERM_UNDERLINE)
+			    || my_tgetflag(TERM_OVER_STRIKE))
+				ul_opt = 0;
+			if ((chUL = my_tgetstr(TERM_UNDERLINE_CHAR)) == NULL)
+				chUL = "";
+			if (((ULenter =
+			      my_tgetstr(TERM_ENTER_UNDERLINE)) == NULL
+			     || (ULexit =
+				 my_tgetstr(TERM_EXIT_UNDERLINE)) == NULL)
+			    && !*chUL) {
+				if ((ULenter = Senter) == NULL
+				    || (ULexit = Sexit) == NULL) {
+					ULenter = "";
+					ULexit = "";
+				} else
+					ulglitch = soglitch;
+			} else {
+				ulglitch = 0;
+			}
 
+			if ((padstr = my_tgetstr(TERM_PAD_CHAR)) != NULL)
+				PC = *padstr;
+			Home = my_tgetstr(TERM_HOME);
+			if (Home == 0 || *Home == '\0') {
+				if ((cursorm =
+				     my_tgetstr(TERM_CURSOR_ADDRESS)) != NULL) {
+					const char *t =
+					    (const char *)my_tgoto(cursorm, 0,
+								   0);
+					xstrncpy(cursorhome, t,
+						 sizeof(cursorhome));
+					Home = cursorhome;
+				}
+			}
+			EodClr = my_tgetstr(TERM_CLEAR_TO_SCREEN_END);
+			if ((chBS = my_tgetstr(TERM_LINE_DOWN)) == NULL)
+				chBS = "\b";
+
+		}
+		if ((shell = getenv("SHELL")) == NULL)
+			shell = "/bin/sh";
+	}
+	no_intty = tcgetattr(fileno(stdin), &otty);
+	tcgetattr(fileno(stderr), &otty);
+	savetty0 = otty;
+	slow_tty = cfgetispeed(&otty) < B1200;
+	hardtabs = (otty.c_oflag & TABDLY) != XTABS;
+	if (!no_tty) {
+		otty.c_lflag &= ~(ICANON | ECHO);
+		otty.c_cc[VMIN] = 1;
+		otty.c_cc[VTIME] = 0;
 	}
-	if ((shell = getenv("SHELL")) == NULL)
-	    shell = "/bin/sh";
-    }
-    no_intty = tcgetattr(fileno(stdin), &otty);
-    tcgetattr(fileno(stderr), &otty);
-    savetty0 = otty;
-    slow_tty = cfgetispeed(&otty) < B1200;
-    hardtabs = (otty.c_oflag & TABDLY) != XTABS;
-    if (!no_tty) {
-	otty.c_lflag &= ~(ICANON|ECHO);
-	otty.c_cc[VMIN] = 1;
-	otty.c_cc[VTIME] = 0;
-    }
 }
 
-int readch () {
+int readch()
+{
 	unsigned char c;
 
 	errno = 0;
-	if (read (fileno(stderr), &c, 1) <= 0) {
+	if (read(fileno(stderr), &c, 1) <= 0) {
 		if (errno != EINTR)
 			end_it(0);
 		else
@@ -1919,279 +1897,281 @@ static char *CARAT = "^";
     else \
 	putserr(BS);
 
-void ttyin (char buf[], register int nmax, char pchar) {
-    char *sp;
-    int c;
-    int slash = 0;
-    int	maxlen;
-
-    sp = buf;
-    maxlen = 0;
-    while (sp - buf < nmax) {
-	if (promptlen > maxlen) maxlen = promptlen;
-	c = readch ();
-	if (c == '\\') {
-	    slash++;
-	}
-	else if (((cc_t) c == otty.c_cc[VERASE]) && !slash) {
-	    if (sp > buf) {
+void ttyin(char buf[], register int nmax, char pchar)
+{
+	char *sp;
+	int c;
+	int slash = 0;
+	int maxlen;
+
+	sp = buf;
+	maxlen = 0;
+	while (sp - buf < nmax) {
+		if (promptlen > maxlen)
+			maxlen = promptlen;
+		c = readch();
+		if (c == '\\') {
+			slash++;
+		} else if (((cc_t) c == otty.c_cc[VERASE]) && !slash) {
+			if (sp > buf) {
 #ifdef HAVE_WIDECHAR
-		if (MB_CUR_MAX > 1)
-		  {
-		    wchar_t wc;
-		    size_t pos = 0, mblength;
-		    mbstate_t state, state_bak;
-
-		    memset (&state, '\0', sizeof (mbstate_t));
-
-		    while (1) {
-			 state_bak = state;
-			 mblength = mbrtowc (&wc, buf + pos, sp - buf, &state);
-
-			 state = (mblength == (size_t)-2
-				 || mblength == (size_t)-1) ? state_bak : state;
-			 mblength = (mblength == (size_t)-2
-				     || mblength == (size_t)-1
-				     || mblength == 0) ? 1 : mblength;
-
-			 if (buf + pos + mblength >= sp)
-			 break;
-
-			 pos += mblength;
-		    }
-
-		    if (mblength == 1) {
-		      ERASEONECOLUMN
-		    }
-		    else {
-			int wc_width;
-			wc_width = wcwidth (wc);
-			wc_width = (wc_width < 1) ? 1 : wc_width;
-			while (wc_width--) {
-			    ERASEONECOLUMN
+				if (MB_CUR_MAX > 1) {
+					wchar_t wc;
+					size_t pos = 0, mblength;
+					mbstate_t state, state_bak;
+
+					memset(&state, '\0', sizeof(mbstate_t));
+
+					while (1) {
+						state_bak = state;
+						mblength =
+						    mbrtowc(&wc, buf + pos,
+							    sp - buf, &state);
+
+						state = (mblength == (size_t)-2
+							 || mblength ==
+							 (size_t)-1) ? state_bak
+						    : state;
+						mblength =
+						    (mblength == (size_t)-2
+						     || mblength == (size_t)-1
+						     || mblength ==
+						     0) ? 1 : mblength;
+
+						if (buf + pos + mblength >= sp)
+							break;
+
+						pos += mblength;
+					}
+
+					if (mblength == 1) {
+					ERASEONECOLUMN} else {
+						int wc_width;
+						wc_width = wcwidth(wc);
+						wc_width =
+						    (wc_width <
+						     1) ? 1 : wc_width;
+						while (wc_width--) {
+						ERASEONECOLUMN}
+					}
+
+					while (mblength--) {
+						--promptlen;
+						--sp;
+					}
+				} else
+#endif	/* HAVE_WIDECHAR */
+				{
+					--promptlen;
+					ERASEONECOLUMN-- sp;
+				}
+
+				if ((*sp < ' ' && *sp != '\n') || *sp == RUBOUT) {
+					--promptlen;
+				ERASEONECOLUMN}
+				continue;
+			} else {
+				if (!eraseln)
+					promptlen = maxlen;
+				siglongjmp(restore, 1);
 			}
-		    }
-
-		    while (mblength--) {
-			--promptlen;
-			--sp;
-		    }
-		  }
-		else
-#endif /* HAVE_WIDECHAR */
-		  {
-		    --promptlen;
-		    ERASEONECOLUMN
-		    --sp;
-		  }
-
-		if ((*sp < ' ' && *sp != '\n') || *sp == RUBOUT) {
-		    --promptlen;
-		    ERASEONECOLUMN
+		} else if (((cc_t) c == otty.c_cc[VKILL]) && !slash) {
+			if (hard) {
+				show(c);
+				putchar('\n');
+				putchar(pchar);
+			} else {
+				putchar('\r');
+				putchar(pchar);
+				if (eraseln)
+					erasep(1);
+				else if (docrtkill)
+					while (promptlen-- > 1)
+						putserr(BSB);
+				promptlen = 1;
+			}
+			sp = buf;
+			fflush(stdout);
+			continue;
 		}
-		continue;
-	    }
-	    else {
-		if (!eraseln) promptlen = maxlen;
-		siglongjmp (restore, 1);
-	    }
-	}
-	else if (((cc_t) c == otty.c_cc[VKILL]) && !slash) {
-	    if (hard) {
-		show (c);
-		putchar ('\n');
-		putchar (pchar);
-	    }
-	    else {
-		putchar ('\r');
-		putchar (pchar);
-		if (eraseln)
-		    erasep (1);
-		else if (docrtkill)
-		    while (promptlen-- > 1)
-			putserr(BSB);
-		promptlen = 1;
-	    }
-	    sp = buf;
-	    fflush (stdout);
-	    continue;
-	}
-	if (slash && ((cc_t) c == otty.c_cc[VKILL]
-		   || (cc_t) c == otty.c_cc[VERASE])) {
-	    ERASEONECOLUMN
-	    --sp;
-	}
-	if (c != '\\')
-	    slash = 0;
-	*sp++ = c;
-	if ((c < ' ' && c != '\n' && c != ESC) || c == RUBOUT) {
-	    c += (c == RUBOUT) ? -0100 : 0100;
-	    putserr(CARAT);
-	    promptlen++;
-	}
-	if (c != '\n' && c != ESC) {
-	    putcerr(c);
-	    promptlen++;
+		if (slash && ((cc_t) c == otty.c_cc[VKILL]
+			      || (cc_t) c == otty.c_cc[VERASE])) {
+			ERASEONECOLUMN-- sp;
+		}
+		if (c != '\\')
+			slash = 0;
+		*sp++ = c;
+		if ((c < ' ' && c != '\n' && c != ESC) || c == RUBOUT) {
+			c += (c == RUBOUT) ? -0100 : 0100;
+			putserr(CARAT);
+			promptlen++;
+		}
+		if (c != '\n' && c != ESC) {
+			putcerr(c);
+			promptlen++;
+		} else
+			break;
 	}
-	else
-	    break;
-    }
-    *--sp = '\0';
-    if (!eraseln) promptlen = maxlen;
-    if (sp - buf >= nmax - 1)
-	more_error (_("Line too long"));
+	*--sp = '\0';
+	if (!eraseln)
+		promptlen = maxlen;
+	if (sp - buf >= nmax - 1)
+		more_error(_("Line too long"));
 }
 
 /* return: 0 - unchanged, 1 - changed, -1 - overflow (unchanged) */
-int expand (char **outbuf, char *inbuf) {
-    char *inpstr;
-    char *outstr;
-    char c;
-    char *temp;
-    int changed = 0;
-    int tempsz, xtra, offset;
-
-    xtra = strlen (fnames[fnum]) + strlen (shell_line) + 1;
-    tempsz = 200 + xtra;
-    temp = xmalloc(tempsz);
-    inpstr = inbuf;
-    outstr = temp;
-    while ((c = *inpstr++) != '\0'){
-	offset = outstr-temp;
-	if (tempsz-offset-1 < xtra) {
-		tempsz += 200 + xtra;
-		temp = xrealloc(temp, tempsz);
-		outstr = temp + offset;
-	}
-	switch (c) {
-	case '%':
-	    if (!no_intty) {
-		strcpy (outstr, fnames[fnum]);
-		outstr += strlen (fnames[fnum]);
-		changed++;
-	    } else
-		*outstr++ = c;
-	    break;
-	case '!':
-	    if (!shellp)
-		more_error (_("No previous command to substitute for"));
-	    strcpy (outstr, shell_line);
-	    outstr += strlen (shell_line);
-	    changed++;
-	    break;
-	case '\\':
-	    if (*inpstr == '%' || *inpstr == '!') {
-		*outstr++ = *inpstr++;
-		break;
-	    }
-	default:
-	    *outstr++ = c;
+int expand(char **outbuf, char *inbuf)
+{
+	char *inpstr;
+	char *outstr;
+	char c;
+	char *temp;
+	int changed = 0;
+	int tempsz, xtra, offset;
+
+	xtra = strlen(fnames[fnum]) + strlen(shell_line) + 1;
+	tempsz = 200 + xtra;
+	temp = xmalloc(tempsz);
+	inpstr = inbuf;
+	outstr = temp;
+	while ((c = *inpstr++) != '\0') {
+		offset = outstr - temp;
+		if (tempsz - offset - 1 < xtra) {
+			tempsz += 200 + xtra;
+			temp = xrealloc(temp, tempsz);
+			outstr = temp + offset;
+		}
+		switch (c) {
+		case '%':
+			if (!no_intty) {
+				strcpy(outstr, fnames[fnum]);
+				outstr += strlen(fnames[fnum]);
+				changed++;
+			} else
+				*outstr++ = c;
+			break;
+		case '!':
+			if (!shellp)
+				more_error(_
+					   ("No previous command to substitute for"));
+			strcpy(outstr, shell_line);
+			outstr += strlen(shell_line);
+			changed++;
+			break;
+		case '\\':
+			if (*inpstr == '%' || *inpstr == '!') {
+				*outstr++ = *inpstr++;
+				break;
+			}
+		default:
+			*outstr++ = c;
+		}
 	}
-    }
-    *outstr++ = '\0';
-    *outbuf = temp;
-    return (changed);
+	*outstr++ = '\0';
+	*outbuf = temp;
+	return (changed);
 }
 
-void show (char c) {
-    if ((c < ' ' && c != '\n' && c != ESC) || c == RUBOUT) {
-	c += (c == RUBOUT) ? -0100 : 0100;
-	putserr(CARAT);
+void show(char c)
+{
+	if ((c < ' ' && c != '\n' && c != ESC) || c == RUBOUT) {
+		c += (c == RUBOUT) ? -0100 : 0100;
+		putserr(CARAT);
+		promptlen++;
+	}
+	putcerr(c);
 	promptlen++;
-    }
-    putcerr(c);
-    promptlen++;
 }
 
-void more_error (char *mess)
+void more_error(char *mess)
 {
-    if (clreol)
-	cleareol ();
-    else
-	kill_line ();
-    promptlen += strlen (mess);
-    if (Senter && Sexit) {
-	my_putstring (Senter);
-	putsout(mess);
-	my_putstring (Sexit);
-    }
-    else
-	putsout(mess);
-    fflush(stdout);
-    errors++;
-    siglongjmp (restore, 1);
+	if (clreol)
+		cleareol();
+	else
+		kill_line();
+	promptlen += strlen(mess);
+	if (Senter && Sexit) {
+		my_putstring(Senter);
+		putsout(mess);
+		my_putstring(Sexit);
+	} else
+		putsout(mess);
+	fflush(stdout);
+	errors++;
+	siglongjmp(restore, 1);
 }
 
-
-void set_tty () {
-	otty.c_lflag &= ~(ICANON|ECHO);
+void set_tty()
+{
+	otty.c_lflag &= ~(ICANON | ECHO);
 	otty.c_cc[VMIN] = 1;	/* read at least 1 char */
 	otty.c_cc[VTIME] = 0;	/* no timeout */
 	stty(fileno(stderr), &otty);
 }
 
-static int
-ourputch(int c) {
+static int ourputch(int c)
+{
 	return putc(c, stdout);
 }
 
-void
-reset_tty () {
-    if (no_tty)
-	return;
-    if (pstate) {
-	tputs(ULexit, fileno(stdout), ourputch);	/* putchar - if that isn't a macro */
-	fflush(stdout);
-	pstate = 0;
-    }
-    otty.c_lflag |= ICANON|ECHO;
-    otty.c_cc[VMIN] = savetty0.c_cc[VMIN];
-    otty.c_cc[VTIME] = savetty0.c_cc[VTIME];
-    stty(fileno(stderr), &savetty0);
+void reset_tty()
+{
+	if (no_tty)
+		return;
+	if (pstate) {
+		/* putchar - if that isn't a macro */
+		tputs(ULexit, fileno(stdout), ourputch);
+		fflush(stdout);
+		pstate = 0;
+	}
+	otty.c_lflag |= ICANON | ECHO;
+	otty.c_cc[VMIN] = savetty0.c_cc[VMIN];
+	otty.c_cc[VTIME] = savetty0.c_cc[VTIME];
+	stty(fileno(stderr), &savetty0);
 }
 
-void rdline (register FILE *f)
+void rdline(register FILE *f)
 {
-    register int  c;
-    register char *p;
+	register int c;
+	register char *p;
 
-    prepare_line_buffer();
+	prepare_line_buffer();
 
-    p = Line;
-    while ((c = Getc (f)) != '\n' && c != EOF && (size_t) (p - Line) < LineLen - 1)
-	*p++ = c;
-    if (c == '\n')
-	Currline++;
-    *p = '\0';
+	p = Line;
+	while ((c = Getc(f)) != '\n' && c != EOF
+	       && (size_t)(p - Line) < LineLen - 1)
+		*p++ = c;
+	if (c == '\n')
+		Currline++;
+	*p = '\0';
 }
 
 /* Come here when we get a suspend signal from the terminal */
-
-void onsusp (int dummy __attribute__ ((__unused__)))
+void onsusp(int dummy __attribute__((__unused__)))
 {
-    sigset_t signals, oldmask;
-
-    /* ignore SIGTTOU so we don't get stopped if csh grabs the tty */
-    signal(SIGTTOU, SIG_IGN);
-    reset_tty ();
-    fflush (stdout);
-    signal(SIGTTOU, SIG_DFL);
-    /* Send the TSTP signal to suspend our process group */
-    signal(SIGTSTP, SIG_DFL);
-
-    /* unblock SIGTSTP or we won't be able to suspend ourself */
-    sigemptyset(&signals);
-    sigaddset(&signals, SIGTSTP);
-    sigprocmask(SIG_UNBLOCK, &signals, &oldmask);
-
-    kill (0, SIGTSTP);
-    /* Pause for station break */
-
-    sigprocmask(SIG_SETMASK, &oldmask, NULL);
-
-    /* We're back */
-    signal (SIGTSTP, onsusp);
-    set_tty ();
-    if (inwait)
-	    siglongjmp (restore, 1);
+	sigset_t signals, oldmask;
+
+	/* ignore SIGTTOU so we don't get stopped if csh grabs the tty */
+	signal(SIGTTOU, SIG_IGN);
+	reset_tty();
+	fflush(stdout);
+	signal(SIGTTOU, SIG_DFL);
+	/* Send the TSTP signal to suspend our process group */
+	signal(SIGTSTP, SIG_DFL);
+
+	/* unblock SIGTSTP or we won't be able to suspend ourself */
+	sigemptyset(&signals);
+	sigaddset(&signals, SIGTSTP);
+	sigprocmask(SIG_UNBLOCK, &signals, &oldmask);
+
+	kill(0, SIGTSTP);
+	/* Pause for station break */
+
+	sigprocmask(SIG_SETMASK, &oldmask, NULL);
+
+	/* We're back */
+	signal(SIGTSTP, onsusp);
+	set_tty();
+	if (inwait)
+		siglongjmp(restore, 1);
 }
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 12/14] more: align void in functions with prototypes, and remove void casts
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
                   ` (10 preceding siblings ...)
  2012-10-08  7:08 ` [PATCH 11/14] more: " Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 13/14] more: remove few memory leaks Sami Kerola
  2012-10-08  7:08 ` [PATCH 14/14] swapon: remove loop declaration [smatch scan] Sami Kerola
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

If there is void in argument list at function prototype it is reasonable
to expect to see it also where the function is wrote.  This change also
removes unnecessary return value void casting.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/more.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/text-utils/more.c b/text-utils/more.c
index d056393..2ecb218 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -582,7 +582,7 @@ FILE *checkf(register char *fs, int *clearfirst)
 	int c;
 
 	if (stat(fs, &stbuf) == -1) {
-		(void)fflush(stdout);
+		fflush(stdout);
 		if (clreol)
 			cleareol();
 		perror(fs);
@@ -593,7 +593,7 @@ FILE *checkf(register char *fs, int *clearfirst)
 		return ((FILE *)NULL);
 	}
 	if ((f = Fopen(fs, "r")) == NULL) {
-		(void)fflush(stdout);
+		fflush(stdout);
 		perror(fs);
 		return ((FILE *)NULL);
 	}
@@ -631,11 +631,11 @@ static int magic(FILE *f, char *fs)
 		case 0x457f:	/* simple ELF detection */
 			printf(_("\n******** %s: Not a text file ********\n\n"),
 			       fs);
-			(void)fclose(f);
+			fclose(f);
 			return 1;
 		}
 	}
-	(void)fseek(f, 0L, SEEK_SET);	/* rewind() not necessary */
+	fseek(f, 0L, SEEK_SET);	/* rewind() not necessary */
 	return 0;
 }
 
@@ -749,7 +749,7 @@ void chgwinsz(int dummy __attribute__((__unused__)))
 		if (win.ws_col != 0)
 			Mcol = win.ws_col;
 	}
-	(void)signal(SIGWINCH, chgwinsz);
+	signal(SIGWINCH, chgwinsz);
 }
 #endif				/* SIGWINCH */
 
@@ -1056,7 +1056,7 @@ void erasep(register int col)
 }
 
 /* Erase the current line entirely */
-void kill_line()
+void kill_line(void)
 {
 	erasep(0);
 	if (!eraseln || dumb)
@@ -1064,12 +1064,12 @@ void kill_line()
 }
 
 /* force clear to end of line */
-void cleareol()
+void cleareol(void)
 {
 	my_putstring(eraseln);
 }
 
-void clreos()
+void clreos(void)
 {
 	my_putstring(EodClr);
 }
@@ -1133,7 +1133,7 @@ void prbuf(register char *s, register int n)
 }
 
 /*  Clear the screen */
-void doclear()
+void doclear(void)
 {
 	if (Clear && !hard) {
 		my_putstring(Clear);
@@ -1145,7 +1145,7 @@ void doclear()
 }
 
 /* Go to home position */
-void home()
+void home(void)
 {
 	my_putstring(Home);
 }
@@ -1743,7 +1743,7 @@ void skipf(register int nskip)
 }
 
 /*----------------------------- Terminal I/O -------------------------------*/
-void initterm()
+void initterm(void)
 {
 	int ret;
 	char *padstr;
@@ -1874,7 +1874,7 @@ void initterm()
 	}
 }
 
-int readch()
+int readch(void)
 {
 	unsigned char c;
 
@@ -2101,7 +2101,7 @@ void more_error(char *mess)
 	siglongjmp(restore, 1);
 }
 
-void set_tty()
+void set_tty(void)
 {
 	otty.c_lflag &= ~(ICANON | ECHO);
 	otty.c_cc[VMIN] = 1;	/* read at least 1 char */
@@ -2114,7 +2114,7 @@ static int ourputch(int c)
 	return putc(c, stdout);
 }
 
-void reset_tty()
+void reset_tty(void)
 {
 	if (no_tty)
 		return;
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 13/14] more: remove few memory leaks
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
                   ` (11 preceding siblings ...)
  2012-10-08  7:08 ` [PATCH 12/14] more: align void in functions with prototypes, and remove void casts Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  2012-10-08  7:08 ` [PATCH 14/14] swapon: remove loop declaration [smatch scan] Sami Kerola
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

The remaining memory leaks are related to ncurses internals, or the one
open file descriptor when user users 'q' to exit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 text-utils/more.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/text-utils/more.c b/text-utils/more.c
index 2ecb218..163f016 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -432,6 +432,7 @@ int main(int argc, char **argv)
 				}
 			}
 			if (srchopt) {
+				free(previousre);
 				previousre = xstrdup(initbuf);
 				search(initbuf, stdin, 1);
 				if (noscroll)
@@ -454,6 +455,7 @@ int main(int argc, char **argv)
 			if (firstf) {
 				firstf = 0;
 				if (srchopt) {
+					free(previousre);
 					previousre = xstrdup(initbuf);
 					search(initbuf, f, 1);
 					if (noscroll)
@@ -509,6 +511,7 @@ int main(int argc, char **argv)
 	}
 	free(previousre);
 	free(initbuf);
+	free(Line);
 	reset_tty();
 	exit(EXIT_SUCCESS);
 }
@@ -766,6 +769,8 @@ void __attribute__((__noreturn__)) end_it(int dummy __attribute__((__unused__)))
 		fflush(stdout);
 	} else
 		putcerr('\n');
+	free(previousre);
+	free(Line);
 	_exit(EXIT_SUCCESS);
 }
 
@@ -1624,6 +1629,7 @@ void search(char buf[], FILE *file, register int n)
 			}
 		}
 	}
+	regfree(&re);
 	if (feof(file)) {
 		if (!no_intty) {
 			Currline = saveln;
@@ -1632,9 +1638,9 @@ void search(char buf[], FILE *file, register int n)
 			putsout(_("\nPattern not found\n"));
 			end_it(0);
 		}
-		more_error(_("Pattern not found"));
 		free(previousre);
 		previousre = NULL;
+		more_error(_("Pattern not found"));
 	}
 }
 
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 14/14] swapon: remove loop declaration [smatch scan]
  2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
                   ` (12 preceding siblings ...)
  2012-10-08  7:08 ` [PATCH 13/14] more: remove few memory leaks Sami Kerola
@ 2012-10-08  7:08 ` Sami Kerola
  13 siblings, 0 replies; 16+ messages in thread
From: Sami Kerola @ 2012-10-08  7:08 UTC (permalink / raw)
  To: util-linux; +Cc: kerolasa

sys-utils/swapon.c:677:2: error: 'for' loop initial declarations are
only allowed in C99 mode

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 sys-utils/swapon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index 3fe6592..f080080 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -642,6 +642,7 @@ static int swapon_all(void)
 
 static void __attribute__ ((__noreturn__)) usage(FILE * out)
 {
+	size_t i;
 	fputs(USAGE_HEADER, out);
 
 	fprintf(out, _(" %s [options] [<spec>]\n"), program_invocation_short_name);
@@ -674,7 +675,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
 		" <file>                 name of file to be used\n"), out);
 
 	fputs(_("\nAvailable columns (for --show):\n"), out);
-	for (size_t i = 0; i < NCOLS; i++)
+	for (i = 0; i < NCOLS; i++)
 		fprintf(out, " %4s  %s\n", infos[i].name, _(infos[i].help));
 
 	fprintf(out, USAGE_MAN_TAIL("swapon(8)"));
-- 
1.7.12.2


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 01/14] ddate: remove from util-linux
  2012-10-08  7:08 ` [PATCH 01/14] ddate: remove from util-linux Sami Kerola
@ 2012-10-08  9:06   ` Petr Uzel
  0 siblings, 0 replies; 16+ messages in thread
From: Petr Uzel @ 2012-10-08  9:06 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

[-- Attachment #1: Type: text/plain, Size: 28273 bytes --]

On Mon, Oct 08, 2012 at 08:08:07AM +0100, Sami Kerola wrote:
> See RedHat bug for reasons why the ddate is cleaned up.  The reference is
> where to get the command in future.
> 
> Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=823156
> References: https://github.com/bo0ts/ddate
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>

Since there is a fork of ddate at github
(https://github.com/bo0ts/ddate) and this IMHO does net belong to
util-linux, feel free to add

Acked-by: Petr Uzel <petr.uzel@suse.cz>

> ---
>  .gitignore                                      |   1 -
>  Documentation/howto-usage-function.txt          |   2 +-
>  Makefile.am                                     |   3 +-
>  configure.ac                                    |  11 -
>  man/ru/ddate.1                                  | 123 --------
>  misc-utils/Makemodule.am                        |   7 -
>  misc-utils/ddate.1                              | 114 --------
>  misc-utils/ddate.c                              | 374 ------------------------
>  tests/expected/build-sys/config-all             |   1 -
>  tests/expected/build-sys/config-all-devel       |   1 -
>  tests/expected/build-sys/config-all-non-nls     |   1 -
>  tests/expected/build-sys/config-devel           |   1 -
>  tests/expected/build-sys/config-devel-new-mount |   1 -
>  tools/checkmans.sh                              |   2 +-
>  14 files changed, 3 insertions(+), 639 deletions(-)
>  delete mode 100644 man/ru/ddate.1
>  delete mode 100644 misc-utils/ddate.1
>  delete mode 100644 misc-utils/ddate.c
> 
> diff --git a/.gitignore b/.gitignore
> index a777d16..e85eb07 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -80,7 +80,6 @@ tests/run.sh.trs
>  /column
>  /ctrlaltdel
>  /cytune
> -/ddate
>  /delpart
>  /dmesg
>  /eject
> diff --git a/Documentation/howto-usage-function.txt b/Documentation/howto-usage-function.txt
> index 70116b2..1944bb7 100644
> --- a/Documentation/howto-usage-function.txt
> +++ b/Documentation/howto-usage-function.txt
> @@ -134,7 +134,7 @@ Some commands use peculiar options and arguments. These are supported,
>  but such will not be accepted in future. See list bellow for a hint what
>  are meant this.
>  
> -- Other than `-' used to define an option. See `+' for `more' or `ddate'
> +- Other than `-' used to define an option. See `+' for `more'
>    commands.
>  - Option string used as an option argument. See `more' command and `-num'.
>  - Short long option. See `setterm'.
> diff --git a/Makefile.am b/Makefile.am
> index a540f0e..6188f49 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -39,7 +39,6 @@ bin_PROGRAMS =
>  sbin_PROGRAMS =
>  dist_usrbin_exec_SCRIPTS =
>  systemdsystemunit_DATA =
> -ruman1_DATA =
>  check_PROGRAMS =
>  TESTS =
>  
> @@ -51,7 +50,7 @@ INSTALL_DATA_HOOKS =
>  CLEAN_LOCALS =
>  CHECK_LOCALS =
>  
> -EXTRA_DIST = man/ru/ddate.1
> +EXTRA_DIST =
>  CLEANFILES =
>  
>  SUBDIRS = po
> diff --git a/configure.ac b/configure.ac
> index 9d2f589..d0a7b57 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -678,7 +678,6 @@ AC_ARG_ENABLE([most-builds],
>  )
>  if test "x$enable_most_builds" = xyes; then
>    enable_arch=check
> -  enable_ddate=yes
>    enable_elvtune=check
>    enable_last=yes
>    enable_line=yes
> @@ -880,16 +879,6 @@ UL_REQUIRES_LINUX([arch])
>  AM_CONDITIONAL(BUILD_ARCH, test "x$build_arch" = xyes)
>  
>  
> -AC_ARG_ENABLE([ddate],
> -  AS_HELP_STRING([--enable-ddate], [do build ddate]),
> -  [], enable_ddate=no
> -)
> -UL_BUILD_INIT([ddate])
> -AM_CONDITIONAL(BUILD_DDATE, test "x$build_ddate" = xyes)
> -ruman1dir='${mandir}/ru/man1'
> -AC_SUBST([ruman1dir])
> -
> -
>  AC_ARG_ENABLE([eject],
>    AS_HELP_STRING([--disable-eject], [do not build eject]),
>    [], enable_eject=check
> diff --git a/man/ru/ddate.1 b/man/ru/ddate.1
> deleted file mode 100644
> index cb10c57..0000000
> --- a/man/ru/ddate.1
> +++ /dev/null
> @@ -1,123 +0,0 @@
> -.\" All Rites Reversed.  This file is in the PUBLIC DOMAIN.
> -.\" Kallisti.
> -.TH DDATE 1 "59 Bureaucracy 3161" "" "Emperor Norton Utilities"
> -.SH ИМЯ
> -ddate \- преобразует дату в григорианском формате в соответствующую дату в 
> -дискордианском формате
> -.SH ОБЗОР
> -.B ddate
> -.RI [ \fB+\fPформат]
> -.RI [ дата ]
> -.SH ОПИСАНИЕ
> -.B ddate
> -выводит дату в дискордианском формате.
> -.PP
> -Если команда 
> -.B ddate
> -вызвана без параметров, она получает текущую системную дату, преобразует её в
> -дискордианский формат и выводит на стандартный вывод. Также можно указать в
> -командной строке дату в григорианском формате, указав в числовом виде день, 
> -месяц и год.
> -.PP
> -Если указан спецификатор формата вывода, дата в дискордианском формате будет
> -отображена в том виде, как это определено спецификатором. Этот механизм 
> -работает подобно механизму форматирования команды
> -.B date(1),
> -но почти полностью иначе. Поля спецификатора следующие:
> -.IP %A
> -Полное название дня недели (например, Sweetmorn)
> -.IP %a
> -День недели в сокращенном формате (например, SM)
> -.IP %B
> -Полное название сезона (времени года) (например, Chaos)
> -.IP %b
> -Сокращенное название сезона (например, Chs)
> -.IP %d
> -Порядковый номер дня в сезоне (например, 23)
> -.IP %e
> -Числовое представление номера дня в сезоне (например, 23rd)
> -.IP %H
> -Название текущего праздника, если таковой имеется
> -.IP %N
> -Волшебный код для предотвращения вывода следующего за ним форматирования,
> -в случае, если дата не является праздником.
> -.IP %n
> -Новая строка
> -.IP %t
> -Табуляция
> -.IP %X
> -Число дней до наступления Дня X (X-Day). Опция не действует, если утилита 
> -без опции SubGenius.
> -.IP %{
> -.IP %}
> -Используется для указания части строки, которая будет заменена словами 
> -"St. Tib's Day", если текущий день является Днем святого Тиба (St. Tib's day).
> -.IP %\.
> -Попробуйте и увидите.
> -.bp
> -.SH ПРИМЕРЫ
> -.nf
> -% ddate
> -.br
> -Sweetmorn, Bureaucracy 42, 3161 YOLD
> -.PP
> -% ddate +'Today is %{%A, the %e of %B%}, %Y. %N%nCelebrate %H'
> -.br
> -Today is Sweetmorn, the 42nd of Bureaucracy, 3161.
> -.PP
> -% ddate +"It's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 26 9 1995
> -.br
> -It's Prickle-Prickle, the 50th of Bureaucracy, 3161.
> -.br
> -Celebrate Bureflux
> -.PP
> -% ddate +"Today's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 29 2 1996
> -.br
> -Today's St. Tib's Day, 3162.
> -.br
> -
> -.SH ОШИБКИ
> -
> -.B ddate(1)
> -будет вести себя непредсказуемо, если попросить вывести дату Дня святого Тиба
> -но строка спецификатора форматирования при этом не содержит разделителей,
> -предусмотренных специально для этого случая (%{ и %}).
> -
> -.SH ЗАМЕЧАНИЯ
> -
> -После того, как День Икс (5 июля 1998 года - прим. пер.) прошел без 
> -происшествий, Церковь СубГения (Church of the SubGenius) провозгласила,
> -что он должен наступить в 'году вверх тормашками' - День Икс наступит в 8661
> -году н. э., а не в 1998 н. э. Таким образом, Истинный День Икс - это 40 день
> -сезона Замешательства 9827 года (Cfn 40, 9827).
> -
> -.SH АВТОРЫ
> -.nh
> -Автор оригинальной программы Druel the Chaotic aka Jeremy Johnson 
> -(mpython@gnu.ai.mit.edu)
> -.br
> -Переписана преимущественно Lee H:. O:. Smith, KYTP, aka Andrew Bulhak 
> -(acb@dev.null.org)
> -.br
> -Пять тонн льна.
> -
> -.SH РАСПРОСТРАНЕНИЕ
> -
> -Свободно распространяемое ПО. Все права защищены.
> -
> -.SH СМ. ТАКЖЕ
> -
> -date(1),
> -.br
> -http://www.subgenius.com/
> -.br
> -Малаклипс Младший (Malaclypse the Younger),
> -.I "Principia Discordia, или Как я нашел Богиню и что я с Ней сделал когда 
> -нашел"
> -
> -.SH ДОСТУПНОСТЬ
> -Команда ddate является частью пакета util-linux и доступна по 
> -ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
> -
> -.SH ПЕРЕВОД
> -Перевод Rino_ap_Codkelden <mavladi@gmail.com> 2010
> \ No newline at end of file
> diff --git a/misc-utils/Makemodule.am b/misc-utils/Makemodule.am
> index 910e428..4c88532 100644
> --- a/misc-utils/Makemodule.am
> +++ b/misc-utils/Makemodule.am
> @@ -52,13 +52,6 @@ CLEANFILES += misc-utils/chkdupexe
>  dist_man_MANS += misc-utils/chkdupexe.1
>  endif
>  
> -if BUILD_DDATE
> -usrbin_exec_PROGRAMS += ddate
> -dist_man_MANS += misc-utils/ddate.1
> -ddate_SOURCES = misc-utils/ddate.c
> -ruman1_DATA += man/ru/ddate.1
> -endif
> -
>  if BUILD_LSLOCKS
>  usrbin_exec_PROGRAMS += lslocks
>  dist_man_MANS += misc-utils/lslocks.8
> diff --git a/misc-utils/ddate.1 b/misc-utils/ddate.1
> deleted file mode 100644
> index 0b01e09..0000000
> --- a/misc-utils/ddate.1
> +++ /dev/null
> @@ -1,114 +0,0 @@
> -.\" All Rites Reversed.  This file is in the PUBLIC DOMAIN.
> -.\" Kallisti.
> -.TH DDATE 1 "Bureaucracy 3161" "util-linux" "Emperor Norton User Command"
> -.SH NAME
> -ddate \- convert Gregorian dates to Discordian dates
> -.SH SYNOPSIS
> -.B ddate
> -.RI [ \fB+\fPformat]
> -.RI [ date ]
> -.SH DESCRIPTION
> -.B ddate
> -prints the date in Discordian date format.
> -.PP
> -If called with no arguments,
> -.B ddate
> -will get the current system date, convert this to the Discordian
> -date format and print this on the standard output. Alternatively, a
> -Gregorian date may be specified on the command line, in the form of a numerical
> -day, month and year.
> -.PP
> -If a format string is specified, the Discordian date will be printed in
> -a format specified by the string. This mechanism works similarly to the
> -format string mechanism of
> -.B date(1),
> -only almost completely differently. The fields are:
> -.IP %A
> -Full name of the day of the week (i.e., Sweetmorn)
> -.IP %a
> -Abbreviated name of the day of the week (i.e., SM)
> -.IP %B
> -Full name of the season (i.e., Chaos)
> -.IP %b
> -Abbreviated name of the season (i.e., Chs)
> -.IP %d
> -Ordinal number of day in season (i.e., 23)
> -.IP %e
> -Cardinal number of day in season (i.e., 23rd)
> -.IP %H
> -Name of current Holyday, if any
> -.IP %N
> -Magic code to prevent rest of format from being printed unless today is
> -a Holyday.
> -.IP %n
> -Newline
> -.IP %t
> -Tab
> -.IP %X
> -Number of days remaining until X-Day. (Not valid if the SubGenius options
> -are not compiled in.)
> -.IP %{
> -.IP %}
> -Used to enclose the part of the string which is to be replaced with the
> -words "St. Tib's Day" if the current day is St. Tib's Day.
> -.IP %\.
> -Try it and see.
> -.bp
> -.SH EXAMPLES
> -.nf
> -% ddate
> -.br
> -Sweetmorn, Bureaucracy 42, 3161 YOLD
> -.PP
> -% ddate +'Today is %{%A, the %e of %B%}, %Y. %N%nCelebrate %H'
> -.br
> -Today is Sweetmorn, the 42nd of Bureaucracy, 3161.
> -.PP
> -% ddate +"It's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 26 9 1995
> -.br
> -It's Prickle-Prickle, the 50th of Bureaucracy, 3161.
> -.br
> -Celebrate Bureflux
> -.PP
> -% ddate +"Today's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 29 2 1996
> -.br
> -Today's St. Tib's Day, 3162.
> -.br
> -
> -.SH BUGS
> -
> -.B ddate(1)
> -will produce undefined behavior if asked to produce the date for St. Tib's
> -day and its format string does not contain the St. Tib's Day delimiters
> -%{ and %}.
> -
> -.SH NOTE
> -
> -After `X-Day' passed without incident, the Church of the SubGenius
> -declared that it had got the year upside down - X-Day is actually in 8661 AD
> -rather than 1998 AD.  Thus, the True X-Day is Cfn 40, 9827.
> -
> -.SH AUTHOR
> -.nh
> -Original program by Druel the Chaotic aka Jeremy Johnson (mpython@gnu.ai.mit.edu)
> -.br
> -Major rewrite by Lee H:. O:. Smith, KYTP, aka Andrew Bulhak (acb@dev.null.org)
> -.br
> -Five tons of flax.
> -
> -.SH DISTRIBUTION POLICY
> -
> -Public domain. All rites reversed.
> -
> -.SH SEE ALSO
> -
> -date(1),
> -.br
> -http://www.subgenius.com/
> -.br
> -Malaclypse the Younger,
> -.I "Principia Discordia, Or How I Found Goddess And What I Did To Her When I Found Her"
> -
> -.SH AVAILABILITY
> -The ddate command is part of the util-linux package and is available from
> -ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
> diff --git a/misc-utils/ddate.c b/misc-utils/ddate.c
> deleted file mode 100644
> index c0b4ce4..0000000
> --- a/misc-utils/ddate.c
> +++ /dev/null
> @@ -1,374 +0,0 @@
> -/* $ DVCS ID: $jer|,523/lhos,KYTP!41023161\b"?" <<= DO NOT DELETE! */
> -
> -/* ddate.c .. converts boring normal dates to fun Discordian Date -><-
> -   written  the 65th day of The Aftermath in the Year of Our Lady of 
> -   Discord 3157 by Druel the Chaotic aka Jeremy Johnson aka
> -   mpython@gnu.ai.mit.edu  
> -      28 Sever St Apt #3
> -      Worcester MA 01609
> -
> -   and I'm not responsible if this program messes anything up (except your 
> -   mind, I'm responsible for that)
> -
> -   (k) YOLD 3161 and all time before and after.
> -   Reprint, reuse, and recycle what you wish.
> -   This program is in the public domain.  Distribute freely.  Or not.
> -
> -   Majorly hacked, extended and bogotified/debogotified on 
> -   Sweetmorn, Bureaucracy 42, 3161 YOLD, by Lee H:. O:. Smith, KYTP, 
> -   aka Andrew Bulhak, aka acb@dev.null.org
> -
> -   and I'm not responsible if this program messes anything up (except your 
> -   mind, I'm responsible for that) (and that goes for me as well --lhos)
> -
> -   Version history:
> -   Bureflux 3161:      First release of enhanced ddate with format strings
> -   59 Bcy, 3161:       PRAISE_BOB and KILL_BOB options split, other minor
> -                       changes.
> -
> -   1999-02-22 Arkadiusz Miskiewicz <misiek@pld.ORG.PL>
> -   - added Native Language Support
> -
> -   2000-03-17 Burt Holzman <bnh@iname.com>
> -   - added range checks for dates
> -*/
> -
> -/* configuration options  VVVVV   READ THIS!!! */
> -
> -/* If you wish ddate(1) to print the date in the same format as Druel's 
> - * original ddate when called in immediate mode, define OLD_IMMEDIATE_FMT 
> - */
> -
> -#define OLD_IMMEDIATE_FMT
> -
> -/* If you wish to use the US format for aneristic dates (m-d-y), as opposed to
> - * the Commonwealth format, define US_FORMAT.
> - */
> -
> -/* #define US_FORMAT */
> -
> -/* If you are ideologically, theologically or otherwise opposed to the 
> - * Church of the SubGenius and do not wish your copy of ddate(1) to contain
> - * code for counting down to X-Day, undefine KILL_BOB */
> -
> -#define KILL_BOB 13013
> -
> -/* If you wish ddate(1) to contain SubGenius slogans, define PRAISE_BOB */
> -
> -/*#define PRAISE_BOB 13013*/
> -
> -#include <stdlib.h>
> -#include <string.h>
> -#include <time.h>
> -#include <stdio.h>
> -
> -#include "nls.h"
> -#include "closestream.h"
> -#include "c.h"
> -
> -#ifndef __GNUC__
> -#define inline /* foo */
> -#endif
> -
> -#ifdef KILL_BOB
> -int xday_countdown(int yday, int year);
> -#endif
> -
> -
> -/* string constants */
> -
> -char *day_long[5] = { 
> -    "Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"
> -};
> -
> -char *day_short[5] = {"SM","BT","PD","PP","SO"};
> -
> -char *season_long[5] = { 
> -    "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"
> -};
> -
> -char *season_short[5] = {"Chs", "Dsc", "Cfn", "Bcy", "Afm"};
> -
> -char *holyday[5][2] = { 
> -    { "Mungday", "Chaoflux" },
> -    { "Mojoday", "Discoflux" },
> -    { "Syaday",  "Confuflux" },
> -    { "Zaraday", "Bureflux" },
> -    { "Maladay", "Afflux" }
> -};
> -
> -struct disc_time {
> -    int season; /* 0-4 */
> -    int day; /* 0-72 */
> -    int yday; /* 0-365 */
> -    int year; /* 3066- */
> -};
> -
> -char *excl[] = {
> -    "Hail Eris!", "All Hail Discordia!", "Kallisti!", "Fnord.", "Or not.",
> -    "Wibble.", "Pzat!", "P'tang!", "Frink!",
> -#ifdef PRAISE_BOB
> -    "Slack!", "Praise \"Bob\"!", "Or kill me.",
> -#endif /* PRAISE_BOB */
> -    /* randomness, from the Net and other places. Feel free to add (after
> -       checking with the relevant authorities, of course). */
> -    "Grudnuk demand sustenance!", "Keep the Lasagna flying!",
> -    "You are what you see.",
> -    "Or is it?", "This statement is false.",
> -#if defined(linux) || defined (__linux__) || defined (__linux)
> -    "Hail Eris, Hack Linux!",
> -#endif
> -    ""
> -};
> -
> -char default_fmt[] = "%{%A, %B %d%}, %Y YOLD";
> -char *default_immediate_fmt=
> -#ifdef OLD_IMMEDIATE_FMT
> -"Today is %{%A, the %e day of %B%} in the YOLD %Y%N%nCelebrate %H"
> -#else
> -default_fmt
> -#endif
> -;
> -
> -#define DY(y) (y+1166)
> -
> -static inline char *ending(int i) {
> -	return i/10==1?"th":(i%10==1?"st":(i%10==2?"nd":(i%10==3?"rd":"th")));
> -}
> -
> -static inline int leapp(int i) {
> -	return (!(DY(i)%4))&&((DY(i)%100)||(!(DY(i)%400)));
> -}
> -
> -/* select a random string */
> -static inline char *sel(char **strings, int num) {
> -	return(strings[random()%num]);
> -}
> -
> -void print(struct disc_time,char **); /* old */
> -void format(char *buf, const char* fmt, struct disc_time dt);
> -/* read a fortune file */
> -int load_fortunes(char *fn, char *delim, char** result);
> -
> -struct disc_time convert(int,int);
> -struct disc_time makeday(int,int,int);
> -
> -int
> -main (int argc, char *argv[]) {
> -    long t;
> -    struct tm *eris;
> -    int bob,raw;
> -    struct disc_time hastur;
> -    char schwa[23*17], *fnord=0;
> -    int pi;
> -    char *progname, *p;
> -
> -    progname = argv[0];
> -    if ((p = strrchr(progname, '/')) != NULL)
> -	progname = p+1;
> -
> -    setlocale(LC_ALL, "");
> -    bindtextdomain(PACKAGE, LOCALEDIR);
> -    textdomain(PACKAGE);
> -    atexit(close_stdout);
> -
> -    srandom(time(NULL));
> -    /* do args here */
> -    for(pi=1; pi<argc; pi++) {
> -	switch(argv[pi][0]) {
> -	case '+': fnord=argv[pi]+1; break;
> -	case '-': 
> -	    switch(argv[pi][1]) {
> -	    case 'V':
> -		printf(_("%s (%s)\n"), progname, PACKAGE_STRING);
> -	    default: goto usage;
> -	    }
> -	default: goto thud;
> -	}
> -    }
> -
> -  thud:
> -    if (argc-pi==3){ 
> -	int moe=atoi(argv[pi]), larry=atoi(argv[pi+1]), curly=atoi(argv[pi+2]);
> -	hastur=makeday(
> -#ifdef US_FORMAT
> -	    moe,larry,
> -#else
> -	    larry,moe,
> -#endif
> -	    curly);
> -	if (hastur.season == -1) {
> -		printf("Invalid date -- out of range\n");
> -		return -1;
> -	}
> -	fnord=fnord?fnord:default_fmt;
> -    } else if (argc!=pi) { 
> -      usage:
> -	fprintf(stderr,_("usage: %s [+format] [day month year]\n"), argv[0]);
> -	exit(1);
> -    } else {
> -	t= time(NULL);
> -	eris=localtime(&t);
> -	bob=eris->tm_yday; /* days since Jan 1. */
> -	raw=eris->tm_year; /* years since 1980 */
> -	hastur=convert(bob,raw);
> -	fnord=fnord?fnord:default_immediate_fmt;
> -    }
> -    format(schwa, fnord, hastur);
> -    printf("%s\n", schwa);
> -   
> -    return 0;
> -}
> -
> -void format(char *buf, const char* fmt, struct disc_time dt)
> -{
> -    int tib_start=-1, tib_end=0;
> -    int i, fmtlen=strlen(fmt);
> -    char *bufptr=buf;
> -
> -/*    fprintf(stderr, "format(%p, \"%s\", dt)\n", buf, fmt);*/
> -
> -    /* first, find extents of St. Tib's Day area, if defined */
> -    for(i=0; i<fmtlen; i++) {
> -	if(fmt[i]=='%') {
> -	    switch(fmt[i+1]) {
> -	    case 'A':
> -	    case 'a':
> -	    case 'd':
> -	    case 'e':
> -		if(tib_start>0)	    tib_end=i+1;
> -		else		    tib_start=i;
> -		break;
> -	    case '{': tib_start=i; break;
> -	    case '}': tib_end=i+1; break;
> -	    }
> -	}
> -    }
> -
> -    /* now do the formatting */
> -    buf[0]=0;
> -
> -    for(i=0; i<fmtlen; i++) {
> -	if((i==tib_start) && (dt.day==-1)) {
> -	    /* handle St. Tib's Day */
> -	    strcpy(bufptr, _("St. Tib's Day"));
> -	    bufptr += strlen(bufptr);
> -	    i=tib_end;
> -	} else {
> -	    if(fmt[i]=='%') {
> -		char *wibble=0, snarf[23];
> -		switch(fmt[++i]) {
> -		case 'A': wibble=day_long[dt.yday%5]; break;
> -		case 'a': wibble=day_short[dt.yday%5]; break;
> -		case 'B': wibble=season_long[dt.season]; break;
> -		case 'b': wibble=season_short[dt.season]; break;
> -		case 'd': sprintf(snarf, "%d", dt.day+1); wibble=snarf; break;
> -		case 'e': sprintf(snarf, "%d%s", dt.day+1, ending(dt.day+1)); 
> -		    wibble=snarf; break;
> -		case 'H': if(dt.day==4||dt.day==49)
> -		    wibble=holyday[dt.season][dt.day==49]; break;
> -		case 'N': if(dt.day!=4&&dt.day!=49) goto eschaton; break;
> -		case 'n': *(bufptr++)='\n'; break;
> -		case 't': *(bufptr++)='\t'; break;
> -
> -		case 'Y': sprintf(snarf, "%d", dt.year); wibble=snarf; break;
> -		case '.': wibble=sel(excl, ARRAY_SIZE(excl));
> -		    break;
> -#ifdef KILL_BOB
> -		case 'X': sprintf(snarf, "%d", 
> -				  xday_countdown(dt.yday, dt.year));
> -				  wibble = snarf; break;
> -#endif /* KILL_BOB */
> -		}
> -		if(wibble) {
> -/*		    fprintf(stderr, "wibble = (%s)\n", wibble);*/
> -		    strcpy(bufptr, wibble); bufptr+=strlen(wibble);
> -		}
> -	    } else {
> -		*(bufptr++) = fmt[i];
> -	    }
> -	}
> -    }
> -  eschaton:
> -    *(bufptr)=0;
> -}
> -
> -struct disc_time makeday(int imonth,int iday,int iyear) /*i for input */
> -{ 
> -    struct disc_time funkychickens;
> -    
> -    int cal[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
> -    int dayspast=0;
> -
> -    memset(&funkychickens,0,sizeof(funkychickens));
> -    /* basic range checks */
> -    if (imonth < 1 || imonth > 12) {
> -	    funkychickens.season = -1;
> -	    return funkychickens;
> -    }
> -    if (iday < 1 || iday > cal[imonth-1]) {
> -	    if (!(imonth == 2 && iday == 29 && iyear%4 == 0 &&
> -		  (iyear%100 != 0 || iyear%400 == 0))) {
> -		    funkychickens.season = -1;
> -		    return funkychickens;
> -	    }
> -    }
> -    
> -    imonth--;
> -    funkychickens.year= iyear+1166;
> -    while(imonth>0) { dayspast+=cal[--imonth]; }
> -    funkychickens.day=dayspast+iday-1;
> -    funkychickens.season=0;
> -    if((funkychickens.year%4)==2) {
> -	if (funkychickens.day==59 && iday==29)  funkychickens.day=-1;
> -    }
> -    funkychickens.yday=funkychickens.day;
> -/*               note: EQUAL SIGN...hopefully that fixes it */
> -    while(funkychickens.day>=73) {
> -	funkychickens.season++;
> -	funkychickens.day-=73;
> -    }
> -    return funkychickens;
> -}
> -
> -struct disc_time convert(int nday, int nyear)
> -{  struct disc_time funkychickens;
> -   
> -   funkychickens.year = nyear+3066;
> -   funkychickens.day=nday;
> -   funkychickens.season=0;
> -   if ((funkychickens.year%4)==2)
> -     {if (funkychickens.day==59)
> -	funkychickens.day=-1;
> -     else if (funkychickens.day >59)
> -       funkychickens.day-=1;
> -    }
> -   funkychickens.yday=funkychickens.day;
> -   while (funkychickens.day>=73)
> -     { funkychickens.season++;
> -       funkychickens.day-=73;
> -     }
> -   return funkychickens;
> -  
> - }
> -
> -#ifdef KILL_BOB
> -
> -/* Code for counting down to X-Day, X-Day being Cfn 40, 3164 
> - *
> - * After `X-Day' passed without incident, the CoSG declared that it had 
> - * got the year upside down --- X-Day is actually in 8661 AD rather than 
> - * 1998 AD.
> - *
> - * Thus, the True X-Day is Cfn 40, 9827.
> - *
> - */
> -
> -int xday_countdown(int yday, int year) {
> -    int r=(185-yday)+(((yday<59)&&(leapp(year)))?1:0);
> -    while(year<9827) r+=(leapp(++year)?366:365);
> -    while(year>9827) r-=(leapp(year--)?366:365);
> -    return r;
> -}
> -
> -#endif
> diff --git a/tests/expected/build-sys/config-all b/tests/expected/build-sys/config-all
> index c31bc40..e5888dd 100644
> --- a/tests/expected/build-sys/config-all
> +++ b/tests/expected/build-sys/config-all
> @@ -36,7 +36,6 @@ colrm:
>  column:  
>  ctrlaltdel:  
>  cytune:  
> -ddate:  
>  delpart:  
>  dmesg:  
>  elvtune:  
> diff --git a/tests/expected/build-sys/config-all-devel b/tests/expected/build-sys/config-all-devel
> index 4b31e7e..1be319b 100644
> --- a/tests/expected/build-sys/config-all-devel
> +++ b/tests/expected/build-sys/config-all-devel
> @@ -54,7 +54,6 @@ uuidd:  libuuid
>  uuidgen:  libuuid 
>  wipefs:  libblkid libuuid 
>  cal:  libncursesw libtinfo 
> -ddate:  
>  kill:  
>  logger:  
>  look:  
> diff --git a/tests/expected/build-sys/config-all-non-nls b/tests/expected/build-sys/config-all-non-nls
> index c31bc40..e5888dd 100644
> --- a/tests/expected/build-sys/config-all-non-nls
> +++ b/tests/expected/build-sys/config-all-non-nls
> @@ -36,7 +36,6 @@ colrm:
>  column:  
>  ctrlaltdel:  
>  cytune:  
> -ddate:  
>  delpart:  
>  dmesg:  
>  elvtune:  
> diff --git a/tests/expected/build-sys/config-devel b/tests/expected/build-sys/config-devel
> index a2e0411..cb7fad3 100644
> --- a/tests/expected/build-sys/config-devel
> +++ b/tests/expected/build-sys/config-devel
> @@ -36,7 +36,6 @@ colrm:
>  column:  
>  ctrlaltdel:  
>  cytune:  
> -ddate:  
>  delpart:  
>  dmesg:  
>  elvtune:  
> diff --git a/tests/expected/build-sys/config-devel-new-mount b/tests/expected/build-sys/config-devel-new-mount
> index 74c35c7..7e83630 100644
> --- a/tests/expected/build-sys/config-devel-new-mount
> +++ b/tests/expected/build-sys/config-devel-new-mount
> @@ -56,7 +56,6 @@ uuidgen:  libuuid
>  wipefs:  libblkid libuuid 
>  blkid.static: STATIC
>  cal:  libncursesw libtinfo 
> -ddate:  
>  kill:  
>  logger:  
>  look:  
> diff --git a/tools/checkmans.sh b/tools/checkmans.sh
> index e54ebed..4b149d0 100755
> --- a/tools/checkmans.sh
> +++ b/tools/checkmans.sh
> @@ -39,7 +39,7 @@ trap "rm -f ${ERROR_FILE}" 0
>  
>  for I in $(
>  	find $(git rev-parse --show-toplevel) -name '*.[1-8]' |
> -	egrep -v '(Documentation|.git|/.libs/|autom4te.cache|ru/ddate)'
> +	egrep -v '(Documentation|.git|/.libs/|autom4te.cache)'
>  ); do
>  	# FIXME: the determination whether a manual does include
>  	# should probably be somewhat smarter.
> -- 
> 1.7.12.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Petr

-- 
Petr Uzel
IRC: ptr_uzl @ freenode

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-10-08  9:07 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-08  7:08 [PATCH 00/14] various: clean ups and fixes Sami Kerola
2012-10-08  7:08 ` [PATCH 01/14] ddate: remove from util-linux Sami Kerola
2012-10-08  9:06   ` Petr Uzel
2012-10-08  7:08 ` [PATCH 02/14] column: add --output-separator option Sami Kerola
2012-10-08  7:08 ` [PATCH 03/14] docs: fix column.1 groff syntax error Sami Kerola
2012-10-08  7:08 ` [PATCH 04/14] pg: refactor argument handing Sami Kerola
2012-10-08  7:08 ` [PATCH 05/14] pg: use libc error printing facilities Sami Kerola
2012-10-08  7:08 ` [PATCH 06/14] pg: add const qualifiers where suitable Sami Kerola
2012-10-08  7:08 ` [PATCH 07/14] pg: add noreturn function attributes Sami Kerola
2012-10-08  7:08 ` [PATCH 08/14] pg: use unistd.h STDOUT_FILENO Sami Kerola
2012-10-08  7:08 ` [PATCH 09/14] pg: do not turn off warnigns artificially Sami Kerola
2012-10-08  7:08 ` [PATCH 10/14] pg: fix coding style Sami Kerola
2012-10-08  7:08 ` [PATCH 11/14] more: " Sami Kerola
2012-10-08  7:08 ` [PATCH 12/14] more: align void in functions with prototypes, and remove void casts Sami Kerola
2012-10-08  7:08 ` [PATCH 13/14] more: remove few memory leaks Sami Kerola
2012-10-08  7:08 ` [PATCH 14/14] swapon: remove loop declaration [smatch scan] Sami Kerola

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).