summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwchang0222%aol.com <devnull@localhost>2004-04-24 17:55:27 +0000
committerwchang0222%aol.com <devnull@localhost>2004-04-24 17:55:27 +0000
commitbf42e6db249694cb52c911d7de024bbb7aa27f7a (patch)
tree8f68c8f8aa3ff74fbf5773e865f83ce49faacee5
parent435746c70e4072c8fd84c8305286e0b157f31165 (diff)
downloadnspr-hg-bf42e6db249694cb52c911d7de024bbb7aa27f7a.tar.gz
Bugzilla bug 209499: backed out the change to strncpy in the previous
checkin because I noticed a subtle difference between PL_strncpy and strncpy (the code marked with JLRU). Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rw-r--r--lib/libc/src/strcpy.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/libc/src/strcpy.c b/lib/libc/src/strcpy.c
index e7d695be..f81a5cc8 100644
--- a/lib/libc/src/strcpy.c
+++ b/lib/libc/src/strcpy.c
@@ -46,9 +46,20 @@ PL_strcpy(char *dest, const char *src)
PR_IMPLEMENT(char *)
PL_strncpy(char *dest, const char *src, PRUint32 max)
{
- if( ((char *)0 == dest) || ((const char *)0 == src) ) return (char *)0;
+ char *rv;
+
+ if( (char *)0 == dest ) return (char *)0;
+ if( (const char *)0 == src ) return (char *)0;
- return strncpy(dest, src, (size_t)max);
+ for( rv = dest; max && ((*dest = *src) != 0); dest++, src++, max-- )
+ ;
+
+#ifdef JLRU
+ while( --max )
+ *++dest = '\0';
+#endif /* JLRU */
+
+ return rv;
}
PR_IMPLEMENT(char *)