commit - ce0d9b90810685e3140a27be24e1a9e08e3b2e87
commit + 6c6c85af5c207047e4cc85a84ceb51803f30ec61
blob - 56e19969650c089c3bfb09e8a3e8c17f8743800b
blob + 668a3dff9487f2f24e79bf7b539ea483cdea38e9
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
free(heads_html);
free(heads);
}
-
return error;
}
char *minutes = "minutes ago", *seconds = "seconds ago";
char *now = "right now";
char *repo_age, *s;
- char datebuf[BUFFER_SIZE];
+ char datebuf[29];
switch (ref_tm) {
case TM_DIFF:
if ((f = fopen(d_file, "r")) == NULL)
goto err;
- if ((buf = calloc(BUFFER_SIZE, sizeof(char *))) == NULL)
+ if ((buf = calloc(128, sizeof(char *))) == NULL)
goto err;
- while ((fgets(buf, BUFFER_SIZE, f)) != NULL) {
+ while ((fgets(buf, 128, f)) != NULL) {
if ((pos = strstr(buf, gotweb)) != NULL)
break;
goto err;
do {
- fgets(buf, BUFFER_SIZE, f);
+ fgets(buf, 128, f);
} while ((comp = strcasestr(buf, gw_owner)) == NULL);
if (comp == NULL)
struct buf *diffbuf = NULL;
time_t committer_time;
+ error = buf_alloc(&diffbuf, 0);
+ if (error != NULL)
+ return NULL;
+
if (search_pattern &&
regcomp(®ex, search_pattern, REG_EXTENDED | REG_NOSUB |
REG_NEWLINE))
return NULL;
- SIMPLEQ_INIT(&refs);
-
error = got_repo_open(&repo, gw_trans->repo_path, NULL);
if (error != NULL)
- goto done;
+ return NULL;
- error = buf_alloc(&diffbuf, BUFFER_SIZE);
- if (error != NULL)
- goto done;
+ SIMPLEQ_INIT(&refs);
if (start_commit == NULL) {
struct got_reference *head_ref;
error = got_ref_open(&head_ref, repo, gw_trans->headref, 0);
if (error != NULL)
goto done;
+
error = got_ref_resolve(&id1, repo, head_ref);
got_ref_close(head_ref);
if (error != NULL)
goto done;
+
error = got_object_open_as_commit(&commit, repo, id1);
} else {
struct got_reference *ref;
if (error != NULL)
goto done;
+
error = got_repo_map_path(&in_repo_path, repo, gw_trans->repo_path, 1);
if (error != NULL)
goto done;
return NULL;
}
- error = buf_append(&newsize, diffbuf, commit_row,
- strlen(commit_row));
+ error = buf_puts(&newsize, diffbuf, commit_row);
free(commit_parent);
free(commit_diff_disp);
if (error)
goto done;
- logs = strdup(diffbuf->cb_buf);
+ if (buf_len(diffbuf) > 0) {
+ error = buf_putc(diffbuf, '\0');
+ logs = strdup(buf_get(diffbuf));
+ }
done:
buf_free(diffbuf);
if (commit != NULL)
struct buf *diffbuf = NULL;
size_t newsize;
- error = buf_alloc(&diffbuf, BUFFER_SIZE);
+ error = buf_alloc(&diffbuf, 0);
if (error != NULL)
- goto done;
+ return NULL;
+ SIMPLEQ_INIT(&refs);
error = got_repo_open(&repo, gw_trans->repo_path, NULL);
if (error != NULL)
goto done;
- SIMPLEQ_INIT(&refs);
-
error = got_ref_list(&refs, repo, "refs/tags", cmp_tags, repo);
if (error)
goto done;
tag_log0 = strdup(got_object_tag_get_message(tag));
- got_object_tag_close(tag);
if (tag_log0 == NULL) {
error = got_error_from_errno("strdup");
goto done;
default:
break;
}
- /* /1* printf("%stag %s %s\n", GOT_COMMIT_SEP_STR, refname, refstr); *1/ */
- /* free(refstr); */
- /* error = got_ref_resolve(&id, repo, re->ref); */
- /* if (error) */
- /* break; */
- /* error = got_object_open_as_tag(&tag, repo, id); */
- /* free(id); */
- /* if (error) */
- /* break; */
- /* /1* printf("from: %s\n", got_object_tag_get_tagger(tag)); *1/ */
- /* tagger_time = got_object_tag_get_tagger_time(tag); */
- /* /1* datestr = get_datestr(&tagger_time, datebuf); *1/ */
- /* /1* if (datestr) *1/ */
- /* /1* printf("date: %s UTC\n", datestr); *1/ */
- /* error = got_object_id_str(&id_str, */
- /* got_object_tag_get_object_id(tag)); */
- /* if (error) */
- /* break; */
- /* switch (got_object_tag_get_object_type(tag)) { */
- /* case GOT_OBJ_TYPE_BLOB: */
- /* /1* printf("object: %s %s\n", GOT_OBJ_LABEL_BLOB, id_str); *1/ */
- /* break; */
- /* case GOT_OBJ_TYPE_TREE: */
- /* /1* printf("object: %s %s\n", GOT_OBJ_LABEL_TREE, id_str); *1/ */
- /* break; */
- /* case GOT_OBJ_TYPE_COMMIT: */
- /* /1* printf("object: %s %s\n", GOT_OBJ_LABEL_COMMIT, id_str); *1/ */
- /* break; */
- /* case GOT_OBJ_TYPE_TAG: */
- /* /1* printf("object: %s %s\n", GOT_OBJ_LABEL_TAG, id_str); *1/ */
- /* break; */
- /* default: */
- /* break; */
- /* } */
- /* free(id_str); */
- /* tagmsg0 = strdup(got_object_tag_get_message(tag)); */
- /* got_object_tag_close(tag); */
- /* if (tagmsg0 == NULL) { */
- /* error = got_error_from_errno("strdup"); */
- /* break; */
- /* } */
+ got_object_tag_close(tag);
- /* tagmsg = tagmsg0; */
- /* do { */
- /* line = strsep(&tagmsg, "\n"); */
- /* if (line) */
- /* printf(" %s\n", line); */
- /* } while (line); */
- /* free(tagmsg0); */
- /* error = buf_append(&newsize, diffbuf, tags_row, */
- /* strlen(tags_row)); */
- error = buf_append(&newsize, diffbuf, tag_row, strlen(tag_row));
+ error = buf_puts(&newsize, diffbuf, tag_row);
+ free(id_str);
+ free(refstr);
+ free(age);
free(tag_log0);
free(tag_row);
- free(age);
- free(id_str);
- id_str = NULL;
if (error || (limit && --limit == 0))
break;
}
- tags = strdup(diffbuf->cb_buf);
+
+ if (buf_len(diffbuf) > 0) {
+ error = buf_putc(diffbuf, '\0');
+ tags = strdup(buf_get(diffbuf));
+ }
done:
buf_free(diffbuf);
got_ref_list_free(&refs);
struct buf *diffbuf = NULL;
size_t newsize;
- error = buf_alloc(&diffbuf, BUFFER_SIZE);
+ error = buf_alloc(&diffbuf, 0);
if (error != NULL)
- goto done;
+ return NULL;
error = got_repo_open(&repo, gw_trans->repo_path, NULL);
if (error != NULL)
goto done;
}
- error = buf_append(&newsize, diffbuf, head_row,
- strlen(head_row));
+ error = buf_puts(&newsize, diffbuf, head_row);
free(head_navs_disp);
free(head_row);
}
- heads = strdup(diffbuf->cb_buf);
+ if (buf_len(diffbuf) > 0) {
+ error = buf_putc(diffbuf, '\0');
+ heads = strdup(buf_get(diffbuf));
+ }
done:
buf_free(diffbuf);
got_ref_list_free(&refs);
{
char *escaped_str = NULL, *buf;
char c[1];
- size_t sz, i;
+ size_t sz, i, buff_sz = 2048;
- if ((buf = calloc(BUFFER_SIZE, sizeof(char *))) == NULL)
+ if ((buf = calloc(buff_sz, sizeof(char *))) == NULL)
return NULL;
if (html == NULL)
if ((sz = strlen(html)) == 0)
return NULL;
- /* only work with BUFFER_SIZE */
- if (BUFFER_SIZE < sz)
- sz = BUFFER_SIZE;
+ /* only work with buff_sz */
+ if (buff_sz < sz)
+ sz = buff_sz;
for (i = 0; i < sz; i++) {
c[0] = html[i];