Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit re-enable -Wconversion



details:   https://anonhg.NetBSD.org/src/rev/d22bc182cdfd
branches:  trunk
changeset: 768432:d22bc182cdfd
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Aug 16 16:25:15 2011 +0000

description:
re-enable -Wconversion

diffstat:

 lib/libedit/Makefile       |   4 +---
 lib/libedit/chared.c       |  16 ++++++++--------
 lib/libedit/chartype.c     |  14 +++++++-------
 lib/libedit/eln.c          |  10 +++++-----
 lib/libedit/filecomplete.c |  23 +++++++++++++----------
 lib/libedit/keymacro.c     |  14 +++++++-------
 lib/libedit/map.c          |  12 ++++++------
 lib/libedit/parse.c        |  10 +++++-----
 lib/libedit/read.c         |   8 ++++----
 lib/libedit/readline.c     |  34 +++++++++++++++++-----------------
 lib/libedit/search.c       |  18 ++++++++++--------
 lib/libedit/terminal.c     |  17 +++++++++--------
 lib/libedit/tokenizer.c    |  16 ++++++++--------
 lib/libedit/tty.c          |  13 +++++++------
 lib/libedit/tty.h          |   4 ++--
 lib/libedit/vi.c           |   8 ++++----
 16 files changed, 113 insertions(+), 108 deletions(-)

diffs (truncated from 894 to 300 lines):

diff -r 8794e0b0457a -r d22bc182cdfd lib/libedit/Makefile
--- a/lib/libedit/Makefile      Tue Aug 16 14:29:16 2011 +0000
+++ b/lib/libedit/Makefile      Tue Aug 16 16:25:15 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.48 2011/08/02 17:22:02 joerg Exp $
+#      $NetBSD: Makefile,v 1.49 2011/08/16 16:25:15 christos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=  yes
@@ -12,9 +12,7 @@
 .include "bsd.own.mk"
 
 COPTS+=        -Wunused-parameter
-.if defined(HAVE_GCC) && ${HAVE_GCC} != 45
 CWARNFLAGS.gcc+=       -Wconversion
-.endif
 
 OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
        hist.c keymacro.c map.c chartype.c \
diff -r 8794e0b0457a -r d22bc182cdfd lib/libedit/chared.c
--- a/lib/libedit/chared.c      Tue Aug 16 14:29:16 2011 +0000
+++ b/lib/libedit/chared.c      Tue Aug 16 16:25:15 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chared.c,v 1.34 2011/07/29 23:44:44 christos Exp $     */
+/*     $NetBSD: chared.c,v 1.35 2011/08/16 16:25:15 christos Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)chared.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: chared.c,v 1.34 2011/07/29 23:44:44 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.35 2011/08/16 16:25:15 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -63,8 +63,8 @@
        size_t size;
 
        /* Save entire line for undo */
-       size = el->el_line.lastchar - el->el_line.buffer;
-       vu->len = size;
+       size = (size_t)(el->el_line.lastchar - el->el_line.buffer);
+       vu->len = (ssize_t)size;
        vu->cursor = (int)(el->el_line.cursor - el->el_line.buffer);
        (void)memcpy(vu->buf, el->el_line.buffer, size * sizeof(*vu->buf));
 
@@ -84,7 +84,7 @@
 {
        c_kill_t *k = &el->el_chared.c_kill;
 
-       (void)memcpy(k->buf, ptr, size * sizeof(*k->buf));
+       (void)memcpy(k->buf, ptr, (size_t)size * sizeof(*k->buf));
        k->last = k->buf + size;
 }
 
@@ -500,7 +500,7 @@
        size_t sz, newsz;
        Char *newbuffer, *oldbuf, *oldkbuf;
 
-       sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE;
+       sz = (size_t)(el->el_line.limit - el->el_line.buffer + EL_LEAVE);
        newsz = sz * 2;
        /*
         * If newly required length is longer than current buffer, we need
@@ -655,8 +655,8 @@
        Char *cp = el->el_line.buffer;
 
        if (prompt) {
-               len = Strlen(prompt);
-               (void)memcpy(cp, prompt, len * sizeof(*cp));
+               len = (ssize_t)Strlen(prompt);
+               (void)memcpy(cp, prompt, (size_t)len * sizeof(*cp));
                cp += len;
        }
        len = 0;
diff -r 8794e0b0457a -r d22bc182cdfd lib/libedit/chartype.c
--- a/lib/libedit/chartype.c    Tue Aug 16 14:29:16 2011 +0000
+++ b/lib/libedit/chartype.c    Tue Aug 16 16:25:15 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chartype.c,v 1.9 2011/07/29 23:44:44 christos Exp $    */
+/*     $NetBSD: chartype.c,v 1.10 2011/08/16 16:25:15 christos Exp $   */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.9 2011/07/29 23:44:44 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.10 2011/08/16 16:25:15 christos Exp $");
 #endif /* not lint && not SCCSID */
 #include "el.h"
 #include <stdlib.h>
@@ -89,7 +89,7 @@
 
        dst = conv->cbuff;
        while (*s) {
-               used = conv->csize - (dst - conv->cbuff);
+               used = (ssize_t)(conv->csize - (size_t)(dst - conv->cbuff));
                if (used < 5) {
                        used = dst - conv->cbuff;
                        ct_conv_buff_resize(conv, conv->csize + CT_BUFSIZ,
@@ -149,7 +149,7 @@
        if (!conv->wsize)
                return NULL;
 
-       wargv = el_malloc(argc * sizeof(*wargv));
+       wargv = el_malloc((size_t)argc * sizeof(*wargv));
 
        for (i = 0, p = conv->wbuff; i < argc; ++i) {
                if (!argv[i]) {   /* don't pass null pointers to mbstowcs */
@@ -157,14 +157,14 @@
                        continue;
                } else {
                        wargv[i] = p;
-                       bytes = mbstowcs(p, argv[i], bufspace);
+                       bytes = (ssize_t)mbstowcs(p, argv[i], bufspace);
                }
                if (bytes == -1) {
                        el_free(wargv);
                        return NULL;
                } else
                        bytes++;  /* include '\0' in the count */
-               bufspace -= bytes;
+               bufspace -= (size_t)bytes;
                p += bytes;
        }
 
@@ -221,7 +221,7 @@
        }
        dst = buff;
        while (*s) {
-               used = ct_visual_char(dst, buffsize - (dst - buff), *s);
+               used = ct_visual_char(dst, buffsize - (size_t)(dst - buff), *s);
                if (used == -1) { /* failed to encode, need more buffer space */
                        used = dst - buff;
                        buffsize += CT_BUFSIZ;
diff -r 8794e0b0457a -r d22bc182cdfd lib/libedit/eln.c
--- a/lib/libedit/eln.c Tue Aug 16 14:29:16 2011 +0000
+++ b/lib/libedit/eln.c Tue Aug 16 16:25:15 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eln.c,v 1.12 2011/07/28 20:50:55 christos Exp $        */
+/*     $NetBSD: eln.c,v 1.13 2011/08/16 16:25:15 christos Exp $        */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.12 2011/07/28 20:50:55 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.13 2011/08/16 16:25:15 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include "histedit.h"
@@ -57,7 +57,7 @@
                el->el_flags &= ~IGNORE_EXTCHARS;
 
        if (num_read > 0)
-               *cp = (unsigned char)wc;
+               *cp = (char)wc;
        return num_read;
 }
 
@@ -237,7 +237,7 @@
        case EL_PROMPT_ESC: /* el_pfunc_t, char */
        case EL_RPROMPT_ESC: {
                el_pfunc_t p = va_arg(ap, el_pfunc_t);
-               char c = va_arg(ap, int);
+               char c = (char)va_arg(ap, int);
                ret = prompt_set(el, p, c, op, 0);
                break;
        }
@@ -277,7 +277,7 @@
                char *c = va_arg(ap, char *);
                wchar_t wc = 0;
                ret = prompt_get(el, p, &wc, op);
-               *c = (unsigned char)wc;
+               *c = (char)wc;
                break;
        }
 
diff -r 8794e0b0457a -r d22bc182cdfd lib/libedit/filecomplete.c
--- a/lib/libedit/filecomplete.c        Tue Aug 16 14:29:16 2011 +0000
+++ b/lib/libedit/filecomplete.c        Tue Aug 16 16:25:15 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecomplete.c,v 1.29 2011/07/29 23:44:44 christos Exp $       */
+/*     $NetBSD: filecomplete.c,v 1.30 2011/08/16 16:25:15 christos Exp $       */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.29 2011/07/29 23:44:44 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.30 2011/08/16 16:25:15 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -86,7 +86,8 @@
                if (temp == NULL)
                        return NULL;
        } else {
-               len = temp - txt + 1;   /* text until string after slash */
+               /* text until string after slash */
+               len = (size_t)(temp - txt + 1);
                temp = el_malloc(len * sizeof(*temp));
                if (temp == NULL)
                        return NULL;
@@ -162,7 +163,7 @@
                        }
                        filename = nptr;
                        (void)strcpy(filename, temp);
-                       len = temp - text;      /* including last slash */
+                       len = (size_t)(temp - text);    /* including last slash */
 
                        nptr = el_realloc(dirname, (len + 1) *
                            sizeof(*nptr));
@@ -371,7 +372,7 @@
         * Find out how many entries can be put on one line; count
         * with one space between strings the same way it's printed.
         */
-       cols = screenwidth / (width + 1);
+       cols = (size_t)screenwidth / (width + 1);
        if (cols == 0)
                cols = 1;
 
@@ -444,7 +445,7 @@
            && (!special_prefixes || !Strchr(special_prefixes, ctemp[-1]) ) )
                ctemp--;
 
-       len = li->cursor - ctemp;
+       len = (size_t)(li->cursor - ctemp);
        temp = el_malloc((len + 1) * sizeof(*temp));
        (void)Strncpy(temp, ctemp, len);
        temp[len] = '\0';
@@ -458,13 +459,15 @@
 
        if (attempted_completion_function) {
                int cur_off = (int)(li->cursor - li->buffer);
-               matches = (*attempted_completion_function) (ct_encode_string(temp, &el->el_scratch),
-                   (int)(cur_off - len), cur_off);
+               matches = (*attempted_completion_function)(
+                   ct_encode_string(temp, &el->el_scratch),
+                   cur_off - (int)len, cur_off);
        } else
                matches = 0;
        if (!attempted_completion_function || 
            (over != NULL && !*over && !matches))
-               matches = completion_matches(ct_encode_string(temp, &el->el_scratch), complet_func);
+               matches = completion_matches(
+                   ct_encode_string(temp, &el->el_scratch), complet_func);
 
        if (over != NULL)
                *over = 0;
@@ -509,7 +512,7 @@
                                        maxlen = match_len;
                        }
                        /* matches[1] through matches[i-1] are available */
-                       matches_num = i - 1;
+                       matches_num = (size_t)(i - 1);
                                
                        /* newline to get on next line from command line */
                        (void)fprintf(el->el_outfile, "\n");
diff -r 8794e0b0457a -r d22bc182cdfd lib/libedit/keymacro.c
--- a/lib/libedit/keymacro.c    Tue Aug 16 14:29:16 2011 +0000
+++ b/lib/libedit/keymacro.c    Tue Aug 16 16:25:15 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: keymacro.c,v 1.6 2011/07/29 23:44:44 christos Exp $    */
+/*     $NetBSD: keymacro.c,v 1.7 2011/08/16 16:25:15 christos Exp $    */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)key.c      8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: keymacro.c,v 1.6 2011/07/29 23:44:44 christos Exp $");
+__RCSID("$NetBSD: keymacro.c,v 1.7 2011/08/16 16:25:15 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -510,11 +510,11 @@
                        if (ptr->next != NULL)
                                /* not yet at leaf */
                                return (node_lookup(el, str + 1, ptr->next,
-                                   used + cnt));
+                                   (size_t)used + cnt));
                        else {
                            /* next node is null so key should be complete */
                                if (str[1] == 0) {
-                                       size_t px = cnt + used;
+                                       size_t px = cnt + (size_t)used;
                                        el->el_keymacro.buf[px] = '"';
                                        el->el_keymacro.buf[px + 1] = '\0';
                                        keymacro_kprint(el, el->el_keymacro.buf,
@@ -565,11 +565,11 @@



Home | Main Index | Thread Index | Old Index