bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] 2 questions


From: Denis Shirokov
Subject: Re: [bug-gawk] 2 questions
Date: Mon, 29 Oct 2012 13:33:34 +0200

hi

I found some gawk crashes while processing regular expressions:

#______________________________________________________________________________
# CASE 1: Using regular expression with \x80

BEGIN{
        t="X\x80YZ"
        if ( match(t,/\x80/) )  print "MATCH"
                                        else    print "NOT MATCH" }

OUTPUT:

>gawk -f rexp80_1.gwk
gawk: rexp80_1.gwk:3: fatal: unbalanced )

>

#______________________________________________________________________________
# CASE 2: Using regular expression with [\x80]

BEGIN{
        t="X\x80YZ"
        if ( match(t,/[\x80]/) )        print "MATCH"
                                        else    print "NOT MATCH" }

OUTPUT: (Application crash window appeared; please see attached Error.png)

>gawk -f rexp80.gwk
gawk: rexp80.gwk:3: fatal error: internal error

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

>

#______________________________________________________________________________
# CASE 3: Using regular expression with [^\x80]

BEGIN{
        t="X\x80YZ"
        if ( match(t,/[^\x80]/) )       print "MATCH!" `" substr(t,1,RSTART-1) 
"' :
`" substr(t,RSTART,RLENGTH) "' : `" substr(t,RSTART+RLENGTH) "'"
                                        else    print "NOT FOUND" }

OUTPUT: (Application crash window appeared; please see attached Error.png)

>gawk -f rexp80_2.gwk
gawk: rexp80_2.gwk:3: fatal error: internal error

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

>

#______________________________________________________________________________















2012/10/28, Aharon Robbins <address@hidden>:
> Hello. Re this:
>
>> Date: Fri, 26 Oct 2012 22:03:24 +0300
>> From: Denis Shirokov <address@hidden>
>> To: address@hidden
>> Subject: [bug-gawk] 2 questions
>>
>> Hi GAWK!
>>
>> Would you be so kind to answer for 2 questions:
>>
>>
>> 1) because /\1B\x2A/ response in regexp as /*/ - this mean that regexp
>> cant process byte-characters with code \x80-\xFF ? or some of thems?
>> is there way to process characters with code \x80-\xFF ?
>
> In general, you should use printable characters for the code that
> are printable, such as '*' for \x2A. Then it becomes clear what
> the problem is.
>
> Gawk can match characters in the range \x80 - \xFF. You simply put
> them into the regex that way. Or you can enclose them in square brackets,
> in which case they will generally lose any special meaning.
>
>> 2) How character "/" being defined in gawk-script:
>>  as arithmetic divider (like 1/5 (==0.2), 10/1 (==10), etc...)
>> OR
>>  as the begining of regexp? (like /2/)
>
> Both.
>
>> CAUSE:
>>
>> 1/2/3      - may mean:(number 1 divided by number 2 divided number by
>> 3) ==0.1666666666666667
>
> This is the interpretation taken by Brian Kernighan's awk, gawk, and mawk.
>
>> OR
>>
>> 1/2/3      - may mean:(number 1 regexp /2/ number 3) =="103"  ( rexp
>> /2/==0)
>>
>> How you  can exactly be sure which expressions is used?
>
> Awk interpreters generally do the right thing.  You can use parentheses
> to force a particular interpretation.
>
> Arnold
>

Attachment: Error.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]