]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cobol: Address some iconv issues.
authorIain Sandoe <iain@sandoe.co.uk>
Sun, 6 Apr 2025 13:56:20 +0000 (14:56 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Mon, 7 Apr 2025 14:28:17 +0000 (15:28 +0100)
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 <iain@sandoe.co.uk>
gcc/cobol/symbols.cc

index 50431251a0f1395b958e740ed216a3911507866e..4067459858c3b88c6b86c843d4da976309796a68 100644 (file)
@@ -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;