| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"KevinGPO" |
| Date: |
20 Feb 2006 06:18:10 AM |
| Object: |
QUERY: strip trailing whitespace ... woes :S |
I am wondering about what's the best and easiest way to strip trailing
whitespace from every single file in a folder, recursively.
I want to write a program/script so that you pass in a folder name and
it'll recursively go through all sub-folders and strips trailing
whitespace from every single file.
Trailing whitespace includes:
1. whitespaces at end of text lines, strip whitespace but retain text
2. whitespaces on empty lines, strip whitespace but leave the empty
line
.
|
|
| User: "Richard Herring" |
|
| Title: Re: QUERY: strip trailing whitespace ... woes :S |
20 Feb 2006 07:48:32 AM |
|
|
In message <1140437890.269200.101610@g14g2000cwa.googlegroups.com>,
KevinGPO <kevingpo@hotmail.com> writes
I am wondering about what's the best
Define "best". Fastest? Easiest to code?
and easiest
For the programmer or for the user?
way to strip trailing
whitespace from every single file in a folder, recursively.
I want to write a program/script so that you pass in a folder name and
it'll recursively go through all sub-folders and strips trailing
whitespace from every single file.
Standard C++ has no concept of "folder", "sub-folder" or even "every ...
file", so the solution is inevitably going to be platform-dependent and
off topic here. You might do better with a scripting language - for
example, perl has easy ways of applying operations to all matching
files.
Trailing whitespace includes:
1. whitespaces at end of text lines, strip whitespace but retain text
2. whitespaces on empty lines, strip whitespace but leave the empty
line
2 is just the special case of 1 when the text is of zero size. No need
to treat it specially.
std::string has lots of functions that might help - find_last_not_of,
for example.
--
Richard Herring
.
|
|
|
|

|
Related Articles |
|
|