[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in GAWK 3.1.0 -> --dump doesn't work with extension()
From: |
Aharon Robbins |
Subject: |
Re: Bug in GAWK 3.1.0 -> --dump doesn't work with extension() |
Date: |
Thu, 12 Sep 2002 15:21:58 +0300 |
In article <address@hidden>,
Kenny McCormack <address@hidden> wrote:
>You get an assert failure (j == func_count -> in awkgram.y).
>
>Basically, I think the problem is that when you add a function via
>extension(), the variable func_count (which is static in awkgram.c) doesn't
>get incremented. The fix should be easy; either of:
> 1) Make func_count non-static and increment it in make_builtin().
> 2) Provide a "increment_func_count()" function and call that from
> make_builtin().
>
>Either is fine, of course - it just depends on how "object oriented" you
>want to be. Anyway, I leave it to people more familiar with the GAWK code
>to implement this - I am not familiar enough with it to know what
>side-effects this may have.
>
>P.S. In regards to the recent thread on c.l.a. about bugs in GAWK and
>whether it is OK to discuss them here: I think it is sufficient to, as I
>have done, cross-post to gnu.utils.bug, as that NG is gated to the mailing
>list (address@hidden - or whatever). So that should suffice to get it to
>Arnold. This is based on correspondence from Arnold in an earlier
>go-around on this topic.
>
>P.P.S. Am having trouble posting news - so this may end up in gnu.utils.bug
>as a multi-post instead of cross-post. We shall see...
It didn't get to gnu.utils.bug. I haven't seen it in that newsgroup.
Your best bet may be to Cc: address@hidden while editing the message,
as I've done here.
Here is a patch.
Arnold
------------------------------------------------------------------------
*** ../gawk-3.1.1/awkgram.y Tue Apr 16 14:40:13 2002
--- awkgram.y Thu Sep 12 15:07:34 2002
***************
*** 1030,1036 ****
if (tokentab[i].ptr == fptr)
return tokentab[i].operator;
! fatal(_("fptr %x not in tokentab\n"), fptr);
return NULL; /* to stop warnings */
}
--- 1030,1036 ----
if (tokentab[i].ptr == fptr)
return tokentab[i].operator;
! /* fatal(_("fptr %x not in tokentab\n"), fptr); */
return NULL; /* to stop warnings */
}
***************
*** 2563,2571 ****
if (func_count == 0)
return;
if (tab == NULL)
! emalloc(tab, struct finfo *, func_count * sizeof(struct finfo),
"dump_funcs");
for (i = j = 0; i < HASHSIZE; i++) {
for (p = variables[i]; p != NULL; p = p->hnext) {
if (p->hvalue->type == Node_func) {
--- 2563,2585 ----
if (func_count == 0)
return;
+ /*
+ * Walk through symbol table countng functions.
+ * Could be more than func_count if there are
+ * extension function.
+ */
+ for (i = j = 0; i < HASHSIZE; i++) {
+ for (p = variables[i]; p != NULL; p = p->hnext) {
+ if (p->hvalue->type == Node_func) {
+ j++;
+ }
+ }
+ }
+
if (tab == NULL)
! emalloc(tab, struct finfo *, j * sizeof(struct finfo),
"dump_funcs");
+ /* now walk again, copying info */
for (i = j = 0; i < HASHSIZE; i++) {
for (p = variables[i]; p != NULL; p = p->hnext) {
if (p->hvalue->type == Node_func) {
***************
*** 2577,2586 ****
}
}
- assert(j == func_count);
/* Shazzam! */
! qsort(tab, func_count, sizeof(struct finfo), fcompare);
for (i = 0; i < j; i++)
pp_func(tab[i].name, tab[i].nlen, tab[i].func);
--- 2591,2599 ----
}
}
/* Shazzam! */
! qsort(tab, j, sizeof(struct finfo), fcompare);
for (i = 0; i < j; i++)
pp_func(tab[i].name, tab[i].nlen, tab[i].func);
*** ../gawk-3.1.1/profile.c Tue Apr 16 14:58:49 2002
--- profile.c Thu Sep 12 15:01:26 2002
***************
*** 1076,1083 ****
static void
pp_builtin(register NODE *tree)
{
! fprintf(prof_fp, "%s(", getfname(tree->proc));
! pp_list(tree->subnode);
fprintf(prof_fp, ")");
}
--- 1073,1083 ----
static void
pp_builtin(register NODE *tree)
{
! const char *func = getfname(tree->proc);
!
! fprintf(prof_fp, "%s(", func ? func : "extension_function");
! if (func)
! pp_list(tree->subnode);
fprintf(prof_fp, ")");
}
--
Aharon (Arnold) Robbins --- Pioneer Consulting Ltd. address@hidden
P.O. Box 354 Home Phone: +972 8 979-0381 Fax: +1 928 569 9018
Nof Ayalon Cell Phone: +972 51 297-545
D.N. Shimshon 99785 ISRAEL