https://gcc.gnu.org/g:e6734ffdd3137d46f5174420183eb0d0348f76c0

commit r17-4717-ge6734ffdd3137d46f5174420183eb0d0348f76c0
Author: Xavier Del Campo Romero <[email protected]>
Date:   Thu Sep 24 14:15:05 2026 +0200

    cobol: Add UDF copybooks to gcobc
    
    GnuCOBOL makes STORED-CHAR-LENGTH always available to users, whereas
    gcobol required COPY "stored-char-length.cpy".
    
    The use of the -include command-line option allows to achieve the same
    effect, thus improving compatibility with GnuCOBOL.
    
    gcc/cobol/ChangeLog:
    
            * gcobc: Add stored-char-length.cpy via -include.

Diff:
---
 gcc/cobol/gcobc | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gcc/cobol/gcobc b/gcc/cobol/gcobc
index 447323b75902..46287f02efd4 100755
--- a/gcc/cobol/gcobc
+++ b/gcc/cobol/gcobc
@@ -86,6 +86,34 @@ then
     copydir="-I$COB_COPY_DIR"
 fi
 
+# if not available from the build tree, attempt to search the install 
directory.
+udf_default="${0%/*}/../$($gcobol -dumpmachine)/libgcobol/compat/gnu/cpy"
+if ! [ -d "$udf_default" ]
+then
+    install_dir="$($gcobol -print-search-dirs | grep '^install:' | awk '{print 
$2}')"
+    udf_default="$install_dir/cobol/compat/gnu/cpy"
+fi
+udfdir="${GCOBCUDF:-$udf_default}"
+
+if [ -d "$udfdir" ]
+then
+    # Feel free to add more UDFs below.
+    udfs=stored-char-length.cpy
+
+    for F in $udfs
+    do
+        if [ -f "$udfdir/$F" ]
+        then
+            includes="$includes -include $udfdir/$F "
+        fi
+    done
+else
+    if [ "${GCOBCUDF:-none}" != "none" ]
+    then
+        echo warning: no such directory: "'$GCOBCUDF'"
+    fi
+fi
+
 exit_status=0
 skip_arg=
 opts="$copydir $includes"

Reply via email to