4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #pragma D option quiet
42 command[i].str = "foobarbaz";
43 command[i].substr = "barbaz";
46 command[i].str = "foofoofoo";
47 command[i].substr = "foo";
50 command[i].str = "boofoofoo";
51 command[i].substr = "foo";
54 command[i].str = "foobarbaz";
55 command[i].substr = "barbazzy";
58 command[i].str = "foobar";
59 command[i].substr = "foobar";
62 command[i].str = "foobar";
63 command[i].substr = "foobarbaz";
67 command[i].substr = "foobar";
70 command[i].str = "foobar";
71 command[i].substr = "";
75 command[i].substr = "";
78 command[i].str = "foo";
79 command[i].substr = "";
83 printf("#!/usr/bin/perl\n\nBEGIN {\n");
89 command[i + k].str = command[j].str;
90 command[i + k].substr = command[j].substr;
91 command[i + k].haspos = 1;
92 command[i + k].position = -400;
95 command[i + k].str = command[j].str;
96 command[i + k].substr = command[j].substr;
97 command[i + k].haspos = 1;
98 command[i + k].position = -1;
101 command[i + k].str = command[j].str;
102 command[i + k].substr = command[j].substr;
103 command[i + k].haspos = 1;
104 command[i + k].position = 0;
107 command[i + k].str = command[j].str;
108 command[i + k].substr = command[j].substr;
109 command[i + k].haspos = 1;
110 command[i + k].position = strlen(command[j].str) / 2;
113 command[i + k].str = command[j].str;
114 command[i + k].substr = command[j].substr;
115 command[i + k].haspos = 1;
116 command[i + k].position = strlen(command[j].str);
119 command[i + k].str = command[j].str;
120 command[i + k].substr = command[j].substr;
121 command[i + k].haspos = 1;
122 command[i + k].position = strlen(command[j].str) + 1;
125 command[i + k].str = command[j].str;
126 command[i + k].substr = command[j].substr;
127 command[i + k].haspos = 1;
128 command[i + k].position = strlen(command[j].str) + 2;
131 command[i + k].str = command[j].str;
132 command[i + k].substr = command[j].substr;
133 command[i + k].haspos = 1;
134 command[i + k].position = 400;
148 /end != 0 && i < end && !command[i].haspos/
150 this->result = index(command[i].str, command[i].substr);
152 printf("\tif (index(\"%s\", \"%s\") != %d) {\n",
153 command[i].str, command[i].substr, this->result);
154 printf("\t\tprintf(\"perl => index(\\\"%s\\\", \\\"%s\\\") = ",
155 command[i].str, command[i].substr);
156 printf("%%d\\n\",\n\t\t index(\"%s\", \"%s\"));\n",
157 command[i].str, command[i].substr);
158 printf("\t\tprintf(\" D => index(\\\"%s\\\", \\\"%s\\\") = ",
159 command[i].str, command[i].substr);
160 printf("%d\\n\");\n", this->result);
161 printf("\t\t$failed++;\n");
166 /end != 0 && i < end && !command[i].haspos/
168 this->result = rindex(command[i].str, command[i].substr);
170 printf("\tif (rindex(\"%s\", \"%s\") != %d) {\n",
171 command[i].str, command[i].substr, this->result);
172 printf("\t\tprintf(\"perl => rindex(\\\"%s\\\", \\\"%s\\\") = ",
173 command[i].str, command[i].substr);
174 printf("%%d\\n\",\n\t\t rindex(\"%s\", \"%s\"));\n",
175 command[i].str, command[i].substr);
176 printf("\t\tprintf(\" D => rindex(\\\"%s\\\", \\\"%s\\\") = ",
177 command[i].str, command[i].substr);
178 printf("%d\\n\");\n", this->result);
179 printf("\t\t$failed++;\n");
184 /end != 0 && i < end && command[i].haspos/
186 this->result = index(command[i].str,
187 command[i].substr, command[i].position);
189 printf("\tif (index(\"%s\", \"%s\", %d) != %d) {\n", command[i].str,
190 command[i].substr, command[i].position, this->result);
191 printf("\t\tprintf(\"perl => index(\\\"%s\\\", \\\"%s\\\", %d) = ",
192 command[i].str, command[i].substr, command[i].position);
193 printf("%%d\\n\",\n\t\t index(\"%s\", \"%s\", %d));\n",
194 command[i].str, command[i].substr, command[i].position);
195 printf("\t\tprintf(\" D => index(\\\"%s\\\", \\\"%s\\\", %d) = ",
196 command[i].str, command[i].substr, command[i].position);
197 printf("%d\\n\");\n", this->result);
198 printf("\t\t$failed++;\n");
203 /end != 0 && i < end && command[i].haspos/
205 this->result = rindex(command[i].str,
206 command[i].substr, command[i].position);
208 printf("\tif (rindex(\"%s\", \"%s\", %d) != %d) {\n", command[i].str,
209 command[i].substr, command[i].position, this->result);
210 printf("\t\tprintf(\"perl => rindex(\\\"%s\\\", \\\"%s\\\", %d) = ",
211 command[i].str, command[i].substr, command[i].position);
212 printf("%%d\\n\",\n\t\t rindex(\"%s\", \"%s\", %d));\n",
213 command[i].str, command[i].substr, command[i].position);
214 printf("\t\tprintf(\" D => rindex(\\\"%s\\\", \\\"%s\\\", %d) = ",
215 command[i].str, command[i].substr, command[i].position);
216 printf("%d\\n\");\n", this->result);
217 printf("\t\t$failed++;\n");
222 /end != 0 && ++i == end/
224 printf("\texit($failed);\n}\n");