From 24c978d5d222161aaf5156832f5993ae8e8f43d5 Mon Sep 17 00:00:00 2001 From: Nicolas Le Cam Date: Sun, 14 Dec 2008 22:03:49 +0000 Subject: [PATCH] Formatting: uniformize end of lines. --- FileLister.cpp | 114 ++++++++++++++++++++++++------------------------- tokenize.cpp | 2 +- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/FileLister.cpp b/FileLister.cpp index cc939e5fd..06d290e6b 100644 --- a/FileLister.cpp +++ b/FileLister.cpp @@ -17,8 +17,8 @@ */ #include "FileLister.h" -#include -#include +#include +#include #include #ifdef __GNUC__ @@ -28,61 +28,61 @@ #if defined(__BORLANDC__) || defined(_MSC_VER) #include #endif - -std::string FileLister::simplifyPath( const char *originalPath ) -{ - std::string subPath = ""; - std::vector pathParts; - for( ; *originalPath; ++originalPath ) - { - if( *originalPath == '/' ) - { - if( subPath.length() > 0 ) - { - pathParts.push_back( subPath ); - subPath = ""; - } - - pathParts.push_back( "/" ); - } - else - subPath.append( 1, *originalPath ); - } - - if( subPath.length() > 0 ) - pathParts.push_back( subPath ); - - for( std::vector::size_type i = 0; i < pathParts.size(); ++i ) - { - if( pathParts[i] == ".." && i > 1 ) - { - pathParts.erase( pathParts.begin() + i ); - pathParts.erase( pathParts.begin()+i-1 ); - pathParts.erase( pathParts.begin()+i-2 ); - i = 0; - } - else if( i > 0 && pathParts[i] == "." ) - { - pathParts.erase( pathParts.begin()+i ); - i = 0; - } - else if( pathParts[i] == "/" && i > 0 && pathParts[i-1] == "/" ) - { - pathParts.erase( pathParts.begin()+i-1 ); - i = 0; - } - } - - std::ostringstream oss; - for( std::vector::size_type i = 0; i < pathParts.size(); ++i ) - { - oss << pathParts[i]; - } - - return oss.str(); -} - - + +std::string FileLister::simplifyPath( const char *originalPath ) +{ + std::string subPath = ""; + std::vector pathParts; + for( ; *originalPath; ++originalPath ) + { + if( *originalPath == '/' ) + { + if( subPath.length() > 0 ) + { + pathParts.push_back( subPath ); + subPath = ""; + } + + pathParts.push_back( "/" ); + } + else + subPath.append( 1, *originalPath ); + } + + if( subPath.length() > 0 ) + pathParts.push_back( subPath ); + + for( std::vector::size_type i = 0; i < pathParts.size(); ++i ) + { + if( pathParts[i] == ".." && i > 1 ) + { + pathParts.erase( pathParts.begin() + i ); + pathParts.erase( pathParts.begin()+i-1 ); + pathParts.erase( pathParts.begin()+i-2 ); + i = 0; + } + else if( i > 0 && pathParts[i] == "." ) + { + pathParts.erase( pathParts.begin()+i ); + i = 0; + } + else if( pathParts[i] == "/" && i > 0 && pathParts[i-1] == "/" ) + { + pathParts.erase( pathParts.begin()+i-1 ); + i = 0; + } + } + + std::ostringstream oss; + for( std::vector::size_type i = 0; i < pathParts.size(); ++i ) + { + oss << pathParts[i]; + } + + return oss.str(); +} + + bool FileLister::AcceptFile( const std::string &filename ) { diff --git a/tokenize.cpp b/tokenize.cpp index b1a5a5d1d..23b97a9a9 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -33,7 +33,7 @@ #include #include #include // <- strtoul -#include +#include #include #ifdef __BORLANDC__