summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/log.c9
-rw-r--r--src/utils/log.h4
2 files changed, 7 insertions, 6 deletions
diff --git a/src/utils/log.c b/src/utils/log.c
index e1822c0..3f73729 100644
--- a/src/utils/log.c
+++ b/src/utils/log.c
@@ -17,8 +17,8 @@ void _printLogBack(const char *format, const char *file, int line, ...) {
free(errorStr);
}
-void _printErrorBack(const char *format, const char *file, int line,
- char *begin, char *end, ...) {
+void _printErrorBack(const char *file, int line, char *begin, char *end,
+ const char *format, ...) {
va_list args;
va_start(args, end);
char *errorStr;
@@ -51,7 +51,8 @@ void _printErrorBack(const char *format, const char *file, int line,
if (*iter == '\n') {
if (iter <= begin) {
file_line_begin = iter + 1;
- } else if (iter >= end) {
+ }
+ if (iter >= end && file_line_end == fileCodes[file_index]) {
file_line_end = iter;
}
if (iter <= end) {
@@ -71,5 +72,5 @@ void _printErrorBack(const char *format, const char *file, int line,
}
fprintf(stderr, "%c", *iter);
}
- fprintf(stderr, "\e[0m");
+ fprintf(stderr, "\e[0m\n");
}
diff --git a/src/utils/log.h b/src/utils/log.h
index 4057394..6cede24 100644
--- a/src/utils/log.h
+++ b/src/utils/log.h
@@ -1,10 +1,10 @@
#pragma once
#define printLog(format,...) _printLogBack(format, __FILE_NAME__, __LINE__, ## __VA_ARGS__)
-#define printError(format,begin,end,...) _printErrorBack(format, __FILE_NAME__, __LINE__, begin, end, ## __VA_ARGS__)
+#define printError(begin,end,format,...) _printErrorBack(__FILE_NAME__, __LINE__, begin, end, format, ## __VA_ARGS__)
#define UNREACHABLE printLog("Unreachable");exit(1)
extern void _printLogBack(const char *format, const char *file, int line, ...);
-extern void _printErrorBack(const char *format, const char *file, int line, char *begin, char *end, ...);
+extern void _printErrorBack(const char *file, int line, char *begin, char *end,const char *format, ...);