>From 5ae7aab919826dc03c2f4a7e4ae33880fc132bf9 Mon Sep 17 00:00:00 2001
From: Jochen Keil <jochen.keil@emlix.com>
Date: Fri, 29 Jan 2010 10:33:34 +0100
Subject: [PATCH 3/9] if we match a #! at start of file we look for a matching exec statement
 to cover the exec tclsh "$0" ${1+$@} trick from the tclsh manpage

---
 tcl-dox.l |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/tcl-dox.l b/tcl-dox.l
index ac3a69b..17887c4 100644
--- a/tcl-dox.l
+++ b/tcl-dox.l
@@ -58,13 +58,18 @@ void handleArgumentComma();
 %option nounput 
 
 %x CBLOCK CLASS PROC PROC_OPEN PROC_ARGS OPTIONAL_ARG 
-%x VAR CLASS_INH INH NAMESPACE UNSUPPORTED_CMD
+%x VAR CLASS_INH INH NAMESPACE UNSUPPORTED_CMD EXEC
 
 ID    [[:alpha:]_]+[[:alnum:]_]*
 WS    [ \t]
 
 %%
 
+	/* looks like a shebang line.. smells like the exec trick so lets
+	 * try to catch it; match this only at the start of file */
+"#!".*$ {
+	BEGIN(EXEC);
+}
 
 <INITIAL>{
  ##{WS}*$ {
@@ -159,6 +164,11 @@ WS    [ \t]
 }
 
 
+<EXEC>{
+	.*"exec"[ \t]+.* {BEGIN(INITIAL);}
+	.* {BEGIN(EXEC);}
+}
+
 
 
 <CBLOCK>{
-- 
1.6.6.1