summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doio.c69
-rw-r--r--ext/File/Glob/bsd_glob.c4
-rw-r--r--pod/perltodo.pod4
-rw-r--r--pp_ctl.c8
-rw-r--r--util.c8
5 files changed, 20 insertions, 73 deletions
diff --git a/doio.c b/doio.c
index 8a04766f09..1fcb165065 100644
--- a/doio.c
+++ b/doio.c
@@ -258,17 +258,10 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw,
}
mode[0] = 'w';
writing = 1;
-#ifdef HAS_STRLCAT
if (out_raw)
- strlcat(mode, "b", PERL_MODE_MAX - 1);
+ my_strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (out_crlf)
- strlcat(mode, "t", PERL_MODE_MAX - 1);
-#else
- if (out_raw)
- strcat(mode, "b");
- else if (out_crlf)
- strcat(mode, "t");
-#endif
+ my_strlcat(mode, "t", PERL_MODE_MAX - 1);
if (num_svs > 1) {
fp = PerlProc_popen_list(mode, num_svs, svp);
}
@@ -296,17 +289,10 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw,
}
writing = 1;
-#ifdef HAS_STRLCAT
if (out_raw)
- strlcat(mode, "b", PERL_MODE_MAX - 1);
+ my_strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (out_crlf)
- strlcat(mode, "t", PERL_MODE_MAX - 1);
-#else
- if (out_raw)
- strcat(mode, "b");
- else if (out_crlf)
- strcat(mode, "t");
-#endif
+ my_strlcat(mode, "t", PERL_MODE_MAX - 1);
if (*type == '&') {
duplicity:
dodup = PERLIO_DUP_FD;
@@ -429,17 +415,10 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw,
type++;
} while (isSPACE(*type));
mode[0] = 'r';
-#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX - 1);
+ my_strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX - 1);
-#else
- if (in_raw)
- strcat(mode, "b");
- else if (in_crlf)
- strcat(mode, "t");
-#endif
+ my_strlcat(mode, "t", PERL_MODE_MAX - 1);
if (*type == '&') {
goto duplicity;
}
@@ -490,17 +469,10 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw,
TAINT_PROPER("piped open");
mode[0] = 'r';
-#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX - 1);
+ my_strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX - 1);
-#else
- if (in_raw)
- strcat(mode, "b");
- else if (in_crlf)
- strcat(mode, "t");
-#endif
+ my_strlcat(mode, "t", PERL_MODE_MAX - 1);
if (num_svs > 1) {
fp = PerlProc_popen_list(mode,num_svs,svp);
@@ -528,17 +500,10 @@ Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw,
;
mode[0] = 'r';
-#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX - 1);
+ my_strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX - 1);
-#else
- if (in_raw)
- strcat(mode, "b");
- else if (in_crlf)
- strcat(mode, "t");
-#endif
+ my_strlcat(mode, "t", PERL_MODE_MAX - 1);
if (*name == '-' && name[1] == '\0') {
fp = PerlIO_stdin();
@@ -1493,19 +1458,11 @@ Perl_do_exec3(pTHX_ const char *incmd, int fd, int do_report)
char flags[PERL_FLAGS_MAX];
if (strnEQ(cmd,PL_cshname,PL_cshlen) &&
strnEQ(cmd+PL_cshlen," -c",3)) {
-#ifdef HAS_STRLCPY
- strlcpy(flags, "-c", PERL_FLAGS_MAX);
-#else
- strcpy(flags,"-c");
-#endif
+ my_strlcpy(flags, "-c", PERL_FLAGS_MAX);
s = cmd+PL_cshlen+3;
if (*s == 'f') {
s++;
-#ifdef HAS_STRLCPY
- strlcat(flags, "f", PERL_FLAGS_MAX - 2);
-#else
- strcat(flags,"f");
-#endif
+ my_strlcat(flags, "f", PERL_FLAGS_MAX - 2);
}
if (*s == ' ')
s++;
@@ -2317,7 +2274,7 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp)
STRLEN len;
const char *mbuf = SvPV_const(mstr, len);
- const I32 n = ((I32)len > msize) ? msize : (I32)len;
+ const I32 n = (len > msize) ? msize : len;
Copy(mbuf, shm + mpos, n, char);
if (n < msize)
memzero(shm + mpos + n, msize - n);
diff --git a/ext/File/Glob/bsd_glob.c b/ext/File/Glob/bsd_glob.c
index 78a8c647ec..c1dbd2c093 100644
--- a/ext/File/Glob/bsd_glob.c
+++ b/ext/File/Glob/bsd_glob.c
@@ -1131,9 +1131,9 @@ g_opendir(register Char *str, glob_t *pglob)
if (!*str) {
#ifdef MACOS_TRADITIONAL
- strcpy(buf, ":");
+ my_strlcpy(buf, ":", sizeof(buf));
#else
- strcpy(buf, ".");
+ my_strlcpy(buf, ".", sizeof(buf));
#endif
} else {
if (g_Ctoc(str, buf, sizeof(buf)))
diff --git a/pod/perltodo.pod b/pod/perltodo.pod
index bade067a1c..9ffb62880d 100644
--- a/pod/perltodo.pod
+++ b/pod/perltodo.pod
@@ -622,7 +622,9 @@ source filters. All this could be fixed.
=head2 Integrate Russ Allbery's strlcat/strlcpy implementation
-And remove the last remaining uses of strcat() and strcpy().
+And remove the last remaining uses of strcat() and strcpy(). Also, add
+my_strlcat() and my_strlcpy() to Devel::PPPort so previous versions of Perl can
+use these APIs.
=head1 Big projects
diff --git a/pp_ctl.c b/pp_ctl.c
index 929f5a27e2..1f9fa4a4b8 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3423,9 +3423,7 @@ PP(pp_entereval)
U32 seq;
HV *saved_hh = NULL;
const char * const fakestr = "_<(eval )";
-#ifdef HAS_STRLCPY
const int fakelen = 9 + 1;
-#endif
if (PL_op->op_private & OPpEVAL_HAS_HH) {
saved_hh = (HV*) SvREFCNT_inc(POPs);
@@ -3498,11 +3496,7 @@ PP(pp_entereval)
if (PERLDB_INTER && was != (I32)PL_sub_generation /* Some subs defined here. */
&& ret != PL_op->op_next) { /* Successive compilation. */
/* Copy in anything fake and short. */
-#ifdef HAS_STRLCPY
- strlcpy(safestr, fakestr, fakelen);
-#else
- strcpy(safestr, fakestr);
-#endif /* #ifdef HAS_STRLCPY */
+ my_strlcpy(safestr, fakestr, fakelen);
}
return DOCATCH(ret);
}
diff --git a/util.c b/util.c
index 6e291d310f..7a3be16a09 100644
--- a/util.c
+++ b/util.c
@@ -3118,13 +3118,7 @@ Perl_find_script(pTHX_ const char *scriptname, bool dosearch,
if (len == 2 && tmpbuf[0] == '.')
seen_dot = 1;
#endif
-#ifdef HAS_STRLCAT
- (void)strlcpy(tmpbuf + len, scriptname, sizeof(tmpbuf) - len);
-#else
- /* FIXME? Convert to memcpy by storing previous strlen(scriptname)
- */
- (void)strcpy(tmpbuf + len, scriptname);
-#endif /* #ifdef HAS_STRLCAT */
+ (void)my_strlcpy(tmpbuf + len, scriptname, sizeof(tmpbuf) - len);
#endif /* !VMS */
#ifdef SEARCH_EXTS