summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2010-11-04 21:19:13 +0800
committerSam Spilsbury <smspillaz@gmail.com>2010-11-04 21:19:13 +0800
commitb3bc6fcb8a12d8b5811b734621b6f3f6081bd592 (patch)
tree8d8f5bb647024745d2d893f7e9e3a9b6bfbe82f9
parentf269698d5618210252027da18283fd16bc000b1d (diff)
downloadcolorfilter-b3bc6fcb8a12d8b5811b734621b6f3f6081bd592.tar.gz
colorfilter-b3bc6fcb8a12d8b5811b734621b6f3f6081bd592.tar.bz2
We can use basename () directly, so we don't need to reimplement it
-rw-r--r--src/colorfilter.cpp3
-rw-r--r--src/parser.cpp34
-rw-r--r--src/parser.h3
3 files changed, 2 insertions, 38 deletions
diff --git a/src/colorfilter.cpp b/src/colorfilter.cpp
index be9811a..66210c6 100644
--- a/src/colorfilter.cpp
+++ b/src/colorfilter.cpp
@@ -20,7 +20,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
#include "colorfilter.h"
#include "parser.h"
@@ -232,7 +231,7 @@ ColorfilterScreen::loadFilters (GLTexture *texture)
loaded = 0;
for (int i = 0; i < count; i++)
{
- name = FragmentParser::baseFileName (filters.at (i).s ());
+ name = CompString (basename (filters.at (i).s ().c_str ()));
file = filters.at (i).s ();
if (name.empty ())
{
diff --git a/src/parser.cpp b/src/parser.cpp
index 7d38759..beaf66c 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -34,45 +34,13 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
+
#include <cstring>
#include <ctype.h>
-
#include <sstream>
#include <fstream>
#include "parser.h"
-/* General helper functions ----------------------------------------- */
-
-/*
- * Helper function to get the basename of file from its path
- * e.g. basename ("/home/user/blah.c") == "blah.c"
- * special case : basename ("/home/user/") == "user"
- */
-CompString
-FragmentParser::baseFileName (const CompString &path)
-{
- size_t pos = 0, foundPos = 0;
- unsigned int length;
- while (foundPos != std::string::npos)
- {
- foundPos = path.find ("/", pos);
- if (foundPos != std::string::npos)
- {
- /* '/' found, check if it is the latest char of the string,
- * if not update result string pointer */
- if (pos + 1 > path.size ())
- break;
-
- pos = foundPos + 1;
- }
- }
- length = path.size ();
- /* Trim terminating '/' if needed */
- if (length > 0 && path.at (length - 1) == '/')
- return path.substr (pos, length - 1);
- return path.substr (pos);
-}
-
/*
* Left trimming function
*/
diff --git a/src/parser.h b/src/parser.h
index eeb7da1..3e87545 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -89,9 +89,6 @@ class FragmentParser
friend class FragmentString;
static CompString
- baseFileName (const CompString &path);
-
- static CompString
ltrim (const CompString &string);
GLFragment::FunctionId