bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: gawk3.1.4: parse_escape problem


From: Aharon Robbins
Subject: Re: gawk3.1.4: parse_escape problem
Date: Wed, 15 Jun 2005 22:42:50 +0300

Greetings. Re this:

In article <address@hidden> you write:
>Hi,
>
>I found multibyte bug.
>
>That is, string which has escape seqence and some multibyte character
>(has '\' as tis second byte) is parse_escape() accidentrally.
>ex. "\nXXYY" (here, XX and YY are multibyte character)
>
>Here is a patch.
>
>--- node.c.7~  2005-02-15 23:25:19.000000000 +0900
>+++ node.c     2005-06-13 01:08:40.000000000 +0900
>@@ -378,9 +378,21 @@
>               register char *ptm;
>               register int c;
>               register const char *end;
>-
>+#if defined MBS_SUPPORT
>+              mbstate_t cur_state;
>+              memset(&cur_state, 0, sizeof (cur_state));
>+#endif
>               end = &(r->stptr[len]);
>               for (pf = ptm = r->stptr; pf < end;) {
>+#if defined MBS_SUPPORT
>+                      int mblen = mbrlen(pf, end-pf, &cur_state);
>+                      if (mblen > 1) {
>+                              int i;
>+                              for (i=0; i<mblen; i++)
>+                                      *ptm++ = *pf++;
>+                              continue;
>+                      }
>+#endif
>                       c = *pf++;
>                       if (c == '\\') {
>                               c = parse_escape(&pf);
>
>
>Thank you,
>
>-- 
>KIMURA Koichi

Thanks. I have applied this, although I wrapped the mblen test in
an additional check for gawk_mb_cur_max > 1.

Arnold
-- 
Aharon (Arnold) Robbins --- Pioneer Consulting Ltd.     arnold AT skeeve DOT com
P.O. Box 354            Home Phone: +972  8 979-0381    Fax: +1 206 350 8765
Nof Ayalon              Cell Phone: +972 50  729-7545
D.N. Shimshon 99785     ISRAEL




reply via email to

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