]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgcobol: Use strchr instead of index
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Sun, 13 Apr 2025 10:46:31 +0000 (12:46 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Sun, 13 Apr 2025 10:46:31 +0000 (12:46 +0200)
valconf.cc doesn't compile on Solaris:

cobol/valconv.cc: In function ‘bool __gg__string_to_numeric_edited(char*, char*, int, int, const char*)’:
cobol/valconv.cc:856:40: error: ‘index’ was not declared in this scope; did you mean ‘Rindex’?
  856 |         const char *decimal_location = index(dest, __gg__decimal_point);      |                                        ^~~~~
     |                                        Rindex

On Solaris, it's only declared in <strings.h>.  While one could get that
included, it's way easier to just use strchr as is already the case in
other instances.

Bootstrapped without regressions on amd64-pc-solaris2.11,
sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu.

2025-04-08  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libgcobol:
* valconv.cc (__gg__string_to_numeric_edited): Use strchr instead
of index.

libgcobol/valconv.cc

index 33d9a0dd1ffd03a666216bca76f9f0246a4c55da..7e5830156c149f3baf8b0512b51a8617c7b41293 100644 (file)
@@ -853,14 +853,14 @@ got_float:
         }
       else
         {
-        const char *decimal_location = index(dest, __gg__decimal_point);
+        const char *decimal_location = strchr(dest, __gg__decimal_point);
         if( !decimal_location )
           {
-          decimal_location = index(dest, ascii_v);
+          decimal_location = strchr(dest, ascii_v);
           }
         if( !decimal_location )
           {
-          decimal_location = index(dest, ascii_V);
+          decimal_location = strchr(dest, ascii_V);
           }
         if( !decimal_location )
           {