summaryrefslogtreecommitdiffstats
path: root/lib/libedit/key.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libedit/key.c')
-rw-r--r--lib/libedit/key.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/libedit/key.c b/lib/libedit/key.c
index 0b9d05d..5a0b779 100644
--- a/lib/libedit/key.c
+++ b/lib/libedit/key.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $NetBSD: key.c,v 1.19 2006/03/23 20:22:51 christos Exp $
+ * $NetBSD: key.c,v 1.20 2009/02/15 21:55:23 christos Exp $
*/
#if !defined(lint) && !defined(SCCSID)
@@ -86,8 +86,8 @@ private void node__free(key_node_t *);
private void node__put(EditLine *, key_node_t *);
private int node__delete(EditLine *, key_node_t **, const char *);
private int node_lookup(EditLine *, const char *, key_node_t *,
- int);
-private int node_enum(EditLine *, key_node_t *, int);
+ size_t);
+private int node_enum(EditLine *, key_node_t *, size_t);
#define KEY_BUFSIZ EL_BUFSIZ
@@ -478,9 +478,9 @@ node__free(key_node_t *k)
* Print if last node
*/
private int
-node_lookup(EditLine *el, const char *str, key_node_t *ptr, int cnt)
+node_lookup(EditLine *el, const char *str, key_node_t *ptr, size_t cnt)
{
- int ncnt;
+ size_t ncnt;
if (ptr == NULL)
return (-1); /* cannot have null ptr */
@@ -493,7 +493,8 @@ node_lookup(EditLine *el, const char *str, key_node_t *ptr, int cnt)
/* If match put this char into el->el_key.buf. Recurse */
if (ptr->ch == *str) {
/* match found */
- ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt,
+ ncnt = key__decode_char(el->el_key.buf,
+ (size_t)KEY_BUFSIZ, cnt,
(unsigned char) ptr->ch);
if (ptr->next != NULL)
/* not yet at leaf */
@@ -527,9 +528,9 @@ node_lookup(EditLine *el, const char *str, key_node_t *ptr, int cnt)
* Traverse the node printing the characters it is bound in buffer
*/
private int
-node_enum(EditLine *el, key_node_t *ptr, int cnt)
+node_enum(EditLine *el, key_node_t *ptr, size_t cnt)
{
- int ncnt;
+ size_t ncnt;
if (cnt >= KEY_BUFSIZ - 5) { /* buffer too small */
el->el_key.buf[++cnt] = '"';
@@ -547,7 +548,7 @@ node_enum(EditLine *el, key_node_t *ptr, int cnt)
return (-1);
}
/* put this char at end of str */
- ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt,
+ ncnt = key__decode_char(el->el_key.buf, (size_t)KEY_BUFSIZ, cnt,
(unsigned char)ptr->ch);
if (ptr->next == NULL) {
/* print this key and function */
@@ -615,8 +616,8 @@ key_kprint(EditLine *el, const char *key, key_value_t *val, int ntype)
/* key__decode_char():
* Put a printable form of char in buf.
*/
-protected int
-key__decode_char(char *buf, int cnt, int off, int ch)
+protected size_t
+key__decode_char(char *buf, size_t cnt, size_t off, int ch)
{
char *sb = buf + off;
char *eb = buf + cnt;
@@ -626,7 +627,7 @@ key__decode_char(char *buf, int cnt, int off, int ch)
if (ch == 0) {
ADDC('^');
ADDC('@');
- return b - sb;
+ return (int)(b - sb);
}
if (iscntrl(ch)) {
ADDC('^');
@@ -648,15 +649,15 @@ key__decode_char(char *buf, int cnt, int off, int ch)
ADDC((((unsigned int) ch >> 3) & 7) + '0');
ADDC((ch & 7) + '0');
}
- return b - sb;
+ return (size_t)(b - sb);
}
/* key__decode_str():
* Make a printable version of the ey
*/
-protected int
-key__decode_str(const char *str, char *buf, int len, const char *sep)
+protected size_t
+key__decode_str(const char *str, char *buf, size_t len, const char *sep)
{
char *b = buf, *eb = b + len;
const char *p;
@@ -699,7 +700,7 @@ key__decode_str(const char *str, char *buf, int len, const char *sep)
}
done:
ADDC('\0');
- if (b - buf >= len)
+ if ((size_t)(b - buf) >= len)
buf[len - 1] = '\0';
- return b - buf;
+ return (size_t)(b - buf);
}
OpenPOWER on IntegriCloud