Mercurial > hg > octave-lojdl > gnulib-hg
annotate lib/xmemcoll.c @ 17325:9d7698fd5b5f
openpty: fix bug where HAVE_OPENPTY is mistakenly 1
Problem reported by Mats Erik Andersson in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-02/msg00051.html>.
* m4/pty.m4 (gl_FUNC_OPENPTY): Define HAVE_OPENPTY when the
openpty function exists, not merely when we intend to replace it.
This corrects the 2013-01-31 patch, which mistakenly defined
HAVE_OPENPTY even on hosts that lacked it.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 08 Feb 2013 08:03:23 -0800 |
parents | e542fd46ad6f |
children |
rev | line source |
---|---|
3711 | 1 /* Locale-specific memory comparison. |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
2 |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16201
diff
changeset
|
3 Copyright (C) 2002-2004, 2006, 2009-2013 Free Software Foundation, Inc. |
3711 | 4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
3711 | 6 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:
7302
diff
changeset
|
7 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:
7302
diff
changeset
|
8 (at your option) any later version. |
3711 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
3711 | 17 |
18 /* Contributed by Paul Eggert <eggert@twinsun.com>. */ | |
19 | |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
20 #include <config.h> |
3711 | 21 |
22 #include <errno.h> | |
23 #include <stdlib.h> | |
24 | |
3966
22d3032f0239
Include gettext.h instead of <libintl.h> with #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
3711
diff
changeset
|
25 #include "gettext.h" |
22d3032f0239
Include gettext.h instead of <libintl.h> with #ifdefs.
Bruno Haible <bruno@clisp.org>
parents:
3711
diff
changeset
|
26 #define _(msgid) gettext (msgid) |
3711 | 27 |
28 #include "error.h" | |
4473
fd6696a97000
Sync with coreutils xalloc.h, xmalloc.c, xmemcoll.h, xmemcoll.c.
Paul Eggert <eggert@cs.ucla.edu>
parents:
3966
diff
changeset
|
29 #include "exitfail.h" |
3711 | 30 #include "memcoll.h" |
31 #include "quotearg.h" | |
32 #include "xmemcoll.h" | |
33 | |
13453
c5416617cfbf
(x)memcoll: minor tweaks
Paul Eggert <eggert@cs.ucla.edu>
parents:
13452
diff
changeset
|
34 static void |
c5416617cfbf
(x)memcoll: minor tweaks
Paul Eggert <eggert@cs.ucla.edu>
parents:
13452
diff
changeset
|
35 collate_error (int collation_errno, |
c5416617cfbf
(x)memcoll: minor tweaks
Paul Eggert <eggert@cs.ucla.edu>
parents:
13452
diff
changeset
|
36 char const *s1, size_t s1len, |
c5416617cfbf
(x)memcoll: minor tweaks
Paul Eggert <eggert@cs.ucla.edu>
parents:
13452
diff
changeset
|
37 char const *s2, size_t s2len) |
13452
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
38 { |
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
39 error (0, collation_errno, _("string comparison failed")); |
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
40 error (0, 0, _("Set LC_ALL='C' to work around the problem.")); |
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
41 error (exit_failure, 0, |
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
42 _("The strings compared were %s and %s."), |
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
43 quotearg_n_style_mem (0, locale_quoting_style, s1, s1len), |
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
44 quotearg_n_style_mem (1, locale_quoting_style, s2, s2len)); |
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
45 } |
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
46 |
3711 | 47 /* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according |
48 to the LC_COLLATE locale. S1 and S2 do not overlap, and are not | |
49 adjacent. Temporarily modify the bytes after S1 and S2, but | |
50 restore their original contents before returning. Report an error | |
51 and exit if there is an error. */ | |
52 | |
53 int | |
54 xmemcoll (char *s1, size_t s1len, char *s2, size_t s2len) | |
55 { | |
56 int diff = memcoll (s1, s1len, s2, s2len); | |
57 int collation_errno = errno; | |
58 if (collation_errno) | |
13452
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
59 collate_error (collation_errno, s1, s1len, s2, s2len); |
3711 | 60 return diff; |
61 } | |
13452
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
62 |
13719
ba8adb841ec0
memcoll, xmemcoll: Clarify size vs. length.
Bruno Haible <bruno@clisp.org>
parents:
13459
diff
changeset
|
63 /* Compare S1 (a memory block of size S1SIZE, with a NUL as last byte) |
ba8adb841ec0
memcoll, xmemcoll: Clarify size vs. length.
Bruno Haible <bruno@clisp.org>
parents:
13459
diff
changeset
|
64 and S2 (a memory block of size S2SIZE, with a NUL as last byte) |
ba8adb841ec0
memcoll, xmemcoll: Clarify size vs. length.
Bruno Haible <bruno@clisp.org>
parents:
13459
diff
changeset
|
65 according to the LC_COLLATE locale. S1SIZE and S2SIZE must be > 0. |
13459
0a02e7a4ac23
memcoll: clarify sizes versus lengths, document better, and tweak perf
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
13453
diff
changeset
|
66 Report an error and exit if there is an error. */ |
13452
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
67 |
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
68 int |
13719
ba8adb841ec0
memcoll, xmemcoll: Clarify size vs. length.
Bruno Haible <bruno@clisp.org>
parents:
13459
diff
changeset
|
69 xmemcoll0 (char const *s1, size_t s1size, char const *s2, size_t s2size) |
13452
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
70 { |
13719
ba8adb841ec0
memcoll, xmemcoll: Clarify size vs. length.
Bruno Haible <bruno@clisp.org>
parents:
13459
diff
changeset
|
71 int diff = memcoll0 (s1, s1size, s2, s2size); |
13452
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
72 int collation_errno = errno; |
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
73 if (collation_errno) |
13719
ba8adb841ec0
memcoll, xmemcoll: Clarify size vs. length.
Bruno Haible <bruno@clisp.org>
parents:
13459
diff
changeset
|
74 collate_error (collation_errno, s1, s1size - 1, s2, s2size - 1); |
13452
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
75 return diff; |
edb3fc126c07
(x)memcoll: speedup when input is known to be NUL delimited
Chen Guo <chenguo4@yahoo.com>
parents:
12559
diff
changeset
|
76 } |