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 ident "%Z%%M% %I% %E% SMI" 28 29 #pragma D option quiet 30 31 struct { 32 int index; 33 int length; 34 int nolen; 35 } command[int]; 36 37 int i; 38 39 BEGIN 40 { 41 str = "foobarbazbop"; 42 43 command[i].index = 3; 44 command[i].nolen = 1; 45 i++; 46 47 command[i].index = 300; 48 command[i].nolen = 1; 49 i++; 50 51 command[i].index = -10; 52 command[i].nolen = 1; 53 i++; 54 55 command[i].index = 0; 56 command[i].nolen = 1; 57 i++; 58 59 command[i].index = 1; 60 command[i].nolen = 1; 61 i++; 62 63 command[i].index = strlen(str) - 1; 64 command[i].nolen = 1; 65 i++; 66 67 command[i].index = strlen(str); 68 command[i].nolen = 1; 69 i++; 70 71 command[i].index = strlen(str) + 1; 72 command[i].nolen = 1; 73 i++; 74 75 command[i].index = 8; 76 command[i].length = 20; 77 i++; 78 79 command[i].index = 4; 80 command[i].length = 4; 81 i++; 82 83 command[i].index = 5; 84 command[i].length = strlen(str) - command[i].index + 1; 85 i++; 86 87 command[i].index = 5; 88 command[i].length = strlen(str) - command[i].index + 2; 89 i++; 90 91 command[i].index = 400; 92 command[i].length = 20; 93 i++; 94 95 command[i].index = 400; 96 command[i].length = 0; 97 i++; 98 99 command[i].index = 400; 100 command[i].length = -1; 101 i++; 102 103 command[i].index = 3; 104 command[i].length = 0; 105 i++; 106 107 command[i].index = 3; 108 command[i].length = -1; 109 i++; 110 111 command[i].index = 0; 112 command[i].length = 400; 113 i++; 114 115 command[i].index = -1; 116 command[i].length = 400; 117 i++; 118 119 command[i].index = -1; 120 command[i].length = 0; 121 i++; 122 123 command[i].index = -1; 124 command[i].length = -1; 125 i++; 126 127 command[i].index = -2 * strlen(str); 128 command[i].length = 2 * strlen(str); 129 i++; 130 131 command[i].index = -2 * strlen(str); 132 command[i].length = strlen(str); 133 i++; 134 135 command[i].index = -2 * strlen(str); 136 command[i].length = strlen(str) + 1; 137 i++; 138 139 command[i].index = -1 * strlen(str); 140 command[i].length = strlen(str); 141 i++; 142 143 command[i].index = -1 * strlen(str); 144 command[i].length = strlen(str) - 1; 145 i++; 146 147 end = i; 148 i = 0; 149 printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n"); 150 151 } 152 153 tick-1ms 154 /i < end && command[i].nolen/ 155 { 156 this->result = substr(str, command[i].index); 157 158 printf("\tif (substr(\"%s\", %d) != \"%s\") {\n", 159 str, command[i].index, this->result); 160 161 printf("\t\tprintf(\"perl => substr(\\\"%s\\\", %d) = ", 162 str, command[i].index); 163 printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s\", %d));\n", 164 str, command[i].index); 165 printf("\t\tprintf(\" D => substr(\\\"%s\\\", %d) = ", 166 str, command[i].index); 167 printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result); 168 printf("\t\t$failed++;\n"); 169 printf("\t}\n\n"); 170 } 171 172 tick-1ms 173 /i < end && !command[i].nolen/ 174 { 175 this->result = substr(str, command[i].index, command[i].length); 176 177 printf("\tif (substr(\"%s\", %d, %d) != \"%s\") {\n", 178 str, command[i].index, command[i].length, this->result); 179 printf("\t\tprintf(\"perl => substr(\\\"%s\\\", %d, %d) = ", 180 str, command[i].index, command[i].length); 181 printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s\", %d, %d));\n", 182 str, command[i].index, command[i].length); 183 printf("\t\tprintf(\" D => substr(\\\"%s\\\", %d, %d) = ", 184 str, command[i].index, command[i].length); 185 printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result); 186 printf("\t\t$failed++;\n"); 187 printf("\t}\n\n"); 188 } 189 190 tick-1ms 191 /++i == end/ 192 { 193 printf("\texit($failed);\n}\n"); 194 exit(0); 195 } 196