#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 39
+#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
if ( yytext[yyl] == '\n' )\
--yylineno;\
}while(0)
- #define YY_LINENO_REWIND_TO(dst) \
- do {\
- const char *p;\
- for ( p = yy_cp-1; p >= (dst); --p)\
- if ( *p == '\n' )\
- --yylineno;\
- }while(0)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
- yy_size_t yy_n_chars;
+ int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
YY_BUFFER_STATE libconfig_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
+YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
void *libconfig_yyalloc (yy_size_t ,yyscan_t yyscanner );
void *libconfig_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-#define libconfig_yywrap(yyscanner) 1
+#define libconfig_yywrap(n) 1
#define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR;
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
+#include <limits.h>
#include "parsectx.h"
#include "scanctx.h"
#include "grammar.h"
}
-#line 625 "scanner.c"
+#line 627 "scanner.c"
#define INITIAL 0
#define COMMENT 1
size_t yy_buffer_stack_max; /**< capacity of stack. */
YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
char yy_hold_char;
- yy_size_t yy_n_chars;
- yy_size_t yyleng_r;
+ int yy_n_chars;
+ int yyleng_r;
char *yy_c_buf_p;
int yy_init;
int yy_start;
void libconfig_yyset_out (FILE * out_str ,yyscan_t yyscanner );
-yy_size_t libconfig_yyget_leng (yyscan_t yyscanner );
+int libconfig_yyget_leng (yyscan_t yyscanner );
char *libconfig_yyget_text (yyscan_t yyscanner );
void libconfig_yyset_lineno (int line_number ,yyscan_t yyscanner );
-int libconfig_yyget_column (yyscan_t yyscanner );
-
-void libconfig_yyset_column (int column_no ,yyscan_t yyscanner );
-
YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner );
void libconfig_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+#line 102 "scanner.l"
+
+
+#line 870 "scanner.c"
+
yylval = yylval_param;
if ( !yyg->yy_init )
libconfig_yy_load_buffer_state(yyscanner );
}
- {
-#line 101 "scanner.l"
-
-
-#line 896 "scanner.c"
-
while ( 1 ) /* loops until end-of-file is reached */
{
yy_cp = yyg->yy_c_buf_p;
yy_match:
do
{
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
{
- yy_size_t yyl;
+ int yyl;
for ( yyl = 0; yyl < yyleng; ++yyl )
if ( yytext[yyl] == '\n' )
case 1:
YY_RULE_SETUP
-#line 103 "scanner.l"
+#line 104 "scanner.l"
{ BEGIN COMMENT; }
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 104 "scanner.l"
+#line 105 "scanner.l"
{ BEGIN INITIAL; }
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 105 "scanner.l"
+#line 106 "scanner.l"
{ /* ignore */ }
YY_BREAK
case 4:
/* rule 4 can match eol */
YY_RULE_SETUP
-#line 106 "scanner.l"
+#line 107 "scanner.l"
{ /* ignore */ }
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 108 "scanner.l"
+#line 109 "scanner.l"
{ BEGIN STRING; }
YY_BREAK
case 6:
/* rule 6 can match eol */
YY_RULE_SETUP
-#line 109 "scanner.l"
+#line 110 "scanner.l"
{ scanctx_append_string(yyextra, yytext); }
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 110 "scanner.l"
+#line 111 "scanner.l"
{ scanctx_append_string(yyextra, "\n"); }
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 111 "scanner.l"
+#line 112 "scanner.l"
{ scanctx_append_string(yyextra, "\r"); }
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 112 "scanner.l"
+#line 113 "scanner.l"
{ scanctx_append_string(yyextra, "\t"); }
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 113 "scanner.l"
+#line 114 "scanner.l"
{ scanctx_append_string(yyextra, "\f"); }
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 114 "scanner.l"
+#line 115 "scanner.l"
{ scanctx_append_string(yyextra, "\\"); }
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 115 "scanner.l"
+#line 116 "scanner.l"
{ scanctx_append_string(yyextra, "\""); }
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 116 "scanner.l"
+#line 117 "scanner.l"
{
char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF),
0 };
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 121 "scanner.l"
+#line 122 "scanner.l"
{ scanctx_append_string(yyextra, "\\"); }
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 122 "scanner.l"
+#line 123 "scanner.l"
{
yylval->sval = scanctx_take_string(yyextra);
BEGIN INITIAL;
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 128 "scanner.l"
+#line 129 "scanner.l"
{ BEGIN INCLUDE; }
YY_BREAK
case 17:
/* rule 17 can match eol */
YY_RULE_SETUP
-#line 129 "scanner.l"
+#line 130 "scanner.l"
{ scanctx_append_string(yyextra, yytext); }
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 130 "scanner.l"
+#line 131 "scanner.l"
{ scanctx_append_string(yyextra, "\\"); }
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 131 "scanner.l"
+#line 132 "scanner.l"
{ scanctx_append_string(yyextra, "\""); }
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 132 "scanner.l"
+#line 133 "scanner.l"
{
const char *error;
FILE *fp = scanctx_push_include(yyextra,
case 21:
/* rule 21 can match eol */
YY_RULE_SETUP
-#line 156 "scanner.l"
+#line 157 "scanner.l"
{ /* ignore */ }
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 157 "scanner.l"
+#line 158 "scanner.l"
{ /* ignore */ }
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 159 "scanner.l"
+#line 160 "scanner.l"
{ return(TOK_EQUALS); }
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 160 "scanner.l"
+#line 161 "scanner.l"
{ return(TOK_COMMA); }
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 161 "scanner.l"
+#line 162 "scanner.l"
{ return(TOK_GROUP_START); }
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 162 "scanner.l"
+#line 163 "scanner.l"
{ return(TOK_GROUP_END); }
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 163 "scanner.l"
+#line 164 "scanner.l"
{ yylval->ival = 1; return(TOK_BOOLEAN); }
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 164 "scanner.l"
+#line 165 "scanner.l"
{ yylval->ival = 0; return(TOK_BOOLEAN); }
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 165 "scanner.l"
+#line 166 "scanner.l"
{ yylval->sval = yytext; return(TOK_NAME); }
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 166 "scanner.l"
+#line 167 "scanner.l"
{ yylval->fval = atof(yytext); return(TOK_FLOAT); }
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 167 "scanner.l"
-{ yylval->ival = atoi(yytext); return(TOK_INTEGER); }
+#line 168 "scanner.l"
+{
+ long long llval;
+ llval = atoll(yytext);
+ if (llval < INT_MIN || llval > INT_MAX) {
+ yylval->llval = llval;
+ return(TOK_INTEGER64);
+ } else {
+ yylval->ival = llval;
+ return(TOK_INTEGER);
+ }
+ }
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 168 "scanner.l"
+#line 179 "scanner.l"
{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 169 "scanner.l"
+#line 180 "scanner.l"
{
yylval->ival = strtoul(yytext, NULL, 16);
return(TOK_HEX);
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 173 "scanner.l"
+#line 184 "scanner.l"
{ yylval->llval = fromhex(yytext); return(TOK_HEX64); }
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 174 "scanner.l"
+#line 185 "scanner.l"
{ return(TOK_ARRAY_START); }
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 175 "scanner.l"
+#line 186 "scanner.l"
{ return(TOK_ARRAY_END); }
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 176 "scanner.l"
+#line 187 "scanner.l"
{ return(TOK_LIST_START); }
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 177 "scanner.l"
+#line 188 "scanner.l"
{ return(TOK_LIST_END); }
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 178 "scanner.l"
+#line 189 "scanner.l"
{ return(TOK_SEMICOLON); }
YY_BREAK
case 40:
yyg->yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 179 "scanner.l"
+#line 190 "scanner.l"
{ /* ignore */ }
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 180 "scanner.l"
+#line 191 "scanner.l"
{ return(TOK_GARBAGE); }
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT):
case YY_STATE_EOF(STRING):
case YY_STATE_EOF(INCLUDE):
-#line 182 "scanner.l"
+#line 193 "scanner.l"
{
YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include(
yyextra);
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 193 "scanner.l"
+#line 204 "scanner.l"
ECHO;
YY_BREAK
-#line 1227 "scanner.c"
+#line 1239 "scanner.c"
case YY_END_OF_BUFFER:
{
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
- } /* end of user's declarations */
} /* end of libconfig_yylex */
/* yy_get_next_buffer - try to read in a new buffer
else
{
- yy_size_t num_to_read =
+ int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
int yy_c_buf_p_offset =
(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
- yy_size_t new_size = b->yy_buf_size * 2;
+ int new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- yyg->yy_n_chars, num_to_read );
+ yyg->yy_n_chars, (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 102);
- (void)yyg;
return yy_is_jam ? 0 : yy_current_state;
}
else
{ /* need more input */
- yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) )
*/
static void libconfig_yyensure_buffer_stack (yyscan_t yyscanner)
{
- yy_size_t num_to_alloc;
+ int num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!yyg->yy_buffer_stack) {
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
+YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- yy_size_t i;
+ int i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
/** Get the length of the current token.
* @param yyscanner The scanner object.
*/
-yy_size_t libconfig_yyget_leng (yyscan_t yyscanner)
+int libconfig_yyget_leng (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng;
/* lineno is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "libconfig_yyset_lineno called with no buffer" );
+ yy_fatal_error( "libconfig_yyset_lineno called with no buffer" , yyscanner);
yylineno = line_number;
}
/* column is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "libconfig_yyset_column called with no buffer" );
+ yy_fatal_error( "libconfig_yyset_column called with no buffer" , yyscanner);
yycolumn = column_no;
}
#define YYTABLES_NAME "yytables"
-#line 193 "scanner.l"
+#line 204 "scanner.l"
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 39
+#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
#endif
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
- yy_size_t yy_n_chars;
+ int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
YY_BUFFER_STATE libconfig_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
+YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
void *libconfig_yyalloc (yy_size_t ,yyscan_t yyscanner );
void *libconfig_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
void libconfig_yyfree (void * ,yyscan_t yyscanner );
-#define libconfig_yywrap(yyscanner) 1
+#define libconfig_yywrap(n) 1
#define YY_SKIP_YYWRAP
#define yytext_ptr yytext_r
void libconfig_yyset_out (FILE * out_str ,yyscan_t yyscanner );
-yy_size_t libconfig_yyget_leng (yyscan_t yyscanner );
+int libconfig_yyget_leng (yyscan_t yyscanner );
char *libconfig_yyget_text (yyscan_t yyscanner );
void libconfig_yyset_lineno (int line_number ,yyscan_t yyscanner );
-int libconfig_yyget_column (yyscan_t yyscanner );
-
-void libconfig_yyset_column (int column_no ,yyscan_t yyscanner );
-
YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner );
void libconfig_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
#endif
/* Number of entries by which start-condition stack grows. */
#undef YY_DECL
#endif
-#line 193 "scanner.l"
+#line 204 "scanner.l"
-#line 343 "scanner.h"
+#line 352 "scanner.h"
#undef libconfig_yyIN_HEADER
#endif /* libconfig_yyHEADER_H */
/* ------------------------------------------------------------------------- */
+TT_TEST(BigInt1)
+{
+ char *buf;
+ config_t cfg;
+ int rc;
+ int ival;
+ long long llval;
+
+ /* int = 5 */
+ buf = "someint=5;";
+
+ config_init(&cfg);
+ rc = config_read_string(&cfg, buf);
+ TT_ASSERT_TRUE(rc);
+
+ rc = config_lookup_int(&cfg, "someint", &ival);
+ TT_ASSERT_TRUE(rc);
+ TT_ASSERT_INT_EQ(ival, 5);
+
+ rc = config_lookup_int64(&cfg, "someint", &llval);
+ TT_ASSERT_TRUE(rc);
+ TT_ASSERT_INT_EQ(llval, 5);
+
+ config_destroy(&cfg);
+}
+
+/* ------------------------------------------------------------------------- */
+
+TT_TEST(BigInt2)
+{
+ char *buf;
+ config_t cfg;
+ int rc;
+ int ival;
+ long long llval;
+
+ /* int = 2^33 */
+ buf = "someint=8589934592;";
+
+ config_init(&cfg);
+ rc = config_read_string(&cfg, buf);
+ TT_ASSERT_TRUE(rc);
+
+ rc = config_lookup_int(&cfg, "someint", &ival);
+ TT_ASSERT_TRUE(rc);
+ /* This looks very wrong. config_lookup_int should fail
+ * instead. */
+ TT_ASSERT_INT_EQ(ival, 0);
+
+ rc = config_lookup_int64(&cfg, "someint", &llval);
+ TT_ASSERT_TRUE(rc);
+ TT_ASSERT_INT64_EQ(llval, 8589934592);
+
+ config_destroy(&cfg);
+}
+
+/* ------------------------------------------------------------------------- */
+
+TT_TEST(BigInt3)
+{
+ char *buf;
+ config_t cfg;
+ int rc;
+ int ival;
+ long long llval;
+
+ /* int = -2^33 */
+ buf = "someint=-8589934592;";
+
+ config_init(&cfg);
+ rc = config_read_string(&cfg, buf);
+ TT_ASSERT_TRUE(rc);
+
+ rc = config_lookup_int(&cfg, "someint", &ival);
+ TT_ASSERT_TRUE(rc);
+ /* This looks very wrong. config_lookup_int should fail
+ * instead. */
+ TT_ASSERT_INT_EQ(ival, 0);
+
+ rc = config_lookup_int64(&cfg, "someint", &llval);
+ TT_ASSERT_TRUE(rc);
+ TT_ASSERT_INT64_EQ(llval, -8589934592);
+
+ config_destroy(&cfg);
+}
+
+/* ------------------------------------------------------------------------- */
+
+TT_TEST(BigInt4)
+{
+ char *buf;
+ config_t cfg;
+ int rc;
+ int ival;
+ long long llval;
+
+ /* int = 2^31-1 */
+ buf = "someint=2147483647;";
+
+ config_init(&cfg);
+ rc = config_read_string(&cfg, buf);
+ TT_ASSERT_TRUE(rc);
+
+ rc = config_lookup_int(&cfg, "someint", &ival);
+ TT_ASSERT_TRUE(rc);
+ TT_ASSERT_INT_EQ(ival, 2147483647);
+
+ rc = config_lookup_int64(&cfg, "someint", &llval);
+ TT_ASSERT_TRUE(rc);
+ TT_ASSERT_INT64_EQ(llval, 2147483647);
+
+ config_destroy(&cfg);
+}
+
+/* ------------------------------------------------------------------------- */
+
+TT_TEST(BigInt5)
+{
+ char *buf;
+ config_t cfg;
+ int rc;
+ int ival;
+ long long llval;
+
+ /* int = 2^31 */
+ buf = "someint=2147483648;";
+
+ config_init(&cfg);
+ rc = config_read_string(&cfg, buf);
+ TT_ASSERT_TRUE(rc);
+
+ rc = config_lookup_int(&cfg, "someint", &ival);
+ TT_ASSERT_TRUE(rc);
+ /* This looks very wrong. config_lookup_int should fail
+ * instead. */
+ TT_ASSERT_INT_EQ(ival, 0);
+
+ rc = config_lookup_int64(&cfg, "someint", &llval);
+ TT_ASSERT_TRUE(rc);
+ TT_ASSERT_INT64_EQ(llval, 2147483648);
+
+ config_destroy(&cfg);
+}
+
+/* ------------------------------------------------------------------------- */
+
+TT_TEST(BigInt6)
+{
+ char *buf;
+ config_t cfg;
+ int rc;
+ int ival;
+ long long llval;
+
+ /* int = -2^31 */
+ buf = "someint=-2147483648;";
+
+ config_init(&cfg);
+ rc = config_read_string(&cfg, buf);
+ TT_ASSERT_TRUE(rc);
+
+ rc = config_lookup_int(&cfg, "someint", &ival);
+ TT_ASSERT_TRUE(rc);
+ TT_ASSERT_INT_EQ(ival, -2147483648);
+
+ rc = config_lookup_int64(&cfg, "someint", &llval);
+ TT_ASSERT_TRUE(rc);
+ TT_ASSERT_INT64_EQ(llval, -2147483648);
+
+ config_destroy(&cfg);
+}
+
+/* ------------------------------------------------------------------------- */
+
+TT_TEST(BigInt7)
+{
+ char *buf;
+ config_t cfg;
+ int rc;
+ int ival;
+ long long llval;
+
+ /* int = -2^31-1 */
+ buf = "someint=-2147483649;";
+
+ config_init(&cfg);
+ rc = config_read_string(&cfg, buf);
+ TT_ASSERT_TRUE(rc);
+
+ rc = config_lookup_int(&cfg, "someint", &ival);
+ TT_ASSERT_TRUE(rc);
+ /* This looks very wrong. config_lookup_int should fail
+ * instead. */
+ TT_ASSERT_INT_EQ(ival, 0);
+
+ rc = config_lookup_int64(&cfg, "someint", &llval);
+ TT_ASSERT_TRUE(rc);
+ TT_ASSERT_INT64_EQ(llval, -2147483649);
+
+ config_destroy(&cfg);
+}
+
+/* ------------------------------------------------------------------------- */
+
int main(int argc, char **argv)
{
int failures;
TT_SUITE_TEST(LibConfigTests, ParsingAndFormatting);
TT_SUITE_TEST(LibConfigTests, ParseInvalidFiles);
TT_SUITE_TEST(LibConfigTests, ParseInvalidStrings);
+ TT_SUITE_TEST(LibConfigTests, BigInt1);
+ TT_SUITE_TEST(LibConfigTests, BigInt2);
+ TT_SUITE_TEST(LibConfigTests, BigInt3);
+ TT_SUITE_TEST(LibConfigTests, BigInt4);
+ TT_SUITE_TEST(LibConfigTests, BigInt5);
+ TT_SUITE_TEST(LibConfigTests, BigInt6);
+ TT_SUITE_TEST(LibConfigTests, BigInt7);
TT_SUITE_RUN(LibConfigTests);
failures = TT_SUITE_NUM_FAILURES(LibConfigTests);
TT_SUITE_END(LibConfigTests);