Mercurial > emacs
annotate lib-src/test-distrib.c @ 12969:836d868710ec
(wordstar-center-line): Renamed from center-line.
(wordstar-center-region): Renamed from center-region.
(wordstar-center-paragraph): Renamed from center-paragraph.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 29 Aug 1995 14:55:25 +0000 |
parents | f65e672e038e |
children | 55e427250ad3 |
rev | line source |
---|---|
12935
f65e672e038e
[HAVE_CONFIG_H]: Include config.h.
Roland McGrath <roland@gnu.org>
parents:
9491
diff
changeset
|
1 #ifdef HAVE_CONFIG_H |
f65e672e038e
[HAVE_CONFIG_H]: Include config.h.
Roland McGrath <roland@gnu.org>
parents:
9491
diff
changeset
|
2 #include <config.h> |
f65e672e038e
[HAVE_CONFIG_H]: Include config.h.
Roland McGrath <roland@gnu.org>
parents:
9491
diff
changeset
|
3 #endif |
f65e672e038e
[HAVE_CONFIG_H]: Include config.h.
Roland McGrath <roland@gnu.org>
parents:
9491
diff
changeset
|
4 |
10 | 5 #include <stdio.h> |
6 | |
12935
f65e672e038e
[HAVE_CONFIG_H]: Include config.h.
Roland McGrath <roland@gnu.org>
parents:
9491
diff
changeset
|
7 #ifndef O_RDONLY |
f65e672e038e
[HAVE_CONFIG_H]: Include config.h.
Roland McGrath <roland@gnu.org>
parents:
9491
diff
changeset
|
8 #define O_RDONLY 0 |
f65e672e038e
[HAVE_CONFIG_H]: Include config.h.
Roland McGrath <roland@gnu.org>
parents:
9491
diff
changeset
|
9 #endif |
f65e672e038e
[HAVE_CONFIG_H]: Include config.h.
Roland McGrath <roland@gnu.org>
parents:
9491
diff
changeset
|
10 |
f65e672e038e
[HAVE_CONFIG_H]: Include config.h.
Roland McGrath <roland@gnu.org>
parents:
9491
diff
changeset
|
11 |
10 | 12 /* Break string in two parts to avoid buggy C compilers that ignore characters |
13 after nulls in strings. */ | |
14 | |
15 char string1[] = "Testing distribution of nonprinting chars:\n\ | |
16 Should be 0177: \177 Should be 0377: \377 Should be 0212: \212.\n\ | |
17 Should be 0000: "; | |
18 | |
19 char string2[] = ".\n\ | |
20 This file is read by the `test-distribution' program.\n\ | |
21 If you change it, you will make that program fail.\n"; | |
22 | |
23 char buf[300]; | |
24 | |
25 /* Like `read' but keeps trying until it gets SIZE bytes or reaches eof. */ | |
26 int | |
27 cool_read (fd, buf, size) | |
28 int fd; | |
29 char *buf; | |
30 int size; | |
31 { | |
32 int num, sofar = 0; | |
33 | |
34 while (1) | |
35 { | |
36 if ((num = read (fd, buf + sofar, size - sofar)) == 0) | |
37 return sofar; | |
38 else if (num < 0) | |
39 return num; | |
40 sofar += num; | |
41 } | |
42 } | |
43 | |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
2814
diff
changeset
|
44 int |
2814
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
45 main (argc, argv) |
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
46 int argc; |
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
47 char **argv; |
10 | 48 { |
2814
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
49 int fd; |
10 | 50 |
2814
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
51 if (argc != 2) |
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
52 { |
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
53 fprintf (stderr, "Usage: %s testfile\n", argv[0]); |
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
54 exit (2); |
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
55 } |
12935
f65e672e038e
[HAVE_CONFIG_H]: Include config.h.
Roland McGrath <roland@gnu.org>
parents:
9491
diff
changeset
|
56 fd = open (argv[1], O_RDONLY); |
10 | 57 if (fd < 0) |
58 { | |
2814
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
59 perror (argv[1]); |
10 | 60 exit (2); |
61 } | |
62 if (cool_read (fd, buf, sizeof string1) != sizeof string1 || | |
63 strcmp (buf, string1) || | |
64 cool_read (fd, buf, sizeof string2) != sizeof string2 - 1 || | |
65 strncmp (buf, string2, sizeof string2 - 1)) | |
66 { | |
2814
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
67 fprintf (stderr, "Data in file `%s' has been damaged.\n\ |
10 | 68 Most likely this means that many nonprinting characters\n\ |
2814
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
69 have been corrupted in the files of Emacs, and it will not work.\n", |
0da5b58e98ed
Install patches from David J. Mackenzie to make the srcdir option
Jim Blandy <jimb@redhat.com>
parents:
10
diff
changeset
|
70 argv[1]); |
10 | 71 exit (2); |
72 } | |
73 close (fd); | |
74 #ifdef VMS | |
75 exit (1); /* On VMS, success is 1. */ | |
76 #endif | |
9491
dd3b83e4ceb0
Eliminate some -Wall warnings.
David J. MacKenzie <djm@gnu.org>
parents:
2814
diff
changeset
|
77 return (0); |
10 | 78 } |