diff options
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r-- | libbb/lineedit.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 2566abd38..34eb16e6b 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -81,7 +81,9 @@ | |||
81 | # define CHAR_T wchar_t | 81 | # define CHAR_T wchar_t |
82 | static bool BB_isspace(CHAR_T c) { return ((unsigned)c < 256 && isspace(c)); } | 82 | static bool BB_isspace(CHAR_T c) { return ((unsigned)c < 256 && isspace(c)); } |
83 | # if ENABLE_FEATURE_EDITING_VI | 83 | # if ENABLE_FEATURE_EDITING_VI |
84 | static bool BB_isalnum(CHAR_T c) { return ((unsigned)c < 256 && isalnum(c)); } | 84 | static bool BB_isalnum_or_underscore(CHAR_T c) { |
85 | return ((unsigned)c < 256 && isalnum(c)) || c == '_'; | ||
86 | } | ||
85 | # endif | 87 | # endif |
86 | static bool BB_ispunct(CHAR_T c) { return ((unsigned)c < 256 && ispunct(c)); } | 88 | static bool BB_ispunct(CHAR_T c) { return ((unsigned)c < 256 && ispunct(c)); } |
87 | # undef isspace | 89 | # undef isspace |
@@ -96,7 +98,11 @@ static bool BB_ispunct(CHAR_T c) { return ((unsigned)c < 256 && ispunct(c)); } | |||
96 | # define BB_NUL '\0' | 98 | # define BB_NUL '\0' |
97 | # define CHAR_T char | 99 | # define CHAR_T char |
98 | # define BB_isspace(c) isspace(c) | 100 | # define BB_isspace(c) isspace(c) |
99 | # define BB_isalnum(c) isalnum(c) | 101 | # if ENABLE_FEATURE_EDITING_VI |
102 | static bool BB_isalnum_or_underscore(CHAR_T c) { | ||
103 | return ((unsigned)c < 256 && isalnum(c)) || c == '_'; | ||
104 | } | ||
105 | # endif | ||
100 | # define BB_ispunct(c) ispunct(c) | 106 | # define BB_ispunct(c) ispunct(c) |
101 | #endif | 107 | #endif |
102 | #if ENABLE_UNICODE_PRESERVE_BROKEN | 108 | #if ENABLE_UNICODE_PRESERVE_BROKEN |
@@ -1647,9 +1653,9 @@ vi_word_motion(int eat) | |||
1647 | { | 1653 | { |
1648 | CHAR_T *command = command_ps; | 1654 | CHAR_T *command = command_ps; |
1649 | 1655 | ||
1650 | if (BB_isalnum(command[cursor]) || command[cursor] == '_') { | 1656 | if (BB_isalnum_or_underscore(command[cursor])) { |
1651 | while (cursor < command_len | 1657 | while (cursor < command_len |
1652 | && (BB_isalnum(command[cursor+1]) || command[cursor+1] == '_') | 1658 | && (BB_isalnum_or_underscore(command[cursor+1])) |
1653 | ) { | 1659 | ) { |
1654 | input_forward(); | 1660 | input_forward(); |
1655 | } | 1661 | } |
@@ -1691,9 +1697,9 @@ vi_end_motion(void) | |||
1691 | input_forward(); | 1697 | input_forward(); |
1692 | if (cursor >= command_len-1) | 1698 | if (cursor >= command_len-1) |
1693 | return; | 1699 | return; |
1694 | if (BB_isalnum(command[cursor]) || command[cursor] == '_') { | 1700 | if (BB_isalnum_or_underscore(command[cursor])) { |
1695 | while (cursor < command_len-1 | 1701 | while (cursor < command_len-1 |
1696 | && (BB_isalnum(command[cursor+1]) || command[cursor+1] == '_') | 1702 | && (BB_isalnum_or_underscore(command[cursor+1])) |
1697 | ) { | 1703 | ) { |
1698 | input_forward(); | 1704 | input_forward(); |
1699 | } | 1705 | } |
@@ -1726,9 +1732,9 @@ vi_back_motion(void) | |||
1726 | input_backward(1); | 1732 | input_backward(1); |
1727 | if (cursor <= 0) | 1733 | if (cursor <= 0) |
1728 | return; | 1734 | return; |
1729 | if (BB_isalnum(command[cursor]) || command[cursor] == '_') { | 1735 | if (BB_isalnum_or_underscore(command[cursor])) { |
1730 | while (cursor > 0 | 1736 | while (cursor > 0 |
1731 | && (BB_isalnum(command[cursor-1]) || command[cursor-1] == '_') | 1737 | && (BB_isalnum_or_underscore(command[cursor-1])) |
1732 | ) { | 1738 | ) { |
1733 | input_backward(1); | 1739 | input_backward(1); |
1734 | } | 1740 | } |