Add support for absolute pathnames to @include / @include_dir (Closes #16)
authorJose Luis Tallon <jltallon@adv-solutions.net>
Thu, 24 Dec 2015 22:05:36 +0000 (23:05 +0100)
committerJose Luis Tallon <jltallon@adv-solutions.net>
Thu, 24 Dec 2015 22:10:23 +0000 (23:10 +0100)
 - Misc documentation fixes

AUTHORS
doc/libconfig.texi
lib/scanctx.c

diff --git a/AUTHORS b/AUTHORS
index c12bf6e..ab6a491 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -4,4 +4,4 @@ Daniel Marjamäki - Enhancements & bugfixes.
 Andrew Tytula - Windows port.
 Glenn Herteg - Enhancements, bugfixes, documentation corrections.
 Matt Renaud - Enhancements & bugfixes.
-JoseLuis Tallon - Enhacements
+JoseLuis Tallon - Enhancements & bugfixes
index d263a28..eec8c9d 100644 (file)
@@ -599,6 +599,7 @@ not treated as part of the configuration. Therefore if the
 configuration is written back out to a stream, any comments that were
 present in the original configuration will be lost.
 
+
 @node Include Directives, , Comments, Configuration Files
 @comment  node-name,  next,  previous,  up
 @section Include Directives
@@ -645,12 +646,13 @@ contents of the ``quote.cfg`` file appeared at the point where the
 @@include directive is placed.
 
 @cindex include_dir directive
-Additionally, a directory containing configuration snippets can be 
-processed using an @i{include_dir directive}. This directive has the 
+Additionally, a directory containing configuration snippets can be
+processed using an @b{include_dir} directive. This directive has the
 effect of inlining the contents of the files contained in the named
 directory at the point of inclusion.
-The files are ordered lexicographically and ``hidden`` files (those
-having a name beginning with a dot) are excluded.
+The configuration files are ordered lexicographically before processing
+and ``hidden`` files (those having a name beginning with a dot) are
+skipped.
 
 An include_dir directive must appear on its own line in the input:
 
@@ -658,7 +660,6 @@ An include_dir directive must appear on its own line in the input:
 
 The same quoting rules as for @i{@@include} apply.
 
-
 @cartouche
 @smallexample
 # directory: myapp/conf.d
@@ -668,7 +669,7 @@ The same quoting rules as for @i{@@include} apply.
 03footer.cfg
 99epilog.cfg
 @end smallexample
-@end cartouche   
+@end cartouche
 
 @cartouche
 @smallexample
@@ -678,13 +679,23 @@ docinfo: @{
   @@include_dir "myapp/conf.d"
 @};
 @end smallexample
-@end cartouche   
+@end cartouche
 
-Please keep in mind that the files will be included in lexicographical order.
+Please keep in mind that the included files will be read and processed in
+lexicographical order, as it has become customary.
 
 Include files may be nested to a maximum of 10 levels; exceeding this
 limit results in a parse error.
 
+When the path argument to an @b{@@include} or @b{@@include_dir} directive
+begins with a PATH_SEPARATOR ('/' or '\'), it is considered to be absolute.
+Alternatively, when an @i{include_basedir} has been set by means of a
+@b{config_set_include_dir} call, the directory and/or filename will be
+taken as relative to the specified include_basedir.
+Otherwise, the name is interpreted as relative to the program's CWD
+(current working directory).
+
+
 Like comments, include directives are not part of the configuration
 file syntax. They are processed before the configuration itself is
 parsed. Therefore, they are not preserved when the configuration is
index 39b00b8..cbdc733 100644 (file)
@@ -127,7 +127,7 @@ const char *scanctx_getpath(struct scan_context *ctx)
   const char *full_path = NULL;
 
        name = scanctx_take_string(ctx);
-       if(ctx->config->include_dir)
+       if(FILE_SEPARATOR[0]!=name[0] && ctx->config->include_dir)
                full_path = scanctx_filename(ctx, ctx->config->include_dir, name);
        else
                full_path = strdup(name);