35
return ret;
36
}
37
38
-#ifdef NO_C99_FORMAT
39
-#define PD_FMT "%d"
40
-#else
41
-#define PD_FMT "%td"
42
-#endif
43
-
38
static int verify_tag(char *buffer, unsigned long size)
39
{
40
int typelen;
64
/* Verify tag-line */
65
tag_line = strchr(type_line, '\n');
66
if (!tag_line)
73
- return error("char" PD_FMT ": could not find next \"\\n\"", type_line - buffer);
67
+ return error("char%"PRIuMAX": could not find next \"\\n\"",
68
+ (uintmax_t) (type_line - buffer));
69
tag_line++;
70
if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n')
76
- return error("char" PD_FMT ": no \"tag \" found", tag_line - buffer);
71
+ return error("char%"PRIuMAX": no \"tag \" found",
72
+ (uintmax_t) (tag_line - buffer));
73
74
/* Get the actual type */
75
typelen = tag_line - type_line - strlen("type \n");
76
if (typelen >= sizeof(type))
81
- return error("char" PD_FMT ": type too long", type_line+5 - buffer);
77
+ return error("char%"PRIuMAX": type too long",
78
+ (uintmax_t) (type_line+5 - buffer));
79
80
memcpy(type, type_line+5, typelen);
81
type[typelen] = 0;
92
break;
93
if (c > ' ')
94
continue;
98
- return error("char" PD_FMT ": could not verify tag name", tag_line - buffer);
95
+ return error("char%"PRIuMAX": could not verify tag name",
96
+ (uintmax_t) (tag_line - buffer));
97
}
98
99
/* Verify the tagger line */
100
tagger_line = tag_line;
101
102
if (memcmp(tagger_line, "tagger ", 7))
105
- return error("char" PD_FMT ": could not find \"tagger \"",
106
- tagger_line - buffer);
103
+ return error("char%"PRIuMAX": could not find \"tagger \"",
104
+ (uintmax_t) (tagger_line - buffer));
105
106
/*
107
* Check for correct form for name and email
113
if (!(lb = strstr(tagger_line, " <")) || !(rb = strstr(lb+2, "> ")) ||
114
strpbrk(tagger_line, "<>\n") != lb+1 ||
115
strpbrk(lb+2, "><\n ") != rb)
118
- return error("char" PD_FMT ": malformed tagger field",
119
- tagger_line - buffer);
116
+ return error("char%"PRIuMAX": malformed tagger field",
117
+ (uintmax_t) (tagger_line - buffer));
118
119
/* Check for author name, at least one character, space is acceptable */
120
if (lb == tagger_line)
123
- return error("char" PD_FMT ": missing tagger name",
124
- tagger_line - buffer);
121
+ return error("char%"PRIuMAX": missing tagger name",
122
+ (uintmax_t) (tagger_line - buffer));
123
124
/* timestamp, 1 or more digits followed by space */
125
tagger_line = rb + 2;
126
if (!(len = strspn(tagger_line, "0123456789")))
129
- return error("char" PD_FMT ": missing tag timestamp",
130
- tagger_line - buffer);
127
+ return error("char%"PRIuMAX": missing tag timestamp",
128
+ (uintmax_t) (tagger_line - buffer));
129
tagger_line += len;
130
if (*tagger_line != ' ')
133
- return error("char" PD_FMT ": malformed tag timestamp",
134
- tagger_line - buffer);
131
+ return error("char%"PRIuMAX": malformed tag timestamp",
132
+ (uintmax_t) (tagger_line - buffer));
133
tagger_line++;
134
135
/* timezone, 5 digits [+-]hhmm, max. 1400 */
136
if (!((tagger_line[0] == '+' || tagger_line[0] == '-') &&
137
strspn(tagger_line+1, "0123456789") == 4 &&
138
tagger_line[5] == '\n' && atoi(tagger_line+1) <= 1400))
141
- return error("char" PD_FMT ": malformed tag timezone",
142
- tagger_line - buffer);
139
+ return error("char%"PRIuMAX": malformed tag timezone",
140
+ (uintmax_t) (tagger_line - buffer));
141
tagger_line += 6;
142
143
/* Verify the blank line separating the header from the body */
144
if (*tagger_line != '\n')
147
- return error("char" PD_FMT ": trailing garbage in tag header",
148
- tagger_line - buffer);
145
+ return error("char%"PRIuMAX": trailing garbage in tag header",
146
+ (uintmax_t) (tagger_line - buffer));
147
148
/* The actual stuff afterwards we don't care about.. */
149
return 0;
150
}
151
154
-#undef PD_FMT
155
-
152
int cmd_mktag(int argc, const char **argv, const char *prefix)
153
{
154
struct strbuf buf = STRBUF_INIT;