Change 28525 by [EMAIL PROTECTED] on 2006/07/10 11:28:24
Add Russ Allbery's public domain implementations of strlcat and
strlcpy as Perl_my_strlcat and Perl_my_strlcpy to the Perl core.
Thanks Russ!
Affected files ...
... //depot/perl/embed.fnc#398 edit
... //depot/perl/embed.h#616 edit
... //depot/perl/global.sym#308 edit
... //depot/perl/perl.h#706 edit
... //depot/perl/proto.h#739 edit
... //depot/perl/util.c#571 edit
Differences ...
==== //depot/perl/embed.fnc#398 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#397~28490~ 2006-07-06 02:01:16.000000000 -0700
+++ perl/embed.fnc 2006-07-10 04:28:24.000000000 -0700
@@ -1718,6 +1718,14 @@
Apo |void* |my_cxt_init |NN int *index|size_t size
#endif
+#ifndef HAS_STRLCAT
+Apno |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
+#endif
+
#ifdef PERL_MAD
Mnp |void |pad_peg |NN const char* s
#if defined(PERL_IN_DUMP_C) || defined(PERL_DECL_PROT)
==== //depot/perl/embed.h#616 (text+w) ====
Index: perl/embed.h
--- perl/embed.h#615~28490~ 2006-07-06 02:01:16.000000000 -0700
+++ perl/embed.h 2006-07-10 04:28:24.000000000 -0700
@@ -1773,6 +1773,10 @@
#endif
#ifdef PERL_IMPLICIT_CONTEXT
#endif
+#ifndef HAS_STRLCAT
+#endif
+#ifndef HAS_STRLCPY
+#endif
#ifdef PERL_MAD
#ifdef PERL_CORE
#define pad_peg Perl_pad_peg
@@ -3966,6 +3970,10 @@
#endif
#ifdef PERL_IMPLICIT_CONTEXT
#endif
+#ifndef HAS_STRLCAT
+#endif
+#ifndef HAS_STRLCPY
+#endif
#ifdef PERL_MAD
#ifdef PERL_CORE
#define pad_peg Perl_pad_peg
==== //depot/perl/global.sym#308 (text+w) ====
Index: perl/global.sym
--- perl/global.sym#307~28490~ 2006-07-06 02:01:16.000000000 -0700
+++ perl/global.sym 2006-07-10 04:28:24.000000000 -0700
@@ -721,4 +721,6 @@
Perl_my_snprintf
Perl_my_vsnprintf
Perl_my_cxt_init
+Perl_my_strlcat
+Perl_my_strlcpy
# ex: set ro:
==== //depot/perl/perl.h#706 (text) ====
Index: perl/perl.h
--- perl/perl.h#705~28490~ 2006-07-06 02:01:16.000000000 -0700
+++ perl/perl.h 2006-07-10 04:28:24.000000000 -0700
@@ -1488,6 +1488,18 @@
# define PERL_MY_VSNPRINTF_GUARDED
#endif
+#ifdef HAS_STRLCAT
+# define my_strlcat strlcat
+#else
+# define my_strlcat Perl_my_strlcat
+#endif
+
+#ifdef HAS_STRLCPY
+# define my_strlcpy strlcpy
+#else
+# define my_strlcpy Perl_my_strlcpy
+#endif
+
/* Configure gets this right but the UTS compiler gets it wrong.
-- Hal Morris <[EMAIL PROTECTED]> */
#ifdef UTS
==== //depot/perl/proto.h#739 (text+w) ====
Index: perl/proto.h
--- perl/proto.h#738~28490~ 2006-07-06 02:01:16.000000000 -0700
+++ perl/proto.h 2006-07-10 04:28:24.000000000 -0700
@@ -4407,6 +4407,14 @@
#endif
+#ifndef HAS_STRLCAT
+PERL_CALLCONV Size_t Perl_my_strlcat(char *dst, const char *src, Size_t
size);
+#endif
+
+#ifndef HAS_STRLCPY
+PERL_CALLCONV Size_t Perl_my_strlcpy(char *dst, const char *src, Size_t
size);
+#endif
+
#ifdef PERL_MAD
PERL_CALLCONV void Perl_pad_peg(const char* s)
__attribute__nonnull__(1);
==== //depot/perl/util.c#571 (text) ====
Index: perl/util.c
--- perl/util.c#570~28459~ 2006-06-30 06:28:46.000000000 -0700
+++ perl/util.c 2006-07-10 04:28:24.000000000 -0700
@@ -5530,6 +5530,39 @@
}
#endif
+#ifndef HAS_STRLCAT
+Size_t
+Perl_my_strlcat(char *dst, const char *src, Size_t size)
+{
+ Size_t used, length, copy;
+
+ used = strlen(dst);
+ length = strlen(src);
+ if (size > 0 && used < size - 1) {
+ copy = (length >= size - used) ? size - used - 1 : length;
+ memcpy(dst + used, src, copy);
+ dst[used + copy] = '\0';
+ }
+ return used + length;
+}
+#endif
+
+#ifndef HAS_STRLCPY
+Size_t
+Perl_my_strlcpy(char *dst, const char *src, Size_t size)
+{
+ Size_t length, copy;
+
+ length = strlen(src);
+ if (size > 0) {
+ copy = (length >= size) ? size - 1 : length;
+ memcpy(dst, src, copy);
+ dst[copy] = '\0';
+ }
+ return length;
+}
+#endif
+
/*
* Local variables:
* c-indentation-style: bsd
End of Patch.