summaryrefslogtreecommitdiff
path: root/debian/patches
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches')
-rw-r--r--debian/patches/cherry-pick-0bb140f9-52999-import-OLDPWD-from-environment-if-set.patch22
-rw-r--r--debian/patches/cherry-pick-10bdbd8b-51877-do-not-build-pcre-module-if-pcre2-config-is-not-found.patch93
-rw-r--r--debian/patches/cherry-pick-3e3cfabc-revert-38150-and-fix-in-calling-function-cfp_matcher_range-instead.patch32
-rw-r--r--debian/patches/cherry-pick-4b7a9fd0-additional-typset--p--m-fix-for-namespaces.patch25
-rw-r--r--debian/patches/cherry-pick-4c89849c-50641-use-int-main-in-test-C-codes-in-configure.patch546
-rw-r--r--debian/patches/cherry-pick-727b493e-50736-silence-use-after-free-warning.patch36
-rw-r--r--debian/patches/cherry-pick-ab4d62eb-52383-Avoid-incompatible-pointer-types-in-terminfo-global.patch49
-rw-r--r--debian/patches/cherry-pick-b62e91134-51723-migrate-pcre-module-to-pcre2.patch514
-rw-r--r--debian/patches/cherry-pick-ecd3f9c9-1057610-support-texinfo-7.0.patch44
-rw-r--r--debian/patches/completion-dscverify.diff40
-rw-r--r--debian/patches/cross-compile.diff63
-rw-r--r--debian/patches/example-shebang.patch12
-rw-r--r--debian/patches/fix-typos-in-man-pages.patch26
-rw-r--r--debian/patches/further-mitigate-test-suite-hangs.patch15
-rw-r--r--debian/patches/series16
-rw-r--r--debian/patches/update-debian-sections.patch51
-rw-r--r--debian/patches/use-pager-instead-of-more-by-default.patch104
17 files changed, 1688 insertions, 0 deletions
diff --git a/debian/patches/cherry-pick-0bb140f9-52999-import-OLDPWD-from-environment-if-set.patch b/debian/patches/cherry-pick-0bb140f9-52999-import-OLDPWD-from-environment-if-set.patch
new file mode 100644
index 000000000..9b56368b2
--- /dev/null
+++ b/debian/patches/cherry-pick-0bb140f9-52999-import-OLDPWD-from-environment-if-set.patch
@@ -0,0 +1,22 @@
+From 0bb140f9911851e9712dba311925f9c9ab521fd2 Mon Sep 17 00:00:00 2001
+From: Peter Stephenson <p.w.stephenson@ntlworld.com>
+Date: Sun, 28 Jul 2024 20:33:07 +0100
+Subject: [PATCH] 52999: import OLDPWD from environment if set
+
+diff --git a/Src/init.c b/Src/init.c
+index ec21521b1..0aecb5db9 100644
+--- a/Src/init.c
++++ b/Src/init.c
+@@ -1245,7 +1245,11 @@ setupvals(char *cmd, char *runscript, char *zsh_name)
+ pwd = metafy(zgetcwd(), -1, META_DUP);
+ }
+
+- oldpwd = ztrdup(pwd); /* initialize `OLDPWD' = `PWD' */
++ oldpwd = zgetenv("OLDPWD");
++ if (oldpwd == NULL)
++ oldpwd = ztrdup(pwd); /* initialize `OLDPWD' = `PWD' */
++ else
++ oldpwd = ztrdup(oldpwd);
+
+ inittyptab(); /* initialize the ztypes table */
+ initlextabs(); /* initialize lexing tables */
diff --git a/debian/patches/cherry-pick-10bdbd8b-51877-do-not-build-pcre-module-if-pcre2-config-is-not-found.patch b/debian/patches/cherry-pick-10bdbd8b-51877-do-not-build-pcre-module-if-pcre2-config-is-not-found.patch
new file mode 100644
index 000000000..c9f14f234
--- /dev/null
+++ b/debian/patches/cherry-pick-10bdbd8b-51877-do-not-build-pcre-module-if-pcre2-config-is-not-found.patch
@@ -0,0 +1,93 @@
+commit 10bdbd8b5b0b43445aff23dcd412f25cf6aa328a
+Author: Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
+Date: Tue Jun 20 18:14:27 2023 +0900
+
+ 51877: do not build pcre module if pcre2-config is not found
+
+--- a/Src/Modules/pcre.mdd
++++ b/Src/Modules/pcre.mdd
+@@ -1,5 +1,5 @@
+ name=zsh/pcre
+-link=`if test x$enable_pcre = xyes && (pcre-config --version >/dev/null 2>/dev/null); then echo dynamic; else echo no; fi`
++link=`if test x$enable_pcre = xyes; then echo dynamic; else echo no; fi`
+ load=no
+
+ autofeatures="b:pcre_compile b:pcre_study b:pcre_match"
+--- a/configure.ac
++++ b/configure.ac
+@@ -440,6 +440,17 @@
+ AC_ARG_ENABLE(pcre,
+ AS_HELP_STRING([--enable-pcre],[enable the search for the pcre2 library (may create run-time library dependencies)]))
+
++AC_ARG_VAR(PCRE_CONFIG, [pathname of pcre2-config if it is not in PATH])
++if test "x$enable_pcre" = xyes; then
++ AC_CHECK_PROG([PCRE_CONFIG], pcre2-config, pcre2-config)
++ if test "x$PCRE_CONFIG" = x; then
++ enable_pcre=no
++ AC_MSG_WARN([pcre2-config not found: pcre module is disabled.])
++ AC_MSG_NOTICE(
++ [Set PCRE_CONFIG to pathname of pcre2-config if it is not in PATH.])
++ fi
++fi
++
+ dnl Do you want to look for capability support?
+ AC_ARG_ENABLE(cap,
+ AS_HELP_STRING([--enable-cap],[enable the search for POSIX capabilities (may require additional headers to be added by hand)]))
+@@ -660,15 +671,12 @@
+ AC_HEADER_STAT
+ AC_HEADER_SYS_WAIT
+
+-oldcflags="$CFLAGS"
+-if test x$enable_pcre = xyes; then
+-AC_CHECK_PROG([PCRECONF], pcre2-config, pcre2-config)
+ dnl pcre2-config --cflags may produce a -I output which needs to go into
+ dnl CPPFLAGS else configure's preprocessor tests don't pick it up,
+ dnl producing a warning.
+-if test "x$ac_cv_prog_PCRECONF" = xpcre2-config; then
+- CPPFLAGS="$CPPFLAGS `pcre2-config --cflags`"
+-fi
++if test "x$enable_pcre" = xyes; then
++ CPPFLAGS="`$PCRE_CONFIG --cflags` $CPPFLAGS"
++ AC_CHECK_HEADERS([pcre2.h],,,[#define PCRE2_CODE_UNIT_WIDTH 8])
+ fi
+
+ AC_CHECK_HEADERS(sys/time.h sys/times.h sys/select.h termcap.h termio.h \
+@@ -680,7 +688,6 @@
+ netinet/in_systm.h langinfo.h wchar.h stddef.h \
+ sys/stropts.h iconv.h ncurses.h ncursesw/ncurses.h \
+ ncurses/ncurses.h)
+-AC_CHECK_HEADERS([pcre2.h],,,[#define PCRE2_CODE_UNIT_WIDTH 8])
+ if test x$dynamic = xyes; then
+ AC_CHECK_HEADERS(dlfcn.h)
+ AC_CHECK_HEADERS(dl.h)
+@@ -957,10 +964,6 @@
+ [Define as const if the declaration of iconv() needs const.])
+ fi
+
+-if test x$enable_pcre = xyes; then
+- LIBS="`$ac_cv_prog_PCRECONF --libs8` $LIBS"
+-fi
+-
+ dnl ---------------------
+ dnl CHECK TERMCAP LIBRARY
+ dnl ---------------------
+@@ -1321,7 +1324,6 @@
+ pathconf sysconf \
+ tgetent tigetflag tigetnum tigetstr setupterm initscr resize_term \
+ getcchar setcchar waddwstr wget_wch win_wch use_default_colors \
+- pcre2_compile_8 \
+ nl_langinfo \
+ erand48 open_memstream \
+ posix_openpt \
+@@ -1376,6 +1378,11 @@
+ AC_DEFINE(REALPATH_ACCEPTS_NULL)
+ fi
+
++if test x$enable_pcre = xyes; then
++ LIBS="`$PCRE_CONFIG --libs8` $LIBS"
++ AC_CHECK_FUNCS(pcre2_compile_8)
++fi
++
+ if test x$enable_cap = xyes; then
+ AC_CHECK_FUNCS(cap_get_proc)
+ fi
diff --git a/debian/patches/cherry-pick-3e3cfabc-revert-38150-and-fix-in-calling-function-cfp_matcher_range-instead.patch b/debian/patches/cherry-pick-3e3cfabc-revert-38150-and-fix-in-calling-function-cfp_matcher_range-instead.patch
new file mode 100644
index 000000000..8424bf4ce
--- /dev/null
+++ b/debian/patches/cherry-pick-3e3cfabc-revert-38150-and-fix-in-calling-function-cfp_matcher_range-instead.patch
@@ -0,0 +1,32 @@
+Origin: commit 3e3cfabcc74dc79d4d8717c4e5859d8d01be6c54
+Description: Fix a completion regression with NO_CASE_GLOB
+Author: Bart Schaefer <schaefer@zsh.org>
+Bug: https://zsh.org/workers/50325
+Bug-Debian: https://bugs.debian.org/1013434
+
+diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
+index bb8359f1d..56e5509a4 100644
+--- a/Src/Zle/compmatch.c
++++ b/Src/Zle/compmatch.c
+@@ -1319,7 +1319,7 @@ pattern_match_equivalence(Cpattern lp, convchar_t wind, int wmtp,
+ convchar_t lchr;
+ int lmtp;
+
+- if (!PATMATCHINDEX(lp->u.str, wind, &lchr, &lmtp)) {
++ if (!PATMATCHINDEX(lp->u.str, wind-1, &lchr, &lmtp)) {
+ /*
+ * No equivalent. No possible match; give up.
+ */
+diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
+index 59abb4cc4..77ccdebf7 100644
+--- a/Src/Zle/computil.c
++++ b/Src/Zle/computil.c
+@@ -4383,7 +4383,7 @@ cfp_matcher_range(Cmatcher *ms, char *add)
+ * word pattern.
+ */
+ if ((ind = pattern_match_equivalence
+- (m->word, ind, mt, addc)) != CHR_INVALID) {
++ (m->word, ind+1, mt, addc)) != CHR_INVALID) {
+ if (ret) {
+ if (imeta(ind)) {
+ *p++ = Meta;
diff --git a/debian/patches/cherry-pick-4b7a9fd0-additional-typset--p--m-fix-for-namespaces.patch b/debian/patches/cherry-pick-4b7a9fd0-additional-typset--p--m-fix-for-namespaces.patch
new file mode 100644
index 000000000..98105eff6
--- /dev/null
+++ b/debian/patches/cherry-pick-4b7a9fd0-additional-typset--p--m-fix-for-namespaces.patch
@@ -0,0 +1,25 @@
+commit 4b7a9fd0ecb750646cac76c41383f8391cd0fdd9
+Author: Bart Schaefer <schaefer@zsh.org>
+Date: Tue Mar 14 20:51:15 2023 -0700
+
+ [partial cherry-pick] 51573: additional "typset -p -m" fix for namespaces
+
+ The "-m pattern" option is supposed to enable printing namespaces, but
+ that didn't work when combined with -p.
+
+ The -p option could also cause an unset parameter to become set if a
+ named reference pointed at it.
+
+diff --git a/Src/builtin.c b/Src/builtin.c
+index d99802f5f..f38a54936 100644
+--- a/Src/builtin.c
++++ b/Src/builtin.c
+@@ -2502,6 +2502,8 @@ typeset_single(char *cname, char *pname, Param pm, int func,
+ "%s: inconsistent array element or slice assignment", pname);
+ return NULL;
+ }
++ } else if (!pm && OPT_ISSET(ops,'p')) {
++ return NULL;
+ }
+ /*
+ * As we can hide existing parameters, we allow a name if
diff --git a/debian/patches/cherry-pick-4c89849c-50641-use-int-main-in-test-C-codes-in-configure.patch b/debian/patches/cherry-pick-4c89849c-50641-use-int-main-in-test-C-codes-in-configure.patch
new file mode 100644
index 000000000..35619cd1a
--- /dev/null
+++ b/debian/patches/cherry-pick-4c89849c-50641-use-int-main-in-test-C-codes-in-configure.patch
@@ -0,0 +1,546 @@
+From: Nicholas Vinson <nvinson234@gmail.com>
+Date: Wed, 21 Sep 2022 09:22:11 +0900
+Subject: 50641: use 'int main()' in test C-codes in configure
+
+Origin: upstream, commit:ab4d62eb975a4c4c51dd35822665050e2ddc6918
+Bug-Debian: https://bugs.debian.org/1075708
+---
+ aczsh.m4 | 64 ++++++++++++++++++++---------------------
+ configure.ac | 94 ++++++++++++++++++++++++++----------------------------------
+ 2 files changed, 72 insertions(+), 86 deletions(-)
+
+diff --git a/aczsh.m4 b/aczsh.m4
+index d2a47ba..27cc260 100644
+--- a/aczsh.m4
++++ b/aczsh.m4
+@@ -44,6 +44,7 @@ AC_DEFUN(zsh_64_BIT_TYPE,
+ #include <sys/types.h>
+ #endif
+
++int
+ main()
+ {
+ $1 foo = 0;
+@@ -118,7 +119,6 @@ AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS
+ AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AS_MESSAGE_LOG_FD) &&
+ AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AS_MESSAGE_LOG_FD); then
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+-#include <stdlib.h>
+ #ifdef HPUX10DYNAMIC
+ #include <dl.h>
+ #define RTLD_LAZY BIND_DEFERRED
+@@ -146,29 +146,30 @@ char *zsh_gl_sym_addr ;
+ #define RTLD_GLOBAL 0
+ #endif
+
++int
+ main()
+ {
+ void *handle1, *handle2;
+ void *(*zsh_getaddr1)(), *(*zsh_getaddr2)();
+ void *sym1, *sym2;
+ handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+- if(!handle1) exit(1);
++ if(!handle1) return(1);
+ handle2 = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+- if(!handle2) exit(1);
++ if(!handle2) return(1);
+ zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");
+ zsh_getaddr2 = (void *(*)()) dlsym(handle2, "${us}zsh_getaddr2");
+ sym1 = zsh_getaddr1();
+ sym2 = zsh_getaddr2();
+- if(!sym1 || !sym2) exit(1);
+- if(sym1 != sym2) exit(1);
++ if(!sym1 || !sym2) return(1);
++ if(sym1 != sym2) return(1);
+ dlclose(handle1);
+ handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+- if(!handle1) exit(1);
++ if(!handle1) return(1);
+ zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");
+ sym1 = zsh_getaddr1();
+- if(!sym1) exit(1);
+- if(sym1 != sym2) exit(1);
+- exit(0);
++ if(!sym1) return(1);
++ if(sym1 != sym2) return(1);
++ return(0);
+ }
+ ]])],[zsh_cv_shared_$1=yes],
+ [zsh_cv_shared_$1=no],
+@@ -200,7 +201,6 @@ AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS
+ AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AS_MESSAGE_LOG_FD) &&
+ AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AS_MESSAGE_LOG_FD); then
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+-#include <stdlib.h>
+ #ifdef HPUX10DYNAMIC
+ #include <dl.h>
+ #define RTLD_LAZY BIND_DEFERRED
+@@ -228,19 +228,19 @@ char *zsh_gl_sym_addr ;
+ #define RTLD_GLOBAL 0
+ #endif
+
+-
++int
+ main()
+ {
+ void *handle1, *handle2;
+ int (*fred1)(), (*fred2)();
+ handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+- if(!handle1) exit(1);
++ if(!handle1) return(1);
+ handle2 = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+- if(!handle2) exit(1);
++ if(!handle2) return(1);
+ fred1 = (int (*)()) dlsym(handle1, "${us}fred");
+ fred2 = (int (*)()) dlsym(handle2, "${us}fred");
+- if(!fred1 || !fred2) exit(1);
+- exit((*fred1)() != 42 || (*fred2)() != 69);
++ if(!fred1 || !fred2) return(1);
++ return((*fred1)() != 42 || (*fred2)() != 69);
+ }
+ ]])],[zsh_cv_sys_dynamic_clash_ok=yes],
+ [zsh_cv_sys_dynamic_clash_ok=no],
+@@ -276,7 +276,6 @@ AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS
+ AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AS_MESSAGE_LOG_FD) &&
+ AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AS_MESSAGE_LOG_FD); then
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+-#include <stdlib.h>
+ #ifdef HPUX10DYNAMIC
+ #include <dl.h>
+ #define RTLD_LAZY BIND_DEFERRED
+@@ -304,17 +303,18 @@ char *zsh_gl_sym_addr ;
+ #define RTLD_GLOBAL 0
+ #endif
+
++int
+ main()
+ {
+ void *handle;
+ int (*barneysym)();
+ handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+- if(!handle) exit(1);
++ if(!handle) return(1);
+ handle = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+- if(!handle) exit(1);
++ if(!handle) return(1);
+ barneysym = (int (*)()) dlsym(handle, "${us}barney");
+- if(!barneysym) exit(1);
+- exit((*barneysym)() != 69);
++ if(!barneysym) return(1);
++ return((*barneysym)() != 69);
+ }
+ ]])],[zsh_cv_sys_dynamic_rtld_global=yes],
+ [zsh_cv_sys_dynamic_rtld_global=no],
+@@ -346,7 +346,6 @@ AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS
+ save_ldflags=$LDFLAGS
+ LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+-#include <stdlib.h>
+ #ifdef HPUX10DYNAMIC
+ #include <dl.h>
+ #define RTLD_LAZY BIND_DEFERRED
+@@ -374,15 +373,16 @@ char *zsh_gl_sym_addr ;
+ #define RTLD_GLOBAL 0
+ #endif
+
++int
+ main()
+ {
+ void *handle;
+ int (*barneysym)();
+ handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+- if(!handle) exit(1);
++ if(!handle) return(1);
+ barneysym = (int (*)()) dlsym(handle, "${us}barney");
+- if(!barneysym) exit(1);
+- exit((*barneysym)() != 69);
++ if(!barneysym) return(1);
++ return((*barneysym)() != 69);
+ }
+
+ int fred () { return 42; }
+@@ -420,7 +420,6 @@ elif
+ save_ldflags=$LDFLAGS
+ LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS -s"
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+-#include <stdlib.h>
+ #ifdef HPUX10DYNAMIC
+ #include <dl.h>
+ #define RTLD_LAZY BIND_DEFERRED
+@@ -448,15 +447,16 @@ char *zsh_gl_sym_addr ;
+ #define RTLD_GLOBAL 0
+ #endif
+
++int
+ main()
+ {
+ void *handle;
+ int (*barneysym)();
+ handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+- if(!handle) exit(1);
++ if(!handle) return(1);
+ barneysym = (int (*)()) dlsym(handle, "${us}barney");
+- if(!barneysym) exit(1);
+- exit((*barneysym)() != 69);
++ if(!barneysym) return(1);
++ return((*barneysym)() != 69);
+ }
+
+ int fred () { return 42; }
+@@ -488,7 +488,6 @@ echo 'int fred () { return 42; }' > conftest1.c
+ if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AS_MESSAGE_LOG_FD) &&
+ AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS -s conftest1.o $LIBS 1>&AS_MESSAGE_LOG_FD); then
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+-#include <stdlib.h>
+ #ifdef HPUX10DYNAMIC
+ #include <dl.h>
+ #define RTLD_LAZY BIND_DEFERRED
+@@ -516,15 +515,16 @@ char *zsh_gl_sym_addr ;
+ #define RTLD_GLOBAL 0
+ #endif
+
++int
+ main()
+ {
+ void *handle;
+ int (*fredsym)();
+ handle = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+- if(!handle) exit(1);
++ if(!handle) return(1);
+ fredsym = (int (*)()) dlsym(handle, "${us}fred");
+- if(!fredsym) exit(1);
+- exit((*fredsym)() != 42);
++ if(!fredsym) return(1);
++ return((*fredsym)() != 42);
+ }
+ ]])],[zsh_cv_sys_dynamic_strip_lib=yes],
+ [zsh_cv_sys_dynamic_strip_lib=no],
+diff --git a/configure.ac b/configure.ac
+index 928b467..5534f42 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -596,7 +596,7 @@ fi
+ dnl Checking if compiler correctly cast signed to unsigned.
+ AC_CACHE_CHECK(if signed to unsigned casting is broken,
+ zsh_cv_c_broken_signed_to_unsigned_casting,
+-[AC_RUN_IFELSE([AC_LANG_SOURCE([[main(){return((int)(unsigned char)((char) -1) == 255);}]])],[zsh_cv_c_broken_signed_to_unsigned_casting=yes],[zsh_cv_c_broken_signed_to_unsigned_casting=no],[zsh_cv_c_broken_signed_to_unsigned_casting=no])])
++[AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(){return((int)(unsigned char)((char) -1) == 255);}]])],[zsh_cv_c_broken_signed_to_unsigned_casting=yes],[zsh_cv_c_broken_signed_to_unsigned_casting=no],[zsh_cv_c_broken_signed_to_unsigned_casting=no])])
+ AH_TEMPLATE([BROKEN_SIGNED_TO_UNSIGNED_CASTING],
+ [Define to 1 if compiler incorrectly cast signed to unsigned.])
+ if test x$zsh_cv_c_broken_signed_to_unsigned_casting = xyes; then
+@@ -1052,7 +1052,7 @@ else
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include <sys/types.h>
+
+-main() { return sizeof(off_t) < 8; }
++int main() { return sizeof(off_t) < 8; }
+ ]])],[zsh_cv_off_t_is_64_bit=yes],[zsh_cv_off_t_is_64_bit=no],[zsh_cv_off_t_is_64_bit=no])])
+ if test x$zsh_cv_off_t_is_64_bit = xyes; then
+ AC_DEFINE(OFF_T_IS_64_BIT)
+@@ -1062,7 +1062,7 @@ main() { return sizeof(off_t) < 8; }
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include <sys/types.h>
+
+-main() { return sizeof(ino_t) < 8; }
++int main() { return sizeof(ino_t) < 8; }
+ ]])],[zsh_cv_ino_t_is_64_bit=yes],[zsh_cv_ino_t_is_64_bit=no],[zsh_cv_ino_t_is_64_bit=no])])
+ if test x$zsh_cv_ino_t_is_64_bit = xyes; then
+ AC_DEFINE(INO_T_IS_64_BIT)
+@@ -1374,7 +1374,7 @@ zsh_cv_func_realpath_accepts_null,
+ #include <stdlib.h>
+ #include <limits.h>
+ ],[
+-exit(!realpath("/", (char*)0));
++return(!realpath("/", (char*)0));
+ ])],
+ [zsh_cv_func_realpath_accepts_null=yes],
+ [zsh_cv_func_realpath_accepts_null=no],
+@@ -1403,10 +1403,9 @@ AC_CACHE_CHECK(if tgetent accepts NULL,
+ zsh_cv_func_tgetent_accepts_null,
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include <fcntl.h>
+-#include <stdlib.h>
+ int tgetent(char *, char *);
+ char *tgetstr(char *, char **);
+-main()
++int main()
+ {
+ char buf[4096];
+ int r1 = tgetent(buf, "vt100");
+@@ -1417,7 +1416,7 @@ main()
+ tgetstr("cl", &u);
+ creat("conftest.tgetent", 0640);
+ }
+- exit((r1 != r2) || r2 == -1);
++ return((r1 != r2) || r2 == -1);
+ }
+ ]])],[if test -f conftest.tgetent; then
+ zsh_cv_func_tgetent_accepts_null=yes
+@@ -1431,10 +1430,9 @@ AC_CACHE_CHECK(if tgetent returns 0 on success,
+ zsh_cv_func_tgetent_zero_success,
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include <fcntl.h>
+-#include <stdlib.h>
+ int tgetent(char *, char*);
+ char *tgetstr(char *, char **);
+-main()
++int main()
+ {
+ char buf[4096];
+ int r1 = tgetent(buf, "!@#$%^&*");
+@@ -1445,7 +1443,7 @@ main()
+ tgetstr("cl", &u);
+ creat("conftest.tgetent0", 0640);
+ }
+- exit(r1 == r2);
++ return(r1 == r2);
+ }
+ ]])],[if test -f conftest.tgetent0; then
+ zsh_cv_func_tgetent_zero_success=yes
+@@ -1871,8 +1869,7 @@ zsh_cv_rlim_t_is_longer,
+ #include <sys/time.h>
+ #endif
+ #include <sys/resource.h>
+-#include <stdlib.h>
+-main(){struct rlimit r;exit(sizeof(r.rlim_cur) <= sizeof(long));}]])],[zsh_cv_rlim_t_is_longer=yes],[zsh_cv_rlim_t_is_longer=no],[zsh_cv_rlim_t_is_longer=yes])])
++int main(){struct rlimit r;return(sizeof(r.rlim_cur) <= sizeof(long));}]])],[zsh_cv_rlim_t_is_longer=yes],[zsh_cv_rlim_t_is_longer=no],[zsh_cv_rlim_t_is_longer=yes])])
+ if test x$zsh_cv_rlim_t_is_longer = xyes; then
+ AC_CACHE_CHECK(if rlim_t is a quad,
+ zsh_cv_rlim_t_is_quad_t,
+@@ -1882,13 +1879,12 @@ if test x$zsh_cv_rlim_t_is_longer = xyes; then
+ #endif
+ #include <stdio.h>
+ #include <sys/resource.h>
+-#include <stdlib.h>
+-main() {
++int main() {
+ struct rlimit r;
+ char buf[20];
+ r.rlim_cur = 0;
+ sprintf(buf, "%qd", r.rlim_cur);
+- exit(strcmp(buf, "0"));
++ return(strcmp(buf, "0"));
+ }]])],[zsh_cv_rlim_t_is_quad_t=yes],[zsh_cv_rlim_t_is_quad_t=no],[zsh_cv_rlim_t_is_quad_t=no])])
+ if test x$zsh_cv_rlim_t_is_quad_t = xyes; then
+ AC_DEFINE(RLIM_T_IS_QUAD_T)
+@@ -1905,8 +1901,7 @@ else
+ #include <sys/time.h>
+ #endif
+ #include <sys/resource.h>
+-#include <stdlib.h>
+- main(){struct rlimit r;r.rlim_cur=-1;exit(r.rlim_cur<0);}]])],[zsh_cv_type_rlim_t_is_unsigned=yes],[zsh_cv_type_rlim_t_is_unsigned=no],[zsh_cv_type_rlim_t_is_unsigned=no])])
++ int main(){struct rlimit r;r.rlim_cur=-1;return(r.rlim_cur<0);}]])],[zsh_cv_type_rlim_t_is_unsigned=yes],[zsh_cv_type_rlim_t_is_unsigned=no],[zsh_cv_type_rlim_t_is_unsigned=no])])
+ if test x$zsh_cv_type_rlim_t_is_unsigned = xyes; then
+ AC_DEFINE(RLIM_T_IS_UNSIGNED)
+ DEFAULT_RLIM_T="unsigned $DEFAULT_RLIM_T"
+@@ -2185,9 +2180,8 @@ zsh_cv_sys_fifo,
+ #include <fcntl.h>
+ #include <signal.h>
+ #include <unistd.h>
+-#include <stdlib.h>
+ #include <sys/stat.h>
+-main()
++int main()
+ {
+ char c;
+ int fd;
+@@ -2198,18 +2192,18 @@ main()
+ #else
+ if(mknod("/tmp/fifo$$", 0010600, 0) < 0)
+ #endif
+- exit(1);
++ return(1);
+ pid = fork();
+ if(pid < 0)
+- exit(1);
++ return(1);
+ if(pid) {
+ fd = open("/tmp/fifo$$", O_RDONLY);
+- exit(fd < 0 || read(fd, &c, 1) != 1 || c != 'x');
++ return(fd < 0 || read(fd, &c, 1) != 1 || c != 'x');
+ }
+ fd = open("/tmp/fifo$$", O_WRONLY);
+ ret = (fd < 0 || write(fd, "x", 1) < 1);
+ unlink("/tmp/fifo$$");
+- exit(ret);
++ return(ret);
+ }
+ ]])],[zsh_cv_sys_fifo=yes],[zsh_cv_sys_fifo=no],[zsh_cv_sys_fifo=yes])
+ ])
+@@ -2287,8 +2281,7 @@ zsh_cv_sys_link,
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include <unistd.h>
+ #include <fcntl.h>
+-#include <stdlib.h>
+-main()
++int main()
+ {
+ int ret;
+ char *tmpfile, *newfile;
+@@ -2297,11 +2290,11 @@ main()
+ unlink(tmpfile);
+ unlink(newfile);
+ if(creat(tmpfile, 0644) < 0)
+- exit(1);
++ return(1);
+ ret = link(tmpfile, newfile);
+ unlink(tmpfile);
+ unlink(newfile);
+- exit(ret<0);
++ return(ret<0);
+ }
+ ]])],[zsh_cv_sys_link=yes],[zsh_cv_sys_link=no],[zsh_cv_sys_link=yes])])
+ AH_TEMPLATE([HAVE_LINK],
+@@ -2320,12 +2313,11 @@ zsh_cv_sys_killesrch,
+ #include <unistd.h>
+ #include <signal.h>
+ #include <errno.h>
+-#include <stdlib.h>
+-main()
++int main()
+ {
+ int pid = (getpid() + 10000) & 0xffffff;
+ while (pid && (kill(pid, 0) == 0 || errno != ESRCH)) pid >>= 1;
+- exit(errno!=ESRCH);
++ return(errno!=ESRCH);
+ }
+ ]])],[zsh_cv_sys_killesrch=yes],[zsh_cv_sys_killesrch=no],[zsh_cv_sys_killesrch=yes])])
+ AH_TEMPLATE([BROKEN_KILL_ESRCH],
+@@ -2346,12 +2338,11 @@ if test x$signals_style = xPOSIX_SIGNALS; then
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include <signal.h>
+ #include <unistd.h>
+-#include <stdlib.h>
+ int child=0;
+ void handler(sig)
+ int sig;
+ {if(sig==SIGCHLD) child=1;}
+-main() {
++int main() {
+ struct sigaction act;
+ sigset_t set;
+ int pid, ret;
+@@ -2366,7 +2357,7 @@ main() {
+ if(pid>0) {
+ sigemptyset(&set);
+ ret=sigsuspend(&set);
+- exit(child==0);
++ return(child==0);
+ }
+ }
+ ]])],[zsh_cv_sys_sigsuspend=yes],[zsh_cv_sys_sigsuspend=no],[zsh_cv_sys_sigsuspend=yes])])
+@@ -2398,15 +2389,14 @@ case "x$zsh_working_tcsetpgrp" in
+ #include <sys/types.h>
+ #include <unistd.h>
+ #include <fcntl.h>
+-#include <stdlib.h>
+-main() {
++int main() {
+ int fd;
+ int ret;
+ fd=open("/dev/tty", O_RDWR);
+- if (fd < 0) exit(2);
++ if (fd < 0) return(2);
+ ret=tcsetpgrp(fd, tcgetpgrp(fd));
+- if (ret < 0) exit(1);
+- exit(0);
++ if (ret < 0) return(1);
++ return(0);
+ }
+ ]])],[zsh_cv_sys_tcsetpgrp=yes],[
+ case $? in
+@@ -2446,7 +2436,7 @@ if test x$ac_cv_func_getpwnam = xyes; then
+ #include <string.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+-main() {
++int main() {
+ struct passwd *pw1, *pw2;
+ char buf[1024], name[1024];
+ sprintf(buf, "%d:%d", getpid(), rand());
+@@ -2454,7 +2444,7 @@ main() {
+ if (pw1) strcpy(name, pw1->pw_name);
+ sprintf(buf, "%d:%d", rand(), getpid());
+ pw2=getpwnam(buf);
+- exit(pw1!=0 && pw2!=0 && !strcmp(name, pw2->pw_name));
++ return(pw1!=0 && pw2!=0 && !strcmp(name, pw2->pw_name));
+ }
+ ]])],[zsh_cv_sys_getpwnam_faked=no],[zsh_cv_sys_getpwnam_faked=yes],[zsh_cv_sys_getpwnam_faked=no])])
+ if test x$zsh_cv_sys_getpwnam_faked = xyes; then
+@@ -2773,20 +2763,17 @@ elif test "x$dynamic" = xyes; then
+ zsh_cv_sys_elf,
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Test for whether ELF binaries are produced */
+ #include <fcntl.h>
+-#include <stdlib.h>
+ #include <unistd.h>
+-main(argc, argv)
+-int argc;
+-char *argv[];
++int main(int argc, char *argv[])
+ {
+ char b[4];
+ int i = open(argv[0],O_RDONLY);
+ if(i == -1)
+- exit(1); /* fail */
++ return(1); /* fail */
+ if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
+- exit(0); /* succeed (yes, it's ELF) */
++ return(0); /* succeed (yes, it's ELF) */
+ else
+- exit(1); /* fail */
++ return(1); /* fail */
+ }]])],[zsh_cv_sys_elf=yes],[zsh_cv_sys_elf=no],[zsh_cv_sys_elf=yes])])
+
+ # We use [0-9]* in case statements, so need to change quoting
+@@ -2922,13 +2909,12 @@ LDFLAGS="$old_LDFLAGS")
+ AC_CACHE_CHECK(if your dlsym() needs a leading underscore,
+ zsh_cv_func_dlsym_needs_underscore,
+ [echo failed >conftestval && cat >conftest.c <<EOM
+-fred () { }
++void fred () { }
+ EOM
+ AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest.c 1>&AS_MESSAGE_LOG_FD) &&
+ AC_TRY_COMMAND($DLLD $LDFLAGS $DLLDFLAGS -o conftest.$DL_EXT conftest.o 1>&AS_MESSAGE_LOG_FD) &&
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #include <stdio.h>
+-#include <stdlib.h>
+ #ifdef HPUX10DYNAMIC
+ #include <dl.h>
+ #define RTLD_LAZY BIND_DEFERRED
+@@ -2955,16 +2941,16 @@ char *zsh_gl_sym_addr ;
+
+ extern int fred() ;
+
+-main()
++int main()
+ {
+ void * handle ;
+ void * symbol ;
+ FILE *f=fopen("conftestval", "w");
+- if (!f) exit(1);
++ if (!f) return(1);
+ handle = dlopen("./conftest.$DL_EXT", RTLD_LAZY) ;
+ if (handle == NULL) {
+ fprintf (f, "dlopen failed") ;
+- exit(1);
++ return(1);
+ }
+ symbol = dlsym(handle, "fred") ;
+ if (symbol == NULL) {
+@@ -2972,13 +2958,13 @@ main()
+ symbol = dlsym(handle, "_fred") ;
+ if (symbol == NULL) {
+ fprintf (f, "dlsym failed") ;
+- exit(1);
++ return(1);
+ }
+ fprintf (f, "yes") ;
+ }
+ else
+ fprintf (f, "no") ;
+- exit(0);
++ return(0);
+ }]])],[zsh_cv_func_dlsym_needs_underscore=`cat conftestval`],[zsh_cv_func_dlsym_needs_underscore=failed
+ dynamic=no],[zsh_cv_func_dlsym_needs_underscore=no])])
+ if test "x$zsh_cv_func_dlsym_needs_underscore" = xyes; then
diff --git a/debian/patches/cherry-pick-727b493e-50736-silence-use-after-free-warning.patch b/debian/patches/cherry-pick-727b493e-50736-silence-use-after-free-warning.patch
new file mode 100644
index 000000000..c1fc7adc4
--- /dev/null
+++ b/debian/patches/cherry-pick-727b493e-50736-silence-use-after-free-warning.patch
@@ -0,0 +1,36 @@
+From 727b493e2b782fca0f3933865faa9a0a6ab1a2c4 Mon Sep 17 00:00:00 2001
+From: Wesley Schwengle <wesleys@opperschaap.net>
+Date: Mon, 17 Oct 2022 13:13:13 +0900
+Subject: [PATCH] 50736: silence use-after-free warning (gcc-12.2)
+
+--- a/Src/Zle/compmatch.c
++++ b/Src/Zle/compmatch.c
+@@ -2045,12 +2045,12 @@
+ zlelineasstring(line, mp->llen, 0, &convlen,
+ NULL, 0);
+ if (rr <= convlen) {
+- char *or = rs;
++ ptrdiff_t diff = rp - rs;
+ int alloclen = (convlen > 20) ? convlen : 20;
+
+ rs = realloc(rs, (rl += alloclen));
+ rr += alloclen;
+- rp += rs - or;
++ rp = rs + diff;
+ }
+ memcpy(rp, convstr, convlen);
+ rp += convlen;
+@@ -2073,11 +2073,11 @@
+ } else {
+ /* Same character, just take it. */
+ if (rr <= 1 /* HERE charlen */) {
+- char *or = rs;
++ ptrdiff_t diff = rp - rs;
+
+ rs = realloc(rs, (rl += 20));
+ rr += 20;
+- rp += rs - or;
++ rp = rs + diff;
+ }
+ /* HERE: multibyte char */
+ *rp++ = *sa;
diff --git a/debian/patches/cherry-pick-ab4d62eb-52383-Avoid-incompatible-pointer-types-in-terminfo-global.patch b/debian/patches/cherry-pick-ab4d62eb-52383-Avoid-incompatible-pointer-types-in-terminfo-global.patch
new file mode 100644
index 000000000..8c87761e6
--- /dev/null
+++ b/debian/patches/cherry-pick-ab4d62eb-52383-Avoid-incompatible-pointer-types-in-terminfo-global.patch
@@ -0,0 +1,49 @@
+From: Florian Weimer <fweimer@redhat.com>
+Date: Fri, 8 Dec 2023 21:58:07 +0100
+Subject: 52383: Avoid incompatible pointer types in terminfo global variable
+ checks
+
+Origin: upstream, commit:https://sourceforge.net/p/zsh/code/ci/4c89849c98172c951a9def3690e8647dae76308f/
+Bug-Debian: https://bugs.debian.org/1075708
+---
+ configure.ac | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index f810052..928b467 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1771,27 +1771,27 @@ if test x$zsh_cv_path_term_header != xnone; then
+ fi
+
+ AC_MSG_CHECKING(if boolcodes is available)
+- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = boolcodes; puts(*test);]])],[AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes],[boolcodes=no])
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolcodes; puts(*test);]])],[AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes],[boolcodes=no])
+ AC_MSG_RESULT($boolcodes)
+
+ AC_MSG_CHECKING(if numcodes is available)
+- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = numcodes; puts(*test);]])],[AC_DEFINE(HAVE_NUMCODES) numcodes=yes],[numcodes=no])
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numcodes; puts(*test);]])],[AC_DEFINE(HAVE_NUMCODES) numcodes=yes],[numcodes=no])
+ AC_MSG_RESULT($numcodes)
+
+ AC_MSG_CHECKING(if strcodes is available)
+- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = strcodes; puts(*test);]])],[AC_DEFINE(HAVE_STRCODES) strcodes=yes],[strcodes=no])
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strcodes; puts(*test);]])],[AC_DEFINE(HAVE_STRCODES) strcodes=yes],[strcodes=no])
+ AC_MSG_RESULT($strcodes)
+
+ AC_MSG_CHECKING(if boolnames is available)
+- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = boolnames; puts(*test);]])],[AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes],[boolnames=no])
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolnames; puts(*test);]])],[AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes],[boolnames=no])
+ AC_MSG_RESULT($boolnames)
+
+ AC_MSG_CHECKING(if numnames is available)
+- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = numnames; puts(*test);]])],[AC_DEFINE(HAVE_NUMNAMES) numnames=yes],[numnames=no])
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numnames; puts(*test);]])],[AC_DEFINE(HAVE_NUMNAMES) numnames=yes],[numnames=no])
+ AC_MSG_RESULT($numnames)
+
+ AC_MSG_CHECKING(if strnames is available)
+- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = strnames; puts(*test);]])],[AC_DEFINE(HAVE_STRNAMES) strnames=yes],[strnames=no])
++ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strnames; puts(*test);]])],[AC_DEFINE(HAVE_STRNAMES) strnames=yes],[strnames=no])
+ AC_MSG_RESULT($strnames)
+
+ dnl There are apparently defective terminal library headers on some
diff --git a/debian/patches/cherry-pick-b62e91134-51723-migrate-pcre-module-to-pcre2.patch b/debian/patches/cherry-pick-b62e91134-51723-migrate-pcre-module-to-pcre2.patch
new file mode 100644
index 000000000..98394347b
--- /dev/null
+++ b/debian/patches/cherry-pick-b62e91134-51723-migrate-pcre-module-to-pcre2.patch
@@ -0,0 +1,514 @@
+commit b62e911341c8ec7446378b477c47da4256053dc0
+Author: Oliver Kiddle <opk@zsh.org>
+Date: Sat May 13 00:53:32 2023 +0200
+
+ 51723: migrate pcre module to pcre2
+
+--- a/Src/Modules/pcre.c
++++ b/Src/Modules/pcre.c
+@@ -34,11 +34,11 @@
+ #define CPCRE_PLAIN 0
+
+ /**/
+-#if defined(HAVE_PCRE_COMPILE) && defined(HAVE_PCRE_EXEC)
+-#include <pcre.h>
++#if defined(HAVE_PCRE2_COMPILE_8) && defined(HAVE_PCRE2_H)
++#define PCRE2_CODE_UNIT_WIDTH 8
++#include <pcre2.h>
+
+-static pcre *pcre_pattern;
+-static pcre_extra *pcre_hints;
++static pcre2_code *pcre_pattern;
+
+ /**/
+ static int
+@@ -58,7 +58,7 @@
+ if ((have_utf8_pcre == -1) &&
+ (!strcmp(nl_langinfo(CODESET), "UTF-8"))) {
+
+- if (pcre_config(PCRE_CONFIG_UTF8, &have_utf8_pcre))
++ if (pcre2_config(PCRE2_CONFIG_UNICODE, &have_utf8_pcre))
+ have_utf8_pcre = -2; /* erk, failed to ask */
+ }
+
+@@ -75,47 +75,38 @@
+ static int
+ bin_pcre_compile(char *nam, char **args, Options ops, UNUSED(int func))
+ {
+- int pcre_opts = 0, pcre_errptr, target_len;
+- const char *pcre_error;
++ uint32_t pcre_opts = 0;
++ int target_len;
++ int pcre_error;
++ PCRE2_SIZE pcre_offset;
+ char *target;
+
+- if(OPT_ISSET(ops,'a')) pcre_opts |= PCRE_ANCHORED;
+- if(OPT_ISSET(ops,'i')) pcre_opts |= PCRE_CASELESS;
+- if(OPT_ISSET(ops,'m')) pcre_opts |= PCRE_MULTILINE;
+- if(OPT_ISSET(ops,'x')) pcre_opts |= PCRE_EXTENDED;
+- if(OPT_ISSET(ops,'s')) pcre_opts |= PCRE_DOTALL;
++ if (OPT_ISSET(ops, 'a')) pcre_opts |= PCRE2_ANCHORED;
++ if (OPT_ISSET(ops, 'i')) pcre_opts |= PCRE2_CASELESS;
++ if (OPT_ISSET(ops, 'm')) pcre_opts |= PCRE2_MULTILINE;
++ if (OPT_ISSET(ops, 'x')) pcre_opts |= PCRE2_EXTENDED;
++ if (OPT_ISSET(ops, 's')) pcre_opts |= PCRE2_DOTALL;
+
+ if (zpcre_utf8_enabled())
+- pcre_opts |= PCRE_UTF8;
+-
+-#ifdef HAVE_PCRE_STUDY
+- if (pcre_hints)
+-#ifdef PCRE_CONFIG_JIT
+- pcre_free_study(pcre_hints);
+-#else
+- pcre_free(pcre_hints);
+-#endif
+- pcre_hints = NULL;
+-#endif
++ pcre_opts |= PCRE2_UTF;
+
+ if (pcre_pattern)
+- pcre_free(pcre_pattern);
++ pcre2_code_free(pcre_pattern);
+ pcre_pattern = NULL;
+
+ target = ztrdup(*args);
+ unmetafy(target, &target_len);
+
+- if ((int)strlen(target) != target_len) {
+- zwarnnam(nam, "embedded NULs in PCRE pattern terminate pattern");
+- }
+-
+- pcre_pattern = pcre_compile(target, pcre_opts, &pcre_error, &pcre_errptr, NULL);
++ pcre_pattern = pcre2_compile((PCRE2_SPTR) target, (PCRE2_SIZE) target_len,
++ pcre_opts, &pcre_error, &pcre_offset, NULL);
+
+ free(target);
+
+ if (pcre_pattern == NULL)
+ {
+- zwarnnam(nam, "error in regex: %s", pcre_error);
++ PCRE2_UCHAR buffer[256];
++ pcre2_get_error_message(pcre_error, buffer, sizeof(buffer));
++ zwarnnam(nam, "error in regex: %s", buffer);
+ return 1;
+ }
+
+@@ -123,67 +114,48 @@
+ }
+
+ /**/
+-#ifdef HAVE_PCRE_STUDY
+-
+-/**/
+ static int
+ bin_pcre_study(char *nam, UNUSED(char **args), UNUSED(Options ops), UNUSED(int func))
+ {
+- const char *pcre_error;
+-
+ if (pcre_pattern == NULL)
+ {
+ zwarnnam(nam, "no pattern has been compiled for study");
+ return 1;
+ }
+-
+- if (pcre_hints)
+-#ifdef PCRE_CONFIG_JIT
+- pcre_free_study(pcre_hints);
+-#else
+- pcre_free(pcre_hints);
+-#endif
+- pcre_hints = NULL;
+
+- pcre_hints = pcre_study(pcre_pattern, 0, &pcre_error);
+- if (pcre_error != NULL)
+- {
+- zwarnnam(nam, "error while studying regex: %s", pcre_error);
+- return 1;
++ int jit = 0;
++ if (!pcre2_config(PCRE2_CONFIG_JIT, &jit) && jit) {
++ if (pcre2_jit_compile(pcre_pattern, PCRE2_JIT_COMPLETE) < 0) {
++ zwarnnam(nam, "error while studying regex");
++ return 1;
++ }
+ }
+
+ return 0;
+ }
+
+-/**/
+-#else /* !HAVE_PCRE_STUDY */
+-
+-# define bin_pcre_study bin_notavail
+-
+-/**/
+-#endif /* !HAVE_PCRE_STUDY */
+-
+-/**/
+ static int
+-zpcre_get_substrings(char *arg, int *ovec, int captured_count, char *matchvar,
+- char *substravar, int want_offset_pair, int matchedinarr,
+- int want_begin_end)
++zpcre_get_substrings(char *arg, pcre2_match_data *mdata, int captured_count,
++ char *matchvar, char *substravar, int want_offset_pair,
++ int matchedinarr, int want_begin_end)
+ {
+- char **captures, *match_all, **matches;
++ PCRE2_SIZE *ovec;
++ char *match_all, **matches;
+ char offset_all[50];
+ int capture_start = 1;
+
+ if (matchedinarr) {
+- /* bash-style captures[0] entire-matched string in the array */
++ /* bash-style ovec[0] entire-matched string in the array */
+ capture_start = 0;
+ }
+
+- /* captures[0] will be entire matched string, [1] first substring */
+- if (!pcre_get_substring_list(arg, ovec, captured_count, (const char ***)&captures)) {
+- int nelem = arrlen(captures)-1;
++ /* ovec[0] will be entire matched string, [1] first substring */
++ ovec = pcre2_get_ovector_pointer(mdata);
++ if (ovec) {
++ int nelem = captured_count - 1;
+ /* Set to the offsets of the complete match */
+ if (want_offset_pair) {
+- sprintf(offset_all, "%d %d", ovec[0], ovec[1]);
++ sprintf(offset_all, "%ld %ld", ovec[0], ovec[1]);
+ setsparam("ZPCRE_OP", ztrdup(offset_all));
+ }
+ /*
+@@ -192,7 +164,7 @@
+ * ovec is length 2*(1+capture_list_length)
+ */
+ if (matchvar) {
+- match_all = metafy(captures[0], ovec[1] - ovec[0], META_DUP);
++ match_all = metafy(arg + ovec[0], ovec[1] - ovec[0], META_DUP);
+ setsparam(matchvar, match_all);
+ }
+ /*
+@@ -207,16 +179,12 @@
+ */
+ if (substravar &&
+ (!want_begin_end || nelem)) {
+- char **x, **y;
++ char **x;
+ int vec_off, i;
+- y = &captures[capture_start];
+ matches = x = (char **) zalloc(sizeof(char *) * (captured_count+1-capture_start));
+- for (i = capture_start; i < captured_count; i++, y++) {
++ for (i = capture_start; i < captured_count; i++) {
+ vec_off = 2*i;
+- if (*y)
+- *x++ = metafy(*y, ovec[vec_off+1]-ovec[vec_off], META_DUP);
+- else
+- *x++ = NULL;
++ *x++ = metafy(arg + ovec[vec_off], ovec[vec_off+1]-ovec[vec_off], META_DUP);
+ }
+ *x = NULL;
+ setaparam(substravar, matches);
+@@ -253,7 +221,8 @@
+ setiparam("MEND", offs + !isset(KSHARRAYS) - 1);
+ if (nelem) {
+ char **mbegin, **mend, **bptr, **eptr;
+- int i, *ipair;
++ int i;
++ size_t *ipair;
+
+ bptr = mbegin = zalloc(sizeof(char*)*(nelem+1));
+ eptr = mend = zalloc(sizeof(char*)*(nelem+1));
+@@ -293,8 +262,6 @@
+ setaparam("mend", mend);
+ }
+ }
+-
+- pcre_free_substring_list((const char **)captures);
+ }
+
+ return 0;
+@@ -320,7 +287,8 @@
+ static int
+ bin_pcre_match(char *nam, char **args, Options ops, UNUSED(int func))
+ {
+- int ret, capcount, *ovec, ovecsize, c;
++ int ret, c;
++ pcre2_match_data *pcre_mdata = NULL;
+ char *matched_portion = NULL;
+ char *plaintext = NULL;
+ char *receptacle = NULL;
+@@ -350,36 +318,30 @@
+ /* For the entire match, 'Return' the offset byte positions instead of the matched string */
+ if(OPT_ISSET(ops,'b')) want_offset_pair = 1;
+
+- if ((ret = pcre_fullinfo(pcre_pattern, pcre_hints, PCRE_INFO_CAPTURECOUNT, &capcount)))
+- {
+- zwarnnam(nam, "error %d in fullinfo", ret);
+- return 1;
+- }
+-
+- ovecsize = (capcount+1)*3;
+- ovec = zalloc(ovecsize*sizeof(int));
+-
+ plaintext = ztrdup(*args);
+ unmetafy(plaintext, &subject_len);
+
+ if (offset_start > 0 && offset_start >= subject_len)
+- ret = PCRE_ERROR_NOMATCH;
+- else
+- ret = pcre_exec(pcre_pattern, pcre_hints, plaintext, subject_len, offset_start, 0, ovec, ovecsize);
++ ret = PCRE2_ERROR_NOMATCH;
++ else {
++ pcre_mdata = pcre2_match_data_create_from_pattern(pcre_pattern, NULL);
++ ret = pcre2_match(pcre_pattern, (PCRE2_SPTR) plaintext, subject_len,
++ offset_start, 0, pcre_mdata, NULL);
++ }
+
+ if (ret==0) return_value = 0;
+- else if (ret==PCRE_ERROR_NOMATCH) /* no match */;
++ else if (ret == PCRE2_ERROR_NOMATCH) /* no match */;
+ else if (ret>0) {
+- zpcre_get_substrings(plaintext, ovec, ret, matched_portion, receptacle,
++ zpcre_get_substrings(plaintext, pcre_mdata, ret, matched_portion, receptacle,
+ want_offset_pair, 0, 0);
+ return_value = 0;
+ }
+ else {
+- zwarnnam(nam, "error in pcre_exec [%d]", ret);
++ zwarnnam(nam, "error in pcre2_match [%d]", ret);
+ }
+
+- if (ovec)
+- zfree(ovec, ovecsize*sizeof(int));
++ if (pcre_mdata)
++ pcre2_match_data_free(pcre_mdata);
+ zsfree(plaintext);
+
+ return return_value;
+@@ -389,17 +351,19 @@
+ static int
+ cond_pcre_match(char **a, int id)
+ {
+- pcre *pcre_pat;
+- const char *pcre_err;
++ pcre2_code *pcre_pat = NULL;
++ int pcre_err;
++ PCRE2_SIZE pcre_erroff;
+ char *lhstr, *rhre, *lhstr_plain, *rhre_plain, *avar, *svar;
+- int r = 0, pcre_opts = 0, pcre_errptr, capcnt, *ov, ovsize;
++ int r = 0, pcre_opts = 0;
++ pcre2_match_data *pcre_mdata = NULL;
+ int lhstr_plain_len, rhre_plain_len;
+ int return_value = 0;
+
+ if (zpcre_utf8_enabled())
+- pcre_opts |= PCRE_UTF8;
++ pcre_opts |= PCRE2_UTF;
+ if (isset(REMATCHPCRE) && !isset(CASEMATCH))
+- pcre_opts |= PCRE_CASELESS;
++ pcre_opts |= PCRE2_CASELESS;
+
+ lhstr = cond_str(a,0,0);
+ rhre = cond_str(a,1,0);
+@@ -407,9 +371,6 @@
+ rhre_plain = ztrdup(rhre);
+ unmetafy(lhstr_plain, &lhstr_plain_len);
+ unmetafy(rhre_plain, &rhre_plain_len);
+- pcre_pat = NULL;
+- ov = NULL;
+- ovsize = 0;
+
+ if (isset(BASHREMATCH)) {
+ svar = NULL;
+@@ -421,27 +382,27 @@
+
+ switch(id) {
+ case CPCRE_PLAIN:
+- if ((int)strlen(rhre_plain) != rhre_plain_len) {
+- zwarn("embedded NULs in PCRE pattern terminate pattern");
+- }
+- pcre_pat = pcre_compile(rhre_plain, pcre_opts, &pcre_err, &pcre_errptr, NULL);
+- if (pcre_pat == NULL) {
+- zwarn("failed to compile regexp /%s/: %s", rhre, pcre_err);
++ if (!(pcre_pat = pcre2_compile((PCRE2_SPTR) rhre_plain,
++ (PCRE2_SIZE) rhre_plain_len, pcre_opts,
++ &pcre_err, &pcre_erroff, NULL)))
++ {
++ PCRE2_UCHAR buffer[256];
++ pcre2_get_error_message(pcre_err, buffer, sizeof(buffer));
++ zwarn("failed to compile regexp /%s/: %s", rhre, buffer);
+ break;
+ }
+- pcre_fullinfo(pcre_pat, NULL, PCRE_INFO_CAPTURECOUNT, &capcnt);
+- ovsize = (capcnt+1)*3;
+- ov = zalloc(ovsize*sizeof(int));
+- r = pcre_exec(pcre_pat, NULL, lhstr_plain, lhstr_plain_len, 0, 0, ov, ovsize);
+- /* r < 0 => error; r==0 match but not enough size in ov
++ pcre_mdata = pcre2_match_data_create_from_pattern(pcre_pat, NULL);
++ r = pcre2_match(pcre_pat, (PCRE2_SPTR8) lhstr_plain, lhstr_plain_len,
++ 0, 0, pcre_mdata, NULL);
++ /* r < 0 => error; r==0 match but not enough size in match data
+ * r > 0 => (r-1) substrings found; r==1 => no substrings
+ */
+ if (r==0) {
+- zwarn("reportable zsh problem: pcre_exec() returned 0");
++ zwarn("reportable zsh problem: pcre2_match() returned 0");
+ return_value = 1;
+ break;
+ }
+- else if (r==PCRE_ERROR_NOMATCH) {
++ else if (r == PCRE2_ERROR_NOMATCH) {
+ return_value = 0; /* no match */
+ break;
+ }
+@@ -450,7 +411,7 @@
+ break;
+ }
+ else if (r>0) {
+- zpcre_get_substrings(lhstr_plain, ov, r, svar, avar, 0,
++ zpcre_get_substrings(lhstr_plain, pcre_mdata, r, svar, avar, 0,
+ isset(BASHREMATCH),
+ !isset(BASHREMATCH));
+ return_value = 1;
+@@ -463,10 +424,10 @@
+ free(lhstr_plain);
+ if(rhre_plain)
+ free(rhre_plain);
++ if (pcre_mdata)
++ pcre2_match_data_free(pcre_mdata);
+ if (pcre_pat)
+- pcre_free(pcre_pat);
+- if (ov)
+- zfree(ov, ovsize*sizeof(int));
++ pcre2_code_free(pcre_pat);
+
+ return return_value;
+ }
+@@ -495,11 +456,11 @@
+
+ static struct features module_features = {
+ bintab, sizeof(bintab)/sizeof(*bintab),
+-#if defined(HAVE_PCRE_COMPILE) && defined(HAVE_PCRE_EXEC)
++#if defined(HAVE_PCRE2_COMPILE_8) && defined(HAVE_PCRE2_H)
+ cotab, sizeof(cotab)/sizeof(*cotab),
+-#else /* !(HAVE_PCRE_COMPILE && HAVE_PCRE_EXEC) */
++#else /* !(HAVE_PCRE2_COMPILE_8 && HAVE_PCRE2_H) */
+ NULL, 0,
+-#endif /* !(HAVE_PCRE_COMPILE && HAVE_PCRE_EXEC) */
++#endif /* !(HAVE_PCRE2_COMPILE_8 && HAVE_PCRE2_H) */
+ NULL, 0,
+ NULL, 0,
+ 0
+@@ -546,19 +507,9 @@
+ int
+ finish_(UNUSED(Module m))
+ {
+-#if defined(HAVE_PCRE_COMPILE) && defined(HAVE_PCRE_EXEC)
+-#ifdef HAVE_PCRE_STUDY
+- if (pcre_hints)
+-#ifdef PCRE_CONFIG_JIT
+- pcre_free_study(pcre_hints);
+-#else
+- pcre_free(pcre_hints);
+-#endif
+- pcre_hints = NULL;
+-#endif
+-
++#if defined(HAVE_PCRE2_COMPILE_8) && defined(HAVE_PCRE2_H)
+ if (pcre_pattern)
+- pcre_free(pcre_pattern);
++ pcre2_code_free(pcre_pattern);
+ pcre_pattern = NULL;
+ #endif
+
+--- a/Test/V07pcre.ztst
++++ b/Test/V07pcre.ztst
+@@ -129,12 +129,17 @@
+ >78884; ZPCRE_OP: 25 30
+ >90210; ZPCRE_OP: 31 36
+
+-# Embedded NULs allowed in plaintext, but not in RE (although \0 as two-chars allowed)
++# Embedded NULs allowed in plaintext, in RE, pcre supports \0 as two-chars
+ [[ $'a\0bc\0d' =~ '^(a\0.)(.+)$' ]]
+ print "${#MATCH}; ${#match[1]}; ${#match[2]}"
+ 0:ensure ASCII NUL passes in and out of matched plaintext
+ >6; 3; 3
+
++# PCRE2 supports NULs also in the RE
++ [[ $'a\0b\0c' =~ $'^(.\0)+' ]] && print "${#MATCH}; ${#match[1]}"
++0:ensure ASCII NUL works also in the regex
++>4; 2
++
+ # Ensure the long-form infix operator works
+ [[ foo -pcre-match ^f..$ ]]
+ print $?
+@@ -174,3 +179,7 @@
+ echo $match[2] )
+ 0:regression for segmentation fault, workers/38307
+ >test
++
++ [[ abc =~ 'a(d*)bc' ]] && print "$#MATCH; $#match; ${#match[1]}"
++0:empty capture
++>3; 1; 0
+--- a/configure.ac
++++ b/configure.ac
+@@ -438,7 +438,7 @@
+
+ dnl Do you want to look for pcre support?
+ AC_ARG_ENABLE(pcre,
+-AS_HELP_STRING([--enable-pcre],[enable the search for the pcre library (may create run-time library dependencies)]))
++AS_HELP_STRING([--enable-pcre],[enable the search for the pcre2 library (may create run-time library dependencies)]))
+
+ dnl Do you want to look for capability support?
+ AC_ARG_ENABLE(cap,
+@@ -662,13 +662,12 @@
+
+ oldcflags="$CFLAGS"
+ if test x$enable_pcre = xyes; then
+-AC_CHECK_PROG([PCRECONF], pcre-config, pcre-config)
+-dnl Typically (meaning on this single RedHat 9 box in front of me)
+-dnl pcre-config --cflags produces a -I output which needs to go into
++AC_CHECK_PROG([PCRECONF], pcre2-config, pcre2-config)
++dnl pcre2-config --cflags may produce a -I output which needs to go into
+ dnl CPPFLAGS else configure's preprocessor tests don't pick it up,
+ dnl producing a warning.
+-if test "x$ac_cv_prog_PCRECONF" = xpcre-config; then
+- CPPFLAGS="$CPPFLAGS `pcre-config --cflags`"
++if test "x$ac_cv_prog_PCRECONF" = xpcre2-config; then
++ CPPFLAGS="$CPPFLAGS `pcre2-config --cflags`"
+ fi
+ fi
+
+@@ -678,9 +677,10 @@
+ locale.h errno.h stdio.h stdarg.h varargs.h stdlib.h \
+ unistd.h sys/capability.h \
+ utmp.h utmpx.h sys/types.h pwd.h grp.h poll.h sys/mman.h \
+- netinet/in_systm.h pcre.h langinfo.h wchar.h stddef.h \
++ netinet/in_systm.h langinfo.h wchar.h stddef.h \
+ sys/stropts.h iconv.h ncurses.h ncursesw/ncurses.h \
+ ncurses/ncurses.h)
++AC_CHECK_HEADERS([pcre2.h],,,[#define PCRE2_CODE_UNIT_WIDTH 8])
+ if test x$dynamic = xyes; then
+ AC_CHECK_HEADERS(dlfcn.h)
+ AC_CHECK_HEADERS(dl.h)
+@@ -958,9 +958,7 @@
+ fi
+
+ if test x$enable_pcre = xyes; then
+-dnl pcre-config should probably be employed here
+-dnl AC_SEARCH_LIBS(pcre_compile, pcre)
+- LIBS="`$ac_cv_prog_PCRECONF --libs` $LIBS"
++ LIBS="`$ac_cv_prog_PCRECONF --libs8` $LIBS"
+ fi
+
+ dnl ---------------------
+@@ -1323,7 +1321,7 @@
+ pathconf sysconf \
+ tgetent tigetflag tigetnum tigetstr setupterm initscr resize_term \
+ getcchar setcchar waddwstr wget_wch win_wch use_default_colors \
+- pcre_compile pcre_study pcre_exec \
++ pcre2_compile_8 \
+ nl_langinfo \
+ erand48 open_memstream \
+ posix_openpt \
diff --git a/debian/patches/cherry-pick-ecd3f9c9-1057610-support-texinfo-7.0.patch b/debian/patches/cherry-pick-ecd3f9c9-1057610-support-texinfo-7.0.patch
new file mode 100644
index 000000000..a766721f6
--- /dev/null
+++ b/debian/patches/cherry-pick-ecd3f9c9-1057610-support-texinfo-7.0.patch
@@ -0,0 +1,44 @@
+commit ecd3f9c9506c7720dc6c0833dc5d5eb00e4459c4
+Author: Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
+Date: Mon Jun 19 11:19:25 2023 +0900
+
+ 51862: support texinfo-7.0
+
+diff --git a/Doc/Makefile.in b/Doc/Makefile.in
+index 136b080d6..dabe11fe3 100644
+--- a/Doc/Makefile.in
++++ b/Doc/Makefile.in
+@@ -43,6 +43,7 @@ TEXI2DVI = @TEXI2DVI@
+ DVIPS = dvips
+ TEXI2PDF = @TEXI2PDF@
+ TEXI2HTML = @TEXI2HTML@
++SET_TEXI2ANY_VAR = @SET_TEXI2ANY_VAR@
+ PAPERSIZE = @PAPERSIZE@
+
+ .SUFFIXES: .yo .1
+@@ -266,7 +267,7 @@ texi2html.conf: $(sdir_top)/Config/version.mk
+ d=`echo $(VERSION_DATE)`; \
+ v="<font size=\"-1\">Zsh version $(VERSION), released on $$d.</font>"; \
+ case '$(TEXI2HTML)' in \
+- *texi2any*) echo "set_from_init_file('PRE_BODY_CLOSE','$$v');" ;; \
++ *texi2any*) echo "$(SET_TEXI2ANY_VAR)('PRE_BODY_CLOSE','$$v');" ;; \
+ *) echo "\$$PRE_BODY_CLOSE = '$$v';" ;; \
+ esac > $@
+
+diff --git a/configure.ac b/configure.ac
+index 4710d1659..ba76f9a60 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -623,7 +623,12 @@ fi
+
+ if test x"$TEXI2HTML" = xtexi2any; then
+ TEXI2HTML='texi2any -c TEXI2HTML=1'
++ case `texi2any --version 2>/dev/null | sed -e 's/^.*) *//' -e 1q` in
++ [[1-6]].*) SET_TEXI2ANY_VAR=set_from_init_file ;;
++ *) SET_TEXI2ANY_VAR=texinfo_set_from_init_file ;;
++ esac
+ fi
++AC_SUBST(SET_TEXI2ANY_VAR)
+
+ case "$LC_PAPER" in
+ ??_US*) PAPERSIZE=us ;;
diff --git a/debian/patches/completion-dscverify.diff b/debian/patches/completion-dscverify.diff
new file mode 100644
index 000000000..6c5c02264
--- /dev/null
+++ b/debian/patches/completion-dscverify.diff
@@ -0,0 +1,40 @@
+Description: Add completion for dscverify(1) from Debian's devscripts.
+Author: Romain Porte <debian@microjoe.org>
+Reviewed-by: Daniel Shahaf <danielsh@apache.org>
+Bug-Debian: https://bugs.debian.org/953389
+Forwarded: https://www.zsh.org/mla/workers/2020/msg00350.html
+Applied-Upstream: master, https://sourceforge.net/p/zsh/code/ci/0d7f888945bd487d6458807684883b22dc3b31b8/#diff-1
+Last-Update: 2020-03-21
+--- a/Completion/Debian/Command/_dscverify
++++ b/Completion/Debian/Command/_dscverify
+@@ -0,0 +1,30 @@
++#compdef dscverify
++
++# $ dscverify --version
++# This is dscverify, from the Debian devscripts package, version 2.20.2
++# ...
++
++_dscverify() {
++ local all_opts=(
++ '--help[show the help message and exit]'
++ '--version[show the version + copyright and exit]'
++ '--no-default-keyrings[do not check against the default keyrings]'
++ '*--keyring[add keyring to the list of keyrings used]:keyring:_files -g "*.{kbx,gpg}(-.)"'
++ '(--nosigcheck --no-sig-check -u)'{--nosigcheck,--no-sig-check,-u}'[do not verify the GPG signature]'
++ '--verbose[do not suppress GPG output]'
++ '*:dsc file:_files -g "*.{changes,dsc,buildinfo}(-.)"'
++ )
++
++ local first_only=(
++ '(--no-conf --noconf)'{--no-conf,--noconf}'[do not read the devscripts config file]'
++ )
++
++ if (( CURRENT == 2 )); then
++ all_opts+=($first_only)
++ fi
++
++ _arguments \
++ "$all_opts[@]"
++}
++
++_dscverify "$@"
diff --git a/debian/patches/cross-compile.diff b/debian/patches/cross-compile.diff
new file mode 100644
index 000000000..ca5f75e81
--- /dev/null
+++ b/debian/patches/cross-compile.diff
@@ -0,0 +1,63 @@
+Description: Adjust cross-compile fallback values to yes.
+Origin: commit, revision id: dmitrijs.ledkovs@canonical.com-20121220153357-amh2d7kzw5d314mt
+Author: Dmitrijs Ledkovs <dmitrijs.ledkovs@canonical.com>
+Last-Update: 2012-12-20
+X-Bzr-Revision-Id: dmitrijs.ledkovs@canonical.com-20121220153357-amh2d7kzw5d314mt
+
+=== modified file 'aczsh.m4'
+--- a/aczsh.m4
++++ b/aczsh.m4
+@@ -172,7 +172,7 @@
+ }
+ ]])],[zsh_cv_shared_$1=yes],
+ [zsh_cv_shared_$1=no],
+-[zsh_cv_shared_$1=no]
++[zsh_cv_shared_$1=yes]
+ )
+ else
+ zsh_cv_shared_$1=no
+@@ -244,7 +244,7 @@
+ }
+ ]])],[zsh_cv_sys_dynamic_clash_ok=yes],
+ [zsh_cv_sys_dynamic_clash_ok=no],
+-[zsh_cv_sys_dynamic_clash_ok=no]
++[zsh_cv_sys_dynamic_clash_ok=yes]
+ )
+ else
+ zsh_cv_sys_dynamic_clash_ok=no
+@@ -318,7 +318,7 @@
+ }
+ ]])],[zsh_cv_sys_dynamic_rtld_global=yes],
+ [zsh_cv_sys_dynamic_rtld_global=no],
+-[zsh_cv_sys_dynamic_rtld_global=no]
++[zsh_cv_sys_dynamic_rtld_global=yes]
+ )
+ else
+ zsh_cv_sys_dynamic_rtld_global=no
+@@ -388,7 +388,7 @@
+ int fred () { return 42; }
+ ]])],[zsh_cv_sys_dynamic_execsyms=yes],
+ [zsh_cv_sys_dynamic_execsyms=no],
+-[zsh_cv_sys_dynamic_execsyms=no]
++[zsh_cv_sys_dynamic_execsyms=yes]
+ )
+ LDFLAGS=$save_ldflags
+ else
+@@ -462,7 +462,7 @@
+ int fred () { return 42; }
+ ]])],[zsh_cv_sys_dynamic_strip_exe=yes],
+ [zsh_cv_sys_dynamic_strip_exe=no],
+-[zsh_cv_sys_dynamic_strip_exe=no]
++[zsh_cv_sys_dynamic_strip_exe=yes]
+ )
+ LDFLAGS=$save_ldflags
+ else
+@@ -528,7 +528,7 @@
+ }
+ ]])],[zsh_cv_sys_dynamic_strip_lib=yes],
+ [zsh_cv_sys_dynamic_strip_lib=no],
+-[zsh_cv_sys_dynamic_strip_lib=no]
++[zsh_cv_sys_dynamic_strip_lib=yes]
+ )
+ else
+ zsh_cv_sys_dynamic_strip_lib=no
diff --git a/debian/patches/example-shebang.patch b/debian/patches/example-shebang.patch
new file mode 100644
index 000000000..cc3c63fa7
--- /dev/null
+++ b/debian/patches/example-shebang.patch
@@ -0,0 +1,12 @@
+Description: Change shebang path in example script to Debian's zsh path
+Author: Axel Beckert <abe@debian.org>
+Forwarded: not-needed
+
+--- a/Util/reporter
++++ b/Util/reporter
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/zsh
++#!/bin/zsh
+ #
+ # NAME:
+ # reporter
diff --git a/debian/patches/fix-typos-in-man-pages.patch b/debian/patches/fix-typos-in-man-pages.patch
new file mode 100644
index 000000000..2223dd210
--- /dev/null
+++ b/debian/patches/fix-typos-in-man-pages.patch
@@ -0,0 +1,26 @@
+Description: Fix two typos in man pages found by Lintian
+Author: Axel Beckert <abe@debian.org>
+Origin: commit 361de369edd3bd17066b5f72e056e487545b364e
+
+--- a/Doc/Zsh/builtins.yo
++++ b/Doc/Zsh/builtins.yo
+@@ -1936,7 +1936,7 @@
+
+ For each var(name)tt(=)var(value) assignment, the parameter
+ var(name) is set to var(value). If the assignment is omitted and var(name)
+-does em(not) refer to an existing parameter, a new parameter is intialized
++does em(not) refer to an existing parameter, a new parameter is initialized
+ to empty string, zero, or empty array (as appropriate), em(unless) the
+ shell option tt(TYPESET_TO_UNSET) is set. When that option is set,
+ the parameter attributes are recorded but the parameter remains unset.
+--- a/Doc/Zsh/options.yo
++++ b/Doc/Zsh/options.yo
+@@ -1952,7 +1952,7 @@
+ item(tt(TYPESET_TO_UNSET) <K> <S>)(
+ When declaring a new parameter with any of the `tt(typeset)' family of
+ related commands, the parameter remains unset unless and until a
+-value is explicity assigned to it, either in the `tt(typeset)' command
++value is explicitly assigned to it, either in the `tt(typeset)' command
+ itself or as a later assignment statement.
+ )
+ pindex(VERBOSE)
diff --git a/debian/patches/further-mitigate-test-suite-hangs.patch b/debian/patches/further-mitigate-test-suite-hangs.patch
new file mode 100644
index 000000000..cf22be741
--- /dev/null
+++ b/debian/patches/further-mitigate-test-suite-hangs.patch
@@ -0,0 +1,15 @@
+Origin: https://www.zsh.org/mla/workers/2014/msg01250.html
+Author: Bart Schaefer <schaefer@brasslantern.com>
+Bug-Debian: https://bugs.debian.org/759870
+Description: Add a sleep call which should prevent a race condition in coproc
+
+--- a/Test/A05execution.ztst
++++ b/Test/A05execution.ztst
+@@ -239,6 +239,7 @@
+ print -u $ZTST_fd 'This test takes 5 seconds to fail...'
+ { printf "%d\n" {1..20000} } 2>/dev/null | ( read -e )
+ hang(){ printf "%d\n" {2..20000} | cat }; hang 2>/dev/null | ( read -e )
++ sleep 1 ;: avoid coproc exit race condition
+ print -p done
+ read -et 6 -p
+ 0:Bug regression: piping a shell construct to an external process may hang
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 000000000..bb3322aa1
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1,16 @@
+further-mitigate-test-suite-hangs.patch
+update-debian-sections.patch
+cross-compile.diff
+example-shebang.patch
+completion-dscverify.diff
+use-pager-instead-of-more-by-default.patch
+fix-typos-in-man-pages.patch
+cherry-pick-3e3cfabc-revert-38150-and-fix-in-calling-function-cfp_matcher_range-instead.patch
+cherry-pick-4b7a9fd0-additional-typset--p--m-fix-for-namespaces.patch
+cherry-pick-b62e91134-51723-migrate-pcre-module-to-pcre2.patch
+cherry-pick-10bdbd8b-51877-do-not-build-pcre-module-if-pcre2-config-is-not-found.patch
+cherry-pick-ecd3f9c9-1057610-support-texinfo-7.0.patch
+cherry-pick-4c89849c-50641-use-int-main-in-test-C-codes-in-configure.patch
+cherry-pick-ab4d62eb-52383-Avoid-incompatible-pointer-types-in-terminfo-global.patch
+cherry-pick-0bb140f9-52999-import-OLDPWD-from-environment-if-set.patch
+cherry-pick-727b493e-50736-silence-use-after-free-warning.patch
diff --git a/debian/patches/update-debian-sections.patch b/debian/patches/update-debian-sections.patch
new file mode 100644
index 000000000..390f5c701
--- /dev/null
+++ b/debian/patches/update-debian-sections.patch
@@ -0,0 +1,51 @@
+From a7204dd6176d4c1305de7092525c8037fd335acf Mon Sep 17 00:00:00 2001
+From: Josh Triplett <josh@joshtriplett.org>
+Date: Thu, 8 Dec 2016 20:19:18 -0800
+Subject: [PATCH] Update for new programming language sections
+Origin: https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=847540;filename=0001-Update-for-new-programming-language-sections.patch;msg=13
+Bug-Debian: https://bugs.debian.org/847540
+Forwarded: not-yet
+Reviewed-By: Axel Beckert <abe@debian.org>, Daniel Shahaf <danielsh@apache.org>
+
+---
+ Completion/Debian/Command/_dak | 2 +-
+ Completion/Debian/Command/_debfoster | 2 ++
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/Completion/Debian/Command/_dak b/Completion/Debian/Command/_dak
+index 086196c4a..d06f55d23 100644
+--- a/Completion/Debian/Command/_dak
++++ b/Completion/Debian/Command/_dak
+@@ -37,7 +37,7 @@
+ '(-n --no-action)'{-n,--no-action}'[do not do anything]'
+ '(-s --suite)'{-s,--suite=}':suite:_values -s , "suite list" oldstable stable testing unstable experimental'
+ ':package:_deb_packages avail'
+- ':section:(admin base comm contrib/admin contrib/comm contrib/devel contrib/doc contrib/games contrib/graphics contrib/interpreters contrib/kde contrib/libdevel contrib/libs contrib/mail contrib/math contrib/misc contrib/net contrib/otherosfs contrib/perl contrib/python contrib/science contrib/sound contrib/tex contrib/text contrib/utils contrib/web contrib/x11 devel doc editors electronics embedded games gnome graphics hamradio interpreters kde libdevel libs mail math misc net news non-free/admin non-free/base non-free/comm non-free/devel non-free/doc non-free/editors non-free/electronics non-free/games non-free/graphics non-free/hamradio non-free/libdevel non-free/libs non-free/mail non-free/math non-free/misc non-free/net non-free/news non-free/otherosfs non-free/python non-free/science non-free/sound non-free/tex non-free/text non-free/utils non-free/web non-free/x11 oldlibs otherosfs perl python science shells sound tex text utils web x11)'
++ ':section:({,contrib/,non-free/}{admin,cli-mono,comm,database,debug,devel,doc,editors,education,electronics,embedded,fonts,games,gnome,gnu-r,gnustep,graphics,hamradio,haskell,httpd,interpreters,introspection,java,javascript,kde,kernel,libdevel,libs,lisp,localization,mail,math,metapackages,misc,net,news,ocaml,oldlibs,otherosfs,perl,php,python,ruby,rust,science,shells,sound,tex,text,utils,vcs,video,web,x11,xfce,zope})'
+ ':priority:(extra important optional required standard)'
+ )
+ ;;
+diff --git a/Completion/Debian/Command/_debfoster b/Completion/Debian/Command/_debfoster
+index 08a1078e2..4c041bc36 100644
+--- a/Completion/Debian/Command/_debfoster
++++ b/Completion/Debian/Command/_debfoster
+@@ -44,10 +44,13 @@
+ ;;
+ *(#i)(no|)keepsections*)
+ _wanted values expl 'section' compadd \
+- x11 web utils text tex sound shells science \
+- otherosfs oldlibs news net misc math mail libs \
+- interpreters hamradio graphics games electronics \
+- editors doc devel comm base admin && ret=0
++ zope xfce x11 web video vcs utils text tex sound shells \
++ science rust ruby python php perl otherosfs oldlibs ocaml \
++ news net misc metapackages math mail localization lisp libs \
++ libdevel kernel kde javascript java introspection \
++ interpreters httpd haskell hamradio graphics gnustep gnu-r \
++ gnome games fonts embedded electronics education editors doc \
++ devel debug database comm cli-mono admin && ret=0
+ ;;
+ *(#i)guessdepends*)
+ _wanted values expl 'name extension' \
+--
+2.11.0
diff --git a/debian/patches/use-pager-instead-of-more-by-default.patch b/debian/patches/use-pager-instead-of-more-by-default.patch
new file mode 100644
index 000000000..2c91e267e
--- /dev/null
+++ b/debian/patches/use-pager-instead-of-more-by-default.patch
@@ -0,0 +1,104 @@
+Description: Use /usr/bin/pager instead of more by default
+ Similar issue as with https://bugs.debian.org/993539, just for a
+ different setting. Replaces the according sed call in debian/rules.
+Bug-Debian: https://bugs.debian.org/993539
+Forwarded: not-needed
+Author: Axel Beckert <abe@debian.org>
+
+--- a/Completion/Base/Widget/_complete_debug
++++ b/Completion/Base/Widget/_complete_debug
+@@ -28,7 +28,7 @@
+
+ if (( debug_fd != -1 )); then
+ zstyle -s ':completion:complete-debug::::' pager pager
+- print -sR "${pager:-${PAGER:-${VISUAL:-${EDITOR:-more}}}} ${(q)tmp} ;: $w"
++ print -sR "${pager:-${PAGER:-${VISUAL:-${EDITOR:-/usr/bin/pager}}}} ${(q)tmp} ;: $w"
+ _message -r "Trace output left in $tmp (up-history to view)"
+ if [[ $compstate[nmatches] -le 1 && $compstate[list] != *force* ]]; then
+ compstate[list]='list force messages'
+--- a/Functions/MIME/zsh-mime-handler
++++ b/Functions/MIME/zsh-mime-handler
+@@ -288,11 +288,11 @@
+ # We need to page the output.
+ # Careful in case PAGER is a set of commands and arguments.
+ local -a pager
+- zsh-mime-contexts -a $suffix pager pager || pager=(${=PAGER:-more})
++ zsh-mime-contexts -a $suffix pager pager || pager=(${=PAGER:-/usr/bin/pager})
+ if [[ -n $stdin ]]; then
+ cat $argv | $execargs | $pager
+ else
+- $execargs | eval ${PAGER:-more}
++ $execargs | eval ${PAGER:-/usr/bin/pager}
+ fi
+ elif [[ $no_bg = yes || $flags = *needsterminal* || -z $DISPLAY ]]; then
+ # Needs a terminal, so run synchronously.
+--- a/Functions/Misc/mere
++++ b/Functions/Misc/mere
+@@ -86,4 +86,4 @@
+ fi |
+ nroff -T$terminal -man | $col -x
+ ) |
+-${=MANPAGER:-${PAGER:-more}} -s
++${=MANPAGER:-${PAGER:-/usr/bin/pager}} -s
+--- a/Functions/Misc/nslookup
++++ b/Functions/Misc/nslookup
+@@ -21,7 +21,7 @@
+ zstyle -s ':nslookup' prompt tmp && pmpt=(-p "$tmp")
+ zstyle -s ':nslookup' rprompt tmp && pmpt=("$pmpt[@]" -r "$tmp")
+ zstyle -s ':nslookup' pager tmp &&
+- [[ -z "$pager" ]] && pager="${opager:-more}"
++ [[ -z "$pager" ]] && pager="${opager:-/usr/bin/pager}"
+ (( $#pmpt )) || pmpt=(-p '> ')
+
+ zpty nslookup command nslookup "${(q)@}"
+--- a/Functions/Misc/run-help
++++ b/Functions/Misc/run-help
+@@ -29,7 +29,7 @@
+ return 0
+ elif [[ -n "${HELPDIR:-}" && -r $HELPDIR/$1 && $1 != compctl ]]
+ then
+- ${=PAGER:-more} $HELPDIR/$1
++ ${=PAGER:-/usr/bin/pager} $HELPDIR/$1
+ return $?
+ fi
+
+@@ -69,7 +69,7 @@
+ (comp*) man zshcompsys;;
+ (zf*) man zshftpsys;;
+ (run-help) man zshcontrib;;
+- (*) builtin functions ${what[(w)1]} | ${=PAGER:-more};;
++ (*) builtin functions ${what[(w)1]} | ${=PAGER:-/usr/bin/pager};;
+ esac;;
+ (*( is a * builtin))
+ case ${what[(w)1]} in
+--- a/Functions/Misc/run-help-svk
++++ b/Functions/Misc/run-help-svk
+@@ -1,1 +1,1 @@
+-svk help $1 | ${=PAGER:-more}
++svk help $1 | ${=PAGER:-/usr/bin/pager}
+--- a/Functions/Misc/run-help-svn
++++ b/Functions/Misc/run-help-svn
+@@ -1,1 +1,1 @@
+-svn help $1 | ${=PAGER:-more}
++svn help $1 | ${=PAGER:-/usr/bin/pager}
+--- a/Functions/Zftp/zfdir
++++ b/Functions/Zftp/zfdir
+@@ -95,15 +95,15 @@
+ fi
+
+ if [[ -n $file && -f $file ]]; then
+- eval ${PAGER:-more} \$file
++ eval ${PAGER:-/usr/bin/pager} \$file
+ else
+ if (zftp test); then
+ # Works OK in subshells
+- zftp dir $* | tee $file | eval ${PAGER:-more}
++ zftp dir $* | tee $file | eval ${PAGER:-/usr/bin/pager}
+ else
+ # Doesn't work in subshells (IRIX 6.2 --- why?)
+ zftp dir $* >$file
+- eval ${PAGER:-more} $file
++ eval ${PAGER:-/usr/bin/pager} $file
+ fi
+ fi
+ # }