Re: Script to add newline to end of all source files, for GCC_WARN_ABOUT_MISSING_NEWLINE
Re: Script to add newline to end of all source files, for GCC_WARN_ABOUT_MISSING_NEWLINE
- Subject: Re: Script to add newline to end of all source files, for GCC_WARN_ABOUT_MISSING_NEWLINE
- From: "Sean McBride" <email@hidden>
- Date: Fri, 7 Apr 2006 13:24:06 -0400
- Organization: Rogue Research
On 2006-04-07 00:27, Cameron Hayne said:
>If you aren't sure if the file is missing a newline or not, you could
>ensure that it does end in a newline with the following one-line Perl
>script:
>perl -ni~ -e 'chomp; print "$_\n"' nameOfTheFile
>that saves a copy of the original file as nameOfTheFile~
>If you also are not sure if the file has proper Unix end-of-lines
>(e.g. if it came from Windows), you could ensure that it does have
>Unix end-of-lines (and that there is a newline at the end) with the
>following one-line Perl script:
>perl -ni~ -e 's/\r\n?/\n/g; chomp; print "$_\n"' nameOfTheFile
>that again saves a copy of the original file as nameOfTheFile~
>
>To process a bunch of files, you could use the above scripts as the
>target of "-exec" with a 'find' command.
Thanks Cameron!
In case anyone else is interested, the final solution is:
cd /path/to/dir-with-code/
find . -iname "*.cp" -exec perl -ni -e 'chomp; print "$_\n"' {} \;
This recursively finds all files ending with .cp and ensures a newline
is at the end of the file.
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden