[committed] cobol: Honor explicit -ffree-form
Checks
Commit Message
From: Xavier Del Campo Romero <xdelcampo@symas.com>
Date: Wed, 30 Sep 2026 22:54:57 +0200
Subject: [PATCH] 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.
---
gcc/cobol/lexio.cc | 4 +++-
gcc/cobol/lexio.h | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)
@@ -1509,7 +1509,7 @@ cdftext::lex_open( const char filename[] ) {
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 @@ cdftext::free_form_reference_format( int input,
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());
@@ -353,6 +353,7 @@ typedef std::stack<source_format_t>
source_format_stack_t;
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 );