summaryrefslogtreecommitdiff
path: root/src/helpers.cpp
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2010-05-17 20:11:50 +0200
committerAndrzej Rybczak <electricityispower@gmail.com>2010-05-17 20:11:50 +0200
commit53dfda0f988f3d68d913f4f46f6313f89256c5de (patch)
treea7ac7b8aebf3729ba04de47191e12d66bc9fe87b /src/helpers.cpp
parent9adb76203601220e418790bff84041ad08c7c174 (diff)
new feature: customizable columns' names
Diffstat (limited to 'src/helpers.cpp')
-rw-r--r--src/helpers.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/helpers.cpp b/src/helpers.cpp
index 356ad5f7..9e1893d5 100644
--- a/src/helpers.cpp
+++ b/src/helpers.cpp
@@ -338,8 +338,9 @@ std::string FindSharedDir(const std::string &one, const std::string &two)
std::string GetLineValue(std::string &line, char a, char b, bool once)
{
int pos[2] = { -1, -1 };
- size_t i;
- for (i = line.find(a); i != std::string::npos && pos[1] < 0; i = line.find(b, i))
+ char x = a;
+ size_t i = 0;
+ while ((i = line.find(x, i)) != std::string::npos && pos[1] < 0)
{
if (i && line[i-1] == '\\')
{
@@ -349,10 +350,22 @@ std::string GetLineValue(std::string &line, char a, char b, bool once)
if (once)
line[i] = 0;
pos[pos[0] >= 0] = i++;
+ if (x == a)
+ x = b;
}
- pos[0]++;
+ ++pos[0];
std::string result = pos[0] >= 0 && pos[1] >= 0 ? line.substr(pos[0], pos[1]-pos[0]) : "";
- Replace(result, "\\\"", "\"");
+
+ // replace \a and \b to a and b respectively
+ char r1[] = "\\ ", r2[] = " ";
+ r1[1] = r2[0] = a;
+ Replace(result, r1, r2);
+ if (a != b)
+ {
+ r1[1] = r2[0] = b;
+ Replace(result, r1, r2);
+ }
+
return result;
}