diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-11-28 23:58:55 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-12-21 21:45:09 +1000 |
commit | f40d96ffab79adb44f6e78a81224efd2bb236062 (patch) | |
tree | 522758099a88035fd54cf5fb4d3f9caeab10bca4 | |
parent | 0475c46a5dcba6913213f63ffdddbbe49ee06146 (diff) | |
download | jimtcl-f40d96ffab79adb44f6e78a81224efd2bb236062.zip jimtcl-f40d96ffab79adb44f6e78a81224efd2bb236062.tar.gz jimtcl-f40d96ffab79adb44f6e78a81224efd2bb236062.tar.bz2 |
Minor compiler warning fixes
Also, don't define _XOPEN_SOURCE if already defined
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim-clock.c | 2 | ||||
-rw-r--r-- | jim.c | 4 | ||||
-rw-r--r-- | linenoise.c | 13 |
3 files changed, 12 insertions, 7 deletions
diff --git a/jim-clock.c b/jim-clock.c index b342f31..f51b14b 100644 --- a/jim-clock.c +++ b/jim-clock.c @@ -6,7 +6,9 @@ */ /* For strptime() */ +#ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 500 +#endif #include <stdlib.h> #include <string.h> @@ -4619,7 +4619,7 @@ void Jim_FreeInterp(Jim_Interp *i) const char *type = objPtr->typePtr ? objPtr->typePtr->name : "string"; printf("%p (%d) %-10s: '%.20s'" JIM_NL, - objPtr, objPtr->refCount, type, objPtr->bytes ? objPtr->bytes : "(null)"); + (void *)objPtr, objPtr->refCount, type, objPtr->bytes ? objPtr->bytes : "(null)"); if (objPtr->typePtr == &sourceObjType) { printf("FILE %s LINE %d" JIM_NL, objPtr->internalRep.sourceValue.fileName, @@ -10353,7 +10353,7 @@ static int JimInfoLevel(Jim_Interp *interp, Jim_Obj *levelObjPtr, Jim_ListAppendElement(interp, listObj, targetCallFrame->argv[0]); Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, - targetCallFrame->filename ? : "", -1)); + targetCallFrame->filename ? targetCallFrame->filename : "", -1)); Jim_ListAppendElement(interp, listObj, Jim_NewIntObj(interp, targetCallFrame->line)); *objPtrPtr = listObj; } diff --git a/linenoise.c b/linenoise.c index 2c83960..038756b 100644 --- a/linenoise.c +++ b/linenoise.c @@ -189,6 +189,9 @@ struct current { int cols; /* Size of the window, in chars */ }; +/* gcc/glibc insists that we care about the return code of write! */ +#define IGNORE_RC(EXPR) ((EXPR) < 0 ? -1 : 0) + /* This is fd_printf() on some systems, but use a different * name to avoid conflicts */ @@ -201,7 +204,7 @@ static void fd_printf(int fd, const char *format, ...) va_start(args, format); n = vsnprintf(buf, sizeof(buf), format, args); va_end(args); - write(fd, buf, n); + IGNORE_RC(write(fd, buf, n)); } @@ -224,7 +227,7 @@ static int get_char(struct current *current, int pos) if (pos >= 0 && pos < current->chars) { int c; int i = utf8_index(current->buf, pos); - utf8_tounicode(current->buf + i, &c); + (void)utf8_tounicode(current->buf + i, &c); return c; } return -1; @@ -285,7 +288,7 @@ static void refreshLine(const char *prompt, struct current *current) { /* Cursor to left edge, then the prompt */ fd_printf(current->fd, "\x1b[0G"); - write(current->fd, prompt, plen); + IGNORE_RC(write(current->fd, prompt, plen)); /* Now the current buffer content */ @@ -305,7 +308,7 @@ static void refreshLine(const char *prompt, struct current *current) { } if (ch < ' ') { /* A control character, so write the buffer so far */ - write(current->fd, buf, b); + IGNORE_RC(write(current->fd, buf, b)); buf += b + w; b = 0; fd_printf(current->fd, "\033[7m^%c\033[0m", ch + '@'); @@ -317,7 +320,7 @@ static void refreshLine(const char *prompt, struct current *current) { b += w; } } - write(current->fd, buf, b); + IGNORE_RC(write(current->fd, buf, b)); /* Erase to right, move cursor to original position */ fd_printf(current->fd, "\x1b[0K" "\x1b[0G\x1b[%dC", pos + pchars + backup); |