--- /dev/null
+--- pari-2.13.1/src/language/anal.c.orig 2020-10-26 13:43:04.000000000 +0100
++++ pari-2.13.1/src/language/anal.c 2021-06-26 11:47:46.571531691 +0200
+@@ -159,6 +159,10 @@ findentry(const char *s, long len, entre
+ if (!strncmp(t, s, len) && !t[len]) return ep;
+ }
+ /* not found */
++ if (foreignAutoload) { /* Try to autoload. */
++ ep = foreignAutoload(s,len);
++ if(ep) return ep;
++ } /* not found */
+ if (insert) { ep = initep(s,len); insertep(ep, T, hash); }
+ return ep;
+ }
+@@ -214,7 +218,7 @@ gp_read_str_prec(const char *s, long pre
+ /* valid return type */
+ static int
+ isreturn(char c)
+-{ return c == 'l' || c == 'v' || c == 'i' || c == 'm' || c == 'u'; }
++{ return c == 'l' || c == 'v' || c == 'i' || c == 'm' || c == 'u' || c == 'x'; }
+
+ /* if is known that 2 commas follow s; base-10 signed integer followed
+ * by comma? */
+@@ -241,7 +245,7 @@ check_proto(const char *code)
+ {
+ long arity = 0;
+ const char *s = code;
+- if (isreturn(*s)) s++;
++ if (isreturn(*s)) { if(*s == 'x') { arity++; } s++; }
+ while (*s && *s != '\n') switch (*s++)
+ {
+ case '&':
+@@ -329,7 +333,11 @@ install(void *f, const char *name, const
+ {
+ if (ep->valence != EpINSTALL)
+ pari_err(e_MISC,"[install] identifier '%s' already in use", name);
+- pari_warn(warner, "[install] updating '%s' prototype; module not reloaded", name);
++ if (foreignFuncFree && ep->code && (*ep->code == 'x'))
++ (*foreignFuncFree)(ep); /* function created by foreign interpreter */
++ else
++ pari_warn(warner, "[install] updating '%s' prototype; module not reloaded", name);
++
+ if (ep->code) pari_free((void*)ep->code);
+ }
+ else
+diff -pru pari-2.9.0-ini/src/language/anal.h pari-2.9.0/src/language/anal.h
+--- pari-2.9.0-ini/src/language/anal.h 2016-10-01 04:23:18.000000000 -0700
++++ pari-2.9.0/src/language/anal.h 2019-03-06 02:48:18.136608900 -0800
+@@ -34,6 +34,9 @@ void pari_fill_hashtable(entree **tabl
+ void compile_err(const char *msg, const char *str);
+ void compile_varerr(const char *str);
+
++extern entree * (*foreignAutoload)(const char*, long len);
++extern void (*foreignFuncFree)(entree *);
++
+ #ifdef STACK_CHECK
+ extern THREAD void *PARI_stack_limit;
+ #endif
+diff -pru pari-2.9.0-ini/src/language/compile.c pari-2.9.0/src/language/compile.c
+--- pari-2.9.0-ini/src/language/compile.c 2016-10-05 02:43:38.000000000 -0700
++++ pari-2.9.0/src/language/compile.c 2019-03-06 02:48:18.027408700 -0800
+@@ -519,9 +519,10 @@ detag(long n)
+
+ /* return type for GP functions */
+ static op_code
+-get_ret_type(const char **p, long arity, Gtype *t, long *flag)
++get_ret_type(const char **p, long arity, Gtype *t, long *flag, long *is_external)
+ {
+- *flag = 0;
++ *flag = *is_external = 0;
++ if (**p == 'x') { (*p)++; *is_external = 1; }
+ if (**p == 'v') { (*p)++; *t=Gvoid; return OCcallvoid; }
+ else if (**p == 'i') { (*p)++; *t=Gsmall; return OCcallint; }
+ else if (**p == 'l') { (*p)++; *t=Gsmall; return OCcalllong; }
+@@ -1203,7 +1204,7 @@ compilefunc(entree *ep, long n, int mode
+ long j;
+ long x=tree[n].x, y=tree[n].y;
+ op_code ret_op;
+- long ret_flag;
++ long ret_flag, is_external;
+ Gtype ret_typ;
+ char const *p,*q;
+ char c;
+@@ -1337,8 +1337,9 @@ compilefunc(entree *ep, long n, int mode
+ if (!ep->value)
+ compile_err("unknown function",tree[n].str);
+ nbopcodes = s_opcode.n;
+- ret_op = get_ret_type(&p, ep->arity, &ret_typ, &ret_flag);
++ ret_op = get_ret_type(&p, ep->arity, &ret_typ, &ret_flag, &is_external);
+ j=1;
++ if (is_external) op_push(OCpushlong,(long)ep,n); /* as in PPauto */
+ if (*p)
+ {
+ q=p;
+@@ -1661,8 +1663,8 @@ genclosure(entree *ep, const char *loc,
+ long arity=0, maskarg=0, maskarg0=0, stop=0, dovararg=0;
+ PPproto mod;
+ Gtype ret_typ;
+- long ret_flag;
+- op_code ret_op=get_ret_type(&code,ep->arity,&ret_typ,&ret_flag);
++ long ret_flag, is_external;
++ op_code ret_op=get_ret_type(&code,ep->arity,&ret_typ,&ret_flag,&is_external);
+ p=code;
+ while ((mod=parseproto(&p,&c,NULL))!=PPend)
+ {
+@@ -1705,6 +1707,7 @@ genclosure(entree *ep, const char *loc,
+ if (maskarg) op_push_loc(OCcheckargs,maskarg,loc);
+ if (maskarg0) op_push_loc(OCcheckargs0,maskarg0,loc);
+ p=code;
++ if (is_external) op_push_loc(OCpushlong,(long)ep,loc); /* as in PPauto */
+ while ((mod=parseproto(&p,&c,NULL))!=PPend)
+ {
+ switch(mod)
+@@ -2292,14 +2292,14 @@ optimizefunc(entree *ep, long n)
+ const char *p;
+ char c;
+ GEN arg = listtogen(y,Flistarg);
+- long nb=lg(arg)-1, ret_flag;
++ long nb=lg(arg)-1, ret_flag, is_external /* ignored */;
+ if (is_func_named(ep,"if") && nb>=4)
+ ep=is_entry("_multi_if");
+ p = ep->code;
+ if (!p)
+ fl=0;
+ else
+- (void) get_ret_type(&p, 2, &t, &ret_flag);
++ (void) get_ret_type(&p, 2, &t, &ret_flag, &is_external);
+ if (p && *p)
+ {
+ j=1;
+--- pari-2.13.1/src/language/eval.c.orig 2020-10-26 13:43:04.000000000 +0100
++++ pari-2.13.1/src/language/eval.c 2021-06-26 11:49:53.724176179 +0200
+@@ -139,6 +139,9 @@ pop_val(entree *ep)
+ void
+ freeep(entree *ep)
+ {
++ if (foreignFuncFree && ep->code && (*ep->code == 'x'))
++ (*foreignFuncFree)(ep); /* function created by foreign interpreter */
++
+ if (EpSTATIC(ep)) return; /* gp function loaded at init time */
+ if (ep->help) {pari_free((void*)ep->help); ep->help=NULL;}
+ if (ep->code) {pari_free((void*)ep->code); ep->code=NULL;}
+@@ -1672,7 +1675,8 @@ evalstate_reset(void)
+ reset_break();
+ compilestate_reset();
+ parsestate_reset();
+- set_avma(pari_mainstack->top);
++ if (!cb_exception_resets_avma)
++ set_avma(pari_mainstack->top);
+ }
+
+ void
+diff -pru pari-2.9.0-ini/src/language/init.c pari-2.9.0/src/language/init.c
+--- pari-2.9.0-ini/src/language/init.c 2016-10-25 01:15:32.000000000 -0700
++++ pari-2.9.0/src/language/init.c 2019-03-06 03:00:07.190054300 -0800
+@@ -113,6 +113,9 @@ static pari_stack s_MODULES;
+ const long functions_tblsz = 135; /* size of functions_hash */
+ entree **functions_hash, **defaults_hash;
+
++entree* (*foreignAutoload)(const char*, long len); /* Autoloader */
++void (*foreignFuncFree)(entree *); /* How to free external entree. */
++
+ char *(*cb_pari_fgets_interactive)(char *s, int n, FILE *f);
+ int (*cb_pari_get_line_interactive)(const char*, const char*, filtre_t *F);
+ void (*cb_pari_quit)(long);
+@@ -130,6 +133,9 @@ void (*cb_pari_start_output)();
+
+ const char * pari_library_path = NULL;
+
++int cb_exception_resets_avma = 0;
++int cb_exception_flushes_err = 0;
++
+ static THREAD GEN global_err_data;
+ THREAD jmp_buf *iferr_env;
+ const long CATCH_ALL = -1;
+@@ -1141,7 +1147,8 @@ pari_sigint(const char *time_s)
+ out_puts(pariErr, "user interrupt after ");
+ out_puts(pariErr, time_s);
+ out_term_color(pariErr, c_NONE);
+- pariErr->flush();
++ if (!cb_exception_flushes_err)
++ pariErr->flush();
+ if (cb_pari_handle_exception)
+ recover = cb_pari_handle_exception(-1);
+ if (!recover && !block)
+@@ -1505,7 +1505,9 @@ pari_err_display(GEN err)
+ pari_free(s);
+ }
+ out_term_color(pariErr, c_NONE);
+- pariErr->flush(); return 0;
++ if (!cb_exception_flushes_err)
++ pariErr->flush();
++ return 0;
+ }
+
+ void
+--- pari-2.9.0/src/headers/paricom.h-pre 2011-05-30 02:28:34.000000000 -0700
++++ pari-2.9.0/src/headers/paricom.h 2018-09-16 00:04:16.527215600 -0700
+@@ -92,6 +92,10 @@ extern void (*cb_pari_start_output)(void
+ extern const char *pari_library_path;
+ extern THREAD long *varpriority;
+
++#define CB_EXCEPTION_FLAGS 1
++extern int cb_exception_resets_avma;
++extern int cb_exception_flushes_err;
++
+ /* pari_init_opts */
+ enum {
+ INIT_JMPm = 1,
# Conditional build:
%bcond_without tex # TeX documentation
#
-# latest perl Math::Pari (2.030518) doesn't know of pari >= 2.12
-%define pari_version 2.11.4
+# note: latest perl Math::Pari (2.030518) doesn't know of pari >= 2.12
+# 2.13.1 with updated Math-Pari diff patch + Math-Pari 2.030518 with update patch:
+# Failed 19/243 test programs. 176/1476 subtests failed.
+# compared to 2.11.4 with Math-Pari 2.11-diff-all patch:
+# Failed 20/229 test programs. 173/1477 subtests failed.
+%define pari_version 2.13.1
%define gp2c_version 0.0.12
# because of previous 2.x versions with 8 minor digits, keep trailing zeros in package Version
%define math_pari_version 2.03051800
Summary(pl.UTF-8): Komputerowy system obliczeń algebraicznych zorientowany na metody teorii liczb
Name: parigp
Version: %{pari_version}
-Release: 19
+Release: 20
License: GPL v2+
Group: Applications/Math
-#Source0: http://pari.math.u-bordeaux.fr/pub/pari/unix/pari-%{pari_version}.tar.gz
-Source0: http://pari.math.u-bordeaux.fr/pub/pari/OLD/2.11/pari-%{pari_version}.tar.gz
-# Source0-md5: fb2968d7805424518fe44a59a2024afd
+Source0: http://pari.math.u-bordeaux.fr/pub/pari/unix/pari-%{pari_version}.tar.gz
+# Source0-md5: 826064cf75af268be8a482ade6e27501
Source1: http://pari.math.u-bordeaux.fr/pub/pari/packages/galdata.tgz
# Source1-md5: f9f61b2930757a785b568e5d307a7d75
Source2: http://pari.math.u-bordeaux.fr/pub/pari/GP2C/gp2c-%{gp2c_version}.tar.gz
Patch5: %{name}-noproccpuinfo.patch
Patch6: gmp-version.patch
Patch7: Math-Pari-escape-left-braces-in-regex.patch
+Patch8: perl-Math-Pari-update.patch
+# based on Math-Pari-%{math_pari_fversion}/patches/diff-2.11.0-all
+Patch10: pari-Math-Pari-diff.patch
URL: http://pari.math.u-bordeaux.fr/
BuildRequires: autoconf
BuildRequires: ctags
%prep
%setup -q -n pari-%{pari_version} -a 2 -a 3
-patch -p1 < Math-Pari-%{math_pari_fversion}/patches/diff-2.11.0-all
+%patch10 -p1
%patch0 -p1
%patch2 -p1
%patch5 -p1
%patch3 -p1
%patch4 -p1
%patch7 -p0
+%patch8 -p1
%build
# pari & parigp
%files
%defattr(644,root,root,755)
%doc AUTHORS CHANGES* COMPAT NEW README examples/Inputrc %{?with_tex:doc/*.pdf}
-%attr(755,root,root) %{_bindir}/gp-2.11
+%attr(755,root,root) %{_bindir}/gp-2.13
%attr(755,root,root) %{_bindir}/gp
%attr(755,root,root) %{_bindir}/gphelp
%attr(755,root,root) %{_bindir}/tex2mail
%files -n pari
%defattr(644,root,root,755)
%attr(755,root,root) %{_libdir}/libpari-gmp.so.*.*.*
-%attr(755,root,root) %ghost %{_libdir}/libpari-gmp.so.6
+%attr(755,root,root) %ghost %{_libdir}/libpari-gmp.so.7
%{_libdir}/parigp
%files -n pari-devel
--- /dev/null
+--- Math-Pari-2.030518/Pari.xs.orig 2021-06-24 18:30:57.496616128 +0200
++++ Math-Pari-2.030518/Pari.xs 2021-06-24 20:04:03.246355523 +0200
+@@ -1283,7 +1283,7 @@
+ /* add to output */
+ switch(d->context) {
+ case G_VOID:
+- case G_SCALAR: sv_catpvf(d->acc, " %2d: %s\n",
++ case G_SCALAR: sv_catpvf(d->acc, " %2ld: %s\n",
+ d->items - 1, SvPV_nolen(tmp));
+ SvREFCNT_dec(tmp); break;
+ case G_ARRAY: av_push((AV*)d->acc,tmp); break;
+@@ -2036,11 +2036,11 @@
+ # if PARI_VERSION_EXP < 2010000
+ # define TAG_community 15 /* "The PARI community" */
+ # else /* !(PARI_VERSION_EXP < 2010000) */
+-# if PARI_VERSION_EXP < 2012000
++# if PARI_VERSION_EXP < 2014000
+ # define TAG_community 17 /* "The PARI community" */
+-# else /* !(PARI_VERSION_EXP < 2012000) */
++# else /* !(PARI_VERSION_EXP < 2014000) */
+ # define TAG_community_unknown
+-# endif /* !(PARI_VERSION_EXP < 2012000) */
++# endif /* !(PARI_VERSION_EXP < 2014000) */
+ # endif /* !(PARI_VERSION_EXP < 2010000) */
+ #endif /* !(PARI_VERSION_EXP < 2008000) */
+
+@@ -2060,7 +2060,7 @@
+ char *
+ added_sections()
+ {
+-#if PARI_VERSION_EXP < 2013000
++#if PARI_VERSION_EXP < 2014000
+ /* Suggestion on format (part of 2.10.0), only use short names: "4: functions related to COMBINATORICS\n13: L-FUNCTIONS" */
+ return "";
+ #else /* !( PARI_VERSION_EXP < 2011000) */
+@@ -3823,7 +3823,7 @@
+ switch (valence) {
+ case 0:
+ if (!ep->code) {
+- croak("Unsupported Pari function %s, interface 0 code NULL");
++ croak("Unsupported Pari function %s, interface 0 code NULL", name);
+ } else if (ep->code[0] == 'p' && ep->code[1] == 0) {
+ DO_INTERFACE(0);
+ } else if (ep->code[0] == 0) {
+@@ -3886,10 +3886,10 @@
+
+ default:
+ if (!ep)
+- croak("Unsupported interface %d for \"direct-link\" Pari function %s",
++ croak("Unsupported interface %ld for \"direct-link\" Pari function %s",
+ valence, olds);
+ if (!ep->code)
+- croak("Unsupported interface %d and no code for a Pari function %s",
++ croak("Unsupported interface %ld and no code for a Pari function %s",
+ valence, olds);
+ flexible:
+ s1 = s = ep->code;
+--- Math-Pari-2.030518/libPARI/Makefile.PL.orig 2021-06-24 21:41:42.021282480 +0200
++++ Math-Pari-2.030518/libPARI/Makefile.PL 2021-06-24 21:41:46.411258697 +0200
+@@ -317,7 +317,7 @@
+ $mp = 'mp.c';
+ my $kern = "$kernel_dir/none";
+ my @dep # Copied from src/kernel/none/MakeLVL1.SH 2.2.10
+- = "$kern/mp.c $kern/cmp.c $kern/gcdll.c $kern/ratlift.c $kern/gcd.c $kern/invmod.c $kern/mp_indep.c $kern/add.c";
++ = "$kern/mp.c $kern/cmp.c $kern/gcdll.c $kern/halfgcd.c $kern/ratlift.c $kern/invmod.c $kern/gcd.c $kern/mp_indep.c $kern/add.c";
+ -f "$main_paridir/src/kernel/$_" and push @dep, "$kernel_dir/$_" for "none/gcdext.c"; # When did it appear? Was: if $pari_version > 2004000
+ $create_mp = <<EOS;
+ mp.c: @dep