summaryrefslogtreecommitdiff
path: root/src/strfuncs.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2010-01-06 16:32:59 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2010-01-06 16:32:59 +0000
commitf3a77d3c00c095a53f37aa7efb39d56168799596 (patch)
tree0bd2269afe0edd5018c5d231c95a5011002c83cf /src/strfuncs.c
parent628079a91ca6d86a7915906d266e6fe5593bb846 (diff)
downloadlibrufl-f3a77d3c00c095a53f37aa7efb39d56168799596.tar.gz
librufl-f3a77d3c00c095a53f37aa7efb39d56168799596.tar.bz2
Port to core buildsystem.
The python module (and associated make runes) need some love (as does non-GCC building with the core buildsystem in general) svn path=/trunk/rufl/; revision=9792
Diffstat (limited to 'src/strfuncs.c')
-rw-r--r--src/strfuncs.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/strfuncs.c b/src/strfuncs.c
new file mode 100644
index 0000000..08b43b2
--- /dev/null
+++ b/src/strfuncs.c
@@ -0,0 +1,37 @@
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "strfuncs.h"
+
+char *strdup(const char *s)
+{
+ size_t len = strlen(s);
+ char *new = malloc(len + 1);
+ if (!new)
+ return 0;
+ memcpy(new, s, len);
+ new[len] = '\0';
+ return new;
+}
+
+char *strndup(const char *s, size_t n)
+{
+ size_t len = strlen(s);
+ if (n < len)
+ len = n;
+ char *new = malloc(len + 1);
+ if (!new)
+ return 0;
+ memcpy(new, s, len);
+ new[len] = '\0';
+ return new;
+}
+
+int strcasecmp(const char *s1, const char *s2)
+{
+ int i;
+ while ((i = tolower(*s1)) && i == tolower(*s2))
+ s1++, s2++;
+ return ((unsigned char) tolower(*s1) - (unsigned char) tolower(*s2));
+}