1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* bool.c--
|
|
|
|
* Functions for the built-in type "bool".
|
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
1997-03-15 00:21:12 +01:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.3 1997/03/14 23:19:52 scrappy Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1996-11-03 07:54:38 +01:00
|
|
|
|
|
|
|
#include "postgres.h"
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "utils/builtins.h" /* where the declarations go */
|
|
|
|
#include "utils/palloc.h"
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* USER I/O ROUTINES *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* boolin - converts "t" or "f" to 1 or 0
|
|
|
|
*/
|
1997-03-15 00:21:12 +01:00
|
|
|
bool
|
1996-07-09 08:22:35 +02:00
|
|
|
boolin(char *b)
|
|
|
|
{
|
|
|
|
if (b == NULL)
|
|
|
|
elog(WARN, "Bad input string for type bool");
|
1997-03-15 00:21:12 +01:00
|
|
|
return((bool) (*b == 't') || (*b == 'T'));
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* boolout - converts 1 or 0 to "t" or "f"
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
boolout(long b)
|
|
|
|
{
|
|
|
|
char *result = (char *) palloc(2);
|
|
|
|
|
|
|
|
*result = (b) ? 't' : 'f';
|
|
|
|
result[1] = '\0';
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* PUBLIC ROUTINES *
|
|
|
|
*****************************************************************************/
|
|
|
|
|
1997-03-15 00:21:12 +01:00
|
|
|
bool
|
1996-07-09 08:22:35 +02:00
|
|
|
booleq(int8 arg1, int8 arg2)
|
|
|
|
{
|
|
|
|
return(arg1 == arg2);
|
|
|
|
}
|
|
|
|
|
1997-03-15 00:21:12 +01:00
|
|
|
bool
|
1996-07-09 08:22:35 +02:00
|
|
|
boolne(int8 arg1, int8 arg2)
|
|
|
|
{
|
|
|
|
return(arg1 != arg2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|