This patch reduces some unsightly #ifdefs, and fixes two typos in
comments in the psql code. This doesn't make any functional change, so
feel free to save it for 7.5
-Neil
Index: src/bin/psql/command.c
===
RCS file: /var/lib/cvs/pgsql-server/src/bin/psql/command.c,v
retrieving revision 1.105
diff -c -r1.105 command.c
*** src/bin/psql/command.c 11 Oct 2003 18:04:26 - 1.105
--- src/bin/psql/command.c 18 Oct 2003 04:02:50 -
***
*** 9,15
#include "command.h"
#include
- #include
#include
#ifdef HAVE_PWD_H
#include
--- 9,14
***
*** 97,106
const char *continue_parse = NULL; /* tell the mainloop where the
* backslash command ended */
! #ifdef USE_ASSERT_CHECKING
! assert(line);
! #endif
!
my_line = xstrdup(line);
/*
--- 96,102
const char *continue_parse = NULL; /* tell the mainloop where the
* backslash command ended */
! psql_assert(line);
my_line = xstrdup(line);
/*
***
*** 1234,1242
*tmp;
size_t length;
! #ifdef USE_ASSERT_CHECKING
! assert(source);
! #endif
length = Min(len, strlen(source)) + 1;
--- 1230,1236
*tmp;
size_t length;
! psql_assert(source);
length = Min(len, strlen(source)) + 1;
***
*** 1515,1526
char *sys;
int result;
! #ifdef USE_ASSERT_CHECKING
! assert(fname);
! #else
! if (!fname)
! return false;
! #endif
/* Find an editor to use */
editorName = getenv("PSQL_EDITOR");
--- 1509,1515
char *sys;
int result;
! psql_assert(fname);
/* Find an editor to use */
editorName = getenv("PSQL_EDITOR");
***
*** 1755,1766
{
size_t vallen = 0;
! #ifdef USE_ASSERT_CHECKING
! assert(param);
! #else
! if (!param)
! return false;
! #endif
if (value)
vallen = strlen(value);
--- 1744,1750
{
size_t vallen = 0;
! psql_assert(param);
if (value)
vallen = strlen(value);
Index: src/bin/psql/common.h
===
RCS file: /var/lib/cvs/pgsql-server/src/bin/psql/common.h,v
retrieving revision 1.29
diff -c -r1.29 common.h
*** src/bin/psql/common.h 3 Sep 2003 22:05:09 - 1.29
--- src/bin/psql/common.h 18 Oct 2003 04:00:20 -
***
*** 13,18
--- 13,25
#include "pqsignal.h"
#include "libpq-fe.h"
+ #ifdef USE_ASSERT_CHECKING
+ #include
+ #define psql_assert(p) assert(p)
+ #else
+ #define psql_assert(p)
+ #endif
+
extern char *xstrdup(const char *string);
extern bool setQFout(const char *fname);
Index: src/bin/psql/copy.c
===
RCS file: /var/lib/cvs/pgsql-server/src/bin/psql/copy.c,v
retrieving revision 1.33
diff -c -r1.33 copy.c
*** src/bin/psql/copy.c 4 Aug 2003 23:59:39 - 1.33
--- src/bin/psql/copy.c 18 Oct 2003 04:03:02 -
***
*** 9,15
#include "copy.h"
#include
- #include
#include
#include
#ifndef WIN32
--- 9,14
Index: src/bin/psql/stringutils.c
===
RCS file: /var/lib/cvs/pgsql-server/src/bin/psql/stringutils.c,v
retrieving revision 1.34
diff -c -r1.34 stringutils.c
*** src/bin/psql/stringutils.c 4 Aug 2003 23:59:40 - 1.34
--- src/bin/psql/stringutils.c 18 Oct 2003 04:02:28 -
***
*** 7,16
*/
#include "postgres_fe.h"
- #include
#include
#include "libpq-fe.h"
#include "settings.h"
#include "stringutils.h"
--- 7,16
*/
#include "postgres_fe.h"
#include
#include "libpq-fe.h"
+ #include "common.h"
#include "settings.h"
#include "stringutils.h"
***
*** 234,243
char *src;
char *dst;
! #ifdef USE_ASSERT_CHECKING
! assert(source);
! assert(quote);
! #endif
src = dst = source;
--- 234,241
char *src;
char *dst;
! psql_assert(source);
! psql_assert(quote);
src = dst = source;
Index: src/bin/psql/tab-complete.c
===
RCS file: /var/lib/cvs/pgsql-server/src/bin/psql/tab-complete.c,v
retrieving revision 1.89
diff -c -r1.89 tab-complete.c
*** src/bin/psql/tab-complete.c 17 Oct 2003 11:52:06 - 1.89
--- src/bin/psql/tab-complete.c 18 Oct 2003 04:27:01 -
***
*** 50,58
#ifdef USE_READLINE
#include
- #ifdef USE_ASSERT_CHECKING
- #include
- #endif
#include "libpq-fe.h"
--- 50,55
***
*** 1342,1348
}
}
-
/*
* If we still don't have anything to match we have to fabricate some
* sort of default list. If we were to just return NULL, readline
--- 1339,1344
***
*** 1357,1363
#endif
}
-
/* free storage */
free(prev_wd);
free(prev2_wd);
--- 1353,1358
**