diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libedit/chared.c | 40 | ||||
-rw-r--r-- | lib/libedit/common.c | 130 | ||||
-rw-r--r-- | lib/libedit/el.c | 38 | ||||
-rw-r--r-- | lib/libedit/emacs.c | 70 | ||||
-rw-r--r-- | lib/libedit/filecomplete.c | 18 | ||||
-rw-r--r-- | lib/libedit/hist.c | 24 | ||||
-rw-r--r-- | lib/libedit/history.c | 116 | ||||
-rw-r--r-- | lib/libedit/keymacro.c | 54 | ||||
-rw-r--r-- | lib/libedit/map.c | 60 | ||||
-rw-r--r-- | lib/libedit/parse.c | 34 | ||||
-rw-r--r-- | lib/libedit/prompt.c | 8 | ||||
-rw-r--r-- | lib/libedit/read.c | 40 | ||||
-rw-r--r-- | lib/libedit/readline.c | 144 | ||||
-rw-r--r-- | lib/libedit/search.c | 48 | ||||
-rw-r--r-- | lib/libedit/terminal.c | 76 | ||||
-rw-r--r-- | lib/libedit/tokenizer.c | 30 | ||||
-rw-r--r-- | lib/libedit/tty.c | 58 | ||||
-rw-r--r-- | lib/libedit/vi.c | 114 |
18 files changed, 551 insertions, 551 deletions
diff --git a/lib/libedit/chared.c b/lib/libedit/chared.c index 101c23e7b77..da3d9224cd1 100644 --- a/lib/libedit/chared.c +++ b/lib/libedit/chared.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chared.c,v 1.14 2016/01/30 02:52:41 schwarze Exp $ */ +/* $OpenBSD: chared.c,v 1.15 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -195,7 +195,7 @@ c_delbefore1(EditLine *el) protected int ce__isword(Int p) { - return (Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL); + return Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL; } @@ -219,7 +219,7 @@ cv__isword(Int p) protected int cv__isWord(Int p) { - return (!Isspace(p)); + return !Isspace(p); } @@ -243,7 +243,7 @@ c__prev_word(Char *p, Char *low, int n, int (*wtest)(Int)) if (p < low) p = low; /* cp now points where we want it */ - return (p); + return p; } @@ -262,7 +262,7 @@ c__next_word(Char *p, Char *high, int n, int (*wtest)(Int)) if (p > high) p = high; /* p now points where we want it */ - return (p); + return p; } /* cv_next_word(): @@ -288,9 +288,9 @@ cv_next_word(EditLine *el, Char *p, Char *high, int n, int (*wtest)(Int)) /* p now points where we want it */ if (p > high) - return (high); + return high; else - return (p); + return p; } @@ -314,9 +314,9 @@ cv_prev_word(Char *p, Char *low, int n, int (*wtest)(Int)) /* p now points where we want it */ if (p < low) - return (low); + return low; else - return (p); + return p; } @@ -377,7 +377,7 @@ cv__endword(Char *p, Char *high, int n, int (*wtest)(Int)) p++; } p--; - return (p); + return p; } /* ch_init(): @@ -391,7 +391,7 @@ ch_init(EditLine *el) el->el_line.buffer = reallocarray(NULL, EL_BUFSIZ, sizeof(*el->el_line.buffer)); if (el->el_line.buffer == NULL) - return (-1); + return -1; (void) memset(el->el_line.buffer, 0, EL_BUFSIZ * sizeof(*el->el_line.buffer)); @@ -402,7 +402,7 @@ ch_init(EditLine *el) el->el_chared.c_undo.buf = reallocarray(NULL, EL_BUFSIZ, sizeof(*el->el_chared.c_undo.buf)); if (el->el_chared.c_undo.buf == NULL) - return (-1); + return -1; (void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ * sizeof(*el->el_chared.c_undo.buf)); el->el_chared.c_undo.len = -1; @@ -410,7 +410,7 @@ ch_init(EditLine *el) el->el_chared.c_redo.buf = reallocarray(NULL, EL_BUFSIZ, sizeof(*el->el_chared.c_redo.buf)); if (el->el_chared.c_redo.buf == NULL) - return (-1); + return -1; el->el_chared.c_redo.pos = el->el_chared.c_redo.buf; el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ; el->el_chared.c_redo.cmd = ED_UNASSIGNED; @@ -421,7 +421,7 @@ ch_init(EditLine *el) el->el_chared.c_kill.buf = reallocarray(NULL, EL_BUFSIZ, sizeof(*el->el_chared.c_kill.buf)); if (el->el_chared.c_kill.buf == NULL) - return (-1); + return -1; (void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ * sizeof(*el->el_chared.c_kill.buf)); el->el_chared.c_kill.mark = el->el_line.buffer; @@ -442,8 +442,8 @@ ch_init(EditLine *el) ma->macro = reallocarray(NULL, EL_MAXMACRO, sizeof(*ma->macro)); if (ma->macro == NULL) - return (-1); - return (0); + return -1; + return 0; } /* ch_reset(): @@ -609,16 +609,16 @@ FUN(el,insertstr)(EditLine *el, const Char *s) size_t len; if ((len = Strlen(s)) == 0) - return (-1); + return -1; if (el->el_line.lastchar + len >= el->el_line.limit) { if (!ch_enlargebufs(el, len)) - return (-1); + return -1; } c_insert(el, (int)len); while (*s) *el->el_line.cursor++ = *s++; - return (0); + return 0; } @@ -717,7 +717,7 @@ c_hpos(EditLine *el) * Find how many characters till the beginning of this line. */ if (el->el_line.cursor == el->el_line.buffer) - return (0); + return 0; else { for (ptr = el->el_line.cursor - 1; ptr >= el->el_line.buffer && *ptr != '\n'; diff --git a/lib/libedit/common.c b/lib/libedit/common.c index 10661a51b51..768bac4d27d 100644 --- a/lib/libedit/common.c +++ b/lib/libedit/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.9 2016/01/30 00:06:39 schwarze Exp $ */ +/* $OpenBSD: common.c,v 1.10 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: common.c,v 1.24 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -51,7 +51,7 @@ ed_end_of_file(EditLine *el, Int c __attribute__((__unused__))) re_goto_bottom(el); *el->el_line.lastchar = '\0'; - return (CC_EOF); + return CC_EOF; } @@ -65,7 +65,7 @@ ed_insert(EditLine *el, Int c) int count = el->el_state.argument; if (c == '\0') - return (CC_ERROR); + return CC_ERROR; if (el->el_line.lastchar + el->el_state.argument >= el->el_line.limit) { @@ -93,7 +93,7 @@ ed_insert(EditLine *el, Int c) if (el->el_state.inputmode == MODE_REPLACE_1) return vi_command_mode(el, 0); - return (CC_NORM); + return CC_NORM; } @@ -108,7 +108,7 @@ ed_delete_prev_word(EditLine *el, Int c __attribute__((__unused__))) Char *cp, *p, *kp; if (el->el_line.cursor == el->el_line.buffer) - return (CC_ERROR); + return CC_ERROR; cp = c__prev_word(el->el_line.cursor, el->el_line.buffer, el->el_state.argument, ce__isword); @@ -121,7 +121,7 @@ ed_delete_prev_word(EditLine *el, Int c __attribute__((__unused__))) el->el_line.cursor = cp; if (el->el_line.cursor < el->el_line.buffer) el->el_line.cursor = el->el_line.buffer; /* bounds check */ - return (CC_REFRESH); + return CC_REFRESH; } @@ -146,24 +146,24 @@ ed_delete_next_char(EditLine *el, Int c) if (el->el_line.cursor == el->el_line.buffer) { /* if I'm also at the beginning */ #ifdef KSHVI - return (CC_ERROR); + return CC_ERROR; #else /* then do an EOF */ terminal_writec(el, c); - return (CC_EOF); + return CC_EOF; #endif } else { #ifdef KSHVI el->el_line.cursor--; #else - return (CC_ERROR); + return CC_ERROR; #endif } } else { if (el->el_line.cursor != el->el_line.buffer) el->el_line.cursor--; else - return (CC_ERROR); + return CC_ERROR; } } c_delafter(el, el->el_state.argument); /* delete after dot */ @@ -171,7 +171,7 @@ ed_delete_next_char(EditLine *el, Int c) el->el_line.cursor > el->el_line.buffer) /* bounds check */ el->el_line.cursor = el->el_line.lastchar - 1; - return (CC_REFRESH); + return CC_REFRESH; } @@ -192,7 +192,7 @@ ed_kill_line(EditLine *el, Int c __attribute__((__unused__))) el->el_chared.c_kill.last = kp; /* zap! -- delete to end */ el->el_line.lastchar = el->el_line.cursor; - return (CC_REFRESH); + return CC_REFRESH; } @@ -209,13 +209,13 @@ ed_move_to_end(EditLine *el, Int c __attribute__((__unused__))) if (el->el_map.type == MAP_VI) { if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } #ifdef VI_MOVE el->el_line.cursor--; #endif } - return (CC_CURSOR); + return CC_CURSOR; } @@ -236,10 +236,10 @@ ed_move_to_beg(EditLine *el, Int c __attribute__((__unused__))) el->el_line.cursor++; if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } } - return (CC_CURSOR); + return CC_CURSOR; } @@ -253,7 +253,7 @@ ed_transpose_chars(EditLine *el, Int c) if (el->el_line.cursor < el->el_line.lastchar) { if (el->el_line.lastchar <= &el->el_line.buffer[1]) - return (CC_ERROR); + return CC_ERROR; else el->el_line.cursor++; } @@ -262,9 +262,9 @@ ed_transpose_chars(EditLine *el, Int c) c = el->el_line.cursor[-2]; el->el_line.cursor[-2] = el->el_line.cursor[-1]; el->el_line.cursor[-1] = c; - return (CC_REFRESH); + return CC_REFRESH; } else - return (CC_ERROR); + return CC_ERROR; } @@ -282,7 +282,7 @@ ed_next_char(EditLine *el, Int c __attribute__((__unused__))) (el->el_line.cursor == lim - 1 && el->el_map.type == MAP_VI && el->el_chared.c_vcmd.action == NOP)) - return (CC_ERROR); + return CC_ERROR; el->el_line.cursor += el->el_state.argument; if (el->el_line.cursor > lim) @@ -291,9 +291,9 @@ ed_next_char(EditLine *el, Int c __attribute__((__unused__))) if (el->el_map.type == MAP_VI) if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -307,7 +307,7 @@ ed_prev_word(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_line.cursor == el->el_line.buffer) - return (CC_ERROR); + return CC_ERROR; el->el_line.cursor = c__prev_word(el->el_line.cursor, el->el_line.buffer, @@ -317,9 +317,9 @@ ed_prev_word(EditLine *el, Int c __attribute__((__unused__))) if (el->el_map.type == MAP_VI) if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -340,11 +340,11 @@ ed_prev_char(EditLine *el, Int c __attribute__((__unused__))) if (el->el_map.type == MAP_VI) if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } else - return (CC_ERROR); + return CC_ERROR; } @@ -363,9 +363,9 @@ ed_quoted_insert(EditLine *el, Int c) c = tc; tty_noquotemode(el); if (num == 1) - return (ed_insert(el, c)); + return ed_insert(el, c); else - return (ed_end_of_file(el, 0)); + return ed_end_of_file(el, 0); } @@ -377,7 +377,7 @@ ed_digit(EditLine *el, Int c) { if (!Isdigit(c)) - return (CC_ERROR); + return CC_ERROR; if (el->el_state.doingarg) { /* if doing an arg, add this in... */ @@ -385,11 +385,11 @@ ed_digit(EditLine *el, Int c) el->el_state.argument = c - '0'; else { if (el->el_state.argument > 1000000) - return (CC_ERROR); + return CC_ERROR; el->el_state.argument = (el->el_state.argument * 10) + (c - '0'); } - return (CC_ARGHACK); + return CC_ARGHACK; } return ed_insert(el, c); @@ -405,18 +405,18 @@ ed_argument_digit(EditLine *el, Int c) { if (!Isdigit(c)) - return (CC_ERROR); + return CC_ERROR; if (el->el_state.doingarg) { if (el->el_state.argument > 1000000) - return (CC_ERROR); + return CC_ERROR; el->el_state.argument = (el->el_state.argument * 10) + (c - '0'); } else { /* else starting an argument */ el->el_state.argument = c - '0'; el->el_state.doingarg = 1; } - return (CC_ARGHACK); + return CC_ARGHACK; } @@ -429,7 +429,7 @@ protected el_action_t ed_unassigned(EditLine *el, Int c __attribute__((__unused__))) { - return (CC_ERROR); + return CC_ERROR; } @@ -447,7 +447,7 @@ ed_tty_sigint(EditLine *el __attribute__((__unused__)), Int c __attribute__((__unused__))) { - return (CC_NORM); + return CC_NORM; } @@ -461,7 +461,7 @@ ed_tty_dsusp(EditLine *el __attribute__((__unused__)), Int c __attribute__((__unused__))) { - return (CC_NORM); + return CC_NORM; } @@ -475,7 +475,7 @@ ed_tty_flush_output(EditLine *el __attribute__((__unused__)), Int c __attribute__((__unused__))) { - return (CC_NORM); + return CC_NORM; } @@ -489,7 +489,7 @@ ed_tty_sigquit(EditLine *el __attribute__((__unused__)), Int c __attribute__((__unused__))) { - return (CC_NORM); + return CC_NORM; } @@ -503,7 +503,7 @@ ed_tty_sigtstp(EditLine *el __attribute__((__unused__)), Int c __attribute__((__unused__))) { - return (CC_NORM); + return CC_NORM; } @@ -517,7 +517,7 @@ ed_tty_stop_output(EditLine *el __attribute__((__unused__)), Int c __attribute__((__unused__))) { - return (CC_NORM); + return CC_NORM; } @@ -531,7 +531,7 @@ ed_tty_start_output(EditLine *el __attribute__((__unused__)), Int c __attribute__((__unused__))) { - return (CC_NORM); + return CC_NORM; } @@ -547,7 +547,7 @@ ed_newline(EditLine *el, Int c __attribute__((__unused__))) re_goto_bottom(el); *el->el_line.lastchar++ = '\n'; *el->el_line.lastchar = '\0'; - return (CC_NEWLINE); + return CC_NEWLINE; } @@ -561,13 +561,13 @@ ed_delete_prev_char(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_line.cursor <= el->el_line.buffer) - return (CC_ERROR); + return CC_ERROR; c_delbefore(el, el->el_state.argument); el->el_line.cursor -= el->el_state.argument; if (el->el_line.cursor < el->el_line.buffer) el->el_line.cursor = el->el_line.buffer; - return (CC_REFRESH); + return CC_REFRESH; } @@ -582,7 +582,7 @@ ed_clear_screen(EditLine *el, Int c __attribute__((__unused__))) terminal_clear_screen(el); /* clear the whole real screen */ re_clear_display(el); /* reset everything */ - return (CC_REFRESH); + return CC_REFRESH; } @@ -596,7 +596,7 @@ ed_redisplay(EditLine *el __attribute__((__unused__)), Int c __attribute__((__unused__))) { - return (CC_REDISPLAY); + return CC_REDISPLAY; } @@ -610,7 +610,7 @@ ed_start_over(EditLine *el, Int c __attribute__((__unused__))) { ch_reset(el, 0); - return (CC_REFRESH); + return CC_REFRESH; } @@ -624,7 +624,7 @@ ed_sequence_lead_in(EditLine *el __attribute__((__unused__)), Int c __attribute__((__unused__))) { - return (CC_NORM); + return CC_NORM; } @@ -714,7 +714,7 @@ ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__))) "e_prev_search_hist(): eventno < 0;\n"); #endif el->el_history.eventno = 0; - return (CC_ERROR); + return CC_ERROR; } if (el->el_history.eventno == 0) { (void) Strncpy(el->el_history.buf, el->el_line.buffer, @@ -723,11 +723,11 @@ ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__))) (el->el_line.lastchar - el->el_line.buffer); } if (el->el_history.ref == NULL) - return (CC_ERROR); + return CC_ERROR; hp = HIST_FIRST(el); if (hp == NULL) - return (CC_ERROR); + return CC_ERROR; c_setpat(el); /* Set search pattern !! */ @@ -753,11 +753,11 @@ ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__))) #ifdef SDEBUG (void) fprintf(el->el_errfile, "not found\n"); #endif - return (CC_ERROR); + return CC_ERROR; } el->el_history.eventno = h; - return (hist_get(el)); + return hist_get(el); } @@ -778,14 +778,14 @@ ed_search_next_history(EditLine *el, Int c __attribute__((__unused__))) *el->el_line.lastchar = '\0'; /* just in case */ if (el->el_history.eventno == 0) - return (CC_ERROR); + return CC_ERROR; if (el->el_history.ref == NULL) - return (CC_ERROR); + return CC_ERROR; hp = HIST_FIRST(el); if (hp == NULL) - return (CC_ERROR); + return CC_ERROR; c_setpat(el); /* Set search pattern !! */ @@ -806,12 +806,12 @@ ed_search_next_history(EditLine *el, Int c __attribute__((__unused__))) #ifdef SDEBUG (void) fprintf(el->el_errfile, "not found\n"); #endif - return (CC_ERROR); + return CC_ERROR; } } el->el_history.eventno = found; - return (hist_get(el)); + return hist_get(el); } @@ -837,7 +837,7 @@ ed_prev_line(EditLine *el, Int c __attribute__((__unused__))) break; if (el->el_state.argument > 0) - return (CC_ERROR); + return CC_ERROR; /* * Move to the beginning of the line @@ -854,7 +854,7 @@ ed_prev_line(EditLine *el, Int c __attribute__((__unused__))) continue; el->el_line.cursor = ptr; - return (CC_CURSOR); + return CC_CURSOR; } @@ -877,7 +877,7 @@ ed_next_line(EditLine *el, Int c __attribute__((__unused__))) break; if (el->el_state.argument > 0) - return (CC_ERROR); + return CC_ERROR; /* * Move to the character requested @@ -888,7 +888,7 @@ ed_next_line(EditLine *el, Int c __attribute__((__unused__))) continue; el->el_line.cursor = ptr; - return (CC_CURSOR); + return CC_CURSOR; } diff --git a/lib/libedit/el.c b/lib/libedit/el.c index 9af4cc739aa..b0fd3e5c85b 100644 --- a/lib/libedit/el.c +++ b/lib/libedit/el.c @@ -1,4 +1,4 @@ -/* $OpenBSD: el.c,v 1.22 2016/01/30 00:06:39 schwarze Exp $ */ +/* $OpenBSD: el.c,v 1.23 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: el.c,v 1.61 2011/01/27 23:11:40 christos Exp $ */ /*- @@ -57,7 +57,7 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr) EditLine *el = (EditLine *) malloc(sizeof(EditLine)); if (el == NULL) - return (NULL); + return NULL; memset(el, 0, sizeof(EditLine)); @@ -102,7 +102,7 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr) (void) sig_init(el); (void) read_init(el); - return (el); + return el; } @@ -161,7 +161,7 @@ FUN(el,set)(EditLine *el, int op, ...) int rv = 0; if (el == NULL) - return (-1); + return -1; va_start(ap, op); switch (op) { @@ -354,7 +354,7 @@ FUN(el,set)(EditLine *el, int op, ...) } va_end(ap); - return (rv); + return rv; } @@ -476,7 +476,7 @@ FUN(el,get)(EditLine *el, int op, ...) } va_end(ap); - return (rv); + return rv; } @@ -487,7 +487,7 @@ public const TYPE(LineInfo) * FUN(el,line)(EditLine *el) { - return (const TYPE(LineInfo) *) (void *) &el->el_line; + return (const TYPE(LineInfo) *)(void *)&el->el_line; } @@ -511,13 +511,13 @@ el_source(EditLine *el, const char *fname) static const char elpath[] = "/.editrc"; if (issetugid()) - return (-1); + return -1; if ((ptr = getenv("HOME")) == NULL) - return (-1); + return -1; if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path)) - return (-1); + return -1; if (strlcat(path, elpath, sizeof(path)) >= sizeof(path)) - return (-1); + return -1; fname = path; #else /* @@ -525,13 +525,13 @@ el_source(EditLine *el, const char *fname) * to keep from inadvertently opening up the user to a security * hole. */ - return (-1); + return -1; #endif } if (fp == NULL) fp = fopen(fname, "r"); if (fp == NULL) - return (-1); + return -1; while ((ptr = fgetln(fp, &len)) != NULL) { if (ptr[len - 1] == '\n') @@ -539,7 +539,7 @@ el_source(EditLine *el, const char *fname) else { if ((lptr = (char *)malloc(len + 1)) == NULL) { (void) fclose(fp); - return (-1); + return -1; } memcpy(lptr, ptr, len); lptr[len] = '\0'; @@ -558,12 +558,12 @@ el_source(EditLine *el, const char *fname) if (parse_line(el, dptr) == -1) { free(lptr); (void) fclose(fp); - return (-1); + return -1; } } free(lptr); (void) fclose(fp); - return (0); + return 0; } @@ -609,7 +609,7 @@ el_editmode(EditLine *el, int argc, const Char **argv) const Char *how; if (argv == NULL || argc != 2 || argv[1] == NULL) - return (-1); + return -1; how = argv[1]; if (Strcmp(how, STR("on")) == 0) { @@ -622,7 +622,7 @@ el_editmode(EditLine *el, int argc, const Char **argv) else { (void) fprintf(el->el_errfile, "edit: Bad value `" FSTR "'.\n", how); - return (-1); + return -1; } - return (0); + return 0; } diff --git a/lib/libedit/emacs.c b/lib/libedit/emacs.c index 011916a839d..52e5834fe3e 100644 --- a/lib/libedit/emacs.c +++ b/lib/libedit/emacs.c @@ -1,5 +1,5 @@ -/* $OpenBSD: emacs.c,v 1.10 2016/01/30 00:06:39 schwarze Exp $ */ -/* $NetBSD: emacs.c,v 1.23 2009/12/30 22:37:40 christos Exp $ */ +/* $OpenBSD: emacs.c,v 1.11 2016/01/30 12:22:20 schwarze Exp $ */ +/* $NetBSD: emacs.c,v 1.25 2011/07/29 15:16:33 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -54,14 +54,14 @@ em_delete_or_list(EditLine *el, Int c) if (el->el_line.cursor == el->el_line.buffer) { /* and the beginning */ terminal_writec(el, c); /* then do an EOF */ - return (CC_EOF); + return CC_EOF; } else { /* * Here we could list completions, but it is an * error right now */ terminal_beep(el); - return (CC_ERROR); + return CC_ERROR; } } else { if (el->el_state.doingarg) @@ -71,7 +71,7 @@ em_delete_or_list(EditLine *el, Int c) if (el->el_line.cursor > el->el_line.lastchar) el->el_line.cursor = el->el_line.lastchar; /* bounds check */ - return (CC_REFRESH); + return CC_REFRESH; } } @@ -87,7 +87,7 @@ em_delete_next_word(EditLine *el, Int c __attribute__((__unused__))) Char *cp, *p, *kp; if (el->el_line.cursor == el->el_line.lastchar) - return (CC_ERROR); + return CC_ERROR; cp = c__next_word(el->el_line.cursor, el->el_line.lastchar, el->el_state.argument, ce__isword); @@ -101,7 +101,7 @@ em_delete_next_word(EditLine *el, Int c __attribute__((__unused__))) if (el->el_line.cursor > el->el_line.lastchar) el->el_line.cursor = el->el_line.lastchar; /* bounds check */ - return (CC_REFRESH); + return CC_REFRESH; } @@ -116,12 +116,12 @@ em_yank(EditLine *el, Int c __attribute__((__unused__))) Char *kp, *cp; if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf) - return (CC_NORM); + return CC_NORM; if (el->el_line.lastchar + (el->el_chared.c_kill.last - el->el_chared.c_kill.buf) >= el->el_line.limit) - return (CC_ERROR); + return CC_ERROR; el->el_chared.c_kill.mark = el->el_line.cursor; cp = el->el_line.cursor; @@ -137,7 +137,7 @@ em_yank(EditLine *el, Int c __attribute__((__unused__))) if (el->el_state.argument == 1) el->el_line.cursor = cp; - return (CC_REFRESH); + return CC_REFRESH; } @@ -159,7 +159,7 @@ em_kill_line(EditLine *el, Int c __attribute__((__unused__))) /* zap! -- delete all of it */ el->el_line.lastchar = el->el_line.buffer; el->el_line.cursor = el->el_line.buffer; - return (CC_REFRESH); + return CC_REFRESH; } @@ -174,7 +174,7 @@ em_kill_region(EditLine *el, Int c __attribute__((__unused__))) Char *kp, *cp; if (!el->el_chared.c_kill.mark) - return (CC_ERROR); + return CC_ERROR; if (el->el_chared.c_kill.mark > el->el_line.cursor) { cp = el->el_line.cursor; @@ -192,7 +192,7 @@ em_kill_region(EditLine *el, Int c __attribute__((__unused__))) c_delbefore(el, (int)(cp - el->el_chared.c_kill.mark)); el->el_line.cursor = el->el_chared.c_kill.mark; } - return (CC_REFRESH); + return CC_REFRESH; } @@ -207,7 +207,7 @@ em_copy_region(EditLine *el, Int c __attribute__((__unused__))) Char *kp, *cp; if (!el->el_chared.c_kill.mark) - return (CC_ERROR); + return CC_ERROR; if (el->el_chared.c_kill.mark > el->el_line.cursor) { cp = el->el_line.cursor; @@ -222,7 +222,7 @@ em_copy_region(EditLine *el, Int c __attribute__((__unused__))) *kp++ = *cp++; /* copy it */ el->el_chared.c_kill.last = kp; } - return (CC_NORM); + return CC_NORM; } @@ -239,9 +239,9 @@ em_gosmacs_transpose(EditLine *el, Int c) c = el->el_line.cursor[-2]; el->el_line.cursor[-2] = el->el_line.cursor[-1]; el->el_line.cursor[-1] = c; - return (CC_REFRESH); + return CC_REFRESH; } else - return (CC_ERROR); + return CC_ERROR; } @@ -254,7 +254,7 @@ protected el_action_t em_next_word(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_line.cursor == el->el_line.lastchar) - return (CC_ERROR); + return CC_ERROR; el->el_line.cursor = c__next_word(el->el_line.cursor, el->el_line.lastchar, @@ -264,9 +264,9 @@ em_next_word(EditLine *el, Int c __attribute__((__unused__))) if (el->el_map.type == MAP_VI) if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -290,7 +290,7 @@ em_upper_case(EditLine *el, Int c __attribute__((__unused__))) el->el_line.cursor = ep; if (el->el_line.cursor > el->el_line.lastchar) el->el_line.cursor = el->el_line.lastchar; - return (CC_REFRESH); + return CC_REFRESH; } @@ -322,7 +322,7 @@ em_capitol_case(EditLine *el, Int c __attribute__((__unused__))) el->el_line.cursor = ep; if (el->el_line.cursor > el->el_line.lastchar) el->el_line.cursor = el->el_line.lastchar; - return (CC_REFRESH); + return CC_REFRESH; } @@ -346,7 +346,7 @@ em_lower_case(EditLine *el, Int c __attribute__((__unused__))) el->el_line.cursor = ep; if (el->el_line.cursor > el->el_line.lastchar) el->el_line.cursor = el->el_line.lastchar; - return (CC_REFRESH); + return CC_REFRESH; } @@ -360,7 +360,7 @@ em_set_mark(EditLine *el, Int c __attribute__((__unused__))) { el->el_chared.c_kill.mark = el->el_line.cursor; - return (CC_NORM); + return CC_NORM; } @@ -377,7 +377,7 @@ em_exchange_mark(EditLine *el, Int c __attribute__((__unused__))) cp = el->el_line.cursor; el->el_line.cursor = el->el_chared.c_kill.mark; el->el_chared.c_kill.mark = cp; - return (CC_CURSOR); + return CC_CURSOR; } @@ -391,10 +391,10 @@ em_universal_argument(EditLine *el, Int c __attribute__((__unused__))) { /* multiply current argument by 4 */ if (el->el_state.argument > 1000000) - return (CC_ERROR); + return CC_ERROR; el->el_state.doingarg = 1; el->el_state.argument *= 4; - return (CC_ARGHACK); + return CC_ARGHACK; } @@ -408,7 +408,7 @@ em_meta_next(EditLine *el, Int c __attribute__((__unused__))) { el->el_state.metanext = 1; - return (CC_ARGHACK); + return CC_ARGHACK; } @@ -422,7 +422,7 @@ em_toggle_overwrite(EditLine *el, Int c __attribute__((__unused__))) el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ? MODE_REPLACE : MODE_INSERT; - return (CC_NORM); + return CC_NORM; } @@ -436,7 +436,7 @@ em_copy_prev_word(EditLine *el, Int c __attribute__((__unused__))) Char *cp, *oldc, *dp; if (el->el_line.cursor == el->el_line.buffer) - return (CC_ERROR); + return CC_ERROR; oldc = el->el_line.cursor; /* does a bounds check */ @@ -449,7 +449,7 @@ em_copy_prev_word(EditLine *el, Int c __attribute__((__unused__))) el->el_line.cursor = dp;/* put cursor at end */ - return (CC_REFRESH); + return CC_REFRESH; } @@ -462,7 +462,7 @@ em_inc_search_next(EditLine *el, Int c __attribute__((__unused__))) { el->el_search.patlen = 0; - return (ce_inc_search(el, ED_SEARCH_NEXT_HISTORY)); + return ce_inc_search(el, ED_SEARCH_NEXT_HISTORY); } @@ -475,7 +475,7 @@ em_inc_search_prev(EditLine *el, Int c __attribute__((__unused__))) { el->el_search.patlen = 0; - return (ce_inc_search(el, ED_SEARCH_PREV_HISTORY)); + return ce_inc_search(el, ED_SEARCH_PREV_HISTORY); } @@ -489,7 +489,7 @@ em_delete_prev_char(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_line.cursor <= el->el_line.buffer) - return (CC_ERROR); + return CC_ERROR; if (el->el_state.doingarg) c_delbefore(el, el->el_state.argument); @@ -498,5 +498,5 @@ em_delete_prev_char(EditLine *el, Int c __attribute__((__unused__))) el->el_line.cursor -= el->el_state.argument; if (el->el_line.cursor < el->el_line.buffer) el->el_line.cursor = el->el_line.buffer; - return (CC_REFRESH); + return CC_REFRESH; } diff --git a/lib/libedit/filecomplete.c b/lib/libedit/filecomplete.c index c6c2000fed6..a83699d5e03 100644 --- a/lib/libedit/filecomplete.c +++ b/lib/libedit/filecomplete.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filecomplete.c,v 1.5 2016/01/30 00:06:39 schwarze Exp $ */ +/* $OpenBSD: filecomplete.c,v 1.6 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: filecomplete.c,v 1.22 2010/12/02 04:42:46 dholland Exp $ */ /*- @@ -69,7 +69,7 @@ static const Char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', * if ``user'' isn't valid user name or ``txt'' doesn't start * w/ '~', returns pointer to strdup()ed copy of ``txt'' * - * it's callers's responsibility to free() returned string + * it's the caller's responsibility to free() the returned string */ char * fn_tilde_expand(const char *txt) @@ -80,7 +80,7 @@ fn_tilde_expand(const char *txt) char pwbuf[1024]; if (txt[0] != '~') - return (strdup(txt)); + return strdup(txt); temp = strchr(txt + 1, '/'); if (temp == NULL) { @@ -104,7 +104,7 @@ fn_tilde_expand(const char *txt) } free(temp); /* value no more needed */ if (pass == NULL) - return (strdup(txt)); + return strdup(txt); /* update pointer txt to point at string immedially following */ /* first slash */ @@ -116,7 +116,7 @@ fn_tilde_expand(const char *txt) return NULL; (void)snprintf(temp, tempsz, "%s/%s", pass->pw_dir, txt); - return (temp); + return temp; } @@ -125,7 +125,7 @@ fn_tilde_expand(const char *txt) * such file can be found * value of ``state'' is ignored * - * it's caller's responsibility to free returned string + * it's the caller's responsibility to free the returned string */ char * fn_filename_completion_function(const char *text, int state) @@ -198,7 +198,7 @@ fn_filename_completion_function(const char *text, int state) dir = opendir(dirpath); if (!dir) - return (NULL); /* cannot open the directory */ + return NULL; /* cannot open the directory */ /* will be used in cycle */ filename_len = filename ? strlen(filename) : 0; @@ -244,7 +244,7 @@ fn_filename_completion_function(const char *text, int state) temp = NULL; } - return (temp); + return temp; } @@ -322,7 +322,7 @@ completion_matches(const char *text, char *(*genfunc)(const char *, int)) /* add NULL as last pointer to the array */ match_list[matches + 1] = (char *) NULL; - return (match_list); + return match_list; } /* diff --git a/lib/libedit/hist.c b/lib/libedit/hist.c index a749bc2c381..7440437747a 100644 --- a/lib/libedit/hist.c +++ b/lib/libedit/hist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hist.c,v 1.10 2014/10/17 06:07:50 deraadt Exp $ */ +/* $OpenBSD: hist.c,v 1.11 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: hist.c,v 1.17 2009/12/30 23:54:52 christos Exp $ */ /*- @@ -54,9 +54,9 @@ hist_init(EditLine *el) sizeof(*el->el_history.buf)); el->el_history.sz = EL_BUFSIZ; if (el->el_history.buf == NULL) - return (-1); + return -1; el->el_history.last = el->el_history.buf; - return (0); + return 0; } @@ -81,7 +81,7 @@ hist_set(EditLine *el, hist_fun_t fun, ptr_t ptr) el->el_history.ref = ptr; el->el_history.fun = fun; - return (0); + return 0; } @@ -108,20 +108,20 @@ hist_get(EditLine *el) #endif /* KSHVI */ el->el_line.cursor = el->el_line.lastchar; - return (CC_REFRESH); + return CC_REFRESH; } if (el->el_history.ref == NULL) - return (CC_ERROR); + return CC_ERROR; hp = HIST_FIRST(el); if (hp == NULL) - return (CC_ERROR); + return CC_ERROR; for (h = 1; h < el->el_history.eventno; h++) if ((hp = HIST_NEXT(el)) == NULL) { el->el_history.eventno = h; - return (CC_ERROR); + return CC_ERROR; } (void) Strncpy(el->el_line.buffer, hp, (size_t)(el->el_line.limit - el->el_line.buffer)); @@ -141,7 +141,7 @@ hist_get(EditLine *el) #endif /* KSHVI */ el->el_line.cursor = el->el_line.lastchar; - return (CC_REFRESH); + return CC_REFRESH; } @@ -156,7 +156,7 @@ hist_command(EditLine *el, int argc, const Char **argv) HistEvent ev; if (el->el_history.ref == NULL) - return (-1); + return -1; if (argc == 1 || Strcmp(argv[1], STR("list")) == 0) { /* List history entries */ @@ -164,11 +164,11 @@ hist_command(EditLine *el, int argc, const Char **argv) for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el)) (void) fprintf(el->el_outfile, "%d %s", el->el_history.ev.num, ct_encode_string(str, &el->el_scratch)); - return (0); + return 0; } if (argc != 3) - return (-1); + return -1; num = (int)Strtol(argv[2], NULL, 0); diff --git a/lib/libedit/history.c b/lib/libedit/history.c index a8d3a518b06..d978522d37c 100644 --- a/lib/libedit/history.c +++ b/lib/libedit/history.c @@ -1,4 +1,4 @@ -/* $OpenBSD: history.c,v 1.19 2014/10/17 06:07:50 deraadt Exp $ */ +/* $OpenBSD: history.c,v 1.20 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: history.c,v 1.37 2010/01/03 18:27:10 christos Exp $ */ /*- @@ -212,10 +212,10 @@ history_def_first(ptr_t p, TYPE(HistEvent) *ev) *ev = h->cursor->ev; else { he_seterrev(ev, _HE_FIRST_NOTFOUND); - return (-1); + return -1; } - return (0); + return 0; } @@ -232,10 +232,10 @@ history_def_last(ptr_t p, TYPE(HistEvent) *ev) *ev = h->cursor->ev; else { he_seterrev(ev, _HE_LAST_NOTFOUND); - return (-1); + return -1; } - return (0); + return 0; } @@ -249,18 +249,18 @@ history_def_next(ptr_t p, TYPE(HistEvent) *ev) if (h->cursor == &h->list) { he_seterrev(ev, _HE_EMPTY_LIST); - return (-1); + return -1; } if (h->cursor->next == &h->list) { he_seterrev(ev, _HE_END_REACHED); - return (-1); + return -1; } h->cursor = h->cursor->next; *ev = h->cursor->ev; - return (0); + return 0; } @@ -275,18 +275,18 @@ history_def_prev(ptr_t p, TYPE(HistEvent) *ev) if (h->cursor == &h->list) { he_seterrev(ev, (h->cur > 0) ? _HE_END_REACHED : _HE_EMPTY_LIST); - return (-1); + return -1; } if (h->cursor->prev == &h->list) { he_seterrev(ev, _HE_START_REACHED); - return (-1); + return -1; } h->cursor = h->cursor->prev; *ev = h->cursor->ev; - return (0); + return 0; } @@ -303,10 +303,10 @@ history_def_curr(ptr_t p, TYPE(HistEvent) *ev) else { he_seterrev(ev, (h->cur > 0) ? _HE_CURR_INVALID : _HE_EMPTY_LIST); - return (-1); + return -1; } - return (0); + return 0; } @@ -321,7 +321,7 @@ history_def_set(ptr_t p, TYPE(HistEvent) *ev, const int n) if (h->cur == 0) { he_seterrev(ev, _HE_EMPTY_LIST); - return (-1); + return -1; } if (h->cursor == &h->list || h->cursor->ev.num != n) { for (h->cursor = h->list.next; h->cursor != &h->list; @@ -331,9 +331,9 @@ history_def_set(ptr_t p, TYPE(HistEvent) *ev, const int n) } if (h->cursor == &h->list) { he_seterrev(ev, _HE_NOT_FOUND); - return (-1); + return -1; } - return (0); + return 0; } @@ -348,7 +348,7 @@ history_set_nth(ptr_t p, TYPE(HistEvent) *ev, int n) if (h->cur == 0) { he_seterrev(ev, _HE_EMPTY_LIST); - return (-1); + return -1; } for (h->cursor = h->list.prev; h->cursor != &h->list; h->cursor = h->cursor->prev) @@ -356,9 +356,9 @@ history_set_nth(ptr_t p, TYPE(HistEvent) *ev, int n) break; if (h->cursor == &h->list) { he_seterrev(ev, _HE_NOT_FOUND); - return (-1); + return -1; } - return (0); + return 0; } @@ -374,12 +374,12 @@ history_def_add(ptr_t p, TYPE(HistEvent) *ev, const Char *str) HistEventPrivate *evp = (void *)&h->cursor->ev; if (h->cursor == &h->list) - return (history_def_enter(p, ev, str)); + return history_def_enter(p, ev, str); len = Strlen(evp->str) + Strlen(str) + 1; s = reallocarray(NULL, len, sizeof(*s)); if (s == NULL) { he_seterrev(ev, _HE_MALLOC_FAILED); - return (-1); + return -1; } (void) Strncpy(s, h->cursor->ev.str, len); s[len - 1] = '\0'; @@ -387,7 +387,7 @@ history_def_add(ptr_t p, TYPE(HistEvent) *ev, const Char *str) free((ptr_t)evp->str); evp->str = s; *ev = h->cursor->ev; - return (0); + return 0; } @@ -396,16 +396,16 @@ history_deldata_nth(history_t *h, TYPE(HistEvent) *ev, int num, void **data) { if (history_set_nth(h, ev, num) != 0) - return (-1); + return -1; /* magic value to skip delete (just set to n-th history) */ if (data == (void **)-1) - return (0); + return 0; ev->str = Strdup(h->cursor->ev.str); ev->num = h->cursor->ev.num; if (data) *data = h->cursor->data; history_def_delete(h, ev, h->cursor); - return (0); + return 0; } @@ -419,11 +419,11 @@ history_def_del(ptr_t p, TYPE(HistEvent) *ev __attribute__((__unused__)), { history_t *h = (history_t *) p; if (history_def_set(h, ev, num) != 0) - return (-1); + return -1; ev->str = Strdup(h->cursor->ev.str); ev->num = h->cursor->ev.num; history_def_delete(h, ev, h->cursor); - return (0); + return 0; } @@ -474,10 +474,10 @@ history_def_insert(history_t *h, TYPE(HistEvent) *ev, const Char *str) h->cur++; *ev = h->cursor->ev; - return (0); + return 0; oomem: he_seterrev(ev, _HE_MALLOC_FAILED); - return (-1); + return -1; } @@ -491,10 +491,10 @@ history_def_enter(ptr_t p, TYPE(HistEvent) *ev, const Char *str) if ((h->flags & H_UNIQUE) != 0 && h->list.next != &h->list && Strcmp(h->list.next->ev.str, str) == 0) - return (0); + return 0; if (history_def_insert(h, ev, str) == -1) - return (-1); /* error, keep error message */ + return -1; /* error, keep error message */ /* * Always keep at least one entry. @@ -503,7 +503,7 @@ history_def_enter(ptr_t p, TYPE(HistEvent) *ev, const Char *str) while (h->cur > h->max && h->cur > 0) history_def_delete(h, ev, h->list.prev); - return (1); + return 1; } @@ -579,7 +579,7 @@ FUN(history,init)(void) h->h_add = history_def_add; h->h_del = history_def_del; - return (h); + return h; } @@ -608,14 +608,14 @@ history_setsize(TYPE(History) *h, TYPE(HistEvent) *ev, int num) if (h->h_next != history_def_next) { he_seterrev(ev, _HE_NOT_ALLOWED); - return (-1); + return -1; } if (num < 0) { he_seterrev(ev, _HE_BAD_PARAM); - return (-1); + return -1; } history_def_setsize(h->h_ref, num); - return (0); + return 0; } @@ -627,14 +627,14 @@ history_getsize(TYPE(History) *h, TYPE(HistEvent) *ev) { if (h->h_next != history_def_next) { he_seterrev(ev, _HE_NOT_ALLOWED); - return (-1); + return -1; } ev->num = history_def_getsize(h->h_ref); if (ev->num < -1) { he_seterrev(ev, _HE_SIZE_NEGATIVE); - return (-1); + return -1; } - return (0); + return 0; } @@ -647,10 +647,10 @@ history_setunique(TYPE(History) *h, TYPE(HistEvent) *ev, int uni) if (h->h_next != history_def_next) { he_seterrev(ev, _HE_NOT_ALLOWED); - return (-1); + return -1; } history_def_setunique(h->h_ref, uni); - return (0); + return 0; } @@ -662,10 +662,10 @@ history_getunique(TYPE(History) *h, TYPE(HistEvent) *ev) { if (h->h_next != history_def_next) { he_seterrev(ev, _HE_NOT_ALLOWED); - return (-1); + return -1; } ev->num = history_def_getunique(h->h_ref); - return (0); + return 0; } @@ -694,7 +694,7 @@ history_set_fun(TYPE(History) *h, TYPE(History) *nh) h->h_add = history_def_add; h->h_del = history_def_del; } - return (-1); + return -1; } if (h->h_next == history_def_next) history_def_clear(h->h_ref, &ev); @@ -711,7 +711,7 @@ history_set_fun(TYPE(History) *h, TYPE(History) *nh) h->h_add = nh->h_add; h->h_del = nh->h_del; - return (0); + return 0; } @@ -733,7 +733,7 @@ history_load(TYPE(History) *h, const char *fname) lbuf = NULL; if ((fp = fopen(fname, "r")) == NULL) - return (i); + return i; if ((line = fgetln(fp, &sz)) == NULL) goto done; @@ -778,7 +778,7 @@ oomem: done: free(lbuf); (void) fclose(fp); - return (i); + return i; } @@ -824,7 +824,7 @@ history_save_fp(TYPE(History) *h, FILE *fp) oomem: free((ptr_t)ptr); done: - return (i); + return i; } @@ -857,10 +857,10 @@ history_prev_event(TYPE(History) *h, TYPE(HistEvent) *ev, int num) for (retval = HCURR(h, ev); retval != -1; retval = HPREV(h, ev)) if (ev->num == num) - return (0); + return 0; he_seterrev(ev, _HE_NOT_FOUND); - return (-1); + return -1; } @@ -873,11 +873,11 @@ history_next_evdata(TYPE(History) *h, TYPE(HistEvent) *ev, int num, void **d) if (ev->num == num) { if (d) *d = ((history_t *)h->h_ref)->cursor->data; - return (0); + return 0; } he_seterrev(ev, _HE_NOT_FOUND); - return (-1); + return -1; } @@ -891,10 +891,10 @@ history_next_event(TYPE(History) *h, TYPE(HistEvent) *ev, int num) for (retval = HCURR(h, ev); retval != -1; retval = HNEXT(h, ev)) if (ev->num == num) - return (0); + return 0; he_seterrev(ev, _HE_NOT_FOUND); - return (-1); + return -1; } @@ -909,10 +909,10 @@ history_prev_string(TYPE(History) *h, TYPE(HistEvent) *ev, const Char *str) for (retval = HCURR(h, ev); retval != -1; retval = HNEXT(h, ev)) if (Strncmp(str, ev->str, len) == 0) - return (0); + return 0; he_seterrev(ev, _HE_NOT_FOUND); - return (-1); + return -1; } @@ -927,10 +927,10 @@ history_next_string(TYPE(History) *h, TYPE(HistEvent) *ev, const Char *str) for (retval = HCURR(h, ev); retval != -1; retval = HPREV(h, ev)) if (Strncmp(str, ev->str, len) == 0) - return (0); + return 0; he_seterrev(ev, _HE_NOT_FOUND); - return (-1); + return -1; } diff --git a/lib/libedit/keymacro.c b/lib/libedit/keymacro.c index b409aa270fa..3c64f94ff48 100644 --- a/lib/libedit/keymacro.c +++ b/lib/libedit/keymacro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keymacro.c,v 1.2 2016/01/29 19:32:33 schwarze Exp $ */ +/* $OpenBSD: keymacro.c,v 1.3 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: key.c,v 1.23 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -101,10 +101,10 @@ keymacro_init(EditLine *el) el->el_keymacro.buf = reallocarray(NULL, KEY_BUFSIZ, sizeof(*el->el_keymacro.buf)); if (el->el_keymacro.buf == NULL) - return (-1); + return -1; el->el_keymacro.map = NULL; keymacro_reset(el); - return (0); + return 0; } /* keymacro_end(): @@ -236,13 +236,13 @@ keymacro_delete(EditLine *el, const Char *key) if (key[0] == '\0') { (void) fprintf(el->el_errfile, "keymacro_delete: Null extended-key not allowed.\n"); - return (-1); + return -1; } if (el->el_keymacro.map == NULL) - return (0); + return 0; (void) node__delete(el, &el->el_keymacro.map, key); - return (0); + return 0; } @@ -281,25 +281,25 @@ node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val) /* key not complete so get next char */ if (FUN(el,getc)(el, ch) != 1) {/* if EOF or error */ val->cmd = ED_END_OF_FILE; - return (XK_CMD); + return XK_CMD; /* PWP: Pretend we just read an end-of-file */ } - return (node_trav(el, ptr->next, ch, val)); + return node_trav(el, ptr->next, ch, val); } else { *val = ptr->val; if (ptr->type != XK_CMD) *ch = '\0'; - return (ptr->type); + return ptr->type; } } else { /* no match found here */ if (ptr->sibling) { /* try next sibling */ - return (node_trav(el, ptr->sibling, ch, val)); + return node_trav(el, ptr->sibling, ch, val); } else { /* no next sibling -- mismatch */ val->str = NULL; - return (XK_STR); + return XK_STR; } } } @@ -364,7 +364,7 @@ node__try(EditLine *el, keymacro_node_t *ptr, const Char *str, ptr->next = node__get(*str); /* setup new node */ (void) node__try(el, ptr->next, str, val, ntype); } - return (0); + return 0; } @@ -386,7 +386,7 @@ node__delete(EditLine *el, keymacro_node_t **inptr, const Char *str) if (xm->sibling->ch == *str) break; if (xm->sibling == NULL) - return (0); + return 0; prev_ptr = xm; ptr = xm->sibling; } @@ -398,20 +398,20 @@ node__delete(EditLine *el, keymacro_node_t **inptr, const Char *str) prev_ptr->sibling = ptr->sibling; ptr->sibling = NULL; node__put(el, ptr); - return (1); + return 1; } else if (ptr->next != NULL && node__delete(el, &ptr->next, str) == 1) { if (ptr->next != NULL) - return (0); + return 0; if (prev_ptr == NULL) *inptr = ptr->sibling; else prev_ptr->sibling = ptr->sibling; ptr->sibling = NULL; node__put(el, ptr); - return (1); + return 1; } else { - return (0); + return 0; } } @@ -464,7 +464,7 @@ node__get(Int ch) ptr->val.str = NULL; ptr->next = NULL; ptr->sibling = NULL; - return (ptr); + return ptr; } private void @@ -487,12 +487,12 @@ node_lookup(EditLine *el, const Char *str, keymacro_node_t *ptr, size_t cnt) ssize_t used; if (ptr == NULL) - return (-1); /* cannot have null ptr */ + return -1; /* cannot have null ptr */ if (!str || *str == 0) { /* no more chars in str. node_enum from here. */ (void) node_enum(el, ptr, cnt); - return (0); + return 0; } else { /* If match put this char into el->el_keymacro.buf. Recurse */ if (ptr->ch == *str) { @@ -500,7 +500,7 @@ node_lookup(EditLine *el, const Char *str, keymacro_node_t *ptr, size_t cnt) used = ct_visual_char(el->el_keymacro.buf + cnt, KEY_BUFSIZ - cnt, ptr->ch); if (used == -1) - return (-1); /* ran out of buffer space */ + return -1; /* ran out of buffer space */ if (ptr->next != NULL) /* not yet at leaf */ return (node_lookup(el, str + 1, ptr->next, @@ -512,9 +512,9 @@ node_lookup(EditLine *el, const Char *str, keymacro_node_t *ptr, size_t cnt) el->el_keymacro.buf[cnt+used+1] = '\0'; keymacro_kprint(el, el->el_keymacro.buf, &ptr->val, ptr->type); - return (0); + return 0; } else - return (-1); + return -1; /* mismatch -- str still has chars */ } } else { @@ -523,7 +523,7 @@ node_lookup(EditLine *el, const Char *str, keymacro_node_t *ptr, size_t cnt) return (node_lookup(el, str, ptr->sibling, cnt)); else - return (-1); + return -1; } } } @@ -544,14 +544,14 @@ node_enum(EditLine *el, keymacro_node_t *ptr, size_t cnt) "Some extended keys too long for internal print buffer"); (void) fprintf(el->el_errfile, " \"" FSTR "...\"\n", el->el_keymacro.buf); - return (0); + return 0; } if (ptr == NULL) { #ifdef DEBUG_EDIT (void) fprintf(el->el_errfile, "node_enum: BUG!! Null ptr passed\n!"); #endif - return (-1); + return -1; } /* put this char at end of str */ used = ct_visual_char(el->el_keymacro.buf + cnt, KEY_BUFSIZ - cnt, @@ -567,7 +567,7 @@ node_enum(EditLine *el, keymacro_node_t *ptr, size_t cnt) /* go to sibling if there is one */ if (ptr->sibling) (void) node_enum(el, ptr->sibling, cnt); - return (0); + return 0; } diff --git a/lib/libedit/map.c b/lib/libedit/map.c index c96329ba0e6..546778468c4 100644 --- a/lib/libedit/map.c +++ b/lib/libedit/map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: map.c,v 1.14 2016/01/30 00:06:39 schwarze Exp $ */ +/* $OpenBSD: map.c,v 1.15 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: map.c,v 1.25 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -899,23 +899,23 @@ map_init(EditLine *el) el->el_map.alt = reallocarray(NULL, N_KEYS, sizeof(el_action_t)); if (el->el_map.alt == NULL) - return (-1); + return -1; el->el_map.key = reallocarray(NULL, N_KEYS, sizeof(el_action_t)); if (el->el_map.key == NULL) - return (-1); + return -1; el->el_map.emacs = el_map_emacs; el->el_map.vic = el_map_vi_command; el->el_map.vii = el_map_vi_insert; el->el_map.help = reallocarray(NULL, EL_NUM_FCNS, sizeof(el_bindings_t)); if (el->el_map.help == NULL) - return (-1); + return -1; (void) memcpy(el->el_map.help, help__get(), sizeof(el_bindings_t) * EL_NUM_FCNS); el->el_map.func = reallocarray(NULL, EL_NUM_FCNS, sizeof(el_func_t)); if (el->el_map.func == NULL) - return (-1); + return -1; memcpy(el->el_map.func, func__get(), sizeof(el_func_t) * EL_NUM_FCNS); el->el_map.nfunc = EL_NUM_FCNS; @@ -924,7 +924,7 @@ map_init(EditLine *el) #else map_init_emacs(el); #endif /* VIDEFAULT */ - return (0); + return 0; } @@ -1079,13 +1079,13 @@ map_set_editor(EditLine *el, Char *editor) if (Strcmp(editor, STR("emacs")) == 0) { map_init_emacs(el); - return (0); + return 0; } if (Strcmp(editor, STR("vi")) == 0) { map_init_vi(el); - return (0); + return 0; } - return (-1); + return -1; } @@ -1097,16 +1097,16 @@ map_get_editor(EditLine *el, const Char **editor) { if (editor == NULL) - return (-1); + return -1; switch (el->el_map.type) { case MAP_EMACS: *editor = STR("emacs"); - return (0); + return 0; case MAP_VI: *editor = STR("vi"); - return (0); + return 0; } - return (-1); + return -1; } @@ -1250,7 +1250,7 @@ map_bind(EditLine *el, int argc, const Char **argv) int key; if (argv == NULL) - return (-1); + return -1; map = el->el_map.key; ntype = XK_CMD; @@ -1280,11 +1280,11 @@ map_bind(EditLine *el, int argc, const Char **argv) case 'v': map_init_vi(el); - return (0); + return 0; case 'e': map_init_emacs(el); - return (0); + return 0; case 'l': ep = &el->el_map.help[el->el_map.nfunc]; @@ -1292,7 +1292,7 @@ map_bind(EditLine *el, int argc, const Char **argv) (void) fprintf(el->el_outfile, "" FSTR "\n\t" FSTR "\n", bp->name, bp->description); - return (0); + return 0; default: (void) fprintf(el->el_errfile, "" FSTR ": Invalid switch `%c'.\n", @@ -1303,7 +1303,7 @@ map_bind(EditLine *el, int argc, const Char **argv) if (argv[argc] == NULL) { map_print_all_keys(el); - return (0); + return 0; } if (key) in = argv[argc++]; @@ -1311,12 +1311,12 @@ map_bind(EditLine *el, int argc, const Char **argv) (void) fprintf(el->el_errfile, "" FSTR ": Invalid \\ or ^ in instring.\n", argv[0]); - return (-1); + return -1; } if (rem) { if (key) { (void) terminal_clear_arrow(el, in); - return (-1); + return -1; } if (in[1]) (void) keymacro_delete(el, in); @@ -1324,19 +1324,19 @@ map_bind(EditLine *el, int argc, const Char **argv) (void) keymacro_delete(el, in); else map[(unsigned char) *in] = ED_UNASSIGNED; - return (0); + return 0; } if (argv[argc] == NULL) { if (key) terminal_print_arrow(el, in); else map_print_key(el, map, in); - return (0); + return 0; } #ifdef notyet if (argv[argc + 1] != NULL) { bindkey_usage(); - return (-1); + return -1; } #endif @@ -1346,7 +1346,7 @@ map_bind(EditLine *el, int argc, const Char **argv) if ((out = parse__string(outbuf, argv[argc])) == NULL) { (void) fprintf(el->el_errfile, "" FSTR ": Invalid \\ or ^ in outstring.\n", argv[0]); - return (-1); + return -1; } if (key) terminal_set_arrow(el, in, keymacro_map_str(el, out), ntype); @@ -1360,7 +1360,7 @@ map_bind(EditLine *el, int argc, const Char **argv) (void) fprintf(el->el_errfile, "" FSTR ": Invalid command `" FSTR "'.\n", argv[0], argv[argc]); - return (-1); + return -1; } if (key) terminal_set_arrow(el, in, keymacro_map_str(el, out), ntype); @@ -1379,7 +1379,7 @@ map_bind(EditLine *el, int argc, const Char **argv) EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype)); break; } - return (0); + return 0; } @@ -1393,14 +1393,14 @@ map_addfunc(EditLine *el, const Char *name, const Char *help, el_func_t func) int nf = el->el_map.nfunc + 1; if (name == NULL || help == NULL || func == NULL) - return (-1); + return -1; if ((p = reallocarray(el->el_map.func, nf, sizeof(el_func_t))) == NULL) - return (-1); + return -1; el->el_map.func = (el_func_t *) p; if ((p = reallocarray(el->el_map.help, nf, sizeof(el_bindings_t))) == NULL) - return (-1); + return -1; el->el_map.help = (el_bindings_t *) p; nf = el->el_map.nfunc; @@ -1411,5 +1411,5 @@ map_addfunc(EditLine *el, const Char *name, const Char *help, el_func_t func) el->el_map.help[nf].description = help; el->el_map.nfunc++; - return (0); + return 0; } diff --git a/lib/libedit/parse.c b/lib/libedit/parse.c index 17dbca40cb7..4b6a88404f1 100644 --- a/lib/libedit/parse.c +++ b/lib/libedit/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.13 2016/01/30 00:06:39 schwarze Exp $ */ +/* $OpenBSD: parse.c,v 1.14 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: parse.c,v 1.23 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -80,7 +80,7 @@ parse_line(EditLine *el, const Char *line) FUN(tok,str)(tok, line, &argc, &argv); argc = FUN(el,parse)(el, argc, argv); FUN(tok,end)(tok); - return (argc); + return argc; } @@ -94,34 +94,34 @@ FUN(el,parse)(EditLine *el, int argc, const Char *argv[]) int i; if (argc < 1) - return (-1); + return -1; ptr = Strchr(argv[0], ':'); if (ptr != NULL) { Char *tprog; size_t l; if (ptr == argv[0]) - return (0); + return 0; l = ptr - argv[0] - 1; tprog = reallocarray(NULL, l + 1, sizeof(*tprog)); if (tprog == NULL) - return (0); + return 0; (void) Strncpy(tprog, argv[0], l); tprog[l] = '\0'; ptr++; l = el_match(el->el_prog, tprog); free(tprog); if (!l) - return (0); + return 0; } else ptr = argv[0]; for (i = 0; cmds[i].name != NULL; i++) if (Strcmp(cmds[i].name, ptr) == 0) { i = (*cmds[i].func) (el, argc, argv); - return (-i); + return -i; } - return (-1); + return -1; } @@ -138,7 +138,7 @@ parse__escape(const Char **ptr) p = *ptr; if (p[1] == 0) - return (-1); + return -1; if (*p == '\\') { p++; @@ -174,12 +174,12 @@ parse__escape(const Char **ptr) const Char *h; ++p; if (*p++ != '+') - return (-1); + return -1; c = 0; for (i = 0; i < 5; ++i) { h = Strchr(hex, *p++); if (!h && i < 4) - return (-1); + return -1; else if (h) c = (c << 4) | ((int)(h - hex)); else @@ -209,7 +209,7 @@ parse__escape(const Char **ptr) c = (c << 3) | (ch - '0'); } if ((c & 0xffffff00) != 0) - return (-1); + return -1; --p; break; } @@ -223,7 +223,7 @@ parse__escape(const Char **ptr) } else c = *p; *ptr = ++p; - return (c); + return c; } /* parse__string(): @@ -239,12 +239,12 @@ parse__string(Char *out, const Char *in) switch (*in) { case '\0': *out = '\0'; - return (rv); + return rv; case '\\': case '^': if ((n = parse__escape(&in)) == -1) - return (NULL); + return NULL; *out++ = n; break; @@ -275,6 +275,6 @@ parse_cmd(EditLine *el, const Char *cmd) for (b = el->el_map.help, i = 0; i < el->el_map.nfunc; i++) if (Strcmp(b[i].name, cmd) == 0) - return (b[i].func); - return (-1); + return b[i].func; + return -1; } diff --git a/lib/libedit/prompt.c b/lib/libedit/prompt.c index 092a000c271..5463bd21dcb 100644 --- a/lib/libedit/prompt.c +++ b/lib/libedit/prompt.c @@ -1,5 +1,5 @@ -/* $OpenBSD: prompt.c,v 1.10 2016/01/30 00:06:39 schwarze Exp $ */ -/* $NetBSD: prompt.c,v 1.18 2009/12/31 15:58:26 christos Exp $ */ +/* $OpenBSD: prompt.c,v 1.11 2016/01/30 12:22:20 schwarze Exp $ */ +/* $NetBSD: prompt.c,v 1.20 2011/07/29 15:16:33 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -53,7 +53,7 @@ prompt_default(EditLine *el __attribute__((__unused__))) { static Char a[3] = {'?', ' ', '\0'}; - return (a); + return a; } @@ -66,7 +66,7 @@ prompt_default_r(EditLine *el __attribute__((__unused__))) { static Char a[1] = {'\0'}; - return (a); + return a; } diff --git a/lib/libedit/read.c b/lib/libedit/read.c index ea8b09fcc10..c152dca3696 100644 --- a/lib/libedit/read.c +++ b/lib/libedit/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.17 2016/01/30 00:06:39 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.18 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: read.c,v 1.57 2010/07/21 18:18:52 christos Exp $ */ /*- @@ -85,7 +85,7 @@ el_read_setfn(EditLine *el, el_rfunc_t rc) protected el_rfunc_t el_read_getfn(EditLine *el) { - return (el->el_read.read_char == read_char) ? + return el->el_read.read_char == read_char ? EL_BUILTIN_GETCFN : el->el_read.read_char; } @@ -144,10 +144,10 @@ read__fixio(int fd __attribute__((__unused__)), int e) #ifdef TRY_AGAIN #if defined(F_SETFL) && defined(O_NDELAY) if ((e = fcntl(fd, F_GETFL, 0)) == -1) - return (-1); + return -1; if (fcntl(fd, F_SETFL, e & ~O_NDELAY) == -1) - return (-1); + return -1; else e = 1; #endif /* F_SETFL && O_NDELAY */ @@ -157,20 +157,20 @@ read__fixio(int fd __attribute__((__unused__)), int e) int zero = 0; if (ioctl(fd, FIONBIO, (ioctl_t) & zero) == -1) - return (-1); + return -1; else e = 1; } #endif /* FIONBIO */ #endif /* TRY_AGAIN */ - return (e ? 0 : -1); + return e ? 0 : -1; case EINTR: - return (0); + return 0; default: - return (-1); + return -1; } } @@ -184,7 +184,7 @@ read_preread(EditLine *el) int chrs = 0; if (el->el_tty.t_mode == ED_IO) - return (0); + return 0; #ifndef WIDECHAR /* FIONREAD attempts to buffer up multiple bytes, and to make that work @@ -203,7 +203,7 @@ read_preread(EditLine *el) } #endif /* FIONREAD */ #endif - return (chrs > 0); + return chrs > 0; } @@ -240,7 +240,7 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch) do { if ((num = FUN(el,getc)(el, ch)) != 1) {/* if EOF or error */ el->el_errno = num == 0 ? 0 : errno; - return (num); + return num; } #ifdef KANJI @@ -285,7 +285,7 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch) el->el_map.current = el->el_map.key; } while (cmd == ED_SEQUENCE_LEAD_IN); *cmdnum = cmd; - return (OKCMD); + return OKCMD; } #ifdef WIDECHAR @@ -295,8 +295,8 @@ read_getcmd(EditLine *el, el_action_t *cmdnum, Char *ch) private int utf8_islead(unsigned char c) { - return (c < 0x80) || /* single byte char */ - (c >= 0xc2 && c <= 0xf4); /* start of multibyte sequence */ + return c < 0x80 || /* single byte char */ + (c >= 0xc2 && c <= 0xf4); /* start of multibyte sequence */ } #endif @@ -329,7 +329,7 @@ read_char(EditLine *el, Char *cp) tried = 1; else { *cp = '\0'; - return (-1); + return -1; } } @@ -342,7 +342,7 @@ read_char(EditLine *el, Char *cp) ct_mbtowc_reset; if (cbp >= MB_LEN_MAX) { /* "shouldn't happen" */ *cp = '\0'; - return (-1); + return -1; } goto again; } @@ -404,14 +404,14 @@ FUN(el,getc)(EditLine *el, Char *cp) read_pop(ma); } - return (1); + return 1; } #ifdef DEBUG_READ (void) fprintf(el->el_errfile, "Turning raw mode on\n"); #endif /* DEBUG_READ */ if (tty_rawmode(el) < 0)/* make sure the tty is set up correctly */ - return (0); + return 0; #ifdef DEBUG_READ (void) fprintf(el->el_errfile, "Reading a character\n"); @@ -424,7 +424,7 @@ FUN(el,getc)(EditLine *el, Char *cp) #ifdef DEBUG_READ (void) fprintf(el->el_errfile, "Got it %c\n", *cp); #endif /* DEBUG_READ */ - return (num_read); + return num_read; } protected void @@ -511,7 +511,7 @@ FUN(el,gets)(EditLine *el, int *nread) if (tty_rawmode(el) < 0) { errno = 0; *nread = 0; - return (NULL); + return NULL; } } } diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c index 92c52cf9058..f39f2ca838a 100644 --- a/lib/libedit/readline.c +++ b/lib/libedit/readline.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readline.c,v 1.14 2015/02/06 23:21:58 millert Exp $ */ +/* $OpenBSD: readline.c,v 1.15 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: readline.c,v 1.91 2010/08/28 15:44:59 christos Exp $ */ /*- @@ -176,7 +176,7 @@ static char * _get_prompt(EditLine *el __attribute__((__unused__))) { rl_already_prompted = 1; - return (rl_prompt); + return rl_prompt; } @@ -190,12 +190,12 @@ _move_history(int op) static HIST_ENTRY rl_he; if (history(h, &ev, op) != 0) - return (HIST_ENTRY *) NULL; + return NULL; rl_he.line = ev.str; rl_he.data = NULL; - return (&rl_he); + return &rl_he; } @@ -304,7 +304,7 @@ rl_initialize(void) h = history_init(); if (!e || !h) - return (-1); + return -1; history(h, &ev, H_SETSIZE, INT_MAX); /* unlimited */ history_length = 0; @@ -365,7 +365,7 @@ rl_initialize(void) if (rl_startup_hook) (*rl_startup_hook)(NULL, 0); - return (0); + return 0; } @@ -485,13 +485,13 @@ _rl_compat_sub(const char *str, const char *what, const char *with, s += what_len; if (!globally) { (void)strlcpy(r, s, len); - return(result); + return result; } } else *r++ = *s++; } *r = '\0'; - return(result); + return result; } static char *last_search_pat; /* last !?pat[?] search pattern */ @@ -508,12 +508,12 @@ get_history_event(const char *cmd, int *cindex, int qchar) idx = *cindex; if (cmd[idx++] != history_expansion_char) - return(NULL); + return NULL; /* find out which event to take */ if (cmd[idx] == history_expansion_char || cmd[idx] == '\0') { if (history(h, &ev, H_FIRST) != 0) - return(NULL); + return NULL; *cindex = cmd[idx]? (idx + 1):idx; return ev.str; } @@ -535,10 +535,10 @@ get_history_event(const char *cmd, int *cindex, int qchar) num = history_length - num + 1; if (!(rl_he = history_get(num))) - return(NULL); + return NULL; *cindex = idx; - return(rl_he->line); + return rl_he->line; } sub = 0; if (cmd[idx] == '?') { @@ -562,7 +562,7 @@ get_history_event(const char *cmd, int *cindex, int qchar) if (sub && len == 0 && last_search_pat && *last_search_pat) pat = last_search_pat; else if (len == 0) - return(NULL); + return NULL; else { if ((pat = malloc(len + 1)) == NULL) return NULL; @@ -573,7 +573,7 @@ get_history_event(const char *cmd, int *cindex, int qchar) if (history(h, &ev, H_CURR) != 0) { if (pat != last_search_pat) free(pat); - return (NULL); + return NULL; } num = ev.num; @@ -593,7 +593,7 @@ get_history_event(const char *cmd, int *cindex, int qchar) (void)fprintf(rl_outstream, "%s: Event not found\n", pat); if (pat != last_search_pat) free(pat); - return(NULL); + return NULL; } if (sub && len) { @@ -606,7 +606,7 @@ get_history_event(const char *cmd, int *cindex, int qchar) free(pat); if (history(h, &ev, H_CURR) != 0) - return(NULL); + return NULL; *cindex = idx; rptr = ev.str; @@ -624,7 +624,7 @@ get_history_event(const char *cmd, int *cindex, int qchar) * returns 0 if data was not modified, 1 if it was and 2 if the string * should be only printed and not executed; in case of error, * returns -1 and *result points to NULL - * it's callers responsibility to free() string returned in *result + * it's the caller's responsibility to free() the string returned in *result */ static int _history_expand_command(const char *command, size_t offs, size_t cmdlen, @@ -673,7 +673,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen, } if (ptr == NULL && aptr == NULL) - return(-1); + return -1; if (!has_mods) { *result = strdup(aptr ? aptr : ptr); @@ -681,7 +681,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen, free(aptr); if (*result == NULL) return -1; - return(1); + return 1; } cmd = command + offs + idx + 1; @@ -727,7 +727,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen, command + offs + idx); if (aptr) free(aptr); - return(-1); + return -1; } } else tmp = strdup(aptr? aptr:ptr); @@ -737,7 +737,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen, if (*cmd == '\0' || ((size_t)(cmd - (command + offs)) >= cmdlen)) { *result = tmp; - return(1); + return 1; } for (; *cmd; cmd++) { @@ -812,7 +812,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen, } else { from = NULL; free(tmp); - return (-1); + return -1; } } cmd++; /* shift after delim */ @@ -866,7 +866,7 @@ _history_expand_command(const char *command, size_t offs, size_t cmdlen, } } *result = tmp; - return (p_on? 2:1); + return p_on? 2:1; } @@ -885,7 +885,7 @@ history_expand(char *str, char **output) if (history_expansion_char == 0) { *output = strdup(str); - return(0); + return 0; } *output = NULL; @@ -1001,7 +1001,7 @@ loop: free(*output); *output = result; - return (ret); + return ret; } /* @@ -1117,7 +1117,7 @@ history_tokenize(const char *str) if (str[i]) i++; } - return (result); + return result; } @@ -1149,7 +1149,7 @@ unstifle_history(void) history(h, &ev, H_SETSIZE, INT_MAX); omax = max_input_history; max_input_history = INT_MAX; - return (omax); /* some value _must_ be returned */ + return omax; /* some value _must_ be returned */ } @@ -1158,7 +1158,7 @@ history_is_stifled(void) { /* cannot return true answer */ - return (max_input_history != INT_MAX); + return max_input_history != INT_MAX; } static const char _history_tmp_template[] = "/tmp/.historyXXXXXX"; @@ -1310,8 +1310,8 @@ read_history(const char *filename) rl_initialize(); if (filename == NULL && (filename = _default_history_file()) == NULL) return errno; - return (history(h, &ev, H_LOAD, filename) == -1 ? - (errno ? errno : EINVAL) : 0); + return history(h, &ev, H_LOAD, filename) == -1 ? + (errno ? errno : EINVAL) : 0; } @@ -1327,8 +1327,8 @@ write_history(const char *filename) rl_initialize(); if (filename == NULL && (filename = _default_history_file()) == NULL) return errno; - return (history(h, &ev, H_SAVE, filename) == -1 ? - (errno ? errno : EINVAL) : 0); + return history(h, &ev, H_SAVE, filename) == -1 ? + (errno ? errno : EINVAL) : 0; } @@ -1349,23 +1349,23 @@ history_get(int num) /* save current position */ if (history(h, &ev, H_CURR) != 0) - return (NULL); + return NULL; curr_num = ev.num; /* start from the oldest */ if (history(h, &ev, H_LAST) != 0) - return (NULL); /* error */ + return NULL; /* error */ /* look forwards for event matching specified offset */ if (history(h, &ev, H_NEXT_EVDATA, num, &she.data)) - return (NULL); + return NULL; she.line = ev.str; /* restore pointer to where it was */ (void)history(h, &ev, H_SET, curr_num); - return (&she); + return &she; } @@ -1384,7 +1384,7 @@ add_history(const char *line) if (history(h, &ev, H_GETSIZE) == 0) history_length = ev.num; - return (!(history_length > 0)); /* return 0 if all is okay */ + return !(history_length > 0); /* return 0 if all is okay */ } @@ -1485,7 +1485,7 @@ where_history(void) int curr_num, off; if (history(h, &ev, H_CURR) != 0) - return (0); + return 0; curr_num = ev.num; (void)history(h, &ev, H_FIRST); @@ -1493,7 +1493,7 @@ where_history(void) while (ev.num != curr_num && history(h, &ev, H_NEXT) == 0) off++; - return (off); + return off; } @@ -1504,7 +1504,7 @@ HIST_ENTRY * current_history(void) { - return (_move_history(H_CURR)); + return _move_history(H_CURR); } @@ -1519,7 +1519,7 @@ history_total_bytes(void) size_t size; if (history(h, &ev, H_CURR) != 0) - return (-1); + return -1; curr_num = ev.num; (void)history(h, &ev, H_FIRST); @@ -1531,7 +1531,7 @@ history_total_bytes(void) /* get to the same position as before */ history(h, &ev, H_PREV_EVENT, curr_num); - return (int)(size); + return (int)size; } @@ -1545,7 +1545,7 @@ history_set_pos(int pos) int curr_num; if (pos >= history_length || pos < 0) - return (-1); + return -1; (void)history(h, &ev, H_CURR); curr_num = ev.num; @@ -1556,9 +1556,9 @@ history_set_pos(int pos) */ if (history(h, &ev, H_DELDATA, pos, (void **)-1)) { (void)history(h, &ev, H_SET, curr_num); - return(-1); + return -1; } - return (0); + return 0; } @@ -1569,7 +1569,7 @@ HIST_ENTRY * previous_history(void) { - return (_move_history(H_PREV)); + return _move_history(H_PREV); } @@ -1580,7 +1580,7 @@ HIST_ENTRY * next_history(void) { - return (_move_history(H_NEXT)); + return _move_history(H_NEXT); } @@ -1595,17 +1595,17 @@ history_search(const char *str, int direction) int curr_num; if (history(h, &ev, H_CURR) != 0) - return (-1); + return -1; curr_num = ev.num; for (;;) { if ((strp = strstr(ev.str, str)) != NULL) - return (int) (strp - ev.str); + return (int)(strp - ev.str); if (history(h, &ev, direction < 0 ? H_NEXT:H_PREV) != 0) break; } (void)history(h, &ev, H_SET, curr_num); - return (-1); + return -1; } @@ -1638,15 +1638,15 @@ history_search_pos(const char *str, pos = (pos > 0) ? 1 : -1; if (history(h, &ev, H_CURR) != 0) - return (-1); + return -1; curr_num = ev.num; if (history_set_pos(off) != 0 || history(h, &ev, H_CURR) != 0) - return (-1); + return -1; for (;;) { if (strstr(ev.str, str)) - return (off); + return off; if (history(h, &ev, (pos < 0) ? H_PREV : H_NEXT) != 0) break; } @@ -1655,7 +1655,7 @@ history_search_pos(const char *str, (void)history(h, &ev, pos < 0 ? H_NEXT_EVENT : H_PREV_EVENT, curr_num); - return (-1); + return -1; } @@ -1679,7 +1679,7 @@ filename_completion_function(const char *name, int state) * which starts with supplied text * text contains a partial username preceded by random character * (usually '~'); state is ignored - * it's callers responsibility to free returned value + * it's the caller's responsibility to free the returned value */ char * username_completion_function(const char *text, int state) @@ -1687,7 +1687,7 @@ username_completion_function(const char *text, int state) struct passwd *pwd; if (text[0] == '\0') - return (NULL); + return NULL; if (*text == '~') text++; @@ -1760,7 +1760,7 @@ rl_complete(int ignore __attribute__((__unused__)), int invoking_key) arr[0] = (char)invoking_key; arr[1] = '\0'; el_insertstr(e, arr); - return (CC_REFRESH); + return CC_REFRESH; } /* Just look at how many global variables modify this operation! */ @@ -1805,7 +1805,7 @@ rl_bind_key(int c, rl_command_func_t *func) e->el_map.key[c] = ED_INSERT; retval = 0; } - return (retval); + return retval; } @@ -1821,7 +1821,7 @@ rl_read_key(void) if (e == NULL || h == NULL) rl_initialize(); - return (el_getc(e, fooarr)); + return el_getc(e, fooarr); } @@ -1857,20 +1857,20 @@ rl_insert(int count, int c) for (; count > 0; count--) el_push(e, arr); - return (0); + return 0; } int rl_insert_text(const char *text) { if (!text || *text == 0) - return (0); + return 0; if (h == NULL || e == NULL) rl_initialize(); if (el_insertstr(e, text) < 0) - return (0); + return 0; return (int)strlen(text); } @@ -1995,7 +1995,7 @@ rl_deprep_terminal(void) int rl_read_init_file(const char *s) { - return(el_source(e, s)); + return el_source(e, s); } int @@ -2009,7 +2009,7 @@ rl_parse_and_bind(const char *line) tok_str(tok, line, &argc, &argv); argc = el_parse(e, argc, argv); tok_end(tok); - return (argc ? 1 : 0); + return argc ? 1 : 0; } int @@ -2019,7 +2019,7 @@ rl_variable_bind(const char *var, const char *value) * The proper return value is undocument, but this is what the * readline source seems to do. */ - return ((el_set(e, EL_BIND, "", var, value, NULL) == -1) ? 1 : 0); + return el_set(e, EL_BIND, "", var, value, NULL) == -1 ? 1 : 0; } void @@ -2045,23 +2045,23 @@ _rl_event_read_char(EditLine *el, char *cp) #if defined(FIONREAD) if (ioctl(el->el_infd, FIONREAD, &n) < 0) - return(-1); + return -1; if (n) num_read = read(el->el_infd, cp, 1); else num_read = 0; #elif defined(F_SETFL) && defined(O_NDELAY) if ((n = fcntl(el->el_infd, F_GETFL, 0)) < 0) - return(-1); + return -1; if (fcntl(el->el_infd, F_SETFL, n|O_NDELAY) < 0) - return(-1); + return -1; num_read = read(el->el_infd, cp, 1); if (fcntl(el->el_infd, F_SETFL, n)) - return(-1); + return -1; #else /* not non-blocking, but what you gonna do? */ num_read = read(el->el_infd, cp, 1); - return(-1); + return -1; #endif if (num_read < 0 && errno == EAGAIN) @@ -2190,9 +2190,9 @@ history_get_history_state(void) HISTORY_STATE *hs; if ((hs = malloc(sizeof(HISTORY_STATE))) == NULL) - return (NULL); + return NULL; hs->length = history_length; - return (hs); + return hs; } int diff --git a/lib/libedit/search.c b/lib/libedit/search.c index 56cf3f8ebe2..10a5c4cfa36 100644 --- a/lib/libedit/search.c +++ b/lib/libedit/search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: search.c,v 1.14 2016/01/30 00:06:39 schwarze Exp $ */ +/* $OpenBSD: search.c,v 1.15 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: search.c,v 1.24 2010/04/15 00:57:33 christos Exp $ */ /*- @@ -63,13 +63,13 @@ search_init(EditLine *el) el->el_search.patbuf = reallocarray(NULL, EL_BUFSIZ, sizeof(*el->el_search.patbuf)); if (el->el_search.patbuf == NULL) - return (-1); + return -1; el->el_search.patlen = 0; el->el_search.patdir = -1; el->el_search.chacha = '\0'; el->el_search.chadir = CHAR_FWD; el->el_search.chatflg = 0; - return (0); + return 0; } @@ -118,7 +118,7 @@ el_match(const Char *str, const Char *pat) #endif if (Strstr(str, pat) != 0) - return (1); + return 1; #if defined(REGEX) if (regcomp(&re, ct_encode_string(pat, &conv), 0) == 0) { @@ -127,7 +127,7 @@ el_match(const Char *str, const Char *pat) } else { rv = 0; } - return (rv); + return rv; #elif defined(REGEXP) if ((re = regcomp(ct_encode_string(pat, &conv))) != NULL) { rv = regexec(re, ct_encode_string(str, &conv)); @@ -135,12 +135,12 @@ el_match(const Char *str, const Char *pat) } else { rv = 0; } - return (rv); + return rv; #else if (re_comp(ct_encode_string(pat, &conv)) != NULL) - return (0); + return 0; else - return (re_exec(ct_encode_string(str, &conv)) == 1); + return re_exec(ct_encode_string(str, &conv)) == 1; #endif } @@ -156,7 +156,7 @@ c_hmatch(EditLine *el, const Char *str) el->el_search.patbuf, str); #endif /* SDEBUG */ - return (el_match(str, el->el_search.patbuf)); + return el_match(str, el->el_search.patbuf); } @@ -214,7 +214,7 @@ ce_inc_search(EditLine *el, int dir) if (el->el_line.lastchar + sizeof(STRfwd) / sizeof(*el->el_line.lastchar) + 2 + el->el_search.patlen >= el->el_line.limit) - return (CC_ERROR); + return CC_ERROR; for (;;) { @@ -242,7 +242,7 @@ ce_inc_search(EditLine *el, int dir) re_refresh(el); if (FUN(el,getc)(el, &ch) != 1) - return (ed_end_of_file(el, 0)); + return ed_end_of_file(el, 0); switch (el->el_map.current[(unsigned char) ch]) { case ED_INSERT: @@ -401,7 +401,7 @@ ce_inc_search(EditLine *el, int dir) el->el_history.eventno = ohisteventno; if (hist_get(el) == CC_ERROR) - return (CC_ERROR); + return CC_ERROR; } el->el_line.cursor = ocursor; pchar = '?'; @@ -426,14 +426,14 @@ ce_inc_search(EditLine *el, int dir) if (el->el_history.eventno != ohisteventno) { el->el_history.eventno = ohisteventno; if (hist_get(el) == CC_ERROR) - return (CC_ERROR); + return CC_ERROR; } el->el_line.cursor = ocursor; if (ret == CC_ERROR) re_refresh(el); } if (done || ret != CC_NORM) - return (ret); + return ret; } } @@ -471,7 +471,7 @@ cv_search(EditLine *el, int dir) */ if (el->el_search.patlen == 0) { re_refresh(el); - return (CC_ERROR); + return CC_ERROR; } #ifdef ANCHOR if (el->el_search.patbuf[0] != '.' && @@ -502,13 +502,13 @@ cv_search(EditLine *el, int dir) if ((dir == ED_SEARCH_PREV_HISTORY ? ed_search_prev_history(el, 0) : ed_search_next_history(el, 0)) == CC_ERROR) { re_refresh(el); - return (CC_ERROR); + return CC_ERROR; } if (ch == 0033) { re_refresh(el); return ed_newline(el, 0); } - return (CC_REFRESH); + return CC_REFRESH; } @@ -535,21 +535,21 @@ ce_search_line(EditLine *el, int dir) if (el_match(cp, ocp)) { *ocp = oc; el->el_line.cursor = cp; - return (CC_NORM); + return CC_NORM; } } *ocp = oc; - return (CC_ERROR); + return CC_ERROR; } else { for (; *cp != '\0' && cp < el->el_line.limit; cp++) { if (el_match(cp, ocp)) { *ocp = oc; el->el_line.cursor = cp; - return (CC_NORM); + return CC_NORM; } } *ocp = oc; - return (CC_ERROR); + return CC_ERROR; } } @@ -571,11 +571,11 @@ cv_repeat_srch(EditLine *el, Int c) switch (c) { case ED_SEARCH_NEXT_HISTORY: - return (ed_search_next_history(el, 0)); + return ed_search_next_history(el, 0); case ED_SEARCH_PREV_HISTORY: - return (ed_search_prev_history(el, 0)); + return ed_search_prev_history(el, 0); default: - return (CC_ERROR); + return CC_ERROR; } } diff --git a/lib/libedit/terminal.c b/lib/libedit/terminal.c index 1bc58fd79a3..7890b8d8608 100644 --- a/lib/libedit/terminal.c +++ b/lib/libedit/terminal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: terminal.c,v 1.4 2016/01/30 02:52:41 schwarze Exp $ */ +/* $OpenBSD: terminal.c,v 1.5 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: term.c,v 1.57 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -281,7 +281,7 @@ terminal_init(EditLine *el) (void) memset(el->el_terminal.t_val, 0, T_val * sizeof(int)); (void) terminal_set(el, NULL); terminal_init_arrow(el); - return (0); + return 0; fail5: free(el->el_terminal.t_str); el->el_terminal.t_str = NULL; @@ -295,7 +295,7 @@ fail2: free(el->el_terminal.t_buf); el->el_terminal.t_buf = NULL; fail: - return (-1); + return -1; } /* terminal_end(): @@ -399,8 +399,8 @@ terminal_rebuffer_display(EditLine *el) c->v = Val(T_li); if (terminal_alloc_display(el) == -1) - return (-1); - return (0); + return -1; + return 0; } @@ -448,7 +448,7 @@ terminal_alloc_display(EditLine *el) done: if (rv) terminal_free_display(el); - return (rv); + return rv; } @@ -933,11 +933,11 @@ terminal_set(EditLine *el, const char *term) /* get the correct window size */ (void) terminal_get_size(el, &lins, &cols); if (terminal_change_size(el, lins, cols) == -1) - return (-1); + return -1; (void) sigprocmask(SIG_SETMASK, &oset, NULL); terminal_bind_arrow(el); el->el_terminal.t_name = term; - return (i <= 0 ? -1 : 0); + return i <= 0 ? -1 : 0; } @@ -974,7 +974,7 @@ terminal_get_size(EditLine *el, int *lins, int *cols) } } #endif - return (Val(T_co) != *cols || Val(T_li) != *lins); + return Val(T_co) != *cols || Val(T_li) != *lins; } @@ -992,9 +992,9 @@ terminal_change_size(EditLine *el, int lins, int cols) /* re-make display buffers */ if (terminal_rebuffer_display(el) == -1) - return (-1); + return -1; re_clear_display(el); - return (0); + return 0; } @@ -1102,9 +1102,9 @@ terminal_set_arrow(EditLine *el, const Char *name, keymacro_value_t *fun, if (Strcmp(name, arrow[i].name) == 0) { arrow[i].fun = *fun; arrow[i].type = type; - return (0); + return 0; } - return (-1); + return -1; } @@ -1120,9 +1120,9 @@ terminal_clear_arrow(EditLine *el, const Char *name) for (i = 0; i < A_K_NKEYS; i++) if (Strcmp(name, arrow[i].name) == 0) { arrow[i].type = XK_NOD; - return (0); + return 0; } - return (-1); + return -1; } @@ -1311,7 +1311,7 @@ terminal_telltc(EditLine *el, int argc __attribute__((__unused__)), t->long_name, t->name, ub); } (void) fputc('\n', el->el_outfile); - return (0); + return 0; } @@ -1407,7 +1407,7 @@ terminal_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv) void *how; if (argv == NULL || argv[1] == NULL || argv[2] == NULL) - return (-1); + return -1; what = argv[1]; how = argv[2]; @@ -1469,7 +1469,7 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), area = buf; if (argv == NULL || argv[1] == NULL) - return (-1); + return -1; argv++; if (argv[0][0] == '-') { @@ -1487,31 +1487,31 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), argv++; } if (!*argv || *argv[0] == '\0') - return (0); + return 0; if (Strcmp(*argv, STR("tabs")) == 0) { (void) fprintf(el->el_outfile, fmts, EL_CAN_TAB ? "yes" : "no"); - return (0); + return 0; } else if (Strcmp(*argv, STR("meta")) == 0) { (void) fprintf(el->el_outfile, fmts, Val(T_km) ? "yes" : "no"); - return (0); + return 0; } else if (Strcmp(*argv, STR("xn")) == 0) { (void) fprintf(el->el_outfile, fmts, EL_HAS_MAGIC_MARGINS ? "yes" : "no"); - return (0); + return 0; } else if (Strcmp(*argv, STR("am")) == 0) { (void) fprintf(el->el_outfile, fmts, EL_HAS_AUTO_MARGINS ? "yes" : "no"); - return (0); + return 0; } else if (Strcmp(*argv, STR("baud")) == 0) { (void) fprintf(el->el_outfile, fmtd, (int)el->el_tty.t_speed); - return (0); + return 0; } else if (Strcmp(*argv, STR("rows")) == 0 || Strcmp(*argv, STR("lines")) == 0) { (void) fprintf(el->el_outfile, fmtd, Val(T_li)); - return (0); + return 0; } else if (Strcmp(*argv, STR("cols")) == 0) { (void) fprintf(el->el_outfile, fmtd, Val(T_co)); - return (0); + return 0; } /* * Try to use our local definition first @@ -1532,7 +1532,7 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), (void) fprintf(el->el_errfile, "echotc: Termcap parameter `" FSTR "' not found.\n", *argv); - return (-1); + return -1; } /* * Count home many values we need for this capability. @@ -1575,7 +1575,7 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), (void) fprintf(el->el_errfile, "echotc: Warning: Extra argument `" FSTR "'.\n", *argv); - return (-1); + return -1; } terminal_tputs(el, scap, 1); break; @@ -1585,7 +1585,7 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), if (!silent) (void) fprintf(el->el_errfile, "echotc: Warning: Missing argument.\n"); - return (-1); + return -1; } arg_cols = 0; i = Strtol(*argv, &ep, 10); @@ -1594,7 +1594,7 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), (void) fprintf(el->el_errfile, "echotc: Bad value `" FSTR "' for rows.\n", *argv); - return (-1); + return -1; } arg_rows = (int) i; argv++; @@ -1603,7 +1603,7 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), (void) fprintf(el->el_errfile, "echotc: Warning: Extra argument `" FSTR "'.\n", *argv); - return (-1); + return -1; } terminal_tputs(el, tgoto(scap, arg_cols, arg_rows), 1); break; @@ -1620,7 +1620,7 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), if (!silent) (void) fprintf(el->el_errfile, "echotc: Warning: Missing argument.\n"); - return (-1); + return -1; } i = Strtol(*argv, &ep, 10); if (*ep != '\0' || i < 0) { @@ -1628,7 +1628,7 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), (void) fprintf(el->el_errfile, "echotc: Bad value `" FSTR "' for cols.\n", *argv); - return (-1); + return -1; } arg_cols = (int) i; argv++; @@ -1636,7 +1636,7 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), if (!silent) (void) fprintf(el->el_errfile, "echotc: Warning: Missing argument.\n"); - return (-1); + return -1; } i = Strtol(*argv, &ep, 10); if (*ep != '\0' || i < 0) { @@ -1644,14 +1644,14 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), (void) fprintf(el->el_errfile, "echotc: Bad value `" FSTR "' for rows.\n", *argv); - return (-1); + return -1; } arg_rows = (int) i; if (*ep != '\0') { if (!silent) (void) fprintf(el->el_errfile, "echotc: Bad value `" FSTR "'.\n", *argv); - return (-1); + return -1; } argv++; if (*argv && *argv[0]) { @@ -1659,10 +1659,10 @@ terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), (void) fprintf(el->el_errfile, "echotc: Warning: Extra argument `" FSTR "'.\n", *argv); - return (-1); + return -1; } terminal_tputs(el, tgoto(scap, arg_cols, arg_rows), arg_rows); break; } - return (0); + return 0; } diff --git a/lib/libedit/tokenizer.c b/lib/libedit/tokenizer.c index 409e387c1d5..7af433a38c0 100644 --- a/lib/libedit/tokenizer.c +++ b/lib/libedit/tokenizer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tokenizer.c,v 1.13 2014/10/17 06:07:50 deraadt Exp $ */ +/* $OpenBSD: tokenizer.c,v 1.14 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: tokenizer.c,v 1.18 2010/01/03 18:27:10 christos Exp $ */ /*- @@ -128,7 +128,7 @@ FUN(tok,init)(const Char *ifs) tok->flags = 0; tok->quote = Q_none; - return (tok); + return tok; } @@ -224,7 +224,7 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line, break; default: - return (-1); + return -1; } break; @@ -255,7 +255,7 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line, break; default: - return (-1); + return -1; } break; @@ -286,7 +286,7 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line, break; default: - return (-1); + return -1; } break; @@ -312,7 +312,7 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line, break; default: - return (0); + return 0; } break; @@ -322,15 +322,15 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line, /* Finish word and return */ if (tok->flags & TOK_EAT) { tok->flags &= ~TOK_EAT; - return (3); + return 3; } goto tok_line_outok; case Q_single: - return (1); + return 1; case Q_double: - return (2); + return 2; case Q_doubleone: tok->quote = Q_double; @@ -343,7 +343,7 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line, break; default: - return (-1); + return -1; } break; @@ -375,7 +375,7 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line, break; default: - return (-1); + return -1; } break; @@ -385,7 +385,7 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line, size_t size = tok->wmax - tok->wspace + WINCR; Char *s = reallocarray(tok->wspace, size, sizeof(*s)); if (s == NULL) - return (-1); + return -1; if (s != tok->wspace) { int i; @@ -404,7 +404,7 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line, tok->amax += AINCR; p = reallocarray(tok->argv, tok->amax, sizeof(*p)); if (p == NULL) - return (-1); + return -1; tok->argv = p; } } @@ -420,7 +420,7 @@ FUN(tok,line)(TYPE(Tokenizer) *tok, const TYPE(LineInfo) *line, FUN(tok,finish)(tok); *argv = (const Char **)tok->argv; *argc = tok->argc; - return (0); + return 0; } /* FUN(tok,str)(): @@ -436,5 +436,5 @@ FUN(tok,str)(TYPE(Tokenizer) *tok, const Char *line, int *argc, memset(&li, 0, sizeof(li)); li.buffer = line; li.cursor = li.lastchar = Strchr(line, '\0'); - return (FUN(tok,line)(tok, &li, argc, argv, NULL, NULL)); + return FUN(tok,line)(tok, &li, argc, argv, NULL, NULL); } diff --git a/lib/libedit/tty.c b/lib/libedit/tty.c index fdb274103fb..7ddfa8ec597 100644 --- a/lib/libedit/tty.c +++ b/lib/libedit/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.17 2016/01/30 02:52:41 schwarze Exp $ */ +/* $OpenBSD: tty.c,v 1.18 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: tty.c,v 1.34 2011/01/27 23:11:40 christos Exp $ */ /*- @@ -490,21 +490,21 @@ tty_setup(EditLine *el) int rst = 1; if (el->el_flags & EDIT_DISABLED) - return (0); + return 0; if (!isatty(el->el_outfd)) { #ifdef DEBUG_TTY (void) fprintf(el->el_errfile, "tty_setup: isatty: %s\n", strerror(errno)); #endif /* DEBUG_TTY */ - return (-1); + return -1; } if (tty_getty(el, &el->el_tty.t_ed) == -1) { #ifdef DEBUG_TTY (void) fprintf(el->el_errfile, "tty_setup: tty_getty: %s\n", strerror(errno)); #endif /* DEBUG_TTY */ - return (-1); + return -1; } el->el_tty.t_ts = el->el_tty.t_ex = el->el_tty.t_ed; @@ -544,7 +544,7 @@ tty_setup(EditLine *el) "tty_setup: tty_setty: %s\n", strerror(errno)); #endif /* DEBUG_TTY */ - return (-1); + return -1; } } @@ -552,7 +552,7 @@ tty_setup(EditLine *el) tty__setchar(&el->el_tty.t_ed, el->el_tty.t_c[ED_IO]); tty_bind_char(el, 1); - return (0); + return 0; } protected int @@ -563,7 +563,7 @@ tty_init(EditLine *el) el->el_tty.t_vdisable = _POSIX_VDISABLE; (void) memcpy(el->el_tty.t_t, ttyperm, sizeof(ttyperm_t)); (void) memcpy(el->el_tty.t_c, ttychar, sizeof(ttychar_t)); - return (tty_setup(el)); + return tty_setup(el); } @@ -589,7 +589,7 @@ tty__getspeed(struct termios *td) if ((spd = cfgetispeed(td)) == 0) spd = cfgetospeed(td); - return (spd); + return spd; } /* tty__getspeed(): @@ -970,17 +970,17 @@ tty_rawmode(EditLine *el) { if (el->el_tty.t_mode == ED_IO || el->el_tty.t_mode == QU_IO) - return (0); + return 0; if (el->el_flags & EDIT_DISABLED) - return (0); + return 0; if (tty_getty(el, &el->el_tty.t_ts) == -1) { #ifdef DEBUG_TTY (void) fprintf(el->el_errfile, "tty_rawmode: tty_getty: %s\n", strerror(errno)); #endif /* DEBUG_TTY */ - return (-1); + return -1; } /* * We always keep up with the eight bit setting and the speed of the @@ -1040,10 +1040,10 @@ tty_rawmode(EditLine *el) (void) fprintf(el->el_errfile, "tty_rawmode: tty_setty: %s\n", strerror(errno)); #endif /* DEBUG_TTY */ - return (-1); + return -1; } el->el_tty.t_mode = ED_IO; - return (0); + return 0; } @@ -1055,10 +1055,10 @@ tty_cookedmode(EditLine *el) { /* set tty in normal setup */ if (el->el_tty.t_mode == EX_IO) - return (0); + return 0; if (el->el_flags & EDIT_DISABLED) - return (0); + return 0; if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ex) == -1) { #ifdef DEBUG_TTY @@ -1066,10 +1066,10 @@ tty_cookedmode(EditLine *el) "tty_cookedmode: tty_setty: %s\n", strerror(errno)); #endif /* DEBUG_TTY */ - return (-1); + return -1; } el->el_tty.t_mode = EX_IO; - return (0); + return 0; } @@ -1080,7 +1080,7 @@ protected int tty_quotemode(EditLine *el) { if (el->el_tty.t_mode == QU_IO) - return (0); + return 0; el->el_tty.t_qu = el->el_tty.t_ed; @@ -1091,10 +1091,10 @@ tty_quotemode(EditLine *el) (void) fprintf(el->el_errfile, "QuoteModeOn: tty_setty: %s\n", strerror(errno)); #endif /* DEBUG_TTY */ - return (-1); + return -1; } el->el_tty.t_mode = QU_IO; - return (0); + return 0; } @@ -1106,16 +1106,16 @@ tty_noquotemode(EditLine *el) { if (el->el_tty.t_mode != QU_IO) - return (0); + return 0; if (tty_setty(el, TCSADRAIN, &el->el_tty.t_ed) == -1) { #ifdef DEBUG_TTY (void) fprintf(el->el_errfile, "QuoteModeOff: tty_setty: %s\n", strerror(errno)); #endif /* DEBUG_TTY */ - return (-1); + return -1; } el->el_tty.t_mode = ED_IO; - return (0); + return 0; } @@ -1135,7 +1135,7 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv) int z = EX_IO; if (argv == NULL) - return (-1); + return -1; strncpy(name, ct_encode_string(*argv++, &el->el_scratch), sizeof(name)); name[sizeof(name) - 1] = '\0'; @@ -1164,7 +1164,7 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv) (void) fprintf(el->el_errfile, "%s: Unknown switch `%c'.\n", name, argv[0][1]); - return (-1); + return -1; } if (!argv || !*argv) { @@ -1209,7 +1209,7 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv) } } (void) fprintf(el->el_outfile, "\n"); - return (0); + return 0; } while (argv && (s = *argv++)) { const Char *p; @@ -1233,7 +1233,7 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv) if (!m->m_name) { (void) fprintf(el->el_errfile, "%s: Invalid argument `" FSTR "'.\n", name, d); - return (-1); + return -1; } if (p) { int c = ffs((int)m->m_value); @@ -1269,11 +1269,11 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv) (void) fprintf(el->el_errfile, "tty_stty: tty_setty: %s\n", strerror(errno)); #endif /* DEBUG_TTY */ - return (-1); + return -1; } } - return (0); + return 0; } diff --git a/lib/libedit/vi.c b/lib/libedit/vi.c index 475fdd33c09..17bff3ed853 100644 --- a/lib/libedit/vi.c +++ b/lib/libedit/vi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vi.c,v 1.13 2016/01/30 00:06:39 schwarze Exp $ */ +/* $OpenBSD: vi.c,v 1.14 2016/01/30 12:22:20 schwarze Exp $ */ /* $NetBSD: vi.c,v 1.33 2011/02/17 16:44:48 joerg Exp $ */ /*- @@ -72,11 +72,11 @@ cv_action(EditLine *el, Int c) if (c & INSERT) el->el_map.current = el->el_map.key; - return (CC_REFRESH); + return CC_REFRESH; } el->el_chared.c_vcmd.pos = el->el_line.cursor; el->el_chared.c_vcmd.action = c; - return (CC_ARGHACK); + return CC_ARGHACK; } /* cv_paste(): @@ -89,7 +89,7 @@ cv_paste(EditLine *el, Int c) size_t len = (size_t)(k->last - k->buf); if (k->buf == NULL || len == 0) - return (CC_ERROR); + return CC_ERROR; #ifdef DEBUG_PASTE (void) fprintf(el->el_errfile, "Paste: \"%.*s\"\n", (int)len, k->buf); #endif @@ -101,11 +101,11 @@ cv_paste(EditLine *el, Int c) c_insert(el, (int)len); if (el->el_line.cursor + len > el->el_line.lastchar) - return (CC_ERROR); + return CC_ERROR; (void) memcpy(el->el_line.cursor, k->buf, len * sizeof(*el->el_line.cursor)); - return (CC_REFRESH); + return CC_REFRESH; } @@ -118,7 +118,7 @@ protected el_action_t vi_paste_next(EditLine *el, Int c __attribute__((__unused__))) { - return (cv_paste(el, 0)); + return cv_paste(el, 0); } @@ -131,7 +131,7 @@ protected el_action_t vi_paste_prev(EditLine *el, Int c __attribute__((__unused__))) { - return (cv_paste(el, 1)); + return cv_paste(el, 1); } @@ -145,7 +145,7 @@ vi_prev_big_word(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_line.cursor == el->el_line.buffer) - return (CC_ERROR); + return CC_ERROR; el->el_line.cursor = cv_prev_word(el->el_line.cursor, el->el_line.buffer, @@ -154,9 +154,9 @@ vi_prev_big_word(EditLine *el, Int c __attribute__((__unused__))) if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -170,7 +170,7 @@ vi_prev_word(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_line.cursor == el->el_line.buffer) - return (CC_ERROR); + return CC_ERROR; el->el_line.cursor = cv_prev_word(el->el_line.cursor, el->el_line.buffer, @@ -179,9 +179,9 @@ vi_prev_word(EditLine *el, Int c __attribute__((__unused__))) if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -195,7 +195,7 @@ vi_next_big_word(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_line.cursor >= el->el_line.lastchar - 1) - return (CC_ERROR); + return CC_ERROR; el->el_line.cursor = cv_next_word(el, el->el_line.cursor, el->el_line.lastchar, el->el_state.argument, cv__isWord); @@ -203,9 +203,9 @@ vi_next_big_word(EditLine *el, Int c __attribute__((__unused__))) if (el->el_map.type == MAP_VI) if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -219,7 +219,7 @@ vi_next_word(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_line.cursor >= el->el_line.lastchar - 1) - return (CC_ERROR); + return CC_ERROR; el->el_line.cursor = cv_next_word(el, el->el_line.cursor, el->el_line.lastchar, el->el_state.argument, cv__isword); @@ -227,9 +227,9 @@ vi_next_word(EditLine *el, Int c __attribute__((__unused__))) if (el->el_map.type == MAP_VI) if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -243,7 +243,7 @@ vi_change_case(EditLine *el, Int c) int i; if (el->el_line.cursor >= el->el_line.lastchar) - return (CC_ERROR); + return CC_ERROR; cv_undo(el); for (i = 0; i < el->el_state.argument; i++) { @@ -277,7 +277,7 @@ vi_change_meta(EditLine *el, Int c __attribute__((__unused__))) * Delete with insert == change: first we delete and then we leave in * insert mode. */ - return (cv_action(el, DELETE | INSERT)); + return cv_action(el, DELETE | INSERT); } @@ -293,7 +293,7 @@ vi_insert_at_bol(EditLine *el, Int c __attribute__((__unused__))) el->el_line.cursor = el->el_line.buffer; cv_undo(el); el->el_map.current = el->el_map.key; - return (CC_CURSOR); + return CC_CURSOR; } @@ -312,7 +312,7 @@ vi_replace_char(EditLine *el, Int c __attribute__((__unused__))) el->el_map.current = el->el_map.key; el->el_state.inputmode = MODE_REPLACE_1; cv_undo(el); - return (CC_ARGHACK); + return CC_ARGHACK; } @@ -328,7 +328,7 @@ vi_replace_mode(EditLine *el, Int c __attribute__((__unused__))) el->el_map.current = el->el_map.key; el->el_state.inputmode = MODE_REPLACE; cv_undo(el); - return (CC_NORM); + return CC_NORM; } @@ -343,7 +343,7 @@ vi_substitute_char(EditLine *el, Int c __attribute__((__unused__))) c_delafter(el, el->el_state.argument); el->el_map.current = el->el_map.key; - return (CC_REFRESH); + return CC_REFRESH; } @@ -361,7 +361,7 @@ vi_substitute_line(EditLine *el, Int c __attribute__((__unused__))) (int)(el->el_line.lastchar - el->el_line.buffer)); (void) em_kill_line(el, 0); el->el_map.current = el->el_map.key; - return (CC_REFRESH); + return CC_REFRESH; } @@ -379,7 +379,7 @@ vi_change_to_eol(EditLine *el, Int c __attribute__((__unused__))) (int)(el->el_line.lastchar - el->el_line.cursor)); (void) ed_kill_line(el, 0); el->el_map.current = el->el_map.key; - return (CC_REFRESH); + return CC_REFRESH; } @@ -394,7 +394,7 @@ vi_insert(EditLine *el, Int c __attribute__((__unused__))) el->el_map.current = el->el_map.key; cv_undo(el); - return (CC_NORM); + return CC_NORM; } @@ -419,7 +419,7 @@ vi_add(EditLine *el, Int c __attribute__((__unused__))) cv_undo(el); - return (ret); + return ret; } @@ -435,7 +435,7 @@ vi_add_at_eol(EditLine *el, Int c __attribute__((__unused__))) el->el_map.current = el->el_map.key; el->el_line.cursor = el->el_line.lastchar; cv_undo(el); - return (CC_CURSOR); + return CC_CURSOR; } @@ -448,7 +448,7 @@ protected el_action_t vi_delete_meta(EditLine *el, Int c __attribute__((__unused__))) { - return (cv_action(el, DELETE)); + return cv_action(el, DELETE); } @@ -462,7 +462,7 @@ vi_end_big_word(EditLine *el, Int c) { if (el->el_line.cursor == el->el_line.lastchar) - return (CC_ERROR); + return CC_ERROR; el->el_line.cursor = cv__endword(el->el_line.cursor, el->el_line.lastchar, el->el_state.argument, cv__isWord); @@ -470,9 +470,9 @@ vi_end_big_word(EditLine *el, Int c) if (el->el_chared.c_vcmd.action != NOP) { el->el_line.cursor++; cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -486,7 +486,7 @@ vi_end_word(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_line.cursor == el->el_line.lastchar) - return (CC_ERROR); + return CC_ERROR; el->el_line.cursor = cv__endword(el->el_line.cursor, el->el_line.lastchar, el->el_state.argument, cv__isword); @@ -494,9 +494,9 @@ vi_end_word(EditLine *el, Int c __attribute__((__unused__))) if (el->el_chared.c_vcmd.action != NOP) { el->el_line.cursor++; cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -523,7 +523,7 @@ vi_undo(EditLine *el, Int c __attribute__((__unused__))) el->el_line.cursor = un.buf + un.cursor; el->el_line.lastchar = un.buf + un.len; - return (CC_REFRESH); + return CC_REFRESH; } @@ -548,7 +548,7 @@ vi_command_mode(EditLine *el, Int c __attribute__((__unused__))) if (el->el_line.cursor > el->el_line.buffer) el->el_line.cursor--; #endif - return (CC_CURSOR); + return CC_CURSOR; } @@ -566,9 +566,9 @@ vi_zero(EditLine *el, Int c) el->el_line.cursor = el->el_line.buffer; if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } @@ -582,11 +582,11 @@ vi_delete_prev_char(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_line.cursor <= el->el_line.buffer) - return (CC_ERROR); + return CC_ERROR; c_delbefore1(el); el->el_line.cursor--; - return (CC_REFRESH); + return CC_REFRESH; } @@ -602,26 +602,26 @@ vi_list_or_eof(EditLine *el, Int c) if (el->el_line.cursor == el->el_line.lastchar) { if (el->el_line.cursor == el->el_line.buffer) { terminal_writec(el, c); /* then do a EOF */ - return (CC_EOF); + return CC_EOF; } else { /* * Here we could list completions, but it is an * error right now */ terminal_beep(el); - return (CC_ERROR); + return CC_ERROR; } } else { #ifdef notyet re_goto_bottom(el); *el->el_line.lastchar = '\0'; /* just in case */ - return (CC_LIST_CHOICES); + return CC_LIST_CHOICES; #else /* * Just complain for now. */ terminal_beep(el); - return (CC_ERROR); + return CC_ERROR; #endif } } @@ -644,7 +644,7 @@ vi_kill_line_prev(EditLine *el, Int c __attribute__((__unused__))) el->el_chared.c_kill.last = kp; c_delbefore(el, (int)(el->el_line.cursor - el->el_line.buffer)); el->el_line.cursor = el->el_line.buffer; /* zap! */ - return (CC_REFRESH); + return CC_REFRESH; } @@ -657,7 +657,7 @@ protected el_action_t vi_search_prev(EditLine *el, Int c __attribute__((__unused__))) { - return (cv_search(el, ED_SEARCH_PREV_HISTORY)); + return cv_search(el, ED_SEARCH_PREV_HISTORY); } @@ -670,7 +670,7 @@ protected el_action_t vi_search_next(EditLine *el, Int c __attribute__((__unused__))) { - return (cv_search(el, ED_SEARCH_NEXT_HISTORY)); + return cv_search(el, ED_SEARCH_NEXT_HISTORY); } @@ -684,9 +684,9 @@ vi_repeat_search_next(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_search.patlen == 0) - return (CC_ERROR); + return CC_ERROR; else - return (cv_repeat_srch(el, el->el_search.patdir)); + return cv_repeat_srch(el, el->el_search.patdir); } @@ -700,7 +700,7 @@ vi_repeat_search_prev(EditLine *el, Int c __attribute__((__unused__))) { if (el->el_search.patlen == 0) - return (CC_ERROR); + return CC_ERROR; else return (cv_repeat_srch(el, el->el_search.patdir == ED_SEARCH_PREV_HISTORY ? @@ -830,9 +830,9 @@ vi_match(EditLine *el, Int c) if (delta > 0) el->el_line.cursor++; cv_delfini(el); - return (CC_REFRESH); + return CC_REFRESH; } - return (CC_CURSOR); + return CC_CURSOR; } /* vi_undo_line(): @@ -1152,5 +1152,5 @@ vi_redo(EditLine *el, Int c) el->el_state.thiscmd = r->cmd; el->el_state.thisch = r->ch; - return (*el->el_map.func[r->cmd])(el, r->ch); + return (*el->el_map.func[r->cmd])(el, r->ch); } |