fixed offset calculation for escape syntax
This commit is contained in:
parent
6f30327420
commit
f8ea125d0f
|
@ -4,7 +4,11 @@ AsmError push_string(char *buf, char *input, size_t len) {
|
||||||
char chr = input[pos];
|
char chr = input[pos];
|
||||||
if (chr == '\\') {
|
if (chr == '\\') {
|
||||||
pos += 1;
|
pos += 1;
|
||||||
|
if (pos + 1 >= len) {
|
||||||
|
return ErrDanglingEscape;
|
||||||
|
}
|
||||||
chr = input[pos];
|
chr = input[pos];
|
||||||
|
size_t offset = 1;
|
||||||
switch (chr) {
|
switch (chr) {
|
||||||
case '\\':
|
case '\\':
|
||||||
chr = '\\';
|
chr = '\\';
|
||||||
|
@ -30,7 +34,7 @@ AsmError push_string(char *buf, char *input, size_t len) {
|
||||||
}
|
}
|
||||||
char high = get_hex(input[pos + 1]);
|
char high = get_hex(input[pos + 1]);
|
||||||
char low = get_hex(input[pos + 2]);
|
char low = get_hex(input[pos + 2]);
|
||||||
pos += 2;
|
offset = 2;
|
||||||
if (high > 15 || low > 15) {
|
if (high > 15 || low > 15) {
|
||||||
return ErrStringBadHex;
|
return ErrStringBadHex;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +43,7 @@ AsmError push_string(char *buf, char *input, size_t len) {
|
||||||
default:
|
default:
|
||||||
return ErrBadStringEscape;
|
return ErrBadStringEscape;
|
||||||
}
|
}
|
||||||
|
pos += offset;
|
||||||
}
|
}
|
||||||
buf[ndata] = chr;
|
buf[ndata] = chr;
|
||||||
ndata += 1;
|
ndata += 1;
|
||||||
|
|
Loading…
Reference in a new issue