]> git.ipfire.org Git - thirdparty/gcc.git/commit
cobol: Improve binary-to-string conversion.
authorRobert Dubner <rdubner@symas.com>
Thu, 7 Aug 2025 19:52:02 +0000 (15:52 -0400)
committerRobert Dubner <rdubner@symas.com>
Thu, 7 Aug 2025 20:12:32 +0000 (16:12 -0400)
commitc684053fc0f0a159f4ddbc7d023fdcc61752b58d
tree22cb4c18fe39bfe167e5cd4f80bb0f67d649b93b
parent932b764be40bc675a65b89111bd28f31e99fcdbd
cobol: Improve binary-to-string conversion.

COBOL often requires the conversion of binary integers to string of characters.
These changes replace a naive routine that peels decimal digits from a binary
value one digit at a time, with a divide-and-conquer algorithm that is twice as
fast even for a couple of digits, and is about eight times faster past ten
digits.

Included here are some minor fixes to the lexer and parser.

gcc/cobol/ChangeLog:

* cbldiag.h (location_dump): Source code formatting.
* parse.y: error_msg formatting.
* scan.l: Remove UTF-8 character from regex pattern.
* scan_ante.h (numstr_of): error_msg formatting.
* show_parse.h (class ANALYZE): Suppress cppcheck error.
* util.cc (cbl_field_t::report_invalid_initial_value):
error_msg formatting.

libgcobol/ChangeLog:

* Makefile.am: Include new stringbin.cc file.
* Makefile.in: Regenerated.
* libgcobol.cc (__gg__power_of_ten): Improve error message.
(__gg__binary_to_string): Deleted.
(__gg__binary_to_string_internal): Deleted.
(int128_to_field): Use new conversion routine.
(__gg__move): Use new conversion routine.
* stringbin.cc: New file. Implements new conversion routine.
* stringbin.h: New file. Likewise.
gcc/cobol/cbldiag.h
gcc/cobol/parse.y
gcc/cobol/scan.l
gcc/cobol/scan_ante.h
gcc/cobol/show_parse.h
gcc/cobol/util.cc
libgcobol/Makefile.am
libgcobol/Makefile.in
libgcobol/libgcobol.cc
libgcobol/stringbin.cc [new file with mode: 0644]
libgcobol/stringbin.h [new file with mode: 0644]