8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / dtrace / test / tst / common / funcs / tst.index.d
blob547730a14ea13fdbbfd396d7c728d4d614f3dcd2
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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
31 struct {
32 string str;
33 string substr;
34 int haspos;
35 int position;
36 } command[int];
38 int i;
40 BEGIN
42 command[i].str = "foobarbaz";
43 command[i].substr = "barbaz";
44 i++;
46 command[i].str = "foofoofoo";
47 command[i].substr = "foo";
48 i++;
50 command[i].str = "boofoofoo";
51 command[i].substr = "foo";
52 i++;
54 command[i].str = "foobarbaz";
55 command[i].substr = "barbazzy";
56 i++;
58 command[i].str = "foobar";
59 command[i].substr = "foobar";
60 i++;
62 command[i].str = "foobar";
63 command[i].substr = "foobarbaz";
64 i++;
66 command[i].str = "";
67 command[i].substr = "foobar";
68 i++;
70 command[i].str = "foobar";
71 command[i].substr = "";
72 i++;
74 command[i].str = "";
75 command[i].substr = "";
76 i++;
78 command[i].str = "foo";
79 command[i].substr = "";
80 i++;
82 end = j = k = 0;
83 printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n");
86 tick-1ms
87 /j < i && end == 0/
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;
93 k++;
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;
99 k++;
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;
105 k++;
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;
111 k++;
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);
117 k++;
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;
123 k++;
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;
129 k++;
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;
135 k++;
137 j++;
140 tick-1ms
141 /j == i && end == 0/
143 end = k;
144 i = 0;
147 tick-1ms
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");
162 printf("\t}\n\n");
165 tick-1ms
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");
180 printf("\t}\n\n");
183 tick-1ms
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");
199 printf("\t}\n\n");
202 tick-1ms
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");
218 printf("\t}\n\n");
221 tick-1ms
222 /end != 0 && ++i == end/
224 printf("\texit($failed);\n}\n");
225 exit(0);