A set of (DOS) ANSI-C text files (click here to download) was copied to a OSX High Sierra laptop. I would like to ensure that the CR\LF is not an obstacle to to compiling the files. The files seem to be displayed correctly by Sublime and vi.
- The Mac, by default, uses a single carriage return (CR), represented as \r.
- Unix, on the other hand, uses a single linefeed (LF), \n.
- Windows goes one step further and uses both, creating a (CRLF) combination, \r\n.
dos2unix
was installed:
brew install dos2unix
attempts to process the ANSI-C files returns an errors:
$ dos2unix *.h
dos2unix: Binary symbol 0x1A found at line 75
dos2unix: Skipping binary file error.h
dos2unix: Binary symbol 0x1A found at line 156
dos2unix: Skipping binary file random.h
dos2unix: Binary symbol 0x1A found at line 49
dos2unix: Skipping binary file resource.h
dos2unix: Binary symbol 0x1A found at line 107
dos2unix: Skipping binary file results.h
dos2unix: Binary symbol 0x1A found at line 261
dos2unix: Skipping binary file sim_lib.h
dos2unix: Binary symbol 0x1A found at line 27
dos2unix: Skipping binary file stats.h
.c files
$ dos2unix *.c
dos2unix: Binary symbol 0x1A found at line 110
dos2unix: Skipping binary file error.c
dos2unix: Binary symbol 0x1A found at line 780
dos2unix: Skipping binary file random.c
dos2unix: Binary symbol 0x1A found at line 79
dos2unix: Skipping binary file resource.c
dos2unix: Binary symbol 0x1A found at line 582
dos2unix: Skipping binary file results.c
dos2unix: Binary symbol 0x1A found at line 1755
dos2unix: Skipping binary file sim_lib.c
dos2unix: Binary symbol 0x1A found at line 102
dos2unix: Skipping binary file stats.c
QUESTIONS
What are the steps required to ensure that the correct terminator is applied?
How can one visualize (verify) which terminator is engaged? (CR \ LF \ CRLF)
Update
The -f (force) flag will ignore the 0x1A and process the file. Recursively find .c files:
user@hostname:~/csim$ find . -name '*.c' | xargs dos2unix -f
od
for example)? – Jan 27 '20 at 23:190x1a
character is playing in each of them. It seems unrelated to line termination. – Kusalananda Jan 27 '20 at 23:21