Thread: Support only octal for psql PROMPT % values

Support only octal for psql PROMPT % values

From
Bruce Momjian
Date:
The following patch makes psql PROMPT only suport %octal rather than the
confusing decimal/hex/octal it used to. Documentation already updated.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/bin/psql/common.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/common.c,v
retrieving revision 1.97
diff -c -c -r1.97 common.c
*** src/bin/psql/common.c    28 Apr 2005 13:09:59 -0000    1.97
--- src/bin/psql/common.c    30 May 2005 18:10:29 -0000
***************
*** 1237,1253 ****
  }


- char
- parse_char(char **buf)
- {
-     long        l;
-
-     l = strtol(*buf, buf, 0);
-     --*buf;
-     return (char) l;
- }
-
-
  /*
   * Test if the current user is a database superuser.
   *
--- 1237,1242 ----
Index: src/bin/psql/common.h
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/common.h,v
retrieving revision 1.42
diff -c -c -r1.42 common.h
*** src/bin/psql/common.h    1 Jan 2005 05:43:08 -0000    1.42
--- src/bin/psql/common.h    30 May 2005 18:10:30 -0000
***************
*** 60,71 ****
  extern bool is_superuser(void);
  extern const char *session_username(void);

- /* Parse a numeric character code from the string pointed at by *buf, e.g.
-  * one written as 0x0c (hexadecimal) or 015 (octal); advance *buf to the last
-  * character of the numeric character code.
-  */
- extern char parse_char(char **buf);
-
  extern char *expand_tilde(char **filename);

  #endif   /* COMMON_H */
--- 60,65 ----
Index: src/bin/psql/prompt.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/prompt.c,v
retrieving revision 1.38
diff -c -c -r1.38 prompt.c
*** src/bin/psql/prompt.c    1 Jan 2005 05:43:08 -0000    1.38
--- src/bin/psql/prompt.c    30 May 2005 18:10:30 -0000
***************
*** 175,185 ****
                  case '5':
                  case '6':
                  case '7':
!                 case '8':
!                 case '9':
!                     *buf = parse_char((char **) &p);
                      break;
-
                  case 'R':
                      switch (status)
                      {
--- 175,183 ----
                  case '5':
                  case '6':
                  case '7':
!                     *buf = (char) strtol(p, (char **)&p, 8);
!                     --p;
                      break;
                  case 'R':
                      switch (status)
                      {