/* Output a line marker for logical line LINE. Special flags are "1" or "2" indicating entering or leaving a file. */ static void print_line (const struct line_map *map, fileline line, const char *special_flags) { /* End any previous line of text. */ if (print.printed) putc ('\n', print.outf); print.printed = 0; print.line = line; if (!flag_no_line_commands) { size_t to_file_len = strlen (map->to_file); unsigned char *to_file_quoted = alloca (to_file_len * 4 + 1); unsigned char *p; /* cpp_quote_string does not nul-terminate, so we have to do it ourselves. */ p = cpp_quote_string (to_file_quoted, (unsigned char *)map->to_file, to_file_len); *p = '\0'; fprintf (print.outf, "# %u \"%s\"%s", SOURCE_LINE (map, print.line), to_file_quoted, special_flags); if (map->sysp == 2) fputs (" 3 4", print.outf); else if (map->sysp == 1) fputs (" 3", print.outf); putc ('\n', print.outf); } }
static bool print_line_1 (source_location src_loc, const char *special_flags, FILE *stream) { bool emitted_line_marker = false; /* End any previous line of text. */ if (print.printed) putc ('\n', stream); print.printed = 0; if (!flag_no_line_commands) { const char *file_path = LOCATION_FILE (src_loc); int sysp; size_t to_file_len = strlen (file_path); unsigned char *to_file_quoted = (unsigned char *) alloca (to_file_len * 4 + 1); unsigned char *p; print.src_line = LOCATION_LINE (src_loc); print.src_file = file_path; /* cpp_quote_string does not nul-terminate, so we have to do it ourselves. */ p = cpp_quote_string (to_file_quoted, (const unsigned char *) file_path, to_file_len); *p = '\0'; fprintf (stream, "# %u \"%s\"%s", print.src_line == 0 ? 1 : print.src_line, to_file_quoted, special_flags); sysp = in_system_header_at (src_loc); if (sysp == 2) fputs (" 3 4", stream); else if (sysp == 1) fputs (" 3", stream); putc ('\n', stream); emitted_line_marker = true; } return emitted_line_marker; }
/* Output a line marker for logical line LINE. Special flags are "1" or "2" indicating entering or leaving a file. */ static void print_line (source_location src_loc, const char *special_flags) { /* End any previous line of text. */ if (print.printed) putc ('\n', print.outf); print.printed = 0; if (!flag_no_line_commands) { const struct line_map *map = linemap_lookup (line_table, src_loc); size_t to_file_len = strlen (map->to_file); unsigned char *to_file_quoted = (unsigned char *) alloca (to_file_len * 4 + 1); unsigned char *p; print.src_line = SOURCE_LINE (map, src_loc); print.src_file = map->to_file; /* cpp_quote_string does not nul-terminate, so we have to do it ourselves. */ p = cpp_quote_string (to_file_quoted, (const unsigned char *) map->to_file, to_file_len); *p = '\0'; fprintf (print.outf, "# %u \"%s\"%s", print.src_line == 0 ? 1 : print.src_line, to_file_quoted, special_flags); if (map->sysp == 2) fputs (" 3 4", print.outf); else if (map->sysp == 1) fputs (" 3", print.outf); putc ('\n', print.outf); } }