most.c (most-5.1.0) | : | most.c (most-5.2.0) | ||
---|---|---|---|---|
/* | /* | |||
This file is part of MOST. | This file is part of MOST. | |||
Copyright (c) 1991, 1999, 2002, 2005-2018, 2019 John E. Davis | Copyright (c) 1991, 1999, 2002, 2005-2021, 2022 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 53 | skipping to change at line 53 | |||
#include "jdmacros.h" | #include "jdmacros.h" | |||
#include "most.h" | #include "most.h" | |||
#include "search.h" | #include "search.h" | |||
#include "window.h" | #include "window.h" | |||
#include "file.h" | #include "file.h" | |||
#include "sysdep.h" | #include "sysdep.h" | |||
#include "keym.h" | #include "keym.h" | |||
#include "display.h" | #include "display.h" | |||
#include "line.h" | #include "line.h" | |||
#include "keyparse.h" | ||||
int Most_S_Opt = 0; /* squeeze liness */ | int Most_S_Opt = 0; /* squeeze liness */ | |||
int Most_A_Opt = 1; /* automatically choose -b if necessary */ | int Most_A_Opt = 1; /* automatically choose -b if necessary */ | |||
int Most_V_Opt = 0; /* display control chars */ | int Most_V_Opt = 0; /* display control chars */ | |||
int Most_B_Opt = 0; /* display Binary File */ | int Most_B_Opt = 0; /* display Binary File */ | |||
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; | |||
skipping to change at line 430 | skipping to change at line 431 | |||
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; | int quit,i,piped; | |||
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 503 | skipping to change at line 504 | |||
} | } | |||
Most_Num_Files = 0; | Most_Num_Files = 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 (); | (void) 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 */ | |||
if (!piped) | if (piped) | |||
{ | { | |||
file_i = i; | do_most(NULL, Most_Starting_Line); | |||
most_exit_most (); | ||||
return status; | ||||
} | ||||
#ifdef VMS | #ifdef VMS | |||
while(i < argc) | while(i < argc) | |||
{ | ||||
if (Most_Num_Files >= MOST_MAX_FILES) break; | ||||
if (argv[i][0] == '.') strcpy(file,"*"); else *file = 0; | ||||
strcat(file, most_unix2vms(argv[i++])); | ||||
while (RMS$_NORMAL == (status = most_expand_file_name(file,filename))) | ||||
{ | { | |||
if (Most_Num_Files >= MOST_MAX_FILES) break; | Most_File_Ring[Most_Num_Files] = (char*) MOSTMALLOC(strlen(filename) | |||
if (argv[i][0] == '.') strcpy(file,"*"); else *file = 0; | + 1); | |||
strcat(file, most_unix2vms(argv[i++])); | strcpy(Most_File_Ring[Most_Num_Files++], filename); | |||
while (RMS$_NORMAL == (status = most_expand_file_name(file,filename) | ||||
)) | ||||
{ | ||||
Most_File_Ring[Most_Num_Files] = (char*) MOSTMALLOC(strlen(file | ||||
name) + 1); | ||||
strcpy(Most_File_Ring[Most_Num_Files++], filename); | ||||
} | ||||
if (status == RMS$_NMF) status = RMS$_NORMAL; /* avoid spurious warn | ||||
ing message */ | ||||
} | } | |||
if (status == RMS$_NMF) status = RMS$_NORMAL; /* avoid spurious warning m | ||||
essage */ | ||||
} | ||||
if (Most_Num_Files) strcpy(file,Most_File_Ring[0]); | if (Most_Num_Files) strcpy(file,Most_File_Ring[0]); | |||
else fputs("%%MOST-W-NOFILES, no files found\n", stderr); | else fputs("%%MOST-W-NOFILES, no files found\n", stderr); | |||
#else | #else | |||
Most_Num_Files = argc - i; | Most_Num_Files = argc - i; | |||
if (Most_Num_Files > MOST_MAX_FILES) | if (Most_Num_Files > MOST_MAX_FILES) | |||
{ | { | |||
Most_Num_Files = MOST_MAX_FILES; | Most_Num_Files = MOST_MAX_FILES; | |||
argc = Most_Num_Files + i; | argc = Most_Num_Files + i; | |||
} | } | |||
j = 0; | j = 0; | |||
while (i < argc) | while (i < argc) | |||
{ | ||||
if (argv[i][0] == 0) /* no filename */ | ||||
{ | { | |||
Most_File_Ring[j++] = argv[i++]; | i++; | |||
Most_Num_Files--; | ||||
} | } | |||
#endif | else Most_File_Ring[j++] = argv[i++]; | |||
} | } | |||
#endif | ||||
if (Most_Num_Files || piped) do_most(file, Most_Starting_Line); | if (Most_Num_Files) | |||
else if (Most_Num_Files == 0) | do_most(Most_File_Ring[0], Most_Starting_Line); | |||
fprintf(stderr,"File %s not found\n", argv[file_i]); | else | |||
fprintf(stderr,"No files were found\n"); | ||||
most_exit_most (); | most_exit_most (); | |||
return status; | return status; | |||
} | } | |||
#if SLANG_VERSION <= 10409 | #if SLANG_VERSION <= 10409 | |||
int SLang_set_error (int x) | int SLang_set_error (int x) | |||
{ | { | |||
SLang_Error = x; | SLang_Error = x; | |||
End of changes. 16 change blocks. | ||||
33 lines changed or deleted | 42 lines changed or added |