9512fe850e98fdd448c638ca63fdd92a8a510255ahl/*
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * CDDL HEADER START
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * The contents of this file are subject to the terms of the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Common Development and Distribution License (the "License").
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * You may not use this file except in compliance with the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * or http://www.opensolaris.org/os/licensing.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * See the License for the specific language governing permissions
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * and limitations under the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * When distributing Covered Code, include this CDDL HEADER in each
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * If applicable, add the following below this CDDL HEADER, with the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * fields enclosed by brackets "[]" replaced with your own identifying
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * information: Portions Copyright [yyyy] [name of copyright owner]
9512fe850e98fdd448c638ca63fdd92a8a510255ahl *
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * CDDL HEADER END
9512fe850e98fdd448c638ca63fdd92a8a510255ahl */
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/*
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl * Use is subject to license terms.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl */
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#pragma ident "%Z%%M% %I% %E% SMI"
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#pragma D option quiet
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlstruct {
9512fe850e98fdd448c638ca63fdd92a8a510255ahl string str;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl string substr;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl int haspos;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl int position;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl} command[int];
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlint i;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlBEGIN
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str = "foobarbaz";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr = "barbaz";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str = "foofoofoo";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr = "foo";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str = "boofoofoo";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr = "foo";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str = "foobarbaz";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr = "barbazzy";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str = "foobar";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr = "foobar";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str = "foobar";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr = "foobarbaz";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str = "";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr = "foobar";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str = "foobar";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr = "";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str = "";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr = "";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str = "foo";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr = "";
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl end = j = k = 0;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("#!/usr/perl5/bin/perl\n\nBEGIN {\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahltick-1ms
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/j < i && end == 0/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].str = command[j].str;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].substr = command[j].substr;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].haspos = 1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].position = -400;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl k++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].str = command[j].str;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].substr = command[j].substr;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].haspos = 1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].position = -1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl k++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].str = command[j].str;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].substr = command[j].substr;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].haspos = 1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].position = 0;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl k++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].str = command[j].str;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].substr = command[j].substr;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].haspos = 1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].position = strlen(command[j].str) / 2;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl k++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].str = command[j].str;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].substr = command[j].substr;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].haspos = 1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].position = strlen(command[j].str);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl k++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].str = command[j].str;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].substr = command[j].substr;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].haspos = 1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].position = strlen(command[j].str) + 1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl k++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].str = command[j].str;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].substr = command[j].substr;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].haspos = 1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].position = strlen(command[j].str) + 2;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl k++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].str = command[j].str;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].substr = command[j].substr;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].haspos = 1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i + k].position = 400;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl k++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl j++;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahltick-1ms
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/j == i && end == 0/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl end = k;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl i = 0;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahltick-1ms
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/end != 0 && i < end && !command[i].haspos/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl this->result = index(command[i].str, command[i].substr);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\tif (index(\"%s\", \"%s\") != %d) {\n",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr, this->result);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\tprintf(\"perl => index(\\\"%s\\\", \\\"%s\\\") = ",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("%%d\\n\",\n\t\t index(\"%s\", \"%s\"));\n",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\tprintf(\" D => index(\\\"%s\\\", \\\"%s\\\") = ",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("%d\\n\");\n", this->result);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\t$failed++;\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t}\n\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahltick-1ms
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/end != 0 && i < end && !command[i].haspos/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl this->result = rindex(command[i].str, command[i].substr);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\tif (rindex(\"%s\", \"%s\") != %d) {\n",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr, this->result);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\tprintf(\"perl => rindex(\\\"%s\\\", \\\"%s\\\") = ",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("%%d\\n\",\n\t\t rindex(\"%s\", \"%s\"));\n",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\tprintf(\" D => rindex(\\\"%s\\\", \\\"%s\\\") = ",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("%d\\n\");\n", this->result);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\t$failed++;\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t}\n\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahltick-1ms
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/end != 0 && i < end && command[i].haspos/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl this->result = index(command[i].str,
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr, command[i].position);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\tif (index(\"%s\", \"%s\", %d) != %d) {\n", command[i].str,
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr, command[i].position, this->result);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\tprintf(\"perl => index(\\\"%s\\\", \\\"%s\\\", %d) = ",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr, command[i].position);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("%%d\\n\",\n\t\t index(\"%s\", \"%s\", %d));\n",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr, command[i].position);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\tprintf(\" D => index(\\\"%s\\\", \\\"%s\\\", %d) = ",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr, command[i].position);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("%d\\n\");\n", this->result);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\t$failed++;\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t}\n\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahltick-1ms
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/end != 0 && i < end && command[i].haspos/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl this->result = rindex(command[i].str,
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr, command[i].position);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\tif (rindex(\"%s\", \"%s\", %d) != %d) {\n", command[i].str,
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].substr, command[i].position, this->result);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\tprintf(\"perl => rindex(\\\"%s\\\", \\\"%s\\\", %d) = ",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr, command[i].position);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("%%d\\n\",\n\t\t rindex(\"%s\", \"%s\", %d));\n",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr, command[i].position);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\tprintf(\" D => rindex(\\\"%s\\\", \\\"%s\\\", %d) = ",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl command[i].str, command[i].substr, command[i].position);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("%d\\n\");\n", this->result);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t\t$failed++;\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\t}\n\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahltick-1ms
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/end != 0 && ++i == end/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("\texit($failed);\n}\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl exit(0);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}