diff options
Diffstat (limited to '')
-rw-r--r-- | examples/c++/cxx_example1.vcproj (renamed from libconfig++_stub.vcproj) | 45 | ||||
-rw-r--r-- | examples/c/example1.vcproj (renamed from libconfig_stub.vcproj) | 39 | ||||
-rw-r--r-- | lib/Makefile.am | 80 | ||||
-rw-r--r-- | lib/Makefile.in | 793 | ||||
-rw-r--r-- | lib/grammar.c (renamed from grammar.c) | 701 | ||||
-rw-r--r-- | lib/grammar.h (renamed from grammar.h) | 54 | ||||
-rw-r--r-- | lib/grammar.y (renamed from grammar.y) | 93 | ||||
-rw-r--r-- | lib/libconfig++.pc.in (renamed from libconfig++.pc.in) | 0 | ||||
-rw-r--r-- | lib/libconfig++.vcproj (renamed from libconfig++.vcproj) | 46 | ||||
-rw-r--r-- | lib/libconfig.c (renamed from libconfig.c) | 389 | ||||
-rw-r--r-- | lib/libconfig.h (renamed from libconfig.h) | 87 | ||||
-rw-r--r-- | lib/libconfig.h++ | 459 | ||||
-rw-r--r-- | lib/libconfig.hh (renamed from libconfig.hh) | 2 | ||||
-rw-r--r-- | lib/libconfig.pc.in (renamed from libconfig.pc.in) | 0 | ||||
-rw-r--r-- | lib/libconfig.vcproj (renamed from libconfig.vcproj) | 40 | ||||
-rw-r--r-- | lib/libconfigcpp.c++ (renamed from libconfigcpp.c++) | 239 | ||||
-rw-r--r-- | lib/libconfigcpp.cc (renamed from libconfigcpp.cc) | 2 | ||||
-rw-r--r-- | lib/parsectx.h | 48 | ||||
-rw-r--r-- | lib/scanctx.c | 171 | ||||
-rw-r--r-- | lib/scanctx.h | 62 | ||||
-rw-r--r-- | lib/scanner.c (renamed from scanner.c) | 690 | ||||
-rw-r--r-- | lib/scanner.h (renamed from scanner.h) | 0 | ||||
-rw-r--r-- | lib/scanner.l | 190 | ||||
-rw-r--r-- | lib/strbuf.c | 58 | ||||
-rw-r--r-- | lib/strbuf.h (renamed from private.h) | 45 | ||||
-rw-r--r-- | lib/wincompat.h (renamed from wincompat.h) | 25 | ||||
-rw-r--r-- | libconfig.h++ | 424 | ||||
-rw-r--r-- | libconfig.sln | 103 | ||||
-rw-r--r-- | libconfig.spec | 19 | ||||
-rw-r--r-- | libconfig.spec.in | 17 |
30 files changed, 3389 insertions, 1532 deletions
diff --git a/libconfig++_stub.vcproj b/examples/c++/cxx_example1.vcproj index c89b53e..0a9207f 100644 --- a/libconfig++_stub.vcproj +++ b/examples/c++/cxx_example1.vcproj @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
- Name="libconfig++_stub"
- ProjectGUID="{2A94C9E9-A7C7-4770-A24C-694312ADB850}"
- RootNamespace="libconfig_stub"
+ Version="9.00"
+ Name="c++_example1"
+ ProjectGUID="{A1DF518C-A515-45A3-9B67-7D49F616DECC}"
+ RootNamespace="cxx_example1"
Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
@@ -39,10 +40,10 @@ />
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="."
+ AdditionalIncludeDirectories="..\..\lib"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
RuntimeLibrary="3"
- WarningLevel="0"
+ CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -55,9 +56,10 @@ />
<Tool
Name="VCLinkerTool"
- LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -79,9 +81,6 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -110,9 +109,11 @@ />
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="."
+ AdditionalIncludeDirectories="..\..\lib"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -125,8 +126,9 @@ />
<Tool
Name="VCLinkerTool"
- GenerateDebugInformation="false"
SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -148,36 +150,35 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
- <ProjectReference
- ReferencedProjectIdentifier="{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}"
- RelativePathToProject=".\libconfig++.vcproj"
- />
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
- RelativePath=".\samples\c++\stubcpp.cpp"
+ RelativePath=".\example1.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
+ <Filter
+ Name="Data Files"
+ >
+ <File
+ RelativePath=".\example.cfg"
+ >
+ </File>
+ </Filter>
</Files>
<Globals>
</Globals>
diff --git a/libconfig_stub.vcproj b/examples/c/example1.vcproj index dc3e31f..b515e3b 100644 --- a/libconfig_stub.vcproj +++ b/examples/c/example1.vcproj @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
- Name="libconfig_stub"
- ProjectGUID="{6CD5E648-E434-4C9A-9872-AF884149CE93}"
- RootNamespace="libconfig_stub"
+ Version="9.00"
+ Name="c_example1"
+ ProjectGUID="{454984C5-C302-4CE2-9B17-15B96E05E120}"
+ RootNamespace="c_example1"
Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
@@ -39,7 +40,7 @@ />
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="."
+ AdditionalIncludeDirectories="../../lib"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
RuntimeLibrary="3"
CompileAs="1"
@@ -57,6 +58,8 @@ Name="VCLinkerTool"
GenerateDebugInformation="true"
SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -78,9 +81,6 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -109,7 +109,7 @@ />
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="."
+ AdditionalIncludeDirectories="../../lib"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
@@ -127,6 +127,8 @@ <Tool
Name="VCLinkerTool"
SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -148,36 +150,35 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
- <ProjectReference
- ReferencedProjectIdentifier="{1A234565-926D-49B2-83E4-D56E0C38C9F2}"
- RelativePathToProject=".\libconfig.vcproj"
- />
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
- RelativePath=".\samples\c\stub.c"
+ RelativePath=".\example1.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
+ <Filter
+ Name="Data Files"
+ >
+ <File
+ RelativePath=".\example.cfg"
+ >
+ </File>
+ </Filter>
</Files>
<Globals>
</Globals>
diff --git a/lib/Makefile.am b/lib/Makefile.am new file mode 100644 index 0000000..240c519 --- /dev/null +++ b/lib/Makefile.am @@ -0,0 +1,80 @@ + +lib_LTLIBRARIES = libconfig.la + +if BUILDCXX +lib_LTLIBRARIES += libconfig++.la +endif + +# Versioning rules ( C:R:A ) +# +# Perform EACH step that applies. +# +# 1. Start with version 0:0:0. +# 2. If any of the sources have changed, increment R. This is a new revision +# of the current interface. +# 3. If the interface has changed, increment C and set R to 0. This is the +# first revision of a new interface. +# 4. If the new interface is a superset of the previous interface +# (that is, if the previous interface has not been broken by the +# changes in this new release), increment A. This release is backwards +# compatible with the previous release. +# 5. If the new interface has removed elements with respect to the +# previous interface, then backward compatibility is broken; set A to 0. +# This release has a new, but backwards incompatible interface. +# +# For more info see section 6.3 of the GNU Libtool Manual. + +VERINFO = -version-info 10:2:1 + +PARSER_PREFIX = libconfig_yy + +libconfig_la_LDFLAGS = $(VERINFO) -no-undefined + +libconfig___la_LDFLAGS = $(VERINFO) -no-undefined + +libsrc = libconfig.c scanner.l grammar.y parsectx.h wincompat.h \ + scanctx.c scanctx.h strbuf.c strbuf.h +libinc = libconfig.h + +libsrc_cpp = $(libsrc) libconfigcpp.c++ +libinc_cpp = libconfig.h++ + +BUILT_SOURCES = scanner.c scanner.h grammar.c grammar.h + +libconfig_la_SOURCES = $(libsrc) + +libconfig___la_SOURCES = $(libsrc_cpp) + +libcppflags = -D_REENTRANT +libcppxxflags = -D_REENTRANT + +if GNU_WIN +libcppflags += -DLIBCONFIG_EXPORTS +libcppxxflags += -DLIBCONFIGXX_EXPORTS -DLIBCONFIG_STATIC +endif + +libconfig_la_CPPFLAGS = -DPARSER_PREFIX=\"$(PARSER_PREFIX)\" $(libcppflags) +libconfig___la_CPPFLAGS = -DPARSER_PREFIX=\"$(PARSER_PREFIX)\" $(libcppxxflags) + +include_HEADERS = $(libinc) + +if BUILDCXX +include_HEADERS += $(libinc_cpp) +endif + +AM_YFLAGS = -d -p $(PARSER_PREFIX) + +AM_LFLAGS = --header-file=scanner.h --prefix=$(PARSER_PREFIX) + +EXTRA_DIST = \ + $(BUILT_SOURCES) \ + libconfigcpp.cc libconfig.hh \ + *.vcproj + +pkgconfigdir = $(libdir)/pkgconfig + +pkgconfig_DATA = libconfig.pc + +if BUILDCXX +pkgconfig_DATA += libconfig++.pc +endif diff --git a/lib/Makefile.in b/lib/Makefile.in new file mode 100644 index 0000000..059644c --- /dev/null +++ b/lib/Makefile.in @@ -0,0 +1,793 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +@BUILDCXX_TRUE@am__append_1 = libconfig++.la +@GNU_WIN_TRUE@am__append_2 = -DLIBCONFIG_EXPORTS +@GNU_WIN_TRUE@am__append_3 = -DLIBCONFIGXX_EXPORTS -DLIBCONFIG_STATIC +@BUILDCXX_TRUE@am__append_4 = $(libinc_cpp) +@BUILDCXX_TRUE@am__append_5 = libconfig++.pc +subdir = lib +DIST_COMMON = $(am__include_HEADERS_DIST) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/libconfig++.pc.in \ + $(srcdir)/libconfig.pc.in grammar.c grammar.h scanner.c +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/aux-build/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/ac_config.h +CONFIG_CLEAN_FILES = libconfig.pc libconfig++.pc +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" \ + "$(DESTDIR)$(includedir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +libconfig___la_LIBADD = +am__objects_1 = libconfig___la-libconfig.lo libconfig___la-scanner.lo \ + libconfig___la-grammar.lo libconfig___la-scanctx.lo \ + libconfig___la-strbuf.lo +am__objects_2 = $(am__objects_1) libconfig___la-libconfigcpp.lo +am_libconfig___la_OBJECTS = $(am__objects_2) +libconfig___la_OBJECTS = $(am_libconfig___la_OBJECTS) +libconfig___la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(libconfig___la_LDFLAGS) $(LDFLAGS) -o $@ +@BUILDCXX_TRUE@am_libconfig___la_rpath = -rpath $(libdir) +libconfig_la_LIBADD = +am__objects_3 = libconfig_la-libconfig.lo libconfig_la-scanner.lo \ + libconfig_la-grammar.lo libconfig_la-scanctx.lo \ + libconfig_la-strbuf.lo +am_libconfig_la_OBJECTS = $(am__objects_3) +libconfig_la_OBJECTS = $(am_libconfig_la_OBJECTS) +libconfig_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libconfig_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/aux-build/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) +LTLEXCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(LEX) $(LFLAGS) $(AM_LFLAGS) +YLWRAP = $(top_srcdir)/aux-build/ylwrap +YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) +LTYACCCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS) +SOURCES = $(libconfig___la_SOURCES) $(libconfig_la_SOURCES) +DIST_SOURCES = $(libconfig___la_SOURCES) $(libconfig_la_SOURCES) +DATA = $(pkgconfig_DATA) +am__include_HEADERS_DIST = libconfig.h libconfig.h++ +HEADERS = $(include_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +lib_LTLIBRARIES = libconfig.la $(am__append_1) + +# Versioning rules ( C:R:A ) +# +# Perform EACH step that applies. +# +# 1. Start with version 0:0:0. +# 2. If any of the sources have changed, increment R. This is a new revision +# of the current interface. +# 3. If the interface has changed, increment C and set R to 0. This is the +# first revision of a new interface. +# 4. If the new interface is a superset of the previous interface +# (that is, if the previous interface has not been broken by the +# changes in this new release), increment A. This release is backwards +# compatible with the previous release. +# 5. If the new interface has removed elements with respect to the +# previous interface, then backward compatibility is broken; set A to 0. +# This release has a new, but backwards incompatible interface. +# +# For more info see section 6.3 of the GNU Libtool Manual. +VERINFO = -version-info 10:2:1 +PARSER_PREFIX = libconfig_yy +libconfig_la_LDFLAGS = $(VERINFO) -no-undefined +libconfig___la_LDFLAGS = $(VERINFO) -no-undefined +libsrc = libconfig.c scanner.l grammar.y parsectx.h wincompat.h \ + scanctx.c scanctx.h strbuf.c strbuf.h + +libinc = libconfig.h +libsrc_cpp = $(libsrc) libconfigcpp.c++ +libinc_cpp = libconfig.h++ +BUILT_SOURCES = scanner.c scanner.h grammar.c grammar.h +libconfig_la_SOURCES = $(libsrc) +libconfig___la_SOURCES = $(libsrc_cpp) +libcppflags = -D_REENTRANT $(am__append_2) +libcppxxflags = -D_REENTRANT $(am__append_3) +libconfig_la_CPPFLAGS = -DPARSER_PREFIX=\"$(PARSER_PREFIX)\" $(libcppflags) +libconfig___la_CPPFLAGS = -DPARSER_PREFIX=\"$(PARSER_PREFIX)\" $(libcppxxflags) +include_HEADERS = $(libinc) $(am__append_4) +AM_YFLAGS = -d -p $(PARSER_PREFIX) +AM_LFLAGS = --header-file=scanner.h --prefix=$(PARSER_PREFIX) +EXTRA_DIST = \ + $(BUILT_SOURCES) \ + libconfigcpp.cc libconfig.hh \ + *.vcproj + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libconfig.pc $(am__append_5) +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .c++ .l .lo .o .obj .y +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu lib/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +libconfig.pc: $(top_builddir)/config.status $(srcdir)/libconfig.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +libconfig++.pc: $(top_builddir)/config.status $(srcdir)/libconfig++.pc.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +grammar.h: grammar.c + @if test ! -f $@; then \ + rm -f grammar.c; \ + $(MAKE) $(AM_MAKEFLAGS) grammar.c; \ + else :; fi +libconfig++.la: $(libconfig___la_OBJECTS) $(libconfig___la_DEPENDENCIES) + $(libconfig___la_LINK) $(am_libconfig___la_rpath) $(libconfig___la_OBJECTS) $(libconfig___la_LIBADD) $(LIBS) +libconfig.la: $(libconfig_la_OBJECTS) $(libconfig_la_DEPENDENCIES) + $(libconfig_la_LINK) -rpath $(libdir) $(libconfig_la_OBJECTS) $(libconfig_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-grammar.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-libconfig.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-libconfigcpp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-scanctx.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-scanner.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig___la-strbuf.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig_la-grammar.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig_la-libconfig.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig_la-scanctx.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig_la-scanner.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libconfig_la-strbuf.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +libconfig___la-libconfig.lo: libconfig.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig___la-libconfig.lo -MD -MP -MF $(DEPDIR)/libconfig___la-libconfig.Tpo -c -o libconfig___la-libconfig.lo `test -f 'libconfig.c' || echo '$(srcdir)/'`libconfig.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-libconfig.Tpo $(DEPDIR)/libconfig___la-libconfig.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libconfig.c' object='libconfig___la-libconfig.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig___la-libconfig.lo `test -f 'libconfig.c' || echo '$(srcdir)/'`libconfig.c + +libconfig___la-scanner.lo: scanner.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig___la-scanner.lo -MD -MP -MF $(DEPDIR)/libconfig___la-scanner.Tpo -c -o libconfig___la-scanner.lo `test -f 'scanner.c' || echo '$(srcdir)/'`scanner.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-scanner.Tpo $(DEPDIR)/libconfig___la-scanner.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanner.c' object='libconfig___la-scanner.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig___la-scanner.lo `test -f 'scanner.c' || echo '$(srcdir)/'`scanner.c + +libconfig___la-grammar.lo: grammar.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig___la-grammar.lo -MD -MP -MF $(DEPDIR)/libconfig___la-grammar.Tpo -c -o libconfig___la-grammar.lo `test -f 'grammar.c' || echo '$(srcdir)/'`grammar.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-grammar.Tpo $(DEPDIR)/libconfig___la-grammar.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='grammar.c' object='libconfig___la-grammar.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig___la-grammar.lo `test -f 'grammar.c' || echo '$(srcdir)/'`grammar.c + +libconfig___la-scanctx.lo: scanctx.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig___la-scanctx.lo -MD -MP -MF $(DEPDIR)/libconfig___la-scanctx.Tpo -c -o libconfig___la-scanctx.lo `test -f 'scanctx.c' || echo '$(srcdir)/'`scanctx.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-scanctx.Tpo $(DEPDIR)/libconfig___la-scanctx.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanctx.c' object='libconfig___la-scanctx.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig___la-scanctx.lo `test -f 'scanctx.c' || echo '$(srcdir)/'`scanctx.c + +libconfig___la-strbuf.lo: strbuf.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig___la-strbuf.lo -MD -MP -MF $(DEPDIR)/libconfig___la-strbuf.Tpo -c -o libconfig___la-strbuf.lo `test -f 'strbuf.c' || echo '$(srcdir)/'`strbuf.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-strbuf.Tpo $(DEPDIR)/libconfig___la-strbuf.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='strbuf.c' object='libconfig___la-strbuf.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig___la-strbuf.lo `test -f 'strbuf.c' || echo '$(srcdir)/'`strbuf.c + +libconfig_la-libconfig.lo: libconfig.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_la-libconfig.lo -MD -MP -MF $(DEPDIR)/libconfig_la-libconfig.Tpo -c -o libconfig_la-libconfig.lo `test -f 'libconfig.c' || echo '$(srcdir)/'`libconfig.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_la-libconfig.Tpo $(DEPDIR)/libconfig_la-libconfig.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libconfig.c' object='libconfig_la-libconfig.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_la-libconfig.lo `test -f 'libconfig.c' || echo '$(srcdir)/'`libconfig.c + +libconfig_la-scanner.lo: scanner.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_la-scanner.lo -MD -MP -MF $(DEPDIR)/libconfig_la-scanner.Tpo -c -o libconfig_la-scanner.lo `test -f 'scanner.c' || echo '$(srcdir)/'`scanner.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_la-scanner.Tpo $(DEPDIR)/libconfig_la-scanner.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanner.c' object='libconfig_la-scanner.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_la-scanner.lo `test -f 'scanner.c' || echo '$(srcdir)/'`scanner.c + +libconfig_la-grammar.lo: grammar.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_la-grammar.lo -MD -MP -MF $(DEPDIR)/libconfig_la-grammar.Tpo -c -o libconfig_la-grammar.lo `test -f 'grammar.c' || echo '$(srcdir)/'`grammar.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_la-grammar.Tpo $(DEPDIR)/libconfig_la-grammar.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='grammar.c' object='libconfig_la-grammar.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_la-grammar.lo `test -f 'grammar.c' || echo '$(srcdir)/'`grammar.c + +libconfig_la-scanctx.lo: scanctx.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_la-scanctx.lo -MD -MP -MF $(DEPDIR)/libconfig_la-scanctx.Tpo -c -o libconfig_la-scanctx.lo `test -f 'scanctx.c' || echo '$(srcdir)/'`scanctx.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_la-scanctx.Tpo $(DEPDIR)/libconfig_la-scanctx.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scanctx.c' object='libconfig_la-scanctx.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_la-scanctx.lo `test -f 'scanctx.c' || echo '$(srcdir)/'`scanctx.c + +libconfig_la-strbuf.lo: strbuf.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libconfig_la-strbuf.lo -MD -MP -MF $(DEPDIR)/libconfig_la-strbuf.Tpo -c -o libconfig_la-strbuf.lo `test -f 'strbuf.c' || echo '$(srcdir)/'`strbuf.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libconfig_la-strbuf.Tpo $(DEPDIR)/libconfig_la-strbuf.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='strbuf.c' object='libconfig_la-strbuf.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libconfig_la-strbuf.lo `test -f 'strbuf.c' || echo '$(srcdir)/'`strbuf.c + +.c++.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.c++.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c++.lo: +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +libconfig___la-libconfigcpp.lo: libconfigcpp.c++ +@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libconfig___la-libconfigcpp.lo -MD -MP -MF $(DEPDIR)/libconfig___la-libconfigcpp.Tpo -c -o libconfig___la-libconfigcpp.lo `test -f 'libconfigcpp.c++' || echo '$(srcdir)/'`libconfigcpp.c++ +@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libconfig___la-libconfigcpp.Tpo $(DEPDIR)/libconfig___la-libconfigcpp.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='libconfigcpp.c++' object='libconfig___la-libconfigcpp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libconfig___la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libconfig___la-libconfigcpp.lo `test -f 'libconfigcpp.c++' || echo '$(srcdir)/'`libconfigcpp.c++ + +.l.c: + $(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE) + +.y.c: + $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE) + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-pkgconfigDATA: $(pkgconfig_DATA) + @$(NORMAL_INSTALL) + test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \ + done + +uninstall-pkgconfigDATA: + @$(NORMAL_UNINSTALL) + @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(includedir)" && rm -f $$files + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -rm -f grammar.c + -rm -f grammar.h + -rm -f scanner.c + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-includeHEADERS install-pkgconfigDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES \ + uninstall-pkgconfigDATA + +.MAKE: all check install install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-includeHEADERS install-info \ + install-info-am install-libLTLIBRARIES install-man install-pdf \ + install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-includeHEADERS uninstall-libLTLIBRARIES \ + uninstall-pkgconfigDATA + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/grammar.c b/lib/grammar.c index 8317318..e95a569 100644 --- a/grammar.c +++ b/lib/grammar.c @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,72 +54,29 @@ /* Pure parsers. */ #define YYPURE 1 +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + /* Using locations. */ #define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ -#define yyparse libconfig_yyparse -#define yylex libconfig_yylex -#define yyerror libconfig_yyerror -#define yylval libconfig_yylval -#define yychar libconfig_yychar -#define yydebug libconfig_yydebug -#define yynerrs libconfig_yynerrs - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_BOOLEAN = 258, - TOK_INTEGER = 259, - TOK_HEX = 260, - TOK_INTEGER64 = 261, - TOK_HEX64 = 262, - TOK_FLOAT = 263, - TOK_STRING = 264, - TOK_NAME = 265, - TOK_EQUALS = 266, - TOK_NEWLINE = 267, - TOK_ARRAY_START = 268, - TOK_ARRAY_END = 269, - TOK_LIST_START = 270, - TOK_LIST_END = 271, - TOK_COMMA = 272, - TOK_GROUP_START = 273, - TOK_GROUP_END = 274, - TOK_END = 275, - TOK_GARBAGE = 276 - }; -#endif -/* Tokens. */ -#define TOK_BOOLEAN 258 -#define TOK_INTEGER 259 -#define TOK_HEX 260 -#define TOK_INTEGER64 261 -#define TOK_HEX64 262 -#define TOK_FLOAT 263 -#define TOK_STRING 264 -#define TOK_NAME 265 -#define TOK_EQUALS 266 -#define TOK_NEWLINE 267 -#define TOK_ARRAY_START 268 -#define TOK_ARRAY_END 269 -#define TOK_LIST_START 270 -#define TOK_LIST_END 271 -#define TOK_COMMA 272 -#define TOK_GROUP_START 273 -#define TOK_GROUP_END 274 -#define TOK_END 275 -#define TOK_GARBAGE 276 - - +#define yyparse libconfig_yyparse +#define yylex libconfig_yylex +#define yyerror libconfig_yyerror +#define yylval libconfig_yylval +#define yychar libconfig_yychar +#define yydebug libconfig_yydebug +#define yynerrs libconfig_yynerrs /* Copy the first part of user declarations. */ -#line 31 "grammar.y" + +/* Line 189 of yacc.c */ +#line 32 "grammar.y" #include <string.h> #include <stdlib.h> @@ -132,36 +88,50 @@ #ifndef _STDLIB_H #define _STDLIB_H #endif - + #include <malloc.h> #endif -#include "private.h" +#include "parsectx.h" +#include "scanctx.h" /* these delcarations 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)) #define IN_LIST() \ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_LIST)) -#define CAPTURE_PARSE_POS(S) \ - (S)->line = (unsigned int)libconfig_yyget_lineno(scanner) +static void capture_parse_pos(void *scanner, struct scan_context *scan_ctx, + config_setting_t *setting) +{ + setting->line = (unsigned int)libconfig_yyget_lineno(scanner); + setting->file = scanctx_current_filename(scan_ctx); +} + +#define CAPTURE_PARSE_POS(S) \ + capture_parse_pos(scanner, scan_ctx, (S)) void libconfig_yyerror(void *scanner, struct parse_context *ctx, - char const *s) + struct scan_context *scan_ctx, char const *s) { + if(ctx->config->error_text) return; ctx->config->error_line = libconfig_yyget_lineno(scanner); ctx->config->error_text = s; } +/* Line 189 of yacc.c */ +#line 134 "grammar.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -180,30 +150,88 @@ void libconfig_yyerror(void *scanner, struct parse_context *ctx, # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_BOOLEAN = 258, + TOK_INTEGER = 259, + TOK_HEX = 260, + TOK_INTEGER64 = 261, + TOK_HEX64 = 262, + TOK_FLOAT = 263, + TOK_STRING = 264, + TOK_NAME = 265, + TOK_EQUALS = 266, + TOK_NEWLINE = 267, + TOK_ARRAY_START = 268, + TOK_ARRAY_END = 269, + TOK_LIST_START = 270, + TOK_LIST_END = 271, + TOK_COMMA = 272, + TOK_GROUP_START = 273, + TOK_GROUP_END = 274, + TOK_SEMICOLON = 275, + TOK_GARBAGE = 276, + TOK_ERROR = 277 + }; +#endif +/* Tokens. */ +#define TOK_BOOLEAN 258 +#define TOK_INTEGER 259 +#define TOK_HEX 260 +#define TOK_INTEGER64 261 +#define TOK_HEX64 262 +#define TOK_FLOAT 263 +#define TOK_STRING 264 +#define TOK_NAME 265 +#define TOK_EQUALS 266 +#define TOK_NEWLINE 267 +#define TOK_ARRAY_START 268 +#define TOK_ARRAY_END 269 +#define TOK_LIST_START 270 +#define TOK_LIST_END 271 +#define TOK_COMMA 272 +#define TOK_GROUP_START 273 +#define TOK_GROUP_END 274 +#define TOK_SEMICOLON 275 +#define TOK_GARBAGE 276 +#define TOK_ERROR 277 + + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 73 "grammar.y" { - long ival; + +/* Line 214 of yacc.c */ +#line 85 "grammar.y" + + int ival; long long llval; double fval; char *sval; -} -/* Line 187 of yacc.c. */ -#line 194 "grammar.c" - YYSTYPE; + + + +/* Line 214 of yacc.c */ +#line 223 "grammar.c" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif - /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 207 "grammar.c" +/* Line 264 of yacc.c */ +#line 235 "grammar.c" #ifdef short # undef short @@ -278,14 +306,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -366,9 +394,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -402,12 +430,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -418,20 +446,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 6 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 32 +#define YYLAST 35 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 22 +#define YYNTOKENS 23 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 18 +#define YYNNTS 20 /* YYNRULES -- Number of rules. */ -#define YYNRULES 34 +#define YYNRULES 39 /* YYNRULES -- Number of states. */ -#define YYNSTATES 43 +#define YYNSTATES 47 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 276 +#define YYMAXUTOK 277 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -466,7 +494,7 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21 + 15, 16, 17, 18, 19, 20, 21, 22 }; #if YYDEBUG @@ -475,31 +503,32 @@ static const yytype_uint8 yytranslate[] = static const yytype_uint8 yyprhs[] = { 0, 0, 3, 4, 6, 8, 11, 12, 14, 15, - 21, 22, 27, 28, 33, 35, 37, 39, 41, 43, - 45, 47, 49, 51, 53, 55, 57, 61, 62, 64, - 66, 70, 71, 73, 74 + 17, 19, 20, 26, 27, 32, 33, 38, 40, 42, + 44, 46, 48, 51, 53, 55, 57, 59, 61, 63, + 65, 67, 71, 72, 74, 76, 80, 81, 83, 84 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 23, 0, -1, -1, 24, -1, 26, -1, 24, 26, - -1, -1, 24, -1, -1, 10, 27, 11, 32, 20, - -1, -1, 13, 29, 37, 14, -1, -1, 15, 31, - 35, 16, -1, 33, -1, 28, -1, 30, -1, 38, + 24, 0, -1, -1, 25, -1, 28, -1, 25, 28, + -1, -1, 25, -1, -1, 20, -1, 17, -1, -1, + 10, 29, 11, 34, 27, -1, -1, 13, 31, 40, + 14, -1, -1, 15, 33, 38, 16, -1, 36, -1, + 30, -1, 32, -1, 41, -1, 9, -1, 35, 9, -1, 3, -1, 4, -1, 6, -1, 5, -1, 7, - -1, 8, -1, 9, -1, 32, -1, 34, 17, 32, - -1, -1, 34, -1, 33, -1, 36, 17, 33, -1, - -1, 36, -1, -1, 18, 39, 25, 19, -1 + -1, 8, -1, 35, -1, 34, -1, 37, 17, 34, + -1, -1, 37, -1, 36, -1, 39, 17, 36, -1, + -1, 39, -1, -1, 18, 42, 26, 19, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 88, 88, 90, 94, 95, 98, 100, 105, 104, - 125, 124, 148, 147, 170, 171, 172, 173, 177, 197, - 219, 241, 263, 285, 303, 330, 331, 334, 336, 340, - 341, 344, 346, 351, 350 + 0, 100, 100, 102, 106, 107, 110, 112, 115, 117, + 118, 123, 122, 142, 141, 165, 164, 187, 188, 189, + 190, 194, 195, 199, 219, 241, 263, 285, 307, 325, + 353, 354, 357, 359, 363, 364, 367, 369, 374, 373 }; #endif @@ -512,11 +541,11 @@ static const char *const yytname[] = "TOK_INTEGER64", "TOK_HEX64", "TOK_FLOAT", "TOK_STRING", "TOK_NAME", "TOK_EQUALS", "TOK_NEWLINE", "TOK_ARRAY_START", "TOK_ARRAY_END", "TOK_LIST_START", "TOK_LIST_END", "TOK_COMMA", "TOK_GROUP_START", - "TOK_GROUP_END", "TOK_END", "TOK_GARBAGE", "$accept", "configuration", - "setting_list", "setting_list_optional", "setting", "@1", "array", "@2", - "list", "@3", "value", "simple_value", "value_list", - "value_list_optional", "simple_value_list", "simple_value_list_optional", - "group", "@4", 0 + "TOK_GROUP_END", "TOK_SEMICOLON", "TOK_GARBAGE", "TOK_ERROR", "$accept", + "configuration", "setting_list", "setting_list_optional", + "setting_terminator", "setting", "$@1", "array", "$@2", "list", "$@3", + "value", "string", "simple_value", "value_list", "value_list_optional", + "simple_value_list", "simple_value_list_optional", "group", "$@4", 0 }; #endif @@ -527,26 +556,26 @@ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276 + 275, 276, 277 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 22, 23, 23, 24, 24, 25, 25, 27, 26, - 29, 28, 31, 30, 32, 32, 32, 32, 33, 33, - 33, 33, 33, 33, 33, 34, 34, 35, 35, 36, - 36, 37, 37, 39, 38 + 0, 23, 24, 24, 25, 25, 26, 26, 27, 27, + 27, 29, 28, 31, 30, 33, 32, 34, 34, 34, + 34, 35, 35, 36, 36, 36, 36, 36, 36, 36, + 37, 37, 38, 38, 39, 39, 40, 40, 42, 41 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 0, 1, 1, 2, 0, 1, 0, 5, - 0, 4, 0, 4, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 0, 1, 1, - 3, 0, 1, 0, 4 + 0, 2, 0, 1, 1, 2, 0, 1, 0, 1, + 1, 0, 5, 0, 4, 0, 4, 1, 1, 1, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 0, 1, 1, 3, 0, 1, 0, 4 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -554,37 +583,37 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 2, 8, 0, 3, 4, 0, 1, 5, 0, 18, - 19, 21, 20, 22, 23, 24, 10, 12, 33, 15, - 16, 0, 14, 17, 31, 27, 6, 9, 29, 32, - 0, 25, 28, 0, 7, 0, 0, 11, 0, 13, - 34, 30, 26 + 2, 11, 0, 3, 4, 0, 1, 5, 0, 23, + 24, 26, 25, 27, 28, 21, 13, 15, 38, 18, + 19, 8, 29, 17, 20, 36, 32, 6, 10, 9, + 12, 22, 34, 37, 0, 30, 33, 0, 7, 0, + 0, 14, 0, 16, 39, 35, 31 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 2, 3, 35, 4, 5, 19, 24, 20, 25, - 21, 22, 32, 33, 29, 30, 23, 26 + -1, 2, 3, 39, 30, 4, 5, 19, 25, 20, + 26, 21, 22, 23, 36, 37, 33, 34, 24, 27 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -18 +#define YYPACT_NINF -26 static const yytype_int8 yypact[] = { - -1, -18, 12, -1, -18, 3, -18, -18, -2, -18, - -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, -5, -18, -18, 20, -2, -1, -18, -18, 0, - 4, -18, 2, 14, -1, 1, 20, -18, -2, -18, - -18, -18, -18 + -8, -26, 12, -8, -26, 5, -26, -26, 0, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -6, 10, -26, -26, 23, 0, -8, -26, -26, + -26, -26, -26, 3, 7, -26, 6, 8, -8, 14, + 23, -26, 0, -26, -26, -26, -26 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -18, -18, 6, -18, -3, -18, -18, -18, -18, -18, - -17, -14, -18, -18, -18, -18, -18, -18 + -26, -26, -5, -26, -26, -3, -26, -26, -26, -26, + -26, -25, -26, -15, -26, -26, -26, -26, -26, -26 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -594,29 +623,29 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 7, 9, 10, 11, 12, 13, 14, 15, 31, 1, - 28, 16, 6, 17, 8, 27, 18, 36, 37, 38, - 40, 42, 41, 9, 10, 11, 12, 13, 14, 15, - 39, 7, 34 + 7, 35, 1, 9, 10, 11, 12, 13, 14, 15, + 32, 28, 6, 16, 29, 17, 8, 46, 18, 31, + 40, 41, 38, 42, 43, 45, 9, 10, 11, 12, + 13, 14, 15, 44, 0, 7 }; -static const yytype_uint8 yycheck[] = +static const yytype_int8 yycheck[] = { - 3, 3, 4, 5, 6, 7, 8, 9, 25, 10, - 24, 13, 0, 15, 11, 20, 18, 17, 14, 17, - 19, 38, 36, 3, 4, 5, 6, 7, 8, 9, - 16, 34, 26 + 3, 26, 10, 3, 4, 5, 6, 7, 8, 9, + 25, 17, 0, 13, 20, 15, 11, 42, 18, 9, + 17, 14, 27, 17, 16, 40, 3, 4, 5, 6, + 7, 8, 9, 19, -1, 38 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 10, 23, 24, 26, 27, 0, 26, 11, 3, - 4, 5, 6, 7, 8, 9, 13, 15, 18, 28, - 30, 32, 33, 38, 29, 31, 39, 20, 33, 36, - 37, 32, 34, 35, 24, 25, 17, 14, 17, 16, - 19, 33, 32 + 0, 10, 24, 25, 28, 29, 0, 28, 11, 3, + 4, 5, 6, 7, 8, 9, 13, 15, 18, 30, + 32, 34, 35, 36, 41, 31, 33, 42, 17, 20, + 27, 9, 36, 39, 40, 34, 37, 38, 25, 26, + 17, 14, 17, 16, 19, 36, 34 }; #define yyerrok (yyerrstatus = 0) @@ -649,7 +678,7 @@ do \ } \ else \ { \ - yyerror (scanner, ctx, YY_("syntax error: cannot back up")); \ + yyerror (scanner, ctx, scan_ctx, YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) @@ -729,7 +758,7 @@ do { \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value, scanner, ctx); \ + Type, Value, scanner, ctx, scan_ctx); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) @@ -743,21 +772,23 @@ do { \ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx) +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) #else static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx) +yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; void *scanner; struct parse_context *ctx; + struct scan_context *scan_ctx; #endif { if (!yyvaluep) return; YYUSE (scanner); YYUSE (ctx); + YYUSE (scan_ctx); # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); @@ -779,15 +810,16 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx) +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) #else static void -yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx) +yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; void *scanner; struct parse_context *ctx; + struct scan_context *scan_ctx; #endif { if (yytype < YYNTOKENS) @@ -795,7 +827,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx) else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx); YYFPRINTF (yyoutput, ")"); } @@ -807,17 +839,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -835,14 +870,15 @@ do { \ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void *scanner, struct parse_context *ctx) +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) #else static void -yy_reduce_print (yyvsp, yyrule, scanner, ctx) +yy_reduce_print (yyvsp, yyrule, scanner, ctx, scan_ctx) YYSTYPE *yyvsp; int yyrule; void *scanner; struct parse_context *ctx; + struct scan_context *scan_ctx; #endif { int yynrhs = yyr2[yyrule]; @@ -853,18 +889,18 @@ yy_reduce_print (yyvsp, yyrule, scanner, ctx) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) - , scanner, ctx); - fprintf (stderr, "\n"); + , scanner, ctx, scan_ctx); + YYFPRINTF (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (yyvsp, Rule, scanner, ctx); \ + yy_reduce_print (yyvsp, Rule, scanner, ctx, scan_ctx); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that @@ -1115,20 +1151,22 @@ yysyntax_error (char *yyresult, int yystate, int yychar) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *scanner, struct parse_context *ctx) +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) #else static void -yydestruct (yymsg, yytype, yyvaluep, scanner, ctx) +yydestruct (yymsg, yytype, yyvaluep, scanner, ctx, scan_ctx) const char *yymsg; int yytype; YYSTYPE *yyvaluep; void *scanner; struct parse_context *ctx; + struct scan_context *scan_ctx; #endif { YYUSE (yyvaluep); YYUSE (scanner); YYUSE (ctx); + YYUSE (scan_ctx); if (!yymsg) yymsg = "Deleting"; @@ -1141,10 +1179,8 @@ yydestruct (yymsg, yytype, yyvaluep, scanner, ctx) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1153,7 +1189,7 @@ int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus -int yyparse (void *scanner, struct parse_context *ctx); +int yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx); #else int yyparse (); #endif @@ -1163,10 +1199,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1182,83 +1217,85 @@ yyparse (YYPARSE_PARAM) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int -yyparse (void *scanner, struct parse_context *ctx) +yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) #else int -yyparse (scanner, ctx) +yyparse (scanner, ctx, scan_ctx) void *scanner; struct parse_context *ctx; + struct scan_context *scan_ctx; #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; + /* Number of syntax errors so far. */ + int yynerrs; - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; - YYSIZE_T yystacksize = YYINITDEPTH; + YYSIZE_T yystacksize; + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; @@ -1288,7 +1325,6 @@ int yynerrs; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1296,7 +1332,6 @@ int yynerrs; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1319,9 +1354,8 @@ int yynerrs; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1332,7 +1366,6 @@ int yynerrs; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1342,6 +1375,9 @@ int yynerrs; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1350,16 +1386,16 @@ int yynerrs; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1391,20 +1427,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1443,15 +1475,16 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 8: -#line 105 "grammar.y" + case 11: + +/* Line 1455 of yacc.c */ +#line 123 "grammar.y" { ctx->setting = config_setting_add(ctx->parent, (yyvsp[(1) - (1)].sval), CONFIG_TYPE_NONE); - free((yyvsp[(1) - (1)].sval)); - + if(ctx->setting == NULL) { - libconfig_yyerror(scanner, ctx, err_duplicate_setting); + libconfig_yyerror(scanner, ctx, scan_ctx, err_duplicate_setting); YYABORT; } else @@ -1461,8 +1494,10 @@ yyreduce: } break; - case 10: -#line 125 "grammar.y" + case 13: + +/* Line 1455 of yacc.c */ +#line 142 "grammar.y" { if(IN_LIST()) { @@ -1478,16 +1513,20 @@ yyreduce: } break; - case 11: -#line 140 "grammar.y" + case 14: + +/* Line 1455 of yacc.c */ +#line 157 "grammar.y" { if(ctx->parent) - ctx->parent = ctx->parent->parent; + ctx->parent = ctx->parent->parent; } break; - case 12: -#line 148 "grammar.y" + case 15: + +/* Line 1455 of yacc.c */ +#line 165 "grammar.y" { if(IN_LIST()) { @@ -1503,25 +1542,43 @@ yyreduce: } break; - case 13: -#line 163 "grammar.y" + case 16: + +/* Line 1455 of yacc.c */ +#line 180 "grammar.y" { if(ctx->parent) - ctx->parent = ctx->parent->parent; + ctx->parent = ctx->parent->parent; } break; - case 18: -#line 178 "grammar.y" + case 21: + +/* Line 1455 of yacc.c */ +#line 194 "grammar.y" + { parsectx_append_string(ctx, (yyvsp[(1) - (1)].sval)); free((yyvsp[(1) - (1)].sval)); } + break; + + case 22: + +/* Line 1455 of yacc.c */ +#line 195 "grammar.y" + { parsectx_append_string(ctx, (yyvsp[(2) - (2)].sval)); free((yyvsp[(2) - (2)].sval)); } + break; + + case 23: + +/* Line 1455 of yacc.c */ +#line 200 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_bool_elem(ctx->parent, -1, (int)(yyvsp[(1) - (1)].ival)); - + if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1534,15 +1591,17 @@ yyreduce: } break; - case 19: -#line 198 "grammar.y" + case 24: + +/* Line 1455 of yacc.c */ +#line 220 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[(1) - (1)].ival)); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1559,15 +1618,17 @@ yyreduce: } break; - case 20: -#line 220 "grammar.y" + case 25: + +/* Line 1455 of yacc.c */ +#line 242 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[(1) - (1)].llval)); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1584,15 +1645,17 @@ yyreduce: } break; - case 21: -#line 242 "grammar.y" + case 26: + +/* Line 1455 of yacc.c */ +#line 264 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[(1) - (1)].ival)); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1609,15 +1672,17 @@ yyreduce: } break; - case 22: -#line 264 "grammar.y" + case 27: + +/* Line 1455 of yacc.c */ +#line 286 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[(1) - (1)].llval)); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1634,15 +1699,17 @@ yyreduce: } break; - case 23: -#line 286 "grammar.y" + case 28: + +/* Line 1455 of yacc.c */ +#line 308 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { config_setting_t *e = config_setting_set_float_elem(ctx->parent, -1, (yyvsp[(1) - (1)].fval)); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1655,18 +1722,20 @@ yyreduce: } break; - case 24: -#line 304 "grammar.y" + case 29: + +/* Line 1455 of yacc.c */ +#line 326 "grammar.y" { if(IN_ARRAY() || IN_LIST()) { - config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, - (yyvsp[(1) - (1)].sval)); - free((yyvsp[(1) - (1)].sval)); - + const char *s = parsectx_take_string(ctx); + config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, s); + _delete(s); + if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -1676,14 +1745,17 @@ yyreduce: } else { - config_setting_set_string(ctx->setting, (yyvsp[(1) - (1)].sval)); - free((yyvsp[(1) - (1)].sval)); + const char *s = parsectx_take_string(ctx); + config_setting_set_string(ctx->setting, s); + _delete(s); } } break; - case 33: -#line 351 "grammar.y" + case 38: + +/* Line 1455 of yacc.c */ +#line 374 "grammar.y" { if(IN_LIST()) { @@ -1699,8 +1771,10 @@ yyreduce: } break; - case 34: -#line 366 "grammar.y" + case 39: + +/* Line 1455 of yacc.c */ +#line 389 "grammar.y" { if(ctx->parent) ctx->parent = ctx->parent->parent; @@ -1708,8 +1782,9 @@ yyreduce: break; -/* Line 1267 of yacc.c. */ -#line 1713 "grammar.c" + +/* Line 1455 of yacc.c */ +#line 1788 "grammar.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1720,7 +1795,6 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1745,7 +1819,7 @@ yyerrlab: { ++yynerrs; #if ! YYERROR_VERBOSE - yyerror (scanner, ctx, YY_("syntax error")); + yyerror (scanner, ctx, scan_ctx, YY_("syntax error")); #else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); @@ -1769,11 +1843,11 @@ yyerrlab: if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (scanner, ctx, yymsg); + yyerror (scanner, ctx, scan_ctx, yymsg); } else { - yyerror (scanner, ctx, YY_("syntax error")); + yyerror (scanner, ctx, scan_ctx, YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } @@ -1785,7 +1859,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1797,12 +1871,12 @@ yyerrlab: else { yydestruct ("Error: discarding", - yytoken, &yylval, scanner, ctx); + yytoken, &yylval, scanner, ctx, scan_ctx); yychar = YYEMPTY; } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1853,15 +1927,12 @@ yyerrlab1: yydestruct ("Error: popping", - yystos[yystate], yyvsp, scanner, ctx); + yystos[yystate], yyvsp, scanner, ctx, scan_ctx); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; @@ -1886,20 +1957,20 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: - yyerror (scanner, ctx, YY_("memory exhausted")); + yyerror (scanner, ctx, scan_ctx, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, scanner, ctx); + yytoken, &yylval, scanner, ctx, scan_ctx); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -1907,7 +1978,7 @@ yyreturn: while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, scanner, ctx); + yystos[*yyssp], yyvsp, scanner, ctx, scan_ctx); YYPOPSTACK (1); } #ifndef yyoverflow @@ -1923,6 +1994,8 @@ yyreturn: } -#line 372 "grammar.y" + +/* Line 1675 of yacc.c */ +#line 395 "grammar.y" diff --git a/grammar.h b/lib/grammar.h index e3fd524..2ce199d 100644 --- a/grammar.h +++ b/lib/grammar.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton interface for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -56,8 +56,9 @@ TOK_COMMA = 272, TOK_GROUP_START = 273, TOK_GROUP_END = 274, - TOK_END = 275, - TOK_GARBAGE = 276 + TOK_SEMICOLON = 275, + TOK_GARBAGE = 276, + TOK_ERROR = 277 }; #endif /* Tokens. */ @@ -78,28 +79,35 @@ #define TOK_COMMA 272 #define TOK_GROUP_START 273 #define TOK_GROUP_END 274 -#define TOK_END 275 +#define TOK_SEMICOLON 275 #define TOK_GARBAGE 276 +#define TOK_ERROR 277 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 73 "grammar.y" { - long ival; + +/* Line 1676 of yacc.c */ +#line 85 "grammar.y" + + int ival; long long llval; double fval; char *sval; -} -/* Line 1489 of yacc.c. */ -#line 98 "grammar.h" - YYSTYPE; + + + +/* Line 1676 of yacc.c */ +#line 105 "grammar.h" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif + diff --git a/grammar.y b/lib/grammar.y index e484530..f578897 100644 --- a/grammar.y +++ b/lib/grammar.y @@ -1,20 +1,20 @@ /* -*- mode: C -*- */ /* ---------------------------------------------------------------------------- libconfig - A library for processing structured configuration files - Copyright (C) 2005-2008 Mark A Lindner - + Copyright (C) 2005-2010 Mark A Lindner + This file is part of libconfig. - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Library General Public License along with this library; if not, see <http://www.gnu.org/licenses/>. @@ -27,6 +27,7 @@ %lex-param{void *scanner} %parse-param{void *scanner} %parse-param{struct parse_context *ctx} +%parse-param{struct scan_context *scan_ctx} %{ #include <string.h> @@ -39,30 +40,41 @@ #ifndef _STDLIB_H #define _STDLIB_H #endif - + #include <malloc.h> #endif -#include "private.h" +#include "parsectx.h" +#include "scanctx.h" /* these delcarations 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)) #define IN_LIST() \ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_LIST)) -#define CAPTURE_PARSE_POS(S) \ - (S)->line = (unsigned int)libconfig_yyget_lineno(scanner) +static void capture_parse_pos(void *scanner, struct scan_context *scan_ctx, + config_setting_t *setting) +{ + setting->line = (unsigned int)libconfig_yyget_lineno(scanner); + setting->file = scanctx_current_filename(scan_ctx); +} + +#define CAPTURE_PARSE_POS(S) \ + capture_parse_pos(scanner, scan_ctx, (S)) void libconfig_yyerror(void *scanner, struct parse_context *ctx, - char const *s) + struct scan_context *scan_ctx, char const *s) { + if(ctx->config->error_text) return; ctx->config->error_line = libconfig_yyget_lineno(scanner); ctx->config->error_text = s; } @@ -71,7 +83,7 @@ void libconfig_yyerror(void *scanner, struct parse_context *ctx, %union { - long ival; + int ival; long long llval; double fval; char *sval; @@ -81,7 +93,7 @@ void libconfig_yyerror(void *scanner, struct parse_context *ctx, %token <llval> TOK_INTEGER64 TOK_HEX64 %token <fval> TOK_FLOAT %token <sval> TOK_STRING TOK_NAME -%token TOK_EQUALS TOK_NEWLINE TOK_ARRAY_START TOK_ARRAY_END TOK_LIST_START TOK_LIST_END TOK_COMMA TOK_GROUP_START TOK_GROUP_END TOK_END TOK_GARBAGE +%token TOK_EQUALS TOK_NEWLINE TOK_ARRAY_START TOK_ARRAY_END TOK_LIST_START TOK_LIST_END TOK_COMMA TOK_GROUP_START TOK_GROUP_END TOK_SEMICOLON TOK_GARBAGE TOK_ERROR %% @@ -100,15 +112,20 @@ setting_list_optional: | setting_list ; +setting_terminator: + /* empty */ + | TOK_SEMICOLON + | TOK_COMMA + ; + setting: TOK_NAME { ctx->setting = config_setting_add(ctx->parent, $1, CONFIG_TYPE_NONE); - free($1); - + if(ctx->setting == NULL) { - libconfig_yyerror(scanner, ctx, err_duplicate_setting); + libconfig_yyerror(scanner, ctx, scan_ctx, err_duplicate_setting); YYABORT; } else @@ -117,9 +134,9 @@ setting: } } - TOK_EQUALS value TOK_END + TOK_EQUALS value setting_terminator ; - + array: TOK_ARRAY_START { @@ -139,7 +156,7 @@ array: TOK_ARRAY_END { if(ctx->parent) - ctx->parent = ctx->parent->parent; + ctx->parent = ctx->parent->parent; } ; @@ -162,7 +179,7 @@ list: TOK_LIST_END { if(ctx->parent) - ctx->parent = ctx->parent->parent; + ctx->parent = ctx->parent->parent; } ; @@ -173,6 +190,11 @@ value: | group ; +string: + TOK_STRING { parsectx_append_string(ctx, $1); free($1); } + | string TOK_STRING { parsectx_append_string(ctx, $2); free($2); } + ; + simple_value: TOK_BOOLEAN { @@ -180,10 +202,10 @@ simple_value: { config_setting_t *e = config_setting_set_bool_elem(ctx->parent, -1, (int)$1); - + if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -201,7 +223,7 @@ simple_value: config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, $1); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -223,7 +245,7 @@ simple_value: config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, $1); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -245,7 +267,7 @@ simple_value: config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, $1); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -267,7 +289,7 @@ simple_value: config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, $1); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -289,7 +311,7 @@ simple_value: config_setting_t *e = config_setting_set_float_elem(ctx->parent, -1, $1); if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -300,17 +322,17 @@ simple_value: else config_setting_set_float(ctx->setting, $1); } - | TOK_STRING + | string { if(IN_ARRAY() || IN_LIST()) { - config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, - $1); - free($1); - + const char *s = parsectx_take_string(ctx); + config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, s); + _delete(s); + if(! e) { - libconfig_yyerror(scanner, ctx, err_array_elem_type); + libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type); YYABORT; } else @@ -320,8 +342,9 @@ simple_value: } else { - config_setting_set_string(ctx->setting, $1); - free($1); + const char *s = parsectx_take_string(ctx); + config_setting_set_string(ctx->setting, s); + _delete(s); } } ; diff --git a/libconfig++.pc.in b/lib/libconfig++.pc.in index 2771cc9..2771cc9 100644 --- a/libconfig++.pc.in +++ b/lib/libconfig++.pc.in diff --git a/libconfig++.vcproj b/lib/libconfig++.vcproj index 232849b..98464a7 100644 --- a/libconfig++.vcproj +++ b/lib/libconfig++.vcproj @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
+ Version="9.00"
Name="libconfig++"
ProjectGUID="{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}"
RootNamespace="libconfig_c"
Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
@@ -40,8 +41,8 @@ <Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="."
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBCONFIG_EXPORTS;YY_NO_UNISTD_H"
+ AdditionalIncludeDirectories="lib"
+ PreprocessorDefinitions="LIBCONFIGXX_EXPORTS;LIBCONFIG_STATIC;YY_NO_UNISTD_H;YY_USE_CONST;WIN32;_DEBUG;_WINDOWS;_USRDLL"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
/>
@@ -56,9 +57,12 @@ />
<Tool
Name="VCLinkerTool"
+ OutputFile="$(OutDir)\$(ProjectName)_d.dll"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -80,9 +84,6 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -111,8 +112,8 @@ />
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="."
- PreprocessorDefinitions="LIBCONFIG_EXPORTS;YY_NO_UNISTD_H;_CRT_SECURE_NO_DEPRECATE"
+ AdditionalIncludeDirectories="lib"
+ PreprocessorDefinitions="LIBCONFIGXX_EXPORTS;LIBCONFIG_STATIC;YY_NO_UNISTD_H;YY_USE_CONST;_CRT_SECURE_NO_DEPRECATE;_STDLIB_H"
RuntimeLibrary="2"
/>
<Tool
@@ -128,6 +129,8 @@ Name="VCLinkerTool"
OptimizeReferences="2"
EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
@@ -149,9 +152,6 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -177,9 +177,17 @@ >
</File>
<File
+ RelativePath=".\scanctx.c"
+ >
+ </File>
+ <File
RelativePath=".\scanner.c"
>
</File>
+ <File
+ RelativePath=".\strbuf.c"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
@@ -187,11 +195,7 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
- RelativePath=".\ac_config.h"
- >
- </File>
- <File
- RelativePath=".\config.tab.h"
+ RelativePath="..\ac_config.h"
>
</File>
<File
@@ -203,15 +207,15 @@ >
</File>
<File
- RelativePath=".\libconfig.h++"
+ RelativePath=".\libconfig.hh"
>
</File>
<File
- RelativePath=".\libconfig.hh"
+ RelativePath=".\parsectx.h"
>
</File>
<File
- RelativePath=".\private.h"
+ RelativePath=".\scanctx.h"
>
</File>
<File
@@ -219,6 +223,10 @@ >
</File>
<File
+ RelativePath=".\win32\stdint.h"
+ >
+ </File>
+ <File
RelativePath=".\wincompat.h"
>
</File>
diff --git a/libconfig.c b/lib/libconfig.c index c09921d..f301c8c 100644 --- a/libconfig.c +++ b/lib/libconfig.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- libconfig - A library for processing structured configuration files - Copyright (C) 2005-2009 Mark A Lindner + Copyright (C) 2005-2010 Mark A Lindner This file is part of libconfig. @@ -27,7 +27,8 @@ #include "libconfig.h" #include "grammar.h" #include "scanner.h" -#include "private.h" +#include "scanctx.h" +#include "parsectx.h" #include "wincompat.h" #include <locale.h> @@ -37,10 +38,11 @@ #endif #include <stdlib.h> +#include <string.h> #include <ctype.h> #define PATH_TOKENS ":./" -#define CHUNK_SIZE 10 +#define CHUNK_SIZE 16 #define FLOAT_PRECISION 10 #define _new(T) (T *)calloc(sizeof(T), 1) /* zeroed */ @@ -48,6 +50,7 @@ /* ------------------------------------------------------------------------- */ +#ifndef LIBCONFIG_STATIC #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) @@ -55,7 +58,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) return(TRUE); } -#endif +#endif /* WIN32 */ +#endif /* LIBCONFIG_STATIC */ /* ------------------------------------------------------------------------- */ @@ -63,13 +67,17 @@ static const char *__io_error = "file I/O error"; static void __config_list_destroy(config_list_t *list); static void __config_write_setting(const config_setting_t *setting, - FILE *stream, int depth); + FILE *stream, int depth, + unsigned short tab_width); -extern int libconfig_yyparse(void *scanner, struct parse_context *ctx); +extern int libconfig_yyparse(void *scanner, struct parse_context *ctx, + struct scan_context *scan_ctx); +extern int libconfig_yylex_init_extra(struct scan_context *scan_ctx, + yyscan_t *scanner); /* ------------------------------------------------------------------------- */ -static void __config_locale_override() +static void __config_locale_override(void) { #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ && ! defined(__MINGW32__) @@ -96,7 +104,7 @@ static void __config_locale_override() /* ------------------------------------------------------------------------- */ -static void __config_locale_restore() +static void __config_locale_restore(void) { #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ && ! defined(__MINGW32__) @@ -143,8 +151,23 @@ static int __config_name_compare(const char *a, const char *b) /* ------------------------------------------------------------------------- */ +static void __config_indent(FILE *stream, int depth, unsigned short w) +{ + if(w) + fprintf(stream, "%*s", (depth - 1) * w, " "); + else + { + int i; + for(i = 0; i < (depth - 1); ++i) + fputc('\t', stream); + } +} + +/* ------------------------------------------------------------------------- */ + static void __config_write_value(const config_value_t *value, int type, - int format, int depth, FILE *stream) + int format, int depth, + unsigned short tab_width, FILE *stream) { char fbuf[64]; @@ -160,12 +183,12 @@ static void __config_write_value(const config_value_t *value, int type, switch(format) { case CONFIG_FORMAT_HEX: - fprintf(stream, "0x%lX", value->ival); + fprintf(stream, "0x%X", value->ival); break; case CONFIG_FORMAT_DEFAULT: default: - fprintf(stream, "%ld", value->ival); + fprintf(stream, "%d", value->ival); break; } break; @@ -193,18 +216,15 @@ static void __config_write_value(const config_value_t *value, int type, snprintf(fbuf, sizeof(fbuf) - 3, "%.*g", FLOAT_PRECISION, value->fval); /* check for exponent */ - q = strchr(fbuf, 'e'); if(! q) { /* no exponent */ - if(! strchr(fbuf, '.')) /* no decimal point */ strcat(fbuf, ".0"); else { /* has decimal point */ - char *p; for(p = fbuf + strlen(fbuf) - 1; p > fbuf; --p) @@ -233,12 +253,13 @@ static void __config_write_value(const config_value_t *value, int type, { for(p = value->sval; *p; p++) { - switch(*p) + int c = (int)*p & 0xFF; + switch(c) { case '\"': case '\\': fputc('\\', stream); - fputc(*p, stream); + fputc(c, stream); break; case '\n': @@ -258,7 +279,10 @@ static void __config_write_value(const config_value_t *value, int type, break; default: - fputc(*p, stream); + if(c >= ' ') + fputc(c, stream); + else + fprintf(stream, "\\x%02X", c); } } } @@ -280,8 +304,9 @@ static void __config_write_value(const config_value_t *value, int type, for(s = list->elements; len--; s++) { - __config_write_value(&((*s)->value), (*s)->type, (*s)->format, - depth + 1, stream); + __config_write_value(&((*s)->value), (*s)->type, + config_setting_get_format(*s), + depth + 1, tab_width, stream); if(len) fputc(',', stream); @@ -308,8 +333,9 @@ static void __config_write_value(const config_value_t *value, int type, for(s = list->elements; len--; s++) { - __config_write_value(&((*s)->value), (*s)->type, (*s)->format, - depth + 1, stream); + __config_write_value(&((*s)->value), (*s)->type, + config_setting_get_format(*s), + depth + 1, tab_width, stream); if(len) fputc(',', stream); @@ -335,7 +361,7 @@ static void __config_write_value(const config_value_t *value, int type, fputc('\n', stream); if(depth > 1) - fprintf(stream, "%*s", (depth - 1) * 2, " "); + __config_indent(stream, depth, tab_width); #endif fprintf(stream, "{\n"); } @@ -346,11 +372,11 @@ static void __config_write_value(const config_value_t *value, int type, config_setting_t **s; for(s = list->elements; len--; s++) - __config_write_setting(*s, stream, depth + 1); + __config_write_setting(*s, stream, depth + 1, tab_width); } if(depth > 1) - fprintf(stream, "%*s", (depth - 1) * 2, " "); + __config_indent(stream, depth, tab_width); if(depth > 0) fputc('}', stream); @@ -369,11 +395,11 @@ static void __config_write_value(const config_value_t *value, int type, static void __config_list_add(config_list_t *list, config_setting_t *setting) { - if(list->length == list->capacity) + if((list->length % CHUNK_SIZE) == 0) { - list->capacity += CHUNK_SIZE; list->elements = (config_setting_t **)realloc( - list->elements, list->capacity * sizeof(config_setting_t *)); + list->elements, + (list->length + CHUNK_SIZE) * sizeof(config_setting_t *)); } list->elements[list->length] = setting; @@ -423,10 +449,7 @@ static config_setting_t *__config_list_remove(config_list_t *list, int idx) list->length--; - if((list->capacity - list->length) >= CHUNK_SIZE) - { - /* realloc smaller? */ - } + /* possibly realloc smaller? */ return(removed); } @@ -525,28 +548,64 @@ static int __config_validate_name(const char *name) /* ------------------------------------------------------------------------- */ -int config_read(config_t *config, FILE *stream) +static int __config_read(config_t *config, FILE *stream, const char *filename, + const char *str) { yyscan_t scanner; - struct parse_context ctx; + struct scan_context scan_ctx; + struct parse_context parse_ctx; + YY_BUFFER_STATE buffer = NULL; int r; - /* Reinitialize the config (keep the destructor) */ + /* Reinitialize the config */ void (*destructor)(void *) = config->destructor; + const char *include_dir = config->include_dir; + unsigned short tab_width = config->tab_width; + unsigned short flags = config->flags; + + config->include_dir = NULL; config_destroy(config); config_init(config); + config->destructor = destructor; + config->include_dir = include_dir; + config->tab_width = tab_width; + config->flags = flags; - ctx.config = config; - ctx.parent = config->root; - ctx.setting = config->root; + parsectx_init(&parse_ctx); + parse_ctx.config = config; + parse_ctx.parent = config->root; + parse_ctx.setting = config->root; __config_locale_override(); - libconfig_yylex_init(&scanner); - libconfig_yyrestart(stream, scanner); - r = libconfig_yyparse(scanner, &ctx); + scanctx_init(&scan_ctx, filename); + scan_ctx.config = config; + libconfig_yylex_init_extra(&scan_ctx, &scanner); + + if(stream) + libconfig_yyrestart(stream, scanner); + else /* read from string */ + buffer = libconfig_yy_scan_string(str, scanner); + + libconfig_yyset_lineno(1, scanner); + r = libconfig_yyparse(scanner, &parse_ctx, &scan_ctx); + + if(r != 0) + { + YY_BUFFER_STATE buf; + + config->error_file = scanctx_current_filename(&scan_ctx); + config->error_type = CONFIG_ERR_PARSE; + + /* Unwind the include stack, freeing the buffers and closing the files. */ + while((buf = (YY_BUFFER_STATE)scanctx_pop_include(&scan_ctx)) != NULL) + libconfig_yy_delete_buffer(buf, scanner); + } + libconfig_yylex_destroy(scanner); + config->filenames = scanctx_cleanup(&scan_ctx, &(config->num_filenames)); + parsectx_cleanup(&parse_ctx); __config_locale_restore(); @@ -555,11 +614,26 @@ int config_read(config_t *config, FILE *stream) /* ------------------------------------------------------------------------- */ +int config_read(config_t *config, FILE *stream) +{ + return(__config_read(config, stream, NULL, NULL)); +} + +/* ------------------------------------------------------------------------- */ + +int config_read_string(config_t *config, const char *str) +{ + return(__config_read(config, NULL, NULL, str)); +} + +/* ------------------------------------------------------------------------- */ + static void __config_write_setting(const config_setting_t *setting, - FILE *stream, int depth) + FILE *stream, int depth, + unsigned short tab_width) { if(depth > 1) - fprintf(stream, "%*s", (depth - 1) * 2, " "); + __config_indent(stream, depth, tab_width); if(setting->name) { @@ -567,8 +641,9 @@ static void __config_write_setting(const config_setting_t *setting, fprintf(stream, " %c ", (setting->type == CONFIG_TYPE_GROUP ? ':' : '=')); } - __config_write_value(&(setting->value), setting->type, setting->format, - depth, stream); + __config_write_value(&(setting->value), setting->type, + config_setting_get_format(setting), + depth, tab_width, stream); if(depth > 0) { @@ -583,7 +658,7 @@ void config_write(const config_t *config, FILE *stream) { __config_locale_override(); - __config_write_setting(config->root, stream, 0); + __config_write_setting(config->root, stream, 0, config->tab_width); __config_locale_restore(); } @@ -593,15 +668,17 @@ void config_write(const config_t *config, FILE *stream) int config_read_file(config_t *config, const char *filename) { int ret; - FILE *f = fopen(filename, "rt"); - if(! f) + FILE *stream = fopen(filename, "rt"); + if(! stream) { config->error_text = __io_error; + config->error_type = CONFIG_ERR_FILE_IO; return(CONFIG_FALSE); } - ret = config_read(config, f); - fclose(f); + ret = __config_read(config, stream, filename, NULL); + fclose(stream); + return(ret); } @@ -613,11 +690,13 @@ int config_write_file(config_t *config, const char *filename) if(! f) { config->error_text = __io_error; + config->error_type = CONFIG_ERR_FILE_IO; return(CONFIG_FALSE); } config_write(config, f); fclose(f); + config->error_type = CONFIG_ERR_NONE; return(CONFIG_TRUE); } @@ -625,8 +704,17 @@ int config_write_file(config_t *config, const char *filename) void config_destroy(config_t *config) { + unsigned int count = config->num_filenames; + const char **f; + __config_setting_destroy(config->root); + for(f = config->filenames; count > 0; ++f, --count) + _delete(*f); + + _delete(config->filenames); + _delete(config->include_dir); + memset((void *)config, 0, sizeof(config_t)); } @@ -639,6 +727,7 @@ void config_init(config_t *config) config->root = _new(config_setting_t); config->root->type = CONFIG_TYPE_GROUP; config->root->config = config; + config->tab_width = 2; } /* ------------------------------------------------------------------------- */ @@ -691,68 +780,94 @@ static config_setting_t *config_setting_create(config_setting_t *parent, /* ------------------------------------------------------------------------- */ -long config_setting_get_int(const config_setting_t *setting) +static int __config_setting_get_int(const config_setting_t *setting, + int *value) { switch(setting->type) { case CONFIG_TYPE_INT: - return(setting->value.ival); + *value = setting->value.ival; + return(CONFIG_TRUE); case CONFIG_TYPE_INT64: if((setting->value.llval > INT32_MAX) || (setting->value.llval < INT32_MIN)) - return(0); + *value = 0; else - return((long)setting->value.llval); + *value = (int)(setting->value.llval); + return(CONFIG_TRUE); case CONFIG_TYPE_FLOAT: if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0) - return((long)(setting->value.fval)); + { + *value = (int)(setting->value.fval); + return(CONFIG_TRUE); + } else - /* fall through */; + { /* fall through */ } default: - return(0); + return(CONFIG_FALSE); } } /* ------------------------------------------------------------------------- */ -long long config_setting_get_int64(const config_setting_t *setting) +int config_setting_get_int(const config_setting_t *setting) +{ + int value = 0; + __config_setting_get_int(setting, &value); + return(value); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_setting_get_int64(const config_setting_t *setting, + long long *value) { switch(setting->type) { case CONFIG_TYPE_INT64: - return(setting->value.llval); + *value = setting->value.llval; + return(CONFIG_TRUE); case CONFIG_TYPE_INT: - return((long long)setting->value.ival); + *value = (long long)(setting->value.ival); + return(CONFIG_TRUE); case CONFIG_TYPE_FLOAT: if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0) - return((long long)(setting->value.fval)); + { + *value = (long long)(setting->value.fval); + return(CONFIG_TRUE); + } else - /* fall through */; + { /* fall through */ } default: - return(0); + return(CONFIG_FALSE); } } /* ------------------------------------------------------------------------- */ +long long config_setting_get_int64(const config_setting_t *setting) +{ + long long value = 0; + __config_setting_get_int64(setting, &value); + return(value); +} + +/* ------------------------------------------------------------------------- */ + int config_setting_lookup_int(const config_setting_t *setting, - const char *name, long *value) + const char *name, int *value) { config_setting_t *member = config_setting_get_member(setting, name); if(! member) return(CONFIG_FALSE); - if(config_setting_type(member) != CONFIG_TYPE_INT) - return(CONFIG_FALSE); - - *value = config_setting_get_int(member); - return(CONFIG_TRUE); + return(__config_setting_get_int(member, value)); } /* ------------------------------------------------------------------------- */ @@ -764,11 +879,50 @@ int config_setting_lookup_int64(const config_setting_t *setting, if(! member) return(CONFIG_FALSE); - if(config_setting_type(member) != CONFIG_TYPE_INT64) - return(CONFIG_FALSE); + return(__config_setting_get_int64(member, value)); +} - *value = config_setting_get_int64(member); - return(CONFIG_TRUE); +/* ------------------------------------------------------------------------- */ + +static int __config_setting_get_float(const config_setting_t *setting, + double *value) +{ + switch(setting->type) + { + case CONFIG_TYPE_FLOAT: + *value = setting->value.fval; + return(CONFIG_TRUE); + + case CONFIG_TYPE_INT: + if(config_get_auto_convert(setting->config)) + { + *value = (double)(setting->value.ival); + return(CONFIG_TRUE); + } + else + return(CONFIG_FALSE); + + case CONFIG_TYPE_INT64: + if(config_get_auto_convert(setting->config)) + { + *value = (double)(setting->value.llval); + return(CONFIG_TRUE); + } + else + { /* fall through */ } + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +double config_setting_get_float(const config_setting_t *setting) +{ + double value = 0.0; + __config_setting_get_float(setting, &value); + return(value); } /* ------------------------------------------------------------------------- */ @@ -780,11 +934,7 @@ int config_setting_lookup_float(const config_setting_t *setting, if(! member) return(CONFIG_FALSE); - if(config_setting_type(member) != CONFIG_TYPE_FLOAT) - return(CONFIG_FALSE); - - *value = config_setting_get_float(member); - return(CONFIG_TRUE); + return(__config_setting_get_float(member, value)); } /* ------------------------------------------------------------------------- */ @@ -821,7 +971,7 @@ int config_setting_lookup_bool(const config_setting_t *setting, /* ------------------------------------------------------------------------- */ -int config_setting_set_int(config_setting_t *setting, long value) +int config_setting_set_int(config_setting_t *setting, int value) { switch(setting->type) { @@ -865,7 +1015,7 @@ int config_setting_set_int64(config_setting_t *setting, long long value) if((value > INT32_MAX) || (value < INT32_MIN)) setting->value.ival = 0; else - setting->value.ival = (long)value; + setting->value.ival = (int)value; return(CONFIG_TRUE); case CONFIG_TYPE_FLOAT: @@ -884,32 +1034,6 @@ int config_setting_set_int64(config_setting_t *setting, long long value) /* ------------------------------------------------------------------------- */ -double config_setting_get_float(const config_setting_t *setting) -{ - switch(setting->type) - { - case CONFIG_TYPE_FLOAT: - return(setting->value.fval); - - case CONFIG_TYPE_INT: - if(config_get_auto_convert(setting->config)) - return((double)(setting->value.ival)); - else - return(0.0); - - case CONFIG_TYPE_INT64: - if(config_get_auto_convert(setting->config)) - return((double)(setting->value.llval)); - else - return(0.0); - - default: - return(0.0); - } -} - -/* ------------------------------------------------------------------------- */ - int config_setting_set_float(config_setting_t *setting, double value) { switch(setting->type) @@ -925,7 +1049,7 @@ int config_setting_set_float(config_setting_t *setting, double value) case CONFIG_TYPE_INT: if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0) { - setting->value.ival = (long)value; + setting->value.ival = (int)value; return(CONFIG_TRUE); } else @@ -1004,17 +1128,19 @@ int config_setting_set_format(config_setting_t *setting, short format) /* ------------------------------------------------------------------------- */ -short config_setting_get_format(config_setting_t *setting) +short config_setting_get_format(const config_setting_t *setting) { - return(setting->format); + return(setting->format != 0 ? setting->format + : setting->config->default_format); } /* ------------------------------------------------------------------------- */ -config_setting_t *config_lookup(const config_t *config, const char *path) +config_setting_t *config_lookup_from(config_setting_t *setting, + const char *path) { const char *p = path; - config_setting_t *setting = config->root, *found; + config_setting_t *found; for(;;) { @@ -1043,6 +1169,13 @@ config_setting_t *config_lookup(const config_t *config, const char *path) /* ------------------------------------------------------------------------- */ +config_setting_t *config_lookup(const config_t *config, const char *path) +{ + return(config_lookup_from(config->root, path)); +} + +/* ------------------------------------------------------------------------- */ + int config_lookup_string(const config_t *config, const char *path, const char **value) { @@ -1061,18 +1194,13 @@ int config_lookup_string(const config_t *config, const char *path, /* ------------------------------------------------------------------------- */ int config_lookup_int(const config_t *config, const char *path, - long *value) + int *value) { const config_setting_t *s = config_lookup(config, path); if(! s) return(CONFIG_FALSE); - if(config_setting_type(s) != CONFIG_TYPE_INT) - return(CONFIG_FALSE); - - *value = config_setting_get_int(s); - - return(CONFIG_TRUE); + return(__config_setting_get_int(s, value)); } /* ------------------------------------------------------------------------- */ @@ -1084,12 +1212,7 @@ int config_lookup_int64(const config_t *config, const char *path, if(! s) return(CONFIG_FALSE); - if(config_setting_type(s) != CONFIG_TYPE_INT64) - return(CONFIG_FALSE); - - *value = config_setting_get_int64(s); - - return(CONFIG_TRUE); + return(__config_setting_get_int64(s, value)); } /* ------------------------------------------------------------------------- */ @@ -1101,11 +1224,7 @@ int config_lookup_float(const config_t *config, const char *path, if(! s) return(CONFIG_FALSE); - if(config_setting_type(s) != CONFIG_TYPE_FLOAT) - return(CONFIG_FALSE); - - *value = config_setting_get_float(s); - return(CONFIG_TRUE); + return(__config_setting_get_float(s, value)); } /* ------------------------------------------------------------------------- */ @@ -1125,7 +1244,7 @@ int config_lookup_bool(const config_t *config, const char *path, int *value) /* ------------------------------------------------------------------------- */ -long config_setting_get_int_elem(const config_setting_t *vector, int idx) +int config_setting_get_int_elem(const config_setting_t *vector, int idx) { const config_setting_t *element = config_setting_get_elem(vector, idx); @@ -1135,7 +1254,7 @@ long config_setting_get_int_elem(const config_setting_t *vector, int idx) /* ------------------------------------------------------------------------- */ config_setting_t *config_setting_set_int_elem(config_setting_t *vector, - int idx, long value) + int idx, int value) { config_setting_t *element = NULL; @@ -1369,6 +1488,14 @@ void config_set_destructor(config_t *config, void (*destructor)(void *)) /* ------------------------------------------------------------------------- */ +void config_set_include_dir(config_t *config, const char *include_dir) +{ + _delete(config->include_dir); + config->include_dir = strdup(include_dir); +} + +/* ------------------------------------------------------------------------- */ + int config_setting_length(const config_setting_t *setting) { if((setting->type != CONFIG_TYPE_GROUP) @@ -1476,7 +1603,7 @@ int config_setting_index(const config_setting_t *setting) list = setting->parent->value.list; - for(i = 0, found = list->elements; i < list->length; ++i, ++found) + for(i = 0, found = list->elements; i < (int)list->length; ++i, ++found) { if(*found == setting) return(i); diff --git a/libconfig.h b/lib/libconfig.h index cf6c67a..cc079db 100644 --- a/libconfig.h +++ b/lib/libconfig.h @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- libconfig - A library for processing structured configuration files - Copyright (C) 2005-2009 Mark A Lindner + Copyright (C) 2005-2010 Mark A Lindner This file is part of libconfig. @@ -39,6 +39,10 @@ extern "C" { #define LIBCONFIG_API #endif /* WIN32 */ +#define LIBCONFIG_VER_MAJOR 1 +#define LIBCONFIG_VER_MINOR 4 +#define LIBCONFIG_VER_REVISION 8 + #include <stdio.h> #define CONFIG_TYPE_NONE 0 @@ -61,7 +65,7 @@ extern "C" { typedef union config_value_t { - long ival; + int ival; long long llval; double fval; char *sval; @@ -78,12 +82,19 @@ typedef struct config_setting_t struct config_t *config; void *hook; unsigned int line; + const char *file; } config_setting_t; +typedef enum +{ + CONFIG_ERR_NONE = 0, + CONFIG_ERR_FILE_IO = 1, + CONFIG_ERR_PARSE = 2 +} config_error_t; + typedef struct config_list_t { unsigned int length; - unsigned int capacity; config_setting_t **elements; } config_list_t; @@ -91,17 +102,29 @@ typedef struct config_t { config_setting_t *root; void (*destructor)(void *); - int flags; + unsigned short flags; + unsigned short tab_width; + short default_format; + const char *include_dir; const char *error_text; + const char *error_file; int error_line; + config_error_t error_type; + const char **filenames; + unsigned int num_filenames; } config_t; extern LIBCONFIG_API int config_read(config_t *config, FILE *stream); extern LIBCONFIG_API void config_write(const config_t *config, FILE *stream); +extern LIBCONFIG_API void config_set_default_format(config_t *config, + short format); + extern LIBCONFIG_API void config_set_auto_convert(config_t *config, int flag); extern LIBCONFIG_API int config_get_auto_convert(const config_t *config); +extern LIBCONFIG_API int config_read_string(config_t *config, const char *str); + extern LIBCONFIG_API int config_read_file(config_t *config, const char *filename); extern LIBCONFIG_API int config_write_file(config_t *config, @@ -109,11 +132,13 @@ extern LIBCONFIG_API int config_write_file(config_t *config, extern LIBCONFIG_API void config_set_destructor(config_t *config, void (*destructor)(void *)); +extern LIBCONFIG_API void config_set_include_dir(config_t *config, + const char *include_dir); extern LIBCONFIG_API void config_init(config_t *config); extern LIBCONFIG_API void config_destroy(config_t *config); -extern LIBCONFIG_API long config_setting_get_int( +extern LIBCONFIG_API int config_setting_get_int( const config_setting_t *setting); extern LIBCONFIG_API long long config_setting_get_int64( const config_setting_t *setting); @@ -125,7 +150,7 @@ extern LIBCONFIG_API const char *config_setting_get_string( const config_setting_t *setting); extern LIBCONFIG_API int config_setting_lookup_int( - const config_setting_t *setting, const char *name, long *value); + const config_setting_t *setting, const char *name, int *value); extern LIBCONFIG_API int config_setting_lookup_int64( const config_setting_t *setting, const char *name, long long *value); extern LIBCONFIG_API int config_setting_lookup_float( @@ -136,7 +161,7 @@ extern LIBCONFIG_API int config_setting_lookup_string( const config_setting_t *setting, const char *name, const char **value); extern LIBCONFIG_API int config_setting_set_int(config_setting_t *setting, - long value); + int value); extern LIBCONFIG_API int config_setting_set_int64(config_setting_t *setting, long long value); extern LIBCONFIG_API int config_setting_set_float(config_setting_t *setting, @@ -148,9 +173,10 @@ extern LIBCONFIG_API int config_setting_set_string(config_setting_t *setting, extern LIBCONFIG_API int config_setting_set_format(config_setting_t *setting, short format); -extern LIBCONFIG_API short config_setting_get_format(config_setting_t *setting); +extern LIBCONFIG_API short config_setting_get_format( + const config_setting_t *setting); -extern LIBCONFIG_API long config_setting_get_int_elem( +extern LIBCONFIG_API int config_setting_get_int_elem( const config_setting_t *setting, int idx); extern LIBCONFIG_API long long config_setting_get_int64_elem( const config_setting_t *setting, int idx); @@ -162,7 +188,7 @@ extern LIBCONFIG_API const char *config_setting_get_string_elem( const config_setting_t *setting, int idx); extern LIBCONFIG_API config_setting_t *config_setting_set_int_elem( - config_setting_t *setting, int idx, long value); + config_setting_t *setting, int idx, int value); extern LIBCONFIG_API config_setting_t *config_setting_set_int64_elem( config_setting_t *setting, int idx, long long value); extern LIBCONFIG_API config_setting_t *config_setting_set_float_elem( @@ -172,6 +198,9 @@ extern LIBCONFIG_API config_setting_t *config_setting_set_bool_elem( extern LIBCONFIG_API config_setting_t *config_setting_set_string_elem( config_setting_t *setting, int idx, const char *value); +#define /* const char * */ config_get_include_dir(/* const config_t * */ C) \ + ((C)->include_dir) + #define /* int */ config_setting_type(/* const config_setting_t * */ S) \ ((S)->type) @@ -186,12 +215,12 @@ extern LIBCONFIG_API config_setting_t *config_setting_set_string_elem( /* const config_setting_t * */ S) \ (((S)->type == CONFIG_TYPE_GROUP) || ((S)->type == CONFIG_TYPE_LIST) \ || ((S)->type == CONFIG_TYPE_ARRAY)) - + #define /* int */ config_setting_is_number(/* const config_setting_t * */ S) \ (((S)->type == CONFIG_TYPE_INT) \ || ((S)->type == CONFIG_TYPE_INT64) \ || ((S)->type == CONFIG_TYPE_FLOAT)) - + #define /* int */ config_setting_is_scalar(/* const config_setting_t * */ S) \ (((S)->type == CONFIG_TYPE_BOOL) || ((S)->type == CONFIG_TYPE_STRING) \ || config_setting_is_number(S)) @@ -231,9 +260,11 @@ extern LIBCONFIG_API void config_setting_set_hook(config_setting_t *setting, extern LIBCONFIG_API config_setting_t *config_lookup(const config_t *config, const char *path); +extern LIBCONFIG_API config_setting_t *config_lookup_from( + config_setting_t *setting, const char *path); extern LIBCONFIG_API int config_lookup_int(const config_t *config, - const char *path, long *value); + const char *path, int *value); extern LIBCONFIG_API int config_lookup_int64(const config_t *config, const char *path, long long *value); @@ -249,16 +280,40 @@ extern LIBCONFIG_API int config_lookup_string(const config_t *config, /* const config_t * */ C) \ ((C)->root) -#define /* unsigned short */ config_setting_source_line( \ - /* const config_t */ C) \ - ((C)->line) +#define /* void */ config_set_default_format(/* config_t * */ C, \ + /* short */ F) \ + (C)->default_format = (F) + +#define /* short */ config_get_default_format(/* config_t * */ C) \ + ((C)->default_format) + +#define /* void */ config_set_tab_width(/* config_t * */ C, \ + /* unsigned short */ W) \ + (C)->tab_width = ((W) & 0x0F) + +#define /* unsigned char */ config_get_tab_width(/* const config_t * */ C) \ + ((C)->tab_width) + +#define /* unsigned short */ config_setting_source_line( \ + /* const config_setting_t * */ S) \ + ((S)->line) + +#define /* const char */ config_setting_source_file( \ + /* const config_setting_t * */ S) \ + ((S)->file) #define /* const char * */ config_error_text(/* const config_t * */ C) \ ((C)->error_text) +#define /* const char * */ config_error_file(/* const config_t * */ C) \ + ((C)->error_file) + #define /* int */ config_error_line(/* const config_t * */ C) \ ((C)->error_line) +#define /* config_error_t */ config_error_type(/* const config_t * */ C) \ + ((C)->error_type) + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lib/libconfig.h++ b/lib/libconfig.h++ new file mode 100644 index 0000000..dfc7939 --- /dev/null +++ b/lib/libconfig.h++ @@ -0,0 +1,459 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + <http://www.gnu.org/licenses/>. + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_hpp +#define __libconfig_hpp + +#include <stdio.h> +#include <exception> +#include <string> + +#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +#if defined(LIBCONFIGXX_STATIC) +#define LIBCONFIGXX_API +#elif defined(LIBCONFIGXX_EXPORTS) +#define LIBCONFIGXX_API __declspec(dllexport) +#else /* ! LIBCONFIGXX_EXPORTS */ +#define LIBCONFIGXX_API __declspec(dllimport) +#endif /* LIBCONFIGXX_STATIC */ +#else /* ! WIN32 */ +#define LIBCONFIGXX_API +#endif /* WIN32 */ + +#define LIBCONFIGXX_VER_MAJOR 1 +#define LIBCONFIGXX_VER_MINOR 4 +#define LIBCONFIGXX_VER_REVISION 8 + +struct config_t; // fwd decl +struct config_setting_t; // fwd decl + +namespace libconfig { + +class LIBCONFIGXX_API ConfigException : public std::exception { }; + +class Setting; // fwd decl + +class LIBCONFIGXX_API SettingException : public ConfigException +{ + friend class Config; + + public: + + SettingException(const SettingException &other); + SettingException& operator=(const SettingException &other); + + virtual ~SettingException() throw(); + + const char *getPath() const; + + virtual const char *what() const throw(); + + protected: + + SettingException(const Setting &setting); + SettingException(const Setting &setting, int idx); + SettingException(const Setting &setting, const char *name); + SettingException(const char *path); + + private: + + char *_path; +}; + +class LIBCONFIGXX_API SettingTypeException : public SettingException +{ + friend class Config; + friend class Setting; + + public: + + const char *what() const throw(); + + private: + + SettingTypeException(const Setting &setting); + SettingTypeException(const Setting &setting, int idx); + SettingTypeException(const Setting &setting, const char *name); +}; + +class LIBCONFIGXX_API SettingNotFoundException : public SettingException +{ + friend class Config; + friend class Setting; + + public: + + const char *what() const throw(); + + private: + + SettingNotFoundException(const Setting &setting, int idx); + SettingNotFoundException(const Setting &setting, const char *name); + SettingNotFoundException(const char *path); +}; + +class LIBCONFIGXX_API SettingNameException : public SettingException +{ + friend class Config; + friend class Setting; + + public: + + const char *what() const throw(); + + private: + + SettingNameException(const Setting &setting, const char *name); +}; + +class LIBCONFIGXX_API FileIOException : public ConfigException +{ + public: + + const char *what() const throw(); +}; + +class LIBCONFIGXX_API ParseException : public ConfigException +{ + friend class Config; + + public: + + ParseException(const ParseException &other); + + virtual ~ParseException() throw(); + + inline const char *getFile() const throw() + { return(_file); } + + inline int getLine() const throw() + { return(_line); } + + inline const char *getError() const throw() + { return(_error); } + + const char *what() const throw(); + + private: + + ParseException(const char *file, int line, const char *error); + + const char *_file; + int _line; + const char *_error; +}; + +class LIBCONFIGXX_API Setting +{ + friend class Config; + + public: + + enum Type + { + TypeNone = 0, + // scalar types + TypeInt, + TypeInt64, + TypeFloat, + TypeString, + TypeBoolean, + // aggregate types + TypeGroup, + TypeArray, + TypeList + }; + + enum Format + { + FormatDefault = 0, + FormatHex = 1 + }; + + private: + + config_setting_t *_setting; + Type _type; + Format _format; + + Setting(config_setting_t *setting); + + void assertType(Type type) const + throw(SettingTypeException); + static Setting & wrapSetting(config_setting_t *setting); + + Setting(const Setting& other); // not supported + Setting& operator=(const Setting& other); // not supported + + public: + + virtual ~Setting() throw(); + + inline Type getType() const throw() { return(_type); } + + inline Format getFormat() const throw() { return(_format); } + void setFormat(Format format) throw(); + + operator bool() const throw(SettingTypeException); + operator int() const throw(SettingTypeException); + operator unsigned int() const throw(SettingTypeException); + operator long() const throw(SettingTypeException); + operator unsigned long() const throw(SettingTypeException); + operator long long() const throw(SettingTypeException); + operator unsigned long long() const throw(SettingTypeException); + operator double() const throw(SettingTypeException); + operator float() const throw(SettingTypeException); + operator const char *() const throw(SettingTypeException); + operator std::string() const throw(SettingTypeException); + + inline const char *c_str() const throw(SettingTypeException) + { return operator const char*(); } + + Setting & operator=(bool value) throw(SettingTypeException); + Setting & operator=(int value) throw(SettingTypeException); + Setting & operator=(long value) throw(SettingTypeException); + Setting & operator=(const long long &value) throw(SettingTypeException); + Setting & operator=(const double &value) throw(SettingTypeException); + Setting & operator=(float value) throw(SettingTypeException); + Setting & operator=(const char *value) throw(SettingTypeException); + Setting & operator=(const std::string &value) throw(SettingTypeException); + + Setting & operator[](const char *key) const + throw(SettingTypeException, SettingNotFoundException); + + inline Setting & operator[](const std::string &key) const + throw(SettingTypeException, SettingNotFoundException) + { return(operator[](key.c_str())); } + + Setting & operator[](int index) const + throw(SettingTypeException, SettingNotFoundException); + + bool lookupValue(const char *name, bool &value) const throw(); + bool lookupValue(const char *name, int &value) const throw(); + bool lookupValue(const char *name, unsigned int &value) const throw(); + bool lookupValue(const char *name, long long &value) const throw(); + bool lookupValue(const char *name, unsigned long long &value) + const throw(); + bool lookupValue(const char *name, double &value) const throw(); + bool lookupValue(const char *name, float &value) const throw(); + bool lookupValue(const char *name, const char *&value) const throw(); + bool lookupValue(const char *name, std::string &value) const throw(); + + inline bool lookupValue(const std::string &name, bool &value) + const throw() + { return(lookupValue(name.c_str(), value)); } + + inline bool lookupValue(const std::string &name, int &value) + const throw() + { return(lookupValue(name.c_str(), value)); } + + inline bool lookupValue(const std::string &name, unsigned int &value) + const throw() + { return(lookupValue(name.c_str(), value)); } + + inline bool lookupValue(const std::string &name, long long &value) + const throw() + { return(lookupValue(name.c_str(), value)); } + + inline bool lookupValue(const std::string &name, + unsigned long long &value) const throw() + { return(lookupValue(name.c_str(), value)); } + + inline bool lookupValue(const std::string &name, double &value) const + throw() + { return(lookupValue(name.c_str(), value)); } + + inline bool lookupValue(const std::string &name, float &value) const + throw() + { return(lookupValue(name.c_str(), value)); } + + inline bool lookupValue(const std::string &name, const char *&value) const + throw() + { return(lookupValue(name.c_str(), value)); } + + inline bool lookupValue(const std::string &name, std::string &value) const + throw() + { return(lookupValue(name.c_str(), value)); } + + void remove(const char *name) + throw(SettingTypeException, SettingNotFoundException); + + inline void remove(const std::string & name) + throw(SettingTypeException, SettingNotFoundException) + { remove(name.c_str()); } + + void remove(unsigned int idx) + throw(SettingTypeException, SettingNotFoundException); + + inline Setting & add(const std::string & name, Type type) + throw(SettingNameException, SettingTypeException) + { return(add(name.c_str(), type)); } + + Setting & add(const char *name, Type type) + throw(SettingNameException, SettingTypeException); + + Setting & add(Type type) throw(SettingTypeException); + + inline bool exists(const std::string &name) const throw() + { return(exists(name.c_str())); } + + bool exists(const char *name) const throw(); + + int getLength() const throw(); + const char *getName() const throw(); + std::string getPath() const; + int getIndex() const throw(); + + const Setting & getParent() const throw(SettingNotFoundException); + Setting & getParent() throw(SettingNotFoundException); + + bool isRoot() const throw(); + + inline bool isGroup() const throw() + { return(_type == TypeGroup); } + + inline bool isArray() const throw() + { return(_type == TypeArray); } + + inline bool isList() const throw() + { return(_type == TypeList); } + + inline bool isAggregate() const throw() + { return(_type >= TypeGroup); } + + inline bool isScalar() const throw() + { return((_type > TypeNone) && (_type < TypeGroup)); } + + inline bool isNumber() const throw() + { return((_type == TypeInt) || (_type == TypeInt64) + || (_type == TypeFloat)); } + + unsigned int getSourceLine() const throw(); + const char *getSourceFile() const throw(); +}; + +class LIBCONFIGXX_API Config +{ + private: + + config_t *_config; + + static void ConfigDestructor(void *arg); + Config(const Config& other); // not supported + Config& operator=(const Config& other); // not supported + + public: + + Config(); + virtual ~Config(); + + void setAutoConvert(bool flag); + bool getAutoConvert() const; + + void setDefaultFormat(Setting::Format format); + inline Setting::Format getDefaultFormat() const + { return(_defaultFormat); } + + void setTabWidth(unsigned short width) throw(); + unsigned short getTabWidth() const throw(); + + void setIncludeDir(const char *includeDir) throw(); + const char *getIncludeDir() const throw(); + + void read(FILE *stream) throw(ParseException); + void write(FILE *stream) const; + + void readString(const char *str) throw(ParseException); + inline void readString(const std::string &str) throw(ParseException) + { return(readString(str.c_str())); } + + void readFile(const char *filename) throw(FileIOException, ParseException); + void writeFile(const char *filename) throw(FileIOException); + + inline Setting & lookup(const std::string &path) const + throw(SettingNotFoundException) + { return(lookup(path.c_str())); } + + Setting & lookup(const char *path) const throw(SettingNotFoundException); + + inline bool exists(const std::string & path) const throw() + { return(exists(path.c_str())); } + + bool exists(const char *path) const throw(); + + bool lookupValue(const char *path, bool &value) const throw(); + bool lookupValue(const char *path, int &value) const throw(); + bool lookupValue(const char *path, unsigned int &value) const throw(); + bool lookupValue(const char *path, long long &value) const throw(); + bool lookupValue(const char *path, unsigned long long &value) + const throw(); + bool lookupValue(const char *path, double &value) const throw(); + bool lookupValue(const char *path, float &value) const throw(); + bool lookupValue(const char *path, const char *&value) const throw(); + bool lookupValue(const char *path, std::string &value) const throw(); + + inline bool lookupValue(const std::string &path, bool &value) const throw() + { return(lookupValue(path.c_str(), value)); } + + inline bool lookupValue(const std::string &path, int &value) const throw() + { return(lookupValue(path.c_str(), value)); } + + inline bool lookupValue(const std::string &path, unsigned int &value) + const throw() + { return(lookupValue(path.c_str(), value)); } + + inline bool lookupValue(const std::string &path, long long &value) + const throw() + { return(lookupValue(path.c_str(), value)); } + + inline bool lookupValue(const std::string &path, + unsigned long long &value) const throw() + { return(lookupValue(path.c_str(), value)); } + + inline bool lookupValue(const std::string &path, double &value) + const throw() + { return(lookupValue(path.c_str(), value)); } + + inline bool lookupValue(const std::string &path, float &value) + const throw() + { return(lookupValue(path.c_str(), value)); } + + inline bool lookupValue(const std::string &path, const char *&value) + const throw() + { return(lookupValue(path.c_str(), value)); } + + inline bool lookupValue(const std::string &path, std::string &value) + const throw() + { return(lookupValue(path.c_str(), value)); } + + Setting & getRoot() const; + + private: + + Setting::Format _defaultFormat; + + void handleError() const; +}; + +} // namespace libconfig + +#endif // __libconfig_hpp diff --git a/libconfig.hh b/lib/libconfig.hh index 8b3b2d5..6883a31 100644 --- a/libconfig.hh +++ b/lib/libconfig.hh @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- libconfig - A structured configuration file parsing library - Copyright (C) 2005-2008 Mark A Lindner + Copyright (C) 2005-2010 Mark A Lindner This file is part of libconfig. diff --git a/libconfig.pc.in b/lib/libconfig.pc.in index 4f7628b..4f7628b 100644 --- a/libconfig.pc.in +++ b/lib/libconfig.pc.in diff --git a/libconfig.vcproj b/lib/libconfig.vcproj index 219f694..90a520e 100644 --- a/libconfig.vcproj +++ b/lib/libconfig.vcproj @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
+ Version="9.00"
Name="libconfig"
ProjectGUID="{1A234565-926D-49B2-83E4-D56E0C38C9F2}"
RootNamespace="libconfig"
+ TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
@@ -38,7 +39,7 @@ <Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBCONFIG_EXPORTS;YY_NO_UNISTD_H"
+ PreprocessorDefinitions="LIBCONFIG_EXPORTS;YY_NO_UNISTD_H;YY_USE_CONST;WIN32;_DEBUG;_WINDOWS;_USRDLL"
RuntimeLibrary="3"
CompileAs="1"
/>
@@ -53,9 +54,12 @@ />
<Tool
Name="VCLinkerTool"
+ OutputFile="$(OutDir)\$(ProjectName)_d.dll"
GenerateDebugInformation="true"
GenerateMapFile="true"
MapExports="true"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
@@ -76,9 +80,6 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -105,7 +106,7 @@ />
<Tool
Name="VCCLCompilerTool"
- PreprocessorDefinitions="LIBCONFIG_EXPORTS;YY_NO_UNISTD_H;_CRT_SECURE_NO_DEPRECATE"
+ PreprocessorDefinitions="LIBCONFIG_EXPORTS;YY_NO_UNISTD_H;YY_USE_CONST;_CRT_SECURE_NO_DEPRECATE;_STDLIB_H"
RuntimeLibrary="2"
CompileAs="1"
/>
@@ -120,6 +121,8 @@ />
<Tool
Name="VCLinkerTool"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
@@ -140,9 +143,6 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -164,9 +164,17 @@ >
</File>
<File
+ RelativePath=".\scanctx.c"
+ >
+ </File>
+ <File
RelativePath=".\scanner.c"
>
</File>
+ <File
+ RelativePath=".\strbuf.c"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
@@ -174,19 +182,19 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
- RelativePath=".\ac_config.h"
+ RelativePath="..\ac_config.h"
>
</File>
<File
- RelativePath=".\config.tab.h"
+ RelativePath=".\grammar.h"
>
</File>
<File
- RelativePath=".\grammar.h"
+ RelativePath=".\libconfig.h"
>
</File>
<File
- RelativePath=".\libconfig.h"
+ RelativePath=".\parsectx.h"
>
</File>
<File
@@ -194,7 +202,7 @@ >
</File>
<File
- RelativePath=".\resource.h"
+ RelativePath=".\scanctx.h"
>
</File>
<File
@@ -202,6 +210,10 @@ >
</File>
<File
+ RelativePath=".\win32\stdint.h"
+ >
+ </File>
+ <File
RelativePath=".\wincompat.h"
>
</File>
diff --git a/libconfigcpp.c++ b/lib/libconfigcpp.c++ index 82ad56e..846c067 100644 --- a/libconfigcpp.c++ +++ b/lib/libconfigcpp.c++ @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- libconfig - A library for processing structured configuration files - Copyright (C) 2005-2009 Mark A Lindner + Copyright (C) 2005-2010 Mark A Lindner This file is part of libconfig. @@ -27,17 +27,27 @@ #endif #include "wincompat.h" - -using namespace libconfig; +#include "libconfig.h" #include <cstring> #include <cstdlib> #include <sstream> +namespace libconfig { + +// --------------------------------------------------------------------------- + +ParseException::ParseException(const char *file, int line, const char *error) + : _file(file ? ::strdup(file) : NULL), _line(line), _error(error) +{ +} + // --------------------------------------------------------------------------- -ParseException::ParseException(int line, const char *error) - : _line(line), _error(error) +ParseException::ParseException(const ParseException &other) + : _file(other._file ? ::strdup(other._file) : NULL), + _line(other._line), + _error(other._error) { } @@ -45,6 +55,7 @@ ParseException::ParseException(int line, const char *error) ParseException::~ParseException() throw() { + ::free((void *)_file); } // --------------------------------------------------------------------------- @@ -290,46 +301,117 @@ void Config::ConfigDestructor(void *arg) // --------------------------------------------------------------------------- Config::Config() + : _defaultFormat(Setting::FormatDefault) { - config_init(& _config); - config_set_destructor(& _config, ConfigDestructor); + _config = new config_t; + config_init(_config); + config_set_destructor(_config, ConfigDestructor); } // --------------------------------------------------------------------------- Config::~Config() { - config_destroy(& _config); + config_destroy(_config); + delete _config; } // --------------------------------------------------------------------------- void Config::setAutoConvert(bool flag) { - config_set_auto_convert(& _config, (flag ? CONFIG_TRUE : CONFIG_FALSE)); + config_set_auto_convert(_config, (flag ? CONFIG_TRUE : CONFIG_FALSE)); } // --------------------------------------------------------------------------- bool Config::getAutoConvert() const { - return(config_get_auto_convert(& _config) != CONFIG_FALSE); + return(config_get_auto_convert(_config) != CONFIG_FALSE); +} + +// --------------------------------------------------------------------------- + +void Config::setDefaultFormat(Setting::Format format) +{ + if(format == Setting::FormatHex) + _defaultFormat = Setting::FormatHex; + else + _defaultFormat = Setting::FormatDefault; + + config_set_default_format(_config, static_cast<short>(_defaultFormat)); +} + +// --------------------------------------------------------------------------- + +void Config::setTabWidth(unsigned short width) throw() +{ + config_set_tab_width(_config, width); +} + +// --------------------------------------------------------------------------- + +unsigned short Config::getTabWidth() const throw() +{ + return(config_get_tab_width(_config)); +} + +// --------------------------------------------------------------------------- + +void Config::setIncludeDir(const char *includeDir) throw() +{ + config_set_include_dir(_config, includeDir); +} + +// --------------------------------------------------------------------------- + +const char *Config::getIncludeDir() const throw() +{ + return(config_get_include_dir(_config)); +} + +// --------------------------------------------------------------------------- + +void Config::handleError() const +{ + switch(config_error_type(_config)) + { + case CONFIG_ERR_NONE: + break; + + case CONFIG_ERR_PARSE: + throw ParseException(config_error_file(_config), + config_error_line(_config), + config_error_text(_config)); + break; + + case CONFIG_ERR_FILE_IO: + default: + throw FileIOException(); + } } // --------------------------------------------------------------------------- void Config::read(FILE *stream) throw(ParseException) { - if(! config_read(& _config, stream)) - throw ParseException(config_error_line(& _config), - config_error_text(& _config)); + if(! config_read(_config, stream)) + handleError(); +} + +// --------------------------------------------------------------------------- + +void Config::readString(const char *str) throw(ParseException) +{ + if(! config_read_string(_config, str)) + handleError(); } // --------------------------------------------------------------------------- void Config::write(FILE *stream) const { - config_write(& _config, stream); + config_write(_config, stream); } // --------------------------------------------------------------------------- @@ -337,27 +419,16 @@ void Config::write(FILE *stream) const void Config::readFile(const char *filename) throw(FileIOException, ParseException) { - FILE *f = fopen(filename, "rt"); - if(f == NULL) - throw FileIOException(); - try - { - read(f); - fclose(f); - } - catch(ParseException& p) - { - fclose(f); - throw p; - } + if(! config_read_file(_config, filename)) + handleError(); } // --------------------------------------------------------------------------- void Config::writeFile(const char *filename) throw(FileIOException) { - if(! config_write_file(& _config, filename)) - throw FileIOException(); + if(! config_write_file(_config, filename)) + handleError(); } // --------------------------------------------------------------------------- @@ -365,7 +436,7 @@ void Config::writeFile(const char *filename) throw(FileIOException) Setting & Config::lookup(const char *path) const throw(SettingNotFoundException) { - config_setting_t *s = config_lookup(& _config, path); + config_setting_t *s = config_lookup(_config, path); if(! s) throw SettingNotFoundException(path); @@ -376,7 +447,7 @@ Setting & Config::lookup(const char *path) const bool Config::exists(const char *path) const throw() { - config_setting_t *s = config_lookup(& _config, path); + config_setting_t *s = config_lookup(_config, path); return(s != NULL); } @@ -404,20 +475,6 @@ bool Config::lookupValue(const char *path, bool &value) const throw() // --------------------------------------------------------------------------- -bool Config::lookupValue(const char *path, long &value) const throw() -{ - CONFIG_LOOKUP_NO_EXCEPTIONS(path, long, value); -} - -// --------------------------------------------------------------------------- - -bool Config::lookupValue(const char *path, unsigned long &value) const throw() -{ - CONFIG_LOOKUP_NO_EXCEPTIONS(path, unsigned long, value); -} - -// --------------------------------------------------------------------------- - bool Config::lookupValue(const char *path, int &value) const throw() { CONFIG_LOOKUP_NO_EXCEPTIONS(path, int, value); @@ -477,7 +534,7 @@ bool Config::lookupValue(const char *path, std::string &value) const throw() Setting & Config::getRoot() const { - return(Setting::wrapSetting(config_root_setting(& _config))); + return(Setting::wrapSetting(config_root_setting(_config))); } // --------------------------------------------------------------------------- @@ -558,6 +615,8 @@ void Setting::setFormat(Format format) throw() } else _format = FormatDefault; + + config_setting_set_format(_setting, static_cast<short>(_format)); } // --------------------------------------------------------------------------- @@ -571,7 +630,7 @@ Setting::operator bool() const throw(SettingTypeException) // --------------------------------------------------------------------------- -Setting::operator long() const throw(SettingTypeException) +Setting::operator int() const throw(SettingTypeException) { assertType(TypeInt); @@ -580,40 +639,36 @@ Setting::operator long() const throw(SettingTypeException) // --------------------------------------------------------------------------- -Setting::operator unsigned long() const throw(SettingTypeException) +Setting::operator unsigned int() const throw(SettingTypeException) { assertType(TypeInt); - long v = config_setting_get_int(_setting); + int v = config_setting_get_int(_setting); if(v < 0) v = 0; - return(static_cast<unsigned long>(v)); + return(static_cast<unsigned int>(v)); } // --------------------------------------------------------------------------- -Setting::operator int() const throw(SettingTypeException) +Setting::operator long() const throw(SettingTypeException) { - assertType(TypeInt); - - // may cause loss of precision: - return(static_cast<int>(config_setting_get_int(_setting))); + if(sizeof(long) == sizeof(long long)) + return operator long long(); + else + return operator int(); } // --------------------------------------------------------------------------- -Setting::operator unsigned int() const throw(SettingTypeException) +Setting::operator unsigned long() const throw(SettingTypeException) { - assertType(TypeInt); - - long v = config_setting_get_int(_setting); - - if(v < 0) - v = 0; - - return(static_cast<unsigned int>(v)); + if(sizeof(long) == sizeof(long long)) + return operator unsigned long long(); + else + return operator unsigned int(); } // --------------------------------------------------------------------------- @@ -695,7 +750,7 @@ Setting & Setting::operator=(bool value) throw(SettingTypeException) // --------------------------------------------------------------------------- -Setting & Setting::operator=(long value) throw(SettingTypeException) +Setting & Setting::operator=(int value) throw(SettingTypeException) { assertType(TypeInt); @@ -706,15 +761,12 @@ Setting & Setting::operator=(long value) throw(SettingTypeException) // --------------------------------------------------------------------------- -Setting & Setting::operator=(int value) throw(SettingTypeException) +Setting & Setting::operator=(long value) throw(SettingTypeException) { - assertType(TypeInt); - - long cvalue = static_cast<long>(value); - - config_setting_set_int(_setting, cvalue); - - return(*this); + if(sizeof(long) == sizeof(long long)) + return(operator=(static_cast<long long>(value))); + else + return(operator=(static_cast<int>(value))); } // --------------------------------------------------------------------------- @@ -830,21 +882,6 @@ bool Setting::lookupValue(const char *name, bool &value) const throw() // --------------------------------------------------------------------------- -bool Setting::lookupValue(const char *name, long &value) const throw() -{ - SETTING_LOOKUP_NO_EXCEPTIONS(name, long, value); -} - -// --------------------------------------------------------------------------- - -bool Setting::lookupValue(const char *name, unsigned long &value) - const throw() -{ - SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned long, value); -} - -// --------------------------------------------------------------------------- - bool Setting::lookupValue(const char *name, int &value) const throw() { SETTING_LOOKUP_NO_EXCEPTIONS(name, int, value); @@ -852,7 +889,8 @@ bool Setting::lookupValue(const char *name, int &value) const throw() // --------------------------------------------------------------------------- -bool Setting::lookupValue(const char *name, unsigned int &value) const throw() +bool Setting::lookupValue(const char *name, unsigned int &value) + const throw() { SETTING_LOOKUP_NO_EXCEPTIONS(name, unsigned int, value); } @@ -963,6 +1001,20 @@ Setting & Setting::getParent() throw(SettingNotFoundException) // --------------------------------------------------------------------------- +unsigned int Setting::getSourceLine() const throw() +{ + return(config_setting_source_line(_setting)); +} + +// --------------------------------------------------------------------------- + +const char *Setting::getSourceFile() const throw() +{ + return(config_setting_source_file(_setting)); +} + +// --------------------------------------------------------------------------- + bool Setting::isRoot() const throw() { return(config_setting_is_root(_setting)); @@ -1037,8 +1089,8 @@ Setting & Setting::add(Setting::Type type) throw(SettingTypeException) } else { - if((type != TypeInt) && (type != TypeFloat) && (type != TypeString) - && (type != TypeBoolean)) + if((type != TypeInt) && (type != TypeInt64) && (type != TypeFloat) + && (type != TypeString) && (type != TypeBoolean)) throw SettingTypeException(*this, idx); } } @@ -1085,7 +1137,7 @@ void Setting::assertType(Setting::Type type) const throw(SettingTypeException) if(type != _type) { if(!(isNumber() && config_get_auto_convert(_setting->config) - && ((type == TypeInt) || (type == TypeFloat)))) + && ((type == TypeInt) || (type == TypeInt64) || (type == TypeFloat)))) throw SettingTypeException(*this); } } @@ -1109,4 +1161,7 @@ Setting & Setting::wrapSetting(config_setting_t *s) } // --------------------------------------------------------------------------- + +}; // namespace libconfig + // eof diff --git a/libconfigcpp.cc b/lib/libconfigcpp.cc index 3917ee7..9431146 100644 --- a/libconfigcpp.cc +++ b/lib/libconfigcpp.cc @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- libconfig - A structured configuration file parsing library - Copyright (C) 2005-2008 Mark A Lindner + Copyright (C) 2005-2010 Mark A Lindner This file is part of libconfig. diff --git a/lib/parsectx.h b/lib/parsectx.h new file mode 100644 index 0000000..af09b56 --- /dev/null +++ b/lib/parsectx.h @@ -0,0 +1,48 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + <http://www.gnu.org/licenses/>. + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_parsectx_h +#define __libconfig_parsectx_h + +#include "libconfig.h" +#include "strbuf.h" + +struct parse_context +{ + config_t *config; + config_setting_t *parent; + config_setting_t *setting; + char *name; + strbuf_t string; +}; + +#define parsectx_init(C) \ + memset((C), 0, sizeof(struct parse_context)) +#define parsectx_cleanup(C) \ + free((void *)(strbuf_release(&((C)->string)))) + +#define parsectx_append_string(C, S) \ + strbuf_append(&((C)->string), (S)) +#define parsectx_take_string(C) \ + strbuf_release(&((C)->string)) + +#endif /* __libconfig_parsectx_h */ diff --git a/lib/scanctx.c b/lib/scanctx.c new file mode 100644 index 0000000..f287fdf --- /dev/null +++ b/lib/scanctx.c @@ -0,0 +1,171 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + <http://www.gnu.org/licenses/>. + ---------------------------------------------------------------------------- +*/ + +#include "scanctx.h" +#include "wincompat.h" + +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#define STRING_BLOCK_SIZE 64 +#define CHUNK_SIZE 32 + +/* ------------------------------------------------------------------------- */ + +static const char *err_bad_include = "cannot open include file"; +static const char *err_include_too_deep = "include file nesting too deep"; + +/* ------------------------------------------------------------------------- */ + +static const char *__scanctx_add_filename(struct scan_context *ctx, + const char *filename) +{ + unsigned int count = ctx->num_filenames; + const char **f; + + for(f = ctx->filenames; count > 0; ++f, --count) + { + if(!strcmp(*f, filename)) + { + free((void *)filename); + return(*f); /* already in list */ + } + } + + if((ctx->num_filenames % CHUNK_SIZE) == 0) + { + ctx->filenames = (const char **)realloc( + (void *)ctx->filenames, + (ctx->num_filenames + CHUNK_SIZE) * sizeof(const char *)); + } + + ctx->filenames[ctx->num_filenames] = filename; + ++ctx->num_filenames; + return(filename); +} + +/* ------------------------------------------------------------------------- */ + +void scanctx_init(struct scan_context *ctx, const char *top_filename) +{ + memset(ctx, 0, sizeof(struct scan_context)); + if(top_filename) + ctx->top_filename = __scanctx_add_filename(ctx, strdup(top_filename)); +} + +/* ------------------------------------------------------------------------- */ + +const char **scanctx_cleanup(struct scan_context *ctx, + unsigned int *num_filenames) +{ + int i; + + for(i = 0; i < ctx->depth; ++i) + fclose(ctx->streams[i]); + + free((void *)(strbuf_release(&(ctx->string)))); + + *num_filenames = ctx->num_filenames; + return(ctx->filenames); +} + +/* ------------------------------------------------------------------------- */ + +FILE *scanctx_push_include(struct scan_context *ctx, void *buffer, + const char **error) +{ + FILE *fp = NULL; + const char *file; + char *full_file = NULL; + + *error = NULL; + + if(ctx->depth == MAX_INCLUDE_DEPTH) + { + *error = err_include_too_deep; + return(NULL); + } + + file = scanctx_take_string(ctx); + if(ctx->config->include_dir) + { + full_file = (char *)malloc(strlen(ctx->config->include_dir) + strlen(file) + + 2); + strcpy(full_file, ctx->config->include_dir); + strcat(full_file, FILE_SEPARATOR); + strcat(full_file, file); + } + + fp = fopen(full_file ? full_file : file, "rt"); + free((void *)full_file); + + if(fp) + { + ctx->streams[ctx->depth] = fp; + ctx->files[ctx->depth] = __scanctx_add_filename(ctx, file); + ctx->buffers[ctx->depth] = buffer; + ++(ctx->depth); + } + else + { + free((void *)file); + *error = err_bad_include; + } + + return(fp); +} + +/* ------------------------------------------------------------------------- */ + +void *scanctx_pop_include(struct scan_context *ctx) +{ + void *buffer; + + if(ctx->depth == 0) + return(NULL); /* stack underflow */ + + --(ctx->depth); + buffer = ctx->buffers[ctx->depth]; + fclose(ctx->streams[ctx->depth]); + + return(buffer); +} + +/* ------------------------------------------------------------------------- */ + +char *scanctx_take_string(struct scan_context *ctx) +{ + char *r = strbuf_release(&(ctx->string)); + + return(r ? r : strdup("")); +} + +/* ------------------------------------------------------------------------- */ + +const char *scanctx_current_filename(struct scan_context *ctx) +{ + return((ctx->depth == 0) ? ctx->top_filename : ctx->files[ctx->depth - 1]); +} + +/* ------------------------------------------------------------------------- */ +/* eof */ diff --git a/lib/scanctx.h b/lib/scanctx.h new file mode 100644 index 0000000..8ff934e --- /dev/null +++ b/lib/scanctx.h @@ -0,0 +1,62 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + <http://www.gnu.org/licenses/>. + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_scanctx_h +#define __libconfig_scanctx_h + +#include "libconfig.h" +#include "strbuf.h" + +#include <stdio.h> +#include <sys/types.h> + +#define MAX_INCLUDE_DEPTH 10 + +struct scan_context +{ + config_t *config; + const char *top_filename; + const char *files[MAX_INCLUDE_DEPTH]; + void *buffers[MAX_INCLUDE_DEPTH]; + FILE *streams[MAX_INCLUDE_DEPTH]; + int depth; + strbuf_t string; + const char **filenames; + unsigned int num_filenames; +}; + +extern void scanctx_init(struct scan_context *ctx, const char *top_filename); +extern const char **scanctx_cleanup(struct scan_context *ctx, + unsigned int *num_filenames); + +extern FILE *scanctx_push_include(struct scan_context *ctx, void *prev_buffer, + const char **error); +extern void *scanctx_pop_include(struct scan_context *ctx); + +#define scanctx_append_string(C, S) \ + strbuf_append(&((C)->string), (S)) + +extern char *scanctx_take_string(struct scan_context *ctx); + +extern const char *scanctx_current_filename(struct scan_context *ctx); + +#endif /* __libconfig_scanctx_h */ diff --git a/scanner.c b/lib/scanner.c index f903514..c2eb7d1 100644 --- a/scanner.c +++ b/lib/scanner.c @@ -54,7 +54,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -85,6 +84,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -158,7 +159,15 @@ typedef void* yyscan_t; /* 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. @@ -360,8 +369,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 26 -#define YY_END_OF_BUFFER 27 +#define YY_NUM_RULES 41 +#define YY_END_OF_BUFFER 42 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -369,39 +378,38 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[117] = +static yyconst flex_int16_t yy_accept[103] = { 0, - 0, 0, 0, 0, 27, 25, 5, 5, 25, 25, - 21, 22, 12, 25, 7, 13, 25, 14, 14, 6, - 23, 12, 12, 19, 20, 8, 9, 3, 4, 3, - 5, 0, 18, 0, 0, 24, 12, 13, 14, 13, - 0, 1, 0, 13, 0, 15, 0, 12, 12, 2, - 0, 0, 0, 0, 0, 13, 13, 0, 0, 13, - 15, 16, 12, 12, 0, 18, 0, 0, 0, 0, - 0, 13, 17, 12, 10, 0, 0, 17, 11, 0, - 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, - 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, - - 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, - 0, 18, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 42, 40, + 21, 20, 20, 5, 40, 36, 37, 28, 40, 23, + 29, 40, 30, 30, 22, 38, 28, 28, 34, 35, + 24, 25, 21, 40, 3, 4, 3, 6, 14, 41, + 16, 19, 41, 21, 0, 39, 28, 29, 30, 29, + 0, 1, 0, 29, 0, 31, 0, 28, 28, 21, + 0, 0, 2, 6, 12, 0, 11, 10, 7, 8, + 9, 16, 18, 17, 0, 29, 29, 0, 0, 29, + 31, 32, 28, 28, 0, 0, 0, 29, 33, 28, + 26, 0, 13, 33, 27, 0, 0, 0, 0, 0, + + 15, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 4, 5, 1, 1, 1, 1, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 16, 17, 1, - 18, 1, 1, 1, 19, 20, 20, 20, 21, 22, - 23, 23, 23, 23, 23, 24, 23, 23, 23, 23, - 23, 25, 26, 27, 28, 23, 23, 29, 23, 23, - 30, 31, 32, 1, 33, 1, 19, 20, 20, 20, - - 21, 22, 23, 23, 23, 23, 23, 34, 23, 23, - 23, 23, 23, 25, 26, 27, 28, 23, 23, 29, - 23, 23, 35, 1, 36, 1, 1, 1, 1, 1, + 1, 2, 1, 6, 7, 1, 1, 1, 1, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 18, 19, 1, + 20, 1, 1, 21, 22, 23, 23, 23, 24, 25, + 26, 26, 26, 26, 26, 27, 26, 26, 26, 26, + 26, 28, 29, 30, 31, 26, 26, 32, 26, 26, + 33, 34, 35, 1, 36, 1, 22, 23, 37, 38, + + 39, 40, 26, 26, 41, 26, 26, 42, 26, 43, + 26, 26, 26, 44, 29, 45, 46, 26, 26, 32, + 26, 26, 47, 1, 48, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -418,181 +426,119 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[37] = +static yyconst flex_int32_t yy_meta[49] = { 0, - 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, - 2, 1, 1, 3, 3, 1, 1, 1, 3, 3, - 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, - 1, 1, 2, 2, 1, 1 + 1, 1, 1, 1, 1, 2, 1, 1, 1, 3, + 1, 1, 3, 1, 1, 4, 4, 1, 1, 1, + 1, 4, 4, 4, 4, 3, 3, 3, 3, 3, + 3, 3, 1, 2, 1, 3, 4, 4, 4, 4, + 3, 3, 3, 3, 3, 3, 1, 1 } ; -static yyconst flex_int16_t yy_base[128] = +static yyconst flex_int16_t yy_base[113] = { 0, - 0, 0, 34, 35, 199, 503, 37, 42, 37, 195, - 503, 503, 0, 34, 503, 36, 39, 57, 41, 503, - 503, 163, 150, 503, 503, 503, 503, 503, 503, 152, - 56, 56, 71, 160, 151, 503, 0, 49, 68, 76, - 84, 503, 150, 86, 94, 128, 0, 43, 118, 503, - 108, 57, 125, 106, 101, 103, 108, 116, 118, 120, - 503, 102, 98, 99, 75, 134, 101, 99, 138, 88, - 130, 134, 70, 64, 0, 58, 142, 503, 0, 154, - 166, 156, 158, 164, 172, 202, 177, 170, 180, 181, - 178, 214, 244, 256, 286, 189, 220, 316, 328, 192, - - 206, 218, 231, 340, 262, 222, 264, 229, 352, 382, - 412, 442, 270, 294, 358, 503, 473, 476, 479, 481, - 51, 484, 487, 490, 493, 496, 499 + 0, 47, 47, 48, 46, 47, 48, 49, 203, 204, + 200, 204, 204, 204, 198, 204, 204, 0, 45, 204, + 47, 50, 60, 74, 204, 204, 178, 28, 204, 204, + 204, 204, 64, 158, 204, 204, 183, 0, 204, 63, + 0, 204, 83, 195, 193, 204, 0, 88, 102, 98, + 62, 204, 190, 104, 119, 162, 0, 67, 65, 121, + 127, 124, 204, 0, 204, 0, 204, 204, 204, 204, + 204, 0, 204, 204, 108, 117, 122, 134, 132, 136, + 204, 139, 136, 116, 126, 0, 140, 142, 135, 130, + 0, 102, 204, 204, 0, 85, 72, 63, 98, 158, + + 204, 204, 169, 173, 177, 181, 183, 187, 191, 89, + 66, 63 } ; -static yyconst flex_int16_t yy_def[128] = +static yyconst flex_int16_t yy_def[113] = { 0, - 116, 1, 117, 117, 116, 116, 116, 116, 118, 119, - 116, 116, 120, 116, 116, 116, 116, 116, 116, 116, - 116, 120, 120, 116, 116, 116, 116, 116, 116, 116, - 116, 118, 116, 118, 119, 116, 120, 116, 116, 116, - 116, 116, 119, 116, 116, 116, 121, 120, 120, 116, - 116, 122, 123, 116, 116, 116, 116, 116, 116, 116, - 116, 121, 120, 120, 122, 116, 122, 123, 116, 124, - 116, 116, 116, 120, 120, 124, 124, 116, 120, 124, - 124, 125, 126, 124, 125, 124, 125, 125, 126, 126, - 124, 125, 126, 125, 125, 127, 125, 126, 124, 127, - - 126, 126, 127, 126, 127, 127, 125, 126, 127, 127, - 125, 127, 127, 127, 127, 0, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116 + 102, 1, 103, 103, 104, 104, 105, 105, 102, 102, + 102, 102, 102, 102, 106, 102, 102, 107, 102, 102, + 102, 102, 102, 102, 102, 102, 107, 107, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 108, 102, 102, + 109, 102, 102, 102, 106, 102, 107, 102, 102, 102, + 102, 102, 106, 102, 102, 102, 110, 107, 107, 102, + 102, 102, 102, 108, 102, 111, 102, 102, 102, 102, + 102, 109, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 110, 107, 107, 102, 112, 102, 102, 102, 107, + 107, 102, 102, 102, 107, 102, 102, 102, 102, 102, + + 102, 0, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 } ; -static yyconst flex_int16_t yy_nxt[540] = +static yyconst flex_int16_t yy_nxt[253] = { 0, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 14, 16, 17, 18, 19, 20, 21, 20, 13, 13, - 13, 22, 13, 13, 13, 13, 23, 13, 13, 24, - 6, 25, 6, 13, 26, 27, 29, 29, 31, 31, - 33, 30, 30, 31, 31, 38, 42, 39, 39, 40, - 40, 43, 44, 62, 39, 39, 41, 31, 31, 33, - 66, 45, 40, 40, 46, 77, 63, 34, 44, 41, - 39, 39, 51, 51, 52, 53, 63, 45, 66, 44, - 46, 39, 39, 54, 79, 47, 34, 67, 45, 40, - 40, 46, 55, 78, 55, 77, 41, 56, 56, 57, - - 57, 69, 59, 116, 59, 67, 58, 60, 60, 51, - 51, 52, 53, 70, 56, 56, 56, 56, 53, 75, - 54, 57, 57, 74, 71, 73, 71, 69, 58, 72, - 72, 60, 60, 60, 60, 51, 51, 52, 53, 51, - 51, 52, 53, 72, 72, 64, 54, 72, 72, 77, - 54, 61, 36, 36, 80, 81, 81, 82, 83, 86, - 80, 77, 116, 87, 50, 90, 84, 81, 81, 82, - 83, 91, 76, 77, 49, 86, 83, 87, 84, 87, - 86, 48, 80, 80, 87, 77, 88, 90, 90, 92, - 80, 92, 104, 93, 92, 104, 105, 36, 116, 105, - - 116, 116, 88, 81, 81, 82, 83, 88, 80, 77, - 116, 116, 116, 90, 84, 94, 94, 95, 96, 106, - 80, 87, 106, 86, 80, 108, 97, 107, 116, 105, - 101, 80, 96, 92, 104, 116, 90, 116, 105, 116, - 116, 93, 116, 116, 88, 98, 99, 100, 101, 116, - 88, 90, 116, 116, 116, 116, 102, 94, 94, 95, - 96, 106, 116, 87, 92, 104, 116, 86, 97, 105, - 116, 87, 92, 104, 109, 116, 92, 105, 116, 116, - 116, 116, 116, 116, 116, 116, 88, 94, 94, 95, - 96, 116, 106, 87, 88, 116, 92, 104, 97, 116, - - 106, 115, 116, 116, 116, 116, 113, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 88, 98, 99, 100, - 101, 116, 116, 90, 106, 116, 116, 116, 102, 81, - 81, 82, 83, 116, 116, 77, 116, 116, 116, 116, - 84, 98, 99, 100, 101, 116, 116, 90, 116, 116, - 116, 116, 102, 110, 111, 112, 113, 116, 116, 105, - 92, 104, 116, 116, 114, 105, 116, 116, 116, 116, - 109, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 106, 110, 111, 112, 113, 116, 106, 105, - 116, 116, 116, 116, 114, 116, 116, 116, 116, 116, - - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 106, 94, 94, 95, 96, 116, 116, 87, - 116, 116, 116, 116, 97, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 88, 110, 111, 112, 113, 116, 116, 105, - 116, 116, 116, 116, 114, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 106, 28, 28, 28, 32, 32, 32, 35, - 35, 35, 37, 37, 65, 65, 65, 68, 68, 68, - 76, 76, 76, 85, 85, 85, 89, 89, 89, 103, - - 103, 103, 5, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116 + 10, 11, 12, 13, 13, 14, 15, 16, 17, 18, + 19, 20, 19, 21, 22, 23, 24, 25, 26, 25, + 10, 18, 18, 18, 27, 18, 18, 18, 18, 28, + 18, 18, 29, 10, 30, 10, 18, 18, 18, 27, + 18, 18, 18, 18, 28, 18, 31, 32, 33, 36, + 36, 39, 39, 42, 42, 59, 37, 37, 48, 52, + 49, 49, 50, 50, 53, 60, 93, 34, 65, 86, + 51, 59, 75, 54, 75, 49, 49, 76, 76, 40, + 40, 43, 43, 55, 61, 51, 56, 54, 73, 49, + 49, 57, 82, 83, 66, 84, 67, 55, 55, 100, + + 56, 99, 68, 50, 50, 69, 70, 71, 83, 98, + 84, 51, 55, 50, 50, 54, 74, 49, 49, 77, + 77, 51, 60, 76, 76, 55, 51, 78, 56, 79, + 97, 79, 76, 76, 80, 80, 51, 77, 77, 91, + 55, 61, 78, 96, 87, 78, 87, 80, 80, 88, + 88, 80, 80, 95, 91, 88, 88, 88, 88, 100, + 78, 94, 92, 101, 90, 89, 85, 62, 95, 35, + 35, 35, 35, 38, 38, 38, 38, 41, 41, 41, + 41, 45, 45, 45, 45, 47, 47, 64, 81, 64, + 64, 72, 46, 72, 72, 46, 44, 63, 62, 58, + + 46, 44, 102, 9, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 } ; -static yyconst flex_int16_t yy_chk[540] = +static yyconst flex_int16_t yy_chk[253] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 4, 7, 7, - 9, 3, 4, 8, 8, 14, 17, 14, 14, 16, - 16, 17, 19, 121, 19, 19, 16, 31, 31, 32, - 52, 19, 38, 38, 19, 76, 48, 9, 18, 38, - 18, 18, 33, 33, 33, 33, 48, 18, 65, 39, - 18, 39, 39, 33, 74, 18, 32, 52, 39, 40, - 40, 39, 41, 73, 41, 70, 40, 41, 41, 44, - - 44, 68, 45, 67, 45, 65, 44, 45, 45, 51, - 51, 51, 51, 54, 55, 55, 56, 56, 54, 64, - 51, 57, 57, 63, 58, 62, 58, 53, 57, 58, - 58, 59, 59, 60, 60, 66, 66, 66, 66, 69, - 69, 69, 69, 71, 71, 49, 66, 72, 72, 77, - 69, 46, 43, 35, 77, 80, 80, 80, 80, 82, - 83, 80, 34, 82, 30, 83, 80, 81, 81, 81, - 81, 84, 88, 81, 23, 85, 84, 88, 81, 85, - 87, 22, 89, 90, 87, 91, 82, 89, 90, 87, - 91, 96, 96, 90, 100, 100, 96, 10, 5, 100, - - 0, 0, 85, 86, 86, 86, 86, 87, 101, 86, - 0, 0, 0, 101, 86, 92, 92, 92, 92, 96, - 102, 92, 100, 97, 106, 102, 92, 97, 0, 106, - 102, 108, 97, 103, 103, 0, 108, 0, 103, 0, - 0, 108, 0, 0, 92, 93, 93, 93, 93, 0, - 97, 93, 0, 0, 0, 0, 93, 94, 94, 94, - 94, 103, 0, 94, 105, 105, 0, 107, 94, 105, - 0, 107, 113, 113, 105, 0, 107, 113, 0, 0, - 0, 0, 0, 0, 0, 0, 94, 95, 95, 95, - 95, 0, 105, 95, 107, 0, 114, 114, 95, 0, - - 113, 114, 0, 0, 0, 0, 114, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 95, 98, 98, 98, - 98, 0, 0, 98, 114, 0, 0, 0, 98, 99, - 99, 99, 99, 0, 0, 99, 0, 0, 0, 0, - 99, 104, 104, 104, 104, 0, 0, 104, 0, 0, - 0, 0, 104, 109, 109, 109, 109, 0, 0, 109, - 115, 115, 0, 0, 109, 115, 0, 0, 0, 0, - 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 109, 110, 110, 110, 110, 0, 115, 110, - 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 110, 111, 111, 111, 111, 0, 0, 111, - 0, 0, 0, 0, 111, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 111, 112, 112, 112, 112, 0, 0, 112, - 0, 0, 0, 0, 112, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 112, 117, 117, 117, 118, 118, 118, 119, - 119, 119, 120, 120, 122, 122, 122, 123, 123, 123, - 124, 124, 124, 125, 125, 125, 126, 126, 126, 127, - - 127, 127, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 116, 116, 116, 116, 116, 116 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 4, 5, 6, 7, 8, 28, 3, 4, 19, 22, + 19, 19, 21, 21, 22, 33, 112, 2, 40, 111, + 21, 28, 51, 23, 51, 23, 23, 51, 51, 5, + 6, 7, 8, 23, 33, 21, 23, 24, 43, 24, + 24, 23, 110, 58, 40, 59, 40, 24, 23, 99, + + 24, 98, 40, 48, 48, 40, 40, 40, 58, 97, + 59, 48, 24, 50, 50, 49, 43, 49, 49, 54, + 54, 50, 60, 75, 75, 49, 48, 54, 49, 55, + 96, 55, 76, 76, 55, 55, 50, 77, 77, 84, + 49, 60, 54, 92, 78, 77, 78, 79, 79, 78, + 78, 80, 80, 90, 84, 87, 87, 88, 88, 100, + 77, 89, 85, 100, 83, 82, 62, 61, 90, 103, + 103, 103, 103, 104, 104, 104, 104, 105, 105, 105, + 105, 106, 106, 106, 106, 107, 107, 108, 56, 108, + 108, 109, 53, 109, 109, 45, 44, 37, 34, 27, + + 15, 11, 9, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[27] = +static yyconst flex_int32_t yy_rule_can_match_eol[42] = { 0, -0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, }; +0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -605,7 +551,7 @@ static yyconst flex_int32_t yy_rule_can_match_eol[27] = /* -*- mode: C -*- */ /* -------------------------------------------------------------------------- libconfig - A library for processing structured configuration files - Copyright (C) 2005-2009 Mark A Lindner + Copyright (C) 2005-2010 Mark A Lindner This file is part of libconfig. @@ -624,10 +570,8 @@ static yyconst flex_int32_t yy_rule_can_match_eol[27] = <http://www.gnu.org/licenses/>. ---------------------------------------------------------------------------- */ -#line 25 "scanner.l" -#define YY_EXTRA_TYPE void* #define YY_NO_UNISTD_H 1 -#line 38 "scanner.l" +#line 35 "scanner.l" #ifdef _MSC_VER #pragma warning (disable: 4996) @@ -638,98 +582,18 @@ static yyconst flex_int32_t yy_rule_can_match_eol[27] = #include <string.h> #include "grammar.h" #include "wincompat.h" +#include "parsectx.h" +#include "scanctx.h" -/* this is somewhat kludgy, but I wanted to avoid building strings - dynamically during scanning */ - -static char *make_string(char *s) -{ - char *r = ++s; - char *p, *q = r; - size_t len = strlen(r); - int esc = 0; - - *(r + --len) = 0; - - for(p = r; *p; p++) - { - if(*p == '\\') - { - if(! esc) - { - esc = 1; - continue; - } - } - - if(esc) - { - if(*p == 'n') - *(q++) = '\n'; - else if(*p == 'r') - *(q++) = '\r'; - else if(*p == 'f') - *(q++) = '\f'; - else if(*p == 't') - *(q++) = '\t'; - else - *(q++) = *p; - - esc = 0; - } - - else if(*p == '\"') /* if we reached the end of a string segment, ... */ - { - /* This construction allows for C-style string concatenation. - We don't bother to check for end-of-string here, as we depend - on the {string} definition to ensure a new opening quote exists. - We do, however, check for and discard all forms of comments - [that is, (#...$|//...$|[/][*]...[*][/])] between string segments. */ - - while (*++p != '\"') /* ... look for the start of the next segment */ - { - if(*p == '#') /* check for #...$ comment */ - { - while(*++p != '\n') - { - /* skip the rest of the line */ - } - } - else if (*p == '/') - { - if(*++p == '/') /* check for //...$ comment */ - { - while (*++p != '\n') - { - /* skip the rest of the line */ - } - } - else /* must be '*', lead-in to an old C-style comment */ - { - while (*++p != '*' || *(p+1) != '/') - { - /* skip all comment content */ - } - ++p; /* step to the trailing slash, to skip it as well */ - } - } - } - } - else - *(q++) = *p; - } - - *q = 0; - - return(r); -} +#define YY_NO_INPUT // Suppress generation of useless input() function static unsigned long long fromhex(const char *s) { #ifdef __MINGW32__ - // MinGW's strtoull() seems to be broken; it only returns the lower - // 32 bits... + /* MinGW's strtoull() seems to be broken; it only returns the lower + * 32 bits... + */ const char *p = s; unsigned long long val = 0; @@ -750,18 +614,20 @@ static unsigned long long fromhex(const char *s) return(val); -#else // ! __MINGW32__ +#else /* ! __MINGW32__ */ return(strtoull(s, NULL, 16)); -#endif // __MINGW32__ +#endif /* __MINGW32__ */ } -#line 762 "scanner.c" +#line 626 "scanner.c" #define INITIAL 0 #define COMMENT 1 +#define STRING 2 +#define INCLUDE 3 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way @@ -771,9 +637,7 @@ static unsigned long long fromhex(const char *s) #include <unistd.h> #endif -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif +#define YY_EXTRA_TYPE struct scan_context * /* Holds the entire state of the reentrant scanner. */ struct yyguts_t @@ -886,7 +750,12 @@ static int input (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. */ @@ -894,7 +763,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( yytext, yyleng, 1, yyout ) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -905,7 +774,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -979,6 +848,9 @@ extern int libconfig_yylex \ #endif #define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION /** The main scanner function which does all the work. @@ -990,10 +862,10 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 194 "scanner.l" +#line 100 "scanner.l" -#line 997 "scanner.c" +#line 869 "scanner.c" yylval = yylval_param; @@ -1036,6 +908,7 @@ YY_DECL yy_bp = yy_cp; yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); yy_match: do { @@ -1048,13 +921,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 117 ) + if ( yy_current_state >= 103 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 503 ); + while ( yy_base[yy_current_state] != 204 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -1092,144 +965,265 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 196 "scanner.l" +#line 102 "scanner.l" { BEGIN COMMENT; } YY_BREAK case 2: YY_RULE_SETUP -#line 197 "scanner.l" +#line 103 "scanner.l" { BEGIN INITIAL; } YY_BREAK case 3: YY_RULE_SETUP -#line 198 "scanner.l" +#line 104 "scanner.l" { /* ignore */ } YY_BREAK case 4: /* rule 4 can match eol */ YY_RULE_SETUP -#line 199 "scanner.l" -{ } +#line 105 "scanner.l" +{ /* ignore */ } YY_BREAK case 5: -/* rule 5 can match eol */ YY_RULE_SETUP -#line 201 "scanner.l" -{ /* skip */ } +#line 107 "scanner.l" +{ BEGIN STRING; } YY_BREAK case 6: +/* rule 6 can match eol */ YY_RULE_SETUP -#line 203 "scanner.l" -{ return(TOK_EQUALS); } +#line 108 "scanner.l" +{ scanctx_append_string(yyextra, yytext); } YY_BREAK case 7: YY_RULE_SETUP -#line 204 "scanner.l" -{ return(TOK_COMMA); } +#line 109 "scanner.l" +{ scanctx_append_string(yyextra, "\n"); } YY_BREAK case 8: YY_RULE_SETUP -#line 205 "scanner.l" -{ return(TOK_GROUP_START); } +#line 110 "scanner.l" +{ scanctx_append_string(yyextra, "\r"); } YY_BREAK case 9: YY_RULE_SETUP -#line 206 "scanner.l" -{ return(TOK_GROUP_END); } +#line 111 "scanner.l" +{ scanctx_append_string(yyextra, "\t"); } YY_BREAK case 10: YY_RULE_SETUP -#line 207 "scanner.l" -{ yylval->ival = 1; return(TOK_BOOLEAN); } +#line 112 "scanner.l" +{ scanctx_append_string(yyextra, "\f"); } YY_BREAK case 11: YY_RULE_SETUP -#line 208 "scanner.l" -{ yylval->ival = 0; return(TOK_BOOLEAN); } +#line 113 "scanner.l" +{ scanctx_append_string(yyextra, "\\"); } YY_BREAK case 12: YY_RULE_SETUP -#line 209 "scanner.l" -{ yylval->sval = strdup(yytext); return(TOK_NAME); } +#line 114 "scanner.l" +{ scanctx_append_string(yyextra, "\""); } YY_BREAK case 13: YY_RULE_SETUP -#line 210 "scanner.l" -{ yylval->fval = atof(yytext); return(TOK_FLOAT); } +#line 115 "scanner.l" +{ + char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF), + 0 }; + scanctx_append_string(yyextra, c); + } YY_BREAK case 14: YY_RULE_SETUP -#line 211 "scanner.l" -{ yylval->ival = atoi(yytext); return(TOK_INTEGER); } +#line 120 "scanner.l" +{ + yylval->sval = scanctx_take_string(yyextra); + BEGIN INITIAL; + return(TOK_STRING); + } YY_BREAK case 15: YY_RULE_SETUP -#line 212 "scanner.l" -{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); } +#line 126 "scanner.l" +{ BEGIN INCLUDE; } YY_BREAK case 16: +/* rule 16 can match eol */ YY_RULE_SETUP -#line 213 "scanner.l" -{ yylval->ival = strtoul(yytext, NULL, 16); return(TOK_HEX); } +#line 127 "scanner.l" +{ scanctx_append_string(yyextra, yytext); } YY_BREAK case 17: YY_RULE_SETUP -#line 214 "scanner.l" -{ yylval->llval = fromhex(yytext); return(TOK_HEX64); } +#line 128 "scanner.l" +{ scanctx_append_string(yyextra, "\\"); } YY_BREAK case 18: -/* rule 18 can match eol */ YY_RULE_SETUP -#line 215 "scanner.l" -{ yylval->sval = strdup(make_string(yytext)); return(TOK_STRING); } +#line 129 "scanner.l" +{ scanctx_append_string(yyextra, "\""); } YY_BREAK case 19: YY_RULE_SETUP -#line 216 "scanner.l" -{ return(TOK_ARRAY_START); } +#line 130 "scanner.l" +{ + const char *error; + FILE *fp = scanctx_push_include(yyextra, + (void *)YY_CURRENT_BUFFER, + &error); + if(fp) + { + yyin = fp; + libconfig_yy_switch_to_buffer(libconfig_yy_create_buffer(yyin,YY_BUF_SIZE,yyscanner),yyscanner); + } + else + { + yyextra->config->error_text = error; + yyextra->config->error_file = scanctx_current_filename( + yyextra); + yyextra->config->error_line = libconfig_yyget_lineno( + yyscanner); + return TOK_ERROR; + } + BEGIN INITIAL; + } YY_BREAK case 20: +/* rule 20 can match eol */ YY_RULE_SETUP -#line 217 "scanner.l" -{ return(TOK_ARRAY_END); } +#line 154 "scanner.l" +{ /* ignore */ } YY_BREAK case 21: YY_RULE_SETUP -#line 218 "scanner.l" -{ return(TOK_LIST_START); } +#line 155 "scanner.l" +{ /* ignore */ } YY_BREAK case 22: YY_RULE_SETUP -#line 219 "scanner.l" -{ return(TOK_LIST_END); } +#line 157 "scanner.l" +{ return(TOK_EQUALS); } YY_BREAK case 23: YY_RULE_SETUP -#line 220 "scanner.l" -{ return(TOK_END); } +#line 158 "scanner.l" +{ return(TOK_COMMA); } YY_BREAK case 24: +YY_RULE_SETUP +#line 159 "scanner.l" +{ return(TOK_GROUP_START); } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 160 "scanner.l" +{ return(TOK_GROUP_END); } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 161 "scanner.l" +{ yylval->ival = 1; return(TOK_BOOLEAN); } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 162 "scanner.l" +{ yylval->ival = 0; return(TOK_BOOLEAN); } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 163 "scanner.l" +{ yylval->sval = yytext; return(TOK_NAME); } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 164 "scanner.l" +{ yylval->fval = atof(yytext); return(TOK_FLOAT); } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 165 "scanner.l" +{ yylval->ival = atoi(yytext); return(TOK_INTEGER); } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 166 "scanner.l" +{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 167 "scanner.l" +{ + yylval->ival = strtoul(yytext, NULL, 16); + return(TOK_HEX); + } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 171 "scanner.l" +{ yylval->llval = fromhex(yytext); return(TOK_HEX64); } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 172 "scanner.l" +{ return(TOK_ARRAY_START); } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 173 "scanner.l" +{ return(TOK_ARRAY_END); } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 174 "scanner.l" +{ return(TOK_LIST_START); } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 175 "scanner.l" +{ return(TOK_LIST_END); } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 176 "scanner.l" +{ return(TOK_SEMICOLON); } + YY_BREAK +case 39: *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */ yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 221 "scanner.l" +#line 177 "scanner.l" { /* ignore */ } YY_BREAK -case 25: +case 40: YY_RULE_SETUP -#line 222 "scanner.l" +#line 178 "scanner.l" { return(TOK_GARBAGE); } YY_BREAK -case 26: +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMENT): +case YY_STATE_EOF(STRING): +case YY_STATE_EOF(INCLUDE): +#line 180 "scanner.l" +{ + YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include( + yyextra); + if(buf) + { + libconfig_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner); + libconfig_yy_switch_to_buffer(buf,yyscanner); + } + else + yyterminate(); + } + YY_BREAK +case 41: YY_RULE_SETUP -#line 223 "scanner.l" +#line 191 "scanner.l" ECHO; YY_BREAK -#line 1230 "scanner.c" -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(COMMENT): - yyterminate(); +#line 1227 "scanner.c" case YY_END_OF_BUFFER: { @@ -1509,6 +1503,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { @@ -1521,7 +1516,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 117 ) + if ( yy_current_state >= 103 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1550,11 +1545,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 117 ) + if ( yy_current_state >= 103 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 116); + yy_is_jam = (yy_current_state == 102); return yy_is_jam ? 0 : yy_current_state; } @@ -1630,7 +1625,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner) *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ yyg->yy_hold_char = *++yyg->yy_c_buf_p; - if ( c == '\n' ) + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) do{ yylineno++; yycolumn=0; @@ -1968,8 +1964,8 @@ YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char * yystr , yyscan_t yyscan /** Setup the input buffer state to scan the given bytes. The next call to libconfig_yylex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -2363,4 +2359,4 @@ void libconfig_yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 223 "scanner.l" +#line 191 "scanner.l" diff --git a/scanner.h b/lib/scanner.h index baa6f77..baa6f77 100644 --- a/scanner.h +++ b/lib/scanner.h diff --git a/lib/scanner.l b/lib/scanner.l new file mode 100644 index 0000000..2703eb6 --- /dev/null +++ b/lib/scanner.l @@ -0,0 +1,190 @@ +/* -*- mode: C -*- */ +/* -------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + <http://www.gnu.org/licenses/>. + ---------------------------------------------------------------------------- +*/ + +%option nounistd +%option reentrant +%option noyywrap +%option yylineno +%option nounput +%option bison-bridge +%option header-file="scanner.h" +%option outfile="lex.yy.c" +%option extra-type="struct scan_context *" + +%{ + +#ifdef _MSC_VER +#pragma warning (disable: 4996) +#endif + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> +#include "grammar.h" +#include "wincompat.h" +#include "parsectx.h" +#include "scanctx.h" + +#define YY_NO_INPUT // Suppress generation of useless input() function + +static unsigned long long fromhex(const char *s) +{ +#ifdef __MINGW32__ + + /* MinGW's strtoull() seems to be broken; it only returns the lower + * 32 bits... + */ + + const char *p = s; + unsigned long long val = 0; + + if(*p != '0') + return(0); + + ++p; + + if(*p != 'x' && *p != 'X') + return(0); + + for(++p; isxdigit(*p); ++p) + { + val <<= 4; + val |= ((*p < 'A') ? (*p & 0xF) : (9 + (*p & 0x7))); + } + + return(val); + +#else /* ! __MINGW32__ */ + + return(strtoull(s, NULL, 16)); + +#endif /* __MINGW32__ */ +} + +%} + +true [Tt][Rr][Uu][Ee] +false [Ff][Aa][Ll][Ss][Ee] +name [A-Za-z\*][-A-Za-z0-9_\*]* +integer [-+]?[0-9]+ +integer64 [-+]?[0-9]+L(L)? +hex 0[Xx][0-9A-Fa-f]+ +hex64 0[Xx][0-9A-Fa-f]+L(L)? +hexchar \\[Xx][0-9A-Fa-f]{2} +float ([-+]?([0-9]*)?\.[0-9]*([eE][-+]?[0-9]+)?)|([-+]?([0-9]+)(\.[0-9]*)?[eE][-+]?[0-9]+) +comment (#|\/\/).*$ +include_open ^[ \t]*@include[ \t]+\" + +%x COMMENT STRING INCLUDE + +%% + +\/\* { BEGIN COMMENT; } +<COMMENT>\*\/ { BEGIN INITIAL; } +<COMMENT>. { /* ignore */ } +<COMMENT>\n { /* ignore */ } + +\" { BEGIN STRING; } +<STRING>[^\"\\]+ { scanctx_append_string(yyextra, yytext); } +<STRING>\\n { scanctx_append_string(yyextra, "\n"); } +<STRING>\\r { scanctx_append_string(yyextra, "\r"); } +<STRING>\\t { scanctx_append_string(yyextra, "\t"); } +<STRING>\\f { scanctx_append_string(yyextra, "\f"); } +<STRING>\\\\ { scanctx_append_string(yyextra, "\\"); } +<STRING>\\\" { scanctx_append_string(yyextra, "\""); } +<STRING>{hexchar} { + char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF), + 0 }; + scanctx_append_string(yyextra, c); + } +<STRING>\" { + yylval->sval = scanctx_take_string(yyextra); + BEGIN INITIAL; + return(TOK_STRING); + } + +{include_open} { BEGIN INCLUDE; } +<INCLUDE>[^\"\\]+ { scanctx_append_string(yyextra, yytext); } +<INCLUDE>\\\\ { scanctx_append_string(yyextra, "\\"); } +<INCLUDE>\\\" { scanctx_append_string(yyextra, "\""); } +<INCLUDE>\" { + const char *error; + FILE *fp = scanctx_push_include(yyextra, + (void *)YY_CURRENT_BUFFER, + &error); + if(fp) + { + yyin = fp; + yy_switch_to_buffer( + yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner), + yyscanner); + } + else + { + yyextra->config->error_text = error; + yyextra->config->error_file = scanctx_current_filename( + yyextra); + yyextra->config->error_line = libconfig_yyget_lineno( + yyscanner); + return TOK_ERROR; + } + BEGIN INITIAL; + } + +\n|\r|\f { /* ignore */ } +[ \t]+ { /* ignore */ } + +\=|\: { return(TOK_EQUALS); } +, { return(TOK_COMMA); } +\{ { return(TOK_GROUP_START); } +\} { return(TOK_GROUP_END); } +{true} { yylval->ival = 1; return(TOK_BOOLEAN); } +{false} { yylval->ival = 0; return(TOK_BOOLEAN); } +{name} { yylval->sval = yytext; return(TOK_NAME); } +{float} { yylval->fval = atof(yytext); return(TOK_FLOAT); } +{integer} { yylval->ival = atoi(yytext); return(TOK_INTEGER); } +{integer64} { yylval->llval = atoll(yytext); return(TOK_INTEGER64); } +{hex} { + yylval->ival = strtoul(yytext, NULL, 16); + return(TOK_HEX); + } +{hex64} { yylval->llval = fromhex(yytext); return(TOK_HEX64); } +\[ { return(TOK_ARRAY_START); } +\] { return(TOK_ARRAY_END); } +\( { return(TOK_LIST_START); } +\) { return(TOK_LIST_END); } +; { return(TOK_SEMICOLON); } +{comment} { /* ignore */ } +. { return(TOK_GARBAGE); } + +<<EOF>> { + YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include( + yyextra); + if(buf) + { + yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner); + yy_switch_to_buffer(buf, yyscanner); + } + else + yyterminate(); + } diff --git a/lib/strbuf.c b/lib/strbuf.c new file mode 100644 index 0000000..f7f48d3 --- /dev/null +++ b/lib/strbuf.c @@ -0,0 +1,58 @@ +/* ---------------------------------------------------------------------------- + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + + This file is part of libconfig. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + <http://www.gnu.org/licenses/>. + ---------------------------------------------------------------------------- +*/ + +#include "strbuf.h" + +#include <string.h> +#include <stdlib.h> + +#define STRING_BLOCK_SIZE 64 + +/* ------------------------------------------------------------------------- */ + +char *strbuf_release(strbuf_t *buf) +{ + char *r = buf->string; + memset(buf, 0, sizeof(strbuf_t)); + return(r); +} + +/* ------------------------------------------------------------------------- */ + +void strbuf_append(strbuf_t *buf, const char *text) +{ + static const size_t mask = ~(STRING_BLOCK_SIZE - 1); + size_t len = strlen(text); + size_t newlen = buf->length + len + 1; /* add 1 for NUL */ + + if(newlen > buf->capacity) + { + buf->capacity = (newlen + (STRING_BLOCK_SIZE - 1)) & mask; + buf->string = (char *)realloc(buf->string, buf->capacity); + } + + strcpy(buf->string + buf->length, text); + buf->length += len; +} + +/* ------------------------------------------------------------------------- */ +/* eof */ @@ -1,37 +1,40 @@ /* ---------------------------------------------------------------------------- - libconfig - A structured configuration file parsing library - Copyright (C) 2005 Mark A Lindner - + libconfig - A library for processing structured configuration files + Copyright (C) 2005-2010 Mark A Lindner + This file is part of libconfig. - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + You should have received a copy of the GNU Library General Public + License along with this library; if not, see + <http://www.gnu.org/licenses/>. ---------------------------------------------------------------------------- */ -#ifndef __libconfig_private_h -#define __libconfig_private_h +#ifndef __libconfig_strbuf_h +#define __libconfig_strbuf_h -#include "libconfig.h" +#include <string.h> +#include <sys/types.h> -struct parse_context +typedef struct { - config_t *config; - config_setting_t *parent; - config_setting_t *setting; - char *name; -}; - -// --------------------------------------------------------------------------- -#endif // __libconfig_private_h + char *string; + size_t length; + size_t capacity; +} strbuf_t; + +char *strbuf_release(strbuf_t *buf); + +void strbuf_append(strbuf_t *buf, const char *text); + +#endif /* __libconfig_strbuf_h */ diff --git a/wincompat.h b/lib/wincompat.h index 6526c1f..23d7379 100644 --- a/wincompat.h +++ b/lib/wincompat.h @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- libconfig - A library for processing structured configuration files - Copyright (C) 2005-2009 Mark A Lindner + Copyright (C) 2005-2010 Mark A Lindner This file is part of libconfig. @@ -32,34 +32,39 @@ #define WIN32_LEAN_AND_MEAN #include <windows.h> -#define atoll _atoi64 #define snprintf _snprintf #ifndef __MINGW32__ +#define atoll _atoi64 #define strtoull _strtoui64 -#endif // __MINGW32__ +#endif /* __MINGW32__ */ #endif #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \ || defined(__MINGW32__)) -// Why does gcc on MinGW use the Visual C++ style format directives -// for 64-bit integers? Inquiring minds want to know.... +/* Why does gcc on MinGW use the Visual C++ style format directives + * for 64-bit integers? Inquiring minds want to know.... + */ #define INT64_FMT "%I64d" #define UINT64_FMT "%I64u" #define INT64_HEX_FMT "%I64X" -#else // defined(WIN32) || defined(__MINGW32__) +#define FILE_SEPARATOR "\\" + +#else /* defined(WIN32) || defined(__MINGW32__) */ #define INT64_FMT "%lld" #define UINT64_FMT "%llu" #define INT64_HEX_FMT "%llX" -#endif // defined(WIN32) || defined(__MINGW32__) +#define FILE_SEPARATOR "/" + +#endif /* defined(WIN32) || defined(__MINGW32__) */ #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ && ! defined(__MINGW32__) @@ -75,11 +80,11 @@ #define INT32_MIN (-2147483647-1) #endif -#else // defined(WIN32) && ! defined(__MINGW32__) +#else /* defined(WIN32) && ! defined(__MINGW32__) */ #define INT64_CONST(I) (I ## LL) #define UINT64_CONST(I) (I ## ULL) -#endif // defined(WIN32) && ! defined(__MINGW32__) +#endif /* defined(WIN32) && ! defined(__MINGW32__) */ -#endif // __wincompat_h +#endif /* __wincompat_h */ diff --git a/libconfig.h++ b/libconfig.h++ deleted file mode 100644 index 0a3b4b2..0000000 --- a/libconfig.h++ +++ /dev/null @@ -1,424 +0,0 @@ -/* ---------------------------------------------------------------------------- - libconfig - A library for processing structured configuration files - Copyright (C) 2005-2009 Mark A Lindner - - This file is part of libconfig. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License - as published by the Free Software Foundation; either version 2.1 of - the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, see - <http://www.gnu.org/licenses/>. - ---------------------------------------------------------------------------- -*/ - -#ifndef __libconfig_hpp -#define __libconfig_hpp - -#include <stdio.h> -#include <string> -#include <map> - -namespace libconfig -{ - -#include <libconfig.h> - - class LIBCONFIG_API ConfigException : public std::exception { }; - - class Setting; // fwd decl - - class LIBCONFIG_API SettingException : public ConfigException - { - friend class Config; - - public: - - SettingException(const SettingException &other); - SettingException& operator=(const SettingException &other); - - virtual ~SettingException() throw(); - - const char *getPath() const; - - virtual const char *what() const throw(); - - protected: - - SettingException(const Setting &setting); - SettingException(const Setting &setting, int idx); - SettingException(const Setting &setting, const char *name); - SettingException(const char *path); - - private: - - char *_path; - }; - - class LIBCONFIG_API SettingTypeException : public SettingException - { - friend class Config; - friend class Setting; - - const char *what() const throw(); - - private: - - SettingTypeException(const Setting &setting); - SettingTypeException(const Setting &setting, int idx); - SettingTypeException(const Setting &setting, const char *name); - }; - - class LIBCONFIG_API SettingNotFoundException : public SettingException - { - friend class Config; - friend class Setting; - - const char *what() const throw(); - - private: - - SettingNotFoundException(const Setting &setting, int idx); - SettingNotFoundException(const Setting &setting, const char *name); - SettingNotFoundException(const char *path); - }; - - class LIBCONFIG_API SettingNameException : public SettingException - { - friend class Config; - friend class Setting; - - const char *what() const throw(); - - private: - - SettingNameException(const Setting &setting, const char *name); - }; - - class LIBCONFIG_API FileIOException : public ConfigException - { - const char *what() const throw(); - }; - - class LIBCONFIG_API ParseException : public ConfigException - { - friend class Config; - - public: - - virtual ~ParseException() throw(); - - inline int getLine() throw() - { return(_line); } - - inline const char *getError() throw() - { return(_error); } - - const char *what() const throw(); - - private: - - ParseException(int line, const char *error); - - int _line; - const char *_error; - }; - - class LIBCONFIG_API Setting - { - friend class Config; - - public: - - enum Type - { - TypeNone = 0, - // scalar types - TypeInt, - TypeInt64, - TypeFloat, - TypeString, - TypeBoolean, - // aggregate types - TypeGroup, - TypeArray, - TypeList - }; - - enum Format - { - FormatDefault = 0, - FormatHex = 1 - }; - - private: - - config_setting_t *_setting; - Type _type; - Format _format; - - Setting(config_setting_t *setting); - - void assertType(Type type) const - throw(SettingTypeException); - static Setting & wrapSetting(config_setting_t *setting); - - Setting(const Setting& other); // not supported - Setting& operator=(const Setting& other); // not supported - - public: - - virtual ~Setting() throw(); - - inline Type getType() const throw() { return(_type); } - - inline Format getFormat() const throw() { return(_format); } - void setFormat(Format format) throw(); - - operator bool() const throw(SettingTypeException); - operator long() const throw(SettingTypeException); - operator unsigned long() const throw(SettingTypeException); - operator int() const throw(SettingTypeException); - operator unsigned int() const throw(SettingTypeException); - operator long long() const throw(SettingTypeException); - operator unsigned long long() const throw(SettingTypeException); - operator double() const throw(SettingTypeException); - operator float() const throw(SettingTypeException); - operator const char *() const throw(SettingTypeException); - operator std::string() const throw(SettingTypeException); - - Setting & operator=(bool value) throw(SettingTypeException); - Setting & operator=(long value) throw(SettingTypeException); - Setting & operator=(int value) throw(SettingTypeException); - Setting & operator=(const long long &value) throw(SettingTypeException); - Setting & operator=(const double &value) throw(SettingTypeException); - Setting & operator=(float value) throw(SettingTypeException); - Setting & operator=(const char *value) throw(SettingTypeException); - Setting & operator=(const std::string &value) throw(SettingTypeException); - - Setting & operator[](const char * key) const - throw(SettingTypeException, SettingNotFoundException); - - inline Setting & operator[](const std::string & key) const - throw(SettingTypeException, SettingNotFoundException) - { return(operator[](key.c_str())); } - - Setting & operator[](int index) const - throw(SettingTypeException, SettingNotFoundException); - - bool lookupValue(const char *name, bool &value) const throw(); - bool lookupValue(const char *name, long &value) const throw(); - bool lookupValue(const char *name, unsigned long &value) const throw(); - bool lookupValue(const char *name, int &value) const throw(); - bool lookupValue(const char *name, unsigned int &value) const throw(); - bool lookupValue(const char *name, long long &value) const throw(); - bool lookupValue(const char *name, unsigned long long &value) - const throw(); - bool lookupValue(const char *name, double &value) const throw(); - bool lookupValue(const char *name, float &value) const throw(); - bool lookupValue(const char *name, const char *&value) const throw(); - bool lookupValue(const char *name, std::string &value) const throw(); - - inline bool lookupValue(const std::string &name, bool &value) - const throw() - { return(lookupValue(name.c_str(), value)); } - - inline bool lookupValue(const std::string &name, long &value) - const throw() - { return(lookupValue(name.c_str(), value)); } - - inline bool lookupValue(const std::string &name, unsigned long &value) - const throw() - { return(lookupValue(name.c_str(), value)); } - - inline bool lookupValue(const std::string &name, int &value) const throw() - { return(lookupValue(name.c_str(), value)); } - - inline bool lookupValue(const std::string &name, unsigned int &value) - const throw() - { return(lookupValue(name.c_str(), value)); } - - inline bool lookupValue(const std::string &name, long long &value) - const throw() - { return(lookupValue(name.c_str(), value)); } - - inline bool lookupValue(const std::string &name, - unsigned long long &value) const throw() - { return(lookupValue(name.c_str(), value)); } - - inline bool lookupValue(const std::string &name, double &value) const - throw() - { return(lookupValue(name.c_str(), value)); } - - inline bool lookupValue(const std::string &name, float &value) const - throw() - { return(lookupValue(name.c_str(), value)); } - - inline bool lookupValue(const std::string &name, const char *&value) const - throw() - { return(lookupValue(name.c_str(), value)); } - - inline bool lookupValue(const std::string &name, std::string &value) const - throw() - { return(lookupValue(name.c_str(), value)); } - - void remove(const char *name) - throw(SettingTypeException, SettingNotFoundException); - - inline void remove(const std::string & name) - throw(SettingTypeException, SettingNotFoundException) - { remove(name.c_str()); } - - void remove(unsigned int idx) - throw(SettingTypeException, SettingNotFoundException); - - inline Setting & add(const std::string & name, Type type) - throw(SettingNameException, SettingTypeException) - { return(add(name.c_str(), type)); } - - Setting & add(const char *name, Type type) - throw(SettingNameException, SettingTypeException); - - Setting & add(Type type) throw(SettingTypeException); - - inline bool exists(const std::string & name) const throw() - { return(exists(name.c_str())); } - - bool exists(const char *name) const throw(); - - int getLength() const throw(); - const char *getName() const throw(); - std::string getPath() const; - int getIndex() const throw(); - - const Setting & getParent() const throw(SettingNotFoundException); - Setting & getParent() throw(SettingNotFoundException); - - bool isRoot() const throw(); - - inline bool isGroup() const throw() - { return(_type == TypeGroup); } - - inline bool isArray() const throw() - { return(_type == TypeArray); } - - inline bool isList() const throw() - { return(_type == TypeList); } - - inline bool isAggregate() const throw() - { return(_type >= TypeGroup); } - - inline bool isScalar() const throw() - { return((_type > TypeNone) && (_type < TypeGroup)); } - - inline bool isNumber() const throw() - { return((_type == TypeInt) || (_type == TypeInt64) - || (_type == TypeFloat)); } - - inline unsigned int getSourceLine() const throw() - { return(config_setting_source_line(_setting)); } - }; - - class LIBCONFIG_API Config - { - private: - - config_t _config; - - static void ConfigDestructor(void *arg); - Config(const Config& other); // not supported - Config& operator=(const Config& other); // not supported - - public: - - Config(); - virtual ~Config(); - - void setAutoConvert(bool flag); - bool getAutoConvert() const; - - void read(FILE *stream) throw(ParseException); - void write(FILE *stream) const; - - void readFile(const char *filename) throw(FileIOException, ParseException); - void writeFile(const char *filename) throw(FileIOException); - - inline Setting & lookup(const std::string &path) const - throw(SettingNotFoundException) - { return(lookup(path.c_str())); } - - Setting & lookup(const char *path) const throw(SettingNotFoundException); - - inline bool exists(const std::string & path) const throw() - { return(exists(path.c_str())); } - - bool exists(const char *path) const throw(); - - bool lookupValue(const char *path, bool &value) const throw(); - bool lookupValue(const char *path, long &value) const throw(); - bool lookupValue(const char *path, unsigned long &value) const throw(); - bool lookupValue(const char *path, int &value) const throw(); - bool lookupValue(const char *path, unsigned int &value) const throw(); - bool lookupValue(const char *path, long long &value) const throw(); - bool lookupValue(const char *path, unsigned long long &value) - const throw(); - bool lookupValue(const char *path, double &value) const throw(); - bool lookupValue(const char *path, float &value) const throw(); - bool lookupValue(const char *path, const char *&value) const throw(); - bool lookupValue(const char *path, std::string &value) const throw(); - - inline bool lookupValue(const std::string &path, bool &value) const throw() - { return(lookupValue(path.c_str(), value)); } - - inline bool lookupValue(const std::string &path, long &value) const throw() - { return(lookupValue(path.c_str(), value)); } - - inline bool lookupValue(const std::string &path, unsigned long &value) - const throw() - { return(lookupValue(path.c_str(), value)); } - - inline bool lookupValue(const std::string &path, int &value) const throw() - { return(lookupValue(path.c_str(), value)); } - - inline bool lookupValue(const std::string &path, unsigned int &value) - const throw() - { return(lookupValue(path.c_str(), value)); } - - inline bool lookupValue(const std::string &path, long long &value) - const throw() - { return(lookupValue(path.c_str(), value)); } - - inline bool lookupValue(const std::string &path, - unsigned long long &value) const throw() - { return(lookupValue(path.c_str(), value)); } - - inline bool lookupValue(const std::string &path, double &value) - const throw() - { return(lookupValue(path.c_str(), value)); } - - inline bool lookupValue(const std::string &path, float &value) - const throw() - { return(lookupValue(path.c_str(), value)); } - - inline bool lookupValue(const std::string &path, const char *&value) - const throw() - { return(lookupValue(path.c_str(), value)); } - - inline bool lookupValue(const std::string &path, std::string &value) - const throw() - { return(lookupValue(path.c_str(), value)); } - - Setting & getRoot() const; - }; - -} // namespace libconfig - -#endif // __libconfig_hpp diff --git a/libconfig.sln b/libconfig.sln index 8a6c989..3b855a8 100644 --- a/libconfig.sln +++ b/libconfig.sln @@ -1,13 +1,52 @@
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual C++ Express 2005
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig++_stub", "libconfig++_stub.vcproj", "{2A94C9E9-A7C7-4770-A24C-694312ADB850}"
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c_example1", "examples\c\example1.vcproj", "{454984C5-C302-4CE2-9B17-15B96E05E120}"
+ ProjectSection(ProjectDependencies) = postProject
+ {1A234565-926D-49B2-83E4-D56E0C38C9F2} = {1A234565-926D-49B2-83E4-D56E0C38C9F2}
+ EndProjectSection
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig++", "libconfig++.vcproj", "{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig", "lib\libconfig.vcproj", "{1A234565-926D-49B2-83E4-D56E0C38C9F2}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig", "libconfig.vcproj", "{1A234565-926D-49B2-83E4-D56E0C38C9F2}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig++", "lib\libconfig++.vcproj", "{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig_stub", "libconfig_stub.vcproj", "{6CD5E648-E434-4C9A-9872-AF884149CE93}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c_example2", "examples\c\example2.vcproj", "{E4B1E9C1-E319-4A23-A6EB-85D74AB59BBE}"
+ ProjectSection(ProjectDependencies) = postProject
+ {1A234565-926D-49B2-83E4-D56E0C38C9F2} = {1A234565-926D-49B2-83E4-D56E0C38C9F2}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c_example3", "examples\c\example3.vcproj", "{93568409-C7AD-4A32-88E2-8883E10A8F7E}"
+ ProjectSection(ProjectDependencies) = postProject
+ {1A234565-926D-49B2-83E4-D56E0C38C9F2} = {1A234565-926D-49B2-83E4-D56E0C38C9F2}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c++_example1", "examples\c++\cxx_example1.vcproj", "{A1DF518C-A515-45A3-9B67-7D49F616DECC}"
+ ProjectSection(ProjectDependencies) = postProject
+ {A0C36CE7-D908-4573-8B69-249EEEB7D2BE} = {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c++_example2", "examples\c++\cxx_example2.vcproj", "{DEBD09F1-33A1-41A9-9506-BC3E6FD053FD}"
+ ProjectSection(ProjectDependencies) = postProject
+ {A0C36CE7-D908-4573-8B69-249EEEB7D2BE} = {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c++_example3", "examples\c++\cxx_example3.vcproj", "{8F2C54DE-BCC8-4CC7-81F3-FD0C04E8D5AE}"
+ ProjectSection(ProjectDependencies) = postProject
+ {A0C36CE7-D908-4573-8B69-249EEEB7D2BE} = {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "c++_example4", "examples\c++\cxx_example4.vcproj", "{F631BE25-B384-4061-B7D1-E0C0E77D3A0C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {A0C36CE7-D908-4573-8B69-249EEEB7D2BE} = {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtinytest", "tinytest\tinytest.vcproj", "{58F43D41-FE56-40E1-BB83-9CB8CDE0B7AA}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig_tests", "tests\tests.vcproj", "{E4FF1E84-9D5A-4A45-A5E5-8B99CA895172}"
+ ProjectSection(ProjectDependencies) = postProject
+ {58F43D41-FE56-40E1-BB83-9CB8CDE0B7AA} = {58F43D41-FE56-40E1-BB83-9CB8CDE0B7AA}
+ {1A234565-926D-49B2-83E4-D56E0C38C9F2} = {1A234565-926D-49B2-83E4-D56E0C38C9F2}
+ EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,22 +54,50 @@ Global Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {2A94C9E9-A7C7-4770-A24C-694312ADB850}.Debug|Win32.ActiveCfg = Debug|Win32
- {2A94C9E9-A7C7-4770-A24C-694312ADB850}.Debug|Win32.Build.0 = Debug|Win32
- {2A94C9E9-A7C7-4770-A24C-694312ADB850}.Release|Win32.ActiveCfg = Release|Win32
- {2A94C9E9-A7C7-4770-A24C-694312ADB850}.Release|Win32.Build.0 = Release|Win32
- {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Debug|Win32.ActiveCfg = Debug|Win32
- {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Debug|Win32.Build.0 = Debug|Win32
- {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Release|Win32.ActiveCfg = Release|Win32
- {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Release|Win32.Build.0 = Release|Win32
+ {454984C5-C302-4CE2-9B17-15B96E05E120}.Debug|Win32.ActiveCfg = Debug|Win32
+ {454984C5-C302-4CE2-9B17-15B96E05E120}.Debug|Win32.Build.0 = Debug|Win32
+ {454984C5-C302-4CE2-9B17-15B96E05E120}.Release|Win32.ActiveCfg = Release|Win32
+ {454984C5-C302-4CE2-9B17-15B96E05E120}.Release|Win32.Build.0 = Release|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Debug|Win32.ActiveCfg = Debug|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Debug|Win32.Build.0 = Debug|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Release|Win32.ActiveCfg = Release|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Release|Win32.Build.0 = Release|Win32
- {6CD5E648-E434-4C9A-9872-AF884149CE93}.Debug|Win32.ActiveCfg = Debug|Win32
- {6CD5E648-E434-4C9A-9872-AF884149CE93}.Debug|Win32.Build.0 = Debug|Win32
- {6CD5E648-E434-4C9A-9872-AF884149CE93}.Release|Win32.ActiveCfg = Release|Win32
- {6CD5E648-E434-4C9A-9872-AF884149CE93}.Release|Win32.Build.0 = Release|Win32
+ {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Debug|Win32.ActiveCfg = Debug|Win32
+ {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Debug|Win32.Build.0 = Debug|Win32
+ {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Release|Win32.ActiveCfg = Release|Win32
+ {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Release|Win32.Build.0 = Release|Win32
+ {E4B1E9C1-E319-4A23-A6EB-85D74AB59BBE}.Debug|Win32.ActiveCfg = Debug|Win32
+ {E4B1E9C1-E319-4A23-A6EB-85D74AB59BBE}.Debug|Win32.Build.0 = Debug|Win32
+ {E4B1E9C1-E319-4A23-A6EB-85D74AB59BBE}.Release|Win32.ActiveCfg = Release|Win32
+ {E4B1E9C1-E319-4A23-A6EB-85D74AB59BBE}.Release|Win32.Build.0 = Release|Win32
+ {93568409-C7AD-4A32-88E2-8883E10A8F7E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {93568409-C7AD-4A32-88E2-8883E10A8F7E}.Debug|Win32.Build.0 = Debug|Win32
+ {93568409-C7AD-4A32-88E2-8883E10A8F7E}.Release|Win32.ActiveCfg = Release|Win32
+ {93568409-C7AD-4A32-88E2-8883E10A8F7E}.Release|Win32.Build.0 = Release|Win32
+ {A1DF518C-A515-45A3-9B67-7D49F616DECC}.Debug|Win32.ActiveCfg = Debug|Win32
+ {A1DF518C-A515-45A3-9B67-7D49F616DECC}.Debug|Win32.Build.0 = Debug|Win32
+ {A1DF518C-A515-45A3-9B67-7D49F616DECC}.Release|Win32.ActiveCfg = Release|Win32
+ {A1DF518C-A515-45A3-9B67-7D49F616DECC}.Release|Win32.Build.0 = Release|Win32
+ {DEBD09F1-33A1-41A9-9506-BC3E6FD053FD}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DEBD09F1-33A1-41A9-9506-BC3E6FD053FD}.Debug|Win32.Build.0 = Debug|Win32
+ {DEBD09F1-33A1-41A9-9506-BC3E6FD053FD}.Release|Win32.ActiveCfg = Release|Win32
+ {DEBD09F1-33A1-41A9-9506-BC3E6FD053FD}.Release|Win32.Build.0 = Release|Win32
+ {8F2C54DE-BCC8-4CC7-81F3-FD0C04E8D5AE}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8F2C54DE-BCC8-4CC7-81F3-FD0C04E8D5AE}.Debug|Win32.Build.0 = Debug|Win32
+ {8F2C54DE-BCC8-4CC7-81F3-FD0C04E8D5AE}.Release|Win32.ActiveCfg = Release|Win32
+ {8F2C54DE-BCC8-4CC7-81F3-FD0C04E8D5AE}.Release|Win32.Build.0 = Release|Win32
+ {F631BE25-B384-4061-B7D1-E0C0E77D3A0C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F631BE25-B384-4061-B7D1-E0C0E77D3A0C}.Debug|Win32.Build.0 = Debug|Win32
+ {F631BE25-B384-4061-B7D1-E0C0E77D3A0C}.Release|Win32.ActiveCfg = Release|Win32
+ {F631BE25-B384-4061-B7D1-E0C0E77D3A0C}.Release|Win32.Build.0 = Release|Win32
+ {58F43D41-FE56-40E1-BB83-9CB8CDE0B7AA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {58F43D41-FE56-40E1-BB83-9CB8CDE0B7AA}.Debug|Win32.Build.0 = Debug|Win32
+ {58F43D41-FE56-40E1-BB83-9CB8CDE0B7AA}.Release|Win32.ActiveCfg = Release|Win32
+ {58F43D41-FE56-40E1-BB83-9CB8CDE0B7AA}.Release|Win32.Build.0 = Release|Win32
+ {E4FF1E84-9D5A-4A45-A5E5-8B99CA895172}.Debug|Win32.ActiveCfg = Debug|Win32
+ {E4FF1E84-9D5A-4A45-A5E5-8B99CA895172}.Debug|Win32.Build.0 = Debug|Win32
+ {E4FF1E84-9D5A-4A45-A5E5-8B99CA895172}.Release|Win32.ActiveCfg = Release|Win32
+ {E4FF1E84-9D5A-4A45-A5E5-8B99CA895172}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/libconfig.spec b/libconfig.spec index 95e89c7..331a32e 100644 --- a/libconfig.spec +++ b/libconfig.spec @@ -1,5 +1,5 @@ Name: libconfig -Version: 1.3.2 +Version: 1.4.8 Release: 1 Summary: C/C++ Configuration File Library @@ -14,18 +14,11 @@ Packager: Deneys S. Maartens <dsm@tlabs.ac.za> BuildRequires: texinfo %description -%{name} is a simple library for manipulating structured configuration +%{name} is a simple library for processing structured configuration files. The file format is more compact and more readable than XML. And unlike XML, it is type-aware, so it is not necessary to do string -parsing in application code. - -%{name} is very compact -- just 25K for the stripped C shared library -(one-fifth the size of the expat XML parser library) and 39K for the -stripped C++ shared library. This makes it well-suited for -memory-constrained systems like handheld devices. - -The library includes bindings for both the C and C++ languages. It works -on POSIX-compliant UNIX systems. +parsing in application code. The library includes bindings for both +the C and C++ languages. It works on POSIX-compliant UNIX systems. %package devel Summary: %{name} development package @@ -67,8 +60,8 @@ ldconfig %doc AUTHORS COPYING.LIB ChangeLog INSTALL NEWS README %doc doc/%{name}.html %doc test.cfg -%doc samples/c/*.c -%doc samples/c++/*.cpp +%doc examples/c/*.c +%doc examples/c++/*.cpp %{_infodir} %{_includedir} %{_libdir}/pkgconfig diff --git a/libconfig.spec.in b/libconfig.spec.in index 963e4de..22edef2 100644 --- a/libconfig.spec.in +++ b/libconfig.spec.in @@ -14,18 +14,11 @@ Packager: Deneys S. Maartens <dsm@tlabs.ac.za> BuildRequires: texinfo %description -%{name} is a simple library for manipulating structured configuration +%{name} is a simple library for processing structured configuration files. The file format is more compact and more readable than XML. And unlike XML, it is type-aware, so it is not necessary to do string -parsing in application code. - -%{name} is very compact -- just 25K for the stripped C shared library -(one-fifth the size of the expat XML parser library) and 39K for the -stripped C++ shared library. This makes it well-suited for -memory-constrained systems like handheld devices. - -The library includes bindings for both the C and C++ languages. It works -on POSIX-compliant UNIX systems. +parsing in application code. The library includes bindings for both +the C and C++ languages. It works on POSIX-compliant UNIX systems. %package devel Summary: %{name} development package @@ -67,8 +60,8 @@ ldconfig %doc AUTHORS COPYING.LIB ChangeLog INSTALL NEWS README %doc doc/%{name}.html %doc test.cfg -%doc samples/c/*.c -%doc samples/c++/*.cpp +%doc examples/c/*.c +%doc examples/c++/*.cpp %{_infodir} %{_includedir} %{_libdir}/pkgconfig |