sortix-mirror/ports/nano/nano.patch

145 lines
3.8 KiB
Diff
Raw Normal View History

diff -Paur --no-dereference -- nano.upstream/configure nano/configure
--- nano.upstream/configure
+++ nano/configure
2022-07-09 22:20:44 +00:00
@@ -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
2022-07-09 22:20:44 +00:00
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+ac_cv_prog_NCURSESW_CONFIG=false
2022-07-09 22:20:44 +00:00
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
2022-07-09 22:20:44 +00:00
@@ -1422,8 +1422,10 @@
if (env_dir != NULL)
tempdir = check_writable_directory(env_dir);
+#ifdef P_tmpdir
2022-07-09 22:20:44 +00:00
if (tempdir == NULL)
tempdir = check_writable_directory(P_tmpdir);
+#endif
2022-07-09 22:20:44 +00:00
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 @@
2022-07-09 22:20:44 +00:00
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
2022-07-09 22:20:44 +00:00
@@ -27,7 +27,9 @@
2022-07-09 22:20:44 +00:00
#include <ctype.h>
#include <errno.h>
+#if __has_include(<glob.h>)
#include <glob.h>
+#endif
#include <string.h>
2022-07-09 22:20:44 +00:00
#include <unistd.h>
@@ -577,6 +579,11 @@
* null-terminate it, and return a pointer to the succeeding text. */
char *parse_next_regex(char *ptr)
{
2022-07-09 22:20:44 +00:00
+ char* outptr = ptr;
+ int escaped = 0;
+ char c;
+ size_t bracket = 0;
+
2022-07-09 22:20:44 +00:00
char *starting_point = ptr;
if (*(ptr - 1) != '"') {
@@ -584,11 +591,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 +625,8 @@
}
/* Null-terminate the regex and skip until the next non-blank. */
- *ptr++ = '\0';
+ *outptr = '\0';
+ ptr++;
while (isblank((unsigned char)*ptr))
ptr++;
@@ -966,8 +991,10 @@
void parse_includes(char *ptr)
{
2022-07-09 22:20:44 +00:00
char *pattern, *expanded;
+#if __has_include(<glob.h>)
glob_t files;
int result;
+#endif
2022-07-09 22:20:44 +00:00
check_for_nonempty_syntax();
2022-07-09 22:20:44 +00:00
@@ -978,6 +1005,7 @@
2022-07-09 22:20:44 +00:00
/* Expand a tilde first, then try to match the globbing pattern. */
expanded = real_dir_from_tilde(pattern);
+#if __has_include(<glob.h>)
result = glob(expanded, GLOB_ERR, NULL, &files);
/* If there are matches, process each of them. Otherwise, only
@@ -989,6 +1017,9 @@
jot_error(N_("Error expanding %s: %s"), pattern, strerror(errno));
globfree(&files);
+#else
2022-07-09 22:20:44 +00:00
+ parse_one_include(expanded);
+#endif
2022-07-09 22:20:44 +00:00
free(expanded);
}