• 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: Cameron Hayne <email@hidden>
  • Date: Fri, 7 Apr 2006 00:27:28 -0400

On 6-Apr-06, at 4:13 PM, Sean McBride wrote:

Xcode/gcc has a warning for files that do not end in a newline. Many of
my files no not. I figure someone out there has already written a
script that will fix all files

If you know that a file is missing a newline, you could add one by doing:
echo >> nameOfTheFile
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.

--
Cameron Hayne
email@hidden


_______________________________________________ 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
  • Follow-Ups:
    • Re: Script to add newline to end of all source files, for GCC_WARN_ABOUT_MISSING_NEWLINE
      • From: "Sean McBride" <email@hidden>
References: 
 >Script to add newline to end of all source files, for GCC_WARN_ABOUT_MISSING_NEWLINE (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: Compiling .r files
  • Next by Date: built app not unzippable
  • Previous by thread: Script to add newline to end of all source files, for GCC_WARN_ABOUT_MISSING_NEWLINE
  • Next by thread: Re: Script to add newline to end of all source files, for GCC_WARN_ABOUT_MISSING_NEWLINE
  • Index(es):
    • Date
    • Thread