Port lstring and sclist to C++.

This commit is contained in:
David Anderson 2014-08-21 23:58:19 -07:00
parent 2ba4fb180e
commit 3e8157c6bc
4 changed files with 16 additions and 7 deletions

View File

@ -79,7 +79,7 @@ elif builder.target_platform == 'mac':
binary.sources += [
'libpawnc.cpp',
'lstring.c',
'lstring.cpp',
'memfile.cpp',
'pawncc.cpp',
'sc1.c',
@ -91,7 +91,7 @@ binary.sources += [
'sc7.c',
'scexpand.c',
'sci18n.c',
'sclist.c',
'sclist.cpp',
'scmemfil.cpp',
'scstate.cpp',
'sctracker.c',

View File

@ -37,7 +37,7 @@
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
size_t
extern "C" size_t
strlcpy(char *dst, const char *src, size_t siz)
{
char *d = dst;
@ -93,7 +93,7 @@ strlcpy(char *dst, const char *src, size_t siz)
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
* If retval >= siz, truncation occurred.
*/
size_t
extern "C" size_t
strlcat(char *dst, const char *src, size_t siz)
{
char *d = dst;

View File

@ -9,10 +9,18 @@
#if !defined HAVE_SAFESTR
size_t
#if defined(__cplusplus)
# define EXPORT extern "C"
#else
# define EXPORT
#endif
EXPORT size_t
strlcpy(char *dst, const char *src, size_t siz);
size_t
EXPORT size_t
strlcat(char *dst, const char *src, size_t siz);
#undef EXPORT
#endif

View File

@ -319,12 +319,13 @@ SC_FUNC stringpair *find_subst(char *name,int length)
if (item && (item->flags & flgDEPRECATED) != 0)
{
static char macro[128];
char *rem, *msg = (item->documentation != NULL) ? item->documentation : "";
const char *msg = (item->documentation != NULL) ? item->documentation : "";
strlcpy(macro, item->first, sizeof(macro));
/* If macro contains an opening parentheses and a percent sign, then assume that
* it takes arguments and remove them from the warning message.
*/
char *rem;
if ((rem = strchr(macro, '(')) != NULL && strchr(macro, '%') > rem)
{
*rem = '\0';