On 8/30/11 4:17 PM, "Ruslan Zasukhin" <[email protected]>
wrote:

> 
> If I call
> 
>     input = antlr3StringStreamNew(
>         input_string, Encoding, input_len, NULL );
>             
> NULL is name of stream
> Then it crashes inside of
> 
> 
> newStr8    (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 ptr)
> {
>     return factory->newPtr8(factory, ptr,
>          (ANTLR3_UINT32)strlen((const char *)ptr));        <<<<<< crash
> }
> 
> 
> Because on mac and linux strlen()  crashes on NULL.

In contrast to above, new  reuse() method can handle stream name as NULL,
Replacing to ³-memory-² name.


========================================================
antlr38BitReuse(pANTLR3_INPUT_STREAM input, pANTLR3_UINT8 inString,
ANTLR3_UINT32 size, pANTLR3_UINT8 name)
{
    input->isAllocated    = ANTLR3_FALSE;
    input->data        = inString;
    input->sizeBuf    = size;
    
    // Now we can set up the file name. As we are reusing the stream, there
may already
    // be a string that we can reuse for holding the filename.
    //
    if    (input->istream->streamName == NULL)
    {
        input->istream->streamName    =
input->strFactory->newStr(input->strFactory, name == NULL ?
(pANTLR3_UINT8)"-memory-" : name);
        input->fileName        = input->istream->streamName;
    }
    else
    {
        input->istream->streamName->set(input->istream->streamName,  (name
== NULL ? (const char *)"-memory-" : (const char *)name));
    }

    input->reset(input);
}



-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to