Login
Log in using an SSO provider:
Fedora Account System
Red Hat Associate
Red Hat Customer
Login using a Red Hat Bugzilla account
Forgot Password
Create an Account
Red Hat Bugzilla – Attachment 104332 Details for
Bug 57508
dos2unix erroneously strips \r
Home
New
Search
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh90 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
[?]
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
a patch
dos2unix-3.1-safeconv.patch (text/plain), 3.06 KB, created by
Michael Schwendt
on 2004-09-26 09:16:44 UTC
(
hide
)
Description:
a patch
Filename:
MIME Type:
Creator:
Michael Schwendt
Created:
2004-09-26 09:16:44 UTC
Size:
3.06 KB
patch
obsolete
>* Fix http://bugzilla.redhat.com/57508 (make dos2unix not modify Mac > files unless in mac2unix mode) >* Make mac2unix mode not create duplicate Unix line delimiters when > run on a DOS file. (mschwendt@users.sf.net) > >diff -Nur dos2unix-3.1-orig/dos2unix.c dos2unix-3.1/dos2unix.c >--- dos2unix-3.1-orig/dos2unix.c 1998-11-19 13:19:25.000000000 +0100 >+++ dos2unix-3.1/dos2unix.c 2004-09-26 11:05:40.073533976 +0200 >@@ -153,6 +153,24 @@ > } > > >+int StripDelimiter(FILE* ipInF, FILE* ipOutF, CFlag *ipFlag, int CurChar) >+{ >+ int TempNextChar; >+ /* Don't modify Mac files when in dos2unix mode. */ >+ if ( (TempNextChar = getc(ipInF)) != EOF) { >+ ungetc( TempNextChar, ipInF ); /* put back peek char */ >+ if ( TempNextChar != '\x0a' ) { >+ putc( CurChar, ipOutF ); /* Mac line, put back CR */ >+ } >+ } >+ else if ( CurChar == '\x0d' ) { /* EOF: last Mac line delimiter (CR)? */ >+ putc( CurChar, ipOutF ); >+ } >+ if (ipFlag->NewLine) { /* add additional LF? */ >+ putc('\n', ipOutF); >+ } >+} >+ > /* converts stream ipInF to UNIX format text and write to stream ipOutF > * RetVal: 0 if success > * -1 otherwise >@@ -161,6 +179,7 @@ > { > int RetVal = 0; > int TempChar; >+ int TempNextChar; > > if ( macmode ) > ipFlag->ConvMode = 3; >@@ -177,11 +196,12 @@ > break; > } > } else { >- if (ipFlag->NewLine) { >- putc('\n', ipOutF); >- } >+ StripDelimiter( ipInF, ipOutF, ipFlag, TempChar ); > } > } >+ if ( TempChar=='\x0d' ) { /* last Mac line? */ >+ StripDelimiter( ipInF, ipOutF, ipFlag, TempChar ); >+ } > break; > case 1: /* 7Bit */ > while ((TempChar = getc(ipInF)) != EOF) { >@@ -193,11 +213,12 @@ > break; > } > } else { >- if (ipFlag->NewLine) { >- putc('\n', ipOutF); >- } >+ StripDelimiter( ipInF, ipOutF, ipFlag, TempChar ); > } > } >+ if ( TempChar=='\x0d' ) { /* last Mac line? */ >+ StripDelimiter( ipInF, ipOutF, ipFlag, TempChar ); >+ } > break; > case 2: /* ISO */ > while ((TempChar = getc(ipInF)) != EOF) { >@@ -209,11 +230,12 @@ > break; > } > } else { >- if (ipFlag->NewLine) { >- putc('\n', ipOutF); >- } >+ StripDelimiter( ipInF, ipOutF, ipFlag, TempChar ); > } > } >+ if ( TempChar=='\x0d' ) { /* last Mac line? */ >+ StripDelimiter( ipInF, ipOutF, ipFlag, TempChar ); >+ } > break; > case 3: /* Mac */ > while ((TempChar = getc(ipInF)) != EOF) >@@ -227,13 +249,19 @@ > } > } > else{ >- if (putc('\x0a', ipOutF) == EOF) >- { >- RetVal = -1; >- if (!ipFlag->Quiet) >- fprintf(stderr, "dos2unix: can not write to out file\n"); >- break; >+ if ( (TempNextChar = getc(ipInF)) != EOF) { >+ ungetc( TempNextChar, ipInF ); /* put back peek char */ >+ /* Don't touch this delimiter if it's a CR,LF pair. */ >+ if ( TempNextChar != '\x0a' ) { >+ if (putc('\x0a', ipOutF) == EOF) >+ { >+ RetVal = -1; >+ if (!ipFlag->Quiet) >+ fprintf(stderr, "dos2unix: can not write to out file\n"); >+ break; >+ } > } >+ } > } > break; > default: /* unknown convmode */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 57508
:
104332
|
104333
|
104335