author | Lars Hjemli <hjemli@gmail.com> | 2008-12-05 18:10:28 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-12-05 18:10:28 (UTC) |
commit | 14b4e108a73b09ce9b6df2c7f2e417305ad68cf4 (patch) (unidiff) | |
tree | d31fe76c70e7149708e78e67fbd61bc2b31f816a | |
parent | 7115f7d257b5e3fb5d5d7ad6299214506fb35042 (diff) | |
download | cgit-14b4e108a73b09ce9b6df2c7f2e417305ad68cf4.zip cgit-14b4e108a73b09ce9b6df2c7f2e417305ad68cf4.tar.gz cgit-14b4e108a73b09ce9b6df2c7f2e417305ad68cf4.tar.bz2 |
parsing.c: enable builds with NO_ICONV defined
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | parsing.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -75,62 +75,66 @@ char *parse_user(char *t, char **name, char **email, unsigned long *date) | |||
75 | } else if (mode == 1 && *p == '\n') { | 75 | } else if (mode == 1 && *p == '\n') { |
76 | *name = substr(t, p); | 76 | *name = substr(t, p); |
77 | p++; | 77 | p++; |
78 | break; | 78 | break; |
79 | } else if (mode == 2 && *p == '>') { | 79 | } else if (mode == 2 && *p == '>') { |
80 | *email = substr(t, p + 1); | 80 | *email = substr(t, p + 1); |
81 | t = p; | 81 | t = p; |
82 | mode++; | 82 | mode++; |
83 | } else if (mode == 2 && *p == '\n') { | 83 | } else if (mode == 2 && *p == '\n') { |
84 | *email = substr(t, p); | 84 | *email = substr(t, p); |
85 | p++; | 85 | p++; |
86 | break; | 86 | break; |
87 | } else if (mode == 3 && isdigit(*p)) { | 87 | } else if (mode == 3 && isdigit(*p)) { |
88 | *date = atol(p); | 88 | *date = atol(p); |
89 | mode++; | 89 | mode++; |
90 | } else if (*p == '\n') { | 90 | } else if (*p == '\n') { |
91 | p++; | 91 | p++; |
92 | break; | 92 | break; |
93 | } | 93 | } |
94 | p++; | 94 | p++; |
95 | } | 95 | } |
96 | return p; | 96 | return p; |
97 | } | 97 | } |
98 | 98 | ||
99 | #ifdef NO_ICONV | ||
100 | #define reencode(a, b, c) | ||
101 | #else | ||
99 | const char *reencode(char **txt, const char *src_enc, const char *dst_enc) | 102 | const char *reencode(char **txt, const char *src_enc, const char *dst_enc) |
100 | { | 103 | { |
101 | char *tmp; | 104 | char *tmp; |
102 | 105 | ||
103 | if (!txt || !*txt || !src_enc || !dst_enc) | 106 | if (!txt || !*txt || !src_enc || !dst_enc) |
104 | return *txt; | 107 | return *txt; |
105 | 108 | ||
106 | tmp = reencode_string(*txt, src_enc, dst_enc); | 109 | tmp = reencode_string(*txt, src_enc, dst_enc); |
107 | if (tmp) { | 110 | if (tmp) { |
108 | free(*txt); | 111 | free(*txt); |
109 | *txt = tmp; | 112 | *txt = tmp; |
110 | } | 113 | } |
111 | return *txt; | 114 | return *txt; |
112 | } | 115 | } |
116 | #endif | ||
113 | 117 | ||
114 | struct commitinfo *cgit_parse_commit(struct commit *commit) | 118 | struct commitinfo *cgit_parse_commit(struct commit *commit) |
115 | { | 119 | { |
116 | struct commitinfo *ret; | 120 | struct commitinfo *ret; |
117 | char *p = commit->buffer, *t = commit->buffer; | 121 | char *p = commit->buffer, *t = commit->buffer; |
118 | 122 | ||
119 | ret = xmalloc(sizeof(*ret)); | 123 | ret = xmalloc(sizeof(*ret)); |
120 | ret->commit = commit; | 124 | ret->commit = commit; |
121 | ret->author = NULL; | 125 | ret->author = NULL; |
122 | ret->author_email = NULL; | 126 | ret->author_email = NULL; |
123 | ret->committer = NULL; | 127 | ret->committer = NULL; |
124 | ret->committer_email = NULL; | 128 | ret->committer_email = NULL; |
125 | ret->subject = NULL; | 129 | ret->subject = NULL; |
126 | ret->msg = NULL; | 130 | ret->msg = NULL; |
127 | ret->msg_encoding = NULL; | 131 | ret->msg_encoding = NULL; |
128 | 132 | ||
129 | if (p == NULL) | 133 | if (p == NULL) |
130 | return ret; | 134 | return ret; |
131 | 135 | ||
132 | if (strncmp(p, "tree ", 5)) | 136 | if (strncmp(p, "tree ", 5)) |
133 | die("Bad commit: %s", sha1_to_hex(commit->object.sha1)); | 137 | die("Bad commit: %s", sha1_to_hex(commit->object.sha1)); |
134 | else | 138 | else |
135 | p += 46; // "tree " + hex[40] + "\n" | 139 | p += 46; // "tree " + hex[40] + "\n" |
136 | 140 | ||