sortix-mirror/ports/nano/nano.patch

106 lines
3.0 KiB
Diff

diff -Paur --no-dereference -- nano.upstream/configure nano/configure
--- nano.upstream/configure
+++ nano/configure
@@ -43510,6 +43510,7 @@
# Extract the first word of "${ac_tool_prefix}ncursesw5-config", so it can be a program name with args.
set dummy ${ac_tool_prefix}ncursesw5-config; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ac_cv_prog_NCURSESW_CONFIG=false
printf %s "checking for $ac_word... " >&6; }
if test ${ac_cv_prog_NCURSESW_CONFIG+y}
then :
diff -Paur --no-dereference -- nano.upstream/src/files.c nano/src/files.c
--- nano.upstream/src/files.c
+++ nano/src/files.c
@@ -1422,8 +1422,10 @@
if (env_dir != NULL)
tempdir = check_writable_directory(env_dir);
+#ifdef P_tmpdir
if (tempdir == NULL)
tempdir = check_writable_directory(P_tmpdir);
+#endif
if (tempdir == NULL)
tempdir = copy_of("/tmp/");
diff -Paur --no-dereference -- nano.upstream/src/nano.c nano/src/nano.c
--- nano.upstream/src/nano.c
+++ nano/src/nano.c
@@ -329,7 +329,7 @@
if (*filename == '\0') {
plainname = nmalloc(28);
- sprintf(plainname, "nano.%u", getpid());
+ sprintf(plainname, "nano.%ji", (intmax_t)getpid());
} else
plainname = copy_of(filename);
@@ -2076,8 +2076,7 @@
}
/* Curses needs TERM; if it is unset, try falling back to a VT220. */
- if (getenv("TERM") == NULL)
- putenv("TERM=vt220");
+ setenv("TERM", "vt220", 0);
/* Enter into curses mode. Abort if this fails. */
if (initscr() == NULL)
diff -Paur --no-dereference -- nano.upstream/src/rcfile.c nano/src/rcfile.c
--- nano.upstream/src/rcfile.c
+++ nano/src/rcfile.c
@@ -577,6 +577,11 @@
* null-terminate it, and return a pointer to the succeeding text. */
char *parse_next_regex(char *ptr)
{
+ char* outptr = ptr;
+ int escaped = 0;
+ char c;
+ size_t bracket = 0;
+
char *starting_point = ptr;
if (*(ptr - 1) != '"') {
@@ -584,11 +589,28 @@
return NULL;
}
- /* Continue until the end of the line, or until a double quote followed
- * by end-of-line or a blank. */
- while (*ptr != '\0' && (*ptr != '"' ||
- (ptr[1] != '\0' && !isblank((unsigned char)ptr[1]))))
+ /* PATCH: This fixes issues in the nanorc parser because the Sortix regcomp
+ does not support \" and \' (just use " and ' instead). */
+ while ((c = *ptr)) {
+ if (!escaped && !bracket && c == '"' &&
+ (!ptr[1] || isspace((unsigned char) ptr[1])) )
+ break;
+ if (escaped && c != '"' && c != '\'')
+ *outptr++ = '\\';
+ if (c == '\\' && !escaped && !bracket)
+ escaped = 1;
+ else if (c == '[' && !escaped) {
+ bracket++;
+ *outptr++ = c;
+ } else if (bracket && c == ']' && !escaped) {
+ bracket--;
+ *outptr++ = c;
+ } else {
+ *outptr++ = c;
+ escaped = 0;
+ }
ptr++;
+ }
if (*ptr == '\0') {
jot_error(N_("Regex strings must begin and end with a \" character"));
@@ -601,7 +623,8 @@
}
/* Null-terminate the regex and skip until the next non-blank. */
- *ptr++ = '\0';
+ *outptr = '\0';
+ ptr++;
while (isblank((unsigned char)*ptr))
ptr++;