PostgreSQL Source Code git master
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
 

Macros

#define YY_TYPEDEF_YY_SCANNER_T
 

Typedefs

typedef struct SEG SEG
 
typedef void * yyscan_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)
 

Macro Definition Documentation

◆ YY_TYPEDEF_YY_SCANNER_T

#define YY_TYPEDEF_YY_SCANNER_T

Definition at line 20 of file segdata.h.

Typedef Documentation

◆ SEG

typedef struct SEG SEG

◆ yyscan_t

typedef void* yyscan_t

Definition at line 21 of file segdata.h.

Function Documentation

◆ seg_scanner_finish()

void seg_scanner_finish ( yyscan_t  yyscanner)

Definition at line 116 of file segscan.l.

117{
118 yylex_destroy(yyscanner);
119}

Referenced by seg_in().

◆ seg_scanner_init()

void seg_scanner_init ( const char *  str,
yyscan_t yyscannerp 
)

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:67
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225
const char * str

References elog, ERROR, and str.

Referenced by seg_in().

◆ seg_yyerror()

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

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
76 if (*yytext == YY_END_OF_BUFFER_CHAR)
77 {
78 errsave(escontext,
79 (errcode(ERRCODE_SYNTAX_ERROR),
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,
87 (errcode(ERRCODE_SYNTAX_ERROR),
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 errdetail(const char *fmt,...)
Definition: elog.c:1203
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define errsave(context,...)
Definition: elog.h:261
#define SOFT_ERROR_OCCURRED(escontext)
Definition: miscnodes.h:53

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

Referenced by seg_in().

◆ seg_yylex()

int seg_yylex ( union YYSTYPE yylval_param,
yyscan_t  yyscanner 
)

◆ seg_yyparse()

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

Referenced by seg_in().

◆ significant_digits()

int significant_digits ( const char *  s)

Definition at line 1065 of file seg.c.

1066{
1067 const char *p = s;
1068 int n,
1069 c,
1070 zeroes;
1071
1072 zeroes = 1;
1073 /* skip leading zeroes and sign */
1074 for (c = *p; (c == '0' || c == '+' || c == '-') && c != 0; c = *(++p));
1075
1076 /* skip decimal point and following zeroes */
1077 for (c = *p; (c == '0' || c == '.') && c != 0; c = *(++p))
1078 {
1079 if (c != '.')
1080 zeroes++;
1081 }
1082
1083 /* count significant digits (n) */
1084 for (c = *p, n = 0; c != 0; c = *(++p))
1085 {
1086 if (!((c >= '0' && c <= '9') || (c == '.')))
1087 break;
1088 if (c != '.')
1089 n++;
1090 }
1091
1092 if (!n)
1093 return zeroes;
1094
1095 return n;
1096}
char * c