Skip to content

Conversation

@tsh-hashimoto
Copy link
Contributor

@tsh-hashimoto tsh-hashimoto commented Jun 23, 2025

Summary

The file name specified in EXEC SQL INCLUDE contains a file extension, which causes a syntax error, so the file can be precompiled and compiled in this format.

Changes

scanner.l

INCFILE [A-Za-z0-9_+\-]+(\.[A-Za-z0-9_+\-]+)?
FILENAME [A-Za-z0-9_\+\-\.]+
...

<ESQL_INCLUDE_STATE>{
...
	{INCFILE} {
		memset(commandname,0,sizeof(commandname));
		com_strcpy(commandname,sizeof(commandname),"INCFILE");
		yylval.s = com_strdup (yytext);
		com_strcpy(incfilename,sizeof(incfilename),yylval.s);
	      	return INCLUDE_FILE;

FILENAME [A-Za-z0-9_+\-]+(\.[A-Za-z0-9_+\-]+)*
...

<ESQL_INCLUDE_STATE>{
...
	{FILENAME} {
		memset(commandname,0,sizeof(commandname));
		com_strcpy(commandname,sizeof(commandname),"INCFILE");
		yylval.s = com_strdup (yytext);
		com_strcpy(incfilename,sizeof(incfilename),yylval.s);
	      	return INCLUDE_FILE;

Tests

Add test cases to basic/include.at.
I have confirmed that it can be included even if the file extension is attached.

Miscellaneous

There were a few tests written in include.at that were not executed. So I have made the following changes:

  • Add include.at to tests/Makefile.
  • Pushed tests/basic after executing make in tests directory.

@tsh-hashimoto tsh-hashimoto requested a review from Copilot June 23, 2025 01:21
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the file name matching logic for the EXEC SQL INCLUDE statement to allow a file extension, changing the regular expression from INCFILE to a revised FILENAME pattern and updating the associated token handling. It also adds test coverage for this behavior and ensures that the include tests are executed via Makefile updates.

  • Updated regex in ocesql/scanner.l to allow file extensions in file names.
  • Replaced token usage from INCFILE to FILENAME to support the extended syntax.
  • Added the missing include test to tests/Makefile.

Reviewed Changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/Makefile Added basic.src/include.at to the test dependencies list.
ocesql/scanner.l Updated regex and token handling to allow file extensions.

@tsh-hashimoto tsh-hashimoto marked this pull request as ready for review June 23, 2025 01:37
@yutaro-sakamoto yutaro-sakamoto merged commit 09ffffd into opensourcecobol:develop Jul 3, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants