Skip to content

Commit

Permalink
Fix linenum calculation in xpp
Browse files Browse the repository at this point in the history
First, when `begin` is parsed, the end of line `\n` is not eaten
up. In fact, there may be code following after `begin` on the same
line; this is placed after xpp in the line after `begin`. If nothing
follows the `begin` statement on the same line, an empty line is
added. This means, that `linenum` must __not__ increased here; it is
increased when the `\n` of this line is found.

Similar argument for parsing a `task` line; `linenum` must
__not__increased here as well.

Also, when processing include files, an additional '\n' was included, which
is later counted. To revert this effect, linenum has to be decreased here as
well.

When parsing `.help` ... `.endhelp` however, one `linenum` increase was
missing, which is added now.
  • Loading branch information
olebole committed Oct 2, 2017
1 parent 9590f45 commit 7325b35
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions unix/boot/spp/xpp/lexyy.c
Expand Up @@ -2868,6 +2868,7 @@ do_include()
* first line of include file.
*/
unput ('\n');
linenum[istkptr-1]--;

yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE ));
BEGIN(INITIAL);
Expand Down
1 change: 1 addition & 0 deletions unix/boot/spp/xpp/xpp.l
Expand Up @@ -413,6 +413,7 @@ do_include()
* first line of include file.
*/
unput ('\n');
linenum[istkptr-1]--;

yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE ));
BEGIN(INITIAL);
Expand Down
3 changes: 1 addition & 2 deletions unix/boot/spp/xpp/xppcode.c
Expand Up @@ -822,6 +822,7 @@ skip_helpblock (void)
if (istkptr == 0)
linenum[istkptr]++;
}
linenum[istkptr]++;
}


Expand Down Expand Up @@ -888,7 +889,6 @@ parse_task_statement (void)
if ((ch = nextch()) != '\n')
unput (ch);
} else if (ch == '\n') {
linenum[istkptr]++;
ntasks++; /* end of task statement */
break;
} else
Expand Down Expand Up @@ -1153,7 +1153,6 @@ begin_code (void)
setcontext (BODY);
d_runtime (text); outstr (text);
outstr ("begin\n");
linenum[istkptr]++;

/* Initialization. */
nbrace = 0;
Expand Down

0 comments on commit 7325b35

Please sign in to comment.