Commit 3171f79
committed
qb: fix silent drop of last HAVE_* option when config.params.sh lacks trailing newline
config.params.sh did not end with a newline on its last line (the most
recent entries were 'HAVE_MFI=auto ...' before commit ebf6708 added
HAVE_AVF=auto as the new last line). qb.params.sh reads the file
with the idiom
while read -r VAR _; do ... done < 'qb/config.params.sh'
Under POSIX semantics, 'read' returns non-zero at EOF when the final
line has no terminating newline; the line is still stored in VAR but
the 'while' condition is already false, so the loop body is not
executed. The practical consequence: whichever HAVE_* option lives
on the last line of config.params.sh is silently dropped from OPTS
and CONFIG_OPTS.
This broke the new HAVE_AVF option: the detection logic in
config.libs.sh correctly set HAVE_AVF=yes on macOS 13 after the
-framework AVFoundation check succeeded, but because 'AVF' was never
added to CONFIG_OPTS, create_config_make and create_config_header
never iterated over it, and neither config.mk nor config.h received
any HAVE_AVF entry. Makefile.common's 'ifeq ($(HAVE_AVF), 1)' then
evaluated to false, the AVFoundation camera and recording driver
object files were never compiled or linked, and the drivers were
invisible in Settings -> Drivers at runtime.
Two-part fix:
1. Harden the read loop with '|| [ -n "$VAR" ]'. This is the
canonical POSIX workaround for newline-less files: if 'read'
returns non-zero but VAR is non-empty, we have a partial last
line and should still process it. Prevents this class of bug
from recurring regardless of how config.params.sh is edited.
2. Add a trailing newline to config.params.sh itself. Both fixes
are independently sufficient; having both means downstream forks
that pull just one commit still get the correct behaviour.
This also retroactively un-drops whichever option was the last line
in config.params.sh at earlier points in history - anyone building
against an older tree with a trailing-newline-less params file would
have had silent feature drops for the final option. The only
trigger was editing the file without a text editor that enforces a
terminal newline (vim writes one by default, nano does not unless
configured, echo >> appends a fresh line; direct printf %s '...'
writes or some IDEs do not).1 parent b327848 commit 3171f79
2 files changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
100 | 105 | | |
101 | 106 | | |
102 | 107 | | |
| |||
0 commit comments