openwrt-redmi-ax3000/include
Huangbin Zhan 2f8ac8bcea
build: image: use printf for ModelNameLimit16
Fix syntax error on macos, for substr is undefined results according to
the POSIX standard.

From expr on macos:
 According to the POSIX standard, the use of string arguments length,
 substr, index, or match produces undefined results.  In this version of
 expr, these arguments are treated just as their respective string values.

By a simple test Makefile:

define ModelNameLimit16
$(shell expr substr "$(word 2, $(subst _, ,$(1)))" 1 16)
endef

define ModelNameLimit16_2
$(shell printf %.16s "$(word 2, $(subst _, ,$(1)))")
endef

hello:
	echo $(call ModelNameLimit16, technicolor_tg582n-telecom-italia)
	echo $(call ModelNameLimit16_2, technicolor_tg582n-telecom-italia)

The same output is produced.

echo tg582n-telecom-i
tg582n-telecom-i
echo tg582n-telecom-i
tg582n-telecom-i

Signed-off-by: Huangbin Zhan <zhanhb88@gmail.com>
[ wrap commit description to 80 columns and improve it ]
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2022-10-13 15:57:35 +02:00
..
site
autotools.mk
bpf.mk
cmake.mk
debug.mk
depends.mk
device_table.txt
download.mk rules.mk: move DOWNLOAD_CHECK_CERTIFICATE to include/download.mk 2022-10-05 17:49:19 +02:00
feeds.mk
hardened-ld-pie.specs
hardening.mk
host-build.mk
image-commands.mk build: image: use printf for ModelNameLimit16 2022-10-13 15:57:35 +02:00
image.mk
kernel-5.10 kernel: bump 5.10 to 5.10.147 2022-10-09 22:18:24 +02:00
kernel-5.15 kernel: bump 5.15 to 5.15.72 2022-10-09 22:26:16 +02:00
kernel-build.mk
kernel-defaults.mk
kernel-version.mk
kernel.mk
logo.png
logo.svg
meson.mk
netfilter.mk
nls.mk
openssl-engine.mk
package-bin.mk
package-defaults.mk
package-dumpinfo.mk
package-ipkg.mk
package-seccomp.mk
package.mk
prereq-build.mk
prereq.mk
quilt.mk
rootfs.mk
scan.awk
scan.mk
shell.sh
subdir.mk
target.mk
toolchain-build.mk
toplevel.mk
trusted-firmware-a.mk
u-boot.mk
uclibc++.mk
unpack.mk
verbose.mk
version.mk