Re: [HACKERS] new patch

From: Massimo Dal Zotto <dz(at)cs(dot)unitn(dot)it>
To: hackers(at)postgreSQL(dot)org (PostgreSQL Hackers), maillist(at)candle(dot)pha(dot)pa(dot)us (Bruce Momjian)
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane)
Subject: Re: [HACKERS] new patch
Date: 1999-06-14 20:55:03
Message-ID: 199906142055.WAA05143@fandango.cs.unitn.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> Massimo Dal Zotto <dz(at)cs(dot)unitn(dot)it> writes:
> > + char *progname = rindex(argv[0], SEP_CHAR);
> > + rl_readline_name = (progname ? progname : argv[0]);
>
> 1. rindex => strrchr, please.
>
> 2. Shouldn't that be (progname ? progname+1 : argv[0]) ?
>
> regards, tom lane
>

Yes, I had already added the +1, but for same obscure reason it worked
also with the original code, so I didn't notice the bug in my first test.
I suspect that the readline uses only the basename of the argument.
Ok also for strrchr, this is the final patch:

*** src/bin/psql/psql.c.orig Sat Jun 5 09:00:38 1999
--- src/bin/psql/psql.c Mon Jun 14 09:04:15 1999
***************
*** 2875,2880 ****
--- 2875,2887 ----
pqsignal(SIGINT, handle_sigint); /* control-C => cancel */
#ifdef USE_READLINE
settings.useReadline = 1;
+ {
+ /*
+ * Set the application name, used for parsing .inputrc -- dz
+ */
+ char *progname = strrchr(argv[0], SEP_CHAR);
+ rl_readline_name = (progname ? progname+1 : argv[0]);
+ }
#endif
}
#ifdef PSQL_ALWAYS_GET_PASSWORDS

--
Massimo Dal Zotto

+----------------------------------------------------------------------+
| Massimo Dal Zotto email: dz(at)cs(dot)unitn(dot)it |
| Via Marconi, 141 phone: ++39-0461534251 |
| 38057 Pergine Valsugana (TN) www: http://www.cs.unitn.it/~dz/ |
| Italy pgp: finger dz(at)tango(dot)cs(dot)unitn(dot)it |
+----------------------------------------------------------------------+

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-06-14 20:57:53 Re: [HACKERS] Docs done?
Previous Message Massimo Dal Zotto 1999-06-14 20:32:50 new patches...