Skip to content

Commit 434b0e5

Browse files
committed
Make "fbc -print x" print just the exeext again (e90b3d3 regression)
Since e90b3d3, -print x was broken: "fbc -print x" now gave unnamed[.exe] instead of just [.exe], because the -print option handling was moved behind the code that sets fbc.mainname (fbcInit2() back then, now fbcDetermineMainName()), and no longer made a difference between whether input files were given or not. However, -print x without input files should not do fbcDetermineMainName(), so fbc.outname ends up being only the .exe extension.
1 parent 31ea57c commit 434b0e5

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/compiler/fbc.bas

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3353,7 +3353,10 @@ end sub
33533353
'' the command line ones, so those will be searched first)
33543354
fbAddIncludePath( fbc.incpath )
33553355

3356-
fbcDetermineMainName( )
3356+
var have_input_files = (listGetHead( @fbc.modules ) <> NULL) or _
3357+
(listGetHead( @fbc.objlist ) <> NULL) or _
3358+
(listGetHead( @fbc.libs.list ) <> NULL) or _
3359+
(listGetHead( @fbc.libfiles ) <> NULL)
33573360

33583361
'' Answer -print query, if any, and stop
33593362
'' The -print option is intended to allow shell scripts, makefiles, etc.
@@ -3365,6 +3368,11 @@ end sub
33653368
case PRINT_TARGET
33663369
print fbGetTargetId( )
33673370
case PRINT_X
3371+
'' If we have input files, -print x should give the output name that we'd normally get.
3372+
'' However, a plain "fbc -print x" without input files should just give the .exe extension.
3373+
if( have_input_files ) then
3374+
fbcDetermineMainName( )
3375+
end if
33683376
hSetOutName( )
33693377
print fbc.outname
33703378
case PRINT_FBLIBDIR
@@ -3373,11 +3381,10 @@ end sub
33733381
fbcEnd( 0 )
33743382
end if
33753383

3384+
fbcDetermineMainName( )
3385+
33763386
'' Show help if there are no input files
3377-
if( (listGetHead( @fbc.modules ) = NULL) and _
3378-
(listGetHead( @fbc.objlist ) = NULL) and _
3379-
(listGetHead( @fbc.libs.list ) = NULL) and _
3380-
(listGetHead( @fbc.libfiles ) = NULL) ) then
3387+
if( have_input_files = FALSE ) then
33813388
hPrintOptions( )
33823389
fbcEnd( 1 )
33833390
end if

tests/fbcprint/results.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-print x -target win32 = unnamed.exe
2-
-print x -target linux = unnamed
1+
-print x -target win32 = .exe
2+
-print x -target linux =
33
-print x 1.bas -target win32 = 1.exe
44
-print x lib1.a -target win32 = unnamed.exe
55
-print x 1.o -target win32 = 1.exe

0 commit comments

Comments
 (0)