| Bill Allombert on Fri, 22 Nov 2002 21:20:02 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Patch for install: allow to change protoype |
Hello PARI/GP developers,
When using install, if you choose a wrong prototype, you cannot
changing without renaming the GP function, because subsequent install
will fail.
For example suppose you enter by mistake
? install(addsi,GG)
? addsi(1,1)
%1 = 1082894589
Which is obviously wrong...
? install(addsi,LG)
*** Warning: [install] 'addsi' already there. Not replaced.
NOte: this a warning not an error, so we expect the command to have done
somathing but
? addsi(1,1)
%2 = 1082894589
The solution is to do
? install(addsi,GG,addsi2)
but this is awkward.
The following (maybe not perfect) patch fix that.
Index: src/language/anal.c
===================================================================
RCS file: /home/megrez/cvsroot/pari/src/language/anal.c,v
retrieving revision 1.120
diff -u -r1.120 anal.c
--- src/language/anal.c 2002/11/16 10:34:34 1.120
+++ src/language/anal.c 2002/11/22 20:17:56
@@ -462,7 +462,15 @@
long hash;
entree *ep = is_entry_intern(name, functions_hash, &hash);
- if (ep) err(warner,"[install] '%s' already there. Not replaced", name);
+ if (ep)
+ {
+ if (ep->valence!=EpINSTALL)
+ err(talker,"function %s already exist in install. Not replaced", name);
+ err(warner,"[install] '%s' already there. Not replaced", name);
+ check_proto(code);
+ if (ep->code) free(ep->code);
+ ep->code = pari_strdup(code);
+ }
else
{
char *s = name;
Cheers,
Bill.