Modernize const handling with readline
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 5 Oct 2023 06:43:49 +0000 (08:43 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 5 Oct 2023 06:45:50 +0000 (08:45 +0200)
The comment

    /* On some platforms, readline is declared as readline(char *) */

is obsolete.  The casting away of const can be removed.

The const in the readline() prototype was added in GNU readline 4.2,
released in 2001.  BSD libedit has also had const in the prototype
since at least 2001.

(The commit that introduced this comment (187e865174) talked about
FreeBSD 4.8, which didn't have readline compatibility in libedit yet,
so it must have been talking about GNU readline in the base system.
This checks out, but already FreeBSD 5 had an updated GNU readline
with const.)

Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/862fc1d4-9a0c-d2b6-5451-ee3dc750bcab%40eisentraut.org

src/bin/psql/input.c

index 873d85079c95bcb830e9c810dc9734bfdd2e1159..7c77fd8e89d0a96edd0242b0248de1b36c2ccf74 100644 (file)
@@ -88,8 +88,7 @@ gets_interactive(const char *prompt, PQExpBuffer query_buf)
        /* Enable SIGINT to longjmp to sigint_interrupt_jmp */
        sigint_interrupt_enabled = true;
 
-       /* On some platforms, readline is declared as readline(char *) */
-       result = readline((char *) prompt);
+       result = readline(prompt);
 
        /* Disable SIGINT again */
        sigint_interrupt_enabled = false;