From: Peter Powell Date: Sat, 6 Apr 2013 10:46:56 +0000 (+0100) Subject: Default to the XML config format. X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=2ae42bbb1fbd661f6078fdbeb65e1d430e38c805;p=user%2Fhenk%2Fcode%2Finspircd.git Default to the XML config format. --- diff --git a/docs/conf/inspircd.conf.example b/docs/conf/inspircd.conf.example index 631db7376..2988ccc0b 100644 --- a/docs/conf/inspircd.conf.example +++ b/docs/conf/inspircd.conf.example @@ -38,6 +38,15 @@ # # ######################################################################## +#-#-#-#-#-#-#-#-#-# CONFIGURATION FORMAT #-#-#-#-#-#-#-#-#-#-#-#-#-#- +# # +# In order to maintain compatibility with older configuration files, # +# you can change the configuration parser to parse as it did in # +# previous releases. When using the "compat" format, you need to use # +# C++ escape sequences (e.g. \n) instead of XML ones (e.g. &nl;) and # +# can not use to create macros. # +# + #-#-#-#-#-#-#-#-#-# INCLUDE CONFIGURATION #-#-#-#-#-#-#-#-#-#-#-#-#-# # # # This optional tag allows you to include another config file # @@ -69,11 +78,6 @@ # # # Variables may be redefined and may reference other variables. # # Value expansion happens at the time the tag is read. # -# # -# Using variable definitions REQUIRES that the config format be # -# changed to "xml" from the default "compat" that uses escape # -# sequences such as "\"" and "\n", and does not support # - diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index bd64f69f5..6d0c2cbdb 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -592,7 +592,7 @@ # ranktoset The numeric rank required to set/unset this mode. Defaults to rank. # depriv Can you remove the mode from yourself? Defaults to yes. # -# +# # # diff --git a/include/configparser.h b/include/configparser.h index 999d79e24..9b2cd4527 100644 --- a/include/configparser.h +++ b/include/configparser.h @@ -31,7 +31,7 @@ struct fpos enum ParseFlags { - FLAG_USE_XML = 1, + FLAG_USE_COMPAT = 1, FLAG_NO_EXEC = 2, FLAG_NO_INC = 4 }; diff --git a/src/configparser.cpp b/src/configparser.cpp index 7d9eab651..25b919b81 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -119,7 +119,7 @@ struct Parser while (1) { ch = next(); - if (ch == '&' && (flags & FLAG_USE_XML)) + if (ch == '&' && !(flags & FLAG_USE_COMPAT)) { std::string varname; while (1) @@ -141,7 +141,7 @@ struct Parser throw CoreException("Undefined XML entity reference '&" + varname + ";'"); value.append(var->second); } - else if (ch == '\\' && !(flags & FLAG_USE_XML)) + else if (ch == '\\' && (flags & FLAG_USE_COMPAT)) { int esc = next(); if (esc == 'n') @@ -211,7 +211,7 @@ struct Parser } else if (name == "define") { - if (!(flags & FLAG_USE_XML)) + if (flags & FLAG_USE_COMPAT) throw CoreException(" tags may only be used in XML-style config (add )"); std::string varname = tag->getString("name"); std::string value = tag->getString("value"); @@ -223,9 +223,9 @@ struct Parser { std::string format = tag->getString("format"); if (format == "xml") - flags |= FLAG_USE_XML; + flags &= ~FLAG_USE_COMPAT; else if (format == "compat") - flags &= ~FLAG_USE_XML; + flags |= FLAG_USE_COMPAT; else if (!format.empty()) throw CoreException("Unknown configuration format " + format); }