Mercurial > hg > xemacs-beta
annotate lib-src/cvtmail.c @ 5652:cc6f0266bc36
Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
lisp/ChangeLog addition:
2012-05-01 Aidan Kehoe <kehoea@parhasard.net>
Avoid #'delq in core code, for the sake of style and a (very
slightly) smaller binary.
* behavior.el (disable-behavior):
* behavior.el (compute-behavior-group-children):
* buff-menu.el (buffers-tab-items):
* byte-optimize.el (byte-optimize-delay-constants-math):
* byte-optimize.el (byte-optimize-logmumble):
* byte-optimize.el (byte-decompile-bytecode-1):
* byte-optimize.el (byte-optimize-lapcode):
* bytecomp.el:
* bytecomp.el (byte-compile-arglist-warn):
* bytecomp.el (byte-compile-warn-about-unresolved-functions):
* bytecomp.el (byte-compile-lambda):
* bytecomp.el (byte-compile-out-toplevel):
* bytecomp.el (byte-compile-insert):
* bytecomp.el (byte-compile-defalias-warn):
* cl-macs.el (cl-upcase-arg):
* cl-macs.el (cl-transform-lambda):
* cl-macs.el (cl-do-proclaim):
* cl-macs.el (defstruct):
* cl-macs.el (cl-make-type-test):
* cl-macs.el (define-compiler-macro):
* cl-macs.el (delete-duplicates):
* cus-edit.el (widget-face-value-delete):
* cus-edit.el (face-history):
* easymenu.el (easy-menu-remove):
* files.el (files-fetch-hook-value):
* files.el (file-expand-wildcards):
* font-lock.el (font-lock-update-removed-keyword-alist):
* font-lock.el (font-lock-remove-keywords):
* frame.el (frame-initialize):
* frame.el (frame-notice-user-settings):
* frame.el (set-frame-font):
* frame.el (delete-other-frames):
* frame.el (get-frame-for-buffer-noselect):
* gnuserv.el (gnuserv-kill-buffer-function):
* gnuserv.el (gnuserv-check-device):
* gnuserv.el (gnuserv-kill-client):
* gnuserv.el (gnuserv-buffer-done-1):
* gtk-font-menu.el (gtk-reset-device-font-menus):
* gutter-items.el (buffers-tab-items):
* gutter.el (set-gutter-element-visible-p):
* info.el (Info-find-file-node):
* info.el (Info-history-add):
* info.el (Info-build-annotation-completions):
* info.el (Info-index):
* info.el (Info-reannotate-node):
* itimer.el (delete-itimer):
* itimer.el (start-itimer):
* lib-complete.el (lib-complete:cache-completions):
* loadhist.el (unload-feature):
* menubar-items.el (build-buffers-menu-internal):
* menubar.el (delete-menu-item):
* menubar.el (relabel-menu-item):
* msw-font-menu.el (mswindows-reset-device-font-menus):
* mule/make-coding-system.el (fixed-width-generate-helper):
* next-error.el (next-error-find-buffer):
* obsolete.el:
* obsolete.el (find-non-ascii-charset-string):
* obsolete.el (find-non-ascii-charset-region):
* occur.el (multi-occur-by-filename-regexp):
* occur.el (occur-1):
* packages.el (packages-package-hierarchy-directory-names):
* packages.el (package-get-key-1):
* process.el (setenv):
* simple.el (undo):
* simple.el (handle-pre-motion-command-current-command-is-motion):
* sound.el (load-sound-file):
* wid-edit.el (widget-field-value-delete):
* wid-edit.el (widget-checklist-match-inline):
* wid-edit.el (widget-checklist-match-find):
* wid-edit.el (widget-editable-list-delete-at):
* wid-edit.el (widget-editable-list-entry-create):
* window.el (quit-window):
* x-font-menu.el (x-reset-device-font-menus-core):
1. Replace (delq nil (mapcar ....)) with analogous (mapcan ...)
forms; this is in non-dumped files, it was done previously in
dumped files.
2. Replace (delq FOO (copy-sequence BAR)) with (remove* FOO BAR),
where #'eq and #'eql are equivalent
3. Replace (delq FOO BAR) with (delete* FOO BAR), where FOO is not
a non-fixnum number. Saves a little space in the dumped file
(since the compiler macro adds :test #'eq to the delete* call if
it's not clear that FOO is not a non-fixnum number).
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Tue, 01 May 2012 16:17:42 +0100 |
parents | b9167d522a9a |
children |
rev | line source |
---|---|
428 | 1 /* Copyright (C) 1985, 1993, 1994 Free Software Foundation |
613 | 2 This file is part of XEmacs. |
428 | 3 |
5406
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
4 XEmacs is free software: you can redistribute it and/or modify it |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
5 under the terms of the GNU General Public License as published by the |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
6 Free Software Foundation, either version 3 of the License, or (at your |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
7 option) any later version. |
428 | 8 |
5406
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
9 XEmacs is distributed in the hope that it will be useful, but WITHOUT |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
12 for more details. |
428 | 13 |
14 You should have received a copy of the GNU General Public License | |
5406
061f4f90f874
Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
613
diff
changeset
|
15 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 16 |
17 /* Synched up with: FSF 19.28. */ | |
18 | |
19 /* cvtmail: | |
20 * Program to convert oldstyle goslings emacs mail directories into | |
21 * gnu-rmail format. Program expects a directory called Messages to | |
22 * exist in your home directory, containing individual mail messages in | |
23 * separate files in the standard gosling emacs mail reader format. | |
24 * | |
442 | 25 * Program takes one argument: an output file. This file will contain |
428 | 26 * all the messages in Messages directory, in berkeley mail format. |
27 * If no output file is mentioned, messages are put in ~/OMAIL. | |
28 * | |
29 * In order to get rmail to read the messages, the resulting file must | |
30 * be mv'ed to ~/mbox, and then have rmail invoked on them. | |
442 | 31 * |
428 | 32 * Author: Larry Kolodney, 1985 |
33 */ | |
34 | |
35 | |
438 | 36 #include <config.h> |
428 | 37 |
38 #include <stdio.h> | |
39 #include <string.h> | |
438 | 40 #include <stdlib.h> |
428 | 41 |
440 | 42 static void *xmalloc (size_t); |
43 static void *xrealloc (void *, size_t); | |
428 | 44 static void skip_to_lf (FILE *stream); |
442 | 45 static void fatal (const char *s1, const char *s2); |
46 static void error (const char *s1, const char *s2); | |
428 | 47 |
48 int | |
49 main (int argc, char *argv[]) | |
50 { | |
51 char *hd; | |
52 char *md; | |
53 char *mdd; | |
54 char *mfile; | |
55 char *cf; | |
56 int cflen; | |
57 FILE *mddf; | |
58 FILE *mfilef; | |
59 FILE *cff; | |
60 char pre[10]; | |
61 char name[14]; | |
62 int c; | |
63 | |
438 | 64 hd = getenv ("HOME"); |
428 | 65 |
66 md = (char *) xmalloc (strlen (hd) + 10); | |
67 strcpy (md, hd); | |
68 strcat (md, "/Messages"); | |
69 | |
70 mdd = (char *) xmalloc (strlen (md) + 11); | |
71 strcpy (mdd, md); | |
72 strcat (mdd, "/Directory"); | |
73 | |
74 cflen = 100; | |
75 cf = (char *) xmalloc (cflen); | |
76 | |
77 mddf = fopen (mdd, "r"); | |
78 if (argc > 1) | |
79 mfilef = fopen (argv[1], "w"); | |
80 else | |
81 { | |
82 mfile = (char *) xmalloc (strlen (hd) + 7); | |
83 strcpy (mfile, hd); | |
84 strcat (mfile, "/OMAIL"); | |
85 mfilef = fopen (mfile, "w"); | |
86 } | |
87 skip_to_lf (mddf); | |
88 while (fscanf (mddf, "%4c%14[0123456789]", pre, name) != EOF) | |
89 { | |
90 int comp_len = strlen (md) + strlen (name) + 2; | |
91 if (cflen < comp_len) | |
92 { | |
93 cflen = strlen (md) + strlen (name) + 2; | |
94 cf = (char *) xrealloc (cf, cflen); | |
95 } | |
96 strcpy (cf, md); | |
97 strcat (cf,"/"); | |
98 strcat (cf, name); | |
99 cff = fopen (cf, "r"); | |
100 while ((c = getc(cff)) != EOF) | |
101 putc (c, mfilef); | |
102 putc ('\n', mfilef); | |
103 skip_to_lf (mddf); | |
104 fclose (cff); | |
105 } | |
106 fclose (mddf); | |
442 | 107 fclose (mfilef); |
428 | 108 return 0; |
109 } | |
110 | |
111 static void | |
440 | 112 skip_to_lf (FILE *stream) |
428 | 113 { |
114 register int c; | |
115 while ((c = getc(stream)) != '\n') | |
116 ; | |
117 } | |
118 | |
119 static void * | |
440 | 120 xmalloc (size_t size) |
428 | 121 { |
440 | 122 void *result = malloc (size); |
428 | 123 if (!result) |
124 fatal ("virtual memory exhausted", 0); | |
125 return result; | |
126 } | |
127 | |
128 static void * | |
440 | 129 xrealloc (void *ptr, size_t size) |
428 | 130 { |
440 | 131 void *result = realloc (ptr, size); |
428 | 132 if (!result) |
133 fatal ("virtual memory exhausted", 0); | |
134 return result; | |
135 } | |
136 | |
137 /* Print error message and exit. */ | |
138 | |
139 static void | |
442 | 140 fatal (const char *s1, const char *s2) |
428 | 141 { |
142 error (s1, s2); | |
143 exit (1); | |
144 } | |
145 | |
146 static void | |
442 | 147 error (const char *s1, const char *s2) |
428 | 148 { |
149 fprintf (stderr, "cvtmail: "); | |
150 fprintf (stderr, s1, s2); | |
151 fprintf (stderr, "\n"); | |
152 } |