You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2013/05/08 23:01:01 UTC

svn commit: r1480456 - in /subversion/trunk: ./ subversion/libsvn_subr/ subversion/libsvn_subr/utf8proc/ subversion/tests/libsvn_subr/

Author: brane
Date: Wed May  8 21:01:01 2013
New Revision: 1480456

URL: http://svn.apache.org/r1480456
Log:
Fallout from the wc-collate-branch merge.
  - Rename the utf8proc .c files to .c.inline to prevent them from
    being built out-of-line on Winodws. This is a temporary measure
    until the windows project file generator is fixed.
  - Fixed crashes in utf-test.

* subversion/libsvn_subr/utf8proc/utf8proc_data.c.inline:
   Renamed from utf8proc_data.c
* subversion/libsvn_subr/utf8proc/utf8proc.c:
   Renamed from utf8proc.c, and updated the _data include.
* build.conf (private-includes): Update with the above changes.

* subversion/libsvn_subr/utf8proc.c: Update utf8proc.c.inline include.
  (encode_ucs4_string, svn_utf__glob): Ensure that membufs have enough
   space when appending data to them.
* subversion/tests/libsvn_subr/utf-test.c
  (test_utf_collated_compare, test_utf_pattern_match): Actually conform
   to the svn_utf__normcomp and svn_utf__glob prototypes.
  (test_funcs): Fix docstring of test_utf_pattern_match.

Added:
    subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc.c.inline
      - copied, changed from r1480412, subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc.c
    subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc_data.c.inline
      - copied unchanged from r1480412, subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc_data.c
Removed:
    subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc.c
    subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc_data.c
Modified:
    subversion/trunk/build.conf
    subversion/trunk/subversion/libsvn_subr/utf8proc.c
    subversion/trunk/subversion/tests/libsvn_subr/utf-test.c

Modified: subversion/trunk/build.conf
URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1480456&r1=1480455&r2=1480456&view=diff
==============================================================================
--- subversion/trunk/build.conf (original)
+++ subversion/trunk/build.conf Wed May  8 21:01:01 2013
@@ -40,9 +40,9 @@ private-includes =
         subversion/libsvn_delta/compose_delta.c
         subversion/bindings/cxxhl/include/*.hpp
         subversion/bindings/cxxhl/include/svncxxhl/*.hpp
-        subversion/libsvn_subr/utf8proc/utf8proc.c
         subversion/libsvn_subr/utf8proc/utf8proc.h
-        subversion/libsvn_subr/utf8proc/utf8proc_data.c
+        subversion/libsvn_subr/utf8proc/utf8proc.c.inline
+        subversion/libsvn_subr/utf8proc/utf8proc_data.c.inline
 private-built-includes =
         subversion/svn_private_config.h
         subversion/libsvn_fs_fs/rep-cache-db.h

Modified: subversion/trunk/subversion/libsvn_subr/utf8proc.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/utf8proc.c?rev=1480456&r1=1480455&r2=1480456&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/utf8proc.c (original)
+++ subversion/trunk/subversion/libsvn_subr/utf8proc.c Wed May  8 21:01:01 2013
@@ -24,7 +24,7 @@
 
 
 #define UTF8PROC_INLINE
-#include "utf8proc/utf8proc.c"
+#include "utf8proc/utf8proc.c.inline"
 
 #include <apr_fnmatch.h>
 
@@ -177,6 +177,7 @@ encode_ucs4_string(svn_membuf_t *buffer,
   *result_length = 0;
   while (len-- > 0)
     SVN_ERR(encode_ucs4(buffer, *ucs4str++, result_length));
+  svn_membuf__resize(buffer, *result_length + 1);
   ((char*)buffer->data)[*result_length] = '\0';
   return SVN_NO_ERROR;
 }
@@ -237,10 +238,12 @@ svn_utf__glob(svn_boolean_t *match,
         }
 
       patternbuf_len = 0;
+      svn_membuf__ensure(pattern_buf, tempbuf_len + 1);
       for (i = 0, escaped = FALSE; i < tempbuf_len; ++i, ++like)
         {
           if (*like == ucs4esc && !escaped)
             {
+              svn_membuf__resize(pattern_buf, patternbuf_len + 1);
               ((char*)pattern_buf->data)[patternbuf_len++] = '\\';
               escaped = TRUE;
             }
@@ -255,6 +258,7 @@ svn_utf__glob(svn_boolean_t *match,
                 {
                   /* Escape brackets and backslashes which are always
                      literals in LIKE patterns. */
+                  svn_membuf__resize(pattern_buf, patternbuf_len + 1);
                   ((char*)pattern_buf->data)[patternbuf_len++] = '\\';
                   escaped = TRUE;
                   --i; --like;
@@ -262,14 +266,17 @@ svn_utf__glob(svn_boolean_t *match,
                 }
 
               /* Replace LIKE wildcards with their GLOB equivalents. */
-              if (*like == '%')
-                ((char*)pattern_buf->data)[patternbuf_len++] = '*';
-              else if (*like == '_')
-                ((char*)pattern_buf->data)[patternbuf_len++] = '?';
+              if (*like == '%' || *like == '_')
+                {
+                  const char wildcard = (*like == '%' ? '*' : '?');
+                  svn_membuf__resize(pattern_buf, patternbuf_len + 1);
+                  ((char*)pattern_buf->data)[patternbuf_len++] = wildcard;
+                }
               else
                 SVN_ERR(encode_ucs4(pattern_buf, *like, &patternbuf_len));
             }
         }
+      svn_membuf__resize(pattern_buf, patternbuf_len + 1);
       ((char*)pattern_buf->data)[patternbuf_len] = '\0';
     }
 

Copied: subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc.c.inline (from r1480412, subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc.c)
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc.c.inline?p2=subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc.c.inline&p1=subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc.c&r1=1480412&r2=1480456&rev=1480456&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc.c (original)
+++ subversion/trunk/subversion/libsvn_subr/utf8proc/utf8proc.c.inline Wed May  8 21:01:01 2013
@@ -40,7 +40,7 @@
 
 
 #include "utf8proc.h"
-#include "utf8proc_data.c"
+#include "utf8proc_data.c.inline"
 
 
 UTF8PROC_DATA

Modified: subversion/trunk/subversion/tests/libsvn_subr/utf-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/utf-test.c?rev=1480456&r1=1480455&r2=1480456&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/utf-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/utf-test.c Wed May  8 21:01:01 2013
@@ -25,6 +25,7 @@
 #include "svn_utf.h"
 #include "svn_pools.h"
 
+#include "private/svn_string_private.h"
 #include "private/svn_utf_private.h"
 
 /* Random number seed.  Yes, it's global, just pretend you can't see it. */
@@ -410,9 +411,10 @@ test_utf_collated_compare(apr_pool_t *po
   };
 
 
-  svn_stringbuf_t *bufa = svn_stringbuf_create_empty(pool);
-  svn_stringbuf_t *bufb = svn_stringbuf_create_empty(pool);
   const struct utfcmp_test_t *ut;
+  svn_membuf_t bufa, bufb;
+  svn_membuf__create(&bufa, 0, pool);
+  svn_membuf__create(&bufb, 0, pool);
 
   srand(111);
   for (ut = utfcmp_tests; ut->stra; ++ut)
@@ -424,23 +426,24 @@ test_utf_collated_compare(apr_pool_t *po
                                ? SVN_UTF__UNKNOWN_LENGTH : strlen(ut->strb));
       int result;
 
-      SVN_ERR(svn_utf__normcmp(ut->stra, lena, ut->strb, lenb,
-                               bufa, bufb, &result));
+      SVN_ERR(svn_utf__normcmp(&result,
+                               ut->stra, lena, ut->strb, lenb,
+                               &bufa, &bufb));
 
       /* UCS-4 debugging dump of the decomposed strings
       {
-        const apr_int32_t *const ucsbufa = (void*)bufa->data;
-        const apr_int32_t *const ucsbufb = (void*)bufb->data;
+        const apr_int32_t *const ucsbufa = bufa.data;
+        const apr_int32_t *const ucsbufb = bufb.data;
         apr_size_t i;
 
         printf("(%c)%7s %c %s\n", ut->op,
                ut->taga, (!result ? '=' : (result < 0 ? '<' : '>')), ut->tagb);
 
-        for (i = 0; i < bufa->len || i < bufb->len; ++i)
+        for (i = 0; i < bufa.size || i < bufb.size; ++i)
         {
-          if (i < bufa->len && i < bufb->len)
+          if (i < bufa.size && i < bufb.size)
             printf("    U+%04X   U+%04X\n", ucsbufa[i], ucsbufb[i]);
-          else if (i < bufa->len)
+          else if (i < bufa.size)
             printf("    U+%04X\n", ucsbufa[i]);
           else
             printf("             U+%04X\n", ucsbufb[i]);
@@ -557,10 +560,11 @@ test_utf_pattern_match(apr_pool_t *pool)
     {FALSE, FALSE, NULL, NULL, NULL}
   };
 
-  svn_stringbuf_t *bufa = svn_stringbuf_create_empty(pool);
-  svn_stringbuf_t *bufb = svn_stringbuf_create_empty(pool);
-  svn_stringbuf_t *bufc = svn_stringbuf_create_empty(pool);
   const struct glob_test_t *gt;
+  svn_membuf_t bufa, bufb, bufc;
+  svn_membuf__create(&bufa, 0, pool);
+  svn_membuf__create(&bufb, 0, pool);
+  svn_membuf__create(&bufc, 0, pool);
 
   srand(79);
   for (gt = glob_tests; gt->pattern; ++gt)
@@ -579,10 +583,11 @@ test_utf_pattern_match(apr_pool_t *pool)
       svn_error_t *err;
 
 
-      err = svn_utf__glob(gt->pattern, lenptn,
+      err = svn_utf__glob(&match,
+                          gt->pattern, lenptn,
                           gt->string, lenstr,
                           gt->escape, lenesc,
-                          gt->sql_like, bufa, bufb, bufc, &match);
+                          gt->sql_like, &bufa, &bufb, &bufc);
 
       if (!gt->sql_like && gt->escape && !err)
         return svn_error_create
@@ -629,6 +634,6 @@ struct svn_test_descriptor_t test_funcs[
     SVN_TEST_PASS2(test_utf_collated_compare,
                    "test svn_utf__normcmp"),
     SVN_TEST_PASS2(test_utf_pattern_match,
-                   "test svn_utf__match"),
+                   "test svn_utf__glob"),
     SVN_TEST_NULL
   };