perlapi: Add doc for my_strlcpy, my_strlcat
authorKarl Williamson <public@khwilliamson.com>
Wed, 11 Sep 2013 03:28:31 +0000 (21:28 -0600)
committerKarl Williamson <public@khwilliamson.com>
Wed, 11 Sep 2013 03:33:51 +0000 (21:33 -0600)
embed.fnc
util.c

index 6ad48d3..aff36ef 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -2549,11 +2549,11 @@ Xpo     |void   |xs_apiversion_bootcheck|NN SV *module|NN const char *api_p \
                                |STRLEN api_len
 
 #ifndef HAS_STRLCAT
-Apno   |Size_t |my_strlcat     |NULLOK char *dst|NULLOK const char *src|Size_t size
+Apnod  |Size_t |my_strlcat     |NULLOK char *dst|NULLOK const char *src|Size_t size
 #endif
 
 #ifndef HAS_STRLCPY
-Apno     |Size_t |my_strlcpy     |NULLOK char *dst|NULLOK const char *src|Size_t size
+Apnod     |Size_t |my_strlcpy     |NULLOK char *dst|NULLOK const char *src|Size_t size
 #endif
 
 #ifdef PERL_MAD
diff --git a/util.c b/util.c
index d2380b2..55f6d9e 100644 (file)
--- a/util.c
+++ b/util.c
@@ -6033,6 +6033,26 @@ Perl_xs_apiversion_bootcheck(pTHX_ SV *module, const char *api_p,
        Perl_croak_sv(aTHX_ xpt);
 }
 
+/*
+=for apidoc my_strlcat
+
+The C library C<strlcat> if available, or a Perl implementation of it.
+This operates on C NUL-terminated strings.
+
+C<my_strlcat()> appends string C<src> to the end of C<dst>.  It will append at
+most S<C<size - strlen(dst) - 1>> characters.  It will then NUL-terminate,
+unless C<size> is 0 or the original C<dst> string was longer than C<size> (in
+practice this should not happen as it means that either C<size> is incorrect or
+that C<dst> is not a proper NUL-terminated string).
+
+Note that C<size> is the full size of the destination buffer and
+the result is guaranteed to be NUL-terminated if there is room.  Note that room
+for the NUL should be included in C<size>.
+
+=cut
+
+Description stolen from http://www.openbsd.org/cgi-bin/man.cgi?query=strlcat
+*/
 #ifndef HAS_STRLCAT
 Size_t
 Perl_my_strlcat(char *dst, const char *src, Size_t size)
@@ -6050,6 +6070,20 @@ Perl_my_strlcat(char *dst, const char *src, Size_t size)
 }
 #endif
 
+
+/*
+=for apidoc my_strlcpy
+
+The C library C<strlcpy> if available, or a Perl implementation of it.
+This operates on C NUL-terminated strings.
+
+C<my_strlcpy()> copies up to S<C<size - 1>> characters from the string C<src>
+to C<dst>, NUL-terminating the result if C<size> is not 0.
+
+=cut
+
+Description stolen from http://www.openbsd.org/cgi-bin/man.cgi?query=strlcpy
+*/
 #ifndef HAS_STRLCPY
 Size_t
 Perl_my_strlcpy(char *dst, const char *src, Size_t size)