https://gcc.gnu.org/g:6f6c2694dc7c07bca5086c77ef29f3793e0c61c2

commit r15-9257-g6f6c2694dc7c07bca5086c77ef29f3793e0c61c2
Author: Iain Sandoe <i...@sandoe.co.uk>
Date:   Sun Apr 6 14:56:20 2025 +0100

    cobol: Address some iconv issues.
    
    Darwin/macOS installed libiconv does not accept // trailers on
    conversion codes; this causes the init_iconv to fail - and then
    that SEGVs later.
    
    Remove the trailing // as it is not needed elsewhere.
    Also print a warning if we fail to init the conversion.
    
    gcc/cobol/ChangeLog:
    
            * symbols.cc : Remove trailing // on standard_internal.
            (cbl_field_t::internalize): Print a warning if we fail to
            initialise iconv.
    
    Signed-off-by: Iain Sandoe <i...@sandoe.co.uk>

Diff:
---
 gcc/cobol/symbols.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc
index 50431251a0f1..4067459858c3 100644
--- a/gcc/cobol/symbols.cc
+++ b/gcc/cobol/symbols.cc
@@ -3567,7 +3567,7 @@ cbl_field_t::is_ascii() const {
  * compilation, if it moves off the default, it adjusts only once, and
  * never reverts.
  */
-static const char standard_internal[] = "CP1252//";
+static const char standard_internal[] = "CP1252";
 extern os_locale_t os_locale;
 
 static const char *
@@ -3595,6 +3595,10 @@ cbl_field_t::internalize() {
   static  iconv_t cd = iconv_open(tocode, fromcode);
   static const size_t noconv = size_t(-1);
 
+  if (cd == (iconv_t)-1) {
+    yywarn("failed iconv_open tocode = '%s' fromcode = %s", tocode, fromcode);
+  }
+
   // Sat Mar 16 11:45:08 2024: require temporary environment for testing
   if( getenv( "INTERNALIZE_NO") ) return data.initial;

Reply via email to