diff --git a/cobc/ChangeLog b/cobc/ChangeLog index 4cd2d8a85..70d42049e 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -1148,6 +1148,10 @@ * cobc.c (cobc_print_info): adjusted version output for JSON and MPIR * typeck.c: adjusted check of defines for JSON +2020-09-27 Robert Dubner + + * codegen.c (output_cobol_info): emit doubled backslashes for source file + 2020-09-14 Simon Sobisch * cobc.c (cobc_xref_link), tree.h: changed cb_xref_elem to a dual-linked diff --git a/cobc/codegen.c b/cobc/codegen.c index 4d37815c5..20f576571 100644 --- a/cobc/codegen.c +++ b/cobc/codegen.c @@ -8661,13 +8661,31 @@ output_c_info (void) static void output_cobol_info (cb_tree x) { + const char *p = x->source_file; if (!cb_cob_line_num) { skip_line_num = 0; return; } - if (!cb_flag_c_line_directives) - sprintf (last_line_num, "#line %d \"%s\"", x->source_line, x->source_file); - output ("#line %d \"%s\"", x->source_line, x->source_file); + if (!cb_flag_c_line_directives) { + char *q = last_line_num + strlen(last_line_num); + sprintf (last_line_num, "#line %d \"", x->source_line); + while(*p){ + if( *p == '\\' ){ + *q++ = '\\'; + } + *q++ = *p++; + } + sprintf (q, "\""); + } + output ("#line %d \"", x->source_line); + + while(*p){ + if( *p == '\\' ){ + output("%c",'\\'); + } + output("%c",*p++); + } + output("\""); skip_line_num++; output_newline (); } diff --git a/cobc/flag.def b/cobc/flag.def index 3b1dbb3af..0fe9c9a4b 100644 --- a/cobc/flag.def +++ b/cobc/flag.def @@ -96,10 +96,6 @@ CB_FLAG (cb_flag_sql_xfd, 1, "sql", /* Flags with suppressed help */ -CB_FLAG_ON (cb_flag_recursive_check, 1, "recursive-check", - _(" -fno-recursive-check disable check of recursive program call;\n" - " effectively compiling as RECURSIVE program")) - CB_FLAG (cb_flag_winmain, 0, "winmain", _(" -fwinmain generate WinMain instead of main when compiling\n" " as executable")) @@ -160,6 +156,10 @@ CB_FLAG (cb_flag_source_location, 1, "source-location", CB_FLAG (cb_flag_implicit_init, 1, "implicit-init", _(" -fimplicit-init automatic initialization of the COBOL runtime system")) +CB_FLAG_ON (cb_flag_recursive_check, 1, "recursive-check", + _(" -fno-recursive-check disable check of recursive program call;\n" + " effectively compiling as RECURSIVE program")) + CB_FLAG (cb_flag_stack_check, 1, "stack-check", _(" -fstack-check PERFORM stack checking\n" " * turned on by -debug or -g"))