Deleted Added
full compact
0a1,2
> /* $NetBSD: chared.c,v 1.40 2014/06/18 18:12:28 christos Exp $ */
>
31,32d32
< *
< * $NetBSD: chared.c,v 1.27 2009/02/15 21:55:23 christos Exp $
34a35
> #include "config.h"
35a37
> #if 0
36a39,41
> #else
> __RCSID("$NetBSD: chared.c,v 1.40 2014/06/18 18:12:28 christos Exp $");
> #endif
39c44
< __FBSDID("$FreeBSD: head/lib/libedit/chared.c 238178 2012-07-06 19:30:50Z pfg $");
---
> __FBSDID("$FreeBSD: head/lib/libedit/chared.c 276881 2015-01-09 07:40:56Z bapt $");
44,45d48
< #include "sys.h"
<
49c52
< private void ch__clearmacro(EditLine *);
---
> private void ch__clearmacro (EditLine *);
65,66c68,69
< 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;
68c71
< memcpy(vu->buf, el->el_line.buffer, size);
---
> (void)memcpy(vu->buf, el->el_line.buffer, size * sizeof(*vu->buf));
82c85
< cv_yank(EditLine *el, const char *ptr, int size)
---
> cv_yank(EditLine *el, const Char *ptr, int size)
86c89
< memcpy(k->buf, ptr, (size_t)size);
---
> (void)memcpy(k->buf, ptr, (size_t)size * sizeof(*k->buf));
97c100
< char *cp;
---
> Char *cp;
129c132
< char *cp;
---
> Char *cp;
145c148
< char *cp;
---
> Char *cp;
170c173
< char *cp;
---
> Char *cp;
188c191
< char *cp;
---
> Char *cp;
201c204
< ce__isword(int p)
---
> ce__isword(Int p)
203c206
< return (isalnum(p) || strchr("*?_-.[]~=", p) != NULL);
---
> return Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL;
211c214
< cv__isword(int p)
---
> cv__isword(Int p)
213c216
< if (isalnum(p) || p == '_')
---
> if (Isalnum(p) || p == '_')
215c218
< if (isgraph(p))
---
> if (Isgraph(p))
225c228
< cv__isWord(int p)
---
> cv__isWord(Int p)
227c230
< return (!isspace(p));
---
> return !Isspace(p);
234,235c237,238
< protected char *
< c__prev_word(char *p, char *low, int n, int (*wtest)(int))
---
> protected Char *
> c__prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
240c243
< while ((p >= low) && !(*wtest)((unsigned char) *p))
---
> while ((p >= low) && !(*wtest)(*p))
242c245
< while ((p >= low) && (*wtest)((unsigned char) *p))
---
> while ((p >= low) && (*wtest)(*p))
251c254
< return (p);
---
> return p;
258,259c261,262
< protected char *
< c__next_word(char *p, char *high, int n, int (*wtest)(int))
---
> protected Char *
> c__next_word(Char *p, Char *high, int n, int (*wtest)(Int))
262c265
< while ((p < high) && !(*wtest)((unsigned char) *p))
---
> while ((p < high) && !(*wtest)(*p))
264c267
< while ((p < high) && (*wtest)((unsigned char) *p))
---
> while ((p < high) && (*wtest)(*p))
270c273
< return (p);
---
> return p;
276,277c279,280
< protected char *
< cv_next_word(EditLine *el, char *p, char *high, int n, int (*wtest)(int))
---
> protected Char *
> cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(Int))
282,283c285,286
< test = (*wtest)((unsigned char) *p);
< while ((p < high) && (*wtest)((unsigned char) *p) == test)
---
> test = (*wtest)(*p);
> while ((p < high) && (*wtest)(*p) == test)
290c293
< while ((p < high) && isspace((unsigned char) *p))
---
> while ((p < high) && Isspace(*p))
296c299
< return (high);
---
> return high;
298c301
< return (p);
---
> return p;
305,306c308,309
< protected char *
< cv_prev_word(char *p, char *low, int n, int (*wtest)(int))
---
> protected Char *
> cv_prev_word(Char *p, Char *low, int n, int (*wtest)(Int))
312c315
< while ((p > low) && isspace((unsigned char) *p))
---
> while ((p > low) && Isspace(*p))
314,315c317,318
< test = (*wtest)((unsigned char) *p);
< while ((p >= low) && (*wtest)((unsigned char) *p) == test)
---
> test = (*wtest)(*p);
> while ((p >= low) && (*wtest)(*p) == test)
322c325
< return (low);
---
> return low;
324c327
< return (p);
---
> return p;
328,361d330
< #ifdef notdef
< /* c__number():
< * Ignore character p points to, return number appearing after that.
< * A '$' by itself means a big number; "$-" is for negative; '^' means 1.
< * Return p pointing to last char used.
< */
< protected char *
< c__number(
< char *p, /* character position */
< int *num, /* Return value */
< int dval) /* dval is the number to subtract from like $-3 */
< {
< int i;
< int sign = 1;
<
< if (*++p == '^') {
< *num = 1;
< return (p);
< }
< if (*p == '$') {
< if (*++p != '-') {
< *num = 0x7fffffff; /* Handle $ */
< return (--p);
< }
< sign = -1; /* Handle $- */
< ++p;
< }
< for (i = 0; isdigit((unsigned char) *p); i = 10 * i + *p++ - '0')
< continue;
< *num = (sign < 0 ? dval - i : i);
< return (--p);
< }
< #endif
<
400,421d368
< #ifdef notdef
< /* ce__endword():
< * Go to the end of this word according to emacs
< */
< protected char *
< ce__endword(char *p, char *high, int n)
< {
< p++;
<
< while (n--) {
< while ((p < high) && isspace((unsigned char) *p))
< p++;
< while ((p < high) && !isspace((unsigned char) *p))
< p++;
< }
<
< p--;
< return (p);
< }
< #endif
<
<
425,426c372,373
< protected char *
< cv__endword(char *p, char *high, int n, int (*wtest)(int))
---
> protected Char *
> cv__endword(Char *p, Char *high, int n, int (*wtest)(Int))
433c380
< while ((p < high) && isspace((unsigned char) *p))
---
> while ((p < high) && Isspace(*p))
436,437c383,384
< test = (*wtest)((unsigned char) *p);
< while ((p < high) && (*wtest)((unsigned char) *p) == test)
---
> test = (*wtest)(*p);
> while ((p < high) && (*wtest)(*p) == test)
441c388
< return (p);
---
> return p;
452c399,400
< el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ);
---
> el->el_line.buffer = el_malloc(EL_BUFSIZ *
> sizeof(*el->el_line.buffer));
454c402
< return (-1);
---
> return -1;
456c404,405
< (void) memset(el->el_line.buffer, 0, EL_BUFSIZ);
---
> (void) memset(el->el_line.buffer, 0, EL_BUFSIZ *
> sizeof(*el->el_line.buffer));
461c410,411
< el->el_chared.c_undo.buf = (char *) el_malloc(EL_BUFSIZ);
---
> el->el_chared.c_undo.buf = el_malloc(EL_BUFSIZ *
> sizeof(*el->el_chared.c_undo.buf));
463,464c413,415
< return (-1);
< (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ);
---
> return -1;
> (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ *
> sizeof(*el->el_chared.c_undo.buf));
467c418,419
< el->el_chared.c_redo.buf = (char *) el_malloc(EL_BUFSIZ);
---
> el->el_chared.c_redo.buf = el_malloc(EL_BUFSIZ *
> sizeof(*el->el_chared.c_redo.buf));
469c421
< return (-1);
---
> return -1;
477c429,430
< el->el_chared.c_kill.buf = (char *) el_malloc(EL_BUFSIZ);
---
> el->el_chared.c_kill.buf = el_malloc(EL_BUFSIZ *
> sizeof(*el->el_chared.c_kill.buf));
479,480c432,434
< return (-1);
< (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ);
---
> return -1;
> (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ *
> sizeof(*el->el_chared.c_kill.buf));
482a437,440
> el->el_chared.c_resizefun = NULL;
> el->el_chared.c_resizearg = NULL;
> el->el_chared.c_aliasfun = NULL;
> el->el_chared.c_aliasarg = NULL;
494c452
< ma->macro = (char **) el_malloc(EL_MAXMACRO * sizeof(char *));
---
> ma->macro = el_malloc(EL_MAXMACRO * sizeof(*ma->macro));
496,497c454,455
< return (-1);
< return (0);
---
> return -1;
> return 0;
536c494
< el_free((ptr_t)ma->macro[ma->level--]);
---
> el_free(ma->macro[ma->level--]);
547c505
< char *newbuffer, *oldbuf, *oldkbuf;
---
> Char *newbuffer, *oldbuf, *oldkbuf;
549c507
< sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE;
---
> sz = (size_t)(el->el_line.limit - el->el_line.buffer + EL_LEAVE);
563c521
< newbuffer = el_realloc(el->el_line.buffer, newsz);
---
> newbuffer = el_realloc(el->el_line.buffer, newsz * sizeof(*newbuffer));
568c526
< (void) memset(&newbuffer[sz], 0, newsz - sz);
---
> (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer));
581c539,540
< newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz);
---
> newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz *
> sizeof(*newbuffer));
586c545
< (void) memset(&newbuffer[sz], 0, newsz - sz);
---
> (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer));
599c558,559
< newbuffer = el_realloc(el->el_chared.c_undo.buf, newsz);
---
> newbuffer = el_realloc(el->el_chared.c_undo.buf,
> newsz * sizeof(*newbuffer));
604c564
< (void) memset(&newbuffer[sz], 0, newsz - sz);
---
> (void) memset(&newbuffer[sz], 0, (newsz - sz) * sizeof(*newbuffer));
607c567,568
< newbuffer = el_realloc(el->el_chared.c_redo.buf, newsz);
---
> newbuffer = el_realloc(el->el_chared.c_redo.buf,
> newsz * sizeof(*newbuffer));
620a582,583
> if (el->el_chared.c_resizefun)
> (*el->el_chared.c_resizefun)(el, el->el_chared.c_resizearg);
630c593
< el_free((ptr_t) el->el_line.buffer);
---
> el_free(el->el_line.buffer);
633c596
< el_free((ptr_t) el->el_chared.c_undo.buf);
---
> el_free(el->el_chared.c_undo.buf);
635c598
< el_free((ptr_t) el->el_chared.c_redo.buf);
---
> el_free(el->el_chared.c_redo.buf);
640c603
< el_free((ptr_t) el->el_chared.c_kill.buf);
---
> el_free(el->el_chared.c_kill.buf);
643c606
< el_free((ptr_t) el->el_chared.c_macro.macro);
---
> el_free(el->el_chared.c_macro.macro);
652c615
< el_insertstr(EditLine *el, const char *s)
---
> FUN(el,insertstr)(EditLine *el, const Char *s)
656,657c619,620
< if ((len = strlen(s)) == 0)
< return (-1);
---
> if (s == NULL || (len = Strlen(s)) == 0)
> return -1;
660c623
< return (-1);
---
> return -1;
666c629
< return (0);
---
> return 0;
687a651,669
> /* el_cursor():
> * Move the cursor to the left or the right of the current position
> */
> public int
> el_cursor(EditLine *el, int n)
> {
> if (n == 0)
> goto out;
>
> el->el_line.cursor += n;
>
> if (el->el_line.cursor < el->el_line.buffer)
> el->el_line.cursor = el->el_line.buffer;
> if (el->el_line.cursor > el->el_line.lastchar)
> el->el_line.cursor = el->el_line.lastchar;
> out:
> return (int)(el->el_line.cursor - el->el_line.buffer);
> }
>
692c674
< c_gets(EditLine *el, char *buf, const char *prompt)
---
> c_gets(EditLine *el, Char *buf, const Char *prompt)
694c676
< char ch;
---
> Char ch;
696c678
< char *cp = el->el_line.buffer;
---
> Char *cp = el->el_line.buffer;
699,700c681,682
< len = strlen(prompt);
< memcpy(cp, prompt, (size_t)len);
---
> len = (ssize_t)Strlen(prompt);
> (void)memcpy(cp, prompt, (size_t)len * sizeof(*cp));
711c693
< if (el_getc(el, &ch) != 1) {
---
> if (FUN(el,getc)(el, &ch) != 1) {
719,720c701,702
< case '\010': /* Delete and backspace */
< case '\177':
---
> case 0010: /* Delete and backspace */
> case 0177:
728c710
< case '\033': /* ESC */
---
> case 0033: /* ESC */
735,736c717,718
< if (len >= EL_BUFSIZ - 16)
< term_beep(el);
---
> if (len >= (ssize_t)(EL_BUFSIZ - 16))
> terminal_beep(el);
759c741
< char *ptr;
---
> Char *ptr;
765c747
< return (0);
---
> return 0;
773a756,771
>
> protected int
> ch_resizefun(EditLine *el, el_zfunc_t f, void *a)
> {
> el->el_chared.c_resizefun = f;
> el->el_chared.c_resizearg = a;
> return 0;
> }
>
> protected int
> ch_aliasfun(EditLine *el, el_afunc_t f, void *a)
> {
> el->el_chared.c_aliasfun = f;
> el->el_chared.c_aliasarg = a;
> return 0;
> }