aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorMiles Bader2006-06-17 20:57:37 +0000
committerMiles Bader2006-06-17 20:57:37 +0000
commit10c1758c0b2d29b3e1fb8e3ffe5c5dc262f25217 (patch)
tree78d2db4ab91026e7d5373086d022a2bce083200b /lib-src
parent2090e2a3897bd0e36fd0e8ba13d861668a0a887f (diff)
parentf362b76002bfd0f43af76a7772a808c042302f07 (diff)
downloademacs-10c1758c0b2d29b3e1fb8e3ffe5c5dc262f25217.tar.gz
emacs-10c1758c0b2d29b3e1fb8e3ffe5c5dc262f25217.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 300-313) - Update from CVS - Update from CVS: lispref/display.texi (Forcing Redisplay): Fix typo. - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 105-106) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-74
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog9
-rw-r--r--lib-src/Makefile.in5
-rw-r--r--lib-src/makefile.w32-in5
-rw-r--r--lib-src/yow.c185
4 files changed, 10 insertions, 194 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 557d8a2d492..040f155221f 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,12 @@
12006-06-09 Eli Zaretskii <eliz@gnu.org>
2
3 * yow.c: Remove file.
4
5 * makefile.w32-in ($(BLD)/yow.$(O)): Remove target.
6
7 * Makefile.in (UTILITIES): Remove yow${EXEEXT}.
8 yow${EXEEXT}: Remove target.
9
12006-06-04 Masatake YAMATO <jet@gyve.org> 102006-06-04 Masatake YAMATO <jet@gyve.org>
2 11
3 * ebrowse.c (main): Exit with EXIT_FAILURE if BROWSE file 12 * ebrowse.c (main): Exit with EXIT_FAILURE if BROWSE file
diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in
index 85a7c13c95a..4eb1658ac0a 100644
--- a/lib-src/Makefile.in
+++ b/lib-src/Makefile.in
@@ -107,7 +107,7 @@ INSTALLABLE_SCRIPTS = rcs-checkin grep-changelog
107# Things that Emacs runs internally, or during the build process, 107# Things that Emacs runs internally, or during the build process,
108# which should not be installed in bindir. 108# which should not be installed in bindir.
109UTILITIES= profile${EXEEXT} digest-doc${EXEEXT} sorted-doc${EXEEXT} movemail${EXEEXT} cvtmail${EXEEXT} fakemail${EXEEXT} \ 109UTILITIES= profile${EXEEXT} digest-doc${EXEEXT} sorted-doc${EXEEXT} movemail${EXEEXT} cvtmail${EXEEXT} fakemail${EXEEXT} \
110 yow${EXEEXT} hexl${EXEEXT} update-game-score${EXEEXT} 110 hexl${EXEEXT} update-game-score${EXEEXT}
111 111
112DONT_INSTALL= test-distrib${EXEEXT} make-docfile${EXEEXT} 112DONT_INSTALL= test-distrib${EXEEXT} make-docfile${EXEEXT}
113 113
@@ -449,9 +449,6 @@ cvtmail${EXEEXT}: ${srcdir}/cvtmail.c
449fakemail${EXEEXT}: ${srcdir}/fakemail.c ../src/config.h 449fakemail${EXEEXT}: ${srcdir}/fakemail.c ../src/config.h
450 $(CC) ${ALL_CFLAGS} ${srcdir}/fakemail.c $(LOADLIBES) -o fakemail 450 $(CC) ${ALL_CFLAGS} ${srcdir}/fakemail.c $(LOADLIBES) -o fakemail
451 451
452yow${EXEEXT}: ${srcdir}/yow.c ../src/epaths.h
453 $(CC) ${ALL_CFLAGS} ${srcdir}/yow.c $(LOADLIBES) -o yow
454
455emacsclient${EXEEXT}: ${srcdir}/emacsclient.c ../src/config.h $(GETOPTDEPS) 452emacsclient${EXEEXT}: ${srcdir}/emacsclient.c ../src/config.h $(GETOPTDEPS)
456 $(CC) ${ALL_CFLAGS} ${srcdir}/emacsclient.c $(GETOPTOBJS) \ 453 $(CC) ${ALL_CFLAGS} ${srcdir}/emacsclient.c $(GETOPTOBJS) \
457 -DVERSION="\"${version}\"" \ 454 -DVERSION="\"${version}\"" \
diff --git a/lib-src/makefile.w32-in b/lib-src/makefile.w32-in
index f941e862514..564487a5858 100644
--- a/lib-src/makefile.w32-in
+++ b/lib-src/makefile.w32-in
@@ -120,7 +120,6 @@ $(BLD)/ctags.$(O): ctags.c
120# 120#
121# don't know what to do with these yet... 121# don't know what to do with these yet...
122# 122#
123# $(BLD)/yow.exe: $(BLD)/yow.$(O)
124# $(BLD)/emacstool.exe: $(BLD)/emacstool.$(O) 123# $(BLD)/emacstool.exe: $(BLD)/emacstool.$(O)
125# $(BLD)/server.exe: $(BLD)/server.$(O) 124# $(BLD)/server.exe: $(BLD)/server.$(O)
126# $(BLD)/cvtmail.exe: $(BLD)/cvtmail.$(O) 125# $(BLD)/cvtmail.exe: $(BLD)/cvtmail.$(O)
@@ -458,7 +457,3 @@ $(BLD)/timer.$(O) : \
458 $(EMACS_ROOT)/src/s/ms-w32.h \ 457 $(EMACS_ROOT)/src/s/ms-w32.h \
459 $(EMACS_ROOT)/src/m/intel386.h \ 458 $(EMACS_ROOT)/src/m/intel386.h \
460 $(EMACS_ROOT)/lib-src/../src/config.h 459 $(EMACS_ROOT)/lib-src/../src/config.h
461
462$(BLD)/yow.$(O) : \
463 $(SRC)/yow.c \
464 $(EMACS_ROOT)/lib-src/../src/paths.h
diff --git a/lib-src/yow.c b/lib-src/yow.c
deleted file mode 100644
index 18f0f7b2e13..00000000000
--- a/lib-src/yow.c
+++ /dev/null
@@ -1,185 +0,0 @@
1/*
2 * yow.c
3 *
4 * Print a quotation from Zippy the Pinhead.
5 * Qux <Kaufman-David@Yale> March 6, 1986
6 *
7 * This file is in the public domain because the author published it
8 * with no copyright notice before the US signed the Bern Convention.
9 *
10 * With dynamic memory allocation.
11 */
12
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include <stdio.h>
18#include <ctype.h>
19#ifdef TIME_WITH_SYS_TIME
20#include <sys/time.h>
21#include <time.h>
22#else
23#ifdef HAVE_SYS_TIME_H
24#include <sys/time.h>
25#else
26#include <time.h>
27#endif
28#endif
29#ifdef HAVE_UNISTD_H
30#include <unistd.h>
31#endif
32#include "epaths.h" /* For PATH_DATA. */
33
34#define BUFSIZE 80
35#define SEP '\0'
36
37#ifndef YOW_FILE
38#define YOW_FILE "yow.lines"
39#endif
40
41#ifdef MSDOS
42#define rootrelativepath(rel) \
43({\
44 static char res[BUFSIZE], *p;\
45 strcpy (res, argv[0]);\
46 p = res + strlen (res);\
47 while (p != res && *p != '/' && *p != '\\' && *p != ':') p--;\
48 strcpy (p + 1, "../");\
49 strcpy (p + 4, rel);\
50 &res;})
51#endif
52
53void yow();
54void setup_yow();
55
56int
57main (argc, argv)
58 int argc;
59 char *argv[];
60{
61 FILE *fp;
62 char file[BUFSIZ];
63
64 if (argc > 2 && !strcmp (argv[1], "-f"))
65 strcpy (file, argv[2]);
66 else
67#ifdef vms
68 sprintf (file, "%s%s", PATH_DATA, YOW_FILE);
69#else
70 sprintf (file, "%s/%s", PATH_DATA, YOW_FILE);
71#endif
72
73 if ((fp = fopen(file, "r")) == NULL) {
74 fprintf(stderr, "yow: ");
75 perror(file);
76 exit(EXIT_FAILURE);
77 }
78
79 /* initialize random seed */
80 srand((int) (getpid() + time((time_t *) 0)));
81
82 setup_yow(fp);
83 yow(fp);
84 fclose(fp);
85 return EXIT_SUCCESS;
86}
87
88static long len = -1;
89static long header_len;
90
91#define AVG_LEN 40 /* average length of a quotation */
92
93/* Sets len and header_len */
94void
95setup_yow(fp)
96 FILE *fp;
97{
98 int c;
99
100 /* Get length of file */
101 /* Because the header (stuff before the first SEP) can be very long,
102 * thus biasing our search in favor of the first quotation in the file,
103 * we explicitly skip that. */
104 while ((c = getc(fp)) != SEP) {
105 if (c == EOF) {
106 fprintf(stderr, "yow: file contains no separators\n");
107 exit(EXIT_FAILURE);
108 }
109 }
110 header_len = ftell(fp);
111 if (header_len > AVG_LEN)
112 header_len -= AVG_LEN; /* allow the first quotation to appear */
113
114 if (fseek(fp, 0L, 2) == -1) {
115 perror("yow");
116 exit(EXIT_FAILURE);
117 }
118 len = ftell(fp) - header_len;
119}
120
121
122/* go to a random place in the file and print the quotation there */
123void
124yow (fp)
125 FILE *fp;
126{
127 long offset;
128 int c, i = 0;
129 char *buf;
130 unsigned int bufsize;
131
132 offset = rand() % len + header_len;
133 if (fseek(fp, offset, 0) == -1) {
134 perror("yow");
135 exit(EXIT_FAILURE);
136 }
137
138 /* Read until SEP, read next line, print it.
139 (Note that we will never print anything before the first separator.)
140 If we hit EOF looking for the first SEP, just recurse. */
141 while ((c = getc(fp)) != SEP)
142 if (c == EOF) {
143 yow(fp);
144 return;
145 }
146
147 /* Skip leading whitespace, then read in a quotation.
148 If we hit EOF before we find a non-whitespace char, recurse. */
149 while (isspace(c = getc(fp)))
150 ;
151 if (c == EOF) {
152 yow(fp);
153 return;
154 }
155
156 bufsize = BUFSIZE;
157 buf = (char *) malloc(bufsize);
158 if (buf == (char *)0) {
159 fprintf(stderr, "yow: virtual memory exhausted\n");
160 exit (EXIT_FAILURE);
161 }
162
163 buf[i++] = c;
164 while ((c = getc(fp)) != SEP && c != EOF) {
165 buf[i++] = c;
166
167 if (i == bufsize-1) {
168 /* Yow! Is this quotation too long yet? */
169 bufsize *= 2;
170 buf = (char *) realloc(buf, bufsize);
171 if (buf == (char *)0) {
172 fprintf(stderr, "yow: virtual memory exhausted\n");
173 exit (EXIT_FAILURE);
174 }
175 }
176 }
177 buf[i++] = 0;
178 printf("%s\n", buf);
179 free (buf);
180}
181
182/* arch-tag: e40fc0df-bafb-4001-af24-5c883d1c685e
183 (do not change this comment) */
184
185/* yow.c ends here */