Changes to src/Marefile.am. (DLR)
- Move the static int pid to the beginning of nano.c with all
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
-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:
close_open_file()
- Tweak to no longer rely on the return values of
return;
}
-/* Open the file (and decide if it exists). */
-int open_file(const char *filename, int insert, int quiet)
+/* Open the file (and decide if it exists). Return TRUE on success,
+ * FALSE on failure. */
+bool open_file(const char *filename, int insert, int quiet)
{
int fd;
FILE *f;
if (filename[0] == '\0' || stat(filename, &fileinfo) == -1) {
if (insert && !quiet) {
statusbar(_("\"%s\" not found"), filename);
- return -1;
+ return FALSE;
} else {
/* We have a new file */
statusbar(_("New File"));
_("File \"%s\" is a device file"), filename);
if (!insert)
new_file();
- return -1;
+ return FALSE;
} else if ((fd = open(filename, O_RDONLY)) == -1) {
/* If we're in multibuffer mode, don't be quiet when an error
occurs while opening a file */
statusbar("%s: %s", strerror(errno), filename);
if (!insert)
new_file();
- return -1;
+ return FALSE;
} else { /* File is A-OK */
if (!quiet)
statusbar(_("Reading File"));
if (f == NULL) {
nperror("fdopen");
close(fd);
- return -1;
+ return FALSE;
}
read_file(f, filename, quiet);
#ifndef NANO_SMALL
#endif
}
- return 1;
+ return TRUE;
}
/* This function will return the name of the first available extension
void do_insertfile(int loading_file)
{
int i, old_current_x = current_x;
+ bool opened;
+ /* TRUE if the file opened successfully. */
char *realname = NULL;
static char *inspath = NULL;
#ifndef NANO_SMALL
if (i == NANO_EXTCMD_KEY) {
realname = mallocstrcpy(realname, "");
- i = open_pipe(answer);
+ opened = open_pipe(answer);
} else {
#endif
realname = real_dir_from_tilde(answer);
- i = open_file(realname, TRUE, loading_file);
+ opened = open_file(realname, TRUE, loading_file);
#ifndef NANO_SMALL
}
#endif
created to hold the file), reload the buffer we had open
before, and skip the insertion; otherwise, save realname
in filename and continue the insertion */
- if (i == -1) {
+ if (!opened) {
free(realname);
free(fileage);
load_open_file();
/* And re-init the shortcut list */
shortcut_init(FALSE);
- }
-#endif
-
-#ifdef ENABLE_MULTIBUFFER
- if (!loading_file) {
+ } else
#endif
-
/* Restore the old x-coordinate position */
current_x = old_current_x;
-#ifdef ENABLE_MULTIBUFFER
- }
-#endif
-
/* If we've gone off the bottom, recenter; otherwise, just redraw */
edit_refresh();
case NANO_HELP_KEY:
case NANO_HELP_FKEY:
case '?': /* Pico compatibility */
+#ifndef DISABLE_HELP
do_help();
curs_set(0);
+#else
+ nano_disabled_msg();
+#endif
break;
case NANO_ENTER_KEY:
case 'S': /* Pico compatibility */
const char *nano_tab_msg = N_("Insert a tab character");
const char *nano_enter_msg =
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_prevword_msg = N_("Move backward one word");
+#endif
const char *nano_verbatim_msg = N_("Insert character(s) verbatim");
#ifdef ENABLE_MULTIBUFFER
const char *nano_openprev_msg = N_("Switch to previous file buffer");
const char *nano_opennext_msg = N_("Switch to next file buffer");
#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");
#endif
const char *nano_whereis_next_msg = N_("Repeat last search");
+#endif
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_lastline_msg = N_("Go to the last line of the file");
+#ifndef DISABLE_JUSTIFY
const char *nano_parabegin_msg =
N_("Go to the beginning of the current paragraph");
const char *nano_paraend_msg =
N_("Go to the end of the current paragraph");
const char *nano_fulljustify_msg = N_("Justify the entire file");
+#endif
#ifndef NANO_SMALL
const char *nano_case_msg =
N_("Make the current search/replace case (in)sensitive");
f = fdopen(fd[0], "rb");
if (f == NULL)
nperror("fdopen");
-
+
read_file(f, "stdin", FALSE);
/* If multibuffer mode is on, we could be here in view mode. If so,
* don't set the modification flag. */
xcur = actual_x(current->data, get_page_start(xplustabs()) +
mouse_x);
+#ifndef NANO_SMALL
/* Selecting where the cursor is toggles the mark, as does
selecting beyond the line length with the cursor at the
end of the line. */
}
do_mark();
}
+#endif
current_x = xcur;
placewewant = xplustabs();
delete_node(foo);
renumber(current);
totlines--;
+#ifndef DISABLE_WRAPPING
wrap_reset();
+#endif
} else
return;
filestruct *read_line(char *buf, filestruct *prev, int *line1ins, size_t
len);
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);
void do_insertfile(int loading_file);
void do_insertfile_void(void);
#ifndef NANO_SMALL
void do_toggle(const toggle *which);
#endif
-#if !defined(NANO_SMALL) || defined(USE_SLANG)
void disable_signals(void);
-#endif
#ifndef NANO_SMALL
void enable_signals(void);
#endif