aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library.js16
-rw-r--r--system/lib/libc/musl/src/string/strncat.c10
-rw-r--r--system/lib/libcextra.symbols1
-rw-r--r--tools/system_libs.py1
4 files changed, 12 insertions, 16 deletions
diff --git a/src/library.js b/src/library.js
index 225ca1b3..9114a539 100644
--- a/src/library.js
+++ b/src/library.js
@@ -3639,22 +3639,6 @@ LibraryManager.library = {
return pdest|0;
},
- strncat__deps: ['strlen'],
- strncat: function(pdest, psrc, num) {
- var len = _strlen(pdest);
- var i = 0;
- while(1) {
- {{{ makeCopyValues('pdest+len+i', 'psrc+i', 1, 'i8', null, 1) }}};
- if ({{{ makeGetValue('pdest', 'len+i', 'i8') }}} == 0) break;
- i ++;
- if (i == num) {
- {{{ makeSetValue('pdest', 'len+i', 0, 'i8') }}};
- break;
- }
- }
- return pdest;
- },
-
memchr: function(ptr, chr, num) {
chr = unSign(chr);
for (var i = 0; i < num; i++) {
diff --git a/system/lib/libc/musl/src/string/strncat.c b/system/lib/libc/musl/src/string/strncat.c
new file mode 100644
index 00000000..01ca2a23
--- /dev/null
+++ b/system/lib/libc/musl/src/string/strncat.c
@@ -0,0 +1,10 @@
+#include <string.h>
+
+char *strncat(char *restrict d, const char *restrict s, size_t n)
+{
+ char *a = d;
+ d += strlen(d);
+ while (n && *s) n--, *d++ = *s++;
+ *d++ = 0;
+ return a;
+}
diff --git a/system/lib/libcextra.symbols b/system/lib/libcextra.symbols
index fc3eaf99..30a39d52 100644
--- a/system/lib/libcextra.symbols
+++ b/system/lib/libcextra.symbols
@@ -118,6 +118,7 @@
T strlcat
T strlcpy
T strncasecmp_l
+ T strncat
T strsep
T strspn
T strverscmp
diff --git a/tools/system_libs.py b/tools/system_libs.py
index c02583c8..6814e806 100644
--- a/tools/system_libs.py
+++ b/tools/system_libs.py
@@ -246,6 +246,7 @@ def calculate(temp_files, in_temp, stdout, stderr):
'strcspn.c',
'strlcat.c',
'strlcpy.c',
+ 'strncat.c',
'strsep.c',
'strspn.c',
'strverscmp.c',