summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2012-07-31 13:50:46 +0200
committerJan Holesovsky <kendy@suse.cz>2012-07-31 13:50:46 +0200
commit0b61e29a77ecbb94b2861fd404441deba54564ed (patch)
tree4ced987af40853cf76482b6fea454c37a4208aff
parent6696b546ffe3cf4cad6c0de65e526698aefaddfe (diff)
Remove the 'all' filter to 'tabs'.
-rw-r--r--filter.cxx46
-rw-r--r--filter.hxx2
-rw-r--r--repository.cxx12
3 files changed, 30 insertions, 30 deletions
diff --git a/filter.cxx b/filter.cxx
index 70a628b..d6f434b 100644
--- a/filter.cxx
+++ b/filter.cxx
@@ -133,26 +133,8 @@ inline void addDataLoopCombined( char*& dest, char what, int& column, int& space
}
}
-/// Just convert Unx line ends to DOS ones
-inline void addDataLoopDos( char*& dest, char what, int& column, int& spaces_to_write, bool& nonspace_appeared, int no_spaces )
-{
- if ( what == '\n' )
- *dest++ = '\r';
-
- *dest++ = what;
-}
-
-/// Just convert DOS line ends to Unx ones
-inline void addDataLoopUnx( char*& dest, char what, int& column, int& spaces_to_write, bool& nonspace_appeared, int no_spaces )
-{
- if ( what == '\r' )
- return;
-
- *dest++ = what;
-}
-
/// The best tabs -> spaces: converts all, strips trailing whitespace
-inline void addDataLoopAll( char*& dest, char what, int& column, int& spaces_to_write, bool& nonspace_appeared, int no_spaces )
+inline void addDataLoopTabs( char*& dest, char what, int& column, int& spaces_to_write, bool& nonspace_appeared, int no_spaces )
{
if ( what == '\t' )
{
@@ -183,6 +165,24 @@ inline void addDataLoopAll( char*& dest, char what, int& column, int& spaces_to_
}
}
+/// Just convert Unx line ends to DOS ones
+inline void addDataLoopDos( char*& dest, char what, int& column, int& spaces_to_write, bool& nonspace_appeared, int no_spaces )
+{
+ if ( what == '\n' )
+ *dest++ = '\r';
+
+ *dest++ = what;
+}
+
+/// Just convert DOS line ends to Unx ones
+inline void addDataLoopUnx( char*& dest, char what, int& column, int& spaces_to_write, bool& nonspace_appeared, int no_spaces )
+{
+ if ( what == '\r' )
+ return;
+
+ *dest++ = what;
+}
+
void Filter::addData( const char* data_, size_t len_ )
{
if ( type == NO_FILTER )
@@ -207,6 +207,10 @@ void Filter::addData( const char* data_, size_t len_ )
for ( const char* it = data_; it < data_ + len_; ++it )
addDataLoopCombined( dest, *it, column, spaces_to_write, nonspace_appeared, spaces );
break;
+ case FILTER_TABS:
+ for ( const char* it = data_; it < data_ + len_; ++it )
+ addDataLoopTabs( dest, *it, column, spaces_to_write, nonspace_appeared, spaces );
+ break;
case FILTER_DOS:
for ( const char* it = data_; it < data_ + len_; ++it )
addDataLoopDos( dest, *it, column, spaces_to_write, nonspace_appeared, spaces );
@@ -215,10 +219,6 @@ void Filter::addData( const char* data_, size_t len_ )
for ( const char* it = data_; it < data_ + len_; ++it )
addDataLoopUnx( dest, *it, column, spaces_to_write, nonspace_appeared, spaces );
break;
- case FILTER_ALL:
- for ( const char* it = data_; it < data_ + len_; ++it )
- addDataLoopAll( dest, *it, column, spaces_to_write, nonspace_appeared, spaces );
- break;
case NO_FILTER:
// NO_FILTER already handled
break;
diff --git a/filter.hxx b/filter.hxx
index 5fedf58..980c35e 100644
--- a/filter.hxx
+++ b/filter.hxx
@@ -15,9 +15,9 @@ enum FilterType {
NO_FILTER, ///< No filtering at all
FILTER_OLD, ///< Old way of filtering - each tab is exactly <n> spaces, no filtering after 1st non-tab, non-space character
FILTER_COMBINED, ///< Combined way of filtering - for the tabs before 1st non-tab, non-space character, behave like _OLD, for the rest as _TABS
+ FILTER_TABS, ///< New way of filtering - each tab is converted as if it was a real tab + strip trailing whitespace
FILTER_DOS, ///< Convert to the DOS line ends
FILTER_UNX, ///< Convert to the Unx line ends
- FILTER_ALL ///< New way of filtering - each tab is converted as if it was a real tab + strip trailing whitespace
};
class Filter
diff --git a/repository.cxx b/repository.cxx
index 5ca78f8..4c70bcb 100644
--- a/repository.cxx
+++ b/repository.cxx
@@ -419,12 +419,12 @@ bool Repositories::load( const char* fname_, unsigned int max_revs_, int& min_re
( equals != string::npos && line.substr( arg, equals - arg ) == "tabs_to_spaces" ) ) // former name of this
{
if ( equals == string::npos )
- Filter::addTabsToSpaces( 8, FILTER_ALL, string( ".*" ) );
+ Filter::addTabsToSpaces( 8, FILTER_TABS, string( ".*" ) );
else
{
size_t comma = line.find( ',', equals + 1 );
if ( comma == string::npos )
- Filter::addTabsToSpaces( atoi( line.substr( equals + 1 ).c_str() ), FILTER_ALL, string( ".*" ) );
+ Filter::addTabsToSpaces( atoi( line.substr( equals + 1 ).c_str() ), FILTER_TABS, string( ".*" ) );
else
{
size_t regex = line.find( ',', comma + 1 );
@@ -433,24 +433,24 @@ bool Repositories::load( const char* fname_, unsigned int max_revs_, int& min_re
{
Error::report( "Please update your configuration file, ':set tabs_to_spaces' now needs 3 params - amount, type, regex" );
Filter::addTabsToSpaces( atoi( line.substr( equals + 1, comma - equals - 1 ).c_str() ),
- FILTER_ALL,
+ FILTER_TABS,
line.substr( comma + 1 ) );
}
else
{
- FilterType filter_type = FILTER_ALL;
+ FilterType filter_type = FILTER_TABS;
if ( line.substr( comma + 1, regex - comma - 1 ) == "none" )
filter_type = NO_FILTER;
else if ( line.substr( comma + 1, regex - comma - 1 ) == "old" )
filter_type = FILTER_OLD;
else if ( line.substr( comma + 1, regex - comma - 1 ) == "combined" )
filter_type = FILTER_COMBINED;
+ else if ( line.substr( comma + 1, regex - comma - 1 ) == "tabs" )
+ filter_type = FILTER_TABS;
else if ( line.substr( comma + 1, regex - comma - 1 ) == "dos" )
filter_type = FILTER_DOS;
else if ( line.substr( comma + 1, regex - comma - 1 ) == "unx" )
filter_type = FILTER_UNX;
- else if ( line.substr( comma + 1, regex - comma - 1 ) == "all" )
- filter_type = FILTER_ALL;
else
Error::report( "Unknown type of filter substitution '" + line.substr( comma + 1, regex - comma - 1 ) + "'." );