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 2012/11/06 12:05:01 UTC

svn commit: r1406095 - in /subversion/branches/wc-collate-path: build.conf subversion/include/private/svn_utf_private.h subversion/include/svn_error_codes.h subversion/libsvn_subr/utf8proc.c

Author: brane
Date: Tue Nov  6 11:05:00 2012
New Revision: 1406095

URL: http://svn.apache.org/viewvc?rev=1406095&view=rev
Log:
On the wc-collate-path branch: Begin wrapping utf8proc.

* build.conf (private-includes): Add utf8proc.h, utf8proc.c and utf8proc_data.c
   from subversion/libsvn_subr/utf8proc/.

* subversion/include/svn_error_codes.h (SVN_ERR_UTF8PROC_ERROR): New error
   code for wrapped utf8proc errors.

* subversion/include/private/svn_utf_private.h: Update description.
  (svn_utf__decompose_normalized, svn_utf__utf8proc_version): New.

* subversion/libsvn_subr/utf8proc.c: New file.
  (svn_utf__decompose_normalized, svn_utf__utf8proc_version): Implement here.

Added:
    subversion/branches/wc-collate-path/subversion/libsvn_subr/utf8proc.c
Modified:
    subversion/branches/wc-collate-path/build.conf
    subversion/branches/wc-collate-path/subversion/include/private/svn_utf_private.h
    subversion/branches/wc-collate-path/subversion/include/svn_error_codes.h

Modified: subversion/branches/wc-collate-path/build.conf
URL: http://svn.apache.org/viewvc/subversion/branches/wc-collate-path/build.conf?rev=1406095&r1=1406094&r2=1406095&view=diff
==============================================================================
--- subversion/branches/wc-collate-path/build.conf (original)
+++ subversion/branches/wc-collate-path/build.conf Tue Nov  6 11:05:00 2012
@@ -38,6 +38,9 @@ private-includes =
         subversion/include/private/*.h
         subversion/bindings/swig/include/*.swg
         subversion/libsvn_delta/compose_delta.c
+        subversion/libsvn_subr/utf8proc/utf8proc.c
+        subversion/libsvn_subr/utf8proc/utf8proc.h
+        subversion/libsvn_subr/utf8proc/utf8proc_data.c
 private-built-includes =
         subversion/svn_private_config.h
         subversion/libsvn_fs_fs/rep-cache-db.h

Modified: subversion/branches/wc-collate-path/subversion/include/private/svn_utf_private.h
URL: http://svn.apache.org/viewvc/subversion/branches/wc-collate-path/subversion/include/private/svn_utf_private.h?rev=1406095&r1=1406094&r2=1406095&view=diff
==============================================================================
--- subversion/branches/wc-collate-path/subversion/include/private/svn_utf_private.h (original)
+++ subversion/branches/wc-collate-path/subversion/include/private/svn_utf_private.h Tue Nov  6 11:05:00 2012
@@ -21,7 +21,7 @@
  * @endcopyright
  *
  * @file svn_utf_private.h
- * @brief UTF validation routines
+ * @brief UTF validation and normalization routines
  */
 
 #ifndef SVN_UTF_PRIVATE_H
@@ -80,6 +80,28 @@ svn_utf__cstring_from_utf8_fuzzy(const c
                                                apr_pool_t *));
 
 
+/* Fill the given BUFFER with an NFD representation of the UTF-8
+ * string STR, with one buffer slot per Unicode codepoint. If LEN is
+ * 0, assume STR is NUL-terminated; otherwise look only at the first
+ * LEN bytes in STR. If the returned RESULT_LENGTH is greater than the
+ * supplied BUFFER_LENGTH, the the contents of the buffer are
+ * indeterminate; otherwise the buffer up to RESULT_LENGTH contains
+ * the normalized string representation.
+ *
+ * A returned error may indicate that STR contains invalid UTF-8 or
+ * invalid Unicode codepoints. Any error message comes from utf8proc.
+ */
+svn_error_t *
+svn_utf__decompose_normalized(const char *str, apr_size_t len,
+                              apr_int32_t *buffer, apr_size_t buffer_length,
+                              apr_size_t *result_length);
+
+
+
+/* Return the version of the wrapped utf8proc library. */
+const char *
+svn_utf__utf8proc_version(void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/branches/wc-collate-path/subversion/include/svn_error_codes.h
URL: http://svn.apache.org/viewvc/subversion/branches/wc-collate-path/subversion/include/svn_error_codes.h?rev=1406095&r1=1406094&r2=1406095&view=diff
==============================================================================
--- subversion/branches/wc-collate-path/subversion/include/svn_error_codes.h (original)
+++ subversion/branches/wc-collate-path/subversion/include/svn_error_codes.h Tue Nov  6 11:05:00 2012
@@ -1430,6 +1430,11 @@ SVN_ERROR_START
              SVN_ERR_MISC_CATEGORY_START + 38,
              "Atomic data storage is corrupt")
 
+  /** @since New in 1.8. */
+  SVN_ERRDEF(SVN_ERR_UTF8PROC_ERROR,
+             SVN_ERR_MISC_CATEGORY_START + 39,
+             "utf8proc library error")
+
   /* command-line client errors */
 
   SVN_ERRDEF(SVN_ERR_CL_ARG_PARSING_ERROR,

Added: subversion/branches/wc-collate-path/subversion/libsvn_subr/utf8proc.c
URL: http://svn.apache.org/viewvc/subversion/branches/wc-collate-path/subversion/libsvn_subr/utf8proc.c?rev=1406095&view=auto
==============================================================================
--- subversion/branches/wc-collate-path/subversion/libsvn_subr/utf8proc.c (added)
+++ subversion/branches/wc-collate-path/subversion/libsvn_subr/utf8proc.c Tue Nov  6 11:05:00 2012
@@ -0,0 +1,63 @@
+/*
+ * utf8proc.c:  Wrappers for the utf8proc library
+ *
+ * ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ * ====================================================================
+ */
+
+
+
+#define UTF8PROC_INLINE
+#include "utf8proc/utf8proc.c"
+
+#include "private/svn_utf_private.h"
+#include "svn_private_config.h"
+#define UNUSED(x) ((void)(x))
+
+
+const char *svn_utf__utf8proc_version(void)
+{
+  /* Unused static function warning removal hack. */
+  UNUSED(utf8proc_codepoint_valid);
+  UNUSED(utf8proc_NFD);
+  UNUSED(utf8proc_NFC);
+  UNUSED(utf8proc_NFKD);
+  UNUSED(utf8proc_NFKC);
+
+  return utf8proc_version();
+}
+
+
+svn_error_t *
+svn_utf__decompose_normalized(const char *str, apr_size_t len,
+                              apr_int32_t *buffer, apr_size_t buffer_length,
+                              apr_size_t *result_length)
+{
+  const ssize_t result = utf8proc_decompose((const void*)str, len,
+                                            buffer, buffer_length,
+                                            UTF8PROC_DECOMPOSE
+                                            | UTF8PROC_STABLE
+                                            | (len ? 0 : UTF8PROC_NULLTERM));
+  if (result < 0)
+    return svn_error_create(SVN_ERR_UTF8PROC_ERROR, NULL,
+                            gettext(utf8proc_errmsg(result)));
+
+  *result_length = (apr_size_t)result;
+  return SVN_NO_ERROR;
+}