commit 167a8e5c0959d4221db58ec8778c84a7d57b053d
parent 90cbdbbe75306e71f0868ae16602daddb3b1b4f2
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 11 Apr 2019 20:18:29 +0200
options: make --nowrap override again a contrary nanorc setting
All other options are off by default and can only be switched *on*
(either by a command-line option or a nanorc setting) -- there are
no command-line options to switch them off again. Except for the
--breaklonglines/--nowrap pair. So these need special handling.
This fixes https://savannah.gnu.org/bugs/?56119.
Reported-by: Sébastien Desreux <seb@h-k.fr>
Bug existed since version 4.0, commit 4d40bea5.
Diffstat:
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -1959,6 +1959,8 @@ int main(int argc, char **argv)
bool fill_used = FALSE;
/* Was the fill option used on the command line? */
#endif
+ int hardwrap = -2;
+ /* Becomes 0 when --nowrap and 1 when --breaklonglines is used. */
#ifdef ENABLE_JUSTIFY
int quoterc;
/* Whether the quoting regex was compiled successfully. */
@@ -2227,7 +2229,7 @@ int main(int argc, char **argv)
#endif
#ifdef ENABLE_WRAPPING
case 'b':
- SET(BREAK_LONG_LINES);
+ hardwrap = 1;
break;
#endif
case 'c':
@@ -2309,7 +2311,7 @@ int main(int argc, char **argv)
break;
#ifdef ENABLE_WRAPPING
case 'w':
- UNSET(BREAK_LONG_LINES);
+ hardwrap = 0;
break;
#endif
case 'x':
@@ -2435,6 +2437,11 @@ int main(int argc, char **argv)
/* Simply OR the boolean flags from rcfile and command line. */
for (size_t i = 0; i < sizeof(flags) / sizeof(flags[0]); i++)
flags[i] |= flags_cmdline[i];
+
+ if (hardwrap == 0)
+ UNSET(BREAK_LONG_LINES);
+ else if (hardwrap == 1)
+ SET(BREAK_LONG_LINES);
}
#endif /* ENABLE_NANORC */