per DB's patch, convert a few parts of files.c to use bool so that
open_pipe()'s failure is handled properly again, and add various #ifdefs to fix a few warnings and compilation problems that occur when everything is enabled manually including NANO_SMALL git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1886 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
ce62e82a93
commit
00d7798756
|
@ -76,8 +76,13 @@ CVS code -
|
||||||
Changes to src/Marefile.am. (DLR)
|
Changes to src/Marefile.am. (DLR)
|
||||||
- Move the static int pid to the beginning of nano.c with all
|
- Move the static int pid to the beginning of nano.c with all
|
||||||
the other static variables. (DLR)
|
the other static variables. (DLR)
|
||||||
|
- Consolidate some if blocks to remove some redundant code.
|
||||||
|
(David Benbennick)
|
||||||
- Fix warnings when compiling with ENABLE_NLS undefined and with
|
- Fix warnings when compiling with ENABLE_NLS undefined and with
|
||||||
-the fwritable-strings option. (David Benbennick)
|
-the fwritable-strings option. (David Benbennick)
|
||||||
|
- Add various #ifdefs to fix warnings and compilation problems
|
||||||
|
when compiling with every option manually turned on, including
|
||||||
|
NANO_SMALL. (David Benbennick)
|
||||||
- files.c:
|
- files.c:
|
||||||
close_open_file()
|
close_open_file()
|
||||||
- Tweak to no longer rely on the return values of
|
- Tweak to no longer rely on the return values of
|
||||||
|
|
38
src/files.c
38
src/files.c
|
@ -338,8 +338,9 @@ void read_file(FILE *f, const char *filename, int quiet)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the file (and decide if it exists). */
|
/* Open the file (and decide if it exists). Return TRUE on success,
|
||||||
int open_file(const char *filename, int insert, int quiet)
|
* FALSE on failure. */
|
||||||
|
bool open_file(const char *filename, int insert, int quiet)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
@ -348,7 +349,7 @@ int open_file(const char *filename, int insert, int quiet)
|
||||||
if (filename[0] == '\0' || stat(filename, &fileinfo) == -1) {
|
if (filename[0] == '\0' || stat(filename, &fileinfo) == -1) {
|
||||||
if (insert && !quiet) {
|
if (insert && !quiet) {
|
||||||
statusbar(_("\"%s\" not found"), filename);
|
statusbar(_("\"%s\" not found"), filename);
|
||||||
return -1;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
/* We have a new file */
|
/* We have a new file */
|
||||||
statusbar(_("New File"));
|
statusbar(_("New File"));
|
||||||
|
@ -361,7 +362,7 @@ int open_file(const char *filename, int insert, int quiet)
|
||||||
_("File \"%s\" is a device file"), filename);
|
_("File \"%s\" is a device file"), filename);
|
||||||
if (!insert)
|
if (!insert)
|
||||||
new_file();
|
new_file();
|
||||||
return -1;
|
return FALSE;
|
||||||
} else if ((fd = open(filename, O_RDONLY)) == -1) {
|
} else if ((fd = open(filename, O_RDONLY)) == -1) {
|
||||||
/* If we're in multibuffer mode, don't be quiet when an error
|
/* If we're in multibuffer mode, don't be quiet when an error
|
||||||
occurs while opening a file */
|
occurs while opening a file */
|
||||||
|
@ -373,7 +374,7 @@ int open_file(const char *filename, int insert, int quiet)
|
||||||
statusbar("%s: %s", strerror(errno), filename);
|
statusbar("%s: %s", strerror(errno), filename);
|
||||||
if (!insert)
|
if (!insert)
|
||||||
new_file();
|
new_file();
|
||||||
return -1;
|
return FALSE;
|
||||||
} else { /* File is A-OK */
|
} else { /* File is A-OK */
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
statusbar(_("Reading File"));
|
statusbar(_("Reading File"));
|
||||||
|
@ -381,7 +382,7 @@ int open_file(const char *filename, int insert, int quiet)
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
nperror("fdopen");
|
nperror("fdopen");
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return FALSE;
|
||||||
}
|
}
|
||||||
read_file(f, filename, quiet);
|
read_file(f, filename, quiet);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
|
@ -389,7 +390,7 @@ int open_file(const char *filename, int insert, int quiet)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function will return the name of the first available extension
|
/* This function will return the name of the first available extension
|
||||||
|
@ -426,6 +427,8 @@ char *get_next_filename(const char *name)
|
||||||
void do_insertfile(int loading_file)
|
void do_insertfile(int loading_file)
|
||||||
{
|
{
|
||||||
int i, old_current_x = current_x;
|
int i, old_current_x = current_x;
|
||||||
|
bool opened;
|
||||||
|
/* TRUE if the file opened successfully. */
|
||||||
char *realname = NULL;
|
char *realname = NULL;
|
||||||
static char *inspath = NULL;
|
static char *inspath = NULL;
|
||||||
|
|
||||||
|
@ -550,11 +553,11 @@ void do_insertfile(int loading_file)
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (i == NANO_EXTCMD_KEY) {
|
if (i == NANO_EXTCMD_KEY) {
|
||||||
realname = mallocstrcpy(realname, "");
|
realname = mallocstrcpy(realname, "");
|
||||||
i = open_pipe(answer);
|
opened = open_pipe(answer);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
realname = real_dir_from_tilde(answer);
|
realname = real_dir_from_tilde(answer);
|
||||||
i = open_file(realname, TRUE, loading_file);
|
opened = open_file(realname, TRUE, loading_file);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -566,7 +569,7 @@ void do_insertfile(int loading_file)
|
||||||
created to hold the file), reload the buffer we had open
|
created to hold the file), reload the buffer we had open
|
||||||
before, and skip the insertion; otherwise, save realname
|
before, and skip the insertion; otherwise, save realname
|
||||||
in filename and continue the insertion */
|
in filename and continue the insertion */
|
||||||
if (i == -1) {
|
if (!opened) {
|
||||||
free(realname);
|
free(realname);
|
||||||
free(fileage);
|
free(fileage);
|
||||||
load_open_file();
|
load_open_file();
|
||||||
|
@ -597,20 +600,11 @@ void do_insertfile(int loading_file)
|
||||||
|
|
||||||
/* And re-init the shortcut list */
|
/* And re-init the shortcut list */
|
||||||
shortcut_init(FALSE);
|
shortcut_init(FALSE);
|
||||||
}
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
|
||||||
if (!loading_file) {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Restore the old x-coordinate position */
|
/* Restore the old x-coordinate position */
|
||||||
current_x = old_current_x;
|
current_x = old_current_x;
|
||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* If we've gone off the bottom, recenter; otherwise, just redraw */
|
/* If we've gone off the bottom, recenter; otherwise, just redraw */
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
|
|
||||||
|
@ -2675,8 +2669,12 @@ char *do_browser(const char *inpath)
|
||||||
case NANO_HELP_KEY:
|
case NANO_HELP_KEY:
|
||||||
case NANO_HELP_FKEY:
|
case NANO_HELP_FKEY:
|
||||||
case '?': /* Pico compatibility */
|
case '?': /* Pico compatibility */
|
||||||
|
#ifndef DISABLE_HELP
|
||||||
do_help();
|
do_help();
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
|
#else
|
||||||
|
nano_disabled_msg();
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case NANO_ENTER_KEY:
|
case NANO_ENTER_KEY:
|
||||||
case 'S': /* Pico compatibility */
|
case 'S': /* Pico compatibility */
|
||||||
|
|
|
@ -282,25 +282,31 @@ void shortcut_init(int unjustify)
|
||||||
const char *nano_tab_msg = N_("Insert a tab character");
|
const char *nano_tab_msg = N_("Insert a tab character");
|
||||||
const char *nano_enter_msg =
|
const char *nano_enter_msg =
|
||||||
N_("Insert a carriage return at the cursor position");
|
N_("Insert a carriage return at the cursor position");
|
||||||
|
#ifndef NANO_SMALL
|
||||||
const char *nano_nextword_msg = N_("Move forward one word");
|
const char *nano_nextword_msg = N_("Move forward one word");
|
||||||
const char *nano_prevword_msg = N_("Move backward one word");
|
const char *nano_prevword_msg = N_("Move backward one word");
|
||||||
|
#endif
|
||||||
const char *nano_verbatim_msg = N_("Insert character(s) verbatim");
|
const char *nano_verbatim_msg = N_("Insert character(s) verbatim");
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
const char *nano_openprev_msg = N_("Switch to previous file buffer");
|
const char *nano_openprev_msg = N_("Switch to previous file buffer");
|
||||||
const char *nano_opennext_msg = N_("Switch to next file buffer");
|
const char *nano_opennext_msg = N_("Switch to next file buffer");
|
||||||
#endif
|
#endif
|
||||||
#if !defined(NANO_SMALL) && defined(HAVE_REGEX_H)
|
#ifndef NANO_SMALL
|
||||||
|
#ifdef HAVE_REGEX_H
|
||||||
const char *nano_bracket_msg = N_("Find other bracket");
|
const char *nano_bracket_msg = N_("Find other bracket");
|
||||||
#endif
|
#endif
|
||||||
const char *nano_whereis_next_msg = N_("Repeat last search");
|
const char *nano_whereis_next_msg = N_("Repeat last search");
|
||||||
|
#endif
|
||||||
const char *nano_cancel_msg = N_("Cancel the current function");
|
const char *nano_cancel_msg = N_("Cancel the current function");
|
||||||
const char *nano_firstline_msg = N_("Go to the first line of the file");
|
const char *nano_firstline_msg = N_("Go to the first line of the file");
|
||||||
const char *nano_lastline_msg = N_("Go to the last line of the file");
|
const char *nano_lastline_msg = N_("Go to the last line of the file");
|
||||||
|
#ifndef DISABLE_JUSTIFY
|
||||||
const char *nano_parabegin_msg =
|
const char *nano_parabegin_msg =
|
||||||
N_("Go to the beginning of the current paragraph");
|
N_("Go to the beginning of the current paragraph");
|
||||||
const char *nano_paraend_msg =
|
const char *nano_paraend_msg =
|
||||||
N_("Go to the end of the current paragraph");
|
N_("Go to the end of the current paragraph");
|
||||||
const char *nano_fulljustify_msg = N_("Justify the entire file");
|
const char *nano_fulljustify_msg = N_("Justify the entire file");
|
||||||
|
#endif
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
const char *nano_case_msg =
|
const char *nano_case_msg =
|
||||||
N_("Make the current search/replace case (in)sensitive");
|
N_("Make the current search/replace case (in)sensitive");
|
||||||
|
|
|
@ -912,6 +912,7 @@ void do_mouse(void)
|
||||||
xcur = actual_x(current->data, get_page_start(xplustabs()) +
|
xcur = actual_x(current->data, get_page_start(xplustabs()) +
|
||||||
mouse_x);
|
mouse_x);
|
||||||
|
|
||||||
|
#ifndef NANO_SMALL
|
||||||
/* Selecting where the cursor is toggles the mark, as does
|
/* Selecting where the cursor is toggles the mark, as does
|
||||||
selecting beyond the line length with the cursor at the
|
selecting beyond the line length with the cursor at the
|
||||||
end of the line. */
|
end of the line. */
|
||||||
|
@ -922,6 +923,7 @@ void do_mouse(void)
|
||||||
}
|
}
|
||||||
do_mark();
|
do_mark();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
current_x = xcur;
|
current_x = xcur;
|
||||||
placewewant = xplustabs();
|
placewewant = xplustabs();
|
||||||
|
@ -1078,7 +1080,9 @@ void do_delete(void)
|
||||||
delete_node(foo);
|
delete_node(foo);
|
||||||
renumber(current);
|
renumber(current);
|
||||||
totlines--;
|
totlines--;
|
||||||
|
#ifndef DISABLE_WRAPPING
|
||||||
wrap_reset();
|
wrap_reset();
|
||||||
|
#endif
|
||||||
} else
|
} else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ void new_file(void);
|
||||||
filestruct *read_line(char *buf, filestruct *prev, int *line1ins, size_t
|
filestruct *read_line(char *buf, filestruct *prev, int *line1ins, size_t
|
||||||
len);
|
len);
|
||||||
void read_file(FILE *f, const char *filename, int quiet);
|
void read_file(FILE *f, const char *filename, int quiet);
|
||||||
int open_file(const char *filename, int insert, int quiet);
|
bool open_file(const char *filename, int insert, int quiet);
|
||||||
char *get_next_filename(const char *name);
|
char *get_next_filename(const char *name);
|
||||||
void do_insertfile(int loading_file);
|
void do_insertfile(int loading_file);
|
||||||
void do_insertfile_void(void);
|
void do_insertfile_void(void);
|
||||||
|
@ -352,9 +352,7 @@ void allow_pending_sigwinch(bool allow);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
void do_toggle(const toggle *which);
|
void do_toggle(const toggle *which);
|
||||||
#endif
|
#endif
|
||||||
#if !defined(NANO_SMALL) || defined(USE_SLANG)
|
|
||||||
void disable_signals(void);
|
void disable_signals(void);
|
||||||
#endif
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
void enable_signals(void);
|
void enable_signals(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue