pinosaur
/
smdp.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a92d65a
)
no goto on our code
author
Michael Göhler
<github@nixhub.de>
Sat, 2 Apr 2016 22:51:32 +0000
(
00:51
+0200)
committer
Michael Göhler
<github@nixhub.de>
Sat, 2 Apr 2016 22:51:32 +0000
(
00:51
+0200)
src/parser.c
patch
|
blob
|
history
diff --git
a/src/parser.c
b/src/parser.c
index
2157310
..
465bdc1
100644
(file)
--- a/
src/parser.c
+++ b/
src/parser.c
@@
-698,7
+698,8
@@
void expand_character_entities(line_t *line)
if (*curr == L'#') {
if (prev == ampersand)
continue;
if (*curr == L'#') {
if (prev == ampersand)
continue;
- goto clean;
+ ampersand = NULL;
+ continue;
}
if (iswalpha(*curr) || iswxdigit(*curr)) {
continue;
}
if (iswalpha(*curr) || iswxdigit(*curr)) {
continue;
@@
-706,22
+707,32
@@
void expand_character_entities(line_t *line)
if (*curr == L';') {
int cnt;
wchar_t ucs = L'\0';
if (*curr == L';') {
int cnt;
wchar_t ucs = L'\0';
- if (ampersand + 1 >= curr || ampersand + 16 < curr) // what is a good limit?
- goto clean;
+ if (ampersand + 1 >= curr || ampersand + 16 < curr) { // what is a good limit?
+ ampersand = NULL;
+ continue;
+ }
if (ampersand[1] == L'#') { // &#nnnn; or &#xhhhh;
if (ampersand[1] == L'#') { // &#nnnn; or &#xhhhh;
- if (ampersand + 2 >= curr)
- goto clean;
+ if (ampersand + 2 >= curr) {
+ ampersand = NULL;
+ continue;
+ }
if (ampersand[2] != L'x') { // &#nnnn;
cnt = wcsspn(&ersand[2], L"0123456789");
if (ampersand[2] != L'x') { // &#nnnn;
cnt = wcsspn(&ersand[2], L"0123456789");
- if (ampersand + 2 + cnt != curr)
- goto clean;
+ if (ampersand + 2 + cnt != curr) {
+ ampersand = NULL;
+ continue;
+ }
ucs = wcstoul(&ersand[2], NULL, 10);
} else { // &#xhhhh;
ucs = wcstoul(&ersand[2], NULL, 10);
} else { // &#xhhhh;
- if (ampersand + 3 >= curr)
- goto clean;
+ if (ampersand + 3 >= curr) {
+ ampersand = NULL;
+ continue;
+ }
cnt = wcsspn(&ersand[3], L"0123456789abcdefABCDEF");
cnt = wcsspn(&ersand[3], L"0123456789abcdefABCDEF");
- if (ampersand + 3 + cnt != curr)
- goto clean;
+ if (ampersand + 3 + cnt != curr) {
+ ampersand = NULL;
+ continue;
+ }
ucs = wcstoul(&ersand[3], NULL, 16);
}
} else { // &name;
ucs = wcstoul(&ersand[3], NULL, 16);
}
} else { // &name;
@@
-731,16
+742,16
@@
void expand_character_entities(line_t *line)
ucs = named_character_entities[cnt].ucs;
break;
}
ucs = named_character_entities[cnt].ucs;
break;
}
- if (ucs == L'\0')
- goto clean;
+ if (ucs == L'\0') {
+ ampersand = NULL;
+ continue;
+ }
}
*ampersand = ucs;
cstring_strip(line->text, ampersand + 1 - &line->text->value[0], curr - ampersand);
curr = ampersand;
}
*ampersand = ucs;
cstring_strip(line->text, ampersand + 1 - &line->text->value[0], curr - ampersand);
curr = ampersand;
-
continue
;
+
ampersand = NULL
;
}
}
-clean:
- ampersand = NULL;
}
}
}
}