PerlIO-eol-0.17000755000764000764 013220416733 13646 5ustar00shlomifshlomif000000000000eol.h100644000764000764 721613220416733 14665 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17typedef struct { bool cr; unsigned int eol; unsigned int mixed; unsigned int seen; } PerlIOEOL_Baton; typedef struct { PerlIOBuf base; PerlIOEOL_Baton read; PerlIOEOL_Baton write; STDCHAR *name; } PerlIOEOL; enum { EOL_Mixed_OK, EOL_Mixed_Warn, EOL_Mixed_Fatal }; #define EOL_CR 015 #define EOL_LF 012 #define EOL_CRLF 015 + 012 #ifdef PERLIO_USING_CRLF # define EOL_NATIVE EOL_CRLF #else # ifdef MACOS_TRADITIONAL # define EOL_NATIVE EOL_CR # else # define EOL_NATIVE EOL_LF # endif #endif #define EOL_LoopBegin \ for (i = start; i < end; i++) { #define EOL_LoopEnd \ start = i + 1; \ } #define EOL_LoopForMixed( baton, do_break, do_lf ) \ EOL_LoopBegin; \ EOL_CheckForMixedCRLF( baton.seen, do_break, NOOP, do_lf, NOOP ); #define EOL_CheckForMixedCRLF( seen, do_break, do_cr, do_lf, do_crlf ) \ switch (*i) { \ case EOL_LF: \ EOL_Seen( seen, EOL_LF, do_break ); do_lf; \ case EOL_CR: \ if (i == end - 1) { \ do_cr; \ } \ else if ( i[1] != EOL_LF ) { \ EOL_Seen( seen, EOL_CR, do_break ); \ } \ else { \ EOL_Seen( seen, EOL_CRLF, do_break ); \ do_crlf; \ } \ break; \ default: \ continue; \ } #define EOL_LoopForCR \ EOL_LoopBegin; \ if (*i != EOL_CR) continue; #define EOL_LoopForCRorLF \ EOL_LoopBegin; \ if ( (*i != EOL_CR) && (*i != EOL_LF) ) continue; #define EOL_CheckForCRLF(baton) \ if (i == end - 1) { \ baton.cr = 1; \ } \ else if (i[1] == EOL_LF) { \ i++; \ } #define EOL_AssignEOL(sym, baton) \ if ( strnEQ( sym, "crlf", 4 ) ) { baton.eol = EOL_CRLF; } \ else if ( strnEQ( sym, "cr", 2 ) ) { baton.eol = EOL_CR; } \ else if ( strnEQ( sym, "lf", 2 ) ) { baton.eol = EOL_LF; } \ else if ( strnEQ( sym, "native", 6 ) ) { baton.eol = EOL_NATIVE; } \ else { \ Perl_die(aTHX_ "Unknown eol '%s'; must pass CRLF, CR or LF or Native to :eol().", sym); \ } \ if (strchr( sym, '!' )) { baton.mixed = EOL_Mixed_Fatal; } \ else if (strchr( sym, '?' )) { baton.mixed = EOL_Mixed_Warn; } \ else { baton.mixed = EOL_Mixed_OK; } #define EOL_Dispatch(baton, run_cr, run_lf, run_crlf) \ switch ( baton.eol ) { \ case EOL_LF: \ EOL_Loop( baton, EOL_LoopForCR, run_lf, continue ); break; \ case EOL_CRLF: \ EOL_Loop( baton, EOL_LoopForCRorLF, run_crlf, break ); break; \ case EOL_CR: \ EOL_Loop( baton, EOL_LoopForCRorLF, run_cr, break ); break; \ } #define EOL_StartUpdate(baton) \ if (baton.cr && *start == EOL_LF) { start++; } \ baton.cr = 0; #define EOL_Break \ RETVAL = (i + len - end); break; #define EOL_Break_Error(do_error) \ if (s->name == NULL) { \ do_error(aTHX_ "Mixed newlines"); \ } \ else { \ do_error(aTHX_ "Mixed newlines found in \"%s\"", s->name); \ } #define EOL_Seen(seen, sym, do_break) \ if (seen && (seen != sym)) { do_break; } \ seen = sym; #define EOL_Loop( baton, run_check, run_loop, do_lf ) \ switch ( baton.mixed ) { \ case EOL_Mixed_OK: \ run_check; run_loop; EOL_LoopEnd; break; \ case EOL_Mixed_Fatal: \ EOL_LoopForMixed( baton, EOL_Break_Error(Perl_die), do_lf ); run_loop; EOL_LoopEnd; break; \ case EOL_Mixed_Warn: \ EOL_LoopForMixed( baton, EOL_Break_Error(Perl_warn), do_lf ); run_loop; EOL_LoopEnd; \ } /* vim: set filetype=perl: */ eol.xs100644000764000764 1255113220416733 15106 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "perlio.h" #include "perliol.h" #include "eol.h" #include "fill.h" #include "write.h" IV PerlIOEOL_pushed(pTHX_ PerlIO *f, const char *mode, SV *arg, PerlIO_funcs *tab) { PerlIOEOL *s = PerlIOSelf(f, PerlIOEOL); char *p, *eol_w = NULL, *eol_r = NULL; STRLEN len; if (PerlIOBase(PerlIONext(f))->flags & PERLIO_F_UTF8) { PerlIOBase(f)->flags |= PERLIO_F_UTF8; } else { PerlIOBase(f)->flags &= ~PERLIO_F_UTF8; } s->name = NULL; s->read.cr = s->write.cr = 0; s->read.seen = s->write.seen = 0; p = SvPV(arg, len); if (len) { char *end = p + len; Newz('e', eol_r, len + 1, char); Copy(p, eol_r, len, char); p = eol_r; end = p + len; for (; p < end; p++) { *p = toLOWER(*p); if ((*p == '-') && (eol_w == NULL)) { *p = '\0'; eol_w = p+1; } } } else { Perl_die(aTHX_ "Must pass CRLF, CR, LF or Native to :eol()."); } if (eol_w == NULL) { eol_w = eol_r; } EOL_AssignEOL( eol_r, s->read ); EOL_AssignEOL( eol_w, s->write ); Safefree( eol_r ); return PerlIOBuf_pushed(aTHX_ f, mode, arg, tab); } STDCHAR * PerlIOEOL_get_base(pTHX_ PerlIO *f) { PerlIOBuf *b = PerlIOSelf(f, PerlIOBuf); if (!b->buf) { PerlIOEOL *s = PerlIOSelf(f, PerlIOEOL); if (!b->bufsiz) b->bufsiz = 4096; b->buf = Newz( 'B', b->buf, b->bufsiz * ( (s->read.eol == EOL_CRLF) ? 2 : 1 ), STDCHAR ); if (!b->buf) { b->buf = (STDCHAR *) & b->oneword; b->bufsiz = sizeof(b->oneword); } b->ptr = b->buf; b->end = b->ptr; } return b->buf; } void PerlIOEOL_clearerr(pTHX_ PerlIO *f) { PerlIOEOL *s; if (PerlIOValid(f)) { s = PerlIOSelf(f, PerlIOEOL); if (PerlIOBase(f)->flags & PERLIO_F_EOF) { s->read.cr = s->write.cr = 0; s->read.seen = s->write.seen = 0; } } PerlIOBase_clearerr(aTHX_ f); } SSize_t PerlIOEOL_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count) { PerlIOEOL *s = PerlIOSelf(f, PerlIOEOL); const STDCHAR *i, *start = vbuf, *end = vbuf; end += (unsigned int)count; EOL_StartUpdate( s->write ); if (!(PerlIOBase(f)->flags & PERLIO_F_CANWRITE)) { return 0; } EOL_Dispatch( s->write, WriteWithCR, WriteWithLF, WriteWithCRLF ); if (start >= end) { return count; } return ( (start + PerlIOBuf_write(aTHX_ f, start, end - start)) - (STDCHAR*)vbuf ); } IV PerlIOEOL_fill(pTHX_ PerlIO * f) { IV code = PerlIOBuf_fill(aTHX_ f); PerlIOEOL *s = PerlIOSelf(f, PerlIOEOL); PerlIOBuf *b = PerlIOSelf(f, PerlIOBuf); const STDCHAR *i, *start = b->ptr, *end = b->end; STDCHAR *buf = NULL, *ptr = NULL; if (code != 0) { return code; } EOL_StartUpdate( s->read ); EOL_Dispatch( s->read, FillWithCR, FillWithLF, FillWithCRLF ); if (buf == NULL) { return 0; } if (i > start) { Copy(start, ptr, i - start, STDCHAR); ptr += i - start; } b->ptr = b->buf; b->end = b->buf + (ptr - buf); if (buf != b->buf) { Copy(buf, b->buf, ptr - buf, STDCHAR); Safefree(buf); } return 0; } PerlIO * PerlIOEOL_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, IV n, const char *mode, int fd, int imode, int perm, PerlIO *old, int narg, SV **args) { SV *arg = (narg > 0) ? *args : PerlIOArg; PerlIO *f = PerlIOBuf_open( aTHX_ self, layers, n, mode, fd, imode, perm, old, narg, args ); if (f) { PerlIOEOL *s = PerlIOSelf(f, PerlIOEOL); s->name = (STDCHAR *)savepv( SvPV_nolen(arg) ); } return f; } PerlIO_funcs PerlIO_eol = { sizeof(PerlIO_funcs), "eol", sizeof(PerlIOEOL), PERLIO_K_BUFFERED | PERLIO_K_UTF8, PerlIOEOL_pushed, PerlIOBuf_popped, PerlIOEOL_open, PerlIOBase_binmode, NULL, PerlIOBase_fileno, PerlIOBuf_dup, PerlIOBuf_read, PerlIOBuf_unread, PerlIOEOL_write, PerlIOBuf_seek, PerlIOBuf_tell, PerlIOBuf_close, PerlIOBuf_flush, PerlIOEOL_fill, PerlIOBase_eof, PerlIOBase_error, PerlIOEOL_clearerr, PerlIOBase_setlinebuf, PerlIOEOL_get_base, PerlIOBuf_bufsiz, PerlIOBuf_get_ptr, PerlIOBuf_get_cnt, PerlIOBuf_set_ptrcnt }; MODULE = PerlIO::eol PACKAGE = PerlIO::eol BOOT: #ifdef PERLIO_LAYERS PerlIO_define_layer(aTHX_ &PerlIO_eol); #endif unsigned int eol_is_mixed(arg) SV *arg PROTOTYPE: $ CODE: STRLEN len; register U8 *i, *end; register unsigned int seen = 0; i = (U8*)SvPV(arg, len); end = i + len; RETVAL = 0; for (; i < end; i++) { EOL_CheckForMixedCRLF( seen, EOL_Break, EOL_Seen( seen, EOL_CR, EOL_Break ), break, ( i++ ) ); } OUTPUT: RETVAL char * CR() PROTOTYPE: CODE: RETVAL = "\015"; OUTPUT: RETVAL char * LF() PROTOTYPE: CODE: RETVAL = "\012"; OUTPUT: RETVAL char * CRLF() PROTOTYPE: CODE: RETVAL = "\015\012"; OUTPUT: RETVAL char * NATIVE() PROTOTYPE: CODE: RETVAL = ( (EOL_NATIVE == EOL_CR) ? "\015" : (EOL_NATIVE == EOL_LF) ? "\012" : (EOL_NATIVE == EOL_CRLF) ? "\015\012" : "" ); OUTPUT: RETVAL README100644000764000764 101213220416733 14601 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17This is the README file for PerlIO::eol, a PerlIO layer for normalizing line endings. It requires Perl version 5.7.3 or later. * Installation PerlIO::eol uses the standard perl module install process: perl Makefile.PL make # or 'nmake' on Win32; see notes below make test make install * Copyright Copyright 2004-2006 by Audrey Tang . All rights reserved. You can redistribute and/or modify this bundle under the same terms as Perl itself. See . fill.h100644000764000764 167413220416733 15036 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17#define FillCopyBuffer \ Copy(start, ptr, i - start, STDCHAR); \ ptr += i - start; #define FillInitializeBufferCopy \ if (buf == NULL) { \ New('b', buf, (i - start) + ((end - i + 1) * 2), STDCHAR); \ ptr = buf; \ } \ FillCopyBuffer; #define FillInitializeBuffer \ if (buf == NULL) { \ ptr = buf = b->buf; \ } \ FillCopyBuffer; #define FillCheckForCRLF \ EOL_CheckForCRLF( s->read ); #define FillCheckForCRandCRLF \ if (*i == EOL_CR) { FillCheckForCRLF }; #define FillInsertCR \ *ptr++ = EOL_CR; #define FillInsertLF \ *ptr++ = EOL_LF; #define FillWithCRLF \ FillInitializeBufferCopy; \ FillInsertCR; \ FillInsertLF; \ FillCheckForCRandCRLF; #define FillWithLF \ FillInitializeBuffer; \ FillInsertLF; \ FillCheckForCRLF; #define FillWithCR \ FillInitializeBuffer; \ FillInsertCR; \ FillCheckForCRandCRLF; /* vim: set filetype=perl: */ Changes100644000764000764 677513220416733 15241 0ustar00shlomifshlomif000000000000PerlIO-eol-0.170.17 2017-12-26 * Fix the link to the GitHub repository in the metadata. * Make sure to remove *~ temporary files / cruft. * https://rt.cpan.org/Ticket/Display.html?id=123943 * Thanks to KENTNL for the report. 0.16 2016-04-30 * Hopefully get rid of some warnings on Solaris and other platforms with STDCHAR not "char". - https://rt.cpan.org/Public/Bug/Display.html?id=28104 - Thanks to SMPETERS, SREZIC, GAAL, and others. 0.15 2016-04-26 * Convert the distribution from Module-Install which has become undermaintained to Dist-Zilla. * Some implied enhancements such as pod coverage, VCS repository information and meta-data, removal of trailing whitespace, a LICENSE file, etc. 0.14 2006-12-15 * Doc fixes. 0.13 2004-10-18 * Coupling read() calls with CRLF line endings resulted in false positives in mixed encoding detection, if the read was on the CR/LF boundary. Fixed. 0.12 2004-10-18 * Building on threaded Perl versions was broken, due to a missing aTHX_ symbol. Reported by Roberto Aguilar. 0.11 2004-10-16 * Exceptions raised by '!' and '?' now includes the filename. * The exception is reworded as 'Mixed newlines found in "filename", or 'Mixed newlines found' if a filename cannot be obtained. 0.10 2004-10-16 * In reading "LF!" and "LF?", when an incoming LF is found, simply remember it without altering the input buffer; this saves many Copy() calls. * Add a test on detecting mixed line endings in output streams. 0.09 2004-10-16 * Mixed line endings may now be detected by appending '!' or '?' symbols to the line ending specifier, eg. ":eol(CRLF!)". * Unified read and write logic into OnceAndOnlyOnce macros. 0.08 2004-10-15 * Macroize the inner write() loop too. * Further refactor common macros into eol.h. * LF and CR disciplines no longer need to allocate any additional memories during fill(). * Test failures are now displayed in hex code for easier debugging. 0.07 2004-10-15 * Safely frees allocated buffer memory during reads. * Also safely frees the "eol_r" marker when the layer is pushed. * Correct "unknown eol_w" diagnostics message. 0.06 2004-10-15 * Macroize the inner fill() loop into fill.h, which saves many cycles. * In particular, 'LF' and 'Native' on LF platforms should now only have minimum overhead over ':raw' if the processed stream does not contain CRs. 0.05 2004-10-09 * PerlIO_read() calls were returning unneeded errors when the read block is only partially filled. Fix this by taking _read calls into our hands and save some bits of indirection. 0.04 2004-10-09 * We now optionally exports CR, LF, CRLF and NATIVE constants, at requests from Chia-Liang Kao. * eol_is_mixed is now prototyped as ($). 0.03 2004-10-08 * Fix building problems on Win32. * Support the "Native" eol style. * Added I/O-specific syntax like "LF-Native", which means reading with LF and writing to Native; this what "svn:eol-style = native" means. * Optionally exports a "eol_is_mixed" function, to determine whether a string has an inconsistent line ending style. 0.02 2004-10-07 * Fixed the buffer offset problem on non-CRLF settings. * Trailing data for read operations were ignored. Oops. 0.01 2004-10-07 * Initial release to CPAN. write.h100644000764000764 124113220416733 15230 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17#define WriteInsert(sym, len) \ if (PerlIOBuf_write(aTHX_ f, sym, len) < len) \ return i - (STDCHAR*)vbuf; #define WriteOutBuffer \ WriteInsert( start, (i - start) ); #define WriteCheckForCRLF \ EOL_CheckForCRLF( s->write ); #define WriteCheckForCRandCRLF \ if (*i == EOL_CR) { WriteCheckForCRLF }; #define WriteWithCRLF \ WriteOutBuffer; \ WriteInsert( "\015\012", 2 ); \ WriteCheckForCRandCRLF; #define WriteWithLF \ WriteOutBuffer; \ WriteInsert( "\012", 1 ); \ WriteCheckForCRLF; #define WriteWithCR \ WriteOutBuffer; \ WriteInsert( "\015", 1 ); \ WriteCheckForCRandCRLF; /* vim: set filetype=perl: */ LICENSE100644000764000764 4364413220416733 14767 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17This software is copyright (c) 2004 by Audrey Tang This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2000 by Randy Kobes. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2000 by Randy Kobes. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End dist.ini100644000764000764 143613220416733 15377 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17name = PerlIO-eol author = Shlomi Fish license = Perl_5 copyright_holder = Audrey Tang copyright_year = 2004 [@Filter] -bundle = @Basic -remove = MakeMaker -remove = ExtraTests -remove = License -remove = Readme [AutoPrereqs] [MakeMaker::Awesome] WriteMakefile_arg = 'OBJECT' => 'eol.o' [MetaJSON] [MetaProvides::Package] [MetaResources] bugtracker.web = https://rt.cpan.org/Public/Dist/Display.html?Name=PerlIO-eol bugtracker.mailto = bug-perlio-eol@rt.cpan.org repository.url = https://github.com/shlomif/PerlIO-eol.git repository.web = https://github.com/shlomif/PerlIO-eol repository.type = git [PodCoverageTests] [PodSyntaxTests] [PruneCruft] [RewriteVersion] [RunExtraTests] [Test::CPAN::Changes] [Test::Compile] fake_home = 1 [Test::Kwalitee] [Test::TrailingSpace] META.yml100644000764000764 152313220416733 15201 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17--- abstract: 'PerlIO layer for normalizing line endings' author: - 'Shlomi Fish ' build_requires: File::Spec: '0' File::Temp: '0' IO::Handle: '0' IPC::Open3: '0' Test::More: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.010, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: PerlIO-eol provides: PerlIO::eol: file: lib/PerlIO/eol.pm version: '0.17' requires: Exporter: '0' XSLoader: '0' perl: '5.007003' strict: '0' warnings: '0' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=PerlIO-eol repository: https://github.com/shlomif/PerlIO-eol.git version: '0.17' x_serialization_backend: 'YAML::Tiny version 1.70' MANIFEST100644000764000764 55413220416733 15044 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.010. Changes LICENSE MANIFEST MANIFEST.SKIP META.json META.yml Makefile.PL README dist.ini eol.h eol.xs fill.h lib/PerlIO/eol.pm t/00-compile.t t/1-basic.t write.h xt/author/pod-coverage.t xt/author/pod-syntax.t xt/release/cpan-changes.t xt/release/kwalitee.t xt/release/trailing-space.t META.json100644000764000764 361413220416733 15354 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17{ "abstract" : "PerlIO layer for normalizing line endings", "author" : [ "Shlomi Fish " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.010, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "PerlIO-eol", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Pod::Coverage::TrustPod" : "0", "Test::CPAN::Changes" : "0.19", "Test::Kwalitee" : "1.21", "Test::More" : "0.96", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::TrailingSpace" : "0.0203" } }, "runtime" : { "requires" : { "Exporter" : "0", "XSLoader" : "0", "perl" : "5.007003", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "File::Spec" : "0", "File::Temp" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::More" : "0" } } }, "provides" : { "PerlIO::eol" : { "file" : "lib/PerlIO/eol.pm", "version" : "0.17" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-perlio-eol@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=PerlIO-eol" }, "repository" : { "type" : "git", "url" : "https://github.com/shlomif/PerlIO-eol.git", "web" : "https://github.com/shlomif/PerlIO-eol" } }, "version" : "0.17", "x_serialization_backend" : "Cpanel::JSON::XS version 3.0239" } t000755000764000764 013220416733 14032 5ustar00shlomifshlomif000000000000PerlIO-eol-0.171-basic.t100644000764000764 437713220416733 15611 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17/tuse strict; use Test::More tests => 23; BEGIN { use_ok('PerlIO::eol', qw( eol_is_mixed CR LF CRLF NATIVE )) } my ($CR, $LF, $CRLF) = (CR, LF, CRLF); is( eol_is_mixed("."), 0 ); is( eol_is_mixed(".$CRLF."), 0 ); is( eol_is_mixed(".$CR.$LF."), 3 ); is( eol_is_mixed(".$CRLF.$CR"), 4 ); $/ = undef; sub is_hex ($$;$) { @_ = ( join(' ', unpack '(H2)*', $_[0]), join(' ', unpack '(H2)*', $_[1]), $_[2], ); goto &is; } { open my $w, ">:raw", "read" or die "can't create testfile: $!"; print $w "...$CRLF$LF$CR..."; } { ok(open(my $r, "<:raw:eol(CR)", "read"), "open for read"); is_hex(<$r>, "...$CR$CR$CR...", "read"); } { ok(open(my $r, "<:raw:eol(LF)", "read"), "open for read"); is_hex(<$r>, "...$LF$LF$LF...", "read"); } { ok(open(my $r, "<:raw:eol(CRLF)", "read"), "open for read"); is_hex(<$r>, "...$CRLF$CRLF$CRLF...", "read"); } { local $@; ok(open(my $r, "<:raw:eol(CR!)", "read"), "open for read"); is(eval { <$r> }, undef, 'mixed encoding'); like($@, qr/Mixed newlines/, 'raises exception'); } { ok(open(my $r, "<:raw:eol(CRLF?)", "read"), "open for read"); my $warning; local $SIG{__WARN__} = sub { $warning = $_[0] }; is_hex(<$r>, "...$CRLF$CRLF$CRLF...", "read"); like($warning, qr/Mixed newlines found in "read"/, 'raises exception'); } { local $@; open my $w, ">:raw:eol(LF!)", "write" or die "can't create testfile: $!"; eval { print $w "...$CRLF$LF$CR..." }; like($@, qr/Mixed newlines found in "write"/, 'raises exception'); } TODO: { local $@; local $TODO = 'Trailing CR in mixed encodings'; open my $w, ">:raw:eol(LF!)", "write" or die "can't create testfile: $!"; eval { print $w "...$CRLF$CR" }; like($@, qr/Mixed newlines found in "write"/, 'raises exception'); } { ok(open(my $w, ">:raw:eol(CrLf-lf)", "write"), "open for write"); print $w "...$CR$LF..."; } { open my $r, "<:raw", "write" or die "can't read testfile: $!"; is_hex(<$r>, "...$LF...", "write"); } { ok(open(my $w, ">:raw:eol(LF-Native)", "write"), "open for write"); print $w "...$CR"; } { open my $r, "<", "write" or die "can't read testfile: $!"; is_hex(<$r>, "...\n", "write"); } END { unlink "read"; unlink "write"; } Makefile.PL100644000764000764 272013220416733 15702 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17# This Makefile.PL for PerlIO-eol was generated by # Dist::Zilla::Plugin::MakeMaker::Awesome 0.39. # Don't edit it but the dist.ini and plugins used to construct it. use strict; use warnings; use 5.007003; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "PerlIO layer for normalizing line endings", "AUTHOR" => "Shlomi Fish ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "PerlIO-eol", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.007003", "NAME" => "PerlIO::eol", "PREREQ_PM" => { "Exporter" => 0, "XSLoader" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "File::Spec" => 0, "File::Temp" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => 0 }, "VERSION" => "0.17", "test" => { "TESTS" => "t/*.t" } ); %WriteMakefileArgs = ( %WriteMakefileArgs, 'OBJECT' => 'eol.o', ); my %FallbackPrereqs = ( "Exporter" => 0, "File::Spec" => 0, "File::Temp" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => 0, "XSLoader" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); MANIFEST.SKIP100644000764000764 16413220416733 15606 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17#defaults ^eol\.(?!pm|xs|h).+$ ^.*\.pdb$ ^MANIFEST.bak$ ^Makefile$ ^Makefile.old$ ^blib/ ^pm_to_blib$ ^blibdirs$ ~$ 00-compile.t100644000764000764 275013220416733 16230 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17/tuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'PerlIO/eol.pm' ); # fake home for cpan-testers use File::Temp; local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 ); my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { +require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; PerlIO000755000764000764 013220416733 15467 5ustar00shlomifshlomif000000000000PerlIO-eol-0.17/libeol.pm100644000764000764 524013220416733 16745 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17/lib/PerlIOpackage PerlIO::eol; use 5.007003; use strict; use warnings; use XSLoader; use Exporter; our $VERSION = '0.17'; our @ISA = qw(Exporter); # symbols to export on request our @EXPORT_OK = qw(eol_is_mixed CR LF CRLF NATIVE); XSLoader::load __PACKAGE__, $VERSION; 1; =head1 NAME PerlIO::eol - PerlIO layer for normalizing line endings =head1 VERSION This document describes version 0.15 of PerlIO::eol, released December 18, 2006. =head1 SYNOPSIS binmode STDIN, ":raw:eol(LF)"; binmode STDOUT, ":raw:eol(CRLF)"; open FH, "+<:raw:eol(LF-Native)", "file"; binmode STDOUT, ":raw:eol(CRLF?)"; # warns on mixed newlines binmode STDOUT, ":raw:eol(CRLF!)"; # dies on mixed newlines use PerlIO::eol qw( eol_is_mixed ); my $pos = eol_is_mixed( "mixed\nstring\r" ); =head1 DESCRIPTION This layer normalizes any of C, C, C and C into the designated line ending. It works for both input and output handles. If you specify two different line endings joined by a C<->, it will use the first one for reading and the second one for writing. For example, the C encoding means that all input should be normalized to C, and all output should be normalized to C. By default, data with mixed newlines are normalized silently. Append a C to the line ending will raise a fatal exception when mixed newlines are spotted. Append a C will raise a warning instead. It is advised to pop any potential C<:crlf> or encoding layers before this layer; this is usually done using a C<:raw> prefix. This module also optionally exports a C function; it takes a string and returns the position of the first inconsistent line ending found in that string, or C<0> if the line endings are consistent. The C, C, C and C constants are also exported at request. =head1 EXPORTS =head2 CR A carriage return constant. =head2 CRLF A carriage return/line feed constant. =head2 LF A line feed constant. =head2 NATIVE The native line ending. =head2 eol_is_mixed This module also optionally exports a C function; it takes a string and returns the position of the first inconsistent line ending found in that string, or C<0> if the line endings are consistent. =head1 AUTHORS Audrey Tang Eautrijus@autrijus.orgE. Janitorial help by Gaal Yahas Egaal@forum2.orgE. Inspired by L by Ben Morrow, EPerlIO-eol@morrow.me.ukE. =head1 COPYRIGHT Copyright 2004-2006 by Audrey Tang Eaudreyt@audreyt.orgE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L =cut release000755000764000764 013220416733 15642 5ustar00shlomifshlomif000000000000PerlIO-eol-0.17/xtkwalitee.t100644000764000764 27513220416733 17760 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17/xt/release# this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.12 use strict; use warnings; use Test::More 0.88; use Test::Kwalitee 1.21 'kwalitee_ok'; kwalitee_ok(); done_testing; author000755000764000764 013220416733 15524 5ustar00shlomifshlomif000000000000PerlIO-eol-0.17/xtpod-syntax.t100644000764000764 25213220416733 20136 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17/xt/author#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); pod-coverage.t100644000764000764 33413220416733 20404 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17/xt/author#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. use Test::Pod::Coverage 1.08; use Pod::Coverage::TrustPod; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); cpan-changes.t100644000764000764 34413220416733 20477 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17/xt/releaseuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::CPAN::Changes 0.012 use Test::More 0.96 tests => 1; use Test::CPAN::Changes; subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; trailing-space.t100644000764000764 103413220416733 21067 0ustar00shlomifshlomif000000000000PerlIO-eol-0.17/xt/release#!perl use strict; use warnings; use Test::More; eval "use Test::TrailingSpace"; if ($@) { plan skip_all => "Test::TrailingSpace required for trailing space test."; } else { plan tests => 1; } # TODO: add .pod, .PL, the README/Changes/TODO/etc. documents and possibly # some other stuff. my $finder = Test::TrailingSpace->new( { root => '.', filename_regex => qr#(?:\.(?:t|pm|pl|xs|c|h|txt|pod|PL)|README|Changes|TODO|LICENSE)\z#, }, ); # TEST $finder->no_trailing_space( "No trailing space was found." );