14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER START
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The contents of this file are subject to the terms of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Common Development and Distribution License (the "License").
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You may not use this file except in compliance with the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * or http://www.opensolaris.org/os/licensing.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * See the License for the specific language governing permissions
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and limitations under the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * When distributing Covered Code, include this CDDL HEADER in each
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If applicable, add the following below this CDDL HEADER, with the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * fields enclosed by brackets "[]" replaced with your own identifying
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * information: Portions Copyright [yyyy] [name of copyright owner]
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER END
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Use is subject to license terms.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma ident "%Z%%M% %I% %E% SMI"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma D option quiet
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#pragma D option strsize=32
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int index;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int length;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int nolen;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int alt;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync} command[int];
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncint i;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncBEGIN
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync str = "foobarbazbop";
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync str2 = "";
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync altstr = "CRAIG: Positioned them, I don't ";
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync altstr2 = "know... I'm fairly wide guy.";
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 3;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].nolen = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 300;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].nolen = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = -10;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].nolen = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].nolen = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].nolen = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = strlen(str) - 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].nolen = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = strlen(str);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].nolen = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = strlen(str) + 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].nolen = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 8;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = 20;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 4;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = 4;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 5;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = strlen(str) - command[i].index + 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 5;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = strlen(str) - command[i].index + 2;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 400;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = 20;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 400;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 400;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = -1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 3;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 3;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = -1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 3;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = -4;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 3;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = -20;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = -10;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = -5;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = 400;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = -1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = 400;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = -1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = -1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = -1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = -2 * strlen(str);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = 2 * strlen(str);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = -2 * strlen(str);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = strlen(str);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = -2 * strlen(str);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = strlen(str) + 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = -1 * strlen(str);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = strlen(str);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = -1 * strlen(str);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = strlen(str) - 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 100;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].length = 10;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].alt = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].index = 100;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].nolen = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync command[i].alt = 1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync end = i;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i = 0;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctick-1ms
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/i < end && command[i].nolen/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str = command[i].alt ? altstr : str;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str2 = command[i].alt ? altstr2 : str2;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->result = substr(command[i].alt ?
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "CRAIG: Positioned them, I don't know... I'm fairly wide guy." :
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync str, command[i].index);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\tif (substr(\"%s%s\", %d) ne \"%s\") {\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str, this->str2, command[i].index, this->result);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d) = ",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str, this->str2, command[i].index);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d));\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str, this->str2, command[i].index);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d) = ",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str, this->str2, command[i].index);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\t\t$failed++;\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\t}\n\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctick-1ms
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/i < end && !command[i].nolen/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str = command[i].alt ? altstr : str;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str2 = command[i].alt ? altstr2 : str2;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->result = substr(command[i].alt ?
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync "CRAIG: Positioned them, I don't know... I'm fairly wide guy." :
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync str, command[i].index, command[i].length);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\tif (substr(\"%s%s\", %d, %d) ne \"%s\") {\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str, this->str2, command[i].index, command[i].length,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->result);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\t\tprintf(\"perl => substr(\\\"%s%s\\\", %d, %d) = ",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str, this->str2, command[i].index, command[i].length);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\\\"%%s\\\"\\n\",\n\t\t substr(\"%s%s\", %d, %d));\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str, this->str2, command[i].index, command[i].length);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\t\tprintf(\" D => substr(\\\"%s%s\\\", %d, %d) = ",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync this->str, this->str2, command[i].index, command[i].length);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\\\"%%s\\\"\\n\",\n\t\t \"%s\");\n", this->result);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\t\t$failed++;\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\t}\n\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctick-1ms
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/++i == end/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("\texit($failed);\n}\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync exit(0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}