summaryrefslogtreecommitdiff
path: root/scan.l
diff options
context:
space:
mode:
authorVern Paxson <vern@ee.lbl.gov>1995-01-09 12:10:57 +0000
committerVern Paxson <vern@ee.lbl.gov>1995-01-09 12:10:57 +0000
commita2e082809053ecb740ef77e62a5dad6727375518 (patch)
tree37718ed88a5735c6591d400b1f53cc9d990a6af8 /scan.l
parent3480b1a76e8daf9dfd2bdfe3cb6bab96f9d2bfe5 (diff)
#line in section 1
Diffstat (limited to 'scan.l')
-rw-r--r--scan.l22
1 files changed, 18 insertions, 4 deletions
diff --git a/scan.l b/scan.l
index 4c5670b..94d3f8f 100644
--- a/scan.l
+++ b/scan.l
@@ -70,7 +70,7 @@
%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
%x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION
-%x OPTION
+%x OPTION LINEDIR
WS [[:blank:]]+
OPTWS [[:blank:]]*
@@ -104,6 +104,7 @@ LEXOPT [aceknopr]
<INITIAL>{
^{WS} indented_code = true; BEGIN(CODEBLOCK);
^"/*" ACTION_ECHO; yy_push_state( COMMENT );
+ ^#{OPTWS}line{WS} yy_push_state( LINEDIR );
^"%s"{NAME}? return SCDECL;
^"%x"{NAME}? return XSCDECL;
^"%{".*{NL} {
@@ -153,6 +154,18 @@ LEXOPT [aceknopr]
[^*\n]*{NL} ++linenum; ACTION_ECHO;
}
+<LINEDIR>{
+ \n yy_pop_state();
+ [[:digit:]]+ linenum = myctoi( yytext );
+
+ \"[^"\n]*\" {
+ flex_free( infilename );
+ infilename = copy_string( yytext + 1 );
+ infilename[strlen( infilename ) - 1] = '\0';
+ }
+ . /* ignore spurious characters */
+}
+
<CODEBLOCK>{
^"%}".*{NL} ++linenum; BEGIN(INITIAL);
@@ -649,7 +662,7 @@ char *file;
{
if ( file )
{
- infilename = file;
+ infilename = copy_string( file );
yyin = fopen( infilename, "r" );
if ( yyin == NULL )
@@ -659,7 +672,7 @@ char *file;
else
{
yyin = stdin;
- infilename = "<stdin>";
+ infilename = copy_string( "<stdin>" );
}
}
@@ -682,5 +695,6 @@ size_t size;
void flex_free( ptr )
void *ptr;
{
- free( ptr );
+ if ( ptr )
+ free( ptr );
}