]>
Commit | Line | Data |
---|---|---|
4216708a JM |
1 | // { dg-require-namedlocale "fr_FR.ISO8859-15" } |
2 | // { dg-require-namedlocale "en_US.ISO8859-1" } | |
34f4edf8 MM |
3 | // { dg-require-fork "" } |
4 | // { dg-require-mkfifo "" } | |
5 | ||
8d9254fc | 6 | // Copyright (C) 2003-2020 Free Software Foundation, Inc. |
c03d83d4 PC |
7 | // |
8 | // This file is part of the GNU ISO C++ Library. This library is free | |
9 | // software; you can redistribute it and/or modify it under the | |
10 | // terms of the GNU General Public License as published by the | |
748086b7 | 11 | // Free Software Foundation; either version 3, or (at your option) |
c03d83d4 PC |
12 | // any later version. |
13 | ||
14 | // This library is distributed in the hope that it will be useful, | |
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | // GNU General Public License for more details. | |
18 | ||
19 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
20 | // with this library; see the file COPYING3. If not see |
21 | // <http://www.gnu.org/licenses/>. | |
c03d83d4 PC |
22 | |
23 | // 27.8.1.4 Overridden virtual functions | |
24 | ||
25 | #include <fstream> | |
26 | #include <locale> | |
debac9f4 | 27 | #include <cstdlib> |
c03d83d4 PC |
28 | |
29 | #include <sys/types.h> | |
30 | #include <sys/stat.h> | |
31 | ||
32 | #include <testsuite_hooks.h> | |
33 | ||
34 | // libstdc++/13171 | |
9339bda8 | 35 | bool test01() |
c03d83d4 | 36 | { |
118c8424 | 37 | bool test = true; |
c03d83d4 | 38 | using namespace std; |
ea1ea21a | 39 | using namespace __gnu_test; |
c03d83d4 | 40 | |
4216708a JM |
41 | locale loc_fr(locale(ISO_8859(15,fr_FR))); |
42 | locale loc_en(locale(ISO_8859(1,en_US))); | |
2d25605a | 43 | |
c03d83d4 PC |
44 | const char* name = "tmp_fifo_13171-2"; |
45 | unlink(name); | |
34f4edf8 | 46 | mkfifo(name, S_IRWXU); |
8f1032c1 | 47 | semaphore s1, s2; |
c03d83d4 PC |
48 | |
49 | int child = fork(); | |
50 | if (child == 0) | |
51 | { | |
52 | filebuf fb; | |
53 | fb.open(name, ios_base::out); | |
54 | fb.sputc('S'); | |
2d25605a | 55 | fb.pubsync(); |
9339bda8 PC |
56 | s1.signal(); |
57 | s2.wait(); | |
c03d83d4 | 58 | fb.close(); |
2d25605a | 59 | exit(0); |
c03d83d4 PC |
60 | } |
61 | ||
62 | filebuf fb; | |
2d25605a | 63 | fb.pubimbue(loc_fr); |
c03d83d4 | 64 | fb.open(name, ios_base::in); |
9339bda8 | 65 | s1.wait(); |
118c8424 | 66 | test &= bool( fb.is_open() ); |
2d25605a | 67 | fb.pubimbue(loc_en); |
c03d83d4 | 68 | filebuf::int_type c = fb.sgetc(); |
c03d83d4 | 69 | fb.close(); |
118c8424 | 70 | test &= bool( c == 'S' ); |
9339bda8 PC |
71 | s2.signal(); |
72 | ||
73 | return test; | |
c03d83d4 PC |
74 | } |
75 | ||
76 | int main() | |
77 | { | |
9339bda8 | 78 | return !test01(); |
c03d83d4 | 79 | } |