mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
viml/parser/expressions,klee: Fix some problems found by KLEE run
This commit is contained in:
parent
bc386c4882
commit
3aa2c0d63a
@ -69,7 +69,7 @@ typedef enum {
|
|||||||
} ExprOptScope;
|
} ExprOptScope;
|
||||||
|
|
||||||
#define EXPR_OPT_SCOPE_LIST \
|
#define EXPR_OPT_SCOPE_LIST \
|
||||||
((char *)(char[]){ kExprOptScopeGlobal, kExprOptScopeLocal })
|
((char[]){ kExprOptScopeGlobal, kExprOptScopeLocal })
|
||||||
|
|
||||||
/// All possible variable scopes
|
/// All possible variable scopes
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -38,20 +38,21 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Recognize hex, octal and bin.
|
// Recognize hex, octal and bin.
|
||||||
if ((ptr[0] == '0') && (ptr[1] != '8') && (ptr[1] != '9')
|
if ((what & (STR2NR_HEX|STR2NR_OCT|STR2NR_BIN))
|
||||||
&& (maxlen == 0 || maxlen > 1)) {
|
&& (maxlen == 0 || maxlen > 1)
|
||||||
|
&& (ptr[0] == '0') && (ptr[1] != '8') && (ptr[1] != '9')) {
|
||||||
pre = ptr[1];
|
pre = ptr[1];
|
||||||
|
|
||||||
if ((what & STR2NR_HEX)
|
if ((what & STR2NR_HEX)
|
||||||
|
&& (maxlen == 0 || maxlen > 2)
|
||||||
&& ((pre == 'X') || (pre == 'x'))
|
&& ((pre == 'X') || (pre == 'x'))
|
||||||
&& ascii_isxdigit(ptr[2])
|
&& ascii_isxdigit(ptr[2])) {
|
||||||
&& (maxlen == 0 || maxlen > 2)) {
|
|
||||||
// hexadecimal
|
// hexadecimal
|
||||||
ptr += 2;
|
ptr += 2;
|
||||||
} else if ((what & STR2NR_BIN)
|
} else if ((what & STR2NR_BIN)
|
||||||
|
&& (maxlen == 0 || maxlen > 2)
|
||||||
&& ((pre == 'B') || (pre == 'b'))
|
&& ((pre == 'B') || (pre == 'b'))
|
||||||
&& ascii_isbdigit(ptr[2])
|
&& ascii_isbdigit(ptr[2])) {
|
||||||
&& (maxlen == 0 || maxlen > 2)) {
|
|
||||||
// binary
|
// binary
|
||||||
ptr += 2;
|
ptr += 2;
|
||||||
} else {
|
} else {
|
||||||
@ -80,7 +81,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
|
|||||||
|
|
||||||
// Do the string-to-numeric conversion "manually" to avoid sscanf quirks.
|
// Do the string-to-numeric conversion "manually" to avoid sscanf quirks.
|
||||||
int n = 1;
|
int n = 1;
|
||||||
if ((pre == 'B') || (pre == 'b') || what == STR2NR_BIN + STR2NR_FORCE) {
|
if (pre == 'B' || pre == 'b' || what == (STR2NR_BIN|STR2NR_FORCE)) {
|
||||||
// bin
|
// bin
|
||||||
if (pre != 0) {
|
if (pre != 0) {
|
||||||
n += 2; // skip over "0b"
|
n += 2; // skip over "0b"
|
||||||
@ -97,7 +98,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((pre == '0') || what == STR2NR_OCT + STR2NR_FORCE) {
|
} else if (pre == '0' || what == (STR2NR_OCT|STR2NR_FORCE)) {
|
||||||
// octal
|
// octal
|
||||||
while ('0' <= *ptr && *ptr <= '7') {
|
while ('0' <= *ptr && *ptr <= '7') {
|
||||||
// avoid ubsan error for overflow
|
// avoid ubsan error for overflow
|
||||||
@ -111,8 +112,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ((pre == 'X') || (pre == 'x')
|
} else if (pre == 'X' || pre == 'x' || what == (STR2NR_HEX|STR2NR_FORCE)) {
|
||||||
|| what == STR2NR_HEX + STR2NR_FORCE) {
|
|
||||||
// hex
|
// hex
|
||||||
if (pre != 0) {
|
if (pre != 0) {
|
||||||
n += 2; // skip over "0x"
|
n += 2; // skip over "0x"
|
||||||
|
@ -46,7 +46,7 @@ main() {
|
|||||||
line1="$line1 '--output-dir=$KLEE_OUT_DIR' '$KLEE_BIN_DIR/a.bc'"
|
line1="$line1 '--output-dir=$KLEE_OUT_DIR' '$KLEE_BIN_DIR/a.bc'"
|
||||||
local line2="for t in '$KLEE_OUT_DIR'/*.err"
|
local line2="for t in '$KLEE_OUT_DIR'/*.err"
|
||||||
line2="$line2 ; do ktest-tool --write-ints"
|
line2="$line2 ; do ktest-tool --write-ints"
|
||||||
line2="$line2 \"\$(printf '%s' \"\$t\" | sed -e 's@.[^/]*\$@.out@')\""
|
line2="$line2 \"\$(printf '%s' \"\$t\" | sed -e 's@\\.[^/]*\$@.ktest@')\""
|
||||||
line2="$line2 ; done"
|
line2="$line2 ; done"
|
||||||
printf '%s\n%s\n' "$line1" "$line2" | \
|
printf '%s\n%s\n' "$line1" "$line2" | \
|
||||||
docker run \
|
docker run \
|
||||||
|
@ -89,8 +89,6 @@ int main(const int argc, const char *const *const argv,
|
|||||||
kvi_init(pstate.reader.lines);
|
kvi_init(pstate.reader.lines);
|
||||||
|
|
||||||
const ExprAST ast = viml_pexpr_parse(&pstate, flags);
|
const ExprAST ast = viml_pexpr_parse(&pstate, flags);
|
||||||
assert(ast.root != NULL
|
|
||||||
|| plines[0].size == 0);
|
|
||||||
assert(ast.root != NULL || ast.err.msg);
|
assert(ast.root != NULL || ast.err.msg);
|
||||||
viml_pexpr_free_ast(ast);
|
viml_pexpr_free_ast(ast);
|
||||||
assert(allocated_memory == 0);
|
assert(allocated_memory == 0);
|
||||||
|
@ -6867,5 +6867,13 @@ describe('Expressions parser', function()
|
|||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
})
|
})
|
||||||
|
check_parsing('0', 0, {
|
||||||
|
-- 0
|
||||||
|
ast = {
|
||||||
|
'Integer(val=0):0:0:0',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
hl('Number', '0'),
|
||||||
|
})
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user