MCPcopy Create free account
hub / github.com/apache/cloudberry / gettoken

Function gettoken

contrib/intarray/_int_bool.c:47–130  ·  view source on GitHub ↗

* get token from query string */

Source from the content-addressed store, hash-verified

45 * get token from query string
46 */
47static int32
48gettoken(WORKSTATE *state, int32 *val)
49{
50 char nnn[16];
51 int innn;
52
53 *val = 0; /* default result */
54
55 innn = 0;
56 while (1)
57 {
58 if (innn >= sizeof(nnn))
59 return ERR; /* buffer overrun => syntax error */
60 switch (state->state)
61 {
62 case WAITOPERAND:
63 innn = 0;
64 if ((*(state->buf) >= '0' && *(state->buf) <= '9') ||
65 *(state->buf) == '-')
66 {
67 state->state = WAITENDOPERAND;
68 nnn[innn++] = *(state->buf);
69 }
70 else if (*(state->buf) == '!')
71 {
72 (state->buf)++;
73 *val = (int32) '!';
74 return OPR;
75 }
76 else if (*(state->buf) == '(')
77 {
78 state->count++;
79 (state->buf)++;
80 return OPEN;
81 }
82 else if (*(state->buf) != ' ')
83 return ERR;
84 break;
85 case WAITENDOPERAND:
86 if (*(state->buf) >= '0' && *(state->buf) <= '9')
87 {
88 nnn[innn++] = *(state->buf);
89 }
90 else
91 {
92 long lval;
93
94 nnn[innn] = '\0';
95 errno = 0;
96 lval = strtol(nnn, NULL, 0);
97 *val = (int32) lval;
98 if (errno != 0 || (long) *val != lval)
99 return ERR;
100 state->state = WAITOPERATOR;
101 return (state->count && *(state->buf) == '\0')
102 ? ERR : VAL;
103 }
104 break;

Callers 1

makepolFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected