comparison lib-src/make-docfile.c @ 251:677f6a0ee643 r20-5b24

Import from CVS: tag r20-5b24
author cvs
date Mon, 13 Aug 2007 10:19:59 +0200
parents 8eaf7971accc
children e11d67e05968
comparison
equal deleted inserted replaced
250:f385a461c9aa 251:677f6a0ee643
50 #include <ctype.h> 50 #include <ctype.h>
51 #endif 51 #endif
52 52
53 #include <sys/param.h> 53 #include <sys/param.h>
54 54
55 #ifdef MSDOS 55 #if defined(MSDOS) || defined(__CYGWIN32__)
56 #include <fcntl.h> 56 #include <fcntl.h>
57 #endif /* MSDOS */ 57 #endif /* MSDOS */
58 #ifdef WINDOWSNT 58 #ifdef WINDOWSNT
59 #include <stdlib.h> 59 #include <stdlib.h>
60 #include <fcntl.h> 60 #include <fcntl.h>
61 #include <direct.h> 61 #include <direct.h>
62 #endif /* WINDOWSNT */ 62 #endif /* WINDOWSNT */
63 63
64 #ifdef DOS_NT 64 #if defined(DOS_NT) || defined(__CYGWIN32__)
65 #define READ_TEXT "rt" 65 #define READ_TEXT "rt"
66 #define READ_BINARY "rb" 66 #define READ_BINARY "rb"
67 #define WRITE_BINARY "wb"
68 #define APPEND_BINARY "ab"
67 #else /* not DOS_NT */ 69 #else /* not DOS_NT */
68 #define READ_TEXT "r" 70 #define READ_TEXT "r"
69 #define READ_BINARY "r" 71 #define READ_BINARY "r"
72 #define WRITE_BINARY "w"
73 #define APPEND_BINARY "a"
70 #endif /* not DOS_NT */ 74 #endif /* not DOS_NT */
71 75
72 #ifdef MSDOS 76 #ifdef MSDOS
73 /* s/msdos.h defines this as sys_chdir, but we're not linking with the 77 /* s/msdos.h defines this as sys_chdir, but we're not linking with the
74 file where that function is defined. */ 78 file where that function is defined. */
141 char *p = line_buf+1; 145 char *p = line_buf+1;
142 146
143 if (!fp) { 147 if (!fp) {
144 if (!extra_elcs) { 148 if (!extra_elcs) {
145 return NULL; 149 return NULL;
146 } else if (!(fp = fopen(extra_elcs, "r"))) { 150 } else if (!(fp = fopen(extra_elcs, READ_BINARY))) {
147 /* It is not an error if this file doesn't exist. */ 151 /* It is not an error if this file doesn't exist. */
148 /*fatal("error opening site package file list", 0);*/ 152 /*fatal("error opening site package file list", 0);*/
149 return NULL; 153 return NULL;
150 } 154 }
151 fgets(line_buf, BUFSIZ, fp); 155 fgets(line_buf, BUFSIZ, fp);
198 202
199 /* If first two args are -o FILE, output to FILE. */ 203 /* If first two args are -o FILE, output to FILE. */
200 i = 1; 204 i = 1;
201 if (argc > i + 1 && !strcmp (argv[i], "-o")) 205 if (argc > i + 1 && !strcmp (argv[i], "-o"))
202 { 206 {
203 outfile = fopen (argv[i + 1], "w"); 207 outfile = fopen (argv[i + 1], WRITE_BINARY);
204 i += 2; 208 i += 2;
205 } 209 }
206 if (argc > i + 1 && !strcmp (argv[i], "-a")) 210 if (argc > i + 1 && !strcmp (argv[i], "-a"))
207 { 211 {
208 outfile = fopen (argv[i + 1], "a"); 212 outfile = fopen (argv[i + 1], APPEND_BINARY);
209 i += 2; 213 i += 2;
210 } 214 }
211 if (argc > i + 1 && !strcmp (argv[i], "-d")) 215 if (argc > i + 1 && !strcmp (argv[i], "-d"))
212 { 216 {
213 chdir (argv[i + 1]); 217 chdir (argv[i + 1]);