Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libconfig
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
libconfig
Commits
01bc2250
Commit
01bc2250
authored
Oct 25, 2017
by
Mark Lindner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consolidate some Windows-specific stuff.
parent
4e482191
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
81 deletions
+73
-81
lib/grammar.c
lib/grammar.c
+49
-58
lib/grammar.h
lib/grammar.h
+1
-1
lib/grammar.y
lib/grammar.y
+6
-15
lib/libconfig.c
lib/libconfig.c
+2
-2
lib/wincompat.h
lib/wincompat.h
+15
-5
No files found.
lib/grammar.c
View file @
01bc2250
...
...
@@ -72,29 +72,20 @@
#include <string.h>
#include <stdlib.h>
#include "libconfig.h"
#ifdef WIN32
#include "wincompat.h"
/* prevent warnings about redefined malloc/free in generated code: */
#ifndef _STDLIB_H
#define _STDLIB_H
#endif
#include <malloc.h>
#endif
#include "libconfig.h"
#include "parsectx.h"
#include "scanctx.h"
#include "util.h"
#include "wincompat.h"
/*
these delcarations are provided to suppress compiler warnings
*/
/*
These declarations are provided to suppress compiler warnings.
*/
extern
int
libconfig_yylex
();
extern
int
libconfig_yyget_lineno
();
static
const
char
*
err_array_elem_type
=
"mismatched element type in array"
;
static
const
char
*
err_duplicate_setting
=
"duplicate setting name"
;
#define _delete(P) free((void *)(P))
#define IN_ARRAY() \
(ctx->parent && (ctx->parent->type == CONFIG_TYPE_ARRAY))
...
...
@@ -120,7 +111,7 @@ void libconfig_yyerror(void *scanner, struct parse_context *ctx,
}
#line 1
24
"grammar.c"
/* yacc.c:339 */
#line 1
15
"grammar.c"
/* yacc.c:339 */
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
...
...
@@ -204,14 +195,14 @@ extern int libconfig_yydebug;
union
YYSTYPE
{
#line
85
"grammar.y"
/* yacc.c:355 */
#line
76
"grammar.y"
/* yacc.c:355 */
int
ival
;
long
long
llval
;
double
fval
;
char
*
sval
;
#line 2
15
"grammar.c"
/* yacc.c:355 */
#line 2
06
"grammar.c"
/* yacc.c:355 */
};
typedef
union
YYSTYPE
YYSTYPE
;
...
...
@@ -227,7 +218,7 @@ int libconfig_yyparse (void *scanner, struct parse_context *ctx, struct scan_con
/* Copy the second part of user declarations. */
#line 2
31
"grammar.c"
/* yacc.c:358 */
#line 2
22
"grammar.c"
/* yacc.c:358 */
#ifdef short
# undef short
...
...
@@ -526,11 +517,11 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static
const
yytype_uint16
yyrline
[]
=
{
0
,
100
,
100
,
102
,
106
,
107
,
110
,
112
,
115
,
117
,
1
18
,
123
,
122
,
142
,
141
,
165
,
164
,
187
,
188
,
189
,
1
90
,
194
,
195
,
199
,
219
,
241
,
263
,
285
,
307
,
325
,
3
53
,
354
,
355
,
358
,
360
,
364
,
365
,
366
,
369
,
371
,
3
76
,
375
0
,
91
,
91
,
93
,
97
,
98
,
101
,
103
,
106
,
108
,
1
09
,
114
,
113
,
133
,
132
,
156
,
155
,
178
,
179
,
180
,
1
81
,
185
,
186
,
190
,
210
,
232
,
254
,
276
,
298
,
316
,
3
44
,
345
,
346
,
349
,
351
,
355
,
356
,
357
,
360
,
362
,
3
67
,
366
};
#endif
...
...
@@ -1343,7 +1334,7 @@ yyreduce:
switch
(
yyn
)
{
case
11
:
#line 1
23
"grammar.y"
/* yacc.c:1646 */
#line 1
14
"grammar.y"
/* yacc.c:1646 */
{
ctx
->
setting
=
config_setting_add
(
ctx
->
parent
,
(
yyvsp
[
0
].
sval
),
CONFIG_TYPE_NONE
);
...
...
@@ -1357,11 +1348,11 @@ yyreduce:
CAPTURE_PARSE_POS
(
ctx
->
setting
);
}
}
#line 13
61
"grammar.c"
/* yacc.c:1646 */
#line 13
52
"grammar.c"
/* yacc.c:1646 */
break
;
case
13
:
#line 1
42
"grammar.y"
/* yacc.c:1646 */
#line 1
33
"grammar.y"
/* yacc.c:1646 */
{
if
(
IN_LIST
())
{
...
...
@@ -1375,20 +1366,20 @@ yyreduce:
ctx
->
setting
=
NULL
;
}
}
#line 137
9
"grammar.c"
/* yacc.c:1646 */
#line 137
0
"grammar.c"
/* yacc.c:1646 */
break
;
case
14
:
#line 1
57
"grammar.y"
/* yacc.c:1646 */
#line 1
48
"grammar.y"
/* yacc.c:1646 */
{
if
(
ctx
->
parent
)
ctx
->
parent
=
ctx
->
parent
->
parent
;
}
#line 13
88
"grammar.c"
/* yacc.c:1646 */
#line 13
79
"grammar.c"
/* yacc.c:1646 */
break
;
case
15
:
#line 1
65
"grammar.y"
/* yacc.c:1646 */
#line 1
56
"grammar.y"
/* yacc.c:1646 */
{
if
(
IN_LIST
())
{
...
...
@@ -1402,32 +1393,32 @@ yyreduce:
ctx
->
setting
=
NULL
;
}
}
#line 1
406
"grammar.c"
/* yacc.c:1646 */
#line 1
397
"grammar.c"
/* yacc.c:1646 */
break
;
case
16
:
#line 1
80
"grammar.y"
/* yacc.c:1646 */
#line 1
71
"grammar.y"
/* yacc.c:1646 */
{
if
(
ctx
->
parent
)
ctx
->
parent
=
ctx
->
parent
->
parent
;
}
#line 14
15
"grammar.c"
/* yacc.c:1646 */
#line 14
06
"grammar.c"
/* yacc.c:1646 */
break
;
case
21
:
#line 1
94
"grammar.y"
/* yacc.c:1646 */
#line 1
85
"grammar.y"
/* yacc.c:1646 */
{
parsectx_append_string
(
ctx
,
(
yyvsp
[
0
].
sval
));
free
((
yyvsp
[
0
].
sval
));
}
#line 14
21
"grammar.c"
/* yacc.c:1646 */
#line 14
12
"grammar.c"
/* yacc.c:1646 */
break
;
case
22
:
#line 1
95
"grammar.y"
/* yacc.c:1646 */
#line 1
86
"grammar.y"
/* yacc.c:1646 */
{
parsectx_append_string
(
ctx
,
(
yyvsp
[
0
].
sval
));
free
((
yyvsp
[
0
].
sval
));
}
#line 14
27
"grammar.c"
/* yacc.c:1646 */
#line 14
18
"grammar.c"
/* yacc.c:1646 */
break
;
case
23
:
#line
200
"grammar.y"
/* yacc.c:1646 */
#line
191
"grammar.y"
/* yacc.c:1646 */
{
if
(
IN_ARRAY
()
||
IN_LIST
())
{
...
...
@@ -1447,11 +1438,11 @@ yyreduce:
else
config_setting_set_bool
(
ctx
->
setting
,
(
int
)(
yyvsp
[
0
].
ival
));
}
#line 14
51
"grammar.c"
/* yacc.c:1646 */
#line 14
42
"grammar.c"
/* yacc.c:1646 */
break
;
case
24
:
#line 2
20
"grammar.y"
/* yacc.c:1646 */
#line 2
11
"grammar.y"
/* yacc.c:1646 */
{
if
(
IN_ARRAY
()
||
IN_LIST
())
{
...
...
@@ -1473,11 +1464,11 @@ yyreduce:
config_setting_set_format
(
ctx
->
setting
,
CONFIG_FORMAT_DEFAULT
);
}
}
#line 14
77
"grammar.c"
/* yacc.c:1646 */
#line 14
68
"grammar.c"
/* yacc.c:1646 */
break
;
case
25
:
#line 2
42
"grammar.y"
/* yacc.c:1646 */
#line 2
33
"grammar.y"
/* yacc.c:1646 */
{
if
(
IN_ARRAY
()
||
IN_LIST
())
{
...
...
@@ -1499,11 +1490,11 @@ yyreduce:
config_setting_set_format
(
ctx
->
setting
,
CONFIG_FORMAT_DEFAULT
);
}
}
#line 1
503
"grammar.c"
/* yacc.c:1646 */
#line 1
494
"grammar.c"
/* yacc.c:1646 */
break
;
case
26
:
#line 2
64
"grammar.y"
/* yacc.c:1646 */
#line 2
55
"grammar.y"
/* yacc.c:1646 */
{
if
(
IN_ARRAY
()
||
IN_LIST
())
{
...
...
@@ -1525,11 +1516,11 @@ yyreduce:
config_setting_set_format
(
ctx
->
setting
,
CONFIG_FORMAT_HEX
);
}
}
#line 152
9
"grammar.c"
/* yacc.c:1646 */
#line 152
0
"grammar.c"
/* yacc.c:1646 */
break
;
case
27
:
#line 2
86
"grammar.y"
/* yacc.c:1646 */
#line 2
77
"grammar.y"
/* yacc.c:1646 */
{
if
(
IN_ARRAY
()
||
IN_LIST
())
{
...
...
@@ -1551,11 +1542,11 @@ yyreduce:
config_setting_set_format
(
ctx
->
setting
,
CONFIG_FORMAT_HEX
);
}
}
#line 15
55
"grammar.c"
/* yacc.c:1646 */
#line 15
46
"grammar.c"
/* yacc.c:1646 */
break
;
case
28
:
#line
308
"grammar.y"
/* yacc.c:1646 */
#line
299
"grammar.y"
/* yacc.c:1646 */
{
if
(
IN_ARRAY
()
||
IN_LIST
())
{
...
...
@@ -1573,17 +1564,17 @@ yyreduce:
else
config_setting_set_float
(
ctx
->
setting
,
(
yyvsp
[
0
].
fval
));
}
#line 15
77
"grammar.c"
/* yacc.c:1646 */
#line 15
68
"grammar.c"
/* yacc.c:1646 */
break
;
case
29
:
#line 3
26
"grammar.y"
/* yacc.c:1646 */
#line 3
17
"grammar.y"
/* yacc.c:1646 */
{
if
(
IN_ARRAY
()
||
IN_LIST
())
{
const
char
*
s
=
parsectx_take_string
(
ctx
);
config_setting_t
*
e
=
config_setting_set_string_elem
(
ctx
->
parent
,
-
1
,
s
);
_delete
(
s
);
_
_
delete
(
s
);
if
(
!
e
)
{
...
...
@@ -1599,14 +1590,14 @@ yyreduce:
{
const
char
*
s
=
parsectx_take_string
(
ctx
);
config_setting_set_string
(
ctx
->
setting
,
s
);
_delete
(
s
);
_
_
delete
(
s
);
}
}
#line 1
606
"grammar.c"
/* yacc.c:1646 */
#line 1
597
"grammar.c"
/* yacc.c:1646 */
break
;
case
40
:
#line 3
76
"grammar.y"
/* yacc.c:1646 */
#line 3
67
"grammar.y"
/* yacc.c:1646 */
{
if
(
IN_LIST
())
{
...
...
@@ -1620,20 +1611,20 @@ yyreduce:
ctx
->
setting
=
NULL
;
}
}
#line 16
24
"grammar.c"
/* yacc.c:1646 */
#line 16
15
"grammar.c"
/* yacc.c:1646 */
break
;
case
41
:
#line 3
91
"grammar.y"
/* yacc.c:1646 */
#line 3
82
"grammar.y"
/* yacc.c:1646 */
{
if
(
ctx
->
parent
)
ctx
->
parent
=
ctx
->
parent
->
parent
;
}
#line 16
33
"grammar.c"
/* yacc.c:1646 */
#line 16
24
"grammar.c"
/* yacc.c:1646 */
break
;
#line 16
37
"grammar.c"
/* yacc.c:1646 */
#line 16
28
"grammar.c"
/* yacc.c:1646 */
default:
break
;
}
/* User semantic actions sometimes alter yychar, and that requires
...
...
@@ -1861,5 +1852,5 @@ yyreturn:
#endif
return
yyresult
;
}
#line 3
97
"grammar.y"
/* yacc.c:1906 */
#line 3
88
"grammar.y"
/* yacc.c:1906 */
lib/grammar.h
View file @
01bc2250
...
...
@@ -94,7 +94,7 @@ extern int libconfig_yydebug;
union
YYSTYPE
{
#line
85
"grammar.y"
/* yacc.c:1909 */
#line
76
"grammar.y"
/* yacc.c:1909 */
int
ival
;
long
long
llval
;
...
...
lib/grammar.y
View file @
01bc2250
...
...
@@ -32,29 +32,20 @@
%{
#include <string.h>
#include <stdlib.h>
#include "libconfig.h"
#ifdef WIN32
#include "wincompat.h"
/* prevent warnings about redefined malloc/free in generated code: */
#ifndef _STDLIB_H
#define _STDLIB_H
#endif
#include <malloc.h>
#endif
#include "libconfig.h"
#include "parsectx.h"
#include "scanctx.h"
#include "util.h"
#include "wincompat.h"
/*
these delcarations are provided to suppress compiler warnings
*/
/*
These declarations are provided to suppress compiler warnings.
*/
extern int libconfig_yylex();
extern int libconfig_yyget_lineno();
static const char *err_array_elem_type = "mismatched element type in array";
static const char *err_duplicate_setting = "duplicate setting name";
#define _delete(P) free((void *)(P))
#define IN_ARRAY() \
(ctx->parent && (ctx->parent->type == CONFIG_TYPE_ARRAY))
...
...
@@ -328,7 +319,7 @@ simple_value:
{
const char *s = parsectx_take_string(ctx);
config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, s);
_delete(s);
_
_
delete(s);
if(! e)
{
...
...
@@ -344,7 +335,7 @@ simple_value:
{
const char *s = parsectx_take_string(ctx);
config_setting_set_string(ctx->setting, s);
_delete(s);
_
_
delete(s);
}
}
;
...
...
lib/libconfig.c
View file @
01bc2250
...
...
@@ -54,8 +54,8 @@
/* ------------------------------------------------------------------------- */
#ifndef LIBCONFIG_STATIC
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
\
|| defined(WIN64) || defined(_WIN64
))
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
|| defined(WIN64) || defined(_WIN64) || defined(__WIN64__
))
BOOL
WINAPI
DllMain
(
HINSTANCE
hinstDLL
,
DWORD
fdwReason
,
LPVOID
lpvReserved
)
{
...
...
lib/wincompat.h
View file @
01bc2250
...
...
@@ -25,7 +25,15 @@
#include <limits.h>
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
|| defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
/* Prevent warnings about redefined malloc/free in generated code. */
#ifndef _STDLIB_H
#define _STDLIB_H
#endif
#include <malloc.h>
#ifdef _MSC_VER
#pragma warning (disable: 4996)
...
...
@@ -53,7 +61,8 @@
#endif
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
|| defined(__MINGW32__))
|| defined(WIN64) || defined(_WIN64) || defined(__WIN64__) \
|| defined(__MINGW32__))
#define INT64_FMT "%I64d"
#define UINT64_FMT "%I64u"
...
...
@@ -73,7 +82,8 @@
#endif
/* defined(WIN32) || defined(__MINGW32__) */
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
|| defined(WIN64) || defined(_WIN64) || defined(__WIN64__)) \
&& ! defined(__MINGW32__)
#define INT64_CONST(I) (I ## i64)
...
...
@@ -91,7 +101,7 @@
#define IS_RELATIVE_PATH(P) \
(PathIsRelativeA(P))
#else
/* defined(WIN32) && ! defined(__MINGW32__) */
#else
/* defined(WIN32
/WIN64
) && ! defined(__MINGW32__) */
#define INT64_CONST(I) (I ## LL)
#define UINT64_CONST(I) (I ## ULL)
...
...
@@ -99,6 +109,6 @@
#define IS_RELATIVE_PATH(P) \
((P)[0] != '/')
#endif
/* defined(WIN32) && ! defined(__MINGW32__) */
#endif
/* defined(WIN32
/WIN64
) && ! defined(__MINGW32__) */
#endif
/* __wincompat_h */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment