@@ -126,18 +126,18 @@ files.
126
126
my $length_delta = 0; # how much to adjust pos($text) by
127
127
# say "Old pos: ", $oldpos;
128
128
129
- # Get line number in the original file
130
- my $orig_lineno = 1 + ( () = substr ($text , 0, $idxes [0]) =~ / \n /g );
129
+ # Get line number in the present, possibly modified, text
130
+ my $curr_lineno = 1 + ( () = substr ($text , 0, $idxes [0]) =~ / \n /g );
131
131
# Thanks to ikegami, http://www.perlmonks.org/?node_id=968352
132
- $orig_lineno -= $lines_added ;
132
+ $curr_lineno -= $lines_added ;
133
133
134
134
# Ln must be followed by whitespace and a newline.
135
135
# This is to keep the line numbering vaguely consistent.
136
136
my ($removed ) = (substr ($text , $idxes [1]) =~ s /\A (\h *\n )// );
137
137
138
138
unless ($removed ) {
139
139
# Tell the caller where in the source file the problem is
140
- eval " #line $orig_lineno \" $fn \"\n " .
140
+ eval " #line $curr_lineno \" $fn \"\n " .
141
141
" die(\" L$lang indicator must be on its own line\" );" ;
142
142
die $@ ;
143
143
}
@@ -149,10 +149,10 @@ files.
149
149
150
150
# End an existing capture if we're switching languages
151
151
if ($curr_trailer ) {
152
- $replacement .= " \n $curr_trailer \n " .
153
- " #line $orig_lineno \" $fn \"\n " ;
152
+ $replacement .= " $curr_trailer \n " .
153
+ " #line $curr_lineno \" $fn \"\n " ;
154
154
$curr_trailer =' ' ;
155
- ++ $lines_added ;
155
+ $lines_added += 2 ;
156
156
}
157
157
158
158
# Does this language parse the source text itself?
@@ -171,7 +171,7 @@ files.
171
171
$curr_trailer =
172
172
" AXK_EMBEDDED_SOURCE_DO_NOT_TYPE_THIS_YOURSELF_OR_ELSE" ;
173
173
174
- my $following_lineno = $orig_lineno +1;
174
+ my $following_lineno = $curr_lineno +1;
175
175
# Number of first line of the text in that language
176
176
$replacement .=
177
177
" use XML::Axk::L$lang \" $fn \" , $following_lineno , " .
0 commit comments