1 /* 2 * CDDL HEADER START 3 * 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. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma D option quiet 28 29 BEGIN 30 { 31 this->str = ",,,Carrots,,Barley,Oatmeal,,,Beans,"; 32 } 33 34 BEGIN 35 /(this->field = strtok(this->str, ",")) == NULL/ 36 { 37 exit(1); 38 } 39 40 BEGIN 41 { 42 printf("%s\n", this->field); 43 } 44 45 BEGIN 46 /(this->field = strtok(NULL, ",")) == NULL/ 47 { 48 exit(2); 49 } 50 51 BEGIN 52 { 53 printf("%s\n", this->field); 54 } 55 56 BEGIN 57 /(this->field = strtok(NULL, ",")) == NULL/ 58 { 59 exit(3); 60 } 61 62 BEGIN 63 { 64 printf("%s\n", this->field); 65 } 66 67 BEGIN 68 /(this->field = strtok(NULL, ",")) == NULL/ 69 { 70 exit(4); 71 } 72 73 BEGIN 74 { 75 printf("%s\n", this->field); 76 } 77 78 BEGIN 79 /(self->a = strtok(NULL, ",")) != NULL/ 80 { 81 printf("unexpected field: %s\n", this->field); 82 exit(5); 83 } 84 85 struct { 86 string s1; 87 string s2; 88 string result; 89 } command[int]; 90 91 int i; 92 93 BEGIN 94 { 95 command[i].s1 = ""; 96 command[i].s2 = ""; 97 command[i].result = ""; 98 i++; 99 100 command[i].s1 = "foo"; 101 command[i].s2 = ""; 102 command[i].result = command[i].s1; 103 i++; 104 105 command[i].s1 = "foobar"; 106 command[i].s2 = "o"; 107 command[i].result = "f"; 108 i++; 109 110 command[i].s1 = "oobar"; 111 command[i].s2 = "o"; 112 command[i].result = "bar"; 113 i++; 114 115 command[i].s1 = "foo"; 116 command[i].s2 = "bar"; 117 command[i].result = command[i].s1; 118 i++; 119 120 command[i].s1 = ""; 121 command[i].s2 = "foo"; 122 command[i].result = ""; 123 i++; 124 125 end = i; 126 i = 0; 127 } 128 129 tick-1ms 130 /i < end && 131 (this->result = strtok(command[i].s1, command[i].s2)) != command[i].result/ 132 { 133 printf("strtok(\"%s\", \"%s\") = \"%s\", expected \"%s\"", 134 command[i].s1, command[i].s2, 135 this->result != NULL ? this->result : "<null>", 136 command[i].result != NULL ? command[i].result : "<null>"); 137 exit(6 + i); 138 } 139 140 tick-1ms 141 /++i == end/ 142 { 143 exit(0); 144 } 145