head	1.3;
access;
symbols
	RELENG_9_1_0_RELEASE:1.2.2.1.4.2
	RELENG_9_1:1.2.2.1.0.4
	RELENG_9_1_BP:1.2.2.1
	RELENG_9_0_0_RELEASE:1.2.2.1.2.1
	RELENG_9_0:1.2.2.1.0.2
	RELENG_9_0_BP:1.2.2.1
	RELENG_9:1.2.0.2
	RELENG_9_BP:1.2;
locks; strict;
comment	@# @;


1.3
date	2012.11.17.01.53.32;	author svnexp;	state Exp;
branches;
next	1.2;

1.2
date	2011.06.26.18.25.10;	author ed;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	2009.09.03.09.33.57;	author ed;	state Exp;
branches;
next	;

1.2.2.1
date	2011.09.23.00.51.37;	author kensmith;	state Exp;
branches
	1.2.2.1.2.1
	1.2.2.1.4.1;
next	1.2.2.2;

1.2.2.2
date	2012.11.17.11.37.26;	author svnexp;	state Exp;
branches;
next	;

1.2.2.1.2.1
date	2011.11.11.04.20.22;	author kensmith;	state Exp;
branches;
next	1.2.2.1.2.2;

1.2.2.1.2.2
date	2012.11.17.08.37.22;	author svnexp;	state Exp;
branches;
next	;

1.2.2.1.4.1
date	2012.08.05.23.54.33;	author kensmith;	state Exp;
branches;
next	1.2.2.1.4.2;

1.2.2.1.4.2
date	2012.11.17.08.48.14;	author svnexp;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Switching exporter and resync
@
text
@#!/usr/bin/awk -f

#-
# Copyright (c) 2008-2009 Ed Schouten <ed@@FreeBSD.org>
# All rights reserved.
#
# 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 AUTHOR 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 AUTHOR 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.
#
# $FreeBSD: head/sys/teken/gensequences 223574 2011-06-26 18:25:10Z ed $

function die(msg) {
	print msg;
	exit 1;
}

function cchar(str) {
	if (str == "^[")
		return "\\x1B";

	return str;
}

BEGIN {
FS = "\t+"

while (getline > 0) {
	if (NF == 0 || $1 ~ /^#/)
		continue;

	if (NF != 3 && NF != 4)
		die("Invalid line layout: " NF " columns");

	split($3, sequence, " +");
	nsequences = 0;
	for (s in sequence)
		nsequences++;

	prefix = "";
	l_prefix_name[""] = "teken_state_init";
	for (i = 1; i < nsequences; i++) {
		n = prefix sequence[i];
		l_prefix_parent[n] = prefix;
		l_prefix_suffix[n] = sequence[i];
		if (!l_prefix_name[n])
			l_prefix_name[n] = "teken_state_" ++npr;
		prefix = n;
	}

	suffix = sequence[nsequences];
	cmd = prefix suffix;

	# Fill lists
	if (l_cmd_name[cmd] != "")
		die(cmd " already exists");
	l_cmd_prefix[cmd] = prefix;
	l_cmd_suffix[cmd] = suffix;
	l_cmd_args[cmd] = $4;
	l_cmd_abbr[cmd] = $1;
	l_cmd_name[cmd] = $2;
	l_cmd_c_name[cmd] = "teken_subr_" tolower($2);
	gsub(" ", "_", l_cmd_c_name[cmd]);

	if ($4 != "")
		l_prefix_numbercmds[prefix]++;
}

print "/* Generated file. Do not edit. */";
print "";

for (p in l_prefix_name) {
	if (l_prefix_name[p] != "teken_state_init")
		print "static teken_state_t	" l_prefix_name[p] ";";
}

for (p in l_prefix_name) {
	print "";
	print "/* '" p "' */";
	print "static void";
	print l_prefix_name[p] "(teken_t *t, teken_char_t c)";
	print "{";

	if (l_prefix_numbercmds[p] > 0) {
		print "";
		print "\tif (teken_state_numbers(t, c))";
		print "\t\treturn;";
	}

	print "";
	print "\tswitch (c) {";
	for (c in l_cmd_prefix) {
		if (l_cmd_prefix[c] != p)
			continue;

		print "\tcase '" cchar(l_cmd_suffix[c]) "': /* " l_cmd_abbr[c] ": " l_cmd_name[c] " */";

		if (l_cmd_args[c] == "v") {
			print "\t\t" l_cmd_c_name[c] "(t, t->t_curnum, t->t_nums);";
		} else {
			printf "\t\t%s(t", l_cmd_c_name[c];
			split(l_cmd_args[c], args, " ");
			for (a = 1; args[a] != ""; a++) {
				if (args[a] == "n")
					printf ", (t->t_curnum < %d || t->t_nums[%d] == 0) ? 1 : t->t_nums[%d]", a, (a - 1), (a - 1);
				else if (args[a] == "r")
					printf ", t->t_curnum < %d ? 0 : t->t_nums[%d]", a, (a - 1);
				else
					die("Invalid argument type: " args[a]);
			}
			print ");";
		}
		print "\t\tbreak;";
	}
	for (pc in l_prefix_parent) {
		if (l_prefix_parent[pc] != p)
			continue;
		print "\tcase '" cchar(l_prefix_suffix[pc]) "':";
		print "\t\tteken_state_switch(t, " l_prefix_name[pc] ");";
		print "\t\treturn;";
	}

	print "\tdefault:";
	if (l_prefix_name[p] == "teken_state_init") {
		print "\t\tteken_subr_regular_character(t, c);";
	} else {
		print "\t\tteken_printf(\"Unsupported sequence in " l_prefix_name[p] ": %u\\n\", (unsigned int)c);";
	}
	print "\t\tbreak;";

	print "\t}";

	if (l_prefix_name[p] != "teken_state_init") {
		print "";
		print "\tteken_state_switch(t, teken_state_init);";
	}
	print "}";
}

}
@


1.2
log
@SVN rev 223574 on 2011-06-26 18:25:10Z by ed

Fix various whitespace inconsistencies in sys/teken.
@
text
@d28 1
a28 1
# $FreeBSD$
@


1.2.2.1
log
@SVN rev 225736 on 2011-09-23 00:51:37Z by kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.2.2.2
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242902
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242902 | dteske | 2012-11-11 23:29:45 +0000 (Sun, 11 Nov 2012) | 10 lines
## SVN ##
## SVN ## Fix a regression introduced by SVN r211417 that saw the breakage of a feature
## SVN ## documented in usr.sbin/sysinstall/help/shortcuts.hlp (reproduced below):
## SVN ##
## SVN ## If /usr/sbin/sysinstall is linked to another filename, say
## SVN ## `/usr/local/bin/configPackages', then the basename will be used
## SVN ## as an implicit command name.
## SVN ##
## SVN ## Reviewed by:	adrian (co-mentor)
## SVN ## Approved by:	adrian (co-mentor)
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d28 1
a28 1
# $FreeBSD: stable/9/sys/teken/gensequences 223574 2011-06-26 18:25:10Z ed $
@


1.2.2.1.4.1
log
@SVN rev 239080 on 2012-08-05 23:54:33Z by kensmith

Copy stable/9 to releng/9.1 as part of the 9.1-RELEASE release process.

Approved by:	re (implicit)
@
text
@@


1.2.2.1.4.2
log
@Switch importer
@
text
@d28 1
a28 1
# $FreeBSD: releng/9.1/sys/teken/gensequences 223574 2011-06-26 18:25:10Z ed $
@


1.2.2.1.2.1
log
@SVN rev 227445 on 2011-11-11 04:20:22Z by kensmith

Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
cycle.

Approved by:	re (implicit)
@
text
@@


1.2.2.1.2.2
log
@Switch importer
@
text
@d28 1
a28 1
# $FreeBSD: releng/9.0/sys/teken/gensequences 223574 2011-06-26 18:25:10Z ed $
@


1.1
log
@SVN rev 196775 on 2009-09-03 09:33:57Z by ed

Move libteken out of the syscons directory.

I initially committed libteken to sys/dev/syscons/teken, but now that
I'm working on a console driver myself, I noticed this was not a good
decision. Move it to sys/teken to make it easier for other drivers to
use a terminal emulator.

Also list teken.c in sys/conf/files, instead of listing it in all the
files.arch files separately.
@
text
@d6 1
a6 1
# 
d15 1
a15 1
# 
@

