From b01b57f3c5caf03f405e386fae809948a5a7f5c6 Mon Sep 17 00:00:00 2001 From: Cliff Yapp <238416+starseeker@users.noreply.github.com> Date: Wed, 11 Mar 2020 07:46:02 -0400 Subject: [PATCH] Clear some warnings and errors with GCC and MSVC. --- Makefile | 2 +- example.c | 2 ++ linenoise.c | 26 +++++++++++++++----------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index f4638e2..1aa01ec 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CFLAGS += -Wall -W -Os -g -Wno-unused-parameter +CFLAGS += -Wall -W -Os -g CC ?= gcc all: linenoise_example linenoise_utf8_example diff --git a/example.c b/example.c index 971ac31..ea3a993 100644 --- a/example.c +++ b/example.c @@ -5,6 +5,7 @@ #ifndef NO_COMPLETION void completion(const char *buf, linenoiseCompletions *lc, void *userdata) { + (void)userdata; if (buf[0] == 'h') { linenoiseAddCompletion(lc,"hello"); linenoiseAddCompletion(lc,"hello there"); @@ -12,6 +13,7 @@ void completion(const char *buf, linenoiseCompletions *lc, void *userdata) { } char *hints(const char *buf, int *color, int *bold, void *userdata) { + (void)userdata; if (!strcasecmp(buf,"hello")) { *color = 35; *bold = 0; diff --git a/linenoise.c b/linenoise.c index c552075..ec1be46 100644 --- a/linenoise.c +++ b/linenoise.c @@ -227,15 +227,17 @@ void linenoiseHistoryFree(void) { } } +typedef enum { + EP_START, /* looking for ESC */ + EP_ESC, /* looking for [ */ + EP_DIGITS, /* parsing digits */ + EP_PROPS, /* parsing digits or semicolons */ + EP_END, /* ok */ + EP_ERROR, /* error */ +} ep_state_t; + struct esc_parser { - enum { - EP_START, /* looking for ESC */ - EP_ESC, /* looking for [ */ - EP_DIGITS, /* parsing digits */ - EP_PROPS, /* parsing digits or semicolons */ - EP_END, /* ok */ - EP_ERROR, /* error */ - } state; + ep_state_t state; int props[5]; /* properties are stored here */ int maxprops; /* size of the props[] array */ int numprops; /* number of properties found */ @@ -342,7 +344,7 @@ static void DRL_STR(const char *str) } } #else -#define DRL(ARGS...) +#define DRL(...) #define DRL_CHAR(ch) #define DRL_STR(str) #endif @@ -1016,6 +1018,7 @@ static void refreshEnd(struct current *current) static void refreshStartChars(struct current *current) { + (void)current; } static void refreshNewline(struct current *current) @@ -1026,6 +1029,7 @@ static void refreshNewline(struct current *current) static void refreshEndChars(struct current *current) { + (void)current; } #endif @@ -1463,8 +1467,8 @@ static int reverseIncrementalSearch(struct current *current) c = fd_read(current); if (c == ctrl('H') || c == CHAR_DELETE) { if (rchars) { - int p = utf8_index(rbuf, --rchars); - rbuf[p] = 0; + int p_ind = utf8_index(rbuf, --rchars); + rbuf[p_ind] = 0; rlen = strlen(rbuf); } continue; -- 2.44.0