SRB2/src/string.c

56 lines
1.2 KiB
C
Raw Normal View History

2014-03-15 16:59:03 +00:00
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2006 by Graue.
2018-11-25 12:35:38 +00:00
// Copyright (C) 2006-2018 by Sonic Team Junior.
2019-04-22 06:18:40 +00:00
// Copyright (C) 2019 by James R.
2014-03-15 16:59:03 +00:00
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file string.c
/// \brief String functions that we need but are missing on some
/// operating systems.
#include <stddef.h>
#include <string.h>
#include "doomdef.h"
2016-03-26 00:37:14 +00:00
#if !defined (__APPLE__)
2014-03-15 16:59:03 +00:00
// Like the OpenBSD version, but it doesn't check for src not being a valid
// C string.
size_t strlcat(char *dst, const char *src, size_t siz)
{
size_t dstlen, n = siz;
char *p = dst;
dstlen = strlen(dst);
n -= dstlen;
p += dstlen;
while (n > 1 && *src != '\0')
{
*p++ = *src++;
n--;
}
if (n >= 1)
*p = '\0';
return strlen(src) + dstlen;
}
size_t strlcpy(char *dst, const char *src, size_t siz)
{
if (siz == 0)
return strlen(dst);
dst[0] = '\0';
return strlcat(dst, src, siz);
}
2016-03-26 00:37:14 +00:00
#endif
2019-04-22 06:18:40 +00:00
#include "strcasestr.c"