Mercurial > emacs
annotate lib-src/b2m.c @ 58195:c12b583f54b9
Fixed these problems:
** Clicking on partially visible lines fails
From: David Kastrup <dak@gnu.org>
Date: 27 Apr 2004 16:42:58 +0200
I had gnus display a mouse-highlighted line (a URL from browse-url)
partially at the bottom of its window. If I click with middle mouse
key on it, the window gets recentered while I hold the mouse key
pressed. If I release it, the window returns into its old position
(cursor in top row) and nothing happens, presumably because the click
was not registered on the line itself, but on the magically
recentered version.
That is a nuisance. Recentering of even partially visible click
targets should only happen if window-point moves there, but not at
the time of the click. From the moment I hold down a key until it
gets released, the displayed window portion should not change, with
the sole exception of scrolling when dragging at the edge of the
screen.
(progn
(setq line-spacing 4)
(dotimes (i (window-height))
(insert "\n" (int-to-string i)))
(forward-line -2)
(recenter -1))
** Can't drag modeline when mouse-autoselect-window is set
From: Klaus Zeitler <kzeitler@lucent.com>
Date: Mon, 11 Oct 2004 11:14:49 +0200
1. start emacs -q --no-site-file
2. set variable mouse-autoselect-window to t
3. split-window-vertically
now I can drag the modeline only upwards but not downwards
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Sat, 13 Nov 2004 01:40:36 +0000 |
parents | 1c425ce93ce9 |
children | e112ec9aa49b 4c90ffeb71c5 |
rev | line source |
---|---|
440 | 1 /* |
2 * b2m - a filter for Babyl -> Unix mail files | |
42260 | 3 * The copyright on this file has been disclaimed. |
440 | 4 * |
5 * usage: b2m < babyl > mailbox | |
6 * | |
7 * I find this useful whenever I have to use a | |
8 * system which - shock horror! - doesn't run | |
40067
5c3937ee7017
Properly spell the name of Emacs.
Pavel Janík <Pavel@Janik.cz>
parents:
37163
diff
changeset
|
9 * GNU Emacs. At least now I can read all my |
5c3937ee7017
Properly spell the name of Emacs.
Pavel Janík <Pavel@Janik.cz>
parents:
37163
diff
changeset
|
10 * GNU Emacs Babyl format mail files! |
440 | 11 * |
12 * it's not much but it's free! | |
13 * | |
14 * Ed Wilkinson | |
15 * E.Wilkinson@massey.ac.nz | |
16 * Mon Nov 7 15:54:06 PDT 1988 | |
17 */ | |
18 | |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
19 /* Made conformant to the GNU coding standards January, 1995 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
20 by Francesco Potorti` <pot@cnuce.cnr.it>. */ |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
21 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
23 #include <config.h> |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
24 /* On some systems, Emacs defines static as nothing for the sake |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
25 of unexec. We don't want that here since we don't use unexec. */ |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
26 #undef static |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
27 #endif |
440 | 28 |
26083
134b57acef68
Add support for large files. Merge glibc 2.1.2.
Paul Eggert <eggert@twinsun.com>
parents:
21386
diff
changeset
|
29 #include <stdio.h> |
134b57acef68
Add support for large files. Merge glibc 2.1.2.
Paul Eggert <eggert@twinsun.com>
parents:
21386
diff
changeset
|
30 #include <time.h> |
134b57acef68
Add support for large files. Merge glibc 2.1.2.
Paul Eggert <eggert@twinsun.com>
parents:
21386
diff
changeset
|
31 #include <sys/types.h> |
134b57acef68
Add support for large files. Merge glibc 2.1.2.
Paul Eggert <eggert@twinsun.com>
parents:
21386
diff
changeset
|
32 #include <getopt.h> |
134b57acef68
Add support for large files. Merge glibc 2.1.2.
Paul Eggert <eggert@twinsun.com>
parents:
21386
diff
changeset
|
33 #ifdef MSDOS |
134b57acef68
Add support for large files. Merge glibc 2.1.2.
Paul Eggert <eggert@twinsun.com>
parents:
21386
diff
changeset
|
34 #include <fcntl.h> |
21386
49b24e54a5fa
Include <stdlib.h> if available.
Andreas Schwab <schwab@suse.de>
parents:
21354
diff
changeset
|
35 #endif |
49b24e54a5fa
Include <stdlib.h> if available.
Andreas Schwab <schwab@suse.de>
parents:
21354
diff
changeset
|
36 |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
37 #undef TRUE |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
38 #define TRUE 1 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
39 #undef FALSE |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
40 #define FALSE 0 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
41 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
42 #define streq(s,t) (strcmp (s, t) == 0) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
43 #define strneq(s,t,n) (strncmp (s, t, n) == 0) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
44 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
45 typedef int logical; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
46 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
47 /* |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
48 * A `struct linebuffer' is a structure which holds a line of text. |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
49 * `readline' reads a line from a stream into a linebuffer and works |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
50 * regardless of the length of the line. |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
51 */ |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
52 struct linebuffer |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
53 { |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
54 long size; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
55 char *buffer; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
56 }; |
8957
4dffbc5d5dc7
(from, labels, data): Use MAX_DATA_LEN as length.
Richard M. Stallman <rms@gnu.org>
parents:
7528
diff
changeset
|
57 |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
58 extern char *strtok(); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
59 |
11674
754722efad75
(xmalloc, xrealloc): Declare them long *.
Richard M. Stallman <rms@gnu.org>
parents:
11423
diff
changeset
|
60 long *xmalloc (), *xrealloc (); |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
61 char *concat (); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
62 long readline (); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
63 void fatal (); |
440 | 64 |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
65 /* |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
66 * xnew -- allocate storage. SYNOPSIS: Type *xnew (int n, Type); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
67 */ |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
68 #define xnew(n, Type) ((Type *) xmalloc ((n) * sizeof (Type))) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
69 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
70 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
71 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
72 char *progname; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
73 |
20328 | 74 struct option longopts[] = |
75 { | |
76 { "help", no_argument, NULL, 'h' }, | |
77 { "version", no_argument, NULL, 'V' }, | |
78 { 0 } | |
79 }; | |
80 | |
81 extern int optind; | |
82 | |
21386
49b24e54a5fa
Include <stdlib.h> if available.
Andreas Schwab <schwab@suse.de>
parents:
21354
diff
changeset
|
83 int |
2101
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
84 main (argc, argv) |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
85 int argc; |
df8249aa4901
* b2m.c (main): Don't exit upon reading a blank line.
Jim Blandy <jimb@redhat.com>
parents:
998
diff
changeset
|
86 char **argv; |
440 | 87 { |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
88 logical labels_saved, printing, header; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
89 time_t ltoday; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
90 char *labels, *p, *today; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
91 struct linebuffer data; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
92 |
5448
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
93 #ifdef MSDOS |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
94 _fmode = O_BINARY; /* all of files are treated as binary files */ |
14968
1351c75bc3d6
(main) [MSDOS]: Handle DJGPP version 2.
Richard M. Stallman <rms@gnu.org>
parents:
14850
diff
changeset
|
95 #if __DJGPP__ > 1 |
1351c75bc3d6
(main) [MSDOS]: Handle DJGPP version 2.
Richard M. Stallman <rms@gnu.org>
parents:
14850
diff
changeset
|
96 if (!isatty (fileno (stdout))) |
1351c75bc3d6
(main) [MSDOS]: Handle DJGPP version 2.
Richard M. Stallman <rms@gnu.org>
parents:
14850
diff
changeset
|
97 setmode (fileno (stdout), O_BINARY); |
1351c75bc3d6
(main) [MSDOS]: Handle DJGPP version 2.
Richard M. Stallman <rms@gnu.org>
parents:
14850
diff
changeset
|
98 if (!isatty (fileno (stdin))) |
1351c75bc3d6
(main) [MSDOS]: Handle DJGPP version 2.
Richard M. Stallman <rms@gnu.org>
parents:
14850
diff
changeset
|
99 setmode (fileno (stdin), O_BINARY); |
1351c75bc3d6
(main) [MSDOS]: Handle DJGPP version 2.
Richard M. Stallman <rms@gnu.org>
parents:
14850
diff
changeset
|
100 #else /* not __DJGPP__ > 1 */ |
5448
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
101 (stdout)->_flag &= ~_IOTEXT; |
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
102 (stdin)->_flag &= ~_IOTEXT; |
14968
1351c75bc3d6
(main) [MSDOS]: Handle DJGPP version 2.
Richard M. Stallman <rms@gnu.org>
parents:
14850
diff
changeset
|
103 #endif /* not __DJGPP__ > 1 */ |
5448
18de002e47dd
(main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
104 #endif |
14850
13d38dfedb51
(main): Initialize progname variable before using it.
Richard M. Stallman <rms@gnu.org>
parents:
11674
diff
changeset
|
105 progname = argv[0]; |
13d38dfedb51
(main): Initialize progname variable before using it.
Richard M. Stallman <rms@gnu.org>
parents:
11674
diff
changeset
|
106 |
20328 | 107 while (1) |
108 { | |
109 int opt = getopt_long (argc, argv, "hV", longopts, 0); | |
110 if (opt == EOF) | |
111 break; | |
112 | |
113 switch (opt) | |
114 { | |
115 case 'V': | |
116 printf ("%s (GNU Emacs %s)\n", "b2m", VERSION); | |
117 puts ("b2m is in the public domain."); | |
55408
1c425ce93ce9
(GOOD, BAD): Delete macros. Throughout,
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
118 exit (EXIT_SUCCESS); |
20328 | 119 |
120 case 'h': | |
121 fprintf (stderr, "Usage: %s <babylmailbox >unixmailbox\n", progname); | |
55408
1c425ce93ce9
(GOOD, BAD): Delete macros. Throughout,
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
122 exit (EXIT_SUCCESS); |
20328 | 123 } |
124 } | |
125 | |
126 if (optind != argc) | |
6173
cbf3383981cb
(main): Change delimiter from "^L" to "^_^L".
Karl Heuer <kwzh@gnu.org>
parents:
5448
diff
changeset
|
127 { |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
128 fprintf (stderr, "Usage: %s <babylmailbox >unixmailbox\n", progname); |
55408
1c425ce93ce9
(GOOD, BAD): Delete macros. Throughout,
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
129 exit (EXIT_SUCCESS); |
6173
cbf3383981cb
(main): Change delimiter from "^L" to "^_^L".
Karl Heuer <kwzh@gnu.org>
parents:
5448
diff
changeset
|
130 } |
20328 | 131 |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
132 labels_saved = printing = header = FALSE; |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
133 ltoday = time (0); |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
134 today = ctime (<oday); |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
135 data.size = 200; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
136 data.buffer = xnew (200, char); |
440 | 137 |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
138 if (readline (&data, stdin) == 0 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
139 || !strneq (data.buffer, "BABYL OPTIONS:", 14)) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
140 fatal ("standard input is not a Babyl mailfile."); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
141 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
142 while (readline (&data, stdin) > 0) |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
143 { |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
144 if (streq (data.buffer, "*** EOOH ***") && !printing) |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
145 { |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
146 printing = header = TRUE; |
14850
13d38dfedb51
(main): Initialize progname variable before using it.
Richard M. Stallman <rms@gnu.org>
parents:
11674
diff
changeset
|
147 printf ("From \"Babyl to mail by %s\" %s", progname, today); |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
148 continue; |
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
149 } |
6173
cbf3383981cb
(main): Change delimiter from "^L" to "^_^L".
Karl Heuer <kwzh@gnu.org>
parents:
5448
diff
changeset
|
150 |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
151 if (data.buffer[0] == '\037') |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
152 { |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
153 if (data.buffer[1] == '\0') |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
154 continue; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
155 else if (data.buffer[1] == '\f') |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
156 { |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
157 /* Save labels. */ |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
158 readline (&data, stdin); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
159 p = strtok (data.buffer, " ,\r\n\t"); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
160 labels = "X-Babyl-Labels: "; |
440 | 161 |
42471
4234f54994ef
(main): Parenthesize assignment when used as truth value to prevent gcc
Pavel Janík <Pavel@Janik.cz>
parents:
42260
diff
changeset
|
162 while ((p = strtok (NULL, " ,\r\n\t"))) |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
163 labels = concat (labels, p, ", "); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
164 |
11423
a096f82d87d9
(main): Check for trailing ", " before trying to delete it.
Karl Heuer <kwzh@gnu.org>
parents:
10370
diff
changeset
|
165 p = &labels[strlen (labels) - 2]; |
a096f82d87d9
(main): Check for trailing ", " before trying to delete it.
Karl Heuer <kwzh@gnu.org>
parents:
10370
diff
changeset
|
166 if (*p == ',') |
a096f82d87d9
(main): Check for trailing ", " before trying to delete it.
Karl Heuer <kwzh@gnu.org>
parents:
10370
diff
changeset
|
167 *p = '\0'; |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
168 printing = header = FALSE; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
169 labels_saved = TRUE; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
170 continue; |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
171 } |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
172 } |
440 | 173 |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
174 if ((data.buffer[0] == '\0') && header) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
175 { |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
176 header = FALSE; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
177 if (labels_saved) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
178 puts (labels); |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
179 } |
440 | 180 |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
181 if (printing) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
182 puts (data.buffer); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
183 } |
37163
e563147d81e5
(main): Always return a value.
Gerd Moellmann <gerd@gnu.org>
parents:
26083
diff
changeset
|
184 |
55408
1c425ce93ce9
(GOOD, BAD): Delete macros. Throughout,
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
185 return EXIT_SUCCESS; |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
186 } |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
187 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
188 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
189 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
190 /* |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
191 * Return a newly-allocated string whose contents |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
192 * concatenate those of s1, s2, s3. |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
193 */ |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
194 char * |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
195 concat (s1, s2, s3) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
196 char *s1, *s2, *s3; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
197 { |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
198 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
199 char *result = xnew (len1 + len2 + len3 + 1, char); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
200 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
201 strcpy (result, s1); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
202 strcpy (result + len1, s2); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
203 strcpy (result + len1 + len2, s3); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
204 result[len1 + len2 + len3] = '\0'; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
205 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
206 return result; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
207 } |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
208 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
209 /* |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
210 * Read a line of text from `stream' into `linebuffer'. |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
211 * Return the number of characters read from `stream', |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
212 * which is the length of the line including the newline, if any. |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
213 */ |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
214 long |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
215 readline (linebuffer, stream) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
216 struct linebuffer *linebuffer; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
217 register FILE *stream; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
218 { |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
219 char *buffer = linebuffer->buffer; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
220 register char *p = linebuffer->buffer; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
221 register char *pend; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
222 int chars_deleted; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
223 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
224 pend = p + linebuffer->size; /* Separate to avoid 386/IX compiler bug. */ |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
225 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
226 while (1) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
227 { |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
228 register int c = getc (stream); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
229 if (p == pend) |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
230 { |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
231 linebuffer->size *= 2; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
232 buffer = (char *) xrealloc (buffer, linebuffer->size); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
233 p += buffer - linebuffer->buffer; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
234 pend = buffer + linebuffer->size; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
235 linebuffer->buffer = buffer; |
6215
226d490216f7
Clean up indentation and whitespace.
Richard M. Stallman <rms@gnu.org>
parents:
6214
diff
changeset
|
236 } |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
237 if (c == EOF) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
238 { |
18238
1f3d8941aba2
(readline): Terminate buffer properly when EOF seen.
Karl Heuer <kwzh@gnu.org>
parents:
14968
diff
changeset
|
239 *p = '\0'; |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
240 chars_deleted = 0; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
241 break; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
242 } |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
243 if (c == '\n') |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
244 { |
18238
1f3d8941aba2
(readline): Terminate buffer properly when EOF seen.
Karl Heuer <kwzh@gnu.org>
parents:
14968
diff
changeset
|
245 if (p > buffer && p[-1] == '\r') |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
246 { |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
247 *--p = '\0'; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
248 chars_deleted = 2; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
249 } |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
250 else |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
251 { |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
252 *p = '\0'; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
253 chars_deleted = 1; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
254 } |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
255 break; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
256 } |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
257 *p++ = c; |
440 | 258 } |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
259 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
260 return (p - buffer + chars_deleted); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
261 } |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
262 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
263 /* |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
264 * Like malloc but get fatal error if memory is exhausted. |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
265 */ |
11674
754722efad75
(xmalloc, xrealloc): Declare them long *.
Richard M. Stallman <rms@gnu.org>
parents:
11423
diff
changeset
|
266 long * |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
267 xmalloc (size) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
268 unsigned int size; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
269 { |
11674
754722efad75
(xmalloc, xrealloc): Declare them long *.
Richard M. Stallman <rms@gnu.org>
parents:
11423
diff
changeset
|
270 long *result = (long *) malloc (size); |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
271 if (result == NULL) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
272 fatal ("virtual memory exhausted"); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
273 return result; |
440 | 274 } |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
275 |
11674
754722efad75
(xmalloc, xrealloc): Declare them long *.
Richard M. Stallman <rms@gnu.org>
parents:
11423
diff
changeset
|
276 long * |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
277 xrealloc (ptr, size) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
278 char *ptr; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
279 unsigned int size; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
280 { |
11674
754722efad75
(xmalloc, xrealloc): Declare them long *.
Richard M. Stallman <rms@gnu.org>
parents:
11423
diff
changeset
|
281 long *result = (long *) realloc (ptr, size); |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
282 if (result == NULL) |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
283 fatal ("virtual memory exhausted"); |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
284 return result; |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
285 } |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
286 |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
287 void |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
288 fatal (message) |
21354
f998f239f77b
(fatal): Declare the arg.
Richard M. Stallman <rms@gnu.org>
parents:
20328
diff
changeset
|
289 char *message; |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
290 { |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
291 fprintf (stderr, "%s: %s\n", progname, message); |
55408
1c425ce93ce9
(GOOD, BAD): Delete macros. Throughout,
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
292 exit (EXIT_FAILURE); |
10370
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
293 } |
4b1c8dc724e6
(concat, xmalloc, xrealloc, readline, xnew): Four new
Richard M. Stallman <rms@gnu.org>
parents:
9491
diff
changeset
|
294 |
52401 | 295 /* arch-tag: 5a3ad2af-a802-408f-83cc-e7cf5e98653e |
296 (do not change this comment) */ | |
55408
1c425ce93ce9
(GOOD, BAD): Delete macros. Throughout,
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
297 |
1c425ce93ce9
(GOOD, BAD): Delete macros. Throughout,
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
52401
diff
changeset
|
298 /* b2m.c ends here */ |