Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit35ddc2e

Browse files
committed
This patch reduces some unsightly #ifdefs, and fixes two typos in
comments in the psql code. This doesn't make any functional change, sofeel free to save it for 7.5Neil Conway
1 parentabd5d75 commit35ddc2e

File tree

6 files changed

+31
-60
lines changed

6 files changed

+31
-60
lines changed

‎src/bin/psql/command.c

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.106 2003/11/29 19:52:06 pgsql Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.107 2003/12/01 22:14:40 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
1010

1111
#include<errno.h>
12-
#include<assert.h>
1312
#include<ctype.h>
1413
#ifdefHAVE_PWD_H
1514
#include<pwd.h>
@@ -97,10 +96,7 @@ HandleSlashCmds(const char *line,
9796
constchar*continue_parse=NULL;/* tell the mainloop where the
9897
* backslash command ended */
9998

100-
#ifdefUSE_ASSERT_CHECKING
101-
assert(line);
102-
#endif
103-
99+
psql_assert(line);
104100
my_line=xstrdup(line);
105101

106102
/*
@@ -1234,9 +1230,7 @@ unescape(const unsigned char *source, size_t len)
12341230
*tmp;
12351231
size_tlength;
12361232

1237-
#ifdefUSE_ASSERT_CHECKING
1238-
assert(source);
1239-
#endif
1233+
psql_assert(source);
12401234

12411235
length=Min(len,strlen(source))+1;
12421236

@@ -1515,12 +1509,7 @@ editFile(const char *fname)
15151509
char*sys;
15161510
intresult;
15171511

1518-
#ifdefUSE_ASSERT_CHECKING
1519-
assert(fname);
1520-
#else
1521-
if (!fname)
1522-
return false;
1523-
#endif
1512+
psql_assert(fname);
15241513

15251514
/* Find an editor to use */
15261515
editorName=getenv("PSQL_EDITOR");
@@ -1755,12 +1744,7 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
17551744
{
17561745
size_tvallen=0;
17571746

1758-
#ifdefUSE_ASSERT_CHECKING
1759-
assert(param);
1760-
#else
1761-
if (!param)
1762-
return false;
1763-
#endif
1747+
psql_assert(param);
17641748

17651749
if (value)
17661750
vallen=strlen(value);

‎src/bin/psql/common.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.30 2003/11/29 19:52:06 pgsql Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.31 2003/12/01 22:14:40 momjian Exp $
77
*/
88
#ifndefCOMMON_H
99
#defineCOMMON_H
@@ -13,6 +13,13 @@
1313
#include"pqsignal.h"
1414
#include"libpq-fe.h"
1515

16+
#ifdefUSE_ASSERT_CHECKING
17+
#include<assert.h>
18+
#definepsql_assert(p) assert(p)
19+
#else
20+
#definepsql_assert(p)
21+
#endif
22+
1623
externchar*xstrdup(constchar*string);
1724

1825
externboolsetQFout(constchar*fname);

‎src/bin/psql/copy.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.34 2003/11/29 19:52:06 pgsql Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.35 2003/12/01 22:14:40 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"copy.h"
1010

1111
#include<errno.h>
12-
#include<assert.h>
1312
#include<signal.h>
1413
#include<sys/stat.h>
1514
#ifndefWIN32

‎src/bin/psql/stringutils.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.35 2003/11/29 19:52:07 pgsql Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.36 2003/12/01 22:14:40 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99

10-
#include<assert.h>
1110
#include<ctype.h>
1211

1312
#include"libpq-fe.h"
13+
#include"common.h"
1414
#include"settings.h"
1515
#include"stringutils.h"
1616

@@ -234,10 +234,8 @@ strip_quotes(char *source, char quote, char escape, int encoding)
234234
char*src;
235235
char*dst;
236236

237-
#ifdefUSE_ASSERT_CHECKING
238-
assert(source);
239-
assert(quote);
240-
#endif
237+
psql_assert(source);
238+
psql_assert(quote);
241239

242240
src=dst=source;
243241

‎src/bin/psql/tab-complete.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.95 2003/12/01 22:08:01 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.96 2003/12/01 22:14:40 momjian Exp $
77
*/
88

99
/*----------------------------------------------------------------------
@@ -49,9 +49,6 @@
4949
#ifdefUSE_READLINE
5050

5151
#include<ctype.h>
52-
#ifdefUSE_ASSERT_CHECKING
53-
#include<assert.h>
54-
#endif
5552
#include"libpq-fe.h"
5653
#include"pqexpbuffer.h"
5754
#include"common.h"
@@ -1345,7 +1342,6 @@ psql_completion(char *text, int start, int end)
13451342
}
13461343
}
13471344

1348-
13491345
/*
13501346
* If we still don't have anything to match we have to fabricate some
13511347
* sort of default list. If we were to just return NULL, readline
@@ -1360,7 +1356,6 @@ psql_completion(char *text, int start, int end)
13601356
#endif
13611357
}
13621358

1363-
13641359
/* free storage */
13651360
free(prev_wd);
13661361
free(prev2_wd);
@@ -1382,7 +1377,7 @@ psql_completion(char *text, int start, int end)
13821377
directly but through the readline interface.
13831378
The return value is expected to be the full completion of the text, going
13841379
through a list each time, or NULL if there are no more matches. The string
1385-
will be free()'dbe readline, so you must run it through strdup() or
1380+
will be free()'dby readline, so you must run it through strdup() or
13861381
something of that sort.
13871382
*/
13881383

@@ -1637,9 +1632,7 @@ complete_from_list(const char *text, int state)
16371632
constchar*item;
16381633

16391634
/* need to have a list */
1640-
#ifdefUSE_ASSERT_CHECKING
1641-
assert(completion_charpp);
1642-
#endif
1635+
psql_assert(completion_charpp);
16431636

16441637
/* Initialization */
16451638
if (state==0)
@@ -1693,9 +1686,7 @@ complete_from_const(const char *text, int state)
16931686
(void)text;/* We don't care about what was entered
16941687
* already. */
16951688

1696-
#ifdefUSE_ASSERT_CHECKING
1697-
assert(completion_charp);
1698-
#endif
1689+
psql_assert(completion_charp);
16991690
if (state==0)
17001691
returnxstrdup(completion_charp);
17011692
else
@@ -1809,7 +1800,7 @@ previous_word(int point, int skip)
18091800

18101801
/*
18111802
* Surround a string with single quotes. This works for both SQL and
1812-
* psql internal. Currentlydisable because it is reported not to
1803+
* psql internal. Currentlydisabled because it is reported not to
18131804
* cooperate with certain versions of readline.
18141805
*/
18151806
staticchar*

‎src/bin/psql/variables.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.14 2003/11/29 19:52:07 pgsql Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/variables.c,v 1.15 2003/12/01 22:14:40 momjian Exp $
77
*/
88
#include"postgres_fe.h"
9+
#include"common.h"
910
#include"variables.h"
1011

11-
#include<assert.h>
12-
13-
1412
VariableSpace
1513
CreateVariableSpace(void)
1614
{
@@ -46,10 +44,8 @@ GetVariable(VariableSpace space, const char *name)
4644

4745
for (current=space;current;current=current->next)
4846
{
49-
#ifdefUSE_ASSERT_CHECKING
50-
assert(current->name);
51-
assert(current->value);
52-
#endif
47+
psql_assert(current->name);
48+
psql_assert(current->value);
5349
if (strcmp(current->name,name)==0)
5450
returncurrent->value;
5551
}
@@ -161,10 +157,8 @@ SetVariable(VariableSpace space, const char *name, const char *value)
161157

162158
for (current=space,previous=NULL;current;previous=current,current=current->next)
163159
{
164-
#ifdefUSE_ASSERT_CHECKING
165-
assert(current->name);
166-
assert(current->value);
167-
#endif
160+
psql_assert(current->name);
161+
psql_assert(current->value);
168162
if (strcmp(current->name,name)==0)
169163
{
170164
free(current->value);
@@ -203,10 +197,8 @@ DeleteVariable(VariableSpace space, const char *name)
203197

204198
for (current=space,previous=NULL;current;previous=current,current=current->next)
205199
{
206-
#ifdefUSE_ASSERT_CHECKING
207-
assert(current->name);
208-
assert(current->value);
209-
#endif
200+
psql_assert(current->name);
201+
psql_assert(current->value);
210202
if (strcmp(current->name,name)==0)
211203
{
212204
free(current->name);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp