8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / dtrace / test / tst / common / funcs / tst.strtok.d
blob47092ba46ba115dcea145cf634311b1f9075f7bc
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 BEGIN
33 this->str = ",,,Carrots,,Barley,Oatmeal,,,Beans,";
36 BEGIN
37 /(this->field = strtok(this->str, ",")) == NULL/
39 exit(1);
42 BEGIN
44 printf("%s\n", this->field);
47 BEGIN
48 /(this->field = strtok(NULL, ",")) == NULL/
50 exit(2);
53 BEGIN
55 printf("%s\n", this->field);
58 BEGIN
59 /(this->field = strtok(NULL, ",")) == NULL/
61 exit(3);
64 BEGIN
66 printf("%s\n", this->field);
69 BEGIN
70 /(this->field = strtok(NULL, ",")) == NULL/
72 exit(4);
75 BEGIN
77 printf("%s\n", this->field);
80 BEGIN
81 /(self->a = strtok(NULL, ",")) != NULL/
83 printf("unexpected field: %s\n", this->field);
84 exit(5);
87 struct {
88 string s1;
89 string s2;
90 string result;
91 } command[int];
93 int i;
95 BEGIN
97 command[i].s1 = "";
98 command[i].s2 = "";
99 command[i].result = "";
100 i++;
102 command[i].s1 = "foo";
103 command[i].s2 = "";
104 command[i].result = command[i].s1;
105 i++;
107 command[i].s1 = "foobar";
108 command[i].s2 = "o";
109 command[i].result = "f";
110 i++;
112 command[i].s1 = "oobar";
113 command[i].s2 = "o";
114 command[i].result = "bar";
115 i++;
117 command[i].s1 = "foo";
118 command[i].s2 = "bar";
119 command[i].result = command[i].s1;
120 i++;
122 command[i].s1 = "";
123 command[i].s2 = "foo";
124 command[i].result = "";
125 i++;
127 end = i;
128 i = 0;
131 tick-1ms
132 /i < end &&
133 (this->result = strtok(command[i].s1, command[i].s2)) != command[i].result/
135 printf("strtok(\"%s\", \"%s\") = \"%s\", expected \"%s\"",
136 command[i].s1, command[i].s2,
137 this->result != NULL ? this->result : "<null>",
138 command[i].result != NULL ? command[i].result : "<null>");
139 exit(6 + i);
142 tick-1ms
143 /++i == end/
145 exit(0);