forked from espressif/esp-idf
Added Kconfig for enabling 0 length returns from linenoise
This commit is contained in:
committed by
Ivan Grokhotkov
parent
8a2413b5c0
commit
c34352549a
10
components/console/Kconfig
Normal file
10
components/console/Kconfig
Normal file
@@ -0,0 +1,10 @@
|
||||
menu "Linenoise"
|
||||
|
||||
config ESP_LINENOISE_RETURN_ZERO_STRING
|
||||
bool "Return 0 length strings"
|
||||
default n
|
||||
help
|
||||
If enabled linenoise will return 0 length strings if the user presses enter with out typing
|
||||
a command, if disabled NULL will be returned instead.
|
||||
|
||||
endmenu
|
@@ -116,6 +116,7 @@
|
||||
#include <sys/fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "linenoise.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
|
||||
#define LINENOISE_MAX_LINE 4096
|
||||
@@ -979,11 +980,14 @@ char *linenoise(const char *prompt) {
|
||||
} else {
|
||||
count = linenoiseDumb(buf, LINENOISE_MAX_LINE, prompt);
|
||||
}
|
||||
#ifdef CONFIG_ESP_LINENOISE_RETURN_ZERO_STRING
|
||||
if (count >= 0) {
|
||||
#else
|
||||
if (count > 0) {
|
||||
#endif
|
||||
sanitize(buf);
|
||||
count = strlen(buf);
|
||||
}
|
||||
if (count < 0) {
|
||||
} else {
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user