aboutsummaryrefslogtreecommitdiff
path: root/gcc/edit-context.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/edit-context.c')
-rw-r--r--gcc/edit-context.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/gcc/edit-context.c b/gcc/edit-context.c
index 9ac2dfc..3cdb88d 100644
--- a/gcc/edit-context.c
+++ b/gcc/edit-context.c
@@ -422,12 +422,10 @@ edited_file::print_content (pretty_printer *pp)
el->print_content (pp);
else
{
- int len;
- const char *line
- = location_get_source_line (m_filename, line_num, &len);
+ char_span line = location_get_source_line (m_filename, line_num);
if (!line)
return false;
- for (int i = 0; i < len; i++)
+ for (size_t i = 0; i < line.length (); i++)
pp_character (pp, line[i]);
}
if (line_num < line_count)
@@ -543,10 +541,8 @@ edited_file::print_diff_hunk (pretty_printer *pp, int old_start_of_hunk,
else
{
/* Unchanged line. */
- int line_len;
- const char *old_line
- = location_get_source_line (m_filename, line_num, &line_len);
- print_diff_line (pp, ' ', old_line, line_len);
+ char_span old_line = location_get_source_line (m_filename, line_num);
+ print_diff_line (pp, ' ', old_line.get_buffer (), old_line.length ());
line_num++;
}
}
@@ -574,10 +570,9 @@ edited_file::print_run_of_changed_lines (pretty_printer *pp,
gcc_assert (el_in_run);
if (el_in_run->actually_edited_p ())
{
- int line_len;
- const char *old_line
- = location_get_source_line (m_filename, line_num, &line_len);
- print_diff_line (pp, '-', old_line, line_len);
+ char_span old_line = location_get_source_line (m_filename, line_num);
+ print_diff_line (pp, '-', old_line.get_buffer (),
+ old_line.length ());
}
}
pp_string (pp, colorize_stop (pp_show_color (pp)));
@@ -671,10 +666,8 @@ edited_file::get_num_lines (bool *missing_trailing_newline)
m_num_lines = 0;
while (true)
{
- int line_size;
- const char *line
- = location_get_source_line (m_filename, m_num_lines + 1,
- &line_size);
+ char_span line
+ = location_get_source_line (m_filename, m_num_lines + 1);
if (line)
m_num_lines++;
else
@@ -695,12 +688,12 @@ edited_line::edited_line (const char *filename, int line_num)
m_line_events (),
m_predecessors ()
{
- const char *line = location_get_source_line (filename, line_num,
- &m_len);
+ char_span line = location_get_source_line (filename, line_num);
if (!line)
return;
+ m_len = line.length ();
ensure_capacity (m_len);
- memcpy (m_content, line, m_len);
+ memcpy (m_content, line.get_buffer (), m_len);
ensure_terminated ();
}