diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 6a26ef549a..fda770f9dc 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -3,13 +3,12 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.106 2003/11/29 19:52:06 pgsql Exp $ + * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.107 2003/12/01 22:14:40 momjian Exp $ */ #include "postgres_fe.h" #include "command.h" #include -#include #include #ifdef HAVE_PWD_H #include @@ -97,10 +96,7 @@ HandleSlashCmds(const char *line, const char *continue_parse = NULL; /* tell the mainloop where the * backslash command ended */ -#ifdef USE_ASSERT_CHECKING - assert(line); -#endif - + psql_assert(line); my_line = xstrdup(line); /* @@ -1234,9 +1230,7 @@ unescape(const unsigned char *source, size_t len) *tmp; size_t length; -#ifdef USE_ASSERT_CHECKING - assert(source); -#endif + psql_assert(source); length = Min(len, strlen(source)) + 1; @@ -1515,12 +1509,7 @@ editFile(const char *fname) char *sys; int result; -#ifdef USE_ASSERT_CHECKING - assert(fname); -#else - if (!fname) - return false; -#endif + psql_assert(fname); /* Find an editor to use */ editorName = getenv("PSQL_EDITOR"); @@ -1755,12 +1744,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet) { size_t vallen = 0; -#ifdef USE_ASSERT_CHECKING - assert(param); -#else - if (!param) - return false; -#endif + psql_assert(param); if (value) vallen = strlen(value); diff --git a/src/bin/psql/common.h b/src/bin/psql/common.h index 74e6deb234..2e9cc5952e 100644 --- a/src/bin/psql/common.h +++ b/src/bin/psql/common.h @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.30 2003/11/29 19:52:06 pgsql Exp $ + * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.31 2003/12/01 22:14:40 momjian Exp $ */ #ifndef COMMON_H #define COMMON_H @@ -13,6 +13,13 @@ #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); diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c index 91e11e4000..200029b77b 100644 --- a/src/bin/psql/copy.c +++ b/src/bin/psql/copy.c @@ -3,13 +3,12 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.34 2003/11/29 19:52:06 pgsql Exp $ + * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.35 2003/12/01 22:14:40 momjian Exp $ */ #include "postgres_fe.h" #include "copy.h" #include -#include #include #include #ifndef WIN32 diff --git a/src/bin/psql/stringutils.c b/src/bin/psql/stringutils.c index 1dbc369df9..c90abb2cdd 100644 --- a/src/bin/psql/stringutils.c +++ b/src/bin/psql/stringutils.c @@ -3,14 +3,14 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.35 2003/11/29 19:52:07 pgsql Exp $ + * $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.36 2003/12/01 22:14:40 momjian Exp $ */ #include "postgres_fe.h" -#include #include #include "libpq-fe.h" +#include "common.h" #include "settings.h" #include "stringutils.h" @@ -234,10 +234,8 @@ strip_quotes(char *source, char quote, char escape, int encoding) char *src; char *dst; -#ifdef USE_ASSERT_CHECKING - assert(source); - assert(quote); -#endif + psql_assert(source); + psql_assert(quote); src = dst = source; diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index c50ce514d1..b6ae2ce865 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.95 2003/12/01 22:08:01 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.96 2003/12/01 22:14:40 momjian Exp $ */ /*---------------------------------------------------------------------- @@ -49,9 +49,6 @@ #ifdef USE_READLINE #include -#ifdef USE_ASSERT_CHECKING -#include -#endif #include "libpq-fe.h" #include "pqexpbuffer.h" #include "common.h" @@ -1345,7 +1342,6 @@ psql_completion(char *text, int start, int end) } } - /* * 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 @@ -1360,7 +1356,6 @@ psql_completion(char *text, int start, int end) #endif } - /* free storage */ free(prev_wd); free(prev2_wd); @@ -1382,7 +1377,7 @@ psql_completion(char *text, int start, int end) directly but through the readline interface. The return value is expected to be the full completion of the text, going through a list each time, or NULL if there are no more matches. The string - will be free()'d be readline, so you must run it through strdup() or + will be free()'d by readline, so you must run it through strdup() or something of that sort. */ @@ -1637,9 +1632,7 @@ complete_from_list(const char *text, int state) const char *item; /* need to have a list */ -#ifdef USE_ASSERT_CHECKING - assert(completion_charpp); -#endif + psql_assert(completion_charpp); /* Initialization */ if (state == 0) @@ -1693,9 +1686,7 @@ complete_from_const(const char *text, int state) (void) text; /* We don't care about what was entered * already. */ -#ifdef USE_ASSERT_CHECKING - assert(completion_charp); -#endif + psql_assert(completion_charp); if (state == 0) return xstrdup(completion_charp); else @@ -1809,7 +1800,7 @@ previous_word(int point, int skip) /* * Surround a string with single quotes. This works for both SQL and - * psql internal. Currently disable because it is reported not to + * psql internal. Currently disabled because it is reported not to * cooperate with certain versions of readline. */ static char * diff --git a/src/bin/psql/variables.c b/src/bin/psql/variables.c index 2275b818fb..21dc8aecb6 100644 --- a/src/bin/psql/variables.c +++ b/src/bin/psql/variables.c @@ -3,14 +3,12 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.14 2003/11/29 19:52:07 pgsql Exp $ + * $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.15 2003/12/01 22:14:40 momjian Exp $ */ #include "postgres_fe.h" +#include "common.h" #include "variables.h" -#include - - VariableSpace CreateVariableSpace(void) { @@ -46,10 +44,8 @@ GetVariable(VariableSpace space, const char *name) for (current = space; current; current = current->next) { -#ifdef USE_ASSERT_CHECKING - assert(current->name); - assert(current->value); -#endif + psql_assert(current->name); + psql_assert(current->value); if (strcmp(current->name, name) == 0) return current->value; } @@ -161,10 +157,8 @@ SetVariable(VariableSpace space, const char *name, const char *value) for (current = space, previous = NULL; current; previous = current, current = current->next) { -#ifdef USE_ASSERT_CHECKING - assert(current->name); - assert(current->value); -#endif + psql_assert(current->name); + psql_assert(current->value); if (strcmp(current->name, name) == 0) { free(current->value); @@ -203,10 +197,8 @@ DeleteVariable(VariableSpace space, const char *name) for (current = space, previous = NULL; current; previous = current, current = current->next) { -#ifdef USE_ASSERT_CHECKING - assert(current->name); - assert(current->value); -#endif + psql_assert(current->name); + psql_assert(current->value); if (strcmp(current->name, name) == 0) { free(current->name);