diff options
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 37 | ||||
| -rw-r--r-- | lib-src/etags.c | 34 | ||||
| -rw-r--r-- | lib-src/hexl.c | 37 | ||||
| -rw-r--r-- | lib-src/make-docfile.c | 128 | ||||
| -rw-r--r-- | lib-src/movemail.c | 17 |
5 files changed, 114 insertions, 139 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 64a73027915..199d46f4984 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,40 @@ | |||
| 1 | 2014-07-15 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Use "b" flag more consistently; avoid "t" (Bug#18006). | ||
| 4 | * make-docfile.c (READ_TEXT): Remove; all uses replaced by "r". | ||
| 5 | (READ_BINARY): Remove; all uses replaced by "rb". | ||
| 6 | |||
| 7 | 2014-07-14 Paul Eggert <eggert@cs.ucla.edu> | ||
| 8 | |||
| 9 | Use binary-io module, O_BINARY, and "b" flag (Bug#18006). | ||
| 10 | * etags.c, hexl.c, make-docfile.c: | ||
| 11 | Include binary-io.h instead of fcntl.h and/or io.h. | ||
| 12 | (main): Use set_binary_mode or SET_BINARY | ||
| 13 | in place of handcrafted code. | ||
| 14 | * etags.c (main) [DOS_NT]: | ||
| 15 | * movemail.c (main) [WINDOWSNT]: | ||
| 16 | Don't mess with _fmode. | ||
| 17 | * etags.c (main, process_file_name, analyse_regex): | ||
| 18 | Use fopen/popen's "b" flag instead. | ||
| 19 | * movemail.c (main, popmail): Use open/lk_open/mkostemp's O_BINARY | ||
| 20 | instead. | ||
| 21 | |||
| 22 | 2014-07-13 Paul Eggert <eggert@cs.ucla.edu> | ||
| 23 | |||
| 24 | * make-docfile.c: Simplify a bit, to simplify further refactoring. | ||
| 25 | (outfile): Remove static var. All uses changed to use stdout, | ||
| 26 | since it's always stdout anyway. While we're at it, prefer | ||
| 27 | putchar/puts/fputs to printf when there are no format strings. | ||
| 28 | (main): Use freopen rather than fopen, so that stdout is reused. | ||
| 29 | Move O_BINARY stuff after the freopen, so it affects the | ||
| 30 | reopened file. | ||
| 31 | (write_c_args): Omit first arg, since it's always stdout now. | ||
| 32 | All uses changed. | ||
| 33 | |||
| 34 | 2014-07-12 Paul Eggert <eggert@cs.ucla.edu> | ||
| 35 | |||
| 36 | * etags.c (Lisp_functions): Also record cl-defun etc. (Bug#17965) | ||
| 37 | |||
| 1 | 2014-06-26 Glenn Morris <rgm@gnu.org> | 38 | 2014-06-26 Glenn Morris <rgm@gnu.org> |
| 2 | 39 | ||
| 3 | * Makefile.in (blessmail): Depend on lisp/mail/blessmail.el. | 40 | * Makefile.in (blessmail): Depend on lisp/mail/blessmail.el. |
diff --git a/lib-src/etags.c b/lib-src/etags.c index 66e7fbb467f..ae5491a8204 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -105,17 +105,13 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; | |||
| 105 | #ifdef MSDOS | 105 | #ifdef MSDOS |
| 106 | # undef MSDOS | 106 | # undef MSDOS |
| 107 | # define MSDOS true | 107 | # define MSDOS true |
| 108 | # include <fcntl.h> | ||
| 109 | # include <sys/param.h> | 108 | # include <sys/param.h> |
| 110 | # include <io.h> | ||
| 111 | #else | 109 | #else |
| 112 | # define MSDOS false | 110 | # define MSDOS false |
| 113 | #endif /* MSDOS */ | 111 | #endif /* MSDOS */ |
| 114 | 112 | ||
| 115 | #ifdef WINDOWSNT | 113 | #ifdef WINDOWSNT |
| 116 | # include <fcntl.h> | ||
| 117 | # include <direct.h> | 114 | # include <direct.h> |
| 118 | # include <io.h> | ||
| 119 | # define MAXPATHLEN _MAX_PATH | 115 | # define MAXPATHLEN _MAX_PATH |
| 120 | # undef HAVE_NTGUI | 116 | # undef HAVE_NTGUI |
| 121 | # undef DOS_NT | 117 | # undef DOS_NT |
| @@ -131,6 +127,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; | |||
| 131 | #include <errno.h> | 127 | #include <errno.h> |
| 132 | #include <sys/types.h> | 128 | #include <sys/types.h> |
| 133 | #include <sys/stat.h> | 129 | #include <sys/stat.h> |
| 130 | #include <binary-io.h> | ||
| 134 | #include <c-strcase.h> | 131 | #include <c-strcase.h> |
| 135 | 132 | ||
| 136 | #include <assert.h> | 133 | #include <assert.h> |
| @@ -1002,13 +999,8 @@ main (int argc, char **argv) | |||
| 1002 | linebuffer filename_lb; | 999 | linebuffer filename_lb; |
| 1003 | bool help_asked = false; | 1000 | bool help_asked = false; |
| 1004 | ptrdiff_t len; | 1001 | ptrdiff_t len; |
| 1005 | char *optstring; | 1002 | char *optstring; |
| 1006 | int opt; | 1003 | int opt; |
| 1007 | |||
| 1008 | |||
| 1009 | #ifdef DOS_NT | ||
| 1010 | _fmode = O_BINARY; /* all of files are treated as binary files */ | ||
| 1011 | #endif /* DOS_NT */ | ||
| 1012 | 1004 | ||
| 1013 | progname = argv[0]; | 1005 | progname = argv[0]; |
| 1014 | nincluded_files = 0; | 1006 | nincluded_files = 0; |
| @@ -1195,15 +1187,10 @@ main (int argc, char **argv) | |||
| 1195 | if (streq (tagfile, "-")) | 1187 | if (streq (tagfile, "-")) |
| 1196 | { | 1188 | { |
| 1197 | tagf = stdout; | 1189 | tagf = stdout; |
| 1198 | #ifdef DOS_NT | 1190 | SET_BINARY (fileno (stdout)); |
| 1199 | /* Switch redirected `stdout' to binary mode (setting `_fmode' | ||
| 1200 | doesn't take effect until after `stdout' is already open). */ | ||
| 1201 | if (!isatty (fileno (stdout))) | ||
| 1202 | setmode (fileno (stdout), O_BINARY); | ||
| 1203 | #endif /* DOS_NT */ | ||
| 1204 | } | 1191 | } |
| 1205 | else | 1192 | else |
| 1206 | tagf = fopen (tagfile, append_to_tagfile ? "a" : "w"); | 1193 | tagf = fopen (tagfile, append_to_tagfile ? "ab" : "wb"); |
| 1207 | if (tagf == NULL) | 1194 | if (tagf == NULL) |
| 1208 | pfatal (tagfile); | 1195 | pfatal (tagfile); |
| 1209 | } | 1196 | } |
| @@ -1306,7 +1293,7 @@ main (int argc, char **argv) | |||
| 1306 | append_to_tagfile = true; | 1293 | append_to_tagfile = true; |
| 1307 | } | 1294 | } |
| 1308 | 1295 | ||
| 1309 | tagf = fopen (tagfile, append_to_tagfile ? "a" : "w"); | 1296 | tagf = fopen (tagfile, append_to_tagfile ? "ab" : "wb"); |
| 1310 | if (tagf == NULL) | 1297 | if (tagf == NULL) |
| 1311 | pfatal (tagfile); | 1298 | pfatal (tagfile); |
| 1312 | put_entries (nodehead); /* write all the tags (CTAGS) */ | 1299 | put_entries (nodehead); /* write all the tags (CTAGS) */ |
| @@ -1547,11 +1534,11 @@ process_file_name (char *file, language *lang) | |||
| 1547 | if (real_name == compressed_name) | 1534 | if (real_name == compressed_name) |
| 1548 | { | 1535 | { |
| 1549 | char *cmd = concat (compr->command, " ", real_name); | 1536 | char *cmd = concat (compr->command, " ", real_name); |
| 1550 | inf = (FILE *) popen (cmd, "r"); | 1537 | inf = popen (cmd, "rb"); |
| 1551 | free (cmd); | 1538 | free (cmd); |
| 1552 | } | 1539 | } |
| 1553 | else | 1540 | else |
| 1554 | inf = fopen (real_name, "r"); | 1541 | inf = fopen (real_name, "rb"); |
| 1555 | if (inf == NULL) | 1542 | if (inf == NULL) |
| 1556 | { | 1543 | { |
| 1557 | perror (real_name); | 1544 | perror (real_name); |
| @@ -4747,6 +4734,9 @@ Lisp_functions (FILE *inf) | |||
| 4747 | } | 4734 | } |
| 4748 | } | 4735 | } |
| 4749 | 4736 | ||
| 4737 | if (strneq (dbp + 1, "cl-", 3) || strneq (dbp + 1, "CL-", 3)) | ||
| 4738 | dbp += 3; | ||
| 4739 | |||
| 4750 | if (strneq (dbp+1, "def", 3) || strneq (dbp+1, "DEF", 3)) | 4740 | if (strneq (dbp+1, "def", 3) || strneq (dbp+1, "DEF", 3)) |
| 4751 | { | 4741 | { |
| 4752 | dbp = skip_non_spaces (dbp); | 4742 | dbp = skip_non_spaces (dbp); |
| @@ -5611,7 +5601,7 @@ analyse_regex (char *regex_arg) | |||
| 5611 | char *regexfile = regex_arg + 1; | 5601 | char *regexfile = regex_arg + 1; |
| 5612 | 5602 | ||
| 5613 | /* regexfile is a file containing regexps, one per line. */ | 5603 | /* regexfile is a file containing regexps, one per line. */ |
| 5614 | regexfp = fopen (regexfile, "r"); | 5604 | regexfp = fopen (regexfile, "rb"); |
| 5615 | if (regexfp == NULL) | 5605 | if (regexfp == NULL) |
| 5616 | pfatal (regexfile); | 5606 | pfatal (regexfile); |
| 5617 | linebuffer_init (®exbuf); | 5607 | linebuffer_init (®exbuf); |
diff --git a/lib-src/hexl.c b/lib-src/hexl.c index 9e21ddf9de6..51744ab08a2 100644 --- a/lib-src/hexl.c +++ b/lib-src/hexl.c | |||
| @@ -24,15 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 24 | 24 | ||
| 25 | #include <stdio.h> | 25 | #include <stdio.h> |
| 26 | #include <ctype.h> | 26 | #include <ctype.h> |
| 27 | #ifdef DOS_NT | 27 | |
| 28 | #include <fcntl.h> | 28 | #include <binary-io.h> |
| 29 | #if __DJGPP__ >= 2 | ||
| 30 | #include <io.h> | ||
| 31 | #endif | ||
| 32 | #endif | ||
| 33 | #ifdef WINDOWSNT | ||
| 34 | #include <io.h> | ||
| 35 | #endif | ||
| 36 | 29 | ||
| 37 | #define DEFAULT_GROUPING 0x01 | 30 | #define DEFAULT_GROUPING 0x01 |
| 38 | #define DEFAULT_BASE 16 | 31 | #define DEFAULT_BASE 16 |
| @@ -155,20 +148,12 @@ main (int argc, char **argv) | |||
| 155 | 148 | ||
| 156 | if (un_flag) | 149 | if (un_flag) |
| 157 | { | 150 | { |
| 158 | char buf[18]; | 151 | SET_BINARY (fileno (stdout)); |
| 159 | 152 | ||
| 160 | #ifdef DOS_NT | ||
| 161 | #if (__DJGPP__ >= 2) || (defined WINDOWSNT) | ||
| 162 | if (!isatty (fileno (stdout))) | ||
| 163 | setmode (fileno (stdout), O_BINARY); | ||
| 164 | #else | ||
| 165 | (stdout)->_flag &= ~_IOTEXT; /* print binary */ | ||
| 166 | _setmode (fileno (stdout), O_BINARY); | ||
| 167 | #endif | ||
| 168 | #endif | ||
| 169 | for (;;) | 153 | for (;;) |
| 170 | { | 154 | { |
| 171 | register int i, c = 0, d; | 155 | int i, c = 0, d; |
| 156 | char buf[18]; | ||
| 172 | 157 | ||
| 173 | #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10) | 158 | #define hexchar(x) (isdigit (x) ? x - '0' : x - 'a' + 10) |
| 174 | 159 | ||
| @@ -210,15 +195,7 @@ main (int argc, char **argv) | |||
| 210 | } | 195 | } |
| 211 | else | 196 | else |
| 212 | { | 197 | { |
| 213 | #ifdef DOS_NT | 198 | SET_BINARY (fileno (fp)); |
| 214 | #if (__DJGPP__ >= 2) || (defined WINDOWSNT) | ||
| 215 | if (!isatty (fileno (fp))) | ||
| 216 | setmode (fileno (fp), O_BINARY); | ||
| 217 | #else | ||
| 218 | (fp)->_flag &= ~_IOTEXT; /* read binary */ | ||
| 219 | _setmode (fileno (fp), O_BINARY); | ||
| 220 | #endif | ||
| 221 | #endif | ||
| 222 | address = 0; | 199 | address = 0; |
| 223 | string[0] = ' '; | 200 | string[0] = ' '; |
| 224 | string[17] = '\0'; | 201 | string[17] = '\0'; |
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 15ffa138b51..884b6c1001e 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c | |||
| @@ -38,17 +38,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 38 | 38 | ||
| 39 | #include <stdio.h> | 39 | #include <stdio.h> |
| 40 | #include <stdlib.h> /* config.h unconditionally includes this anyway */ | 40 | #include <stdlib.h> /* config.h unconditionally includes this anyway */ |
| 41 | #ifdef MSDOS | 41 | |
| 42 | #include <fcntl.h> | ||
| 43 | #endif /* MSDOS */ | ||
| 44 | #ifdef WINDOWSNT | 42 | #ifdef WINDOWSNT |
| 45 | /* Defined to be sys_fopen in ms-w32.h, but only #ifdef emacs, so this | 43 | /* Defined to be sys_fopen in ms-w32.h, but only #ifdef emacs, so this |
| 46 | is really just insurance. */ | 44 | is really just insurance. */ |
| 47 | #undef fopen | 45 | #undef fopen |
| 48 | #include <fcntl.h> | ||
| 49 | #include <direct.h> | 46 | #include <direct.h> |
| 50 | #endif /* WINDOWSNT */ | 47 | #endif /* WINDOWSNT */ |
| 51 | 48 | ||
| 49 | #include <binary-io.h> | ||
| 50 | |||
| 52 | #ifdef DOS_NT | 51 | #ifdef DOS_NT |
| 53 | /* Defined to be sys_chdir in ms-w32.h, but only #ifdef emacs, so this | 52 | /* Defined to be sys_chdir in ms-w32.h, but only #ifdef emacs, so this |
| 54 | is really just insurance. | 53 | is really just insurance. |
| @@ -56,12 +55,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 56 | Similarly, msdos defines this as sys_chdir, but we're not linking with the | 55 | Similarly, msdos defines this as sys_chdir, but we're not linking with the |
| 57 | file where that function is defined. */ | 56 | file where that function is defined. */ |
| 58 | #undef chdir | 57 | #undef chdir |
| 59 | #define READ_TEXT "rt" | ||
| 60 | #define READ_BINARY "rb" | ||
| 61 | #define IS_SLASH(c) ((c) == '/' || (c) == '\\' || (c) == ':') | 58 | #define IS_SLASH(c) ((c) == '/' || (c) == '\\' || (c) == ':') |
| 62 | #else /* not DOS_NT */ | 59 | #else /* not DOS_NT */ |
| 63 | #define READ_TEXT "r" | ||
| 64 | #define READ_BINARY "r" | ||
| 65 | #define IS_SLASH(c) ((c) == '/') | 60 | #define IS_SLASH(c) ((c) == '/') |
| 66 | #endif /* not DOS_NT */ | 61 | #endif /* not DOS_NT */ |
| 67 | 62 | ||
| @@ -73,9 +68,6 @@ static void write_globals (void); | |||
| 73 | 68 | ||
| 74 | #include <unistd.h> | 69 | #include <unistd.h> |
| 75 | 70 | ||
| 76 | /* Stdio stream for output to the DOC file. */ | ||
| 77 | FILE *outfile; | ||
| 78 | |||
| 79 | /* Name this program was invoked with. */ | 71 | /* Name this program was invoked with. */ |
| 80 | char *progname; | 72 | char *progname; |
| 81 | 73 | ||
| @@ -135,33 +127,24 @@ main (int argc, char **argv) | |||
| 135 | 127 | ||
| 136 | progname = argv[0]; | 128 | progname = argv[0]; |
| 137 | 129 | ||
| 138 | outfile = stdout; | ||
| 139 | |||
| 140 | /* Don't put CRs in the DOC file. */ | ||
| 141 | #ifdef MSDOS | ||
| 142 | _fmode = O_BINARY; | ||
| 143 | #if 0 /* Suspicion is that this causes hanging. | ||
| 144 | So instead we require people to use -o on MSDOS. */ | ||
| 145 | (stdout)->_flag &= ~_IOTEXT; | ||
| 146 | _setmode (fileno (stdout), O_BINARY); | ||
| 147 | #endif | ||
| 148 | outfile = 0; | ||
| 149 | #endif /* MSDOS */ | ||
| 150 | #ifdef WINDOWSNT | ||
| 151 | _fmode = O_BINARY; | ||
| 152 | _setmode (fileno (stdout), O_BINARY); | ||
| 153 | #endif /* WINDOWSNT */ | ||
| 154 | |||
| 155 | /* If first two args are -o FILE, output to FILE. */ | 130 | /* If first two args are -o FILE, output to FILE. */ |
| 156 | i = 1; | 131 | i = 1; |
| 157 | if (argc > i + 1 && !strcmp (argv[i], "-o")) | 132 | if (argc > i + 1 && !strcmp (argv[i], "-o")) |
| 158 | { | 133 | { |
| 159 | outfile = fopen (argv[i + 1], "w"); | 134 | if (! freopen (argv[i + 1], "w", stdout)) |
| 135 | { | ||
| 136 | perror (argv[i + 1]); | ||
| 137 | return EXIT_FAILURE; | ||
| 138 | } | ||
| 160 | i += 2; | 139 | i += 2; |
| 161 | } | 140 | } |
| 162 | if (argc > i + 1 && !strcmp (argv[i], "-a")) | 141 | if (argc > i + 1 && !strcmp (argv[i], "-a")) |
| 163 | { | 142 | { |
| 164 | outfile = fopen (argv[i + 1], "a"); | 143 | if (! freopen (argv[i + 1], "a", stdout)) |
| 144 | { | ||
| 145 | perror (argv[i + 1]); | ||
| 146 | return EXIT_FAILURE; | ||
| 147 | } | ||
| 165 | i += 2; | 148 | i += 2; |
| 166 | } | 149 | } |
| 167 | if (argc > i + 1 && !strcmp (argv[i], "-d")) | 150 | if (argc > i + 1 && !strcmp (argv[i], "-d")) |
| @@ -179,8 +162,7 @@ main (int argc, char **argv) | |||
| 179 | ++i; | 162 | ++i; |
| 180 | } | 163 | } |
| 181 | 164 | ||
| 182 | if (outfile == 0) | 165 | set_binary_mode (fileno (stdout), O_BINARY); |
| 183 | fatal ("No output file specified", ""); | ||
| 184 | 166 | ||
| 185 | if (generate_globals) | 167 | if (generate_globals) |
| 186 | start_globals (); | 168 | start_globals (); |
| @@ -215,13 +197,11 @@ put_filename (char *filename) | |||
| 215 | filename = tmp + 1; | 197 | filename = tmp + 1; |
| 216 | } | 198 | } |
| 217 | 199 | ||
| 218 | putc (037, outfile); | 200 | printf ("\037S%s\n", filename); |
| 219 | putc ('S', outfile); | ||
| 220 | fprintf (outfile, "%s\n", filename); | ||
| 221 | } | 201 | } |
| 222 | 202 | ||
| 223 | /* Read file FILENAME and output its doc strings to outfile. */ | 203 | /* Read file FILENAME and output its doc strings to stdout. |
| 224 | /* Return 1 if file is not found, 0 if it is found. */ | 204 | Return 1 if file is not found, 0 if it is found. */ |
| 225 | 205 | ||
| 226 | static int | 206 | static int |
| 227 | scan_file (char *filename) | 207 | scan_file (char *filename) |
| @@ -232,19 +212,19 @@ scan_file (char *filename) | |||
| 232 | if (!generate_globals) | 212 | if (!generate_globals) |
| 233 | put_filename (filename); | 213 | put_filename (filename); |
| 234 | if (len > 4 && !strcmp (filename + len - 4, ".elc")) | 214 | if (len > 4 && !strcmp (filename + len - 4, ".elc")) |
| 235 | return scan_lisp_file (filename, READ_BINARY); | 215 | return scan_lisp_file (filename, "rb"); |
| 236 | else if (len > 3 && !strcmp (filename + len - 3, ".el")) | 216 | else if (len > 3 && !strcmp (filename + len - 3, ".el")) |
| 237 | return scan_lisp_file (filename, READ_TEXT); | 217 | return scan_lisp_file (filename, "r"); |
| 238 | else | 218 | else |
| 239 | return scan_c_file (filename, READ_TEXT); | 219 | return scan_c_file (filename, "r"); |
| 240 | } | 220 | } |
| 241 | 221 | ||
| 242 | static void | 222 | static void |
| 243 | start_globals (void) | 223 | start_globals (void) |
| 244 | { | 224 | { |
| 245 | fprintf (outfile, "/* This file was auto-generated by make-docfile. */\n"); | 225 | puts ("/* This file was auto-generated by make-docfile. */"); |
| 246 | fprintf (outfile, "/* DO NOT EDIT. */\n"); | 226 | puts ("/* DO NOT EDIT. */"); |
| 247 | fprintf (outfile, "struct emacs_globals {\n"); | 227 | puts ("struct emacs_globals {"); |
| 248 | } | 228 | } |
| 249 | 229 | ||
| 250 | static char input_buffer[128]; | 230 | static char input_buffer[128]; |
| @@ -373,7 +353,7 @@ scan_keyword_or_put_char (int ch, struct rcsoc_state *state) | |||
| 373 | 353 | ||
| 374 | /* Skip a C string or C-style comment from INFILE, and return the | 354 | /* Skip a C string or C-style comment from INFILE, and return the |
| 375 | character that follows. COMMENT non-zero means skip a comment. If | 355 | character that follows. COMMENT non-zero means skip a comment. If |
| 376 | PRINTFLAG is positive, output string contents to outfile. If it is | 356 | PRINTFLAG is positive, output string contents to stdout. If it is |
| 377 | negative, store contents in buf. Convert escape sequences \n and | 357 | negative, store contents in buf. Convert escape sequences \n and |
| 378 | \t to newline and tab; discard \ followed by newline. | 358 | \t to newline and tab; discard \ followed by newline. |
| 379 | If SAW_USAGE is non-zero, then any occurrences of the string `usage:' | 359 | If SAW_USAGE is non-zero, then any occurrences of the string `usage:' |
| @@ -388,7 +368,7 @@ read_c_string_or_comment (FILE *infile, int printflag, int comment, int *saw_usa | |||
| 388 | 368 | ||
| 389 | state.in_file = infile; | 369 | state.in_file = infile; |
| 390 | state.buf_ptr = (printflag < 0 ? input_buffer : 0); | 370 | state.buf_ptr = (printflag < 0 ? input_buffer : 0); |
| 391 | state.out_file = (printflag > 0 ? outfile : 0); | 371 | state.out_file = (printflag > 0 ? stdout : 0); |
| 392 | state.pending_spaces = 0; | 372 | state.pending_spaces = 0; |
| 393 | state.pending_newlines = 0; | 373 | state.pending_newlines = 0; |
| 394 | state.keyword = (saw_usage ? "usage:" : 0); | 374 | state.keyword = (saw_usage ? "usage:" : 0); |
| @@ -465,18 +445,18 @@ read_c_string_or_comment (FILE *infile, int printflag, int comment, int *saw_usa | |||
| 465 | 445 | ||
| 466 | 446 | ||
| 467 | 447 | ||
| 468 | /* Write to file OUT the argument names of function FUNC, whose text is in BUF. | 448 | /* Write to stdout the argument names of function FUNC, whose text is in BUF. |
| 469 | MINARGS and MAXARGS are the minimum and maximum number of arguments. */ | 449 | MINARGS and MAXARGS are the minimum and maximum number of arguments. */ |
| 470 | 450 | ||
| 471 | static void | 451 | static void |
| 472 | write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) | 452 | write_c_args (char *func, char *buf, int minargs, int maxargs) |
| 473 | { | 453 | { |
| 474 | register char *p; | 454 | register char *p; |
| 475 | int in_ident = 0; | 455 | int in_ident = 0; |
| 476 | char *ident_start IF_LINT (= NULL); | 456 | char *ident_start IF_LINT (= NULL); |
| 477 | size_t ident_length = 0; | 457 | size_t ident_length = 0; |
| 478 | 458 | ||
| 479 | fprintf (out, "(fn"); | 459 | fputs ("(fn", stdout); |
| 480 | 460 | ||
| 481 | if (*buf == '(') | 461 | if (*buf == '(') |
| 482 | ++buf; | 462 | ++buf; |
| @@ -517,10 +497,10 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) | |||
| 517 | if (strncmp (ident_start, "void", ident_length) == 0) | 497 | if (strncmp (ident_start, "void", ident_length) == 0) |
| 518 | continue; | 498 | continue; |
| 519 | 499 | ||
| 520 | putc (' ', out); | 500 | putchar (' '); |
| 521 | 501 | ||
| 522 | if (minargs == 0 && maxargs > 0) | 502 | if (minargs == 0 && maxargs > 0) |
| 523 | fprintf (out, "&optional "); | 503 | fputs ("&optional ", stdout); |
| 524 | 504 | ||
| 525 | minargs--; | 505 | minargs--; |
| 526 | maxargs--; | 506 | maxargs--; |
| @@ -528,7 +508,7 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) | |||
| 528 | /* In C code, `default' is a reserved word, so we spell it | 508 | /* In C code, `default' is a reserved word, so we spell it |
| 529 | `defalt'; demangle that here. */ | 509 | `defalt'; demangle that here. */ |
| 530 | if (ident_length == 6 && memcmp (ident_start, "defalt", 6) == 0) | 510 | if (ident_length == 6 && memcmp (ident_start, "defalt", 6) == 0) |
| 531 | fprintf (out, "DEFAULT"); | 511 | fputs ("DEFAULT", stdout); |
| 532 | else | 512 | else |
| 533 | while (ident_length-- > 0) | 513 | while (ident_length-- > 0) |
| 534 | { | 514 | { |
| @@ -539,12 +519,12 @@ write_c_args (FILE *out, char *func, char *buf, int minargs, int maxargs) | |||
| 539 | else if (c == '_') | 519 | else if (c == '_') |
| 540 | /* Print underscore as hyphen. */ | 520 | /* Print underscore as hyphen. */ |
| 541 | c = '-'; | 521 | c = '-'; |
| 542 | putc (c, out); | 522 | putchar (c); |
| 543 | } | 523 | } |
| 544 | } | 524 | } |
| 545 | } | 525 | } |
| 546 | 526 | ||
| 547 | putc (')', out); | 527 | putchar (')'); |
| 548 | } | 528 | } |
| 549 | 529 | ||
| 550 | /* The types of globals. These are sorted roughly in decreasing alignment | 530 | /* The types of globals. These are sorted roughly in decreasing alignment |
| @@ -613,8 +593,8 @@ compare_globals (const void *a, const void *b) | |||
| 613 | static void | 593 | static void |
| 614 | close_emacs_globals (void) | 594 | close_emacs_globals (void) |
| 615 | { | 595 | { |
| 616 | fprintf (outfile, "};\n"); | 596 | puts ("};"); |
| 617 | fprintf (outfile, "extern struct emacs_globals globals;\n"); | 597 | puts ("extern struct emacs_globals globals;"); |
| 618 | } | 598 | } |
| 619 | 599 | ||
| 620 | static void | 600 | static void |
| @@ -641,7 +621,7 @@ write_globals (void) | |||
| 641 | if (!seen_defun) | 621 | if (!seen_defun) |
| 642 | { | 622 | { |
| 643 | close_emacs_globals (); | 623 | close_emacs_globals (); |
| 644 | fprintf (outfile, "\n"); | 624 | putchar ('\n'); |
| 645 | seen_defun = 1; | 625 | seen_defun = 1; |
| 646 | } | 626 | } |
| 647 | break; | 627 | break; |
| @@ -651,9 +631,9 @@ write_globals (void) | |||
| 651 | 631 | ||
| 652 | if (type) | 632 | if (type) |
| 653 | { | 633 | { |
| 654 | fprintf (outfile, " %s f_%s;\n", type, globals[i].name); | 634 | printf (" %s f_%s;\n", type, globals[i].name); |
| 655 | fprintf (outfile, "#define %s globals.f_%s\n", | 635 | printf ("#define %s globals.f_%s\n", |
| 656 | globals[i].name, globals[i].name); | 636 | globals[i].name, globals[i].name); |
| 657 | } | 637 | } |
| 658 | else | 638 | else |
| 659 | { | 639 | { |
| @@ -664,16 +644,16 @@ write_globals (void) | |||
| 664 | || strcmp (globals[i].name, "Fkill_emacs") == 0 | 644 | || strcmp (globals[i].name, "Fkill_emacs") == 0 |
| 665 | || strcmp (globals[i].name, "Fexit_recursive_edit") == 0 | 645 | || strcmp (globals[i].name, "Fexit_recursive_edit") == 0 |
| 666 | || strcmp (globals[i].name, "Fabort_recursive_edit") == 0) | 646 | || strcmp (globals[i].name, "Fabort_recursive_edit") == 0) |
| 667 | fprintf (outfile, "_Noreturn "); | 647 | fputs ("_Noreturn ", stdout); |
| 668 | 648 | ||
| 669 | fprintf (outfile, "EXFUN (%s, ", globals[i].name); | 649 | printf ("EXFUN (%s, ", globals[i].name); |
| 670 | if (globals[i].value == -1) | 650 | if (globals[i].value == -1) |
| 671 | fprintf (outfile, "MANY"); | 651 | fputs ("MANY", stdout); |
| 672 | else if (globals[i].value == -2) | 652 | else if (globals[i].value == -2) |
| 673 | fprintf (outfile, "UNEVALLED"); | 653 | fputs ("UNEVALLED", stdout); |
| 674 | else | 654 | else |
| 675 | fprintf (outfile, "%d", globals[i].value); | 655 | printf ("%d", globals[i].value); |
| 676 | fprintf (outfile, ")"); | 656 | putchar (')'); |
| 677 | 657 | ||
| 678 | /* It would be nice to have a cleaner way to deal with these | 658 | /* It would be nice to have a cleaner way to deal with these |
| 679 | special hacks, too. */ | 659 | special hacks, too. */ |
| @@ -681,9 +661,9 @@ write_globals (void) | |||
| 681 | || strcmp (globals[i].name, "Ftool_bar_height") == 0 | 661 | || strcmp (globals[i].name, "Ftool_bar_height") == 0 |
| 682 | || strcmp (globals[i].name, "Fmax_char") == 0 | 662 | || strcmp (globals[i].name, "Fmax_char") == 0 |
| 683 | || strcmp (globals[i].name, "Fidentity") == 0) | 663 | || strcmp (globals[i].name, "Fidentity") == 0) |
| 684 | fprintf (outfile, " ATTRIBUTE_CONST"); | 664 | fputs (" ATTRIBUTE_CONST", stdout); |
| 685 | 665 | ||
| 686 | fprintf (outfile, ";\n"); | 666 | puts (";"); |
| 687 | } | 667 | } |
| 688 | 668 | ||
| 689 | while (i + 1 < num_globals | 669 | while (i + 1 < num_globals |
| @@ -952,9 +932,7 @@ scan_c_file (char *filename, const char *mode) | |||
| 952 | int comment = c != '"'; | 932 | int comment = c != '"'; |
| 953 | int saw_usage; | 933 | int saw_usage; |
| 954 | 934 | ||
| 955 | putc (037, outfile); | 935 | printf ("\037%c%s\n", defvarflag ? 'V' : 'F', input_buffer); |
| 956 | putc (defvarflag ? 'V' : 'F', outfile); | ||
| 957 | fprintf (outfile, "%s\n", input_buffer); | ||
| 958 | 936 | ||
| 959 | if (comment) | 937 | if (comment) |
| 960 | getc (infile); /* Skip past `*'. */ | 938 | getc (infile); /* Skip past `*'. */ |
| @@ -996,8 +974,8 @@ scan_c_file (char *filename, const char *mode) | |||
| 996 | while (c != ')'); | 974 | while (c != ')'); |
| 997 | *p = '\0'; | 975 | *p = '\0'; |
| 998 | /* Output them. */ | 976 | /* Output them. */ |
| 999 | fprintf (outfile, "\n\n"); | 977 | fputs ("\n\n", stdout); |
| 1000 | write_c_args (outfile, input_buffer, argbuf, minargs, maxargs); | 978 | write_c_args (input_buffer, argbuf, minargs, maxargs); |
| 1001 | } | 979 | } |
| 1002 | else if (defunflag && maxargs == -1 && !saw_usage) | 980 | else if (defunflag && maxargs == -1 && !saw_usage) |
| 1003 | /* The DOC should provide the usage form. */ | 981 | /* The DOC should provide the usage form. */ |
| @@ -1433,12 +1411,10 @@ scan_lisp_file (const char *filename, const char *mode) | |||
| 1433 | In the latter case, the opening quote (and leading backslash-newline) | 1411 | In the latter case, the opening quote (and leading backslash-newline) |
| 1434 | have already been read. */ | 1412 | have already been read. */ |
| 1435 | 1413 | ||
| 1436 | putc (037, outfile); | 1414 | printf ("\037%c%s\n", type, buffer); |
| 1437 | putc (type, outfile); | ||
| 1438 | fprintf (outfile, "%s\n", buffer); | ||
| 1439 | if (saved_string) | 1415 | if (saved_string) |
| 1440 | { | 1416 | { |
| 1441 | fputs (saved_string, outfile); | 1417 | fputs (saved_string, stdout); |
| 1442 | /* Don't use one dynamic doc string twice. */ | 1418 | /* Don't use one dynamic doc string twice. */ |
| 1443 | free (saved_string); | 1419 | free (saved_string); |
| 1444 | saved_string = 0; | 1420 | saved_string = 0; |
diff --git a/lib-src/movemail.c b/lib-src/movemail.c index d0d00fcf4cc..c600fc0ea53 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c | |||
| @@ -191,11 +191,6 @@ main (int argc, char **argv) | |||
| 191 | uid_t real_gid = getgid (); | 191 | uid_t real_gid = getgid (); |
| 192 | uid_t priv_gid = getegid (); | 192 | uid_t priv_gid = getegid (); |
| 193 | 193 | ||
| 194 | #ifdef WINDOWSNT | ||
| 195 | /* Ensure all file i/o is in binary mode. */ | ||
| 196 | _fmode = _O_BINARY; | ||
| 197 | #endif | ||
| 198 | |||
| 199 | delete_lockname = 0; | 194 | delete_lockname = 0; |
| 200 | 195 | ||
| 201 | while ((c = getopt (argc, argv, ARGSTR)) != EOF) | 196 | while ((c = getopt (argc, argv, ARGSTR)) != EOF) |
| @@ -304,7 +299,7 @@ main (int argc, char **argv) | |||
| 304 | 299 | ||
| 305 | memcpy (tempname, inname, inname_dirlen); | 300 | memcpy (tempname, inname, inname_dirlen); |
| 306 | strcpy (tempname + inname_dirlen, "EXXXXXX"); | 301 | strcpy (tempname + inname_dirlen, "EXXXXXX"); |
| 307 | desc = mkostemp (tempname, 0); | 302 | desc = mkostemp (tempname, O_BINARY); |
| 308 | if (desc < 0) | 303 | if (desc < 0) |
| 309 | { | 304 | { |
| 310 | int mkostemp_errno = errno; | 305 | int mkostemp_errno = errno; |
| @@ -358,12 +353,12 @@ main (int argc, char **argv) | |||
| 358 | 353 | ||
| 359 | #ifndef MAIL_USE_MMDF | 354 | #ifndef MAIL_USE_MMDF |
| 360 | #ifdef MAIL_USE_SYSTEM_LOCK | 355 | #ifdef MAIL_USE_SYSTEM_LOCK |
| 361 | indesc = open (inname, O_RDWR); | 356 | indesc = open (inname, O_RDWR | O_BINARY); |
| 362 | #else /* if not MAIL_USE_SYSTEM_LOCK */ | 357 | #else /* if not MAIL_USE_SYSTEM_LOCK */ |
| 363 | indesc = open (inname, O_RDONLY); | 358 | indesc = open (inname, O_RDONLY | O_BINARY); |
| 364 | #endif /* not MAIL_USE_SYSTEM_LOCK */ | 359 | #endif /* not MAIL_USE_SYSTEM_LOCK */ |
| 365 | #else /* MAIL_USE_MMDF */ | 360 | #else /* MAIL_USE_MMDF */ |
| 366 | indesc = lk_open (inname, O_RDONLY, 0, 0, 10); | 361 | indesc = lk_open (inname, O_RDONLY | O_BINARY, 0, 0, 10); |
| 367 | #endif /* MAIL_USE_MMDF */ | 362 | #endif /* MAIL_USE_MMDF */ |
| 368 | 363 | ||
| 369 | if (indesc < 0) | 364 | if (indesc < 0) |
| @@ -372,7 +367,7 @@ main (int argc, char **argv) | |||
| 372 | /* Make sure the user can read the output file. */ | 367 | /* Make sure the user can read the output file. */ |
| 373 | umask (umask (0) & 0377); | 368 | umask (umask (0) & 0377); |
| 374 | 369 | ||
| 375 | outdesc = open (outname, O_WRONLY | O_CREAT | O_EXCL, 0666); | 370 | outdesc = open (outname, O_WRONLY | O_BINARY | O_CREAT | O_EXCL, 0666); |
| 376 | if (outdesc < 0) | 371 | if (outdesc < 0) |
| 377 | pfatal_with_name (outname); | 372 | pfatal_with_name (outname); |
| 378 | 373 | ||
| @@ -675,7 +670,7 @@ popmail (char *mailbox, char *outfile, int preserve, char *password, int reverse | |||
| 675 | return EXIT_SUCCESS; | 670 | return EXIT_SUCCESS; |
| 676 | } | 671 | } |
| 677 | 672 | ||
| 678 | mbfi = open (outfile, O_WRONLY | O_CREAT | O_EXCL, 0666); | 673 | mbfi = open (outfile, O_WRONLY | O_BINARY | O_CREAT | O_EXCL, 0666); |
| 679 | if (mbfi < 0) | 674 | if (mbfi < 0) |
| 680 | { | 675 | { |
| 681 | pop_close (server); | 676 | pop_close (server); |