GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
cobol

cobol: UNSTRING uses longest delimiter

The COBOL UNSTRING statement now correctly selects the longest matching delimiter.

The COBOL compiler’s UNSTRING statement handling has been corrected to properly select the longest delimiter when multiple delimiters match the input text. Previously, it could incorrectly choose the last matching delimiter in the list, leading to parsing errors. This fix ensures that UNSTRING behaves according to the COBOL standard by prioritizing the longest match.

In Details

The unstring.cc implementation for the UNSTRING statement, specifically in unstring_fixed, was selecting the last delimiter that matched the input rather than the longest. This patch modifies the logic to iterate through potential delimiters and only update the 'winner' if a new delimiter is found that is longer than the current longest match.

For Context
UNSTRING statement
A COBOL statement used to parse a string and move parts of it into various receiving fields, optionally using specified delimiters to identify the boundaries between parts.
delimiter
A character or sequence of characters that separates distinct pieces of data. In UNSTRING, delimiters mark the boundaries of substrings to be extracted.
Filed Under: cobolparserstring processing