https://gcc.gnu.org/g:ff5ce0e7507196be830939f772edeb0528504315
commit r17-6599-gff5ce0e7507196be830939f772edeb0528504315 Author: James K. Lowden <[email protected]> Date: Thu Nov 19 10:50:46 2026 -0500 cobol: Ignore CDF paths for absolute copybook names. gcc/cobol/ChangeLog: * cdf-copy.cc (copybook_elem_t::open_file): Recognize leading slash. Diff: --- gcc/cobol/cdf-copy.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/cobol/cdf-copy.cc b/gcc/cobol/cdf-copy.cc index e2878b33bbe3..dd3c53387ac4 100644 --- a/gcc/cobol/cdf-copy.cc +++ b/gcc/cobol/cdf-copy.cc @@ -258,8 +258,9 @@ copybook_elem_t::open_file( const char directory[], bool literally ) { } char *path = NULL; + bool absolutely = '/' == source.name[0]; - if( dname || library.name ) { + if( (dname || library.name) && ! absolutely ) { if( dname && library.name ) { path = xasprintf( "%s/%s/%s", dname, library.name, source.name ); } else { @@ -298,7 +299,7 @@ copybook_elem_t::open_file( const char directory[], bool literally ) { gcc_assert( ! literally ); free(copier); - + extern int yydebug; if( yydebug ) { std::string pattern(path); @@ -317,7 +318,7 @@ copybook_elem_t::open_file( const char directory[], bool literally ) { std::string pattern(path); pattern += suffix; auto filename = pattern.c_str(); - + if( (this->fd = open(filename, O_RDONLY)) != -1 ) { struct stat sb; if (fstat(fd, &sb)) {
