Skip to content

Initial @file - #289

Open
RamyGeorge wants to merge 10 commits into
OCamlPro:gitside-gnucobol-3.xfrom
RamyGeorge:initial-atfile
Open

Initial @file#289
RamyGeorge wants to merge 10 commits into
OCamlPro:gitside-gnucobol-3.xfrom
RamyGeorge:initial-atfile

Conversation

@RamyGeorge

Copy link
Copy Markdown

Summary

This pull request is intended to introduce the "@file" command line option to GnuCOBOL.

Motivation

Such option would no longer limit the amount of options to that of a given OS's Terminal size.

Changes

  • added initial implementation for "@" detection and reading File contents
  • Called new process_at_file in process_command_line

Misc

I Have left a few notes on current changes and hope for feedback

Comment thread cobc/cobc.c Outdated

@GitMensch GitMensch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll need a force-push from a new local branch to not includes screen changes, it may or may not cherry-pick the current commit on that)

We then need test cases which also shows what the implementation wants to provide and then can have a look if the proposed changes work that way (= work on getting it there).

Comment thread libcob/cobgetopt.c Outdated
Comment thread libcob/cobgetopt.c Outdated

@GitMensch GitMensch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As seen in CI that currently leads to a SEGFAULT:

1197. run_extensions.at:1761: testing CALL unusual PROGRAM-ID. ...
../../tests/run_extensions.at:1815: $COMPILE_MODULE A@B.cob
/tmp/_actions-runner-working-dir/gnucobol/gnucobol/_build/tests/testsuite.dir/at-groups/1197/test-source: line 154: 75721 Segmentation fault      (core dumped) ( $at_check_trace; $COMPILE_MODULE A@B.cob ) >> "$at_stdout" 2>> "$at_stderr" 5>&-
--- /dev/null	2026-04-27 01:59:42.626967408 +0000
+++ /tmp/_actions-runner-working-dir/gnucobol/gnucobol/_build/tests/testsuite.dir/at-groups/1197/stderr	2026-05-18 21:19:44.588745273 +0000
@@ -0,0 +1,5 @@
+
+attempt to reference invalid memory address (signal SIGSEGV)
+
+cobc: aborting
+cobc: Please report this!
../../tests/run_extensions.at:1815: exit code was 139, expected 0
1197. run_extensions.at:1761:  FAILED (run_extensions.at:1815)

so there is still some stuff to do :-)

Most important: please always add Changelog entries as those document the changes you did - also helps for review - and getting the habit of always documenting at least on git push is a good thing; similar applies for the testsuite (would go into used_binaries.at)

Comment thread cobc/cobc.c
Comment thread cobc/cobc.h Outdated
Comment thread libcob/cobgetopt.h Outdated
Comment thread libcob/cobgetopt.c Outdated
Comment thread libcob/cobgetopt.c Outdated
Comment thread libcob/cobgetopt.c Outdated
Comment thread libcob/cobgetopt.c Outdated
Comment thread libcob/cobgetopt.c Outdated

@GitMensch GitMensch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice progress

Comment thread libcob/cobgetopt.c Outdated
Comment thread libcob/cobgetopt.c Outdated
Comment thread cobc/cobc.c
Comment thread cobc/cobc.c Outdated
Comment thread libcob/cobgetopt.c Outdated
Comment thread libcob/cobgetopt.c Outdated
Comment thread libcob/cobgetopt.c Outdated
/* Test whether ARGV[optind] points to a non-option argument. */
#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this non-change for cleaner diff

Comment thread tests/testsuite.src/used_binaries.at
Comment thread tests/testsuite.src/used_binaries.at Outdated
STOP RUN.
])

AT_CHECK([echo "-x" > tempfile.txt

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just use AT_DATA for that

Comment thread tests/testsuite.src/used_binaries.at Outdated
Comment thread libcob/cobgetopt.c Outdated
Comment on lines 493 to 499
@@ -500,11 +498,11 @@ process_at_file(const char* argument_values,int* compile_mode,int* atfile_size){
return NULL;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the old code here was better, you just need to add an additional scope {} around that; note that I'd suggest to do the define here and use all upper-case with a name that is unlikely conflict with any system header

Comment thread libcob/cobgetopt.c Outdated
@RamyGeorge
RamyGeorge force-pushed the initial-atfile branch 2 times, most recently from dd0e41a to 9dbd453 Compare June 2, 2026 16:03
@codecov-commenter

codecov-commenter commented Jun 2, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 65.51724% with 30 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (gitside-gnucobol-3.x@a3accbe). Learn more about missing BASE report.

Files with missing lines Patch % Lines
libcob/cobgetopt.c 64.70% 22 Missing and 8 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@                   Coverage Diff                   @@
##             gitside-gnucobol-3.x     #289   +/-   ##
=======================================================
  Coverage                        ?   67.44%           
=======================================================
  Files                           ?       34           
  Lines                           ?    61615           
  Branches                        ?    16051           
=======================================================
  Hits                            ?    41555           
  Misses                          ?    14107           
  Partials                        ?     5953           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread libcob/cobgetopt.h
Modified for use in GnuCOBOL by Roger While
*/

#include "libcob/common.h"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that change is unrelated and should be done - if at all - in a different commit (possibly added by clangd vscode extension - you can configure automated changes there)

Comment thread libcob/cobgetopt.c

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file should be reverted -> no change

Comment thread libcob/argv.c
Comment on lines +5 to +19
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

Libiberty is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
Boston, MA 02110-1301, USA. */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have a look at cobgetopt.c how to adjust the header

Comment thread libcob/ChangeLog

2026-05-29 Ramy George <ramygeorge19@gmail.com>

* argv.c: extracted the argv.c file from GCC

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • argv.c: new file, extracted from libiberty [GCC version NNN], [youradjustments]
  • cobgetopt.h (cob_expandargv): added the expandargv function in header
  • Makefile.am (SOURCES): include argv.c

Comment thread libcob/argv.c
/* Create and destroy argument vectors. An argument vector is simply an
array of string pointers, terminated by a NULL pointer. */

#include "cobc/cobc.h"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be no cobc in libcob (only the other way around)

Comment thread libcob/cobgetopt.h
arguments to the option '\0'. This behavior is specific to the GNU
`getopt'. */

COB_EXPIMP void cob_expandargv (int *argcp, char ***argvp);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use unnamed parameters in our headers

Comment thread libcob/argv.c

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GCC says:

../../libcob/argv.c:361:1: warning: 'cob_expandargv' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  361 | cob_expandargv (int *argcp, char ***argvp)
      | ^~~~~~~~~~~~~~
../../libcob/argv.c:512:1: warning: 'expandargstr' defined but not used [-Wunused-function]
  512 | expandargstr (const char *progname, const char *val)
      | ^~~~~~~~~~~~
../../libcob/argv.c:486:1: warning: 'countargv' defined but not used [-Wunused-function]
  486 | countargv (char * const *argv)
      | ^~~~~~~~~
../../libcob/argv.c:300:1: warning: 'writeargv' defined but not used [-Wunused-function]
  300 | writeargv (char * const *argv, FILE *f)
      | ^~~~~~~~~

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

following cobgetopt I'd also suggest to rename the file

Comment on lines +1644 to +1645
AT_DATA([echo "-x @tempfile.txt" > tempfile.txt])
AT_DATA([echo "-g --free" > otherfile.txt])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above how AT_DATA is intended to be used (can still be single line)

Comment on lines +1650 to +1653
AT_SETUP(recursive @file with conflict)
AT_KEYWORDS([cobc getopt])


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 before AT_SETUP one after AT_KEYWORDS

Comment thread cobc/cobc.c
cb_config_text_column = 72;

/* Process command line arguments */
cob_expandargv(&argc, &argv);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it useful to also add that to bin/cobcrun?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants