diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/lineedit.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 27c1f3a74..4802b46b4 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -1249,6 +1249,9 @@ static NOINLINE void input_tab(smallint *lastWasTab) | |||
1249 | size_t len_found; | 1249 | size_t len_found; |
1250 | /* Length of string used for matching */ | 1250 | /* Length of string used for matching */ |
1251 | unsigned match_pfx_len = match_pfx_len; | 1251 | unsigned match_pfx_len = match_pfx_len; |
1252 | #if ENABLE_PLATFORM_MINGW32 | ||
1253 | unsigned orig_pfx_len; | ||
1254 | #endif | ||
1252 | int find_type; | 1255 | int find_type; |
1253 | # if ENABLE_UNICODE_SUPPORT | 1256 | # if ENABLE_UNICODE_SUPPORT |
1254 | /* cursor pos in command converted to multibyte form */ | 1257 | /* cursor pos in command converted to multibyte form */ |
@@ -1313,6 +1316,9 @@ static NOINLINE void input_tab(smallint *lastWasTab) | |||
1313 | { | 1316 | { |
1314 | const char *e = match_buf + strlen(match_buf); | 1317 | const char *e = match_buf + strlen(match_buf); |
1315 | const char *s = e - match_pfx_len; | 1318 | const char *s = e - match_pfx_len; |
1319 | #if ENABLE_PLATFORM_MINGW32 | ||
1320 | orig_pfx_len = match_pfx_len; | ||
1321 | #endif | ||
1316 | while (s < e) | 1322 | while (s < e) |
1317 | if (is_special_char(*s++)) | 1323 | if (is_special_char(*s++)) |
1318 | match_pfx_len++; | 1324 | match_pfx_len++; |
@@ -1388,10 +1394,12 @@ static NOINLINE void input_tab(smallint *lastWasTab) | |||
1388 | strcpy(match_buf, &command_ps[cursor]); | 1394 | strcpy(match_buf, &command_ps[cursor]); |
1389 | /* add match and tail */ | 1395 | /* add match and tail */ |
1390 | #if ENABLE_PLATFORM_MINGW32 | 1396 | #if ENABLE_PLATFORM_MINGW32 |
1391 | sprintf(&command_ps[cursor-match_pfx_len], "%s%s", chosen_match, match_buf); | 1397 | if (match_pfx_len == orig_pfx_len) { |
1392 | #else | 1398 | sprintf(&command_ps[cursor-match_pfx_len], "%s%s", |
1393 | sprintf(&command_ps[cursor], "%s%s", chosen_match + match_pfx_len, match_buf); | 1399 | chosen_match, match_buf); |
1400 | } else | ||
1394 | #endif | 1401 | #endif |
1402 | sprintf(&command_ps[cursor], "%s%s", chosen_match + match_pfx_len, match_buf); | ||
1395 | command_len = strlen(command_ps); | 1403 | command_len = strlen(command_ps); |
1396 | /* new pos */ | 1404 | /* new pos */ |
1397 | pos = cursor + len_found - match_pfx_len; | 1405 | pos = cursor + len_found - match_pfx_len; |