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

Commita21c3e3

Browse files
author
Thomas G. Lockhart
committed
Allow 't', 'T', and even/odd ASCII characters to denote true/false
rather than just 't' and 'T'. This allows yes/no and 1/0 to be interpreted as one might expect.Clean up function declarations to use bool as the type for arguments and return values.
1 parent8fe55ef commita21c3e3

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

‎src/backend/utils/adt/bool.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.6 1997/09/08 02:30:26 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.7 1997/10/09 05:06:12 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -23,20 +23,23 @@
2323

2424
/*
2525
*boolin- converts "t" or "f" to 1 or 0
26+
*
27+
* Check explicitly for "true/TRUE" and allow any odd ASCII value to be "true".
28+
* This handles "true/false", "yes/no", "1/0". - thomas 1997-10-05
2629
*/
2730
bool
2831
boolin(char*b)
2932
{
3033
if (b==NULL)
3134
elog(WARN,"Bad input string for type bool");
32-
return ((bool) (*b=='t')|| (*b=='T'));
35+
return ((bool) (((*b)=='t')|| ((*b)=='T')|| ((*b)&1)));
3336
}
3437

3538
/*
3639
*boolout- converts 1 or 0 to "t" or "f"
3740
*/
38-
char*
39-
boolout(longb)
41+
char*
42+
boolout(boolb)
4043
{
4144
char*result= (char*)palloc(2);
4245

@@ -50,25 +53,25 @@ boolout(long b)
5053
*****************************************************************************/
5154

5255
bool
53-
booleq(int8arg1,int8arg2)
56+
booleq(boolarg1,boolarg2)
5457
{
5558
return (arg1==arg2);
5659
}
5760

5861
bool
59-
boolne(int8arg1,int8arg2)
62+
boolne(boolarg1,boolarg2)
6063
{
6164
return (arg1!=arg2);
6265
}
6366

6467
bool
65-
boollt(int8arg1,int8arg2)
68+
boollt(boolarg1,boolarg2)
6669
{
6770
return (arg1<arg2);
6871
}
6972

7073
bool
71-
boolgt(int8arg1,int8arg2)
74+
boolgt(boolarg1,boolarg2)
7275
{
7376
return (arg1>arg2);
7477
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp