[prev in list] [next in list] [prev in thread] [next in thread]
List: pdns-dev
Subject: Re: [Pdns-dev] [patch] Independent ArgvMap
From: Norbert Sendetzky <norbert () linuxnetworks ! de>
Date: 2004-01-05 19:19:39
Message-ID: 200401052019.45466.norbert () linuxnetworks ! de
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sunday 04 January 2004 18:32, Norbert Sendetzky wrote:
> Furthermore I've fixed a possible bug in file() and preParseFile().
Fixed one, introduced a new :-(
The chomp() line removing the blanks must stay.
Norbert
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAj/5uM8ACgkQxMLs5v5/7eBIQACfWmzxGVACBWdCilOubWxshCoe
/9wAn0r0E0pKGaIn5QTi4tWh15szvm3R
=/H38
-----END PGP SIGNATURE-----
["arguments2.diff" (text/x-diff)]
--- pdns-2.9.13.orig/pdns/arguments.cc Sat Nov 8 13:25:23 2003
+++ pdns-2.9.13/pdns/arguments.cc Mon Jan 5 20:15:41 2004
@@ -16,15 +16,25 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "utility.hh"
+
+
+
#include <fstream>
#include <iostream>
-#include "logger.hh"
#include "arguments.hh"
#include "misc.hh"
-#define L theL("pdns")
-extern Logger &theL(const string &prefix);
+
+
+inline void ArgvMap::chomp(string &line, const string &delim)
+{
+ string::size_type pos;
+
+ if( ( pos = line.find_last_not_of( delim ) ) != string::npos )
+ {
+ line.resize( pos + 1 );
+ }
+}
const ArgvMap::param_t::const_iterator ArgvMap::begin()
{
@@ -263,7 +273,8 @@
string::size_type pos;
while(getline(f,pline)) {
- chomp(pline,"\t\r\n");
+ chomp(pline," \t\r\n"); // strip trailing white spaces
+
if(pline[pline.size()-1]=='\\') {
line+=pline.substr(0,pline.length()-1);
continue;
@@ -271,13 +282,12 @@
else
line+=pline;
-
// strip everything after a #
if((pos=line.find("#"))!=string::npos)
line=line.substr(0,pos);
// strip trailing spaces
- chomp(line," ");
+ chomp(line," \t");
// strip leading spaces
if((pos=line.find_first_not_of(" \t\r\n"))!=string::npos)
@@ -285,7 +295,7 @@
// gpgsql-basic-query=sdfsdfs dfsdfsdf sdfsdfsfd
- parseOne(string("--")+line, arg);
+ parseOne( string("--") + line, arg );
line="";
}
@@ -297,17 +307,15 @@
{
ifstream f(fname);
if(!f) {
- // L<<"Tried file '"<<fname<<"' for configuration"<<endl;
return false;
}
- if(!lax)
- L<<"Opened file '"<<fname<<"' for configuration"<<endl;
string line;
string pline;
string::size_type pos;
+
while(getline(f,pline)) {
- chomp(pline,"\t\r\n");
+ chomp(pline," \t\r\n"); // strip trailing white spaces
if(pline[pline.size()-1]=='\\') {
line+=pline.substr(0,pline.length()-1);
@@ -322,14 +330,12 @@
line=line.substr(0,pos);
// strip trailing spaces
- chomp(line," ");
-
+ chomp(line," \t");
// strip leading spaces
if((pos=line.find_first_not_of(" \t\r\n"))!=string::npos)
line=line.substr(pos);
-
parseOne(string("--")+line,"",lax);
line="";
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic