summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7bd7f28)
raw | patch | inline | side by side (parent: 7bd7f28)
author | Junio C Hamano <junkio@cox.net> | |
Thu, 9 Mar 2006 19:58:05 +0000 (11:58 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 9 Mar 2006 19:58:05 +0000 (11:58 -0800) |
Signed-off-by: Junio C Hamano <junkio@cox.net>
apply.c | patch | blob | history | |
date.c | patch | blob | history | |
exec_cmd.c | patch | blob | history | |
git-compat-util.h | patch | blob | history | |
git.c | patch | blob | history |
index 849a8b4485e65c7eac315daca60b781965a1d22e..179b3bbd00fc6da726491639920ba6540c9b3c71 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -651,7 +651,7 @@ static int parse_git_header(char *line, int len, unsigned int size, struct patch
len = linelen(line, size);
if (!len || line[len-1] != '\n')
break;
- for (i = 0; i < sizeof(optable) / sizeof(optable[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(optable); i++) {
const struct opentry *p = optable + i;
int oplen = strlen(p->str);
if (len < oplen || memcmp(p->str, line, oplen))
index 416ea579a3eb1dbc910817413f995556ad115b29..1c1917b4e8768b0046729e19505d6f1b0845a0d8 100644 (file)
--- a/date.c
+++ b/date.c
{ "IDLE", +12, 0, }, /* International Date Line East */
};
-#define NR_TZ (sizeof(timezone_names) / sizeof(timezone_names[0]))
-
static int match_string(const char *date, const char *str)
{
int i = 0;
}
}
- for (i = 0; i < NR_TZ; i++) {
+ for (i = 0; i < ARRAY_SIZE(timezone_names); i++) {
int match = match_string(date, timezone_names[i].name);
if (match >= 3) {
int off = timezone_names[i].offset;
diff --git a/exec_cmd.c b/exec_cmd.c
index 96cc2123b642173bbf7ff38cbea46695357b2c0b..590e738969ecfdd7ff2f23da36cdac917215313d 100644 (file)
--- a/exec_cmd.c
+++ b/exec_cmd.c
getenv("GIT_EXEC_PATH"),
builtin_exec_path };
- for (i = 0; i < sizeof(paths)/sizeof(paths[0]); ++i) {
+ for (i = 0; i < ARRAY_SIZE(paths); ++i) {
const char *exec_dir = paths[i];
const char *tmp;
diff --git a/git-compat-util.h b/git-compat-util.h
index f982b8e48469a5f09698808d1e55ded04d5923b8..5d543d29f85e432a89bb8cbfbe2d18205599b06f 100644 (file)
--- a/git-compat-util.h
+++ b/git-compat-util.h
#endif
#endif
+#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>