"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/most.c" between
most-5.0.0a.tar.gz and most-5.1.0.tar.gz

About: most is a textfile paging program (supports multiple windows and can scroll left and right).

most.c  (most-5.0.0a):most.c  (most-5.1.0)
/* /*
This file is part of MOST. This file is part of MOST.
Copyright (c) 1991, 1999, 2002, 2005, 2006, 2007 John E. Davis Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) Software Foundation; either version 2 of the License, or (at your option)
any later version. any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details. more details.
skipping to change at line 68 skipping to change at line 68
int Most_T_Opt = 0; /* display tab as ^I-- valid only with V o ption */ int Most_T_Opt = 0; /* display tab as ^I-- valid only with V o ption */
int Most_D_Opt = 0; /* delete file mode (see ':D') */ int Most_D_Opt = 0; /* delete file mode (see ':D') */
int Most_K_Opt = 0; /* Display 8 bit unformatted (Kanji) */ int Most_K_Opt = 0; /* Display 8 bit unformatted (Kanji) */
int Most_Z_Opt = 0; /* Gunzip on the fly */ int Most_Z_Opt = 0; /* Gunzip on the fly */
int Most_Want_Exit; int Most_Want_Exit;
int Most_Secure_Mode; int Most_Secure_Mode;
int Most_Captive_Mode; int Most_Captive_Mode;
#if MOST_HAS_MMAP #if MOST_HAS_MMAP
int Most_Disable_MMap = 0; int Most_Disable_MMap = 0;
#endif #endif
int Most_Do_Regexp_Search = 0;
int Most_UTF8_Mode = -1; /* -1:auto, 0:off, 1:on */ int Most_UTF8_Mode = -1; /* -1:auto, 0:off, 1:on */
static int Most_Starting_Line; static int Most_Starting_Line;
char *Most_Program; /* Program Name (argv[0]) */ char *Most_Program; /* Program Name (argv[0]) */
static char *Most_Version = MOST_VERSION_STR; static char *Most_Version = MOST_VERSION_STR;
#ifdef VMS #ifdef VMS
# ifndef isalpha # ifndef isalpha
# define isalpha(x) \ # define isalpha(x) \
(((x >= 'A') && (x <= 'Z'))||((x >= 'a') && (x <= 'z')) ? 1 : 0) (((x >= 'A') && (x <= 'Z'))||((x >= 'a') && (x <= 'z')) ? 1 : 0)
# endif # endif
#endif #endif
void most_usage (void) void most_usage (void)
{ {
fprintf(stderr,"MOST version %s (S-Lang version %s)\n", fprintf(stderr,"MOST version %s (S-Lang version %s)\n",
Most_Version, SLang_Version_String); Most_Version, SLang_Version_String);
if (SLang_Version != SLANG_VERSION) if (SLang_Version != SLANG_VERSION)
fprintf (stderr, " *Note: This executable was compiled against S-Lang %s\n" , SLANG_VERSION_STRING); fprintf (stderr, " *Note: This executable was compiled against S-Lang %s\n" , SLANG_VERSION_STRING);
fprintf (stderr, "Usage:\n"); fprintf (stderr, "Usage:\n");
fprintf(stderr, "most [-1Cbcdkstvw] [+/string] [+line number] [+s] [+d] file. ..\n"); fprintf(stderr, "most [-1Cbcdkrstvw] [+/string] [+line number] [+s] [+d] file ...\n");
fputs(" where: -1: assume VT100 terminal. (VMS only)\n", stderr); fputs(" where: -1: assume VT100 terminal. (VMS only)\n", stderr);
fputs(" -b: Startup in binary mode.\n", stderr); fputs(" -b: Startup in binary mode.\n", stderr);
fputs(" -C: disable color support\n", stderr); fputs(" -C: disable color support\n", stderr);
fputs(" -c: Make searches case sensitive.\n", stderr); fputs(" -c: Make searches case sensitive.\n", stderr);
fputs(" -d: Do not display the \\ wrap marker when wrapping lines.\n" , stderr); fputs(" -d: Do not display the \\ wrap marker when wrapping lines.\n" , stderr);
/* fputs(" -k: Kanji mode.\n", stderr); */ /* fputs(" -k: Kanji mode.\n", stderr); */
#if MOST_HAS_MMAP #if MOST_HAS_MMAP
fputs(" -M: Do not attempt to mmap files.\n", stderr); fputs(" -M: Do not attempt to mmap files.\n", stderr);
#endif #endif
fputs(" -r: Default to regexp search\n", stderr);
fputs(" -s: Squeeze out excess blank lines.\n", stderr); fputs(" -s: Squeeze out excess blank lines.\n", stderr);
fputs(" -t: Display tabs as ^I. If this option is immediately follow ed\n", stderr); fputs(" -t: Display tabs as ^I. If this option is immediately follow ed\n", stderr);
fputs(" by an integer, the integer sets the tab width.\n", stde rr); fputs(" by an integer, the integer sets the tab width.\n", stde rr);
fputs(" -u: Disable UTF-8 mode\n", stderr); fputs(" -u: Disable UTF-8 mode\n", stderr);
fputs(" -v: Do not interpret backspace formatting characters.\n", std err); fputs(" -v: Do not interpret backspace formatting characters.\n", std err);
fputs(" -w: Wrap lines.\n", stderr); fputs(" -w: Wrap lines.\n", stderr);
fputs(" -z: No gunzip-on-the-fly.\n", stderr); fputs(" -z: No gunzip-on-the-fly.\n", stderr);
fputs(" +/string:\n", stderr); fputs(" +/string:\n", stderr);
fputs(" Search for string\n", stderr); fputs(" Search for string\n", stderr);
fputs(" +line number\n", stderr); fputs(" +line number\n", stderr);
skipping to change at line 217 skipping to change at line 219
case 'C': case 'C':
No_Colors = 1; No_Colors = 1;
break; break;
case 'c': case 'c':
Most_Case_Sensitive = 1; Most_Case_Sensitive = 1;
break; break;
case 'd': case 'd':
case 'D': case 'D':
Most_Show_Wrap_Marker = 0; Most_Show_Wrap_Marker = 0;
break;
case 'r':
Most_Do_Regexp_Search = 1;
break;
case 's': case 's':
case 'S': case 'S':
Most_S_Opt = 1; break; Most_S_Opt = 1; break;
case 'V': case 'V':
case 'v': case 'v':
Most_V_Opt = 1; /* verbose-- convert control chars to '^' 'ch' */ Most_V_Opt = 1; /* verbose-- convert control chars to '^' 'ch' */
break; break;
case 'W': case 'W':
case 'w': Most_W_Opt = 1; break; case 'w': Most_W_Opt = 1; break;
skipping to change at line 324 skipping to change at line 330
} }
while ((n = fread(buf, 1, 4096 * 4, fp)) > 0) while ((n = fread(buf, 1, 4096 * 4, fp)) > 0)
{ {
int m; int m;
m = fwrite (buf, 1, n, stdout); m = fwrite (buf, 1, n, stdout);
if (m != n) if (m != n)
{ {
fprintf (stderr, "fwrite returned %d, errno = %d\n", fprintf (stderr, "fwrite returned %d, errno = %d\n",
m, errno); m, errno);
(void) fclose (fp);
exit (1); exit (1);
} }
} }
(void) fclose (fp);
} }
void most_initialize_most (void) void most_initialize_most (void)
{ {
Most_S_Opt = 0; Most_S_Opt = 0;
Most_A_Opt = 1; Most_A_Opt = 1;
Most_V_Opt = 0; Most_V_Opt = 0;
Most_B_Opt = 0; Most_B_Opt = 0;
Most_T_Opt = 0; Most_T_Opt = 0;
Most_D_Opt = 0; Most_D_Opt = 0;
skipping to change at line 352 skipping to change at line 360
Most_Top_Win = Most_Win = NULL; Most_Top_Win = Most_Win = NULL;
Most_Buf = NULL; Most_Buf = NULL;
Most_Eob = NULL; Most_Eob = NULL;
Most_Beg = NULL; Most_Beg = NULL;
Most_Captive_Mode = Most_Secure_Mode = 0; Most_Captive_Mode = Most_Secure_Mode = 0;
Most_Want_Exit = 0; Most_Want_Exit = 0;
} }
static void do_most (char *file, int start) static void do_most (char *file, int start)
{ {
int piped;
MOST_INT row, col; MOST_INT row, col;
most_get_cdir(Most_C_Dir); most_get_cdir(Most_C_Dir);
row = col = 0; row = col = 0;
if (file[0] == '\0') piped = 1; else piped = 0;
if ((-1 == most_find_file (file)) if ((-1 == most_find_file (file))
&& (Most_Num_Files == 1)) && (Most_Num_Files == 1))
most_exit_error ("%s: failed to open for reading.", file); most_exit_error ("%s: failed to open for reading.", file);
most_init_display (); most_init_display ();
most_goto_line(start); most_goto_line(start);
Most_Curs_Offset = Most_C_Offset; Most_Curs_Offset = Most_C_Offset;
skipping to change at line 424 skipping to change at line 430
if (utf8_mode == 1) if (utf8_mode == 1)
(void) SLsmg_utf8_enable (0); /* locale is UTF-8, but -u passed */ (void) SLsmg_utf8_enable (0); /* locale is UTF-8, but -u passed */
else else
(void) SLsmg_utf8_enable (1); /* locale not UTF-8, but +u passed */ (void) SLsmg_utf8_enable (1); /* locale not UTF-8, but +u passed */
} }
} }
int most (int argc, char **argv) int most (int argc, char **argv)
{ {
char file[MAX_PATHLEN], *switches; char file[MAX_PATHLEN], *switches;
int file_i = 0, quit,i,piped,a_opt; int file_i = 0, quit,i,piped;
unsigned long context;
int status = 0; int status = 0;
#ifdef VMS #ifdef VMS
char filename[256]; char filename[256];
#else #else
int j; int j;
#endif #endif
Most_Program = argv[0]; Most_Program = argv[0];
piped = 0; piped = 0;
skipping to change at line 491 skipping to change at line 496
file[sizeof(file)-1] = 0; file[sizeof(file)-1] = 0;
} }
if (!isatty(fileno(stdout))) if (!isatty(fileno(stdout)))
{ {
while (i < argc) play_cat(argv[i++]); while (i < argc) play_cat(argv[i++]);
exit(0); exit(0);
} }
Most_Num_Files = 0; Most_Num_Files = 0;
context = 0;
SLtt_get_terminfo(); SLtt_get_terminfo();
utf8_config (); utf8_config ();
SLtt_Ignore_Beep = 1; SLtt_Ignore_Beep = 1;
if (No_Colors) if (No_Colors)
SLtt_Use_Ansi_Colors = 0; SLtt_Use_Ansi_Colors = 0;
most_setup_colors (); most_setup_colors ();
most_init_tty (); most_init_tty ();
most_init_keymaps (); most_init_keymaps ();
if (Most_B_Opt) Most_A_Opt = 0; /* explicit b overrides a */ if (Most_B_Opt) Most_A_Opt = 0; /* explicit b overrides a */
a_opt = Most_A_Opt;
if (!piped) if (!piped)
{ {
file_i = i; file_i = i;
#ifdef VMS #ifdef VMS
while(i < argc) while(i < argc)
{ {
if (Most_Num_Files >= MOST_MAX_FILES) break; if (Most_Num_Files >= MOST_MAX_FILES) break;
if (argv[i][0] == '.') strcpy(file,"*"); else *file = 0; if (argv[i][0] == '.') strcpy(file,"*"); else *file = 0;
strcat(file, most_unix2vms(argv[i++])); strcat(file, most_unix2vms(argv[i++]));
 End of changes. 13 change blocks. 
9 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)