From 3d53a70f14d9a6553cd0ffd07497030f2a190fc0 Mon Sep 17 00:00:00 2001
From: Bob Dubner <rdubner@symas.com>
Date: Tue, 24 Dec 2024 16:45:33 -0500
Subject: [PATCH] Replaced "errx(EXITFAILURE," with "cbl_internal_error)"

---
 gcc/cobol/cdf.y        |  2 +-
 gcc/cobol/cdf_text.h   |  4 ++--
 gcc/cobol/cobol1.cc    |  4 ++--
 gcc/cobol/genapi.cc    |  2 +-
 gcc/cobol/parse.y      |  8 ++++----
 gcc/cobol/parse_util.h |  2 +-
 gcc/cobol/scan.l       |  2 +-
 gcc/cobol/symbols.cc   | 10 +++++-----
 gcc/cobol/util.cc      |  2 +-
 9 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/gcc/cobol/cdf.y b/gcc/cobol/cdf.y
index d50c36c30075..897cc888b630 100644
--- a/gcc/cobol/cdf.y
+++ b/gcc/cobol/cdf.y
@@ -651,7 +651,7 @@ replace_by:	name_any[a] BY name_any[b]
 		    add_whitespace = $b.token != YDF_PSEUDOTEXT;
 		    break;
 		  default:
-		      errx(EXIT_FAILURE, "%s:%d: logic error on token %s",
+		      cbl_internal_error( "%s:%d: logic error on token %s",
 			   __FILE__, __LINE__, keyword_str($a.token));
 		      break;
 		  }
diff --git a/gcc/cobol/cdf_text.h b/gcc/cobol/cdf_text.h
index 143d27d9ae41..1f8386db2786 100644
--- a/gcc/cobol/cdf_text.h
+++ b/gcc/cobol/cdf_text.h
@@ -203,12 +203,12 @@ cdftext::lex_open( const char filename[] ) {
     if( kid == -1 ) err(EXIT_FAILURE, "failed waiting for pid %d", pid);
 
     if( WIFSIGNALED(status) ) {
-      errx(EXIT_FAILURE, "%s pid %d terminated by %s",
+      cbl_internal_error( "%s pid %d terminated by %s",
            filter, kid, strsignal(WTERMSIG(status)) );
     }
     if( WIFEXITED(status) ) {
       if( (status = WEXITSTATUS(status)) != 0 ) {
-        errx(EXIT_FAILURE, "%s exited with status %d",
+        cbl_internal_error( "%s exited with status %d",
              filter, status);
       }
     }
diff --git a/gcc/cobol/cobol1.cc b/gcc/cobol/cobol1.cc
index 6f1d833ec854..0bc76a1394a0 100644
--- a/gcc/cobol/cobol1.cc
+++ b/gcc/cobol/cobol1.cc
@@ -251,12 +251,12 @@ cobol_langhook_handle_option (size_t scode,
           break;
         case OPT_preprocess:
           if( ! preprocess_filter_add(arg) ) {
-            errx(EXIT_FAILURE, "error: could not execute preprocessor %s", arg);
+            cbl_internal_error( "error: could not execute preprocessor %s", arg);
           }
           return true;
         case OPT_include:
           if( ! include_file_add(cobol_include) ) {
-            errx(EXIT_FAILURE, "error: could not include %s", cobol_include);
+            cbl_internal_error( "error: could not include %s", cobol_include);
           }
             return true;
 
diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index 0703de0b039e..e5912e93b40a 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -3465,7 +3465,7 @@ parser_leave_file()
     }
   if( file_level == 0 && next_program_is_main )
     {
-    errx(EXIT_FAILURE, 
+    cbl_internal_error( 
          "error: -main switch says \"%s\" should contain the"
          " starting program, but none was found", 
          current_filename.back().c_str());
diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index f69cf799c48c..a25a39a2b538 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -10913,7 +10913,7 @@ constant_index( int token ) {
   case QUOTES      : return 5;
   case NULLS       : return 6;
   }
-  errx(EXIT_FAILURE, "%s:%d: no such constant %d", __func__, __LINE__, token);
+  cbl_internal_error( "%s:%d: no such constant %d", __func__, __LINE__, token);
   return (size_t)-1;
 }
 
@@ -10928,7 +10928,7 @@ relop_of(int token) {
   case GE:  return ge_op;
   case '>': return gt_op;
   }
-  errx(EXIT_FAILURE,
+  cbl_internal_error(
        "%s:%d: invalid relop token %d", __func__, __LINE__, token);
 
   return lt_op; // not reached
@@ -10944,7 +10944,7 @@ relop_invert(relop_t op) {
   case ge_op: return lt_op;
   case gt_op: return le_op;
   }
-  errx(EXIT_FAILURE, "%s:%d: invalid relop_t %d", __func__, __LINE__, op);
+  cbl_internal_error( "%s:%d: invalid relop_t %d", __func__, __LINE__, op);
 
   return relop_t(0); // not reached
 }
@@ -10975,7 +10975,7 @@ token_of(enum relop_t op) {
   case ge_op: return GE;
   case gt_op: return '>';
   }
-  errx(EXIT_FAILURE, "%s:%d: invalid relop_t %d", __func__, __LINE__, op);
+  cbl_internal_error( "%s:%d: invalid relop_t %d", __func__, __LINE__, op);
 
   return 0; // not reached
 }
diff --git a/gcc/cobol/parse_util.h b/gcc/cobol/parse_util.h
index 2a21d2def0b0..06a269478af4 100644
--- a/gcc/cobol/parse_util.h
+++ b/gcc/cobol/parse_util.h
@@ -374,7 +374,7 @@ intrinsic_invalid_parameter( int token, size_t n, cbl_field_t **fields ) {
     case 'U' : //National
     case '8' : //UTF-8
     default:
-      errx(EXIT_FAILURE, "%s: invalid function descr type '%c'",
+      cbl_internal_error( "%s: invalid function descr type '%c'",
            __func__, descr.types[i]);
     }
 
diff --git a/gcc/cobol/scan.l b/gcc/cobol/scan.l
index f13fcd3092ca..54732fdf39e8 100644
--- a/gcc/cobol/scan.l
+++ b/gcc/cobol/scan.l
@@ -912,7 +912,7 @@ USE({SPC}FOR)?		{ return USE; }
                           }
                         }
 
-  . { errx(EXIT_FAILURE, "failed to parse field level on line %d", yylineno); }
+  . { cbl_internal_error( "failed to parse field level on line %d", yylineno); }
 }
 
 <field_state>{
diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc
index 236547c226fb..eecc505763ef 100644
--- a/gcc/cobol/symbols.cc
+++ b/gcc/cobol/symbols.cc
@@ -510,7 +510,7 @@ static bool label_cmp( const cbl_label_t& key,
     switch( elem.type ) {
     case LblNone:
       if(elem.explicit_parent()) {
-        errx(EXIT_FAILURE,  "%s:%d: LblNone '%s' has parent #%zu",
+        cbl_internal_error(  "%s:%d: LblNone '%s' has parent #%zu",
              __func__, __LINE__, elem.name, elem.parent );
       }
       assert(!elem.explicit_parent());
@@ -2043,7 +2043,7 @@ defined_fwd_cmp( const void *K, const void *E ) {
     *e=static_cast<const struct symbol_elem_t *>(E);
 
   if( k->type != SymField ) {
-    errx(EXIT_FAILURE, "%s: key must be field", __func__);
+    cbl_internal_error( "%s: key must be field", __func__);
   }
   if( k->type != e->type ) return 1;
   if( k->program != e->program ) return 1;
@@ -3971,7 +3971,7 @@ symbol_label_add( size_t program, cbl_label_t *input )
   e->elem.label.line = -e->elem.label.line; // force insertion
 
   if( (e = symbol_add(&elem)) == NULL ) {
-    errx(EXIT_FAILURE,
+    cbl_internal_error(
          "%s:%d: could not add '%s'", __func__, __LINE__, label->name);
   }
 
@@ -4101,7 +4101,7 @@ symbol_special_add( size_t program, struct cbl_special_name_t *special )
   struct symbol_elem_t elem = { SymSpecial, program, { .special = *special } };
 
   if( (e = symbol_add(&elem)) == NULL ) {
-    errx(EXIT_FAILURE,
+    cbl_internal_error(
          "%s:%d: could not add '%s'", __func__, __LINE__, special->name);
   }
 
@@ -4139,7 +4139,7 @@ symbol_section_add( size_t program, struct cbl_section_t *section )
                                     program, { .section = *section } };
 
   if( (e = symbol_add(&elem)) == NULL ) {
-    errx(EXIT_FAILURE,
+    cbl_internal_error(
          "%s:%d: could not add '%s'", __func__, __LINE__, section->name());
   }
 
diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc
index 18900afddc87..67668d7f2895 100644
--- a/gcc/cobol/util.cc
+++ b/gcc/cobol/util.cc
@@ -2016,7 +2016,7 @@ bool cobol_filename( const char *name, ino_t inode ) {
       for( auto& elem : old_filenames ) {
         cbl_warning("%6zu %-30s", elem.second, elem.first.c_str());
       }
-      errx(EXIT_FAILURE, "logic error: missing inode for %s", name);
+      cbl_internal_error( "logic error: missing inode for %s", name);
     }
     inode = p->second;
     assert(inode != 0);
-- 
GitLab