Mercurial > gnulib
annotate tests/test-binary-io.c @ 40231:9b3c79fdfe0b
strtod: fix clash with strtold
Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817).
* lib/strtod.c (compute_minus_zero, minus_zero):
Simplify by remving the macro / external variable,
and having just a function. User changed. This avoids
the need for an external variable that might clash.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 11 Mar 2019 16:40:29 -0700 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
7869 | 1 /* Test of binary mode I/O. |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
2 Copyright (C) 2005, 2007-2019 Free Software Foundation, Inc. |
7869 | 3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8910
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
7869 | 5 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8910
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8910
diff
changeset
|
7 (at your option) any later version. |
7869 | 8 |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
19190 | 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
7869 | 16 |
17 /* Written by Bruno Haible <bruno@clisp.org>, 2005. */ | |
18 | |
8891
633babea5f62
Unconditionally include <config.h> in unit tests.
Eric Blake <ebb9@byu.net>
parents:
8754
diff
changeset
|
19 #include <config.h> |
7869 | 20 |
21 #include "binary-io.h" | |
22 | |
23 #include <sys/types.h> | |
24 #include <sys/stat.h> | |
25 #include <fcntl.h> | |
26 #include <stdio.h> | |
27 #include <stdlib.h> | |
28 #include <unistd.h> | |
29 | |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
30 #include "macros.h" |
7869 | 31 |
32 int | |
16851
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
33 main (int argc, char *argv[]) |
7869 | 34 { |
35 /* Test the O_BINARY macro. */ | |
36 { | |
8910
a7e0b65d5c78
Attempt to fix a test failure on Solaris (open fails with EACCES).
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
37 int fd = |
16851
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
38 open ("t-bin-out0.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600); |
7869 | 39 if (write (fd, "Hello\n", 6) < 0) |
40 exit (1); | |
41 close (fd); | |
42 } | |
43 { | |
44 struct stat statbuf; | |
16851
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
45 if (stat ("t-bin-out0.tmp", &statbuf) < 0) |
7869 | 46 exit (1); |
47 ASSERT (statbuf.st_size == 6); | |
48 } | |
49 | |
16851
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
50 switch (argv[1][0]) |
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
51 { |
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
52 case '1': |
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
53 /* Test the set_binary_mode() function. */ |
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
54 set_binary_mode (1, O_BINARY); |
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
55 fputs ("Hello\n", stdout); |
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
56 break; |
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
57 |
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
58 default: |
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
59 break; |
2ef869fa79b4
binary-io: Define set_binary_mode function.
Bruno Haible <bruno@clisp.org>
parents:
16201
diff
changeset
|
60 } |
7869 | 61 |
62 return 0; | |
63 } |