On Monday 23 May 2005 22:57, Stas Bekman wrote:
> if it works for you, i'll commit it.

The attachment contains a complete patch including the test.

All tests successful, 1 test skipped.
Files=229, Tests=2475, 81 wallclock secs (62.48 cusr +  6.47 csys = 68.95 CPU)

Torsten
diff -Naur mod_perl-2.0.0/t/lib/TestAPRlib/base64.pm mod_perl-2.0.0.new/t/lib/TestAPRlib/base64.pm
--- mod_perl-2.0.0/t/lib/TestAPRlib/base64.pm	2005-04-26 20:58:42.000000000 +0200
+++ mod_perl-2.0.0.new/t/lib/TestAPRlib/base64.pm	2005-05-24 09:05:31.176231063 +0200
@@ -20,7 +20,7 @@
     my $encoded = APR::Base64::encode($str);
 
     t_debug("encoded string: $encoded");
-    ok $encoded;
+    ok t_cmp($encoded, 'MTIzNDVxd2VydCFAIyQl', 'encode');
 
     ok t_cmp(APR::Base64::encode_len(length $str),
              length $encoded,
diff -Naur mod_perl-2.0.0/xs/APR/Base64/APR__Base64.h mod_perl-2.0.0.new/xs/APR/Base64/APR__Base64.h
--- mod_perl-2.0.0/xs/APR/Base64/APR__Base64.h	2005-04-26 20:58:34.000000000 +0200
+++ mod_perl-2.0.0.new/xs/APR/Base64/APR__Base64.h	2005-05-24 09:03:30.697580724 +0200
@@ -13,14 +13,18 @@
  * limitations under the License.
  */
 
+/* apr_base64_encode_len and apr_base64_encode_binary give length that
+ * includes the terminating '\0' */
+#define mpxs_APR__Base64_encode_len(len) apr_base64_encode_len(len) - 1;
+
 static MP_INLINE void mpxs_apr_base64_encode(pTHX_ SV *sv, SV *arg)
 {
     STRLEN len;
     int encoded_len;
     char *data = SvPV(arg, len);
-    mpxs_sv_grow(sv, apr_base64_encode_len(len));
+    mpxs_sv_grow(sv, apr_base64_encode_len(len) - 1);
     encoded_len = apr_base64_encode_binary(SvPVX(sv), data, len);
-    mpxs_sv_cur_set(sv, encoded_len);
+    mpxs_sv_cur_set(sv, encoded_len - 1);
 }
 
 static MP_INLINE void mpxs_apr_base64_decode(pTHX_ SV *sv, SV *arg)
diff -Naur mod_perl-2.0.0/xs/maps/apr_functions.map mod_perl-2.0.0.new/xs/maps/apr_functions.map
--- mod_perl-2.0.0/xs/maps/apr_functions.map	2005-05-12 13:46:50.000000000 +0200
+++ mod_perl-2.0.0.new/xs/maps/apr_functions.map	2005-05-24 09:03:12.383066190 +0200
@@ -579,7 +579,7 @@
 MODULE=APR::Base64
  apr_base64_decode | MPXS_ | coded_src
  apr_base64_encode | MPXS_ | plain_src
- apr_base64_encode_len
+ int:DEFINE_encode_len | | int:len
 -apr_base64_decode_len
 -apr_base64_encode_binary
 -apr_base64_decode_binary

Attachment: pgpBsiM5YJQdF.pgp
Description: PGP signature

Reply via email to