From 8d6138fba9f67a8270f2fa01128ad29f44e746ae Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 16 Sep 2007 03:45:06 +0000 Subject: [PATCH] admin file parser now reports line numbers for individual errors --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401438 --- plugins/admin-flatfile/admin-flatfile.sp | 6 +++++- plugins/admin-flatfile/admin-groups.sp | 8 ++++++++ plugins/admin-flatfile/admin-overrides.sp | 9 +++++++++ plugins/admin-flatfile/admin-users.sp | 8 ++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/plugins/admin-flatfile/admin-flatfile.sp b/plugins/admin-flatfile/admin-flatfile.sp index 63a8e225..2cc9bc0d 100644 --- a/plugins/admin-flatfile/admin-flatfile.sp +++ b/plugins/admin-flatfile/admin-flatfile.sp @@ -49,6 +49,7 @@ public Plugin:myinfo = new bool:g_LoggedFileName = false; /* Whether or not the file name has been logged */ new g_ErrorCount = 0; /* Current error count */ new g_IgnoreLevel = 0; /* Nested ignored section count, so users can screw up files safely */ +new g_CurrentLine = 0; /* Current line we're on */ new String:g_Filename[PLATFORM_MAX_PATH]; /* Used for error messages */ #include "admin-overrides.sp" @@ -81,12 +82,15 @@ ParseError(const String:format[], {Handle,String,Float,_}:...) VFormat(buffer, sizeof(buffer), format, 2); - LogError(" (%d) %s", ++g_ErrorCount, buffer); + LogError(" (line %d) %s", g_CurrentLine, buffer); + + g_ErrorCount++; } InitGlobalStates() { g_ErrorCount = 0; g_IgnoreLevel = 0; + g_CurrentLine = 0; g_LoggedFileName = false; } diff --git a/plugins/admin-flatfile/admin-groups.sp b/plugins/admin-flatfile/admin-groups.sp index 968f24a7..4824774e 100644 --- a/plugins/admin-flatfile/admin-groups.sp +++ b/plugins/admin-flatfile/admin-groups.sp @@ -187,6 +187,13 @@ public SMCResult:ReadGroups_EndSection(Handle:smc) return SMCParse_Continue; } +public SMCResult:ReadGroups_CurrentLine(Handle:smc, const String:line[], lineno) +{ + g_CurrentLine = lineno; + + return SMCParse_Continue; +} + static InitializeGroupParser() { if (g_hGroupParser == INVALID_HANDLE) @@ -196,6 +203,7 @@ static InitializeGroupParser() ReadGroups_NewSection, ReadGroups_KeyValue, ReadGroups_EndSection); + SMC_SetRawLine(g_hGroupParser, ReadGroups_CurrentLine); } } diff --git a/plugins/admin-flatfile/admin-overrides.sp b/plugins/admin-flatfile/admin-overrides.sp index cc3f5511..3ff926d5 100644 --- a/plugins/admin-flatfile/admin-overrides.sp +++ b/plugins/admin-flatfile/admin-overrides.sp @@ -155,6 +155,13 @@ public SMCResult:ReadNewOverrides_EndSection(Handle:smc) return SMCParse_Continue; } +public SMCResult:ReadOverrides_CurrentLine(Handle:smc, const String:line[], lineno) +{ + g_CurrentLine = lineno; + + return SMCParse_Continue; +} + static InitializeOverrideParsers() { if (g_hOldOverrideParser == INVALID_HANDLE) @@ -164,6 +171,7 @@ static InitializeOverrideParsers() ReadOldOverrides_NewSection, ReadOverrides_KeyValue, ReadOldOverrides_EndSection); + SMC_SetRawLine(g_hOldOverrideParser, ReadOverrides_CurrentLine); } if (g_hNewOverrideParser == INVALID_HANDLE) { @@ -172,6 +180,7 @@ static InitializeOverrideParsers() ReadNewOverrides_NewSection, ReadOverrides_KeyValue, ReadNewOverrides_EndSection); + SMC_SetRawLine(g_hNewOverrideParser, ReadOverrides_CurrentLine); } } diff --git a/plugins/admin-flatfile/admin-users.sp b/plugins/admin-flatfile/admin-users.sp index 8bfbfbc9..1549b3ef 100644 --- a/plugins/admin-flatfile/admin-users.sp +++ b/plugins/admin-flatfile/admin-users.sp @@ -162,6 +162,13 @@ public SMCResult:ReadUsers_EndSection(Handle:smc) return SMCParse_Continue; } +public SMCResult:ReadUsers_CurrentLine(Handle:smc, const String:line[], lineno) +{ + g_CurrentLine = lineno; + + return SMCParse_Continue; +} + static InitializeUserParser() { if (g_hUserParser == INVALID_HANDLE) @@ -171,6 +178,7 @@ static InitializeUserParser() ReadUsers_NewSection, ReadUsers_KeyValue, ReadUsers_EndSection); + SMC_SetRawLine(g_hUserParser, ReadUsers_CurrentLine); } }