subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bre...@apache.org
Subject svn commit: r1612748 - in /subversion/branches/svn-auth-x509/subversion: include/svn_utf.h libsvn_subr/utf.c
Date Wed, 23 Jul 2014 03:33:52 GMT
Author: breser
Date: Wed Jul 23 03:33:52 2014
New Revision: 1612748

URL: http://svn.apache.org/r1612748
Log:
On svn-auth-x509 branch, add svn_utf_string_to_utf8_ex() API.

I'll need this API to convert BMPString and UniversalString types to UTF-8.
They are UCS-2BE and UCS-4BE respectively, which means they may have NUL bytes
and so we need a function to convert a counted length string of a given encoding
to UTF-8, which we don't have right now.

* subversion/include/svn_utf.h
  subversion/libsvn_subr/utf.c:  Add svn_utf_string_to_utf8_ex().

Modified:
    subversion/branches/svn-auth-x509/subversion/include/svn_utf.h
    subversion/branches/svn-auth-x509/subversion/libsvn_subr/utf.c

Modified: subversion/branches/svn-auth-x509/subversion/include/svn_utf.h
URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/include/svn_utf.h?rev=1612748&r1=1612747&r2=1612748&view=diff
==============================================================================
--- subversion/branches/svn-auth-x509/subversion/include/svn_utf.h (original)
+++ subversion/branches/svn-auth-x509/subversion/include/svn_utf.h Wed Jul 23 03:33:52 2014
@@ -94,6 +94,18 @@ svn_utf_string_to_utf8(const svn_string_
                        apr_pool_t *pool);
 
 
+/** Set @a *dest to a utf8 encoded string from @a frompage encoded
+ * string @a src; allocate @a *dest in @a pool.
+ *
+ * @since New in 1.9.
+ */
+svn_error_t *
+svn_utf_string_to_utf8_ex(const svn_string_t **dest,
+                          const svn_string_t *src,
+                          const char *frompage,
+                          apr_pool_t *pool);
+
+
 /** Set @a *dest to a utf8-encoded C string from native C string @a src;
  * allocate @a *dest in @a pool.
  */

Modified: subversion/branches/svn-auth-x509/subversion/libsvn_subr/utf.c
URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_subr/utf.c?rev=1612748&r1=1612747&r2=1612748&view=diff
==============================================================================
--- subversion/branches/svn-auth-x509/subversion/libsvn_subr/utf.c (original)
+++ subversion/branches/svn-auth-x509/subversion/libsvn_subr/utf.c Wed Jul 23 03:33:52 2014
@@ -703,17 +703,17 @@ svn_utf_stringbuf_to_utf8(svn_stringbuf_
                                       pool));
 }
 
-
-svn_error_t *
-svn_utf_string_to_utf8(const svn_string_t **dest,
-                       const svn_string_t *src,
-                       apr_pool_t *pool)
+/* Common implementation for svn_utf_string_to_utf8,
+   svn_utf_string_to_utf8_ex.  Convert SRC to DEST using NODE->handle as
+   the translator and allocating from POOL. */
+static svn_error_t *
+convert_string(const svn_string_t **dest,
+               const svn_string_t *src,
+               xlate_handle_node_t *node,
+               apr_pool_t *pool)
 {
-  svn_stringbuf_t *destbuf;
-  xlate_handle_node_t *node;
   svn_error_t *err;
-
-  SVN_ERR(get_ntou_xlate_handle_node(&node, pool));
+  svn_stringbuf_t *destbuf;
 
   if (node->handle)
     {
@@ -730,6 +730,20 @@ svn_utf_string_to_utf8(const svn_string_
         *dest = svn_string_dup(src, pool);
     }
 
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_utf_string_to_utf8(const svn_string_t **dest,
+                       const svn_string_t *src,
+                       apr_pool_t *pool)
+{
+  xlate_handle_node_t *node;
+  svn_error_t *err;
+
+  SVN_ERR(get_ntou_xlate_handle_node(&node, pool));
+
+  err = convert_string(dest, src, node, pool);
   return svn_error_compose_create(err,
                                   put_xlate_handle_node
                                      (node,
@@ -737,6 +751,28 @@ svn_utf_string_to_utf8(const svn_string_
                                       pool));
 }
 
+svn_error_t *
+svn_utf_string_to_utf8_ex(const svn_string_t **dest,
+                          const svn_string_t *src,
+                          const char *frompage,
+                          apr_pool_t *pool)
+{
+  xlate_handle_node_t *node;
+  svn_error_t *err;
+  const char *convset_key = get_xlate_key(SVN_APR_UTF8_CHARSET, frompage,
+                                          pool);
+
+  SVN_ERR(get_xlate_handle_node(&node, SVN_APR_UTF8_CHARSET, frompage,
+                                convset_key, pool));
+  err = convert_string(dest, src, node, pool);
+  SVN_ERR(svn_error_compose_create(err,
+                                   put_xlate_handle_node
+                                      (node,
+                                       SVN_UTF_NTOU_XLATE_HANDLE,
+                                       pool)));
+
+  return check_utf8((*dest)->data, (*dest)->len, pool);
+}
 
 /* Common implementation for svn_utf_cstring_to_utf8,
    svn_utf_cstring_to_utf8_ex, svn_utf_cstring_from_utf8 and



Mime
View raw message