1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Change TRUE/FALSE to true/false

The lower case spellings are C and C++ standard and are used in most
parts of the PostgreSQL sources.  The upper case spellings are only used
in some files/modules.  So standardize on the standard spellings.

The APIs for ICU, Perl, and Windows define their own TRUE and FALSE, so
those are left as is when using those APIs.

In code comments, we use the lower-case spelling for the C concepts and
keep the upper-case spelling for the SQL concepts.

Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
This commit is contained in:
Peter Eisentraut
2017-08-16 00:22:32 -04:00
parent 4497f2f3b3
commit 2eb4a831e5
216 changed files with 1168 additions and 1168 deletions

View File

@ -231,17 +231,17 @@ PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
/* If attrs already exist, they cannot be overwritten. */
if (!res || res->numAttributes > 0)
return FALSE;
return false;
/* ignore no-op request */
if (numAttributes <= 0 || !attDescs)
return TRUE;
return true;
res->attDescs = (PGresAttDesc *)
PQresultAlloc(res, numAttributes * sizeof(PGresAttDesc));
if (!res->attDescs)
return FALSE;
return false;
res->numAttributes = numAttributes;
memcpy(res->attDescs, attDescs, numAttributes * sizeof(PGresAttDesc));
@ -256,13 +256,13 @@ PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
res->attDescs[i].name = res->null_field;
if (!res->attDescs[i].name)
return FALSE;
return false;
if (res->attDescs[i].format == 0)
res->binary = 0;
}
return TRUE;
return true;
}
/*
@ -368,7 +368,7 @@ PQcopyResult(const PGresult *src, int flags)
PQclear(dest);
return NULL;
}
dest->events[i].resultInitialized = TRUE;
dest->events[i].resultInitialized = true;
}
}
@ -398,7 +398,7 @@ dupEvents(PGEvent *events, int count)
newEvents[i].proc = events[i].proc;
newEvents[i].passThrough = events[i].passThrough;
newEvents[i].data = NULL;
newEvents[i].resultInitialized = FALSE;
newEvents[i].resultInitialized = false;
newEvents[i].name = strdup(events[i].name);
if (!newEvents[i].name)
{
@ -428,7 +428,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
/* Note that this check also protects us against null "res" */
if (!check_field_number(res, field_num))
return FALSE;
return false;
/* Invalid tup_num, must be <= ntups */
if (tup_num < 0 || tup_num > res->ntups)
@ -436,7 +436,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
pqInternalNotice(&res->noticeHooks,
"row number %d is out of range 0..%d",
tup_num, res->ntups);
return FALSE;
return false;
}
/* need to allocate a new tuple? */
@ -447,7 +447,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
tup = (PGresAttValue *)
pqResultAlloc(res, res->numAttributes * sizeof(PGresAttValue),
TRUE);
true);
if (!tup)
goto fail;
@ -479,7 +479,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
}
else
{
attval->value = (char *) pqResultAlloc(res, len + 1, TRUE);
attval->value = (char *) pqResultAlloc(res, len + 1, true);
if (!attval->value)
goto fail;
attval->len = len;
@ -487,7 +487,7 @@ PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
attval->value[len] = '\0';
}
return TRUE;
return true;
/*
* Report failure via pqInternalNotice. If preceding code didn't provide
@ -498,7 +498,7 @@ fail:
errmsg = libpq_gettext("out of memory");
pqInternalNotice(&res->noticeHooks, "%s", errmsg);
return FALSE;
return false;
}
/*
@ -510,7 +510,7 @@ fail:
void *
PQresultAlloc(PGresult *res, size_t nBytes)
{
return pqResultAlloc(res, nBytes, TRUE);
return pqResultAlloc(res, nBytes, true);
}
/*
@ -622,7 +622,7 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary)
char *
pqResultStrdup(PGresult *res, const char *str)
{
char *space = (char *) pqResultAlloc(res, strlen(str) + 1, FALSE);
char *space = (char *) pqResultAlloc(res, strlen(str) + 1, false);
if (space)
strcpy(space, str);
@ -852,7 +852,7 @@ pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...)
* Result text is always just the primary message + newline. If we can't
* allocate it, don't bother invoking the receiver.
*/
res->errMsg = (char *) pqResultAlloc(res, strlen(msgBuf) + 2, FALSE);
res->errMsg = (char *) pqResultAlloc(res, strlen(msgBuf) + 2, false);
if (res->errMsg)
{
sprintf(res->errMsg, "%s\n", msgBuf);
@ -868,7 +868,7 @@ pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...)
/*
* pqAddTuple
* add a row pointer to the PGresult structure, growing it if necessary
* Returns TRUE if OK, FALSE if an error prevented adding the row
* Returns true if OK, false if an error prevented adding the row
*
* On error, *errmsgp can be set to an error string to be returned.
* If it is left NULL, the error is presumed to be "out of memory".
@ -903,7 +903,7 @@ pqAddTuple(PGresult *res, PGresAttValue *tup, const char **errmsgp)
else
{
*errmsgp = libpq_gettext("PGresult cannot support more than INT_MAX tuples");
return FALSE;
return false;
}
/*
@ -915,7 +915,7 @@ pqAddTuple(PGresult *res, PGresAttValue *tup, const char **errmsgp)
if (newSize > SIZE_MAX / sizeof(PGresAttValue *))
{
*errmsgp = libpq_gettext("size_t overflow");
return FALSE;
return false;
}
#endif
@ -926,13 +926,13 @@ pqAddTuple(PGresult *res, PGresAttValue *tup, const char **errmsgp)
newTuples = (PGresAttValue **)
realloc(res->tuples, newSize * sizeof(PGresAttValue *));
if (!newTuples)
return FALSE; /* malloc or realloc failed */
return false; /* malloc or realloc failed */
res->tupArrSize = newSize;
res->tuples = newTuples;
}
res->tuples[res->ntups] = tup;
res->ntups++;
return TRUE;
return true;
}
/*
@ -947,7 +947,7 @@ pqSaveMessageField(PGresult *res, char code, const char *value)
pqResultAlloc(res,
offsetof(PGMessageField, contents) +
strlen(value) + 1,
TRUE);
true);
if (!pfield)
return; /* out of memory? */
pfield->code = code;
@ -1111,7 +1111,7 @@ pqRowProcessor(PGconn *conn, const char **errmsgp)
* memory for gettext() to do anything.
*/
tup = (PGresAttValue *)
pqResultAlloc(res, nfields * sizeof(PGresAttValue), TRUE);
pqResultAlloc(res, nfields * sizeof(PGresAttValue), true);
if (tup == NULL)
goto fail;
@ -1725,14 +1725,14 @@ parseInput(PGconn *conn)
/*
* PQisBusy
* Return TRUE if PQgetResult would block waiting for input.
* Return true if PQgetResult would block waiting for input.
*/
int
PQisBusy(PGconn *conn)
{
if (!conn)
return FALSE;
return false;
/* Parse any available data, if our state permits. */
parseInput(conn);
@ -1771,7 +1771,7 @@ PQgetResult(PGconn *conn)
*/
while ((flushResult = pqFlush(conn)) > 0)
{
if (pqWait(FALSE, TRUE, conn))
if (pqWait(false, true, conn))
{
flushResult = -1;
break;
@ -1780,7 +1780,7 @@ PQgetResult(PGconn *conn)
/* Wait for some more data, and load it. */
if (flushResult ||
pqWait(TRUE, FALSE, conn) ||
pqWait(true, false, conn) ||
pqReadData(conn) < 0)
{
/*
@ -1844,7 +1844,7 @@ PQgetResult(PGconn *conn)
res->resultStatus = PGRES_FATAL_ERROR;
break;
}
res->events[i].resultInitialized = TRUE;
res->events[i].resultInitialized = true;
}
}
@ -2746,22 +2746,22 @@ PQbinaryTuples(const PGresult *res)
/*
* Helper routines to range-check field numbers and tuple numbers.
* Return TRUE if OK, FALSE if not
* Return true if OK, false if not
*/
static int
check_field_number(const PGresult *res, int field_num)
{
if (!res)
return FALSE; /* no way to display error message... */
return false; /* no way to display error message... */
if (field_num < 0 || field_num >= res->numAttributes)
{
pqInternalNotice(&res->noticeHooks,
"column number %d is out of range 0..%d",
field_num, res->numAttributes - 1);
return FALSE;
return false;
}
return TRUE;
return true;
}
static int
@ -2769,38 +2769,38 @@ check_tuple_field_number(const PGresult *res,
int tup_num, int field_num)
{
if (!res)
return FALSE; /* no way to display error message... */
return false; /* no way to display error message... */
if (tup_num < 0 || tup_num >= res->ntups)
{
pqInternalNotice(&res->noticeHooks,
"row number %d is out of range 0..%d",
tup_num, res->ntups - 1);
return FALSE;
return false;
}
if (field_num < 0 || field_num >= res->numAttributes)
{
pqInternalNotice(&res->noticeHooks,
"column number %d is out of range 0..%d",
field_num, res->numAttributes - 1);
return FALSE;
return false;
}
return TRUE;
return true;
}
static int
check_param_number(const PGresult *res, int param_num)
{
if (!res)
return FALSE; /* no way to display error message... */
return false; /* no way to display error message... */
if (param_num < 0 || param_num >= res->numParameters)
{
pqInternalNotice(&res->noticeHooks,
"parameter number %d is out of range 0..%d",
param_num, res->numParameters - 1);
return FALSE;
return false;
}
return TRUE;
return true;
}
/*
@ -3177,8 +3177,8 @@ PQparamtype(const PGresult *res, int param_num)
/* PQsetnonblocking:
* sets the PGconn's database connection non-blocking if the arg is TRUE
* or makes it blocking if the arg is FALSE, this will not protect
* sets the PGconn's database connection non-blocking if the arg is true
* or makes it blocking if the arg is false, this will not protect
* you from PQexec(), you'll only be safe when using the non-blocking API.
* Needs to be called only on a connected database connection.
*/
@ -3190,7 +3190,7 @@ PQsetnonblocking(PGconn *conn, int arg)
if (!conn || conn->status == CONNECTION_BAD)
return -1;
barg = (arg ? TRUE : FALSE);
barg = (arg ? true : false);
/* early out if the socket is already in the state requested */
if (barg == conn->nonblocking)
@ -3213,7 +3213,7 @@ PQsetnonblocking(PGconn *conn, int arg)
/*
* return the blocking status of the database connection
* TRUE == nonblocking, FALSE == blocking
* true == nonblocking, false == blocking
*/
int
PQisnonblocking(const PGconn *conn)