Skip to content

Commit fec1314

Browse files
authored
Merge pull request #7994 from tautschnig/bugfixes/doc-properties-line-no
Fix line-number output in document-properties-*
2 parents cb62568 + 2038010 commit fec1314

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

regression/goto-instrument/document-properties-basic/html.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.c
33
--document-properties-html
44
^EXIT=0$
55
^SIGNAL=0$
6-
^<em> assert\(1 == 1\);<\/em>$
6+
^\s*\d+&nbsp;&nbsp;<em> assert\(1 == 1\);<\/em>$
77
--
88
^warning: ignoring
99
--

src/goto-instrument/document_properties.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ document_propertiest::get_code(const source_locationt &source_location)
225225

226226
// build dest
227227

228+
std::size_t max_line_number_width = 0;
229+
if(!lines.empty())
230+
{
231+
max_line_number_width = std::to_string(lines.back().line_number).size();
232+
}
228233
for(std::list<linet>::iterator it=lines.begin();
229234
it!=lines.end(); it++)
230235
{
@@ -235,10 +240,10 @@ document_propertiest::get_code(const source_locationt &source_location)
235240
switch(format)
236241
{
237242
case LATEX:
238-
while(line_no.size()<4)
243+
while(line_no.size() < max_line_number_width)
239244
line_no=" "+line_no;
240245

241-
line_no+" ";
246+
line_no += " ";
242247

243248
tmp+=escape_latex(it->text, true);
244249

@@ -248,10 +253,10 @@ document_propertiest::get_code(const source_locationt &source_location)
248253
break;
249254

250255
case HTML:
251-
while(line_no.size()<4)
256+
while(line_no.size() < max_line_number_width)
252257
line_no="&nbsp;"+line_no;
253258

254-
line_no+"&nbsp;&nbsp;";
259+
line_no += "&nbsp;&nbsp;";
255260

256261
tmp+=escape_html(it->text);
257262

@@ -261,7 +266,7 @@ document_propertiest::get_code(const source_locationt &source_location)
261266
break;
262267
}
263268

264-
dest+=tmp+"\n";
269+
dest += line_no + tmp + "\n";
265270
}
266271

267272
return dest;

0 commit comments

Comments
 (0)