From a3ef9b2d402acbcef3a1540905a9869a39581821 Mon Sep 17 00:00:00 2001 From: psychon Date: Sun, 6 Jun 2010 09:47:30 +0000 Subject: [PATCH] Allow leading/trailing spaces in the config This is especially useful for all those ASCII-art-in-the-MOTD guys. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2010 726aef4b-f618-498e-8847-2d620e286838 --- znc.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/znc.cpp b/znc.cpp index fc6f6515..1f156ac5 100644 --- a/znc.cpp +++ b/znc.cpp @@ -1106,8 +1106,9 @@ bool CZNC::DoRehash(CString& sError) while (File.ReadLine(sLine)) { uLineNum++; - // Remove all leading / trailing spaces and line endings - sLine.Trim(); + // Remove all leading spaces and trailing line endings + sLine.TrimLeft(); + sLine.TrimRight("\r\n"); if ((sLine.empty()) || (sLine[0] == '#') || (sLine.Left(2) == "//")) { continue; @@ -1251,8 +1252,15 @@ bool CZNC::DoRehash(CString& sError) // If we have a regular line, figure out where it goes CString sName = sLine.Token(0, false, "="); CString sValue = sLine.Token(1, true, "="); + + // Only remove the first space, people might want + // leading spaces (e.g. in the MOTD). + if (sValue.Left(1) == " ") + sValue.LeftChomp(); + + // We don't have any names with spaces, trim all + // leading/trailing spaces. sName.Trim(); - sValue.Trim(); if ((!sName.empty()) && (!sValue.empty())) { if (pUser) {