tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

strcat.c (1088B)


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