[interchange-cvs] interchange - jon modified eg/te

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Tue Jul 23 14:31:01 2002


User:      jon
Date:      2002-07-23 18:30:19 GMT
Modified:  eg       te
Log:
Do cross-platform chomp on lines (remove Windows CRLF even on Unix).

Revision  Changes    Path
2.3       +9 -3      interchange/eg/te


rev 2.3, prev_rev 2.2
Index: te
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/eg/te,v
retrieving revision 2.2
retrieving revision 2.3
diff -u -u -r2.2 -r2.3
--- te	3 Oct 2001 19:32:41 -0000	2.2
+++ te	23 Jul 2002 18:30:19 -0000	2.3
@@ -66,7 +66,7 @@
=20
 =3Dhead1 COPYRIGHT
=20
-Copyright (C) 2001 Red Hat, Inc., http://www.redhat.com/
+Copyright (C) 2001-2002 Red Hat, Inc., http://www.redhat.com/
=20
 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
@@ -98,6 +98,11 @@
=20
 2001-10-03. Added gvim support by forcing foreground option -f.
=20
+2002-07-23. Remove line endings whether CR, LF, or CRLF, instead of
+using running Perl's platform-specific chomp. If preserving a trailing
+solitary CR in the last field of a line is important, you'll want to
+change this behavior.
+
 =3Dcut
=20
 use strict;
@@ -127,7 +132,8 @@
 		warn "Error 'opening' $filename for reading: $!\n";
 		next;
 	}
-	chomp ($_ =3D <IN>);
+	$_ =3D <IN>;
+	s/\x0d?\x0a?$//;
 	die "Error in '$filename' header: null field name found\n" if /\t\t/;
 	$fieldcount =3D tr/\t/\t/ + 1;
 	@fieldnames =3D split /\t/, $_, $fieldcount;
@@ -152,7 +158,7 @@
 #
 EOF
 	while (<IN>) {
-		chomp;
+		s/\x0d?\x0a?$//;
 		@fields =3D split /\t/, $_, $fieldcount;
 		for (my $i =3D 0; $i < @fieldnames; $i++) {
 			print OUT $fieldnames[$i], ":",