• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Script to add newline to end of all source files, for GCC_WARN_ABOUT_MISSING_NEWLINE
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Script to add newline to end of all source files, for GCC_WARN_ABOUT_MISSING_NEWLINE (From: "Sean McBride" <email@hidden>)
 >Re: Script to add newline to end of all source files, for GCC_WARN_ABOUT_MISSING_NEWLINE (From: Cameron Hayne <email@hidden>)

  • Prev by Date: Re: How is your Xcode layout and workflow?
  • Next by Date: Re: How to change debug executable to a new path
  • Previous by thread: Re: Script to add newline to end of all source files, for GCC_WARN_ABOUT_MISSING_NEWLINE
  • Next by thread: RE: dlopen() on 10.3 and static initializers: SOLVED
  • Index(es):
    • Date
    • Thread