summaryrefslogtreecommitdiff
path: root/server/src/macroparser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/macroparser.cc')
-rw-r--r--server/src/macroparser.cc38
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()