libi2ncommon: (gerd) merge escape into stringfunc
authorGerd v. Egidy <gerd.von.egidy@intra2net.com>
Wed, 25 Aug 2004 09:01:49 +0000 (09:01 +0000)
committerGerd v. Egidy <gerd.von.egidy@intra2net.com>
Wed, 25 Aug 2004 09:01:49 +0000 (09:01 +0000)
aclocal.m4
libi2ncommon.kdevelop
src/Makefile.am
src/escape.cpp [deleted file]
src/escape.hxx [deleted file]
src/stringfunc.cpp
src/stringfunc.hxx
stamp-h.in

index 55aea75..cd168bd 100644 (file)
@@ -1,4 +1,4 @@
-dnl ./aclocal.m4 generated automatically by aclocal 1.4-p5
+dnl aclocal.m4 generated automatically by aclocal 1.4-p5
 
 dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
index b97b7e9..a7908ae 100644 (file)
@@ -1,25 +1,26 @@
-<?xml version="1.0"?>
+<?xml version = '1.0'?>
 <kdevelop>
- <general>
-  <author>Gerd v. Egidy</author>
-  <email>info@intra2net.com</email>
-  <version>0.1</version>
-  <projectmanagement>KDevAutoProject</projectmanagement>
-  <primarylanguage>C++</primarylanguage>
-  <keywords>
-   <keyword>C++</keyword>
-   <keyword>Code</keyword>
-  </keywords>
- </general>
- <kdevautoproject>
   <general>
-   <activetarget>src/libi2ncommon</activetarget>
-   <useconfiguration>debug</useconfiguration>
+    <author>Gerd v. Egidy</author>
+    <email>info@intra2net.com</email>
+    <version>0.1</version>
+    <projectmanagement>KDevAutoProject</projectmanagement>
+    <primarylanguage>C++</primarylanguage>
+    <keywords>
+      <keyword>C++</keyword>
+      <keyword>Code</keyword>
+    </keywords>
   </general>
-  <run>
-   <mainprogram>src/libi2ncommon</mainprogram>
-   <terminal>true</terminal>
-  </run>
+  <kdevautoproject>
+    <general>
+      <activetarget>src/libi2ncommon</activetarget>
+      <useconfiguration>debug</useconfiguration>
+    </general>
+    <run>
+      <mainprogram>src/libi2ncommon</mainprogram>
+      <terminal>true</terminal>
+      <directoryradio>executable</directoryradio>
+    </run>
     <configurations>
       <optimized>
         <builddir>optimized</builddir>
         <cxxflags>-O0 -g3</cxxflags>
       </debug>
     </configurations>
- </kdevautoproject>
- <kdevdoctreeview>
+    <make>
+      <envvars>
+        <envvar value="1" name="WANT_AUTOCONF_2_5" />
+        <envvar value="1" name="WANT_AUTOMAKE_1_6" />
+      </envvars>
+    </make>
+  </kdevautoproject>
+  <kdevdoctreeview>
     <ignoretocs>
       <toc>ada</toc>
       <toc>ada_bugs_gcc</toc>
     <ignoredoxygen>
       <toc>KDE Libraries (Doxygen)</toc>
     </ignoredoxygen>
- </kdevdoctreeview>
- <kdevfilecreate>
-  <useglobaltypes>
-   <type ext="cpp"/>
-   <type ext="h"/>
-  </useglobaltypes>
- </kdevfilecreate>
- <kdevfileview>
+  </kdevdoctreeview>
+  <kdevfilecreate>
+    <useglobaltypes>
+      <type ext="cpp" />
+      <type ext="h" />
+    </useglobaltypes>
+  </kdevfilecreate>
+  <kdevfileview>
     <groups>
       <group pattern="*.h" name="Header files" />
       <group pattern="*.cpp" name="Source files" />
+      <hidenonprojectfiles>false</hidenonprojectfiles>
+      <hidenonlocation>false</hidenonlocation>
     </groups>
- </kdevfileview>
+    <tree>
+      <hidepatterns>*.o,*.lo,CVS</hidepatterns>
+      <hidenonprojectfiles>false</hidenonprojectfiles>
+    </tree>
+  </kdevfileview>
+  <kdevcppsupport>
+    <references/>
+    <codecompletion>
+      <includeGlobalFunctions>true</includeGlobalFunctions>
+      <includeTypes>true</includeTypes>
+      <includeEnums>true</includeEnums>
+      <includeTypedefs>false</includeTypedefs>
+      <automaticCodeCompletion>true</automaticCodeCompletion>
+      <automaticArgumentsHint>true</automaticArgumentsHint>
+      <automaticHeaderCompletion>true</automaticHeaderCompletion>
+      <codeCompletionDelay>250</codeCompletionDelay>
+      <argumentsHintDelay>400</argumentsHintDelay>
+      <headerCompletionDelay>250</headerCompletionDelay>
+    </codecompletion>
+  </kdevcppsupport>
 </kdevelop>
index 27e72a3..0f5bc55 100644 (file)
@@ -4,8 +4,8 @@ INCLUDES = -I$(top_srcdir)/src @LIBGETTEXT_CFLAGS@ $(all_includes)
 
 # the library search path.
 lib_LTLIBRARIES =  libi2ncommon.la
-include_HEADERS = escape.hxx insocketstream.hxx oftmpstream.hxx pipestream.hxx filefunc.hxx stringfunc.hxx timefunc.hxx ipfunc.hxx
-libi2ncommon_la_SOURCES = oftmpstream.cpp escape.cpp ipfunc.cpp timefunc.cpp filefunc.cpp stringfunc.cpp
+include_HEADERS = insocketstream.hxx oftmpstream.hxx pipestream.hxx filefunc.hxx stringfunc.hxx timefunc.hxx ipfunc.hxx
+libi2ncommon_la_SOURCES = oftmpstream.cpp ipfunc.cpp timefunc.cpp filefunc.cpp stringfunc.cpp
 
 # Note:  If you specify a:b:c as the version in the next line,
 #  the library that is made has version (a-c).c.b.  In this
diff --git a/src/escape.cpp b/src/escape.cpp
deleted file mode 100644 (file)
index 04a3407..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/***************************************************************************
-                          escape.cpp  -  escaping of strings
-                             -------------------
-    begin                : Sun Nov 14 1999
-    copyright            : (C) 1999 by Intra2net AG
-    email                : info@intra2net.com
- ***************************************************************************/
-
-#include <string>
-#include <iostream>
-#include <stdexcept>
-
-using namespace std;
-
-string escape(const string &s)
-{
-    string out(s);
-    string::size_type p;
-
-    p=0;
-    while ((p=out.find_first_of("\"\\",p))!=out.npos)
-    {
-        out.insert(p,"\\");
-        p+=2;
-    }
-
-    p=0;
-    while ((p=out.find_first_of("\r",p))!=out.npos)
-    {
-        out.replace(p,1,"\\r");
-        p+=2;
-    }
-
-    p=0;
-    while ((p=out.find_first_of("\n",p))!=out.npos)
-    {
-        out.replace(p,1,"\\n");
-        p+=2;
-    }
-
-    out='"'+out+'"';
-
-    return out;
-}
-
-string descape(const string &s, int startpos, int &endpos)
-{
-    string out;
-
-    if (s.at(startpos) != '"')
-        throw out_of_range("value not type escaped string");
-
-    out=s.substr(startpos+1);
-    string::size_type p=0;
-
-    // search for the end of the string
-    while((p=out.find("\"",p))!=out.npos)
-    {
-        int e=p-1;
-        bool escaped=false;
-
-        // the " might be escaped with a backslash
-        while(e>=0 && out.at(e)=='\\')
-        {
-            if (escaped == false)
-                escaped=true;
-            else
-                escaped=false;
-
-            e--;
-        }
-
-        if (escaped==false)
-            break;
-        else
-            p++;
-    }
-
-    // we now have the end of the string
-    out=out.substr(0,p);
-
-    // tell calling prog about the endposition
-    endpos=startpos+p+1;
-
-    // descape all \ stuff inside the string now
-    p=0;
-    while((p=out.find_first_of("\\",p))!=out.npos)
-    {
-        switch(out.at(p+1))
-        {
-        case 'r':
-            out.replace(p,2,"\r");
-            break;
-        case 'n':
-            out.replace(p,2,"\n");
-            break;
-        default:
-            out.erase(p,1);
-        }
-        p++;
-    }
-
-    return out;
-}
-
-string escape_shellarg(const string &input)
-{
-    if (!input.size())
-        return "";
-    
-    string output = "'";
-    string::const_iterator it, it_end = input.end();
-    for (it = input.begin(); it != it_end; it++) {
-        if ((*it) == '\'')
-            output += "'\\'";
-        
-        output += *it;
-    }
-    
-    output += "'";
-    return output;
-}
diff --git a/src/escape.hxx b/src/escape.hxx
deleted file mode 100644 (file)
index 8ab22f3..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/***************************************************************************
-                          escape.hxx  -  escaping of strings
-                             -------------------
-    begin                : Sun Nov 14 1999
-    copyright            : (C) 1999 by Intra2net AG
-    email                : info@intra2net.com
- ***************************************************************************/
-
-#ifndef __ESCAPE_HXX
-#define __ESCAPE_HXX
-
-#include <string>
-
-std::string escape(const std::string &s);
-
-std::string descape(const std::string &s, int startpos, int &endpos);
-std::string descape(const std::string &s)
-{
-    int endpos;
-    return descape(s,0,endpos);
-}
-
-std::string escape_shellarg(const std::string &input);
-
-#endif
index ae53e36..8f6e14a 100644 (file)
@@ -197,4 +197,111 @@ string nice_unit_format (int input) {
     return out.str();
 }
 
+string escape(const string &s)
+{
+    string out(s);
+    string::size_type p;
+
+    p=0;
+    while ((p=out.find_first_of("\"\\",p))!=out.npos)
+    {
+        out.insert(p,"\\");
+        p+=2;
+    }
+
+    p=0;
+    while ((p=out.find_first_of("\r",p))!=out.npos)
+    {
+        out.replace(p,1,"\\r");
+        p+=2;
+    }
+
+    p=0;
+    while ((p=out.find_first_of("\n",p))!=out.npos)
+    {
+        out.replace(p,1,"\\n");
+        p+=2;
+    }
+
+    out='"'+out+'"';
+
+    return out;
+}
+
+string descape(const string &s, int startpos, int &endpos)
+{
+    string out;
+
+    if (s.at(startpos) != '"')
+        throw out_of_range("value not type escaped string");
+
+    out=s.substr(startpos+1);
+    string::size_type p=0;
+
+    // search for the end of the string
+    while((p=out.find("\"",p))!=out.npos)
+    {
+        int e=p-1;
+        bool escaped=false;
+
+        // the " might be escaped with a backslash
+        while(e>=0 && out.at(e)=='\\')
+        {
+            if (escaped == false)
+                escaped=true;
+            else
+                escaped=false;
+
+            e--;
+        }
+
+        if (escaped==false)
+            break;
+        else
+            p++;
+    }
+
+    // we now have the end of the string
+    out=out.substr(0,p);
+
+    // tell calling prog about the endposition
+    endpos=startpos+p+1;
+
+    // descape all \ stuff inside the string now
+    p=0;
+    while((p=out.find_first_of("\\",p))!=out.npos)
+    {
+        switch(out.at(p+1))
+        {
+        case 'r':
+            out.replace(p,2,"\r");
+            break;
+        case 'n':
+            out.replace(p,2,"\n");
+            break;
+        default:
+            out.erase(p,1);
+        }
+        p++;
+    }
+
+    return out;
+}
 
+string escape_shellarg(const string &input)
+{
+    if (!input.size())
+        return "";
+    
+    string output = "'";
+    string::const_iterator it, it_end = input.end();
+    for (it = input.begin(); it != it_end; it++) {
+        if ((*it) == '\'')
+            output += "'\\'";
+        
+        output += *it;
+    }
+    
+    output += "'";
+    return output;
+}
index d2dd417..bacaff1 100644 (file)
@@ -24,4 +24,15 @@ std::string iso_to_utf8(const std::string& isostring);
 std::string utf8_to_iso(const std::string& utf8string);
 std::string iso_to_html(const std::string& isostring);
 
+std::string escape(const std::string &s);
+
+std::string descape(const std::string &s, int startpos, int &endpos);
+std::string descape(const std::string &s)
+{
+    int endpos;
+    return descape(s,0,endpos);
+}
+
+std::string escape_shellarg(const std::string &input);
+
 #endif
index e69de29..9788f70 100644 (file)
@@ -0,0 +1 @@
+timestamp