Apparently Windows doesn't have strndup or index.
This commit is contained in:
parent
b40f4e33fb
commit
92b3dfb42c
|
@ -15,7 +15,7 @@ bool tracing(char k)
|
|||
if (!tracechars)
|
||||
return false;
|
||||
|
||||
return index(tracechars, k);
|
||||
return strchr(tracechars, k);
|
||||
}
|
||||
|
||||
void tracef(char k, const char* fmt, ...)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include "system.h"
|
||||
#include "em_arith.h"
|
||||
#include "em_label.h"
|
||||
#include "em.h"
|
||||
|
|
19
modules/src/system/strndup.c
Normal file
19
modules/src/system/strndup.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "system.h"
|
||||
|
||||
#if defined WIN32
|
||||
/* Really? */
|
||||
char* strndup(const char* s, size_t n)
|
||||
{
|
||||
size_t len = strnlen(s, n);
|
||||
char* ns = malloc(len + 1);
|
||||
if (!ns)
|
||||
return NULL;
|
||||
|
||||
ns[len] = '\0';
|
||||
memcpy(ns, s, len);
|
||||
return ns;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -84,4 +84,9 @@ void sys_basename(const char *str, register char *dst);
|
|||
* the same semantics as ISO C90 tmpnam() */
|
||||
char* sys_tmpnam(char *buffer);
|
||||
|
||||
#if defined WIN32
|
||||
/* Really? */
|
||||
extern char* strndup(const char* s, size_t n);
|
||||
#endif
|
||||
|
||||
#endif /* __SYSTEM_INCLUDED__ */
|
||||
|
|
Loading…
Reference in a new issue