aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-02-26 10:56:11 +0100
committerlookshe <github@lookshe.org>2016-02-26 10:56:11 +0100
commit4d7d10dba5215da5c4a284cbe13e13e085c45d93 (patch)
tree1273e8dee89ea8216106838e46524ccf661b35b5
parent1c1f2a00d290598f050cb77ad4c846902a135f5b (diff)
skip FS# not followed by number correctly
-rw-r--r--ui-shared.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/ui-shared.c b/ui-shared.c
index ea6d18b..2d695a7 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -364,27 +364,30 @@ void cgit_commit_link2(char *name, const char *title, const char *class,
{
if (checkForIssueLink) {
int last_match = 0;
+ int offset = 0;
for (;;) {
- const char* sub = strstr(name + last_match, "FS#");
- if (sub != NULL) {
- const char* sub = strstr(name + last_match, "FS#");
+ const char* sub = strstr(name + last_match + offset, "FS#");
+ if (sub != NULL) {
int found_pos = (sub - (name + last_match));
- if (found_pos > 0) {
- char* left_part = sub_str(name, last_match, last_match + found_pos);
- cgit_commit_link3(left_part, title, class, head, rev, path);
- free(left_part);
- }
sub += 3;
int numbercount = 0;
while (*sub >= '0' && *sub <= '9') {
numbercount++;
sub++;
}
+ if (!numbercount) {
+ offset = found_pos + 3;
+ continue;
+ } else {
+ offset = 0;
+ }
+ if (found_pos > 0) {
+ char* left_part = sub_str(name, last_match, last_match + found_pos);
+ cgit_commit_link3(left_part, title, class, head, rev, path);
+ free(left_part);
+ }
char* issue_part = sub_str(name, last_match + found_pos, last_match + found_pos + 3 + numbercount);
- if (numbercount)
- cgit_issue_link(issue_part);
- else
- cgit_commit_link3(issue_part, title, class, head, rev, path);
+ cgit_issue_link(issue_part);
free(issue_part);
last_match += found_pos + 3 + numbercount;
} else {
@@ -1166,26 +1169,30 @@ extern void cgit_author_link(const char *author, const char *head)
extern void cgit_check_text_for_issue_link(const char* text)
{
int last_match = 0;
+ int offset = 0;
for (;;) {
- const char* sub = strstr(text + last_match, "FS#");
- if(sub != NULL) {
+ const char* sub = strstr(text + last_match + offset, "FS#");
+ if(sub != NULL) {
int found_pos = (sub - (text + last_match));
- if (found_pos > 0) {
- char* left_part = sub_str(text, last_match, last_match + found_pos);
- html_txt(left_part);
- free(left_part);
- }
sub += 3;
int numbercount = 0;
while (*sub >= '0' && *sub <= '9') {
numbercount++;
sub++;
}
+ if (!numbercount) {
+ offset = found_pos + 3;
+ continue;
+ } else {
+ offset = 0;
+ }
+ if (found_pos > 0) {
+ char* left_part = sub_str(text, last_match, last_match + found_pos);
+ html_txt(left_part);
+ free(left_part);
+ }
char* issue_part = sub_str(text, last_match + found_pos, last_match + found_pos + 3 + numbercount);
- if (numbercount)
- cgit_issue_link(issue_part);
- else
- html_txt(issue_part);
+ cgit_issue_link(issue_part);
free(issue_part);
last_match += found_pos + 3 + numbercount;
} else {