From a8f98304e6d2f4627ca31f6c661934c92b1095f7 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Thu, 19 Apr 2018 22:46:27 +0100 Subject: more: reorder global declarations Group include, defines and such together, and move items inbetween functions on top of the source file so that everything can be seen easily. Signed-off-by: Sami Kerola --- text-utils/more.c | 96 +++++++++++++++++++++++++++---------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'text-utils/more.c') diff --git a/text-utils/more.c b/text-utils/more.c index 7df04de7b..d3317cf9c 100644 --- a/text-utils/more.c +++ b/text-utils/more.c @@ -59,6 +59,15 @@ #include #include #include +#include + +#if defined(HAVE_NCURSESW_TERM_H) +# include +#elif defined(HAVE_NCURSES_TERM_H) +# include +#elif defined(HAVE_TERM_H) +# include +#endif #include "strutils.h" #include "nls.h" @@ -66,8 +75,6 @@ #include "widechar.h" #include "closestream.h" -#include - #ifdef TEST_PROGRAM # define NON_INTERACTIVE_MORE 1 #endif @@ -89,6 +96,14 @@ #define stty(fd,argp) tcsetattr(fd,TCSANOW,argp) +#define ERASEONECOLUMN(x) \ + do { \ + if (x) \ + putserr(BSB); \ + else \ + putserr(BS); \ + } while(0) + #define TBUFSIZ 1024 #define LINSIZ 256 /* minimal Line buffer size */ #define ctrl(letter) (letter & 077) @@ -103,6 +118,29 @@ #define SHELL_LINE 1000 #define COMMAND_BUF 200 #define REGERR_BUF NUM_COLUMNS +#define STOP -10 + +#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 struct termios otty, savetty0; static long file_pos, file_size; @@ -158,35 +196,15 @@ static struct { } context, screen_start; extern char PC; /* pad character */ -#if defined(HAVE_NCURSESW_TERM_H) -# include -#elif defined(HAVE_NCURSES_TERM_H) -# include -#elif defined(HAVE_TERM_H) -# include -#endif +static char *BS = "\b"; +static char *BSB = "\b \b"; +static char *CARAT = "^"; + +static char ch; +static int lastcmd, lastarg, lastp; +static int lastcolon; +static char shell_line[SHELL_LINE]; -#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 putstring(char *s) { @@ -733,8 +751,6 @@ static int readch(void) return (c); } -static char ch; - /* Read a decimal number from the terminal. Set cmd to the non-digit * which terminates the number. */ static int number(char *cmd) @@ -785,17 +801,6 @@ static void skipf(register int nskip) --fnum; } -static char *BS = "\b"; -static char *BSB = "\b \b"; -static char *CARAT = "^"; -#define ERASEONECOLUMN(x) \ - do { \ - if (x) \ - putserr(BSB); \ - else \ - putserr(BS); \ - } while(0) - static void show(char c) { if ((c < ' ' && c != '\n' && c != ESC) || c == RUBOUT) { @@ -952,10 +957,6 @@ static void ttyin(char buf[], register int nmax, char pchar) more_error(_("Line too long")); } -static int lastcmd, lastarg, lastp; -static int lastcolon; -static char shell_line[SHELL_LINE]; - /* return: 0 - unchanged, 1 - changed, -1 - overflow (unchanged) */ static int expand(char **outbuf, char *inbuf) { @@ -1615,7 +1616,6 @@ static int command(char *filename, register FILE *f) } /* Print out the contents of the file f, one screenful at a time. */ -#define STOP -10 static void screen(register FILE *f, register int num_lines) { register int c; -- cgit v1.2.3-55-g7522