Fix generalized patches
This commit is contained in:
parent
b18e5fe83f
commit
ba5b3e53e2
1 changed files with 12 additions and 12 deletions
24
smu.c
24
smu.c
|
@ -171,14 +171,14 @@ dohtml(const char *begin, const char *end, int newblock) {
|
||||||
p += 2;
|
p += 2;
|
||||||
if(strncmp(p, tag, tagend - tag) == 0 && p[tagend - tag] == '>') {
|
if(strncmp(p, tag, tagend - tag) == 0 && p[tagend - tag] == '>') {
|
||||||
p++;
|
p++;
|
||||||
fwrite(begin, sizeof(char), p - begin + tagend - tag + 1, stdout);
|
fwrite(begin, sizeof(char), p - begin + tagend - tag - 1, stdout);
|
||||||
return p - begin + tagend - tag + 1;
|
return p - begin + tagend - tag - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = strchr(tagend, '>');
|
p = strchr(tagend, '>');
|
||||||
if(p) {
|
if(p) {
|
||||||
fwrite(begin, sizeof(char), p - begin + 2, stdout);
|
fwrite(begin, sizeof(char), p - begin + 1, stdout);
|
||||||
return p - begin + 2;
|
return p - begin + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -282,12 +282,12 @@ dolink(const char *begin, const char *end, int newblock) {
|
||||||
q++;
|
q++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((p = strpbrk(link, "\"'")) && p < end && q > p) {
|
if((p = strpbrk(link, "\"'")) && p < end && q - 1 > p + 1) {
|
||||||
sep = p[0]; /* separator: can be " or ' */
|
sep = p[0]; /* separator: can be " or ' */
|
||||||
title = p + 1;
|
title = p + 1;
|
||||||
/* strip trailing whitespace */
|
/* strip trailing whitespace */
|
||||||
for(linkend = p; linkend > link && isspace(*(linkend - 1)); linkend--);
|
for(linkend = p; linkend > link && isspace(*(linkend - 1)); linkend--);
|
||||||
for(titleend = q - 1; titleend > link && isspace(*(titleend)); titleend--);
|
for(titleend = q - 1; titleend > title && isspace(*(titleend)); titleend--);
|
||||||
if(*titleend != sep) {
|
if(*titleend != sep) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ dosurround(const char *begin, const char *end, int newblock) {
|
||||||
fputs(surround[i].before, stdout);
|
fputs(surround[i].before, stdout);
|
||||||
|
|
||||||
/* Single space at start and end are ignored */
|
/* Single space at start and end are ignored */
|
||||||
if (*start == ' ' && *(stop - 1) == ' ') {
|
if (stop - start > 2 && *start == ' ' && *(stop - 1) == ' ') {
|
||||||
start++;
|
start++;
|
||||||
stop--;
|
stop--;
|
||||||
l++;
|
l++;
|
||||||
|
@ -552,12 +552,12 @@ dounderline(const char *begin, const char *end, int newblock) {
|
||||||
if(!newblock)
|
if(!newblock)
|
||||||
return 0;
|
return 0;
|
||||||
p = begin;
|
p = begin;
|
||||||
for(l = 0; p + l != end && p[l] != '\n'; l++);
|
for(l = 0; p + l + 1 != end && p[l] != '\n'; l++);
|
||||||
p += l + 1;
|
p += l + 1;
|
||||||
if(l == 0)
|
if(l == 0)
|
||||||
return 0;
|
return 0;
|
||||||
for(i = 0; i < LENGTH(underline); i++) {
|
for(i = 0; i < LENGTH(underline); i++) {
|
||||||
for(j = 0; p + j < end && p[j] != '\n' && p[j] == underline[i].search[0]; j++);
|
for(j = 0; p + j != end && p[j] != '\n' && p[j] == underline[i].search[0]; j++);
|
||||||
if(j >= l) {
|
if(j >= l) {
|
||||||
fputs(underline[i].before, stdout);
|
fputs(underline[i].before, stdout);
|
||||||
if(underline[i].process)
|
if(underline[i].process)
|
||||||
|
@ -588,7 +588,7 @@ void
|
||||||
hprint(const char *begin, const char *end) {
|
hprint(const char *begin, const char *end) {
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
for(p = begin; p < end; p++) {
|
for(p = begin; p != end; p++) {
|
||||||
if(*p == '&')
|
if(*p == '&')
|
||||||
fputs("&", stdout);
|
fputs("&", stdout);
|
||||||
else if(*p == '"')
|
else if(*p == '"')
|
||||||
|
@ -624,10 +624,10 @@ process(const char *begin, const char *end, int newblock) {
|
||||||
fputc(*p, stdout);
|
fputc(*p, stdout);
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
for(q = p; q < end && *q == '\n'; q++);
|
for(q = p; q != end && *q == '\n'; q++);
|
||||||
if(q == end)
|
if(q == end)
|
||||||
return;
|
return;
|
||||||
else if(p < end && p[0] == '\n' && p + 1 < end && p[1] == '\n')
|
else if(p[0] == '\n' && p + 1 != end && p[1] == '\n')
|
||||||
newblock = 1;
|
newblock = 1;
|
||||||
else
|
else
|
||||||
newblock = affected < 0;
|
newblock = affected < 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue