[syslinux:pathbased] Add simplified toupper, tolower, str[n]casecmp to core

syslinux-bot for H. Peter Anvin hpa at zytor.com
Mon Mar 1 08:57:22 PST 2010


Commit-ID:  f6bd4f6d06b23470c4397c8950177b0810a531dd
Gitweb:     http://syslinux.zytor.com/commit/f6bd4f6d06b23470c4397c8950177b0810a531dd
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Mon, 1 Mar 2010 08:54:36 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 1 Mar 2010 08:54:36 -0800

Add simplified toupper, tolower, str[n]casecmp to core

(Missing from previous checkin)

Add simplified toupper(), tolower() and str[n]casecmp()
implementations to the core, good enough for ASCII e.g. for use in URL
parsing, or in config file decoding.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 core/include/ctype.h              |   25 +++++++++++++++++++++++++
 core/strcasecmp.c                 |   11 +++++++++++
 {com32/lib => core}/strncasecmp.c |    0
 3 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/core/include/ctype.h b/core/include/ctype.h
new file mode 100644
index 0000000..5c6d4cb
--- /dev/null
+++ b/core/include/ctype.h
@@ -0,0 +1,25 @@
+#ifndef CTYPE_H
+#define CTYPE_H
+
+/*
+ * Small subset of <ctype.h> for parsing uses, only handles ASCII
+ * and passes the rest through.
+ */
+
+static inline int toupper(int c)
+{
+    if (c >= 'a' && c <= 'z')
+	c -= 0x20;
+
+    return c;
+}
+
+static inline int tolower(int c)
+{
+    if (c >= 'A' && c <= 'Z')
+	c += 0x20;
+
+    return c;
+}
+
+#endif /* CTYPE_H */
diff --git a/core/strcasecmp.c b/core/strcasecmp.c
new file mode 100644
index 0000000..2f7480d
--- /dev/null
+++ b/core/strcasecmp.c
@@ -0,0 +1,11 @@
+/*
+ * strcasecmp.c
+ */
+
+#include <string.h>
+#include <ctype.h>
+
+int strcasecmp(const char *s1, const char *s2)
+{
+    return strncasecmp(s1, s2, -1);
+}
diff --git a/com32/lib/strncasecmp.c b/core/strncasecmp.c
similarity index 100%
copy from com32/lib/strncasecmp.c
copy to core/strncasecmp.c



More information about the Syslinux-commits mailing list