Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "plstr.h" |
michael@0 | 7 | #include <string.h> |
michael@0 | 8 | |
michael@0 | 9 | PR_IMPLEMENT(char *) |
michael@0 | 10 | PL_strcat(char *dest, const char *src) |
michael@0 | 11 | { |
michael@0 | 12 | if( ((char *)0 == dest) || ((const char *)0 == src) ) |
michael@0 | 13 | return dest; |
michael@0 | 14 | |
michael@0 | 15 | return strcat(dest, src); |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | PR_IMPLEMENT(char *) |
michael@0 | 19 | PL_strncat(char *dest, const char *src, PRUint32 max) |
michael@0 | 20 | { |
michael@0 | 21 | char *rv; |
michael@0 | 22 | |
michael@0 | 23 | if( ((char *)0 == dest) || ((const char *)0 == src) || (0 == max) ) |
michael@0 | 24 | return dest; |
michael@0 | 25 | |
michael@0 | 26 | for( rv = dest; *dest; dest++ ) |
michael@0 | 27 | ; |
michael@0 | 28 | |
michael@0 | 29 | (void)PL_strncpy(dest, src, max); |
michael@0 | 30 | return rv; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | PR_IMPLEMENT(char *) |
michael@0 | 34 | PL_strcatn(char *dest, PRUint32 max, const char *src) |
michael@0 | 35 | { |
michael@0 | 36 | char *rv; |
michael@0 | 37 | PRUint32 dl; |
michael@0 | 38 | |
michael@0 | 39 | if( ((char *)0 == dest) || ((const char *)0 == src) ) |
michael@0 | 40 | return dest; |
michael@0 | 41 | |
michael@0 | 42 | for( rv = dest, dl = 0; *dest; dest++, dl++ ) |
michael@0 | 43 | ; |
michael@0 | 44 | |
michael@0 | 45 | if( max <= dl ) return rv; |
michael@0 | 46 | (void)PL_strncpyz(dest, src, max-dl); |
michael@0 | 47 | |
michael@0 | 48 | return rv; |
michael@0 | 49 | } |