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
 

Typedefs

typedef struct SEG SEG
 

Functions

int significant_digits (const char *str)
 
int seg_yylex (void)
 
void seg_yyerror (SEG *result, const char *message) pg_attribute_noreturn()
 
void seg_scanner_init (const char *str)
 
void seg_scanner_finish (void)
 
int seg_yyparse (SEG *result)
 

Typedef Documentation

◆ SEG

typedef struct SEG SEG

Function Documentation

◆ seg_scanner_finish()

void seg_scanner_finish ( void  )

Referenced by seg_in().

◆ seg_scanner_init()

void seg_scanner_init ( const char *  str)

Referenced by seg_in().

◆ seg_yyerror()

void seg_yyerror ( SEG result,
const char *  message 
)

Referenced by seg_in().

◆ seg_yylex()

int seg_yylex ( void  )

◆ seg_yyparse()

int seg_yyparse ( SEG result)

Referenced by seg_in().

◆ significant_digits()

int significant_digits ( const char *  str)

Definition at line 1059 of file seg.c.

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