h2pas: Failing on header guards and inline comments: `An unhandled exception occurred` and `EInOutError: File not open`
Summary
h2pas is failing on #ifndef...#define...#endif simple headers guards with An unhandled exception occurred and EInOutError: File not open along with 3 temporary files.
h2pas is also failing // end of line comments.
System Information
- Operating system: Linux, AlmaLinux 9.2, x86_64
- Processor architecture: x86-64
- Compiler version: 3.3.1-13810-g1bcf4a5a8c
- Device: Computer
Steps to reproduce
given the following 3 header files:
header_in_00.h
int b(int c);
header_in_01.h
#ifndef HEADER_GUARD_H
#define HEADER_GUARD_H
int b(int c);
#endif
header_in_02.h
// what?
int b(int c);
When FPC trunk h2pas is run on them ( *.tmp and *.pp removed on each run ):
$ fpc -iW
3.3.1
$ h2pas header_in_00.h
$ ls
header_in_00.h
header_in_00.pp
header_in_01.h
header_in_02.h
$ h2pas header_in_01.h
An unhandled exception occurred at $0000000000452F20:
EInOutError: File not open
$0000000000452F20
$ ls
ext2.tmp
ext3.tmp
ext.tmp
header_in_00.h
header_in_01.h
header_in_02.h
$ h2pas header_in_02.h
An unhandled exception occurred at $0000000000451A09:
EInOutError: File not open
$0000000000451A09
$ ls
ext2.tmp
ext3.tmp
ext.tmp
header_in_00.h
header_in_01.h
header_in_02.h
Only the h2pas run on header_in_00.h results in a valid .pp file.
The other results in an an unhandled EInOutError exception and 3 temporary files.
The header_in_00.pp created by the first run is valid.
unit header_in_00;
interface
{
Automatically converted by H2Pas 0.99.16 from header_in_00.h
The following command line parameters were used:
header_in_00.h
}
{$IFDEF FPC}
{$PACKRECORDS C}
{$ENDIF}
function b(c:longint):longint;
implementation
function b(c:longint):longint;
begin
{ You must implement this function }
end;
end.
Example Project
See Steps to reproduce.
What is the current bug behavior?
See Steps to reproduce.
What is the expected (correct) behavior?
The stable released FPC h2pas handles all 3 header files with no issues.
$ fpc -iW
3.2.2
$ h2pas header_in_00.h
$ ls
header_in_00.h
header_in_00.pp
header_in_01.h
header_in_02.h
$ h2pas header_in_01.h
$ ls
header_in_00.h
header_in_01.h
header_in_01.pp
header_in_02.h
$ h2pas header_in_02.h
$ ls
header_in_00.h
header_in_01.h
header_in_02.h
header_in_02.pp
All generated header_in_*.pp unit files are correct when using the stable h2pas.
Relevant logs and/or screenshots
See Steps to reproduce.
Possible fixes
None known.