"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "main.c" between
less-530.tar.gz and less-548.tar.gz

About: less is a file pager (a program that displays text files similar to "more" or "pg"). Beta version.

main.c  (less-530):main.c  (less-548)
/* /*
* Copyright (C) 1984-2017 Mark Nudelman * Copyright (C) 1984-2018 Mark Nudelman
* *
* You may distribute under the terms of either the GNU General Public * You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file. * License or the Less License, as specified in the README file.
* *
* For more information, see the README file. * For more information, see the README file.
*/ */
/* /*
* Entry point, initialization, miscellaneous routines. * Entry point, initialization, miscellaneous routines.
*/ */
#include "less.h" #include "less.h"
#if MSDOS_COMPILER==WIN32C #if MSDOS_COMPILER==WIN32C
#define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#endif #endif
public char * every_first_cmd = NULL; public char * every_first_cmd = NULL;
public int new_file; public int new_file;
public int is_tty; public int is_tty;
public IFILE curr_ifile = NULL_IFILE; public IFILE curr_ifile = NULL_IFILE;
public IFILE old_ifile = NULL_IFILE; public IFILE old_ifile = NULL_IFILE;
public struct scrpos initial_scrpos; public struct scrpos initial_scrpos;
public int any_display = FALSE; public int any_display = FALSE;
skipping to change at line 55 skipping to change at line 56
#if TAGS #if TAGS
extern char * tags; extern char * tags;
extern char * tagoption; extern char * tagoption;
extern int jump_sline; extern int jump_sline;
#endif #endif
#ifdef WIN32 #ifdef WIN32
static char consoleTitle[256]; static char consoleTitle[256];
#endif #endif
public int line_count; public int one_screen;
extern int less_is_more; extern int less_is_more;
extern int missing_cap; extern int missing_cap;
extern int know_dumb; extern int know_dumb;
extern int pr_type; extern int pr_type;
extern int quit_if_one_screen; extern int quit_if_one_screen;
extern int no_init;
/* /*
* Entry point. * Entry point.
*/ */
int int
main(argc, argv) main(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
{ {
IFILE ifile; IFILE ifile;
skipping to change at line 83 skipping to change at line 85
#ifdef __EMX__ #ifdef __EMX__
_response(&argc, &argv); _response(&argc, &argv);
_wildcard(&argc, &argv); _wildcard(&argc, &argv);
#endif #endif
progname = *argv++; progname = *argv++;
argc--; argc--;
secure = 0; secure = 0;
s = lgetenv("LESSSECURE"); s = lgetenv("LESSSECURE");
if (s != NULL && *s != '\0') if (!isnullenv(s))
secure = 1; secure = 1;
#ifdef WIN32 #ifdef WIN32
if (getenv("HOME") == NULL) if (getenv("HOME") == NULL)
{ {
/* /*
* If there is no HOME environment variable, * If there is no HOME environment variable,
* try the concatenation of HOMEDRIVE + HOMEPATH. * try the concatenation of HOMEDRIVE + HOMEPATH.
*/ */
char *drive = getenv("HOMEDRIVE"); char *drive = getenv("HOMEDRIVE");
skipping to change at line 113 skipping to change at line 115
} }
} }
GetConsoleTitle(consoleTitle, sizeof(consoleTitle)/sizeof(char)); GetConsoleTitle(consoleTitle, sizeof(consoleTitle)/sizeof(char));
#endif /* WIN32 */ #endif /* WIN32 */
/* /*
* Process command line arguments and LESS environment arguments. * Process command line arguments and LESS environment arguments.
* Command line arguments override environment arguments. * Command line arguments override environment arguments.
*/ */
is_tty = isatty(1); is_tty = isatty(1);
init_mark();
init_cmds(); init_cmds();
get_term(); get_term();
expand_cmd_tables(); expand_cmd_tables();
init_charset(); init_charset();
init_line(); init_line();
init_cmdhist(); init_cmdhist();
init_option(); init_option();
init_search(); init_search();
/* /*
* If the name of the executable program is "more", * If the name of the executable program is "more",
* act like LESS_IS_MORE is set. * act like LESS_IS_MORE is set.
*/ */
for (s = progname + strlen(progname); s > progname; s--) s = last_component(progname);
{
if (s[-1] == PATHNAME_SEP[0])
break;
}
if (strcmp(s, "more") == 0) if (strcmp(s, "more") == 0)
less_is_more = 1; less_is_more = 1;
init_prompt(); init_prompt();
s = lgetenv(less_is_more ? "MORE" : "LESS"); s = lgetenv(less_is_more ? "MORE" : "LESS");
if (s != NULL) if (s != NULL)
scan_option(save(s)); scan_option(save(s));
#define isoptstring(s) (((s)[0] == '-' || (s)[0] == '+') && (s)[1] != '\ 0') #define isoptstring(s) (((s)[0] == '-' || (s)[0] == '+') && (s)[1] != '\ 0')
skipping to change at line 166 skipping to change at line 165
*/ */
nopendopt(); nopendopt();
quit(QUIT_OK); quit(QUIT_OK);
} }
#if EDITOR #if EDITOR
editor = lgetenv("VISUAL"); editor = lgetenv("VISUAL");
if (editor == NULL || *editor == '\0') if (editor == NULL || *editor == '\0')
{ {
editor = lgetenv("EDITOR"); editor = lgetenv("EDITOR");
if (editor == NULL || *editor == '\0') if (isnullenv(editor))
editor = EDIT_PGM; editor = EDIT_PGM;
} }
editproto = lgetenv("LESSEDIT"); editproto = lgetenv("LESSEDIT");
if (editproto == NULL || *editproto == '\0') if (isnullenv(editproto))
editproto = "%E ?lm+%lm. %f"; editproto = "%E ?lm+%lm. %g";
#endif #endif
/* /*
* Call get_ifile with all the command line filenames * Call get_ifile with all the command line filenames
* to "register" them with the ifile system. * to "register" them with the ifile system.
*/ */
ifile = NULL_IFILE; ifile = NULL_IFILE;
if (dohelp) if (dohelp)
ifile = get_ifile(FAKE_HELPFILE, ifile); ifile = get_ifile(FAKE_HELPFILE, ifile);
while (argc-- > 0) while (argc-- > 0)
skipping to change at line 221 skipping to change at line 220
/* /*
* Set up terminal, etc. * Set up terminal, etc.
*/ */
if (!is_tty) if (!is_tty)
{ {
/* /*
* Output is not a tty. * Output is not a tty.
* Just copy the input file(s) to output. * Just copy the input file(s) to output.
*/ */
SET_BINARY(1); SET_BINARY(1);
if (nifile() == 0) if (edit_first() == 0)
{
if (edit_stdin() == 0)
cat_file();
} else if (edit_first() == 0)
{ {
do { do {
cat_file(); cat_file();
} while (edit_next(1) == 0); } while (edit_next(1) == 0);
} }
quit(QUIT_OK); quit(QUIT_OK);
} }
if (missing_cap && !know_dumb) if (missing_cap && !know_dumb)
error("WARNING: terminal is not fully functional", NULL_PARG); error("WARNING: terminal is not fully functional", NULL_PARG);
init_mark();
open_getchr(); open_getchr();
raw_mode(1); raw_mode(1);
init_signals(1); init_signals(1);
/* /*
* Select the first file to examine. * Select the first file to examine.
*/ */
#if TAGS #if TAGS
if (tagoption != NULL || strcmp(tags, "-") == 0) if (tagoption != NULL || strcmp(tags, "-") == 0)
{ {
skipping to change at line 271 skipping to change at line 265
/* /*
* Search for the line which contains the tag. * Search for the line which contains the tag.
* Set up initial_scrpos so we display that line. * Set up initial_scrpos so we display that line.
*/ */
initial_scrpos.pos = tagsearch(); initial_scrpos.pos = tagsearch();
if (initial_scrpos.pos == NULL_POSITION) if (initial_scrpos.pos == NULL_POSITION)
quit(QUIT_ERROR); quit(QUIT_ERROR);
initial_scrpos.ln = jump_sline; initial_scrpos.ln = jump_sline;
} else } else
#endif #endif
if (nifile() == 0)
{ {
if (edit_stdin()) /* Edit standard input */ if (edit_first())
quit(QUIT_ERROR);
if (quit_if_one_screen)
line_count = get_line_count();
} else
{
if (edit_first()) /* Edit first valid file in cmd line */
quit(QUIT_ERROR); quit(QUIT_ERROR);
/*
* See if file fits on one screen to decide whether
* to send terminal init. But don't need this
* if -X (no_init) overrides this (see init()).
*/
if (quit_if_one_screen) if (quit_if_one_screen)
{ {
if (nifile() == 1) if (nifile() > 1) /* If more than one file, -F cannot be
line_count = get_line_count(); used */
else /* If more than one file, -F can not be used */
quit_if_one_screen = FALSE; quit_if_one_screen = FALSE;
else if (!no_init)
one_screen = get_one_screen();
} }
} }
init(); init();
commands(); commands();
quit(QUIT_OK); quit(QUIT_OK);
/*NOTREACHED*/ /*NOTREACHED*/
return (0); return (0);
} }
 End of changes. 16 change blocks. 
28 lines changed or deleted 21 lines changed or added

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