}
}
-char *substr(const char *head, const char *tail)
+static char *substr(const char *head, const char *tail)
{
char *buf;
+ if (tail < head)
+ return xstrdup("");
buf = xmalloc(tail - head + 1);
strncpy(buf, head, tail - head);
buf[tail - head] = '\0';
return buf;
}
-char *parse_user(char *t, char **name, char **email, unsigned long *date)
+static char *parse_user(char *t, char **name, char **email, unsigned long *date)
{
char *p = t;
int mode = 1;
#ifdef NO_ICONV
#define reencode(a, b, c)
#else
-const char *reencode(char **txt, const char *src_enc, const char *dst_enc)
+static const char *reencode(char **txt, const char *src_enc, const char *dst_enc)
{
char *tmp;
- if (!txt || !*txt || !src_enc || !dst_enc)
+ if (!txt)
+ return NULL;
+
+ if (!*txt || !src_enc || !dst_enc)
return *txt;
/* no encoding needed if src_enc equals dst_enc */
- if(!strcasecmp(src_enc, dst_enc))
+ if (!strcasecmp(src_enc, dst_enc))
return *txt;
tmp = reencode_string(*txt, dst_enc, src_enc);
struct commitinfo *cgit_parse_commit(struct commit *commit)
{
struct commitinfo *ret;
- char *p = commit->buffer, *t = commit->buffer;
+ char *p = commit->buffer, *t;
ret = xmalloc(sizeof(*ret));
ret->commit = commit;
}
/* if no special encoding is found, assume UTF-8 */
- if(!ret->msg_encoding)
+ if (!ret->msg_encoding)
ret->msg_encoding = xstrdup("UTF-8");
// skip unknown header fields