michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "plstr.h" michael@0: #include michael@0: michael@0: PR_IMPLEMENT(char *) michael@0: PL_strcpy(char *dest, const char *src) michael@0: { michael@0: if( ((char *)0 == dest) || ((const char *)0 == src) ) return (char *)0; michael@0: michael@0: return strcpy(dest, src); michael@0: } michael@0: michael@0: PR_IMPLEMENT(char *) michael@0: PL_strncpy(char *dest, const char *src, PRUint32 max) michael@0: { michael@0: char *rv; michael@0: michael@0: if( (char *)0 == dest ) return (char *)0; michael@0: if( (const char *)0 == src ) return (char *)0; michael@0: michael@0: for( rv = dest; max && ((*dest = *src) != 0); dest++, src++, max-- ) michael@0: ; michael@0: michael@0: #ifdef JLRU michael@0: /* XXX I (wtc) think the -- and ++ operators should be postfix. */ michael@0: while( --max ) michael@0: *++dest = '\0'; michael@0: #endif /* JLRU */ michael@0: michael@0: return rv; michael@0: } michael@0: michael@0: PR_IMPLEMENT(char *) michael@0: PL_strncpyz(char *dest, const char *src, PRUint32 max) michael@0: { michael@0: char *rv; michael@0: michael@0: if( (char *)0 == dest ) return (char *)0; michael@0: if( (const char *)0 == src ) return (char *)0; michael@0: if( 0 == max ) return (char *)0; michael@0: michael@0: for( rv = dest, max--; max && ((*dest = *src) != 0); dest++, src++, max-- ) michael@0: ; michael@0: michael@0: *dest = '\0'; michael@0: michael@0: return rv; michael@0: }