From f0ff0bc3aa47118f16f822b3aa1a81aa58f60818 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 22 Apr 2022 01:25:07 +0000 Subject: [PATCH] Bug 1765474 - Fix deprecated-non-prototype warnings in editline. r=jandem js/src/editline/editline.c:147:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] TTYput(c) ^ js/src/editline/editline.c:158:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] TTYputs(p) ^ js/src/editline/editline.c:166:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] TTYshow(c) ^ js/src/editline/editline.c:187:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] TTYstring(p) ^ js/src/editline/editline.c:212:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] TTYbackn(n) ^ js/src/editline/editline.c:288:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] left(Change) ^ js/src/editline/editline.c:305:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] right(Change) ^ js/src/editline/editline.c:322:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] do_macro(c) ^ js/src/editline/editline.c:340:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] do_forward(move) ^ js/src/editline/editline.c:365:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] do_case(type) ^ js/src/editline/editline.c:441:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] insert_string(p) ^ js/src/editline/editline.c:502:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] do_insert_hist(p) ^ js/src/editline/editline.c:515:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] do_hist(move) ^ js/src/editline/editline.c:557:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] substrcmp(text, pat, len) ^ js/src/editline/editline.c:607:14: error: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] if ((*match)((char *)H.Lines[H.Pos], pat, len) == 0) ^ js/src/editline/editline.c:573:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] search_hist(search, move) ^ js/src/editline/editline.c:663:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] save_yank(begin, i) ^ js/src/editline/editline.c:682:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] delete_string(count) ^ js/src/editline/editline.c:781:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] insert_char(c) ^ js/src/editline/editline.h:81:13: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] extern void rl_add_slash(); ^ js/src/editline/sysunix.c:36:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] rl_ttyset(Reset) ^ js/src/editline/sysunix.c:139:1: error: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype] rl_add_slash(path, p) ^ Differential Revision: https://phabricator.services.mozilla.com/D144145 --- js/src/editline/editline.c | 84 ++++++++++++-------------------------- js/src/editline/editline.h | 2 +- js/src/editline/sysunix.c | 13 ++---- 3 files changed, 32 insertions(+), 67 deletions(-) diff --git a/js/src/editline/editline.c b/js/src/editline/editline.c index 8146bb82f3d0..48db9c2ac28d 100644 --- a/js/src/editline/editline.c +++ b/js/src/editline/editline.c @@ -144,8 +144,7 @@ TTYflush() } STATIC void -TTYput(c) - CHAR c; +TTYput(CHAR c) { Screen[ScreenCount] = c; if (++ScreenCount >= ScreenSize - 1) { @@ -155,16 +154,14 @@ TTYput(c) } STATIC void -TTYputs(p) - CONST CHAR *p; +TTYputs(CONST CHAR *p) { while (*p) TTYput(*p++); } STATIC void -TTYshow(c) - CHAR c; +TTYshow(CHAR c) { if (c == DEL) { TTYput('^'); @@ -184,8 +181,7 @@ TTYshow(c) } STATIC void -TTYstring(p) - CHAR *p; +TTYstring(CHAR *p) { while (*p) TTYshow(*p++); @@ -209,8 +205,7 @@ TTYget() #define TTYback() (backspace ? TTYputs((CHAR *)backspace) : TTYput('\b')) STATIC void -TTYbackn(n) - int n; +TTYbackn(int n) { while (--n >= 0) TTYback(); @@ -285,8 +280,7 @@ reposition() } STATIC void -left(Change) - STATUS Change; +left(STATUS Change) { TTYback(); if (Point) { @@ -302,8 +296,7 @@ left(Change) } STATIC void -right(Change) - STATUS Change; +right(STATUS Change) { TTYshow(Line[Point]); if (Change == CSmove) @@ -319,8 +312,7 @@ ring_bell() } STATIC STATUS -do_macro(c) - unsigned int c; +do_macro(unsigned int c) { CHAR name[4]; @@ -337,8 +329,7 @@ do_macro(c) } STATIC STATUS -do_forward(move) - STATUS move; +do_forward(STATUS move) { int i; CHAR *p; @@ -362,8 +353,7 @@ do_forward(move) } STATIC STATUS -do_case(type) - CASE type; +do_case(CASE type) { int i; int end; @@ -438,8 +428,7 @@ clear_line() } STATIC STATUS -insert_string(p) - CHAR *p; +insert_string(CHAR *p) { SIZE_T len; int i; @@ -499,8 +488,7 @@ prev_hist() } STATIC STATUS -do_insert_hist(p) - CHAR *p; +do_insert_hist(CHAR *p) { if (p == NULL) return ring_bell(); @@ -512,8 +500,7 @@ do_insert_hist(p) } STATIC STATUS -do_hist(move) - CHAR *(*move)(); +do_hist(CHAR *(*move)()) { CHAR *p; int i; @@ -554,10 +541,7 @@ h_last() ** Return zero if pat appears as a substring in text. */ STATIC int -substrcmp(text, pat, len) - char *text; - char *pat; - int len; +substrcmp(char *text, char *pat, size_t len) { char c; @@ -570,14 +554,12 @@ substrcmp(text, pat, len) } STATIC CHAR * -search_hist(search, move) - CHAR *search; - CHAR *(*move)(); +search_hist(CHAR *search, CHAR *(*move)()) { static CHAR *old_search; int len; int pos; - int (*match)(); + int (*match)(char *, char *, size_t); char *pat; /* Save or get remembered search pattern. */ @@ -594,7 +576,7 @@ search_hist(search, move) /* Set up pattern-finder. */ if (*search == '^') { - match = strncmp; + match = (int(*)(char *, char *, size_t))strncmp; pat = (char *)(search + 1); } else { @@ -660,9 +642,7 @@ fd_char() } STATIC void -save_yank(begin, i) - int begin; - int i; +save_yank(int begin, int i) { if (Yanked) { DISPOSE(Yanked); @@ -679,8 +659,7 @@ save_yank(begin, i) } STATIC STATUS -delete_string(count) - int count; +delete_string(int count) { int i; CHAR *p; @@ -778,8 +757,7 @@ kill_line() } STATIC STATUS -insert_char(c) - int c; +insert_char(int c) { STATUS s; CHAR buff[2]; @@ -843,8 +821,7 @@ meta() } STATIC STATUS -emacs(c) - unsigned int c; +emacs(unsigned int c) { STATUS s; const KEYMAP *kp; @@ -865,8 +842,7 @@ emacs(c) } STATIC STATUS -TTYspecial(c) - unsigned int c; +TTYspecial(unsigned int c) { if (ISMETA(c)) return CSdispatch; @@ -942,8 +918,7 @@ editinput() } STATIC void -hist_add(p) - CHAR *p; +hist_add(CHAR *p) { int i; @@ -965,8 +940,7 @@ hist_add(p) */ /* ARGSUSED0 */ void -rl_reset_terminal(p) - char *p; +rl_reset_terminal(char *p) { (void)p; } @@ -977,8 +951,7 @@ rl_initialize() } char * -readline(prompt) - CONST char *prompt; +readline(CONST char *prompt) { CHAR *line; int s; @@ -1013,8 +986,7 @@ readline(prompt) } void -add_history(p) - char *p; +add_history(char *p) { if (p == NULL || *p == '\0') return; @@ -1217,9 +1189,7 @@ bk_kill_word() } STATIC int -argify(line, avp) - CHAR *line; - CHAR ***avp; +argify(CHAR *line, CHAR ***avp) { CHAR *c; CHAR **p; diff --git a/js/src/editline/editline.h b/js/src/editline/editline.h index b849e58ad6b2..0d34620e58eb 100644 --- a/js/src/editline/editline.h +++ b/js/src/editline/editline.h @@ -78,7 +78,7 @@ extern unsigned rl_quit; extern char *rl_complete(); extern int rl_list_possib(); extern void rl_ttyset(int); -extern void rl_add_slash(); +extern void rl_add_slash(char *, char *); #if !defined(HAVE_STDLIB) extern char *getenv(); diff --git a/js/src/editline/sysunix.c b/js/src/editline/sysunix.c index d45db6c79baa..528c9d8cabfe 100644 --- a/js/src/editline/sysunix.c +++ b/js/src/editline/sysunix.c @@ -33,8 +33,7 @@ #include void -rl_ttyset(Reset) - int Reset; +rl_ttyset(int Reset) { static struct termios old; struct termios new; @@ -65,8 +64,7 @@ rl_ttyset(Reset) #include void -rl_ttyset(Reset) - int Reset; +rl_ttyset(int Reset) { static struct termio old; struct termio new; @@ -96,8 +94,7 @@ rl_ttyset(Reset) #include void -rl_ttyset(Reset) - int Reset; +rl_ttyset(int Reset) { static struct sgttyb old_sgttyb; static struct tchars old_tchars; @@ -136,9 +133,7 @@ rl_ttyset(Reset) #endif /* defined(HAVE_TCGETATTR) */ void -rl_add_slash(path, p) - char *path; - char *p; +rl_add_slash(char *path, char *p) { struct stat Sb;