cobol: Honor explicit -ffree-form
Previously, an explicit format was only determined as long as
command_line_indicator_column did not equal 0. However, OPT_ffree_form
assigns it to 0 via cobol_set_indicator_column, and therefore the
explicit user setting was being ignored, falling back to the default
behaviour, a heuristic where the first {PROGRAM,FUNCTION}-ID is
examined to determine whether either fixed or free format should be
applied.
Since comparing against 0 is not enough to determine whether a given
format was explicitly requested, a boolean flag has been added to
force a call to source_format_t::indicator_column_set whenever
-ffree-form is requested.
gcc/cobol/ChangeLog:
* lexio.cc (cdftext::lex_open): Add explicit_format condition.
(cobol_set_indicator_column): Use cdftext::explicit_format.
* lexio.h (class cdftext): Add cdftext::explicit_format.
diff --git a/gcc/cobol/lexio.cc b/gcc/cobol/lexio.cc
index 71bc21ed..8b7f6e3 100644
--- a/gcc/cobol/lexio.cc
+++ b/gcc/cobol/lexio.cc
@@ -1509,7 +1509,7 @@
source_format_stack_t source_format;
source_format_t format; // free-form by default
- if( command_line_indicator_column ) {
+ if( command_line_indicator_column || explicit_format ) {
format.indicator_column_set(command_line_indicator_column);
}
source_format.push(format);
@@ -1867,10 +1867,12 @@
bool cdftext::please_push_filename = false;
int cdftext::command_line_indicator_column = 0;
+bool cdftext::explicit_format = false;
void
cobol_set_indicator_column( int column ) {
cdftext::command_line_indicator_column = column;
+ cdftext::explicit_format = true;
source_format_t local;
local.indicator_column_set(column);
dbgmsg("%s: format now %s", __func__, local.description());
diff --git a/gcc/cobol/lexio.h b/gcc/cobol/lexio.h
index 76af58d..742e28e 100644
--- a/gcc/cobol/lexio.h
+++ b/gcc/cobol/lexio.h
@@ -353,6 +353,7 @@
class cdftext {
static bool please_push_filename;
static int command_line_indicator_column;
+ static bool explicit_format;
friend void cobol_set_indicator_column( int column );