Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 oops forgot to commit the script.



details:   https://anonhg.NetBSD.org/src/rev/8994cbf8bec6
branches:  trunk
changeset: 761701:8994cbf8bec6
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Feb 05 16:10:17 2011 +0000

description:
oops forgot to commit the script.

diffstat:

 usr.bin/xlint/lint1/mkops |  106 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 106 insertions(+), 0 deletions(-)

diffs (110 lines):

diff -r ef79a29a6c20 -r 8994cbf8bec6 usr.bin/xlint/lint1/mkops
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/xlint/lint1/mkops Sat Feb 05 16:10:17 2011 +0000
@@ -0,0 +1,106 @@
+#!/bin/sh -
+#      $NetBSD: mkops,v 1.1 2011/02/05 16:10:17 christos Exp $
+#
+# Copyright (c) 2003 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Christos Zoulas.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# allow AWK to be overriden
+: ${AWK:=awk}
+
+
+while getopts ch f
+do
+       case $f in
+       c)
+               v=c;;
+       h)
+               v=h;;
+       *)
+               echo "Usage: $0 -c|-h";;
+       esac
+done
+
+shift $(expr ${OPTIND} - 1)
+
+$AWK -F'       ' -v v=$v '
+function display(fmt, last, comment)
+{
+       printf(fmt, last);
+       if (comment != "")
+               printf("\t%s", comment);
+       printf("\n");
+}
+
+BEGIN {
+       print "/* Automatically generated file; do not edit */";
+       if (v == "h") {
+               printf("typedef enum {\n");
+               FIRST = "";
+               LAST = "";
+               LASTCOMMENT= "";
+       }
+       if (v == "c") {
+               printf("#include <sys/types.h>\n");
+               printf("#include \"op.h\"\n");
+               printf("static const char *opnames[] = {\n");
+       }
+}
+
+{
+       if (v == "h") {
+               if (LAST != "") {
+                       if (FIRST == "") {
+                               display("\t%s\t= 0,", LAST, LASTCOMMENT);
+                       } else {
+                               display("\t%s,", LAST, LASTCOMMENT);
+                       }
+               }
+               FIRST = LAST;
+               LAST = $2;
+               LASTCOMMENT = $3;
+       }
+       if (v == "c") {
+               printf("\t\"%s\",\t/* %s */\n", $1, $2);
+       }
+}
+
+END {
+       if (v == "h") {
+               display("\t%s,", LAST, LASTCOMMENT);
+               printf("#define\tNOPS\t((int)%s + 1)\n", LAST);
+               printf("} op_t;\n");
+               printf("const char *getopname(op_t);\n");
+       } 
+       if (v == "c") {
+               printf("};\n");
+               printf("const char *\n");
+               printf("getopname(op_t op) {\n");
+               printf("\treturn opnames[op];\n");
+               printf("}\n");
+       }
+}
+' "$@"



Home | Main Index | Thread Index | Old Index