apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r106176 - /apr/apr-util/trunk/CHANGES /apr/apr-util/trunk/include/apr_xlate.h /apr/apr-util/trunk/test/testxlate.c /apr/apr-util/trunk/xlate/xlate.c
Date Mon, 22 Nov 2004 11:44:25 GMT
Author: jorton
Date: Mon Nov 22 03:44:24 2004
New Revision: 106176

Modified:
   apr/apr-util/trunk/CHANGES
   apr/apr-util/trunk/include/apr_xlate.h
   apr/apr-util/trunk/test/testxlate.c
   apr/apr-util/trunk/xlate/xlate.c
Log:
* include/apr_xlate.h (apr_xlate_conv_buffer): Document the
final inbuf=NUL call necessary to correctly terminate the
output buffer.

* xlate/xlate.c (apr_xlate_conv_buffer): Handle a NULL inbuf
parameter.

* text/testxlate.c (test_conversion): Call apr_xlate_conv_buffer with
NULL inbuf paramater to terminate the output buffer.

Reviewed by: Uwe Zeisberger, Jeff Trawick


Modified: apr/apr-util/trunk/CHANGES
Url: http://svn.apache.org/viewcvs/apr/apr-util/trunk/CHANGES?view=diff&rev=106176&p1=apr/apr-util/trunk/CHANGES&r1=106175&p2=apr/apr-util/trunk/CHANGES&r2=106176
==============================================================================
--- apr/apr-util/trunk/CHANGES	(original)
+++ apr/apr-util/trunk/CHANGES	Mon Nov 22 03:44:24 2004
@@ -1,5 +1,10 @@
 Changes with APR-util 1.1.0
 
+  *) Allow passing NULL inbuf/inbytes_left parameters to
+     apr_xlate_conv_buffer(), required to correctly terminate the
+     output buffer for some stateful character set encodings.
+     [Joe Orton]
+
   *) Link libaprutil against the libraries on which it depends.
      PR 11122.  [Joe Orton]
 

Modified: apr/apr-util/trunk/include/apr_xlate.h
Url: http://svn.apache.org/viewcvs/apr/apr-util/trunk/include/apr_xlate.h?view=diff&rev=106176&p1=apr/apr-util/trunk/include/apr_xlate.h&r1=106175&p2=apr/apr-util/trunk/include/apr_xlate.h&r2=106176
==============================================================================
--- apr/apr-util/trunk/include/apr_xlate.h	(original)
+++ apr/apr-util/trunk/include/apr_xlate.h	Mon Nov 22 03:44:24 2004
@@ -102,8 +102,16 @@
  * @param outbytes_left Input: the size of the output buffer
  *                      Output: the amount of the output buffer not yet used
  * @remark
- *  Return APR_ENOTIMPL if charset transcoding is not available
- *  in this instance of apr-util (i.e., APR_HAS_XLATE is undefined).
+ * Returns APR_ENOTIMPL if charset transcoding is not available
+ * in this instance of apr-util (i.e., APR_HAS_XLATE is undefined).
+ * Returns APR_INCOMPLETE if the input buffer ends in an incomplete
+ * multi-byte character.
+ *
+ * To correctly terminate the output buffer for some multi-byte
+ * character set encodings, a final call must be made to this function
+ * after the complete input string has been converted, passing
+ * the inbuf and inbytes_left parameters as NULL.  (Note that this
+ * mode only works from version 1.1.0 onwards)
  */
 APU_DECLARE(apr_status_t) apr_xlate_conv_buffer(apr_xlate_t *convset, 
                                                 const char *inbuf, 

Modified: apr/apr-util/trunk/test/testxlate.c
Url: http://svn.apache.org/viewcvs/apr/apr-util/trunk/test/testxlate.c?view=diff&rev=106176&p1=apr/apr-util/trunk/test/testxlate.c&r1=106175&p2=apr/apr-util/trunk/test/testxlate.c&r2=106176
==============================================================================
--- apr/apr-util/trunk/test/testxlate.c	(original)
+++ apr/apr-util/trunk/test/testxlate.c	Mon Nov 22 03:44:24 2004
@@ -53,6 +53,11 @@
                                                 &inbytes_left,
                                                 buf,
                                                 &outbytes_left);
+    if (status == APR_SUCCESS) {
+        status = apr_xlate_conv_buffer(convset, NULL, NULL,
+                                       buf + sizeof(buf) - outbytes_left - 1,
+                                       &outbytes_left);
+    }
     buf[sizeof(buf) - outbytes_left - 1] = '\0';
     retcode |= check_status(status, "apr_xlate_conv_buffer");
     if ((!status || APR_STATUS_IS_INCOMPLETE(status))

Modified: apr/apr-util/trunk/xlate/xlate.c
Url: http://svn.apache.org/viewcvs/apr/apr-util/trunk/xlate/xlate.c?view=diff&rev=106176&p1=apr/apr-util/trunk/xlate/xlate.c&r1=106175&p2=apr/apr-util/trunk/xlate/xlate.c&r2=106176
==============================================================================
--- apr/apr-util/trunk/xlate/xlate.c	(original)
+++ apr/apr-util/trunk/xlate/xlate.c	Mon Nov 22 03:44:24 2004
@@ -385,7 +385,7 @@
     else
 #endif
 
-    {
+    if (inbuf) {
         int to_convert = min(*inbytes_left, *outbytes_left);
         int converted = to_convert;
         char *table = convset->sbcs_table;

Mime
View raw message