⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dos2unix.lst

📁 编码方式的解码示范uuencode and uudecode are in the public domain. dos2unix and unix2dos are hereby placed in
💻 LST
字号:
 


                                                                                                                            PAGE   1
                                                                                                                            10-15-89
                                                                                                                            17:01:06

 Line#  Source Line                                                                                Microsoft C Compiler Version 5.10

      1  /*
      2   *	This program strips the CRs from a file.  MSDOS uses CRLF for
      3   * \n while Unix uses only a LF.  In addition, ^Z characters are
      4   * stripped from the input file.  Unix does not use ^Z to mark the
      5   * EOF, while some MSDOS editors put a ^Z at the end of a file.
      6   * ^D characters are stripped from the file also.  Some PC products
      7   * which produce Postscript output put ^Ds in the file.  Some
      8   * Postscript printers will complain about these files and refuse
      9   * to print them.
     10   *
     11   * Kenneth J. Hendrickson
     12   */
     13  
     14  #ifdef MSDOS
     15  #include <fcntl.h>
     16  #include <io.h>
     17  #include <process.h>
     18  #endif
     19  #include <stdio.h>
     20  
     21  #define CTRL_D	'\004'	/* EOT */
     22  #define CTRL_M	'\015'	/* CR */
     23  #define CTRL_Z	'\032'	/* SUB */
     24  
     25  main(argc, argv)
     26  int argc;
     27  char **argv;
     28  
     29  {
     30  	FILE *in;
     31  	char buffer[2];
     32  
     33  	/* optional input arg */
     34  	if (argc > 1) {
     35  		if ((in = fopen(argv[1], "r")) == NULL) {
     36  			(void) perror(argv[1]);
     37  			exit(1);
     38  		}
     39  		argc--;
     40  	} else
     41  		in = stdin;
     42  
     43  	if (argc != 1) {
     44  		(void) fprintf(stderr, "Usage: dos2unix [infile]\n");
     45  		exit(2);
     46  	}
     47  
     48  #ifdef MSDOS
     49  	/* don't translate CRLF into LF when reading */
     50  	(void) setmode(fileno(in), O_BINARY);
     51  
 


                                                                                                                            PAGE   2
                                                                                                                            10-15-89
                                                                                                                            17:01:06

 Line#  Source Line                                                                                Microsoft C Compiler Version 5.10

     52  	/* don't translate LF into CRLF when writing */
     53  	(void) setmode(fileno(stdout), O_BINARY);
     54  #endif
     55  
     56  	while (fread(buffer, sizeof (char), 1, in) == 1)
     57  		if ( (buffer[0] != CTRL_D) && (buffer[0] != CTRL_M) && (buffer[0] != CTRL_Z) )
     58  			(void) fputc(buffer[0], stdout);
     59  }


main  Local Symbols

Name                      Class   Type              Size   Offset  Register

buffer. . . . . . . . . . auto                             -0004 
in. . . . . . . . . . . . auto                             -0002 
argc. . . . . . . . . . . param                             0004
argv. . . . . . . . . . . param                             0006


Global Symbols

Name                      Class   Type              Size   Offset  

_iob. . . . . . . . . . . extern  struct/array       ***     ***
exit. . . . . . . . . . . extern  near function      ***     ***
fopen . . . . . . . . . . extern  near function      ***     ***
fprintf . . . . . . . . . extern  near function      ***     ***
fputc . . . . . . . . . . extern  near function      ***     ***
fread . . . . . . . . . . extern  near function      ***     ***
main. . . . . . . . . . . global  near function      ***    0000
perror. . . . . . . . . . extern  near function      ***     ***
setmode . . . . . . . . . extern  near function      ***     ***

Code size = 00c2 (194)
Data size = 001c (28)
Bss size  = 0000 (0)

No errors detected

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -