| 1 |
// { dg-require-namedlocale "fr_FR.ISO8859-15" } |
| 2 |
// { dg-require-namedlocale "en_US.ISO8859-1" } |
| 3 |
// { dg-require-fork "" } |
| 4 |
// { dg-require-mkfifo "" } |
| 5 |
|
| 6 |
// Copyright (C) 2003-2025 Free Software Foundation, Inc. |
| 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 |
| 11 |
// Free Software Foundation; either version 3, or (at your option) |
| 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 |
| 20 |
// with this library; see the file COPYING3. If not see |
| 21 |
// <http://www.gnu.org/licenses/>. |
| 22 |
|
| 23 |
// 27.8.1.4 Overridden virtual functions |
| 24 |
|
| 25 |
#include <fstream> |
| 26 |
#include <locale> |
| 27 |
#include <cstdlib> |
| 28 |
|
| 29 |
#include <sys/types.h> |
| 30 |
#include <sys/stat.h> |
| 31 |
|
| 32 |
#include <testsuite_hooks.h> |
| 33 |
|
| 34 |
// libstdc++/13171 |
| 35 |
bool test01() |
| 36 |
{ |
| 37 |
bool test = true; |
| 38 |
using namespace std; |
| 39 |
using namespace __gnu_test; |
| 40 |
|
| 41 |
locale loc_fr(locale(ISO_8859(15,fr_FR))); |
| 42 |
locale loc_en(locale(ISO_8859(1,en_US))); |
| 43 |
|
| 44 |
const char* name = "tmp_fifo_13171-2"; |
| 45 |
unlink(name); |
| 46 |
mkfifo(name, S_IRWXU); |
| 47 |
semaphore s1, s2; |
| 48 |
|
| 49 |
int child = fork(); |
| 50 |
if (child == 0) |
| 51 |
{ |
| 52 |
filebuf fb; |
| 53 |
fb.open(name, ios_base::out); |
| 54 |
fb.sputc('S'); |
| 55 |
fb.pubsync(); |
| 56 |
s1.signal(); |
| 57 |
s2.wait(); |
| 58 |
fb.close(); |
| 59 |
exit(0); |
| 60 |
} |
| 61 |
|
| 62 |
filebuf fb; |
| 63 |
fb.pubimbue(loc_fr); |
| 64 |
fb.open(name, ios_base::in); |
| 65 |
s1.wait(); |
| 66 |
test &= bool( fb.is_open() ); |
| 67 |
fb.pubimbue(loc_en); |
| 68 |
filebuf::int_type c = fb.sgetc(); |
| 69 |
fb.close(); |
| 70 |
test &= bool( c == 'S' ); |
| 71 |
s2.signal(); |
| 72 |
|
| 73 |
return test; |
| 74 |
} |
| 75 |
|
| 76 |
int main() |
| 77 |
{ |
| 78 |
return !test01(); |
| 79 |
} |