summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2022-07-28 20:01:03 -0300
committermrb0nk500 <b0nk@b0nk.xyz>2022-07-28 20:42:46 -0300
commitd98868fa4d03659aad9ad2d858ee51e414d54ce4 (patch)
tree7e1ce8604cb6dad2949065dfe50bf4cfe80dd2e3 /git.c
parent052e06fd16f5ef161a10fc7880e32827c814bea2 (diff)
everywhere: Fix compiler errors, compiler warnings, and correct typos
Diffstat (limited to 'git.c')
-rw-r--r--git.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/git.c b/git.c
index e13b787..579df11 100644
--- a/git.c
+++ b/git.c
@@ -80,7 +80,7 @@ static linked_list *parse_dsv_str(const char *str, const char *delm) {
/* Create the token. */
char *tok = calloc(tok_len+1, sizeof(char));
/* Get the token from the string. */
- memcpy(tok, tmp, tok_len);
+ memcpy(tok, str, tok_len);
/* Add the token to the list.. */
tail = add_node(&tail, tok);
/* Move over the token. */
@@ -89,7 +89,7 @@ static linked_list *parse_dsv_str(const char *str, const char *delm) {
return tail;
}
-static int parse_patch_list(void *ctx, void *ret, const keyword *key, keyword_val val) {
+int parse_patch_list(void *ctx, void *ret, const keyword *key, keyword_val val) {
/* Do we actually have a "patches" keyword? */
if (key->type == TYPE_STRING) {
const char *root = (const char *)ctx;
@@ -119,18 +119,18 @@ static int parse_patch_list(void *ctx, void *ret, const keyword *key, keyword_va
return -1;
}
-static int parse_comment_reply(void *ctx, void *ret, const keyword *key, keyword_val val) {
+int parse_comment_reply(void *ctx, void *ret, const keyword *key, keyword_val val) {
linked_list *comment_list = *(linked_list **)ctx;
- comment *comment = (comment *)ret;
+ comment *comm = (comment *)ret;
/* Do we already have a reply? */
- if (comment->reply != NULL) {
+ if (comm->reply != NULL) {
/* Check if this reply matches any other comment in the list. */
for (linked_list *node = get_tail(comment_list); node != NULL; node = node->prev) {
comment *reply = (comment *)node->data;
/* Do we have a match? */
- if (comment->reply == reply) {
+ if (comm->reply == reply) {
return 1;
}
}
@@ -146,13 +146,13 @@ static int parse_comment_reply(void *ctx, void *ret, const keyword *key, keyword
/* Do we have a match? */
if (reply->id == val.i) {
/* Does this comment already have a reply? */
- if (comment->reply != NULL) {
+ if (comm->reply != NULL) {
/* Free the reply. */
- free(comment->reply);
+ free(comm->reply);
}
/* Set our reply comment to the matched comment. */
- comment->reply = reply;
+ comm->reply = reply;
found_reply = 1;
break;
}
@@ -165,28 +165,29 @@ static int parse_comment_reply(void *ctx, void *ret, const keyword *key, keyword
}
/* Do we not have a reply? */
- if (comment->reply == NULL) {
+ if (comm->reply == NULL) {
/* Create one. */
- comment->reply = calloc(1, sizeof(comment));
+ comm->reply = calloc(1, sizeof(comment));
}
/* Which keyword do we have? */
switch (key->type) {
/* reply-to */
- case TYPE_INT : comment->reply->id = val.i; break;
+ case TYPE_INT : comm->reply->id = val.i; break;
/* reply-author */
- case TYPE_STRING: comment->reply->author = val.str; break;
+ case TYPE_STRING: comm->reply->author = val.str; break;
/* reply-date */
- case TYPE_TIME : comment->reply->date = val.t; break;
- default : break;
+ case TYPE_TIME : comm->reply->date = val.t; break;
+ default : return -1; break;
}
+ return 1;
}
typedef int (parse_callback)(void **ret, void *ctx, char *buf);
static int parse_colon_key_value_file(void *ret, void *ctx, const keyword **keywords, char *buf, parse_callback *parse_cb) {
if (buf != NULL) {
- int ret = 0;
+ int ret_val = 0;
for (;;) {
char *lhs, *rhs;
/* Find the keyword before the colon. */
@@ -198,11 +199,12 @@ static int parse_colon_key_value_file(void *ret, void *ctx, const keyword **keyw
if (lhs == NULL) {
break;
} else {
+ int error;
char *tmp = skip_whitespace(buf);
/* Does the right hand side start with a double, or single quote? */
if (*tmp == '\"' || *tmp == '\'') {
- const char *delm = (delm == '\"') ? "\"" : "\'";
+ const char *delm = (*delm == '\"') ? "\"" : "\'";
/* Get the string in between the start, and end qoute. */
rhs = get_str_delm_range(tmp, delm, delm, &buf);
} else {
@@ -211,9 +213,9 @@ static int parse_colon_key_value_file(void *ret, void *ctx, const keyword **keyw
}
/* Did we fail to parse the keyword? */
- if (int error = parse_keywords(keywords, lhs, rhs, ret, ctx)) {
+ if (error = parse_keywords(keywords, lhs, rhs, ret, ctx)) {
log(LOG_WARNING, "Failed to parse keyword \"%s\". Error code: %i", lhs, error);
- ret = error;
+ ret_val = error;
}
}
@@ -221,14 +223,14 @@ static int parse_colon_key_value_file(void *ret, void *ctx, const keyword **keyw
if (parse_cb != NULL) {
/* Did the callback return an error. */
if (parse_cb(&ret, ctx, buf) < 0) {
- ret = 5;
+ ret_val = 7;
break;
}
}
}
- return ret;
+ return ret_val;
} else {
- return 6;
+ return 8;
}
}
@@ -252,19 +254,19 @@ static int is_end_of_comment(void **ret, void *ctx, char *buf) {
static int parse_comments_file(comment ***comments, char *buf) {
if (comments == NULL) {
- return 7;
+ return 9;
} else {
linked_list *comment_list = NULL;
int ret = parse_colon_key_value_file(calloc(1, sizeof(comment)), &comment_list, comment_keywords, buf, is_end_of_comment);
- *comments = linked_list_to_array(comment_list);
- cleanup_linked_list(comments_list);
+ *comments = (comment **)linked_list_to_array(comment_list);
+ cleanup_linked_list(comment_list);
return ret;
}
}
static int parse_info_file(pull_request *pr, char *buf, const char *root) {
- return parse_colon_key_value_file(pr, root, info_keywords, buf, NULL);
+ return parse_colon_key_value_file(pr, (void *)root, info_keywords, buf, NULL);
}
static int parse_comments_file_path(comment ***comments, const char *root) {
@@ -533,7 +535,7 @@ int create_pull_request_dir(pull_request *pr, index_t *idx, const char *root) {
}
/* Use the index as the directory path. */
- pr_dir = make_index_path(root, idx);
+ pr_dir = make_index_path(root, idx, 0);
/* Did we fail to make an indexed path? */
if (pr_dir == NULL) {