dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / dtrace / test / tst / common / funcs / tst.substr.d
blobedee6442e35013de9db2fa2b171fa0ed17b2b372
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 2008 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
30 #pragma D option strsize=32
32 struct {
33 int index;
34 int length;
35 int nolen;
36 int alt;
37 } command[int];
39 int i;
41 BEGIN
43 str = "foobarbazbop";
44 str2 = "";
45 altstr = "CRAIG: Positioned them, I don't ";
46 altstr2 = "know... I'm fairly wide guy.";
48 command[i].index = 3;
49 command[i].nolen = 1;
50 i++;
52 command[i].index = 300;
53 command[i].nolen = 1;
54 i++;
56 command[i].index = -10;
57 command[i].nolen = 1;
58 i++;
60 command[i].index = 0;
61 command[i].nolen = 1;
62 i++;
64 command[i].index = 1;
65 command[i].nolen = 1;
66 i++;
68 command[i].index = strlen(str) - 1;
69 command[i].nolen = 1;
70 i++;
72 command[i].index = strlen(str);
73 command[i].nolen = 1;
74 i++;
76 command[i].index = strlen(str) + 1;
77 command[i].nolen = 1;
78 i++;
80 command[i].index = 8;
81 command[i].length = 20;
82 i++;
84 command[i].index = 4;
85 command[i].length = 4;
86 i++;
88 command[i].index = 5;
89 command[i].length = strlen(str) - command[i].index + 1;
90 i++;
92 command[i].index = 5;
93 command[i].length = strlen(str) - command[i].index + 2;
94 i++;
96 command[i].index = 400;
97 command[i].length = 20;
98 i++;
100 command[i].index = 400;
101 command[i].length = 0;
102 i++;
104 command[i].index = 400;
105 command[i].length = -1;
106 i++;
108 command[i].index = 3;
109 command[i].length = 0;
110 i++;
112 command[i].index = 3;
113 command[i].length = -1;
114 i++;
116 command[i].index = 3;
117 command[i].length = -4;
118 i++;
120 command[i].index = 3;
121 command[i].length = -20;
122 i++;
124 command[i].index = -10;
125 command[i].length = -5;
126 i++;
128 command[i].index = 0;
129 command[i].length = 400;
130 i++;
132 command[i].index = -1;
133 command[i].length = 400;
134 i++;
136 command[i].index = -1;
137 command[i].length = 0;
138 i++;
140 command[i].index = -1;
141 command[i].length = -1;
142 i++;
144 command[i].index = -2 * strlen(str);
145 command[i].length = 2 * strlen(str);
146 i++;
148 command[i].index = -2 * strlen(str);
149 command[i].length = strlen(str);
150 i++;
152 command[i].index = -2 * strlen(str);
153 command[i].length = strlen(str) + 1;
154 i++;
156 command[i].index = -1 * strlen(str);
157 command[i].length = strlen(str);
158 i++;
160 command[i].index = -1 * strlen(str);
161 command[i].length = strlen(str) - 1;
162 i++;
164 command[i].index = 100;
165 command[i].length = 10;
166 command[i].alt = 1;
167 i++;
169 command[i].index = 100;
170 command[i].nolen = 1;
171 command[i].alt = 1;
172 i++;
174 end = i;
175 i = 0;
176 printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n");
180 tick-1ms
181 /i < end && command[i].nolen/
183 this->str = command[i].alt ? altstr : str;
184 this->str2 = command[i].alt ? altstr2 : str2;
185 this->result = substr(command[i].alt ?
186 "CRAIG: Positioned them, I don't know... I'm fairly wide guy." :
187 str, command[i].index);
189 printf("\tif (substr(\"%s%s\", %d) ne \"%s\") {\n",
190 this->str, this->str2, command[i].index, this->result);
192 printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d) = ",
193 this->str, this->str2, command[i].index);
194 printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d));\n",
195 this->str, this->str2, command[i].index);
196 printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d) = ",
197 this->str, this->str2, command[i].index);
198 printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result);
199 printf("\t\t$failed++;\n");
200 printf("\t}\n\n");
203 tick-1ms
204 /i < end && !command[i].nolen/
206 this->str = command[i].alt ? altstr : str;
207 this->str2 = command[i].alt ? altstr2 : str2;
208 this->result = substr(command[i].alt ?
209 "CRAIG: Positioned them, I don't know... I'm fairly wide guy." :
210 str, command[i].index, command[i].length);
212 printf("\tif (substr(\"%s%s\", %d, %d) ne \"%s\") {\n",
213 this->str, this->str2, command[i].index, command[i].length,
214 this->result);
215 printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d, %d) = ",
216 this->str, this->str2, command[i].index, command[i].length);
217 printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d, %d));\n",
218 this->str, this->str2, command[i].index, command[i].length);
219 printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d, %d) = ",
220 this->str, this->str2, command[i].index, command[i].length);
221 printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result);
222 printf("\t\t$failed++;\n");
223 printf("\t}\n\n");
226 tick-1ms
227 /++i == end/
229 printf("\texit($failed);\n}\n");
230 exit(0);