summaryrefslogtreecommitdiff
path: root/src/common/strlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/strlib.c')
-rw-r--r--src/common/strlib.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/common/strlib.c b/src/common/strlib.c
index 592390770..8b63b4161 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -18,6 +18,10 @@
#define J_MAX_MALLOC_SIZE 65535
+struct strlib_interface strlib_s;
+struct stringbuf_interface stringbuf_s;
+struct sv_interface sv_s;
+
// escapes a string in-place (' -> \' , \ -> \\ , % -> _)
char* jstrescape (char* pt) {
//copy from here
@@ -58,11 +62,12 @@ char* jstrescapecpy (char* pt, const char* spt)
//a escape character is found, the target's final length increases! [Skotlex]
int i =0, j=0;
- if (!spt) { //Return an empty string [Skotlex]
+ if (!spt) {
+ //Return an empty string [Skotlex]
pt[0] = '\0';
return &pt[0];
}
-
+
while (spt[i] != '\0') {
switch (spt[i]) {
case '\'':
@@ -248,7 +253,8 @@ char* strtok_r_(char *s1, const char *s2, char **lasts) {
// for NetBSD 5.x and possibly some Solaris versions.
#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN)
/* Find the length of STRING, but scan at most MAXLEN characters.
- If no '\0' terminator is found in that many characters, return MAXLEN. */
+ * If no '\0' terminator is found in that many characters, return MAXLEN.
+ */
size_t strnlen(const char* string, size_t maxlen) {
const char* end = (const char*)memchr(string, '\0', maxlen);
return end ? (size_t) (end - string) : maxlen;
@@ -1126,18 +1132,19 @@ void strlib_defaults(void) {
sv = &sv_s;
/* link~u! */
strlib->jstrescape = jstrescape;
+ strlib->jstrescapecpy = jstrescapecpy;
strlib->jmemescapecpy = jmemescapecpy;
strlib->remove_control_chars = remove_control_chars;
strlib->trim = trim;
strlib->normalize_name = normalize_name;
strlib->stristr = stristr;
-
+
#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN)
strlib->strnlen = strnlen;
#else
strlib->strnlen = NULL;
#endif
-
+
#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200
strlib->strtoull = strtoull;
#else
@@ -1150,7 +1157,7 @@ void strlib_defaults(void) {
strlib->safesnprintf = safesnprintf;
strlib->strline = strline;
strlib->bin2hex = bin2hex;
-
+
StrBuf->Malloc = StringBuf_Malloc;
StrBuf->Init = StringBuf_Init;
StrBuf->Printf = StringBuf_Printf;
@@ -1162,7 +1169,7 @@ void strlib_defaults(void) {
StrBuf->Clear = StringBuf_Clear;
StrBuf->Destroy = StringBuf_Destroy;
StrBuf->Free = StringBuf_Free;
-
+
sv->parse_next = sv_parse_next;
sv->parse = sv_parse;
sv->split = sv_split;