diff options
author | deva <deva> | 2009-07-17 13:02:45 +0000 |
---|---|---|
committer | deva <deva> | 2009-07-17 13:02:45 +0000 |
commit | 177cea995d02fd14dd82fa010957ebfbc1c5e760 (patch) | |
tree | 62703ddc11b83a054e8068c0e9c79ce1951959a6 /server/src/macroparser.cc | |
parent | a619ccc300a00947207600e11fac848b7d37b26b (diff) |
More work on the macrotool. Now fieldnames can be added and deleted, and a filehandler is able to add new macros assuring no conflicts in macro names/version/filenames happen. Error messages in MacroParser has been made more elaborate.
Diffstat (limited to 'server/src/macroparser.cc')
-rw-r--r-- | server/src/macroparser.cc | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/server/src/macroparser.cc b/server/src/macroparser.cc index c5b524d..0f7ed76 100644 --- a/server/src/macroparser.cc +++ b/server/src/macroparser.cc @@ -28,6 +28,8 @@ #include "macroparser.h" #include "configuration.h" +#include <stdio.h> + // For assert #include <assert.h> @@ -56,24 +58,37 @@ void MacroParser::error(const char* fmt, ...) PRACRO_ERR_LOG(macro, "Error in MacroParser: "); - va_list argp; - va_start(argp, fmt); - PRACRO_ERR_LOG_VA(macro, fmt, argp); - va_end(argp); + { + va_list argp; + va_start(argp, fmt); + PRACRO_ERR_LOG_VA(macro, fmt, argp); + va_end(argp); + + fprintf(stderr, "\n"); + } - fprintf(stderr, "\n"); + { + char *p; + va_list argp; + va_start(argp, fmt); + if(vasprintf(&p, fmt, argp) != -1) { + throw Exception("Error in MacroParser: " + std::string(p)); + free(p); + } + va_end(argp); + } - throw Exception("Error in MacroParser"); } -MacroParser::MacroParser(std::string macro) +MacroParser::MacroParser(std::string macro, bool abspath) { state = UNDEFINED; m = NULL; current_map = NULL; current_script = NULL; - file = Conf::xml_basedir + "/macros/" + macro + ".xml"; + if(!abspath) file = Conf::xml_basedir + "/macros/" + macro + ".xml"; + else file = macro; PRACRO_DEBUG(macro, "Using macro file: %s\n", file.c_str()); @@ -298,6 +313,13 @@ void MacroParser::parseError(char *buf, size_t len, std::string error, int linen PRACRO_ERR_LOG(macro, "\tBuffer %u bytes: [", len); if(fwrite(buf, len, 1, stderr) != len) {} PRACRO_ERR_LOG(macro, "]\n"); + + char *slineno; + if(asprintf(&slineno, " at line %d\n", lineno) != -1) { + throw Exception(error + slineno); + free(slineno); + } + } Macro *MacroParser::getMacro() |