Mercurial > gnulib
annotate tests/test-wcsrtombs.c @ 40196:e63f5d3edab5
relocatable-prog: Update documentation.
* doc/relocatable-maint.texi (Supporting Relocation): Update to match
the recent changes.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 24 Feb 2019 01:49:15 +0100 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
10942 | 1 /* Test of conversion of wide string to string. |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
2 Copyright (C) 2008-2019 Free Software Foundation, Inc. |
10942 | 3 |
4 This program is free software: you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 3 of the License, or | |
7 (at your option) any later version. | |
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/>. */ |
10942 | 16 |
17 /* Written by Bruno Haible <bruno@clisp.org>, 2008. */ | |
18 | |
19 #include <config.h> | |
20 | |
21 #include <wchar.h> | |
22 | |
12489 | 23 #include "signature.h" |
24 SIGNATURE_CHECK (wcsrtombs, size_t, (char *, wchar_t const **, size_t, | |
25 mbstate_t *)); | |
26 | |
10942 | 27 #include <locale.h> |
28 #include <stdlib.h> | |
29 #include <string.h> | |
30 | |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12489
diff
changeset
|
31 #include "macros.h" |
10942 | 32 |
33 int | |
34 main (int argc, char *argv[]) | |
35 { | |
36 /* configure should already have checked that the locale is supported. */ | |
37 if (setlocale (LC_ALL, "") == NULL) | |
38 return 1; | |
39 | |
40 if (argc > 1) | |
41 { | |
42 wchar_t input[10]; | |
43 size_t n; | |
44 const wchar_t *src; | |
45 #define BUFSIZE 20 | |
46 char buf[BUFSIZE]; | |
47 size_t ret; | |
48 | |
49 { | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
50 size_t i; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
51 for (i = 0; i < BUFSIZE; i++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
52 buf[i] = '_'; |
10942 | 53 } |
54 | |
55 switch (argv[1][0]) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
56 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
57 case '1': |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
58 /* Locale encoding is ISO-8859-1 or ISO-8859-15. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
59 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
60 const char original[] = "B\374\337er"; /* "Büßer" */ |
10942 | 61 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
62 ret = mbstowcs (input, original, 10); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
63 ASSERT (ret == 5); |
10942 | 64 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
65 for (n = 0; n < 10; n++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
66 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
67 src = input; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
68 ret = wcsrtombs (NULL, &src, n, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
69 ASSERT (ret == 5); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
70 ASSERT (src == input); |
10942 | 71 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
72 src = input; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
73 ret = wcsrtombs (buf, &src, n, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
74 ASSERT (ret == (n <= 5 ? n : 5)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
75 ASSERT (src == (n <= 5 ? input + n : NULL)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
76 ASSERT (memcmp (buf, original, ret) == 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
77 if (src == NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
78 ASSERT (buf[ret] == '\0'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
79 ASSERT (buf[ret + (src == NULL) + 0] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
80 ASSERT (buf[ret + (src == NULL) + 1] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
81 ASSERT (buf[ret + (src == NULL) + 2] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
82 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
83 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
84 break; |
10942 | 85 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
86 case '2': |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
87 /* Locale encoding is UTF-8. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
88 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
89 const char original[] = "B\303\274\303\237er"; /* "Büßer" */ |
10942 | 90 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
91 ret = mbstowcs (input, original, 10); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
92 ASSERT (ret == 5); |
10942 | 93 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
94 for (n = 0; n < 10; n++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
95 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
96 src = input; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
97 ret = wcsrtombs (NULL, &src, n, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
98 ASSERT (ret == 7); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
99 ASSERT (src == input); |
10942 | 100 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
101 src = input; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
102 ret = wcsrtombs (buf, &src, n, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
103 ASSERT (ret == (n < 1 ? n : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
104 n < 3 ? 1 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
105 n < 5 ? 3 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
106 n <= 7 ? n : 7)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
107 ASSERT (src == (n < 1 ? input + n : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
108 n < 3 ? input + 1 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
109 n < 5 ? input + 2 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
110 n <= 7 ? input + (n - 2) : NULL)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
111 ASSERT (memcmp (buf, original, ret) == 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
112 if (src == NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
113 ASSERT (buf[ret] == '\0'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
114 ASSERT (buf[ret + (src == NULL) + 0] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
115 ASSERT (buf[ret + (src == NULL) + 1] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
116 ASSERT (buf[ret + (src == NULL) + 2] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
117 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
118 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
119 break; |
10942 | 120 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
121 case '3': |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
122 /* Locale encoding is EUC-JP. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
123 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
124 const char original[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */ |
10942 | 125 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
126 ret = mbstowcs (input, original, 10); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
127 ASSERT (ret == 5); |
10942 | 128 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
129 for (n = 0; n < 10; n++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
130 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
131 src = input; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
132 ret = wcsrtombs (NULL, &src, n, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
133 ASSERT (ret == 8); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
134 ASSERT (src == input); |
10942 | 135 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
136 src = input; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
137 ret = wcsrtombs (buf, &src, n, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
138 ASSERT (ret == (n < 1 ? n : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
139 n < 3 ? 1 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
140 n < 5 ? 3 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
141 n < 7 ? 5 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
142 n <= 8 ? n : 8)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
143 ASSERT (src == (n < 1 ? input + n : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
144 n < 3 ? input + 1 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
145 n < 5 ? input + 2 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
146 n < 7 ? input + 3 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
147 n <= 8 ? input + (n - 3) : NULL)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
148 ASSERT (memcmp (buf, original, ret) == 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
149 if (src == NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
150 ASSERT (buf[ret] == '\0'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
151 ASSERT (buf[ret + (src == NULL) + 0] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
152 ASSERT (buf[ret + (src == NULL) + 1] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
153 ASSERT (buf[ret + (src == NULL) + 2] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
154 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
155 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
156 break; |
10942 | 157 |
158 | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
159 case '4': |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
160 /* Locale encoding is GB18030. */ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
161 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
162 const char original[] = "B\250\271\201\060\211\070er"; /* "Büßer" */ |
10942 | 163 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
164 ret = mbstowcs (input, original, 10); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
165 ASSERT (ret == 5); |
10942 | 166 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
167 for (n = 0; n < 10; n++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
168 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
169 src = input; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
170 ret = wcsrtombs (NULL, &src, n, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
171 ASSERT (ret == 9); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
172 ASSERT (src == input); |
10942 | 173 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
174 src = input; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
175 ret = wcsrtombs (buf, &src, n, NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
176 ASSERT (ret == (n < 1 ? n : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
177 n < 3 ? 1 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
178 n < 7 ? 3 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
179 n <= 9 ? n : 9)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
180 ASSERT (src == (n < 1 ? input + n : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
181 n < 3 ? input + 1 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
182 n < 7 ? input + 2 : |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
183 n <= 9 ? input + (n - 4) : NULL)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
184 ASSERT (memcmp (buf, original, ret) == 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
185 if (src == NULL) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
186 ASSERT (buf[ret] == '\0'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
187 ASSERT (buf[ret + (src == NULL) + 0] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
188 ASSERT (buf[ret + (src == NULL) + 1] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
189 ASSERT (buf[ret + (src == NULL) + 2] == '_'); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
190 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
191 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
192 break; |
10942 | 193 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
194 default: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
195 return 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
10942
diff
changeset
|
196 } |
10942 | 197 |
198 return 0; | |
199 } | |
200 | |
201 return 1; | |
202 } |