📄 bool.c
字号:
/*------------------------------------------------------------------------- * * bool.c * Functions for the built-in type "bool". * * Copyright (c) 1994, Regents of the University of California * * * IDENTIFICATION * $Header: /usr/local/cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.16.2.1 1999/08/02 05:24:50 scrappy Exp $ * *------------------------------------------------------------------------- */#include "postgres.h"#include "utils/builtins.h"/***************************************************************************** * USER I/O ROUTINES * *****************************************************************************//* * boolin - converts "t" or "f" to 1 or 0 * * Check explicitly for "true/false" and TRUE/FALSE, 1/0, YES/NO. * Reject other values. - thomas 1997-10-05 * * In the switch statement, check the most-used possibilities first. */boolboolin(char *b){ switch (*b) { case 't': case 'T': if (strncasecmp(b, "true", strlen(b)) == 0) return TRUE; break; case 'f': case 'F': if (strncasecmp(b, "false", strlen(b)) == 0) return FALSE; break; case 'y': case 'Y': if (strncasecmp(b, "yes", strlen(b)) == 0) return TRUE; break; case '1': if (strncasecmp(b, "1", strlen(b)) == 0) return TRUE; break; case 'n': case 'N': if (strncasecmp(b, "no", strlen(b)) == 0) return FALSE; break; case '0': if (strncasecmp(b, "0", strlen(b)) == 0) return FALSE; break; default: break; } elog(ERROR, "Bad boolean external representation '%s'", b); /* not reached */ return FALSE;} /* boolin() *//* * boolout - converts 1 or 0 to "t" or "f" */char *boolout(bool b){ char *result = (char *) palloc(2); *result = (b) ? 't' : 'f'; result[1] = '\0'; return result;} /* boolout() *//***************************************************************************** * PUBLIC ROUTINES * *****************************************************************************/boolbooleq(bool arg1, bool arg2){ return arg1 == arg2;}boolboolne(bool arg1, bool arg2){ return arg1 != arg2;}boolboollt(bool arg1, bool arg2){ return arg1 < arg2;}boolboolgt(bool arg1, bool arg2){ return arg1 > arg2;}boolistrue(bool arg1){ return arg1 == TRUE;} /* istrue() */boolisfalse(bool arg1){ return arg1 != TRUE;} /* isfalse() */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -