]> git.lizzy.rs Git - linenoise.git/commitdiff
Clear some warnings and errors with GCC and MSVC.
authorCliff Yapp <238416+starseeker@users.noreply.github.com>
Wed, 11 Mar 2020 11:46:02 +0000 (07:46 -0400)
committerSteve Bennett <steveb@workware.net.au>
Thu, 12 Mar 2020 12:18:24 +0000 (22:18 +1000)
Makefile
example.c
linenoise.c

index f4638e2d74d05aaf45f65641c31de5d9388d3907..1aa01ecf53627e916bb71b8b7ba5cb3ead337bce 100644 (file)
--- 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
index 971ac31def48e6ba975537360217f32cf795626b..ea3a9937e1acc9418009ff3323497bc5eaecc0ca 100644 (file)
--- 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;
index c5520754950a377c612e6405436f31c61bbe8cf3..ec1be46b78d98abf2d99fbd31cbd9b5849d3128f 100644 (file)
@@ -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;