blob: 2f49d5a86ac613bb898e4658551600c3ee62b608 [file] [log] [blame]
Erik Andersenfb002d02000-03-05 08:07:00 +00001/* vi: set sw=4 ts=4: */
2/*
Erik Andersen8f8d6d52000-05-01 22:30:37 +00003 * Mini tr implementation for busybox
Erik Andersenfb002d02000-03-05 08:07:00 +00004 *
Rob Landleycd545282006-06-30 16:35:40 +00005 ** Copyright (c) 1987,1997, Prentice Hall All rights reserved.
6 *
7 * The name of Prentice Hall may not be used to endorse or promote
8 * products derived from this software without specific prior
9 * written permission.
10 *
Erik Andersen5afc8642000-05-02 00:07:56 +000011 * Copyright (c) Michiel Huisjes
12 *
Eric Andersenc7bda1c2004-03-15 08:29:22 +000013 * This version of tr is adapted from Minix tr and was modified
Eric Andersencb81e642003-07-14 21:21:08 +000014 * by Erik Andersen <andersen@codepoet.org> to be used in busybox.
Erik Andersenfb002d02000-03-05 08:07:00 +000015 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +020016 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
Erik Andersenfb002d02000-03-05 08:07:00 +000017 */
Bernhard Reutner-Fischereceecea2007-03-30 14:43:27 +000018/* http://www.opengroup.org/onlinepubs/009695399/utilities/tr.html
Denis Vlasenko491d6e32009-03-02 12:05:57 +000019 * TODO: graph, print
Bernhard Reutner-Fischereceecea2007-03-30 14:43:27 +000020 */
Denys Vlasenkoe4070cb2010-06-04 19:59:49 +020021
22//kbuild:lib-$(CONFIG_TR) += tr.o
23
24//config:config TR
25//config: bool "tr"
Denys Vlasenko2f32bf82010-06-06 04:14:28 +020026//config: default y
Denys Vlasenkoe4070cb2010-06-04 19:59:49 +020027//config: help
28//config: tr is used to squeeze, and/or delete characters from standard
29//config: input, writing to standard output.
Denys Vlasenko729ce472010-06-05 21:29:41 +020030//config:
31//config:config FEATURE_TR_CLASSES
32//config: bool "Enable character classes (such as [:upper:])"
Denys Vlasenko2f32bf82010-06-06 04:14:28 +020033//config: default y
Denys Vlasenko729ce472010-06-05 21:29:41 +020034//config: depends on TR
35//config: help
36//config: Enable character classes, enabling commands such as:
37//config: tr [:upper:] [:lower:] to convert input into lowercase.
38//config:
39//config:config FEATURE_TR_EQUIV
40//config: bool "Enable equivalence classes"
Denys Vlasenko2f32bf82010-06-06 04:14:28 +020041//config: default y
Denys Vlasenko729ce472010-06-05 21:29:41 +020042//config: depends on TR
43//config: help
44//config: Enable equivalence classes, which essentially add the enclosed
45//config: character to the current set. For instance, tr [=a=] xyz would
46//config: replace all instances of 'a' with 'xyz'. This option is mainly
47//config: useful for cases when no other way of expressing a character
48//config: is possible.
Denys Vlasenkoe4070cb2010-06-04 19:59:49 +020049
Pere Orga34425382011-03-31 14:43:25 +020050//usage:#define tr_trivial_usage
51//usage: "[-cds] STRING1 [STRING2]"
52//usage:#define tr_full_usage "\n\n"
53//usage: "Translate, squeeze, or delete characters from stdin, writing to stdout\n"
Pere Orga34425382011-03-31 14:43:25 +020054//usage: "\n -c Take complement of STRING1"
55//usage: "\n -d Delete input characters coded STRING1"
56//usage: "\n -s Squeeze multiple output characters of STRING2 into one character"
57//usage:
58//usage:#define tr_example_usage
59//usage: "$ echo \"gdkkn vnqkc\" | tr [a-y] [b-z]\n"
60//usage: "hello world\n"
61
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000062#include "libbb.h"
Erik Andersen330fd2b2000-05-19 05:35:19 +000063
Denis Vlasenko491d6e32009-03-02 12:05:57 +000064enum {
65 ASCII = 256,
66 /* string buffer needs to be at least as big as the whole "alphabet".
67 * BUFSIZ == ASCII is ok, but we will realloc in expand
68 * even for smallest patterns, let's avoid that by using *2:
69 */
70 TR_BUFSIZ = (BUFSIZ > ASCII*2) ? BUFSIZ : ASCII*2,
71};
Erik Andersenfb002d02000-03-05 08:07:00 +000072
Denis Vlasenko74324c82007-06-04 10:16:52 +000073static void map(char *pvector,
Denis Vlasenko491d6e32009-03-02 12:05:57 +000074 char *string1, unsigned string1_len,
75 char *string2, unsigned string2_len)
Erik Andersen8f8d6d52000-05-01 22:30:37 +000076{
Rob Landleyab58d5c2006-06-30 19:04:09 +000077 char last = '0';
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +000078 unsigned i, j;
Erik Andersen8f8d6d52000-05-01 22:30:37 +000079
Eric Andersen00143ba2000-07-13 16:40:41 +000080 for (j = 0, i = 0; i < string1_len; i++) {
81 if (string2_len <= j)
Denis Vlasenko491d6e32009-03-02 12:05:57 +000082 pvector[(unsigned char)(string1[i])] = last;
Erik Andersen8f8d6d52000-05-01 22:30:37 +000083 else
Denis Vlasenko491d6e32009-03-02 12:05:57 +000084 pvector[(unsigned char)(string1[i])] = last = string2[j++];
Erik Andersen8f8d6d52000-05-01 22:30:37 +000085 }
86}
87
Mark Whitley8b7a0d82001-05-24 21:31:09 +000088/* supported constructs:
Denis Vlasenko3d461672007-11-13 22:22:29 +000089 * Ranges, e.g., 0-9 ==> 0123456789
Denis Vlasenko3d461672007-11-13 22:22:29 +000090 * Escapes, e.g., \a ==> Control-G
91 * Character classes, e.g. [:upper:] ==> A...Z
92 * Equiv classess, e.g. [=A=] ==> A (hmmmmmmm?)
Denis Vlasenko9210a362009-03-15 16:41:55 +000093 * not supported:
Denis Vlasenko9210a362009-03-15 16:41:55 +000094 * [x*N] - repeat char x N times
95 * [x*] - repeat char x until it fills STRING2:
96 * # echo qwe123 | /usr/bin/tr 123456789 '[d]'
97 * qwe[d]
98 * # echo qwe123 | /usr/bin/tr 123456789 '[d*]'
99 * qweddd
Mark Whitley8b7a0d82001-05-24 21:31:09 +0000100 */
Richard Genoudd683c5c2015-10-26 10:10:28 +0100101static unsigned expand(char *arg, char **buffer_p)
Erik Andersen8f8d6d52000-05-01 22:30:37 +0000102{
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000103 char *buffer = *buffer_p;
104 unsigned pos = 0;
105 unsigned size = TR_BUFSIZ;
Denis Vlasenko3d461672007-11-13 22:22:29 +0000106 unsigned i; /* can't be unsigned char: must be able to hold 256 */
Bernhard Reutner-Fischereceecea2007-03-30 14:43:27 +0000107 unsigned char ac;
Denis Vlasenko3d461672007-11-13 22:22:29 +0000108
109 while (*arg) {
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000110 if (pos + ASCII > size) {
111 size += ASCII;
112 *buffer_p = buffer = xrealloc(buffer, size);
113 }
Denis Vlasenko3d461672007-11-13 22:22:29 +0000114 if (*arg == '\\') {
Richard Genoudd683c5c2015-10-26 10:10:28 +0100115 const char *z;
Denis Vlasenko3d461672007-11-13 22:22:29 +0000116 arg++;
Richard Genoudd683c5c2015-10-26 10:10:28 +0100117 z = arg;
118 ac = bb_process_escape_sequence(&z);
119 arg = (char *)z;
120 arg--;
121 *arg = ac;
122 /*
123 * fall through, there may be a range.
124 * If not, current char will be treated anyway.
125 */
Denis Vlasenko3d461672007-11-13 22:22:29 +0000126 }
127 if (arg[1] == '-') { /* "0-9..." */
128 ac = arg[2];
129 if (ac == '\0') { /* "0-": copy verbatim */
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000130 buffer[pos++] = *arg++; /* copy '0' */
Denis Vlasenko3d461672007-11-13 22:22:29 +0000131 continue; /* next iter will copy '-' and stop */
132 }
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000133 i = (unsigned char) *arg;
Richard Genoudd683c5c2015-10-26 10:10:28 +0100134 arg += 3; /* skip 0-9 or 0-\ */
135 if (ac == '\\') {
136 const char *z;
137 z = arg;
138 ac = bb_process_escape_sequence(&z);
139 arg = (char *)z;
140 }
Denis Vlasenko3d461672007-11-13 22:22:29 +0000141 while (i <= ac) /* ok: i is unsigned _int_ */
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000142 buffer[pos++] = i++;
Denis Vlasenko3d461672007-11-13 22:22:29 +0000143 continue;
144 }
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000145 if ((ENABLE_FEATURE_TR_CLASSES || ENABLE_FEATURE_TR_EQUIV)
146 && *arg == '['
147 ) {
Denis Vlasenko3d461672007-11-13 22:22:29 +0000148 arg++;
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000149 i = (unsigned char) *arg++;
150 /* "[xyz...". i=x, arg points to y */
151 if (ENABLE_FEATURE_TR_CLASSES && i == ':') { /* [:class:] */
Denis Vlasenko990d0f62007-07-24 15:54:42 +0000152#define CLO ":]\0"
Denis Vlasenko3d461672007-11-13 22:22:29 +0000153 static const char classes[] ALIGN1 =
154 "alpha"CLO "alnum"CLO "digit"CLO
155 "lower"CLO "upper"CLO "space"CLO
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000156 "blank"CLO "punct"CLO "cntrl"CLO
157 "xdigit"CLO;
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000158 enum {
159 CLASS_invalid = 0, /* we increment the retval */
160 CLASS_alpha = 1,
161 CLASS_alnum = 2,
162 CLASS_digit = 3,
163 CLASS_lower = 4,
164 CLASS_upper = 5,
165 CLASS_space = 6,
166 CLASS_blank = 7,
167 CLASS_punct = 8,
168 CLASS_cntrl = 9,
169 CLASS_xdigit = 10,
170 //CLASS_graph = 11,
171 //CLASS_print = 12,
172 };
Bernhard Reutner-Fischereceecea2007-03-30 14:43:27 +0000173 smalluint j;
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000174 char *tmp;
175
176 /* xdigit needs 8, not 7 */
177 i = 7 + (arg[0] == 'x');
178 tmp = xstrndup(arg, i);
179 j = index_in_strings(classes, tmp) + 1;
180 free(tmp);
181
182 if (j == CLASS_invalid)
183 goto skip_bracket;
184
185 arg += i;
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000186 if (j == CLASS_alnum || j == CLASS_digit || j == CLASS_xdigit) {
Rob Landley998dbee2006-04-19 22:22:06 +0000187 for (i = '0'; i <= '9'; i++)
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000188 buffer[pos++] = i;
Bernhard Reutner-Fischereceecea2007-03-30 14:43:27 +0000189 }
190 if (j == CLASS_alpha || j == CLASS_alnum || j == CLASS_upper) {
Rob Landleyf1048142005-10-08 21:21:08 +0000191 for (i = 'A'; i <= 'Z'; i++)
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000192 buffer[pos++] = i;
Bernhard Reutner-Fischereceecea2007-03-30 14:43:27 +0000193 }
194 if (j == CLASS_alpha || j == CLASS_alnum || j == CLASS_lower) {
Rob Landleyf1048142005-10-08 21:21:08 +0000195 for (i = 'a'; i <= 'z'; i++)
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000196 buffer[pos++] = i;
Rob Landleyf1048142005-10-08 21:21:08 +0000197 }
Bernhard Reutner-Fischereceecea2007-03-30 14:43:27 +0000198 if (j == CLASS_space || j == CLASS_blank) {
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000199 buffer[pos++] = '\t';
Bernhard Reutner-Fischereceecea2007-03-30 14:43:27 +0000200 if (j == CLASS_space) {
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000201 buffer[pos++] = '\n';
202 buffer[pos++] = '\v';
203 buffer[pos++] = '\f';
204 buffer[pos++] = '\r';
Bernhard Reutner-Fischereceecea2007-03-30 14:43:27 +0000205 }
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000206 buffer[pos++] = ' ';
Rob Landley998dbee2006-04-19 22:22:06 +0000207 }
Bernhard Reutner-Fischereceecea2007-03-30 14:43:27 +0000208 if (j == CLASS_punct || j == CLASS_cntrl) {
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000209 for (i = '\0'; i < ASCII; i++) {
Denys Vlasenko8684cbb2009-11-18 11:34:43 +0100210 if ((j == CLASS_punct && isprint_asciionly(i) && !isalnum(i) && !isspace(i))
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000211 || (j == CLASS_cntrl && iscntrl(i))
212 ) {
213 buffer[pos++] = i;
214 }
215 }
Rob Landleyf1048142005-10-08 21:21:08 +0000216 }
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000217 if (j == CLASS_xdigit) {
218 for (i = 'A'; i <= 'F'; i++) {
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000219 buffer[pos + 6] = i | 0x20;
220 buffer[pos++] = i;
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000221 }
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000222 pos += 6;
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000223 }
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000224 continue;
Rob Landleyf1048142005-10-08 21:21:08 +0000225 }
Denis Vlasenko3d461672007-11-13 22:22:29 +0000226 /* "[xyz...", i=x, arg points to y */
227 if (ENABLE_FEATURE_TR_EQUIV && i == '=') { /* [=CHAR=] */
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000228 buffer[pos++] = *arg; /* copy CHAR */
229 if (!arg[0] || arg[1] != '=' || arg[2] != ']')
Denis Vlasenko043d15d2008-07-28 23:49:42 +0000230 bb_show_usage();
Denys Vlasenkofb132e42010-10-29 11:46:52 +0200231 arg += 3; /* skip CHAR=] */
Rob Landleyf1048142005-10-08 21:21:08 +0000232 continue;
233 }
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000234 /* The rest of "[xyz..." cases is treated as normal
235 * string, "[" has no special meaning here:
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000236 * tr "[a-z]" "[A-Z]" can be written as tr "a-z" "A-Z",
237 * also try tr "[a-z]" "_A-Z+" and you'll see that
238 * [] is not special here.
239 */
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000240 skip_bracket:
241 arg -= 2; /* points to "[" in "[xyz..." */
Denis Vlasenko3d461672007-11-13 22:22:29 +0000242 }
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000243 buffer[pos++] = *arg++;
Erik Andersen8f8d6d52000-05-01 22:30:37 +0000244 }
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000245 return pos;
Erik Andersen8f8d6d52000-05-01 22:30:37 +0000246}
247
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000248/* NB: buffer is guaranteed to be at least TR_BUFSIZE
249 * (which is >= ASCII) big.
250 */
Rob Landleyab58d5c2006-06-30 19:04:09 +0000251static int complement(char *buffer, int buffer_len)
Erik Andersen8f8d6d52000-05-01 22:30:37 +0000252{
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000253 int len;
254 char conv[ASCII];
255 unsigned char ch;
Erik Andersen8f8d6d52000-05-01 22:30:37 +0000256
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000257 len = 0;
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000258 ch = '\0';
259 while (1) {
260 if (memchr(buffer, ch, buffer_len) == NULL)
261 conv[len++] = ch;
262 if (++ch == '\0')
263 break;
Erik Andersen8f8d6d52000-05-01 22:30:37 +0000264 }
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000265 memcpy(buffer, conv, len);
266 return len;
Erik Andersen8f8d6d52000-05-01 22:30:37 +0000267}
268
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +0000269int tr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenkoa60f84e2008-07-05 09:18:54 +0000270int tr_main(int argc UNUSED_PARAM, char **argv)
Erik Andersen8f8d6d52000-05-01 22:30:37 +0000271{
Eric Andersenfad04fd2000-07-14 06:49:52 +0000272 int i;
Denis Vlasenko9210a362009-03-15 16:41:55 +0000273 smalluint opts;
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000274 ssize_t read_chars;
275 size_t in_index, out_index;
Denis Vlasenko3d461672007-11-13 22:22:29 +0000276 unsigned last = UCHAR_MAX + 1; /* not equal to any char */
Denis Vlasenkof7be20e2007-12-24 14:09:19 +0000277 unsigned char coded, c;
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000278 char *str1 = xmalloc(TR_BUFSIZ);
279 char *str2 = xmalloc(TR_BUFSIZ);
280 int str2_length;
281 int str1_length;
282 char *vector = xzalloc(ASCII * 3);
283 char *invec = vector + ASCII;
284 char *outvec = vector + ASCII * 2;
Mark Whitley59ab0252001-01-23 22:30:04 +0000285
Denys Vlasenkofb132e42010-10-29 11:46:52 +0200286#define TR_OPT_complement (3 << 0)
287#define TR_OPT_delete (1 << 2)
288#define TR_OPT_squeeze_reps (1 << 3)
Denis Vlasenko8d0a7342007-11-13 22:23:57 +0000289
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000290 for (i = 0; i < ASCII; i++) {
Erik Andersen8f8d6d52000-05-01 22:30:37 +0000291 vector[i] = i;
Denis Vlasenko8d0a7342007-11-13 22:23:57 +0000292 /*invec[i] = outvec[i] = FALSE; - done by xzalloc */
Erik Andersen8f8d6d52000-05-01 22:30:37 +0000293 }
294
Denis Vlasenko9210a362009-03-15 16:41:55 +0000295 /* -C/-c difference is that -C complements "characters",
296 * and -c complements "values" (binary bytes I guess).
297 * In POSIX locale, these are the same.
298 */
299
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000300 opt_complementary = "-1";
Denis Vlasenko9210a362009-03-15 16:41:55 +0000301 opts = getopt32(argv, "+Ccds"); /* '+': stop at first non-option */
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000302 argv += optind;
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000303
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000304 str1_length = expand(*argv++, &str1);
305 str2_length = 0;
Denis Vlasenko9210a362009-03-15 16:41:55 +0000306 if (opts & TR_OPT_complement)
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000307 str1_length = complement(str1, str1_length);
308 if (*argv) {
309 if (argv[0][0] == '\0')
310 bb_error_msg_and_die("STRING2 cannot be empty");
311 str2_length = expand(*argv, &str2);
312 map(vector, str1, str1_length,
313 str2, str2_length);
Erik Andersen8f8d6d52000-05-01 22:30:37 +0000314 }
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000315 for (i = 0; i < str1_length; i++)
316 invec[(unsigned char)(str1[i])] = TRUE;
317 for (i = 0; i < str2_length; i++)
318 outvec[(unsigned char)(str2[i])] = TRUE;
Denis Vlasenko74324c82007-06-04 10:16:52 +0000319
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000320 goto start_from;
321
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000322 /* In this loop, str1 space is reused as input buffer,
323 * str2 - as output one. */
Denis Vlasenko74324c82007-06-04 10:16:52 +0000324 for (;;) {
325 /* If we're out of input, flush output and read more input. */
Denis Vlasenko77ad97f2008-05-13 02:27:31 +0000326 if ((ssize_t)in_index == read_chars) {
Denis Vlasenko74324c82007-06-04 10:16:52 +0000327 if (out_index) {
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000328 xwrite(STDOUT_FILENO, str2, out_index);
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000329 start_from:
Denis Vlasenko74324c82007-06-04 10:16:52 +0000330 out_index = 0;
331 }
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000332 read_chars = safe_read(STDIN_FILENO, str1, TR_BUFSIZ);
Denis Vlasenko74324c82007-06-04 10:16:52 +0000333 if (read_chars <= 0) {
Denis Vlasenkoa89d50f2007-11-13 17:51:40 +0000334 if (read_chars < 0)
335 bb_perror_msg_and_die(bb_msg_read_error);
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000336 break;
Denis Vlasenko74324c82007-06-04 10:16:52 +0000337 }
338 in_index = 0;
339 }
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000340 c = str1[in_index++];
Denis Vlasenko9210a362009-03-15 16:41:55 +0000341 if ((opts & TR_OPT_delete) && invec[c])
Denis Vlasenko74324c82007-06-04 10:16:52 +0000342 continue;
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000343 coded = vector[c];
Denis Vlasenko9210a362009-03-15 16:41:55 +0000344 if ((opts & TR_OPT_squeeze_reps) && last == coded
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000345 && (invec[c] || outvec[coded])
346 ) {
Denis Vlasenko74324c82007-06-04 10:16:52 +0000347 continue;
Denis Vlasenko491d6e32009-03-02 12:05:57 +0000348 }
349 str2[out_index++] = last = coded;
Denis Vlasenko74324c82007-06-04 10:16:52 +0000350 }
Denis Vlasenko1bfcc8b2009-03-01 04:50:18 +0000351
Alexey Soloviev41478ad2011-03-06 18:21:07 +0100352 if (ENABLE_FEATURE_CLEAN_UP) {
353 free(vector);
354 free(str2);
355 free(str1);
356 }
357
Bernhard Reutner-Fischereceecea2007-03-30 14:43:27 +0000358 return EXIT_SUCCESS;
Erik Andersenfb002d02000-03-05 08:07:00 +0000359}