From: "Владислав Родин via ruby-core" Date: 2023-09-29T19:55:45+06:00 Subject: [ruby-core:114923] Re: [Ruby master Misc#19767] [Not really a bug, but more a not ideal notification] "historical binary regexp match" when using the "n" modifier in a ruby regex --===============4698106767963002690== Content-Type: multipart/alternative; boundary="0000000000009f3c9d06067fc8c4" --0000000000009f3c9d06067fc8c4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =F0=9F=98=83 =D0=BF=D1=82, 29 =D1=81=D0=B5=D0=BD=D1=82. 2023=E2=80=AF=D0=B3. =D0=B2 18:5= 7, Dan0042 (Daniel DeLorme) via ruby-core < ruby-core@ml.ruby-lang.org>: > Issue #19767 has been updated by Dan0042 (Daniel DeLorme). > > > The "historical" and "binary" parts were added in 2017 > > https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/= d8cee4ff0a851037e96fe76d951a1549284c875a/diff/re.c > > https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/= dbd4c4a7b373061d235857f7f34e15859a7f1051/diff/re.c > The original warning was added in 2008 > > https://bugs.ruby-lang.org/projects/ruby-master/repository/git/revisions/= 880a96c795d30d95497cb216c8bfc7fa1b3b5387/diff/re.c > > It means that even though it may look like a binary regexp, it doesn't ac= t > like one. `"=C3=A9"[/./n] =3D=3D "=C3=A9"`, not the first byte of "=C3=A9= " > > TBH I don't know why it was done that way. It would be convenient if > `/.../n =3D~ str` was equivalent to `/.../n =3D~ str.b` but without the > intermediary string. > > ---------------------------------------- > Misc #19767: [Not really a bug, but more a not ideal notification] > "historical binary regexp match" when using the "n" modifier in a ruby re= gex > https://bugs.ruby-lang.org/issues/19767#change-104790 > > * Author: rubyFeedback (robert heiler) > * Status: Open > * Priority: Normal > ---------------------------------------- > To get my knowledge about ruby regexes up-to-date I have been > going through this tutorial/book here at: > > https://learnbyexample.github.io/Ruby_Regexp/unicode.html > > One example they provide is this, with some odd characters: > > 'fox:=CE=B1=CE=BB=CE=B5=CF=80=CE=BF=CF=8D'.scan(/\w+/n) > > This will match the found word ("fox"), but it also reports > the following warning: > > warning: historical binary regexp match /.../n against UTF-8 string > > Now: this may be obvious to others, but to me personally I am not > sure what a "historical" binary regexp match actually is. I assume > it may have meant that this was more used in the past, and may be > discouraged now? Or is something else meant? What does "historical" > mean in this context? > > I may not be the only one who does not fully understand the term > historical. Most of ruby's warnings are fairly easy to understand, > but this one seems odd. Right now I do not know whether we can use > the "n" modifier in a regex - not that I really have a good use > case for it (I am using UTF-8 these days, so I don't seem to need > ASCII-8BIT anyway), but perhaps the warning could be changed a little. > > I have no good alternative suggestion how it can be changed, largely > because I do not know what it actually means, e. g. what is "historical" > about it (but, even then, I'd actually recommend against using the > word "historical" because I don't understand what it means; deprecated > is easy to understand, historical does not tell me anything). > > Perhaps it could be expressed somewhat differently and we could get > rid of the word "historical" there? Either way, it's a tiny issue so > I was not even sure whether to report it. But, from the point of view > of other warnings, I believe the term "historical" does not tell the > user enough about what the issue is here. > > > (irb):1: warning: historical binary regexp match /.../n against UTF-8 > string > =3D> ["fox"] > > > > > -- > https://bugs.ruby-lang.org/ > ______________________________________________ > ruby-core mailing list -- ruby-core@ml.ruby-lang.org > To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org > ruby-core info -- > https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.= org/ --0000000000009f3c9d06067fc8c4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
=F0=9F=98=83

=D0=BF=D1=82, 29 =D1=81=D0=B5=D0=BD=D1=82.= 2023=E2=80=AF=D0=B3. =D0=B2 18:57, Dan0042 (Daniel DeLorme) via ruby-core = <ruby-core@ml.ruby-lang.or= g>:
Issue= #19767 has been updated by Dan0042 (Daniel DeLorme).


The "historical" and "binary" parts were added in 2017<= br> https://bugs.ruby-lang.org/projects/ruby-master/repo= sitory/git/revisions/d8cee4ff0a851037e96fe76d951a1549284c875a/diff/re.c=
https://bugs.ruby-lang.org/projects/ruby-master/repo= sitory/git/revisions/dbd4c4a7b373061d235857f7f34e15859a7f1051/diff/re.c=
The original warning was added in 2008
https://bugs.ruby-lang.org/projects/ruby-master/repo= sitory/git/revisions/880a96c795d30d95497cb216c8bfc7fa1b3b5387/diff/re.c=

It means that even though it may look like a binary regexp, it doesn't = act like one. `"=C3=A9"[/./n] =3D=3D "=C3=A9"`, not the= first byte of "=C3=A9"

TBH I don't know why it was done that way. It would be convenient if `/= .../n =3D~ str` was equivalent to `/.../n =3D~ str.b` but without the inter= mediary string.

----------------------------------------
Misc #19767: [Not really a bug, but more a not ideal notification] "hi= storical binary regexp match" when using the "n" modifier in= a ruby regex
https://bugs.ruby-lang.org/issues/19767#change-= 104790

* Author: rubyFeedback (robert heiler)
* Status: Open
* Priority: Normal
----------------------------------------
To get my knowledge about ruby regexes up-to-date I have been
going through this tutorial/book here at:

https://learnbyexample.github.io/Ruby_Reg= exp/unicode.html

One example they provide is this, with some odd characters:

=C2=A0 =C2=A0 'fox:=CE=B1=CE=BB=CE=B5=CF=80=CE=BF=CF=8D'.scan(/\w+/= n)

This will match the found word ("fox"), but it also reports
the following warning:

=C2=A0 =C2=A0 warning: historical binary regexp match /.../n against UTF-8 = string

Now: this may be obvious to others, but to me personally I am not
sure what a "historical" binary regexp match actually is. I assum= e
it may have meant that this was more used in the past, and may be
discouraged now? Or is something else meant? What does "historical&quo= t;
mean in this context?

I may not be the only one who does not fully understand the term
historical. Most of ruby's warnings are fairly easy to understand,
but this one seems odd. Right now I do not know whether we can use
the "n" modifier in a regex - not that I really have a good use <= br> case for it (I am using UTF-8 these days, so I don't seem to need
ASCII-8BIT anyway), but perhaps the warning could be changed a little.

I have no good alternative suggestion how it can be changed, largely
because I do not know what it actually means, e. g. what is "historica= l"
about it (but, even then, I'd actually recommend against using the
word "historical" because I don't understand what it means; d= eprecated
is easy to understand, historical does not tell me anything).

Perhaps it could be expressed somewhat differently and we could get
rid of the word "historical" there? Either way, it's a tiny i= ssue so
I was not even sure whether to report it. But, from the point of view
of other warnings, I believe the term "historical" does not tell = the
user enough about what the issue is here.


(irb):1: warning: historical binary regexp match /.../n against UTF-8 strin= g
=3D> ["fox"]




--
https://bugs.ruby-lang.org/
=C2=A0______________________________________________
=C2=A0ruby-core mailing list -- ruby-core@ml.ruby-lang.org
=C2=A0To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
=C2=A0ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.o= rg/
--0000000000009f3c9d06067fc8c4-- --===============4698106767963002690== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/ --===============4698106767963002690==--