summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d402d55)
raw | patch | inline | side by side (parent: d402d55)
author | Linus Torvalds <torvalds@osdl.org> | |
Thu, 13 Oct 2005 18:03:18 +0000 (11:03 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 15 Oct 2005 00:17:27 +0000 (17:17 -0700) |
Do our own ctype.h, just to get the sane semantics: we want
locale-independence, _and_ we want the right signed behaviour. Plus we
only use a very small subset of ctype.h anyway (isspace, isalpha,
isdigit and isalnum).
Signed-off-by: Junio C Hamano <junkio@cox.net>
locale-independence, _and_ we want the right signed behaviour. Plus we
only use a very small subset of ctype.h anyway (isspace, isalpha,
isdigit and isalnum).
Signed-off-by: Junio C Hamano <junkio@cox.net>
16 files changed:
Makefile | patch | blob | history | |
apply.c | patch | blob | history | |
cache.h | patch | blob | history | |
commit-tree.c | patch | blob | history | |
commit.c | patch | blob | history | |
config.c | patch | blob | history | |
convert-objects.c | patch | blob | history | |
ctype.c | [new file with mode: 0644] | patch | blob |
date.c | patch | blob | history | |
diff-tree.c | patch | blob | history | |
ident.c | patch | blob | history | |
mailsplit.c | patch | blob | history | |
pack-objects.c | patch | blob | history | |
patch-id.c | patch | blob | history | |
refs.c | patch | blob | history | |
update-ref.c | patch | blob | history |
diff --git a/Makefile b/Makefile
index e2e87f6bebda9fb6517bb4af754489c09c0fe283..9fe65ba2be6d920e92ca7a7e08470698f11bf486 100644 (file)
--- a/Makefile
+++ b/Makefile
object.o pack-check.o patch-delta.o path.o pkt-line.o \
quote.o read-cache.o refs.o run-command.o \
server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
- tag.o tree.o usage.o config.o environment.o $(DIFF_OBJS)
+ tag.o tree.o usage.o config.o environment.o ctype.o \
+ $(DIFF_OBJS)
LIBS = $(LIB_FILE)
LIBS += -lz
index 155fbe84da8b6d8dfb231fe508b68a36d52ffc60..f4d00f2835c444aecf1b6c7ca3f97739c1958803 100644 (file)
--- a/apply.c
+++ b/apply.c
* This applies patches on top of some (arbitrary) version of the SCM.
*
*/
-#include <ctype.h>
#include <fnmatch.h>
#include "cache.h"
index 328658235b8bb46132fd1717d9152f5f0cc9668e..f1d15ab3c9f1006f99c9852b2ce1d1209d986064 100644 (file)
--- a/cache.h
+++ b/cache.h
extern char git_default_email[MAX_GITNAME];
extern char git_default_name[MAX_GITNAME];
+/* Sane ctype - no locale, and works with signed chars */
+#undef isspace
+#undef isdigit
+#undef isalpha
+#undef isalnum
+#undef tolower
+#undef toupper
+extern unsigned char sane_ctype[256];
+#define GIT_SPACE 0x01
+#define GIT_DIGIT 0x02
+#define GIT_ALPHA 0x04
+#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
+#define isspace(x) sane_istest(x,GIT_SPACE)
+#define isdigit(x) sane_istest(x,GIT_DIGIT)
+#define isalpha(x) sane_istest(x,GIT_ALPHA)
+#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
+#define tolower(x) sane_case((unsigned char)(x), 0x20)
+#define toupper(x) sane_case((unsigned char)(x), 0)
+
+static inline int sane_case(int x, int high)
+{
+ if (sane_istest(x, GIT_ALPHA))
+ x = (x & ~0x20) | high;
+ return x;
+}
+
#endif /* CACHE_H */
diff --git a/commit-tree.c b/commit-tree.c
index 030fb704e5545fbebc978f919d89caad99b327ee..ea0fdd44e2865e63c6e4750345a30c42e699cf66 100644 (file)
--- a/commit-tree.c
+++ b/commit-tree.c
#include <pwd.h>
#include <time.h>
-#include <ctype.h>
#define BLOCKING (1ul << 14)
diff --git a/commit.c b/commit.c
index f735f981bb2d4d7594e416bcb728ac06d09ebd0c..8f403180e5903bfa3da9df76b2cda213135c58d3 100644 (file)
--- a/commit.c
+++ b/commit.c
-#include <ctype.h>
#include "tag.h"
#include "commit.h"
#include "cache.h"
diff --git a/config.c b/config.c
index 9b7c6f2942483c7791277ad659b5683accafab8d..519fecfee4cd7344b538528f7fa923b7fda280d2 100644 (file)
--- a/config.c
+++ b/config.c
-#include <ctype.h>
#include "cache.h"
diff --git a/convert-objects.c b/convert-objects.c
index 9ad0c77678a740c82c91b4f99de039e12605808d..a892013f0f37480fbf13a9511f2146d1681ba136 100644 (file)
--- a/convert-objects.c
+++ b/convert-objects.c
#define _XOPEN_SOURCE /* glibc2 needs this */
#include <time.h>
-#include <ctype.h>
#include "cache.h"
struct entry {
diff --git a/ctype.c b/ctype.c
--- /dev/null
+++ b/ctype.c
@@ -0,0 +1,23 @@
+/*
+ * Sane locale-independent, ASCII ctype.
+ *
+ * No surprises, and works with signed and unsigned chars.
+ */
+#include "cache.h"
+
+#define SS GIT_SPACE
+#define AA GIT_ALPHA
+#define DD GIT_DIGIT
+
+unsigned char sane_ctype[256] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, SS, SS, 0, 0, SS, 0, 0, /* 0-15 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16-15 */
+ SS, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 32-15 */
+ DD, DD, DD, DD, DD, DD, DD, DD, DD, DD, 0, 0, 0, 0, 0, 0, /* 48-15 */
+ 0, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, /* 64-15 */
+ AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, 0, 0, 0, 0, 0, /* 80-15 */
+ 0, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, /* 96-15 */
+ AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, 0, 0, 0, 0, 0, /* 112-15 */
+ /* Nothing in the 128.. range */
+};
+
index b21cadc4d6811d7b333c90a072d56c077ff21ae7..63f5a0919768112c0d3301e7afaa59edcce7da36 100644 (file)
--- a/date.c
+++ b/date.c
* Copyright (C) Linus Torvalds, 2005
*/
-#include <ctype.h>
#include <time.h>
#include "cache.h"
diff --git a/diff-tree.c b/diff-tree.c
index 2203fa56d0ce7ba46dcf3a35e82d613f111fac6e..851722037df936c2b4e0ab6a9389291e74d5ae60 100644 (file)
--- a/diff-tree.c
+++ b/diff-tree.c
-#include <ctype.h>
#include "cache.h"
#include "diff.h"
#include "commit.h"
index 7a9f5672ebfa0d3fc4ba72b7b90273b11aeebee4..1bfbc6ff350baf61c15debf5bba45c0669ec107d 100644 (file)
--- a/ident.c
+++ b/ident.c
#include <pwd.h>
#include <time.h>
-#include <ctype.h>
static char git_default_date[50];
diff --git a/mailsplit.c b/mailsplit.c
index 0f8100dcca3677260d159bf8d5ae73f1e6bdc5ef..189f4ed724cba345eeb80cd41a9b7ae67068a037 100644 (file)
--- a/mailsplit.c
+++ b/mailsplit.c
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
-#include <ctype.h>
#include <assert.h>
#include "cache.h"
diff --git a/pack-objects.c b/pack-objects.c
index 8a1ee746e083947343087f127f7fa6280a62b77c..b3e61520339231f6d9a43c545100f4d5f87e0aac 100644 (file)
--- a/pack-objects.c
+++ b/pack-objects.c
-#include <ctype.h>
#include "cache.h"
#include "object.h"
#include "delta.h"
diff --git a/patch-id.c b/patch-id.c
index 960e7cedf9d55f8a8fa9dba38a2b69d5f622212d..edbc4aa3e82974168f2d4c21085bdd43b774d55e 100644 (file)
--- a/patch-id.c
+++ b/patch-id.c
-#include <ctype.h>
#include "cache.h"
static void flush_current_id(int patchlen, unsigned char *id, SHA_CTX *c)
index 5a8cbd4ef386da60d3f7a2cac4563fc993e38b94..42240d27690b7a32cb06cd0ea96ce8fb13226459 100644 (file)
--- a/refs.c
+++ b/refs.c
#include "cache.h"
#include <errno.h>
-#include <ctype.h>
/* We allow "recursive" symbolic refs. Only within reason, though */
#define MAXDEPTH 5
diff --git a/update-ref.c b/update-ref.c
index 4a1704c1a538ffde8eed46d4efb253b2d9b31b7f..65dc3d6385756a11aac257a3ed6a9dfcb68cce53 100644 (file)
--- a/update-ref.c
+++ b/update-ref.c
#include "cache.h"
#include "refs.h"
-#include <ctype.h>
static const char git_update_ref_usage[] = "git-update-ref <refname> <value> [<oldval>]";