19512fe85Sahl /* 29512fe85Sahl * CDDL HEADER START 39512fe85Sahl * 49512fe85Sahl * The contents of this file are subject to the terms of the 59512fe85Sahl * Common Development and Distribution License (the "License"). 69512fe85Sahl * You may not use this file except in compliance with the License. 79512fe85Sahl * 89512fe85Sahl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 99512fe85Sahl * or http://www.opensolaris.org/os/licensing. 109512fe85Sahl * See the License for the specific language governing permissions 119512fe85Sahl * and limitations under the License. 129512fe85Sahl * 139512fe85Sahl * When distributing Covered Code, include this CDDL HEADER in each 149512fe85Sahl * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159512fe85Sahl * If applicable, add the following below this CDDL HEADER, with the 169512fe85Sahl * fields enclosed by brackets "[]" replaced with your own identifying 179512fe85Sahl * information: Portions Copyright [yyyy] [name of copyright owner] 189512fe85Sahl * 199512fe85Sahl * CDDL HEADER END 209512fe85Sahl */ 219512fe85Sahl 229512fe85Sahl /* 23*6009dbc6Sahl * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 249512fe85Sahl * Use is subject to license terms. 259512fe85Sahl */ 269512fe85Sahl 279512fe85Sahl #pragma ident "%Z%%M% %I% %E% SMI" 289512fe85Sahl 299512fe85Sahl #pragma D option quiet 30*6009dbc6Sahl #pragma D option strsize=32 319512fe85Sahl 329512fe85Sahl struct { 339512fe85Sahl int index; 349512fe85Sahl int length; 359512fe85Sahl int nolen; 36*6009dbc6Sahl int alt; 379512fe85Sahl } command[int]; 389512fe85Sahl 399512fe85Sahl int i; 409512fe85Sahl 419512fe85Sahl BEGIN 429512fe85Sahl { 439512fe85Sahl str = "foobarbazbop"; 44*6009dbc6Sahl str2 = ""; 45*6009dbc6Sahl altstr = "CRAIG: Positioned them, I don't "; 46*6009dbc6Sahl altstr2 = "know... I'm fairly wide guy."; 479512fe85Sahl 489512fe85Sahl command[i].index = 3; 499512fe85Sahl command[i].nolen = 1; 509512fe85Sahl i++; 519512fe85Sahl 529512fe85Sahl command[i].index = 300; 539512fe85Sahl command[i].nolen = 1; 549512fe85Sahl i++; 559512fe85Sahl 569512fe85Sahl command[i].index = -10; 579512fe85Sahl command[i].nolen = 1; 589512fe85Sahl i++; 599512fe85Sahl 609512fe85Sahl command[i].index = 0; 619512fe85Sahl command[i].nolen = 1; 629512fe85Sahl i++; 639512fe85Sahl 649512fe85Sahl command[i].index = 1; 659512fe85Sahl command[i].nolen = 1; 669512fe85Sahl i++; 679512fe85Sahl 689512fe85Sahl command[i].index = strlen(str) - 1; 699512fe85Sahl command[i].nolen = 1; 709512fe85Sahl i++; 719512fe85Sahl 729512fe85Sahl command[i].index = strlen(str); 739512fe85Sahl command[i].nolen = 1; 749512fe85Sahl i++; 759512fe85Sahl 769512fe85Sahl command[i].index = strlen(str) + 1; 779512fe85Sahl command[i].nolen = 1; 789512fe85Sahl i++; 799512fe85Sahl 809512fe85Sahl command[i].index = 8; 819512fe85Sahl command[i].length = 20; 829512fe85Sahl i++; 839512fe85Sahl 849512fe85Sahl command[i].index = 4; 859512fe85Sahl command[i].length = 4; 869512fe85Sahl i++; 879512fe85Sahl 889512fe85Sahl command[i].index = 5; 899512fe85Sahl command[i].length = strlen(str) - command[i].index + 1; 909512fe85Sahl i++; 919512fe85Sahl 929512fe85Sahl command[i].index = 5; 939512fe85Sahl command[i].length = strlen(str) - command[i].index + 2; 949512fe85Sahl i++; 959512fe85Sahl 969512fe85Sahl command[i].index = 400; 979512fe85Sahl command[i].length = 20; 989512fe85Sahl i++; 999512fe85Sahl 1009512fe85Sahl command[i].index = 400; 1019512fe85Sahl command[i].length = 0; 1029512fe85Sahl i++; 1039512fe85Sahl 1049512fe85Sahl command[i].index = 400; 1059512fe85Sahl command[i].length = -1; 1069512fe85Sahl i++; 1079512fe85Sahl 1089512fe85Sahl command[i].index = 3; 1099512fe85Sahl command[i].length = 0; 1109512fe85Sahl i++; 1119512fe85Sahl 1129512fe85Sahl command[i].index = 3; 1139512fe85Sahl command[i].length = -1; 1149512fe85Sahl i++; 1159512fe85Sahl 116*6009dbc6Sahl command[i].index = 3; 117*6009dbc6Sahl command[i].length = -4; 118*6009dbc6Sahl i++; 119*6009dbc6Sahl 120*6009dbc6Sahl command[i].index = 3; 121*6009dbc6Sahl command[i].length = -20; 122*6009dbc6Sahl i++; 123*6009dbc6Sahl 124*6009dbc6Sahl command[i].index = -10; 125*6009dbc6Sahl command[i].length = -5; 126*6009dbc6Sahl i++; 127*6009dbc6Sahl 1289512fe85Sahl command[i].index = 0; 1299512fe85Sahl command[i].length = 400; 1309512fe85Sahl i++; 1319512fe85Sahl 1329512fe85Sahl command[i].index = -1; 1339512fe85Sahl command[i].length = 400; 1349512fe85Sahl i++; 1359512fe85Sahl 1369512fe85Sahl command[i].index = -1; 1379512fe85Sahl command[i].length = 0; 1389512fe85Sahl i++; 1399512fe85Sahl 1409512fe85Sahl command[i].index = -1; 1419512fe85Sahl command[i].length = -1; 1429512fe85Sahl i++; 1439512fe85Sahl 1449512fe85Sahl command[i].index = -2 * strlen(str); 1459512fe85Sahl command[i].length = 2 * strlen(str); 1469512fe85Sahl i++; 1479512fe85Sahl 1489512fe85Sahl command[i].index = -2 * strlen(str); 1499512fe85Sahl command[i].length = strlen(str); 1509512fe85Sahl i++; 1519512fe85Sahl 1529512fe85Sahl command[i].index = -2 * strlen(str); 1539512fe85Sahl command[i].length = strlen(str) + 1; 1549512fe85Sahl i++; 1559512fe85Sahl 1569512fe85Sahl command[i].index = -1 * strlen(str); 1579512fe85Sahl command[i].length = strlen(str); 1589512fe85Sahl i++; 1599512fe85Sahl 1609512fe85Sahl command[i].index = -1 * strlen(str); 1619512fe85Sahl command[i].length = strlen(str) - 1; 1629512fe85Sahl i++; 1639512fe85Sahl 164*6009dbc6Sahl command[i].index = 100; 165*6009dbc6Sahl command[i].length = 10; 166*6009dbc6Sahl command[i].alt = 1; 167*6009dbc6Sahl i++; 168*6009dbc6Sahl 169*6009dbc6Sahl command[i].index = 100; 170*6009dbc6Sahl command[i].nolen = 1; 171*6009dbc6Sahl command[i].alt = 1; 172*6009dbc6Sahl i++; 173*6009dbc6Sahl 1749512fe85Sahl end = i; 1759512fe85Sahl i = 0; 1769512fe85Sahl printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n"); 1779512fe85Sahl 1789512fe85Sahl } 1799512fe85Sahl 1809512fe85Sahl tick-1ms 1819512fe85Sahl /i < end && command[i].nolen/ 1829512fe85Sahl { 183*6009dbc6Sahl this->str = command[i].alt ? altstr : str; 184*6009dbc6Sahl this->str2 = command[i].alt ? altstr2 : str2; 185*6009dbc6Sahl this->result = substr(command[i].alt ? 186*6009dbc6Sahl "CRAIG: Positioned them, I don't know... I'm fairly wide guy." : 187*6009dbc6Sahl str, command[i].index); 1889512fe85Sahl 189*6009dbc6Sahl printf("\tif (substr(\"%s%s\", %d) ne \"%s\") {\n", 190*6009dbc6Sahl this->str, this->str2, command[i].index, this->result); 1919512fe85Sahl 192*6009dbc6Sahl printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d) = ", 193*6009dbc6Sahl this->str, this->str2, command[i].index); 194*6009dbc6Sahl printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d));\n", 195*6009dbc6Sahl this->str, this->str2, command[i].index); 196*6009dbc6Sahl printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d) = ", 197*6009dbc6Sahl this->str, this->str2, command[i].index); 1989512fe85Sahl printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result); 1999512fe85Sahl printf("\t\t$failed++;\n"); 2009512fe85Sahl printf("\t}\n\n"); 2019512fe85Sahl } 2029512fe85Sahl 2039512fe85Sahl tick-1ms 2049512fe85Sahl /i < end && !command[i].nolen/ 2059512fe85Sahl { 206*6009dbc6Sahl this->str = command[i].alt ? altstr : str; 207*6009dbc6Sahl this->str2 = command[i].alt ? altstr2 : str2; 208*6009dbc6Sahl this->result = substr(command[i].alt ? 209*6009dbc6Sahl "CRAIG: Positioned them, I don't know... I'm fairly wide guy." : 2109512fe85Sahl str, command[i].index, command[i].length); 211*6009dbc6Sahl 212*6009dbc6Sahl printf("\tif (substr(\"%s%s\", %d, %d) ne \"%s\") {\n", 213*6009dbc6Sahl this->str, this->str2, command[i].index, command[i].length, 214*6009dbc6Sahl this->result); 215*6009dbc6Sahl printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d, %d) = ", 216*6009dbc6Sahl this->str, this->str2, command[i].index, command[i].length); 217*6009dbc6Sahl printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d, %d));\n", 218*6009dbc6Sahl this->str, this->str2, command[i].index, command[i].length); 219*6009dbc6Sahl printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d, %d) = ", 220*6009dbc6Sahl this->str, this->str2, command[i].index, command[i].length); 2219512fe85Sahl printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result); 2229512fe85Sahl printf("\t\t$failed++;\n"); 2239512fe85Sahl printf("\t}\n\n"); 2249512fe85Sahl } 2259512fe85Sahl 2269512fe85Sahl tick-1ms 2279512fe85Sahl /++i == end/ 2289512fe85Sahl { 2299512fe85Sahl printf("\texit($failed);\n}\n"); 2309512fe85Sahl exit(0); 2319512fe85Sahl } 232