Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Cleaning Whitespace from Source Code

by zentara (Archbishop)
on Dec 09, 2004 at 11:58 UTC ( [id://413485]=note: print w/replies, xml ) Need Help??


in reply to Cleaning Whitespace from Source Code

As others have pointed out, you can only strip leading and trailing whitespace, unless you want to risk messing up the code. Do a google search for the C-C++ Beautifier HOW-TO. It's very good. Indent and bcpp have options for specifying how much internal whitespace you want.

Basically for perl use perltidy, for c use indent, for c++ use bcpp, and htmltidy for html. What I have is a little perl script that strips all leading whitespace( and possibly leading line numbers followed by zero or 1 colon(or semi-colon typo) , then I run it thru the above mentioned beautifiers. And yes, occasionally I need to manually fix something, when the thing breaks on an odd line or 2.


I'm not really a human, but I play one on earth. flash japh
  • Comment on Re: Cleaning Whitespace from Source Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://413485]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-19 16:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found