diff -Nru zsh-5.9/debian/changelog zsh-5.9/debian/changelog --- zsh-5.9/debian/changelog 2023-02-05 00:37:45.000000000 +0000 +++ zsh-5.9/debian/changelog 2023-09-22 04:49:44.000000000 +0000 @@ -1,3 +1,18 @@ +zsh (5.9-5ubuntu1) mantic; urgency=medium + + * Don't build zsh-static on Ubuntu/i386. + + -- Steve Langasek Thu, 21 Sep 2023 21:49:44 -0700 + +zsh (5.9-5) unstable; urgency=medium + + * [138340f9,dc77864f] Cherry pick multiple (partial) upstream commits to + migrate zsh's pcre module to pcre2. Update Build-Depends, Build-Using + and debian/tests/control from libpcre3-dev to libpcre2-dev + accordingly. (Closes: #999918) + + -- Axel Beckert Thu, 07 Sep 2023 01:17:01 +0200 + zsh (5.9-4) unstable; urgency=medium * [76a48d6c] Enable gdbm module to be build again, this time via diff -Nru zsh-5.9/debian/control zsh-5.9/debian/control --- zsh-5.9/debian/control 2023-01-30 00:43:16.000000000 +0000 +++ zsh-5.9/debian/control 2023-09-22 04:49:44.000000000 +0000 @@ -11,7 +11,7 @@ libelf-dev, libgdbm-dev, libncurses-dev, - libpcre3-dev + libpcre2-dev Build-Depends-Indep: cm-super-minimal, ghostscript, texinfo (>= 5~), @@ -19,7 +19,8 @@ texlive-latex-base, texlive-latex-recommended, yodl (>= 3.08.01) | yodl (<< 3.08.00) -Maintainer: Debian Zsh Maintainers +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Debian Zsh Maintainers Uploaders: Michael Prokop , Axel Beckert , Frank Terbeck , diff -Nru zsh-5.9/debian/patches/cherry-pick-10bdbd8b-51877-do-not-build-pcre-module-if-pcre2-config-is-not-found.patch zsh-5.9/debian/patches/cherry-pick-10bdbd8b-51877-do-not-build-pcre-module-if-pcre2-config-is-not-found.patch --- zsh-5.9/debian/patches/cherry-pick-10bdbd8b-51877-do-not-build-pcre-module-if-pcre2-config-is-not-found.patch 1970-01-01 00:00:00.000000000 +0000 +++ zsh-5.9/debian/patches/cherry-pick-10bdbd8b-51877-do-not-build-pcre-module-if-pcre2-config-is-not-found.patch 2023-07-05 02:24:26.000000000 +0000 @@ -0,0 +1,93 @@ +commit 10bdbd8b5b0b43445aff23dcd412f25cf6aa328a +Author: Jun-ichi Takimoto +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 -Nru zsh-5.9/debian/patches/cherry-pick-4b7a9fd0-additional-typset--p--m-fix-for-namespaces.patch zsh-5.9/debian/patches/cherry-pick-4b7a9fd0-additional-typset--p--m-fix-for-namespaces.patch --- zsh-5.9/debian/patches/cherry-pick-4b7a9fd0-additional-typset--p--m-fix-for-namespaces.patch 1970-01-01 00:00:00.000000000 +0000 +++ zsh-5.9/debian/patches/cherry-pick-4b7a9fd0-additional-typset--p--m-fix-for-namespaces.patch 2023-07-05 16:18:11.000000000 +0000 @@ -0,0 +1,25 @@ +commit 4b7a9fd0ecb750646cac76c41383f8391cd0fdd9 +Author: Bart Schaefer +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 -Nru zsh-5.9/debian/patches/cherry-pick-b62e91134-51723-migrate-pcre-module-to-pcre2.patch zsh-5.9/debian/patches/cherry-pick-b62e91134-51723-migrate-pcre-module-to-pcre2.patch --- zsh-5.9/debian/patches/cherry-pick-b62e91134-51723-migrate-pcre-module-to-pcre2.patch 1970-01-01 00:00:00.000000000 +0000 +++ zsh-5.9/debian/patches/cherry-pick-b62e91134-51723-migrate-pcre-module-to-pcre2.patch 2023-07-05 00:26:17.000000000 +0000 @@ -0,0 +1,514 @@ +commit b62e911341c8ec7446378b477c47da4256053dc0 +Author: Oliver Kiddle +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 ++#if defined(HAVE_PCRE2_COMPILE_8) && defined(HAVE_PCRE2_H) ++#define PCRE2_CODE_UNIT_WIDTH 8 ++#include + +-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 -Nru zsh-5.9/debian/patches/series zsh-5.9/debian/patches/series --- zsh-5.9/debian/patches/series 2023-01-29 22:51:31.000000000 +0000 +++ zsh-5.9/debian/patches/series 2023-07-05 16:54:57.000000000 +0000 @@ -6,3 +6,6 @@ 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 diff -Nru zsh-5.9/debian/rules zsh-5.9/debian/rules --- zsh-5.9/debian/rules 2023-02-03 12:36:25.000000000 +0000 +++ zsh-5.9/debian/rules 2023-09-22 04:49:44.000000000 +0000 @@ -48,20 +48,27 @@ CONFIGFLAGS += --enable-zsh-hash-debug endif +ifeq ($(DEB_HOST_ARCH):$(VENDOR),i386:ubuntu) + PKGS=-Nzsh-static +endif + # We first need to check if the package is installed, otherwise the # resulting syntax might be invalid. Needed for packages which are # also provided by other packages like libncurses-dev and # libncursesw5-dev which both fulfil the according build-dependency. -BUILT_USING=$(shell for pkg in libcap-dev libncurses-dev libpcre3-dev libc-dev-bin; do dpkg-query -f '$${status}' -W $$pkg 2>&1 | grep -Fq installed && dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W $$pkg; done) +BUILT_USING=$(shell for pkg in libcap-dev libncurses-dev libpcre2-dev libc-dev-bin; do dpkg-query -f '$${status}' -W $$pkg 2>&1 | grep -Fq installed && dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W $$pkg; done) %: - dh $@ + dh $@ $(PKGS) override_dh_auto_build-arch: build-dynamic build-static build-dynamic: dh_auto_build -B obj build-static: +ifneq (,$(filter zsh-static, $(shell dh_listpackages))) dh_auto_build -B obj-static +endif + : override_dh_auto_build-indep: dh_auto_build -B obj -- pdf @@ -71,7 +78,9 @@ if dpkg-architecture -qDEB_BUILD_ARCH_OS | grep -qv hurd; then \ HOME="$(CURDIR)/obj/testhome" ZTST_verbose=1 dh_auto_test -B obj; \ fi +ifneq (,$(filter zsh-static, $(shell dh_listpackages))) HOME="$(CURDIR)/obj-static/testhome" ZTST_verbose=1 dh_auto_test -B obj-static || true +endif override_dh_auto_test-indep: @@ -79,16 +88,24 @@ chmod 755 configure mkdir -p obj/testhome obj-static/testhome dh_auto_configure -B obj -- $(CONFIGFLAGS) +ifneq (,$(filter zsh-static, $(shell dh_listpackages))) dh_auto_configure -B obj-static -- $(CONFIGFLAGS) $(STATICFLAGS) +endif sed -e 's/#define VENDOR "pc"/#define VENDOR "$(VENDOR)"/' \ - -i obj/config.h obj-static/config.h + -i obj/config.h +ifneq (,$(filter zsh-static, $(shell dh_listpackages))) + sed -e 's/#define VENDOR "pc"/#define VENDOR "$(VENDOR)"/' \ + -i obj-static/config.h sed -e 's/files.mdd link=no/files.mdd link=static/;s/stat.mdd link=no/stat.mdd link=static/' \ -i obj-static/config.modules +endif override_dh_auto_clean: dh_auto_clean -B obj +ifneq (,$(filter zsh-static, $(shell dh_listpackages))) dh_auto_clean -B obj-static +endif override_dh_installdocs-indep: dh_installdocs -pzsh-doc --link-doc=zsh-common --doc-main-package=zsh-common @@ -148,12 +165,16 @@ -dRecommends debian/zsh/usr/lib/*/zsh/*/zsh/*.so execute_after_dh_installdocs-arch: +ifneq (,$(filter zsh-static, $(shell dh_listpackages))) awk 'BEGIN { print "The following modules are statically-compiled into the static zsh binary:\n"; } /link=static/ { printf "%s (%s %s)\n", substr($$1,6), $$4, $$5; }' obj-static/config.modules >debian/zsh-static/usr/share/doc/zsh-static/README.Debian +endif execute_after_dh_install-arch: +ifneq (,$(filter zsh-static, $(shell dh_listpackages))) mv debian/zsh-static/bin/zsh debian/zsh-static/bin/zsh-static mv debian/zsh-static/bin/zsh5 debian/zsh-static/bin/zsh5-static sed -e 's:#!/bin/zsh:#!/bin/zsh-static:' -i debian/zsh-static/bin/zsh5-static +endif find debian/zsh-dev/usr/include/zsh -name '*.h' -o -name '*.mdh' | \ xargs sed -e 's@\.\./config\.h@config.h@;s@#\(\s*\)include "\([^"]\+\)"@#\1include @' -i diff -Nru zsh-5.9/debian/tests/control zsh-5.9/debian/tests/control --- zsh-5.9/debian/tests/control 2022-02-25 10:40:02.000000000 +0000 +++ zsh-5.9/debian/tests/control 2023-09-06 23:11:28.000000000 +0000 @@ -3,7 +3,7 @@ libelf-dev, libgdbm-dev, libncurses-dev, - libpcre3-dev, + libpcre2-dev, zsh, zsh-dev @@ -12,7 +12,7 @@ libelf-dev, libgdbm-dev, libncurses-dev, - libpcre3-dev, + libpcre2-dev, zsh-static, zsh-dev