[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: locale-dependent assertion failure in gawk 3.1.5
From: |
Andrew J. Schorr |
Subject: |
Re: locale-dependent assertion failure in gawk 3.1.5 |
Date: |
Mon, 10 Jul 2006 08:58:21 -0400 |
User-agent: |
Mutt/1.4.2.1i |
On Fri, Jul 07, 2006 at 06:05:00PM -0400, Andrew J. Schorr wrote:
> Given that NODE is a union, I'm not clear on whether it's OK to
> test the wstptr value if the WSTRCUR flag is not set. I guess
> one has to assume that wstptr may contain random garbage if WSTRCUR
> is not set; is that the correct approach? Or would it be safe to
> assume that if STRCUR is set, then
> (wstptr != NULL) <==> ((flags & WSTRCUR) != 0)?
In particular, I'm not certain that I understand the model implied
by this code at the top of node.c:str2wstr():
NODE *
str2wstr(NODE *n, size_t **ptr)
{
...
if ((n->flags & WSTRCUR) != 0) {
if (ptr == NULL)
return n;
}
if (n->wstptr != NULL) {
free(n->wstptr);
n->wstptr = NULL;
n->wstlen = 0;
}
Suppose that ((n->flags & WSTRCUR) == 0) (the flag bit is not set). In that
case, is it valid to access n->wstptr? I had imagined from reviewing other
parts of the code that we should consider n->wstptr undefined if the WSTRCUR
flag is not set...
In other words, would it be more correct to write:
if ((n->flags & WSTRCUR) != 0) {
if (ptr == NULL)
return n;
assert(n->wstptr != NULL);
free(n->wstptr);
/* no need to reset wstptr and wstlen since they will
be set below */
}
Or are there some well-defined circumstances under which it is OK to presume
that the wstptr field is valid even if the WSTRCUR flag is not set? And
if so, is that concisely expressible in code (or a comment)?
Regards,
Andy
- locale-dependent assertion failure in gawk 3.1.5, Andrew J. Schorr, 2006/07/06
- Re: locale-dependent assertion failure in gawk 3.1.5, Andrew J. Schorr, 2006/07/07
- Message not available
- Re: locale-dependent assertion failure in gawk 3.1.5, Jürgen Kahrs, 2006/07/07
- Message not available
- Re: locale-dependent assertion failure in gawk 3.1.5, Jürgen Kahrs, 2006/07/07
- Re: locale-dependent assertion failure in gawk 3.1.5, Andrew J. Schorr, 2006/07/07
- Re: locale-dependent assertion failure in gawk 3.1.5, Andrew J. Schorr, 2006/07/07
- Re: locale-dependent assertion failure in gawk 3.1.5,
Andrew J. Schorr <=
- Re: locale-dependent assertion failure in gawk 3.1.5, Andrew J. Schorr, 2006/07/10
- Re: locale-dependent assertion failure in gawk 3.1.5, Andrew J. Schorr, 2006/07/11
- Re: locale-dependent assertion failure in gawk 3.1.5, Andrew J. Schorr, 2006/07/12
- Message not available
- Re: locale-dependent assertion failure in gawk 3.1.5, Jürgen Kahrs, 2006/07/10