grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.18-39-gebe17c1


From: Paul Eggert
Subject: grep branch, master, updated. v2.18-39-gebe17c1
Date: Fri, 28 Mar 2014 16:33:45 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  ebe17c14f4110af0b480f734f4a25d2fe78df217 (commit)
       via  57b039471b5adaf1846fdd048bc6eb4de830d241 (commit)
       via  2b9c57ca9604c6e1117afb73177737892bab4adf (commit)
      from  cb1e339f576fa3a8431dd544edfc1d3b7792ddf2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=ebe17c14f4110af0b480f734f4a25d2fe78df217


commit ebe17c14f4110af0b480f734f4a25d2fe78df217
Author: Paul Eggert <address@hidden>
Date:   Fri Mar 28 09:32:29 2014 -0700

    dfa: avoid an indirection and port wint_t usage
    
    * src/dfa.c (struct dfa): Put mbrtowc_cache directly into struct dfa
    rather than having a pointer; this saves a malloc and an indirection.
    All uses changed.
    (dfambcache): Port to hosts where wint_t * can't be cast to wchar_t *.

diff --git a/src/dfa.c b/src/dfa.c
index 1ca7f38..4ed2189 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -381,7 +381,7 @@ struct dfa
      character (if any) for that byte.  WEOF means the byte is the
      leading byte of a multibyte character.  Invalid and null bytes are
      mapped to themselves.  */
-  wint_t *mbrtowc_cache;
+  wint_t mbrtowc_cache[NOTCHAR];
 #endif
 
   /* Array of the bracket expression in the DFA.  */
@@ -490,38 +490,42 @@ dfambcache (struct dfa *d)
 {
 #if MBS_SUPPORT
   int i;
-  MALLOC (d->mbrtowc_cache, NOTCHAR);
   for (i = CHAR_MIN; i <= CHAR_MAX; ++i)
     {
       char c = i;
       unsigned char uc = i;
       mbstate_t s = { 0 };
-      switch (mbrtowc ((wchar_t *) &d->mbrtowc_cache[uc], &c, 1, &s))
+      wchar_t wc;
+      wint_t wi;
+      switch (mbrtowc (&wc, &c, 1, &s))
         {
-        case (size_t) -2: d->mbrtowc_cache[uc] = WEOF; break;
-        case (size_t) -1: d->mbrtowc_cache[uc] = uc; break;
+        default: wi = wc; break;
+        case (size_t) -2: wi = WEOF; break;
+        case (size_t) -1: wi = uc; break;
         }
+      d->mbrtowc_cache[uc] = wi;
     }
 #endif
 }
 
 #if MBS_SUPPORT
-/* Store into *PWC the result of converting the leading bytes of the
-   multibyte buffer S of length N bytes, updating the conversion state
-   in *MBS.  On conversion error, convert just a single byte as-is.
-   Return the number of bytes converted.
+/* Given the dfa D, store into *PWC the result of converting the
+   leading bytes of the multibyte buffer S of length N bytes, updating
+   the conversion state in *MBS.  On conversion error, convert just a
+   single byte as-is.  Return the number of bytes converted.
 
    This differs from mbrtowc (PWC, S, N, MBS) as follows:
 
+   * Extra arg D, containing an mbrtowc_cache for speed.
    * N must be at least 1.
    * S[N - 1] must be a sentinel byte.
    * Shift encodings are not supported.
    * The return value is always in the range 1..N.
    * *MBS is always valid afterwards.
-   * *PWC is always set to something.
-   * This uses mbrtowc_cache for speed in the typical case.  */
+   * *PWC is always set to something.  */
 static size_t
-mbs_to_wchar (struct dfa *d, wchar_t *pwc, char const *s, size_t n, mbstate_t 
*mbs)
+mbs_to_wchar (struct dfa *d, wchar_t *pwc, char const *s, size_t n,
+              mbstate_t *mbs)
 {
   unsigned char uc = s[0];
   wint_t wc = d->mbrtowc_cache[uc];
@@ -3653,9 +3657,6 @@ dfafree (struct dfa *d)
 
   if (d->mb_cur_max > 1)
     free_mbdata (d);
-#if MBS_SUPPORT
-  free (d->mbrtowc_cache);
-#endif
 
   for (i = 0; i < d->sindex; ++i)
     {

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=57b039471b5adaf1846fdd048bc6eb4de830d241


commit ebe17c14f4110af0b480f734f4a25d2fe78df217
Author: Paul Eggert <address@hidden>
Date:   Fri Mar 28 09:32:29 2014 -0700

    dfa: avoid an indirection and port wint_t usage
    
    * src/dfa.c (struct dfa): Put mbrtowc_cache directly into struct dfa
    rather than having a pointer; this saves a malloc and an indirection.
    All uses changed.
    (dfambcache): Port to hosts where wint_t * can't be cast to wchar_t *.

diff --git a/src/dfa.c b/src/dfa.c
index 1ca7f38..4ed2189 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -381,7 +381,7 @@ struct dfa
      character (if any) for that byte.  WEOF means the byte is the
      leading byte of a multibyte character.  Invalid and null bytes are
      mapped to themselves.  */
-  wint_t *mbrtowc_cache;
+  wint_t mbrtowc_cache[NOTCHAR];
 #endif
 
   /* Array of the bracket expression in the DFA.  */
@@ -490,38 +490,42 @@ dfambcache (struct dfa *d)
 {
 #if MBS_SUPPORT
   int i;
-  MALLOC (d->mbrtowc_cache, NOTCHAR);
   for (i = CHAR_MIN; i <= CHAR_MAX; ++i)
     {
       char c = i;
       unsigned char uc = i;
       mbstate_t s = { 0 };
-      switch (mbrtowc ((wchar_t *) &d->mbrtowc_cache[uc], &c, 1, &s))
+      wchar_t wc;
+      wint_t wi;
+      switch (mbrtowc (&wc, &c, 1, &s))
         {
-        case (size_t) -2: d->mbrtowc_cache[uc] = WEOF; break;
-        case (size_t) -1: d->mbrtowc_cache[uc] = uc; break;
+        default: wi = wc; break;
+        case (size_t) -2: wi = WEOF; break;
+        case (size_t) -1: wi = uc; break;
         }
+      d->mbrtowc_cache[uc] = wi;
     }
 #endif
 }
 
 #if MBS_SUPPORT
-/* Store into *PWC the result of converting the leading bytes of the
-   multibyte buffer S of length N bytes, updating the conversion state
-   in *MBS.  On conversion error, convert just a single byte as-is.
-   Return the number of bytes converted.
+/* Given the dfa D, store into *PWC the result of converting the
+   leading bytes of the multibyte buffer S of length N bytes, updating
+   the conversion state in *MBS.  On conversion error, convert just a
+   single byte as-is.  Return the number of bytes converted.
 
    This differs from mbrtowc (PWC, S, N, MBS) as follows:
 
+   * Extra arg D, containing an mbrtowc_cache for speed.
    * N must be at least 1.
    * S[N - 1] must be a sentinel byte.
    * Shift encodings are not supported.
    * The return value is always in the range 1..N.
    * *MBS is always valid afterwards.
-   * *PWC is always set to something.
-   * This uses mbrtowc_cache for speed in the typical case.  */
+   * *PWC is always set to something.  */
 static size_t
-mbs_to_wchar (struct dfa *d, wchar_t *pwc, char const *s, size_t n, mbstate_t 
*mbs)
+mbs_to_wchar (struct dfa *d, wchar_t *pwc, char const *s, size_t n,
+              mbstate_t *mbs)
 {
   unsigned char uc = s[0];
   wint_t wc = d->mbrtowc_cache[uc];
@@ -3653,9 +3657,6 @@ dfafree (struct dfa *d)
 
   if (d->mb_cur_max > 1)
     free_mbdata (d);
-#if MBS_SUPPORT
-  free (d->mbrtowc_cache);
-#endif
 
   for (i = 0; i < d->sindex; ++i)
     {

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=2b9c57ca9604c6e1117afb73177737892bab4adf


commit ebe17c14f4110af0b480f734f4a25d2fe78df217
Author: Paul Eggert <address@hidden>
Date:   Fri Mar 28 09:32:29 2014 -0700

    dfa: avoid an indirection and port wint_t usage
    
    * src/dfa.c (struct dfa): Put mbrtowc_cache directly into struct dfa
    rather than having a pointer; this saves a malloc and an indirection.
    All uses changed.
    (dfambcache): Port to hosts where wint_t * can't be cast to wchar_t *.

diff --git a/src/dfa.c b/src/dfa.c
index 1ca7f38..4ed2189 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -381,7 +381,7 @@ struct dfa
      character (if any) for that byte.  WEOF means the byte is the
      leading byte of a multibyte character.  Invalid and null bytes are
      mapped to themselves.  */
-  wint_t *mbrtowc_cache;
+  wint_t mbrtowc_cache[NOTCHAR];
 #endif
 
   /* Array of the bracket expression in the DFA.  */
@@ -490,38 +490,42 @@ dfambcache (struct dfa *d)
 {
 #if MBS_SUPPORT
   int i;
-  MALLOC (d->mbrtowc_cache, NOTCHAR);
   for (i = CHAR_MIN; i <= CHAR_MAX; ++i)
     {
       char c = i;
       unsigned char uc = i;
       mbstate_t s = { 0 };
-      switch (mbrtowc ((wchar_t *) &d->mbrtowc_cache[uc], &c, 1, &s))
+      wchar_t wc;
+      wint_t wi;
+      switch (mbrtowc (&wc, &c, 1, &s))
         {
-        case (size_t) -2: d->mbrtowc_cache[uc] = WEOF; break;
-        case (size_t) -1: d->mbrtowc_cache[uc] = uc; break;
+        default: wi = wc; break;
+        case (size_t) -2: wi = WEOF; break;
+        case (size_t) -1: wi = uc; break;
         }
+      d->mbrtowc_cache[uc] = wi;
     }
 #endif
 }
 
 #if MBS_SUPPORT
-/* Store into *PWC the result of converting the leading bytes of the
-   multibyte buffer S of length N bytes, updating the conversion state
-   in *MBS.  On conversion error, convert just a single byte as-is.
-   Return the number of bytes converted.
+/* Given the dfa D, store into *PWC the result of converting the
+   leading bytes of the multibyte buffer S of length N bytes, updating
+   the conversion state in *MBS.  On conversion error, convert just a
+   single byte as-is.  Return the number of bytes converted.
 
    This differs from mbrtowc (PWC, S, N, MBS) as follows:
 
+   * Extra arg D, containing an mbrtowc_cache for speed.
    * N must be at least 1.
    * S[N - 1] must be a sentinel byte.
    * Shift encodings are not supported.
    * The return value is always in the range 1..N.
    * *MBS is always valid afterwards.
-   * *PWC is always set to something.
-   * This uses mbrtowc_cache for speed in the typical case.  */
+   * *PWC is always set to something.  */
 static size_t
-mbs_to_wchar (struct dfa *d, wchar_t *pwc, char const *s, size_t n, mbstate_t 
*mbs)
+mbs_to_wchar (struct dfa *d, wchar_t *pwc, char const *s, size_t n,
+              mbstate_t *mbs)
 {
   unsigned char uc = s[0];
   wint_t wc = d->mbrtowc_cache[uc];
@@ -3653,9 +3657,6 @@ dfafree (struct dfa *d)
 
   if (d->mb_cur_max > 1)
     free_mbdata (d);
-#if MBS_SUPPORT
-  free (d->mbrtowc_cache);
-#endif
 
   for (i = 0; i < d->sindex; ++i)
     {

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |  154 +++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 90 insertions(+), 64 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

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