* Re: [9fans] Fix sam regexp bug with metacharacters in classes
2021-11-23 20:26 [9fans] Fix sam regexp bug with metacharacters in classes adr
@ 2021-11-24 1:28 ` Conor Williams
2021-11-24 1:29 ` Conor Williams
2021-12-25 3:10 ` Conor Williams
2021-12-25 5:35 ` Conor Williams
2 siblings, 1 reply; 5+ messages in thread
From: Conor Williams @ 2021-11-24 1:28 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 2233 bytes --]
why on Gaia do you not have a
Runemas_Incremented_By_One_To_Keep_A_Negative_Sub
variable?
apart from that, it looks okay... will tango it in later...
/c:2022November!^N^M
On Tue, Nov 23, 2021 at 8:27 PM adr <adr@sdf.org> wrote:
> The code assumes runes are 16 bits long, not 21, creating faulting
> code parsing classes. I.e. '/[\-]' will not match '-'.
>
> This is the same fix already in 9front.
>
> http://adr.freeshell.org/plan9/patches/sam_fix_metachars_on_classes.diff
>
> --- /sys/src/cmd/sam/regexp.c Tue Apr 23 19:06:01 2013
> +++ regexp.c Tue Nov 23 15:01:18 2021
> @@ -53,8 +53,8 @@
> /*
> * Actions and Tokens
> *
> - * 0x100xx are operators, value == precedence
> - * 0x200xx are tokens, i.e. operands for operators
> + * 0x2000xx are operators, value == precedence
> + * 0x3000xx are tokens, i.e. operands for operators
> */
> enum {
> OPERATOR = Runemask+1, /* Bitmask of all operators */
> @@ -462,7 +462,8 @@
> exprp++;
> return '\n';
> }
> - return *exprp++|(Runemax+1);
> + /* add a flag so metacharacters aren't interpreted */
> + return *exprp++|(Runemask+1);
> }
> return *exprp++;
> }
> @@ -498,11 +499,12 @@
> if((c2 = nextrec()) == ']')
> goto Error;
> classp[n+0] = Runemax;
> - classp[n+1] = c1;
> - classp[n+2] = c2;
> + /* remove possible flag from nextrec() */
> + classp[n+1] = c1 & Runemask;
> + classp[n+2] = c2 & Runemask;
> n += 3;
> }else
> - classp[n++] = c1;
> + classp[n++] = c1 & Runemask;
> }
> classp[n] = 0;
> if(nclass == Nclass){
>
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tccbdb20b670003a1-M7b2bbb4acbd0bc7b5c5c7f69
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 5075 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] Fix sam regexp bug with metacharacters in classes
2021-11-24 1:28 ` Conor Williams
@ 2021-11-24 1:29 ` Conor Williams
0 siblings, 0 replies; 5+ messages in thread
From: Conor Williams @ 2021-11-24 1:29 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 2437 bytes --]
sorry that s should have a k preceding _ /c:2021248pm
On Wed, Nov 24, 2021 at 1:28 AM Conor Williams <conor.williams@gmail.com>
wrote:
> why on Gaia do you not have a
> Runemas_Incremented_By_One_To_Keep_A_Negative_Sub
> variable?
> apart from that, it looks okay... will tango it in later...
>
> /c:2022November!^N^M
>
> On Tue, Nov 23, 2021 at 8:27 PM adr <adr@sdf.org> wrote:
>
>> The code assumes runes are 16 bits long, not 21, creating faulting
>> code parsing classes. I.e. '/[\-]' will not match '-'.
>>
>> This is the same fix already in 9front.
>>
>> http://adr.freeshell.org/plan9/patches/sam_fix_metachars_on_classes.diff
>>
>> --- /sys/src/cmd/sam/regexp.c Tue Apr 23 19:06:01 2013
>> +++ regexp.c Tue Nov 23 15:01:18 2021
>> @@ -53,8 +53,8 @@
>> /*
>> * Actions and Tokens
>> *
>> - * 0x100xx are operators, value == precedence
>> - * 0x200xx are tokens, i.e. operands for operators
>> + * 0x2000xx are operators, value == precedence
>> + * 0x3000xx are tokens, i.e. operands for operators
>> */
>> enum {
>> OPERATOR = Runemask+1, /* Bitmask of all operators */
>> @@ -462,7 +462,8 @@
>> exprp++;
>> return '\n';
>> }
>> - return *exprp++|(Runemax+1);
>> + /* add a flag so metacharacters aren't interpreted */
>> + return *exprp++|(Runemask+1);
>> }
>> return *exprp++;
>> }
>> @@ -498,11 +499,12 @@
>> if((c2 = nextrec()) == ']')
>> goto Error;
>> classp[n+0] = Runemax;
>> - classp[n+1] = c1;
>> - classp[n+2] = c2;
>> + /* remove possible flag from nextrec() */
>> + classp[n+1] = c1 & Runemask;
>> + classp[n+2] = c2 & Runemask;
>> n += 3;
>> }else
>> - classp[n++] = c1;
>> + classp[n++] = c1 & Runemask;
>> }
>> classp[n] = 0;
>> if(nclass == Nclass){
>>
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tccbdb20b670003a1-M5540075cb6bb20848c0e586d
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 5520 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] Fix sam regexp bug with metacharacters in classes
2021-11-23 20:26 [9fans] Fix sam regexp bug with metacharacters in classes adr
2021-11-24 1:28 ` Conor Williams
@ 2021-12-25 3:10 ` Conor Williams
2021-12-25 5:35 ` Conor Williams
2 siblings, 0 replies; 5+ messages in thread
From: Conor Williams @ 2021-12-25 3:10 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 2200 bytes --]
hi Adr
Can you send me both the files, please?
Kind Reards
Conor P. Williams (conor.williams@gmail.com)
ps: before I apply the patch...
On Tue, Nov 23, 2021 at 8:27 PM adr <adr@sdf.org> wrote:
> The code assumes runes are 16 bits long, not 21, creating faulting
> code parsing classes. I.e. '/[\-]' will not match '-'.
>
> This is the same fix already in 9front.
>
> http://adr.freeshell.org/plan9/patches/sam_fix_metachars_on_classes.diff
>
> --- /sys/src/cmd/sam/regexp.c Tue Apr 23 19:06:01 2013
> +++ regexp.c Tue Nov 23 15:01:18 2021
> @@ -53,8 +53,8 @@
> /*
> * Actions and Tokens
> *
> - * 0x100xx are operators, value == precedence
> - * 0x200xx are tokens, i.e. operands for operators
> + * 0x2000xx are operators, value == precedence
> + * 0x3000xx are tokens, i.e. operands for operators
> */
> enum {
> OPERATOR = Runemask+1, /* Bitmask of all operators */
> @@ -462,7 +462,8 @@
> exprp++;
> return '\n';
> }
> - return *exprp++|(Runemax+1);
> + /* add a flag so metacharacters aren't interpreted */
> + return *exprp++|(Runemask+1);
> }
> return *exprp++;
> }
> @@ -498,11 +499,12 @@
> if((c2 = nextrec()) == ']')
> goto Error;
> classp[n+0] = Runemax;
> - classp[n+1] = c1;
> - classp[n+2] = c2;
> + /* remove possible flag from nextrec() */
> + classp[n+1] = c1 & Runemask;
> + classp[n+2] = c2 & Runemask;
> n += 3;
> }else
> - classp[n++] = c1;
> + classp[n++] = c1 & Runemask;
> }
> classp[n] = 0;
> if(nclass == Nclass){
>
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tccbdb20b670003a1-Mff16469136bde42ef0336be5
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 5096 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] Fix sam regexp bug with metacharacters in classes
2021-11-23 20:26 [9fans] Fix sam regexp bug with metacharacters in classes adr
2021-11-24 1:28 ` Conor Williams
2021-12-25 3:10 ` Conor Williams
@ 2021-12-25 5:35 ` Conor Williams
2 siblings, 0 replies; 5+ messages in thread
From: Conor Williams @ 2021-12-25 5:35 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 2570 bytes --]
are u getting confused between Runemax and Runemask...
I'm going to have my christmas dinner now ;; and reckon this patch
would break a few things... i'm working off a mounted iso at the minute...
it's handier: as in i have "-t iso9660" in it..
laters...
/c:2021 crimbo hay
ps: the jury is out on this one 'till after christmas but i'm not...
pps: am i close?..
ppps: in bb vi a search for minus both ways works...
ppps: should have an answer for you soon as to whether I would run with
this patch
On Tue, Nov 23, 2021 at 8:27 PM adr <adr@sdf.org> wrote:
> The code assumes runes are 16 bits long, not 21, creating faulting
> code parsing classes. I.e. '/[\-]' will not match '-'.
>
> This is the same fix already in 9front.
>
> http://adr.freeshell.org/plan9/patches/sam_fix_metachars_on_classes.diff
>
> --- /sys/src/cmd/sam/regexp.c Tue Apr 23 19:06:01 2013
> +++ regexp.c Tue Nov 23 15:01:18 2021
> @@ -53,8 +53,8 @@
> /*
> * Actions and Tokens
> *
> - * 0x100xx are operators, value == precedence
> - * 0x200xx are tokens, i.e. operands for operators
> + * 0x2000xx are operators, value == precedence
> + * 0x3000xx are tokens, i.e. operands for operators
> */
> enum {
> OPERATOR = Runemask+1, /* Bitmask of all operators */
> @@ -462,7 +462,8 @@
> exprp++;
> return '\n';
> }
> - return *exprp++|(Runemax+1);
> + /* add a flag so metacharacters aren't interpreted */
> + return *exprp++|(Runemask+1);
> }
> return *exprp++;
> }
> @@ -498,11 +499,12 @@
> if((c2 = nextrec()) == ']')
> goto Error;
> classp[n+0] = Runemax;
> - classp[n+1] = c1;
> - classp[n+2] = c2;
> + /* remove possible flag from nextrec() */
> + classp[n+1] = c1 & Runemask;
> + classp[n+2] = c2 & Runemask;
> n += 3;
> }else
> - classp[n++] = c1;
> + classp[n++] = c1 & Runemask;
> }
> classp[n] = 0;
> if(nclass == Nclass){
>
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tccbdb20b670003a1-Mde1c714fd9ca1af9f3407d8d
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 5515 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread