[Parseperl-discuss] [PATCH] preserve newlines
Brought to you by:
adamkennedy
From: Chris D. <ch...@ch...> - 2006-10-04 21:45:36
|
Here's another slightly controversial patch that I don't feel comfortable just committing without a nod from Adam: This patch changes PPI to preserve line endings instead of localizing them. The code passes all PPI and Perl::Critic tests. I implemented this change to enable a new Perl::Critic policy, CodeLayout::RequireConsistentNewlines, which is intended to help with code signing problems. There are still a few un-fixed methods that are not exercised by the test suite, like PPI::Token::Pod::merge(). These need to be fixed before this patch could be committed. Additionally, the PPI.pm docs need to be updated to reflect this change. In the process, I added two new API methods: PPI::Node::line_ending () and PPI::Token::HereDoc::Terminator_line(). This patch will collide a tiny bit with my "$_" patch, but it should be easy to repair (I'm happy to do the legwork on that). *** This implementation simply changes all "\n" checks to "\015{1,2}\012| \012|\015" checks. An alternative implementation would be for the tokenizer to look ahead to the first line ending, store that value, and use it throughout tokenization. That implementation would be more like what text editors do, but less like Perl (I think). Chris -- Chris Dolan, Software Developer, http://www.chrisdolan.net/ Public key: http://www.chrisdolan.net/public.key vCard: http://www.chrisdolan.net/ChrisDolan.vcf |