* configure.ac, doc/texinfo/nano.texi: Make --enable-tiny disable
the use of libmagic, and document the --disable-libmagic flag.
* src/nano.c (version): Print the correct --enable/--disable option.
+ * configure.ac, src/*, doc/texinfo/nano.texi: Convert all occurrences
+ of #ifdef ENABLE_NANORC to #ifndef DISABLE_NANORC, and adapt for it.
2014-04-10 Benno Schulenberg <bensberg@justemail.net>
* doc/syntax/Makefile.am: Add four recent syntaxes to the packlist.
AC_ARG_ENABLE(nanorc,
AS_HELP_STRING([--disable-nanorc], [Disable use of .nanorc files]))
-if test "x$enable_nanorc" != xno; then
- AC_DEFINE(ENABLE_NANORC, 1, [Define this to use .nanorc files.])
+if test "x$enable_nanorc" = xno; then
+ AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
+else
nanorc_support=yes
fi
if test "x$enable_multibuffer" != xyes; then
AC_DEFINE(DISABLE_MULTIBUFFER, 1, [Define this to disable multiple file buffers.])
fi
+ if test "x$enable_nanorc" != xyes; then
+ AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
+ fi
if test "x$enable_operatingdir" != xyes; then
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of the operating directory (chroot of sorts).])
fi
Disable support for opening multiple files at a time and switching
between them on the fly.
+@item --disable-nanorc
+Disable support for reading the nanorc files at startup. With such
+support, you can store custom settings in a system-wide and a per-user
+nanorc file rather than having to pass command-line options to get
+the desired behavior. See @xref{Nanorc Files}, for more info.
+
@item --disable-operatingdir
Disable setting the operating directory. This also eliminates the -o
command-line option, which sets the operating directory.
Enable support for runtime debug output. This can get pretty messy, so
chances are you only want this feature when you're working on the nano source.
-@item --enable-nanorc
-Enable support for reading the nanorc file at startup. You can store
-custom settings in the nanorc file rather than having to pass command
-line options to get desired behavior. See @xref{Nanorc Files}, for
-more info.
-
@item --disable-nls
Disables Native Language support. This will disable use of the
available GNU @code{nano} translations.
}
#endif /* !NANO_TINY */
-#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
+#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
/* Return TRUE if the string s contains one or more blank characters,
* and FALSE otherwise. */
bool has_blank_chars(const char *s)
#endif
return has_blank_chars(s);
}
-#endif /* ENABLE_NANORC && (!NANO_TINY || !DISABLE_JUSTIFY) */
+#endif /* !DISABLE_NANORC && (!NANO_TINY || !DISABLE_JUSTIFY) */
#ifdef ENABLE_UTF8
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
}
#endif
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
/* Check if the string s is a valid multibyte string. Return TRUE if it
* is, and FALSE otherwise. */
bool is_valid_mbstring(const char *s)
#endif
TRUE;
}
-#endif /* ENABLE_NANORC */
+#endif /* !DISABLE_NANORC */
if (openfile == openfile->next)
return FALSE;
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
update_poshistory(openfile->filename, openfile->current->lineno, xplustabs()+1);
#endif
}
#endif
-#if !defined(DISABLE_MULTIBUFFER) && defined(ENABLE_NANORC)
+#if !defined(DISABLE_MULTIBUFFER) && !defined(DISABLE_NANORC)
if (ISSET(MULTIBUFFER)) {
/* Update the screen to account for the current
* buffer. */
return tmp;
}
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
/* Return the constructed dorfile path, or NULL if we can't find the home
* directory. The string is dynamically allocated, and should be
* freed. */
fprintf(stderr, _("\nPress Enter to continue\n"));
while (getchar() != '\n')
;
-
}
/* Now that we have more than one history file, let's just rely on a
char *fullpath = get_full_path(file);
if (fullpath == NULL)
- return 0;
+ return 0;
for (posptr = poshistory; posptr != NULL; posptr = posptr->next) {
if (!strcmp(posptr->filename, fullpath)) {
}
}
-#endif /* !NANO_TINY && ENABLE_NANORC */
+#endif /* !NANO_TINY && !DISABLE_NANORC */
* searches. */
#endif
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
char *whitespace = NULL;
/* The characters used when displaying the first characters of
* tabs and spaces. */
return s;
}
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
/* Same thing as above but for the menu. */
int strtomenu(char *input)
{
if (replaceage != NULL)
free_filestruct(replaceage);
#endif
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
if (homedir != NULL)
free(homedir);
#endif
int scsfound = 0;
#ifndef NANO_TINY
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
ptr += sprintf(ptr, "(%s)\t\t\t%s %s\n",
s->keystr, _(flagtostr(s->toggle)), _("enable/disable"));
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
if (old_whitespace)
SET(WHITESPACE_DISPLAY);
#endif
static int oldinterval = -1;
/* Used to store the user's original mouse click interval. */
#endif
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
static bool no_rcfiles = FALSE;
/* Should we ignore all rcfiles? */
#endif
/* Restore the old terminal settings. */
tcsetattr(0, TCSANOW, &oldterm);
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
if (!no_rcfiles && ISSET(HISTORYLOG))
save_history();
if (!no_rcfiles && ISSET(POS_HISTORY)) {
#ifndef DISABLE_MULTIBUFFER
print_opt("-F", "--multibuffer", N_("Enable multiple file buffers"));
#endif
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
#ifndef NANO_TINY
print_opt("-G", "--locking",
N_("Use (vim-style) lock files"));
#ifndef DISABLE_MOUSE
printf(" --enable-mouse");
#endif
+#ifndef DISABLE_NANORC
+ printf(" --enable-nanorc");
+#endif
#ifndef DISABLE_MULTIBUFFER
printf(" --enable-multibuffer");
#endif
#ifdef DISABLE_MULTIBUFFER
printf(" --disable-multibuffer");
#endif
+#ifdef DISABLE_NANORC
+ printf(" --disable-nanorc");
+#endif
#ifdef DISABLE_OPERATINGDIR
printf(" --disable-operatingdir");
#endif
#ifdef DEBUG
printf(" --enable-debug");
#endif
-#ifdef ENABLE_NANORC
- printf(" --enable-nanorc");
-#endif
#ifndef ENABLE_NLS
printf(" --disable-nls");
#endif
case SUSPEND:
signal_init();
break;
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
case WHITESPACE_DISPLAY:
titlebar(NULL);
edit_refresh();
#ifndef DISABLE_MULTIBUFFER
{"multibuffer", 0, NULL, 'F'},
#endif
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
{"ignorercfiles", 0, NULL, 'I'},
#endif
{"rebindkeypad", 0, NULL, 'K'},
textdomain(PACKAGE);
#endif
-#if !defined(ENABLE_NANORC) && defined(DISABLE_ROOTWRAPPING)
+#if defined(DISABLE_NANORC) && defined(DISABLE_ROOTWRAPPING)
/* If we don't have rcfile support, --disable-wrapping-as-root is
* used, and we're root, turn wrapping off. */
if (geteuid() == NANO_ROOT_UID)
SET(MULTIBUFFER);
break;
#endif
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
#ifndef NANO_TINY
case 'G':
SET(LOCKING);
if (ISSET(RESTRICTED)) {
UNSET(SUSPEND);
UNSET(BACKUP_FILE);
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
no_rcfiles = TRUE;
#endif
}
/* We've read through the command line options. Now back up the flags
* and values that are set, and read the rcfile(s). If the values
* haven't changed afterward, restore the backed-up values. */
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
if (!no_rcfiles) {
#ifndef DISABLE_OPERATINGDIR
char *operating_dir_cpy = operating_dir;
else if (geteuid() == NANO_ROOT_UID)
SET(NO_WRAP);
#endif
-#endif /* ENABLE_NANORC */
+#endif /* !DISABLE_NANORC */
#ifndef DISABLE_WRAPPING
/* Overwrite an rcfile "set nowrap" or --disable-wrapping-as-root
#ifndef NANO_TINY
/* Set up the search/replace history. */
history_init();
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
if (!no_rcfiles) {
if (ISSET(HISTORYLOG) || ISSET(POS_HISTORY)) {
if (check_dotnano() == 0) {
if (ISSET(POS_HISTORY))
load_poshistory();
}
-#endif /* ENABLE_NANORC */
+#endif /* !DISABLE_NANORC */
/* Set up the backup directory (unless we're using restricted mode,
* in which case backups are disabled, since they would allow
if (matchbrackets == NULL)
matchbrackets = mallocstrcpy(NULL, "(<[{)>]}");
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
/* If whitespace wasn't specified, set its default value. If we're
* using UTF-8, it's Unicode 00BB (Right-Pointing Double Angle
* Quotation Mark) and Unicode 00B7 (Middle Dot). Otherwise, it's
whitespace_len[1] = 1;
}
}
-#endif /* ENABLE_NANORC */
+#endif /* !DISABLE_NANORC */
#endif /* !NANO_TINY */
/* If tabsize wasn't specified, set its default value. */
iline = 1;
icol = 1;
}
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
else {
/* See if we have a POS history to use if we haven't overridden it. */
ssize_t savedposline, savedposcol;
if (startline > 1 || startcol > 1)
do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE,
FALSE);
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
else {
/* See if we have a POS history to use if we haven't overridden it. */
ssize_t savedposline, savedposcol;
/* Next shortcut. */
} shortcut;
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
typedef struct rcoption {
const char *name;
/* The name of the rcfile option. */
extern char *matchbrackets;
#endif
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
extern char *whitespace;
extern int whitespace_len[2];
extern undo_type last_action;
char *mbrevstrpbrk(const char *s, const char *accept, const char
*rev_start);
#endif
-#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
+#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
bool has_blank_chars(const char *s);
bool has_blank_mbchars(const char *s);
#endif
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
bool is_valid_mbstring(const char *s);
#endif
*lastwastab, void (*refresh_func)(void), bool *list);
#endif
const char *tail(const char *foo);
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
char *histfilename(void);
void load_history(void);
bool writehist(FILE *hist, filestruct *histhead);
int do_yesno_prompt(bool all, const char *msg);
/* All functions in rcfile.c. */
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
void rcfile_error(const char *msg, ...);
char *parse_next_word(char *ptr);
char *parse_argument(char *ptr);
#ifndef NANO_TINY
bool find_bracket_match(bool reverse, const char *bracket_set);
void do_find_bracket(void);
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
bool history_has_changed(void);
#endif
void history_init(void);
void null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len);
void sunder(char *str);
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef HAVE_GETLINE
ssize_t ngetline(char **lineptr, size_t *n, FILE *stream);
#endif
#include <unistd.h>
#include <ctype.h>
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
static const rcoption rcopts[] = {
{"boldtext", BOLD_TEXT},
#endif
}
-#endif /* ENABLE_NANORC */
+#endif /* !DISABLE_NANORC */
static bool search_last_line = FALSE;
/* Have we gone past the last line while searching? */
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
static bool history_changed = FALSE;
/* Have any of the history lists changed? */
#endif
free(found_ch);
}
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
/* Indicate whether any of the history lists have changed. */
bool history_has_changed(void)
{
*hbot = (*hbot)->next;
(*hbot)->data = mallocstrcpy(NULL, "");
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
/* Indicate that the history's been changed. */
history_changed = TRUE;
#endif
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301, USA. */
-#ifdef ENABLE_NANORC
+#ifndef DISABLE_NANORC
#ifndef HAVE_GETDELIM
/* This function is equivalent to getdelim(). */
return getdelim(lineptr, n, '\n', stream);
}
#endif
-#endif /* ENABLE_NANORC */
+#endif /* !DISABLE_NANORC */
#ifdef HAVE_REGEX_H
/* Do the compiled regex in preg and the regex in string match the
/* If buf contains a tab character, interpret it. */
if (*buf_mb == '\t') {
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
if (ISSET(WHITESPACE_DISPLAY)) {
int i;
free(ctrl_buf_mb);
/* If buf contains a space character, interpret it. */
} else if (*buf_mb == ' ') {
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
if (ISSET(WHITESPACE_DISPLAY)) {
int i;
va_list ap;
char *bar, *foo;
size_t start_x, foo_len;
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
bool old_whitespace;
#endif
blank_statusbar();
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
#endif
vsnprintf(bar, mb_cur_max() * (COLS - 3), msg, ap);
va_end(ap);
foo = display_string(bar, 0, COLS - 4, FALSE);
-#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
+#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
if (old_whitespace)
SET(WHITESPACE_DISPLAY);
#endif