PostgreSQL Source Code git master
Loading...
Searching...
No Matches
segdata.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SEG
 

Typedefs

typedef struct SEG SEG
 
typedef voidyyscan_t
 

Functions

int significant_digits (const char *s)
 
int seg_yylex (union YYSTYPE *yylval_param, yyscan_t yyscanner)
 
void seg_yyerror (SEG *result, struct Node *escontext, yyscan_t yyscanner, const char *message)
 
void seg_scanner_init (const char *str, yyscan_t *yyscannerp)
 
void seg_scanner_finish (yyscan_t yyscanner)
 
int seg_yyparse (SEG *result, struct Node *escontext, yyscan_t yyscanner)
 

Typedef Documentation

◆ SEG

typedef struct SEG SEG

◆ yyscan_t

Definition at line 19 of file segdata.h.

Function Documentation

◆ seg_scanner_finish()

void seg_scanner_finish ( yyscan_t  yyscanner)
extern

Definition at line 116 of file segscan.l.

117{
118 yylex_destroy(yyscanner);
119}
static int fb(int x)

References fb().

Referenced by seg_in().

◆ seg_scanner_init()

void seg_scanner_init ( const char str,
yyscan_t yyscannerp 
)
extern

Definition at line 99 of file segscan.l.

100{
101 yyscan_t yyscanner;
102
103 if (yylex_init(yyscannerp) != 0)
104 elog(ERROR, "yylex_init() failed: %m");
105
106 yyscanner = *yyscannerp;
107
108 yy_scan_string(str, yyscanner);
109}
void * yyscan_t
Definition cubedata.h:65
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
const char * str

References elog, ERROR, fb(), and str.

Referenced by seg_in().

◆ seg_yyerror()

void seg_yyerror ( SEG result,
struct Node escontext,
yyscan_t  yyscanner,
const char message 
)
extern

Definition at line 67 of file segscan.l.

68{
69 struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; /* needed for yytext
70 * macro */
71
72 /* if we already reported an error, don't overwrite it */
73 if (SOFT_ERROR_OCCURRED(escontext))
74 return;
75
77 {
78 errsave(escontext,
80 errmsg("bad seg representation"),
81 /* translator: %s is typically "syntax error" */
82 errdetail("%s at end of input", message)));
83 }
84 else
85 {
86 errsave(escontext,
88 errmsg("bad seg representation"),
89 /* translator: first %s is typically "syntax error" */
90 errdetail("%s at or near \"%s\"", message, yytext)));
91 }
92}
int errcode(int sqlerrcode)
Definition elog.c:875
#define errsave(context,...)
Definition elog.h:264
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define SOFT_ERROR_OCCURRED(escontext)
Definition miscnodes.h:53
static char * errmsg

References errcode(), errdetail(), errmsg, errsave, fb(), and SOFT_ERROR_OCCURRED.

Referenced by seg_in().

◆ seg_yylex()

int seg_yylex ( union YYSTYPE yylval_param,
yyscan_t  yyscanner 
)
extern

◆ seg_yyparse()

int seg_yyparse ( SEG result,
struct Node escontext,
yyscan_t  yyscanner 
)
extern

Referenced by seg_in().

◆ significant_digits()

int significant_digits ( const char s)
extern

Definition at line 1075 of file seg.c.

1076{
1077 const char *p = s;
1078 int n,
1079 c,
1080 zeroes;
1081
1082 zeroes = 1;
1083 /* skip leading zeroes and sign */
1084 for (c = *p; (c == '0' || c == '+' || c == '-') && c != 0; c = *(++p));
1085
1086 /* skip decimal point and following zeroes */
1087 for (c = *p; (c == '0' || c == '.') && c != 0; c = *(++p))
1088 {
1089 if (c != '.')
1090 zeroes++;
1091 }
1092
1093 /* count significant digits (n) */
1094 for (c = *p, n = 0; c != 0; c = *(++p))
1095 {
1096 if (!((c >= '0' && c <= '9') || (c == '.')))
1097 break;
1098 if (c != '.')
1099 n++;
1100 }
1101
1102 if (!n)
1103 return zeroes;
1104
1105 return n;
1106}
char * c

References fb().