| Ilya Zakharevich on Thu, 28 Jan 1999 23:16:23 -0500 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| [PATCH] Do not create new variables if not needed |
This patch makes "s"-type arguments to not create new variables for
unknown identifiers. Currently, if you do something like (suppose n=4 and
no variable named xx)
xx""n
then the result is "xx4", and a new variable xx is created. With the patch
applied the value is the same, but xx is not created.
Btw, when doing this I thought that PARI has something like
evalstring(STRING), so that
evalstring(xx""n)
would give you a (maybe new) variable xx4. Why there is no such
thing?
vector(25,X,evalstring(xx""X))
Another btw: what happened to the limit on the number of user variables?
Is it lifted now?
Enjoy,
Ilya
--- ./src/language/anal.c~ Sun Nov 8 21:26:30 1998
+++ ./src/language/anal.c Thu Jan 28 22:50:00 1999
@@ -1214,13 +1214,30 @@ identifier(void)
else if (*analyseur == ',' || *analyseur == ')') break;
else
{ /* expand string */
- long len, av = avma;
- char *tmp = GENtostr(expr()), *tbp;
+ long len, av = avma, alloc = 1;
+ char *tmp, *tbp, *s = analyseur;
- len = strlen(tmp); tbp = bp + len;
+ while (is_keyword_char(*s)) s++;
+ if (*s == '"' || *s == ',' || *s == ')') {
+ /* Do not create new user variables */
+ entree *ep = is_entry_intern(analyseur, functions_hash, 0);
+
+ if (!ep) { /* consider as a literal */
+ tmp = analyseur;
+ len = s - analyseur;
+ analyseur = s;
+ alloc = 0;
+ }
+ }
+ if (alloc) {
+ tmp = GENtostr(expr());
+ len = strlen(tmp);
+ }
+ tbp = bp + len;
if (tbp>limit) break;
memcpy(bp,tmp,len); /* ignore trailing \0 */
- free(tmp); avma=av; bp = tbp;
+ if (alloc) free(tmp);
+ avma=av; bp = tbp;
}
}
if (bp > limit) err(talker,"string too long");