summaryrefslogtreecommitdiff
path: root/builtin/mktag.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/mktag.c')
-rw-r--r--builtin/mktag.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/builtin/mktag.c b/builtin/mktag.c
index d0ccbb2..324a267 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -34,12 +34,6 @@ static int verify_object(const unsigned char *sha1, const char *expected_type)
return ret;
}
-#ifdef NO_C99_FORMAT
-#define PD_FMT "%d"
-#else
-#define PD_FMT "%td"
-#endif
-
static int verify_tag(char *buffer, unsigned long size)
{
int typelen;
@@ -69,15 +63,18 @@ static int verify_tag(char *buffer, unsigned long size)
/* Verify tag-line */
tag_line = strchr(type_line, '\n');
if (!tag_line)
- return error("char" PD_FMT ": could not find next \"\\n\"", type_line - buffer);
+ return error("char%"PRIuMAX": could not find next \"\\n\"",
+ (uintmax_t) (type_line - buffer));
tag_line++;
if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n')
- return error("char" PD_FMT ": no \"tag \" found", tag_line - buffer);
+ return error("char%"PRIuMAX": no \"tag \" found",
+ (uintmax_t) (tag_line - buffer));
/* Get the actual type */
typelen = tag_line - type_line - strlen("type \n");
if (typelen >= sizeof(type))
- return error("char" PD_FMT ": type too long", type_line+5 - buffer);
+ return error("char%"PRIuMAX": type too long",
+ (uintmax_t) (type_line+5 - buffer));
memcpy(type, type_line+5, typelen);
type[typelen] = 0;
@@ -94,15 +91,16 @@ static int verify_tag(char *buffer, unsigned long size)
break;
if (c > ' ')
continue;
- return error("char" PD_FMT ": could not verify tag name", tag_line - buffer);
+ return error("char%"PRIuMAX": could not verify tag name",
+ (uintmax_t) (tag_line - buffer));
}
/* Verify the tagger line */
tagger_line = tag_line;
if (memcmp(tagger_line, "tagger ", 7))
- return error("char" PD_FMT ": could not find \"tagger \"",
- tagger_line - buffer);
+ return error("char%"PRIuMAX": could not find \"tagger \"",
+ (uintmax_t) (tagger_line - buffer));
/*
* Check for correct form for name and email
@@ -114,44 +112,42 @@ static int verify_tag(char *buffer, unsigned long size)
if (!(lb = strstr(tagger_line, " <")) || !(rb = strstr(lb+2, "> ")) ||
strpbrk(tagger_line, "<>\n") != lb+1 ||
strpbrk(lb+2, "><\n ") != rb)
- return error("char" PD_FMT ": malformed tagger field",
- tagger_line - buffer);
+ return error("char%"PRIuMAX": malformed tagger field",
+ (uintmax_t) (tagger_line - buffer));
/* Check for author name, at least one character, space is acceptable */
if (lb == tagger_line)
- return error("char" PD_FMT ": missing tagger name",
- tagger_line - buffer);
+ return error("char%"PRIuMAX": missing tagger name",
+ (uintmax_t) (tagger_line - buffer));
/* timestamp, 1 or more digits followed by space */
tagger_line = rb + 2;
if (!(len = strspn(tagger_line, "0123456789")))
- return error("char" PD_FMT ": missing tag timestamp",
- tagger_line - buffer);
+ return error("char%"PRIuMAX": missing tag timestamp",
+ (uintmax_t) (tagger_line - buffer));
tagger_line += len;
if (*tagger_line != ' ')
- return error("char" PD_FMT ": malformed tag timestamp",
- tagger_line - buffer);
+ return error("char%"PRIuMAX": malformed tag timestamp",
+ (uintmax_t) (tagger_line - buffer));
tagger_line++;
/* timezone, 5 digits [+-]hhmm, max. 1400 */
if (!((tagger_line[0] == '+' || tagger_line[0] == '-') &&
strspn(tagger_line+1, "0123456789") == 4 &&
tagger_line[5] == '\n' && atoi(tagger_line+1) <= 1400))
- return error("char" PD_FMT ": malformed tag timezone",
- tagger_line - buffer);
+ return error("char%"PRIuMAX": malformed tag timezone",
+ (uintmax_t) (tagger_line - buffer));
tagger_line += 6;
/* Verify the blank line separating the header from the body */
if (*tagger_line != '\n')
- return error("char" PD_FMT ": trailing garbage in tag header",
- tagger_line - buffer);
+ return error("char%"PRIuMAX": trailing garbage in tag header",
+ (uintmax_t) (tagger_line - buffer));
/* The actual stuff afterwards we don't care about.. */
return 0;
}
-#undef PD_FMT
-
int cmd_mktag(int argc, const char **argv, const char *prefix)
{
struct strbuf buf = STRBUF_INIT;