12633Sahl /* 22633Sahl * CDDL HEADER START 32633Sahl * 42633Sahl * The contents of this file are subject to the terms of the 52633Sahl * Common Development and Distribution License (the "License"). 62633Sahl * You may not use this file except in compliance with the License. 72633Sahl * 82633Sahl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92633Sahl * or http://www.opensolaris.org/os/licensing. 102633Sahl * See the License for the specific language governing permissions 112633Sahl * and limitations under the License. 122633Sahl * 132633Sahl * When distributing Covered Code, include this CDDL HEADER in each 142633Sahl * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152633Sahl * If applicable, add the following below this CDDL HEADER, with the 162633Sahl * fields enclosed by brackets "[]" replaced with your own identifying 172633Sahl * information: Portions Copyright [yyyy] [name of copyright owner] 182633Sahl * 192633Sahl * CDDL HEADER END 202633Sahl */ 212633Sahl 222633Sahl /* 23*6390Sahl * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 242633Sahl * Use is subject to license terms. 252633Sahl */ 262633Sahl 272633Sahl #pragma ident "%Z%%M% %I% %E% SMI" 282633Sahl 292633Sahl #pragma D option quiet 30*6390Sahl #pragma D option strsize=32 312633Sahl 322633Sahl struct { 332633Sahl int index; 342633Sahl int length; 352633Sahl int nolen; 36*6390Sahl int alt; 372633Sahl } command[int]; 382633Sahl 392633Sahl int i; 402633Sahl 412633Sahl BEGIN 422633Sahl { 432633Sahl str = "foobarbazbop"; 44*6390Sahl str2 = ""; 45*6390Sahl altstr = "CRAIG: Positioned them, I don't "; 46*6390Sahl altstr2 = "know... I'm fairly wide guy."; 472633Sahl 482633Sahl command[i].index = 3; 492633Sahl command[i].nolen = 1; 502633Sahl i++; 512633Sahl 522633Sahl command[i].index = 300; 532633Sahl command[i].nolen = 1; 542633Sahl i++; 552633Sahl 562633Sahl command[i].index = -10; 572633Sahl command[i].nolen = 1; 582633Sahl i++; 592633Sahl 602633Sahl command[i].index = 0; 612633Sahl command[i].nolen = 1; 622633Sahl i++; 632633Sahl 642633Sahl command[i].index = 1; 652633Sahl command[i].nolen = 1; 662633Sahl i++; 672633Sahl 682633Sahl command[i].index = strlen(str) - 1; 692633Sahl command[i].nolen = 1; 702633Sahl i++; 712633Sahl 722633Sahl command[i].index = strlen(str); 732633Sahl command[i].nolen = 1; 742633Sahl i++; 752633Sahl 762633Sahl command[i].index = strlen(str) + 1; 772633Sahl command[i].nolen = 1; 782633Sahl i++; 792633Sahl 802633Sahl command[i].index = 8; 812633Sahl command[i].length = 20; 822633Sahl i++; 832633Sahl 842633Sahl command[i].index = 4; 852633Sahl command[i].length = 4; 862633Sahl i++; 872633Sahl 882633Sahl command[i].index = 5; 892633Sahl command[i].length = strlen(str) - command[i].index + 1; 902633Sahl i++; 912633Sahl 922633Sahl command[i].index = 5; 932633Sahl command[i].length = strlen(str) - command[i].index + 2; 942633Sahl i++; 952633Sahl 962633Sahl command[i].index = 400; 972633Sahl command[i].length = 20; 982633Sahl i++; 992633Sahl 1002633Sahl command[i].index = 400; 1012633Sahl command[i].length = 0; 1022633Sahl i++; 1032633Sahl 1042633Sahl command[i].index = 400; 1052633Sahl command[i].length = -1; 1062633Sahl i++; 1072633Sahl 1082633Sahl command[i].index = 3; 1092633Sahl command[i].length = 0; 1102633Sahl i++; 1112633Sahl 1122633Sahl command[i].index = 3; 1132633Sahl command[i].length = -1; 1142633Sahl i++; 1152633Sahl 116*6390Sahl command[i].index = 3; 117*6390Sahl command[i].length = -4; 118*6390Sahl i++; 119*6390Sahl 120*6390Sahl command[i].index = 3; 121*6390Sahl command[i].length = -20; 122*6390Sahl i++; 123*6390Sahl 124*6390Sahl command[i].index = -10; 125*6390Sahl command[i].length = -5; 126*6390Sahl i++; 127*6390Sahl 1282633Sahl command[i].index = 0; 1292633Sahl command[i].length = 400; 1302633Sahl i++; 1312633Sahl 1322633Sahl command[i].index = -1; 1332633Sahl command[i].length = 400; 1342633Sahl i++; 1352633Sahl 1362633Sahl command[i].index = -1; 1372633Sahl command[i].length = 0; 1382633Sahl i++; 1392633Sahl 1402633Sahl command[i].index = -1; 1412633Sahl command[i].length = -1; 1422633Sahl i++; 1432633Sahl 1442633Sahl command[i].index = -2 * strlen(str); 1452633Sahl command[i].length = 2 * strlen(str); 1462633Sahl i++; 1472633Sahl 1482633Sahl command[i].index = -2 * strlen(str); 1492633Sahl command[i].length = strlen(str); 1502633Sahl i++; 1512633Sahl 1522633Sahl command[i].index = -2 * strlen(str); 1532633Sahl command[i].length = strlen(str) + 1; 1542633Sahl i++; 1552633Sahl 1562633Sahl command[i].index = -1 * strlen(str); 1572633Sahl command[i].length = strlen(str); 1582633Sahl i++; 1592633Sahl 1602633Sahl command[i].index = -1 * strlen(str); 1612633Sahl command[i].length = strlen(str) - 1; 1622633Sahl i++; 1632633Sahl 164*6390Sahl command[i].index = 100; 165*6390Sahl command[i].length = 10; 166*6390Sahl command[i].alt = 1; 167*6390Sahl i++; 168*6390Sahl 169*6390Sahl command[i].index = 100; 170*6390Sahl command[i].nolen = 1; 171*6390Sahl command[i].alt = 1; 172*6390Sahl i++; 173*6390Sahl 1742633Sahl end = i; 1752633Sahl i = 0; 1762633Sahl printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n"); 1772633Sahl 1782633Sahl } 1792633Sahl 1802633Sahl tick-1ms 1812633Sahl /i < end && command[i].nolen/ 1822633Sahl { 183*6390Sahl this->str = command[i].alt ? altstr : str; 184*6390Sahl this->str2 = command[i].alt ? altstr2 : str2; 185*6390Sahl this->result = substr(command[i].alt ? 186*6390Sahl "CRAIG: Positioned them, I don't know... I'm fairly wide guy." : 187*6390Sahl str, command[i].index); 1882633Sahl 189*6390Sahl printf("\tif (substr(\"%s%s\", %d) ne \"%s\") {\n", 190*6390Sahl this->str, this->str2, command[i].index, this->result); 191*6390Sahl 192*6390Sahl printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d) = ", 193*6390Sahl this->str, this->str2, command[i].index); 194*6390Sahl printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d));\n", 195*6390Sahl this->str, this->str2, command[i].index); 196*6390Sahl printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d) = ", 197*6390Sahl this->str, this->str2, command[i].index); 1982633Sahl printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result); 1992633Sahl printf("\t\t$failed++;\n"); 2002633Sahl printf("\t}\n\n"); 2012633Sahl } 2022633Sahl 2032633Sahl tick-1ms 2042633Sahl /i < end && !command[i].nolen/ 2052633Sahl { 206*6390Sahl this->str = command[i].alt ? altstr : str; 207*6390Sahl this->str2 = command[i].alt ? altstr2 : str2; 208*6390Sahl this->result = substr(command[i].alt ? 209*6390Sahl "CRAIG: Positioned them, I don't know... I'm fairly wide guy." : 210*6390Sahl str, command[i].index, command[i].length); 2112633Sahl 212*6390Sahl printf("\tif (substr(\"%s%s\", %d, %d) ne \"%s\") {\n", 213*6390Sahl this->str, this->str2, command[i].index, command[i].length, 214*6390Sahl this->result); 215*6390Sahl printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d, %d) = ", 216*6390Sahl this->str, this->str2, command[i].index, command[i].length); 217*6390Sahl printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d, %d));\n", 218*6390Sahl this->str, this->str2, command[i].index, command[i].length); 219*6390Sahl printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d, %d) = ", 220*6390Sahl this->str, this->str2, command[i].index, command[i].length); 2212633Sahl printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result); 2222633Sahl printf("\t\t$failed++;\n"); 2232633Sahl printf("\t}\n\n"); 2242633Sahl } 2252633Sahl 2262633Sahl tick-1ms 2272633Sahl /++i == end/ 2282633Sahl { 2292633Sahl printf("\texit($failed);\n}\n"); 2302633Sahl exit(0); 2312633Sahl } 232