라벨이 cr인 게시물 표시

Porting to OS/2: Case #1 line ending

When porting programs and libraries from Unix to OS/2, one of the most problematic cases is a line ending problem. OS/2 including Windows and DOS uses CR/LF pair to mark an end of line. Whereas, Unix-like systems use LF only. And OS/2 distinguish text mode(aka translation mode) from binary mode(aka no translation mode). That is, OS/2 translates LF to CR/LF when writing to devices, and CR/LF to LF when reading from on text mode. Whereas, Unix-like systems don't care about distinguishing text mode from binary mode. In OS/2's terms, Unix-like systems treat all the devices as binary mode. And the default mode of OS/2 is text mode. These are the causes of a line ending problem. For example, if we open a file with open() without both O_TEXT and O_BINARY, it is opened in text mode. Likewise, fopen() without both "t" and "b", it is opened in text mode. But on Unix-like systems all of them are opened in binary mode. If they are real text files, nothing is probl...