build: doc: emit something for each "make check"-run rule
[coreutils.git] / lib / xmemxfrm.c
blob84f51583bcfa3b3b138f4f35ac6dd7d452d3147f
1 /* Locale-specific memory transformation
3 Copyright (C) 2006 Free Software Foundation, Inc.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* Written by Paul Eggert <eggert@cs.ucla.edu>. */
20 #include <config.h>
22 #include "xmemxfrm.h"
24 #include <errno.h>
25 #include <stdlib.h>
27 #include "gettext.h"
28 #define _(msgid) gettext (msgid)
30 #include "error.h"
31 #include "exitfail.h"
32 #include "memxfrm.h"
33 #include "quotearg.h"
35 /* Store into DEST (of size DESTSIZE) the text in SRC (of size
36 SRCSIZE) transformed so that the result of memcmp on two
37 transformed texts (with ties going to the longer text) is the same
38 as the result of memcoll on the two texts before their
39 transformation. Perhaps temporarily modify the byte after SRC, but
40 restore its original contents before returning.
42 Return the size of the resulting text. DEST contains an
43 indeterminate value if the resulting size is greater than DESTSIZE.
44 Report an error and exit if there is an error. */
46 size_t
47 xmemxfrm (char *restrict dest, size_t destsize,
48 char *restrict src, size_t srcsize)
50 size_t translated_size = memxfrm (dest, destsize, src, srcsize);
52 if (errno)
54 error (0, errno, _("string transformation failed"));
55 error (0, 0, _("set LC_ALL='C' to work around the problem"));
56 error (exit_failure, 0,
57 _("the untransformed string was %s"),
58 quotearg_n_style_mem (0, locale_quoting_style, src, srcsize));
61 return translated_size;