]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cobol: Properly DISPLAY COMP-1/-2 variables when "-dialect ibm" is in effect. [PR125616]
authorRobert Dubner <rdubner@symas.com>
Fri, 5 Jun 2026 18:57:27 +0000 (14:57 -0400)
committerRobert Dubner <rdubner@symas.com>
Fri, 5 Jun 2026 19:06:07 +0000 (15:06 -0400)
Second try at DISPLAY COMP-1.  The generated output now matches the
example giving in the PR.

This also addresses a lang.opt.urls problem.

PR cobol/125616

gcc/cobol/ChangeLog:

* lang.opt.urls: Regenerated.

libgcobol/ChangeLog:

* libgcobol.cc (format_for_display_internal): Format matches the
description in the PR.

gcc/cobol/lang.opt.urls
libgcobol/libgcobol.cc

index 9a9a49e78cb2a4411e45a113f06f7473d2cae364..69493276ac1444726a44b9a0468b4a99d85ceb17 100644 (file)
@@ -1,5 +1,8 @@
 ; Autogenerated by regenerate-opt-urls.py from gcc/cobol/lang.opt and generated HTML
 
+B
+UrlSuffix(gcc/Directory-Options.html#index-B) LangUrlSuffix_D(gdc/Directory-Options.html#index-B)
+
 D
 UrlSuffix(gcc/Preprocessor-Options.html#index-D-1)
 
@@ -37,3 +40,6 @@ UrlSuffix(gcc/Directory-Options.html#index-isysroot) LangUrlSuffix_Fortran(gfort
 isystem
 UrlSuffix(gcc/Directory-Options.html#index-isystem) LangUrlSuffix_Fortran(gfortran/Preprocessing-Options.html#index-isystem)
 
+idirafter
+UrlSuffix(gcc/Directory-Options.html#index-idirafter) LangUrlSuffix_Fortran(gfortran/Preprocessing-Options.html#index-idirafter)
+
index dd7ea15dbec657a324510699e32ba688da5a9fcf..64a61411ecbae01af34d84dfa429badb68fe511e 100644 (file)
@@ -3505,15 +3505,21 @@ format_for_display_internal(char **dest,
               //     A COMP-1 item will display as if it had an external
               //     floating-point PICTURE clause of -.9(8)E-99.
               // The plus signs are suppressed.
+              floatval *= 10; // Needed because we are going to flip the
+              //              // decimal point and first digit.
               if( floatval >= 0 )
                 {
-                strfromf32(ach+1, sizeof(ach), "%.8E", floatval);
+                strfromf32(ach+1, sizeof(ach), "%.7E", floatval);
                 ach[0] = ascii_space;
                 }
               else
                 {
-                strfromf32(ach, sizeof(ach), "%.8E", floatval);
+                strfromf32(ach, sizeof(ach), "%.7E", floatval);
                 }
+              // Turn 1.23 into .123
+              ach[2] = ach[1];
+              ach[1] = ascii_period;
+
               // Turn "E+00" to the IBM "E 00"
               p = strchr(ach, ascii_plus);
               if(p)
@@ -3570,15 +3576,20 @@ format_for_display_internal(char **dest,
               //     A COMP-2 item will display as if it had an external
               //     floating-point PICTURE clause of -.9(17)E-99.
               // The plus signs are suppressed.
+              floatval *= 10; // Needed because we are going to flip the
+              //              // decimal point and first digit.
               if( floatval >= 0 )
                 {
-                strfromf64(ach+1, sizeof(ach), "%.17E", floatval);
+                strfromf64(ach+1, sizeof(ach), "%.16E", floatval);
                 ach[0] = ascii_space;
                 }
               else
                 {
-                strfromf64(ach, sizeof(ach), "%.17E", floatval);
+                strfromf64(ach, sizeof(ach), "%.16E", floatval);
                 }
+              // Turn 1.23 into .123
+              ach[2] = ach[1];
+              ach[1] = ascii_period;
               // Turn "E+00" to the IBM "E 00"
               p = strchr(ach, ascii_plus);
               if(p)