summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
Diffstat (limited to 'extra')
-rw-r--r--extra/Configs/Config.alpha4
-rw-r--r--extra/Configs/Config.arc46
-rw-r--r--extra/Configs/Config.arm138
-rw-r--r--extra/Configs/Config.avr324
-rw-r--r--extra/Configs/Config.bfin5
-rw-r--r--extra/Configs/Config.c6x29
-rw-r--r--extra/Configs/Config.cris10
-rw-r--r--extra/Configs/Config.e123
-rw-r--r--extra/Configs/Config.frv4
-rw-r--r--extra/Configs/Config.h83007
-rw-r--r--extra/Configs/Config.hppa4
-rw-r--r--extra/Configs/Config.i38679
-rw-r--r--extra/Configs/Config.i96019
-rw-r--r--extra/Configs/Config.ia644
-rw-r--r--extra/Configs/Config.in1082
-rw-r--r--extra/Configs/Config.in.arch59
-rw-r--r--extra/Configs/Config.lm32 (renamed from extra/Configs/Config.v850)13
-rw-r--r--extra/Configs/Config.m68k5
-rw-r--r--extra/Configs/Config.metag32
-rw-r--r--extra/Configs/Config.microblaze11
-rw-r--r--extra/Configs/Config.mips45
-rw-r--r--extra/Configs/Config.nios23
-rw-r--r--extra/Configs/Config.nios26
-rw-r--r--extra/Configs/Config.or1k35
-rw-r--r--extra/Configs/Config.powerpc4
-rw-r--r--extra/Configs/Config.sh9
-rw-r--r--extra/Configs/Config.sh6435
-rw-r--r--extra/Configs/Config.sparc14
-rw-r--r--extra/Configs/Config.vax24
-rw-r--r--extra/Configs/Config.x86_645
-rw-r--r--extra/Configs/Config.xtensa8
-rw-r--r--extra/Configs/defconfigs/alpha/defconfig (renamed from extra/Configs/defconfigs/alpha)0
-rw-r--r--extra/Configs/defconfigs/arc/arcv2_defconfig39
-rw-r--r--extra/Configs/defconfigs/arc/defconfig38
-rw-r--r--extra/Configs/defconfigs/arc/tb10x_defconfig38
-rw-r--r--extra/Configs/defconfigs/arm/defconfig (renamed from extra/Configs/defconfigs/arm)0
-rw-r--r--extra/Configs/defconfigs/avr32/defconfig (renamed from extra/Configs/defconfigs/avr32)0
-rw-r--r--extra/Configs/defconfigs/bfin/defconfig (renamed from extra/Configs/defconfigs/bfin)0
-rw-r--r--extra/Configs/defconfigs/cris/defconfig (renamed from extra/Configs/defconfigs/cris)0
-rw-r--r--extra/Configs/defconfigs/e11
-rw-r--r--extra/Configs/defconfigs/frv/defconfig (renamed from extra/Configs/defconfigs/frv)0
-rw-r--r--extra/Configs/defconfigs/h8300/defconfig (renamed from extra/Configs/defconfigs/h8300)0
-rw-r--r--extra/Configs/defconfigs/hppa/defconfig (renamed from extra/Configs/defconfigs/hppa)0
-rw-r--r--extra/Configs/defconfigs/i386/defconfig (renamed from extra/Configs/defconfigs/i386)0
-rw-r--r--extra/Configs/defconfigs/i9601
-rw-r--r--extra/Configs/defconfigs/ia64/defconfig (renamed from extra/Configs/defconfigs/ia64)0
-rw-r--r--extra/Configs/defconfigs/lm321
-rw-r--r--extra/Configs/defconfigs/m68k/defconfig (renamed from extra/Configs/defconfigs/m68k)0
-rw-r--r--extra/Configs/defconfigs/metag/defconfig1
-rw-r--r--extra/Configs/defconfigs/microblaze/defconfig (renamed from extra/Configs/defconfigs/microblaze)0
-rw-r--r--extra/Configs/defconfigs/mips/defconfig (renamed from extra/Configs/defconfigs/mips)0
-rw-r--r--extra/Configs/defconfigs/nios1
-rw-r--r--extra/Configs/defconfigs/nios2/defconfig (renamed from extra/Configs/defconfigs/nios2)0
-rw-r--r--extra/Configs/defconfigs/or1k/defconfig242
-rw-r--r--extra/Configs/defconfigs/powerpc/defconfig (renamed from extra/Configs/defconfigs/powerpc)0
-rw-r--r--extra/Configs/defconfigs/sh/defconfig (renamed from extra/Configs/defconfigs/sh)0
-rw-r--r--extra/Configs/defconfigs/sh641
-rw-r--r--extra/Configs/defconfigs/sparc/defconfig (renamed from extra/Configs/defconfigs/sparc)0
-rw-r--r--extra/Configs/defconfigs/v8501
-rw-r--r--extra/Configs/defconfigs/vax1
-rw-r--r--extra/Configs/defconfigs/x86_64/defconfig (renamed from extra/Configs/defconfigs/x86_64)0
-rw-r--r--extra/config/.gitignore7
-rw-r--r--extra/config/Makefile91
-rw-r--r--extra/config/Makefile.kconfig293
-rw-r--r--extra/config/README.uClibc3
-rwxr-xr-xextra/config/check.sh2
-rw-r--r--extra/config/conf.c510
-rw-r--r--extra/config/confdata.c871
-rw-r--r--extra/config/expr.c92
-rw-r--r--extra/config/expr.h122
-rw-r--r--extra/config/gconf.c218
-rw-r--r--extra/config/gconf.glade33
-rw-r--r--extra/config/kconfig-language.txt62
-rw-r--r--extra/config/kconfig-to-uclibc.patch.gzbin5989 -> 0 bytes
-rw-r--r--extra/config/kconfig-to-uclibc.tar.gzbin0 -> 4285 bytes
-rw-r--r--extra/config/kconfig_load.c35
-rw-r--r--extra/config/kxgettext.c24
-rw-r--r--extra/config/list.h131
-rw-r--r--extra/config/lkc.h84
-rw-r--r--extra/config/lkc_proto.h16
-rw-r--r--[-rwxr-xr-x]extra/config/lxdialog/check-lxdialog.sh15
-rw-r--r--extra/config/lxdialog/checklist.c21
-rw-r--r--extra/config/lxdialog/dialog.h31
-rw-r--r--extra/config/lxdialog/inputbox.c135
-rw-r--r--extra/config/lxdialog/menubox.c53
-rw-r--r--extra/config/lxdialog/textbox.c183
-rw-r--r--extra/config/lxdialog/util.c94
-rw-r--r--extra/config/lxdialog/yesno.c8
-rw-r--r--extra/config/mconf.c535
-rw-r--r--extra/config/menu.c325
-rwxr-xr-xextra/config/merge_config.sh150
-rw-r--r--extra/config/nconf.c1557
-rw-r--r--extra/config/nconf.gui.c656
-rw-r--r--extra/config/nconf.h96
-rw-r--r--extra/config/qconf.cc337
-rw-r--r--extra/config/qconf.h95
-rw-r--r--extra/config/streamline_config.pl640
-rw-r--r--extra/config/symbol.c636
-rw-r--r--extra/config/util.c70
-rw-r--r--extra/config/zconf.gperf3
-rw-r--r--extra/config/zconf.hash.c_shipped271
-rw-r--r--extra/config/zconf.l61
-rw-r--r--extra/config/zconf.lex.c_shipped (renamed from extra/config/lex.zconf.c_shipped)126
-rw-r--r--extra/config/zconf.tab.c_shipped1000
-rw-r--r--extra/config/zconf.y107
-rw-r--r--extra/locale/.gitignore26
-rw-r--r--extra/locale/Makefile6
-rw-r--r--extra/locale/Makefile.in189
-rw-r--r--extra/locale/gen_collate.c236
-rw-r--r--extra/locale/gen_ldc.c9
-rw-r--r--extra/locale/gen_locale.c227
-rw-r--r--extra/locale/gen_mmap.c2
-rw-r--r--extra/locale/gen_wc8bit.c327
-rw-r--r--extra/locale/gen_wctype.c913
-rw-r--r--extra/locale/lmmtolso.c6
-rw-r--r--extra/locale/locale_mmap.h52
-rw-r--r--extra/locale/programs/locale.c52
-rw-r--r--extra/scripts/.gitignore1
-rwxr-xr-xextra/scripts/MAKEALL146
-rwxr-xr-xextra/scripts/conf-header.sh2
-rwxr-xr-xextra/scripts/cppcheck.sh56
-rw-r--r--extra/scripts/gen-as-const.awk33
-rwxr-xr-xextra/scripts/gen_bits_syscall_h.sh56
-rwxr-xr-xextra/scripts/getent4
-rwxr-xr-xextra/scripts/install_headers.sh53
-rwxr-xr-xextra/scripts/install_kernel_headers.sh74
-rw-r--r--extra/scripts/none.lds13
-rwxr-xr-xextra/scripts/randconfig.sh26
-rwxr-xr-xextra/scripts/relative_path.sh5
-rwxr-xr-xextra/scripts/relinfo.pl5
-rw-r--r--extra/scripts/unifdef.c1159
-rw-r--r--extra/scripts/unifdef.h57
-rw-r--r--extra/scripts/unifdef.test67
-rw-r--r--extra/scripts/version.h2
134 files changed, 11272 insertions, 4482 deletions
diff --git a/extra/Configs/Config.alpha b/extra/Configs/Config.alpha
index fd2d7a8e5..212df6a82 100644
--- a/extra/Configs/Config.alpha
+++ b/extra/Configs/Config.alpha
@@ -13,7 +13,5 @@ config FORCE_OPTIONS_FOR_ARCH
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_MMU
select ARCH_HAS_NO_LDSO
+ select ARCH_HAS_DEPRECATED_SYSCALLS
select UCLIBC_HAS_LFS
-
-config ARCH_CFLAGS
- string
diff --git a/extra/Configs/Config.arc b/extra/Configs/Config.arc
new file mode 100644
index 000000000..0c0bc71ce
--- /dev/null
+++ b/extra/Configs/Config.arc
@@ -0,0 +1,46 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+config TARGET_ARCH
+ default "arc"
+
+config FORCE_OPTIONS_FOR_ARCH
+ bool
+ default y
+ select ARCH_ANY_ENDIAN
+
+choice
+ prompt "Target Processor Type"
+ default CONFIG_ARC_CPU_700
+
+config CONFIG_ARC_CPU_700
+ bool "ARC700"
+ select ARCH_HAS_MMU
+ help
+ ARCompact ISA based ARC CPU
+
+config CONFIG_ARC_CPU_HS
+ bool "ARC-HS"
+ select ARCH_HAS_MMU
+ help
+ Next Generation ARCv2 ISA based Processors
+
+endchoice
+
+choice
+ prompt "MMU Page Size"
+ default CONFIG_ARC_PAGE_SIZE_8K
+
+config CONFIG_ARC_PAGE_SIZE_8K
+ bool "8KB"
+ help
+ Choose between 4k, 8k (default) or 16k
+
+config CONFIG_ARC_PAGE_SIZE_16K
+ bool "16KB"
+
+config CONFIG_ARC_PAGE_SIZE_4K
+ bool "4KB"
+
+endchoice
diff --git a/extra/Configs/Config.arm b/extra/Configs/Config.arm
index 26e1f3da4..00cf98281 100644
--- a/extra/Configs/Config.arm
+++ b/extra/Configs/Config.arm
@@ -11,126 +11,38 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_ANY_ENDIAN
+ select ARCH_HAS_UCONTEXT
+ select ARCH_HAS_DEPRECATED_SYSCALLS
-config ARCH_CFLAGS
- string
-
-choice
- prompt "Target ABI"
- default CONFIG_ARM_OABI
+config CONFIG_ARM_EABI
+ bool "Build for EABI"
help
- If you choose "EABI" here, functions and constants required by the
- ARM EABI will be built into the library. You should choose "EABI"
+ If you say 'y' here, functions and constants required by the
+ ARM EABI will be built into the library. You should say 'y'
if your compiler uses the ARM EABI, in which case you will also
- need a kernel supporting the EABI system call interface, or "OABI"
- for a compiler using the old Linux ABI.
-
-config CONFIG_ARM_OABI
- bool "OABI"
+ need a kernel supporting the EABI system call interface.
-config CONFIG_ARM_EABI
- bool "EABI"
+ If you say 'n' here, then the library will be built for the
+ old Linux ABI.
-endchoice
+config COMPILE_IN_THUMB_MODE
+ bool "Build using Thumb mode"
+ select USE_BX
+ select USE_LDREXSTREX
+ help
+ Say 'y' here to force building uClibc in thumb mode.
+ Say 'n' to use your compiler's default mode.
config USE_BX
bool "Use BX in function return"
- default y
- depends on !CONFIG_GENERIC_ARM && !CONFIG_ARM610 && !CONFIG_ARM710
help
- Use BX instruction for THUMB aware architectures.
-
-choice
- prompt "Target Processor Type"
- default CONFIG_GENERIC_ARM
+ Say 'y' to use BX to return from functions on your thumb-aware
+ processor. Say 'y' if you need to use interworking. Say 'n' if not.
+ It is safe to say 'y' even if you're not doing interworking.
+
+config USE_LDREXSTREX
+ bool "Use load-store exclusive ASM ops (not supported in SmartFusion)"
+ depends on COMPILE_IN_THUMB_MODE
+ default n
help
- This is the processor type of your CPU. This information is used for
- optimizing purposes. To build a library that will run on all ARMCPU
- types (albeit not optimally fast), you can specify "Generic Arm" here.
- If you pick anything other than "Generic Arm", there is no guarantee
- that uClibc will even run on anything other than the selected processor
- type.
-
- Here are the settings recommended for greatest speed:
- - "Generic Arm" select this if your compiler is already setup to
- optimize things properly, or if you want to run on pretty much
- everything, or you just don't much care.
- - For anything else, pick the ARM core type that best matches the
- cpu you will be using on your device.
-
- If you don't know what to do, choose "Generic Arm".
-
-config CONFIG_GENERIC_ARM
- bool "Generic Arm"
-
-config CONFIG_ARM610
- bool "Arm 610"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM710
- bool "Arm 710"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM7TDMI
- bool "Arm 7TDMI"
- select ARCH_HAS_NO_MMU
-
-config CONFIG_ARM720T
- bool "Arm 720T"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM920T
- bool "Arm 920T"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM922T
- bool "Arm 922T"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM926T
- bool "Arm 926T"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM10T
- bool "Arm 10T"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM1136JF_S
- bool "Arm 1136JF-S"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM1176JZ_S
- bool "Arm 1176JZ-S"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM1176JZF_S
- bool "Arm 1176JZF-S"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM_CORTEX_M3
- bool "Arm Cortex-M3"
- select ARCH_HAS_NO_MMU
- select USE_BX
-
-config CONFIG_ARM_CORTEX_M1
- bool "Arm Cortex-M1"
- select ARCH_HAS_NO_MMU
- select USE_BX
-
-config CONFIG_ARM_SA110
- bool "Intel StrongArm SA-110"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM_SA1100
- bool "Intel StrongArm SA-1100"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM_XSCALE
- bool "Intel Xscale"
- select ARCH_HAS_MMU
-
-config CONFIG_ARM_IWMMXT
- bool "Intel Xscale With WMMX PXA27x"
- select ARCH_HAS_MMU
-
-endchoice
+ Say 'y' to use LDREX/STREX ASM ops.
diff --git a/extra/Configs/Config.avr32 b/extra/Configs/Config.avr32
index 8d70e6e99..5fcd6f216 100644
--- a/extra/Configs/Config.avr32
+++ b/extra/Configs/Config.avr32
@@ -11,11 +11,9 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_BIG_ENDIAN
+ select ARCH_HAS_DEPRECATED_SYSCALLS
select FORCE_SHAREABLE_TEXT_SEGMENTS
-config ARCH_CFLAGS
- string
-
choice
prompt "Target CPU Type"
default CONFIG_AVR32_AP7
diff --git a/extra/Configs/Config.bfin b/extra/Configs/Config.bfin
index d5a9eae80..c3ed1716c 100644
--- a/extra/Configs/Config.bfin
+++ b/extra/Configs/Config.bfin
@@ -12,7 +12,4 @@ config FORCE_OPTIONS_FOR_ARCH
default y
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_NO_MMU
- select UCLIBC_HAS_LFS
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.c6x b/extra/Configs/Config.c6x
new file mode 100644
index 000000000..96adfb398
--- /dev/null
+++ b/extra/Configs/Config.c6x
@@ -0,0 +1,29 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+
+config TARGET_ARCH
+ default "c6x"
+
+config FORCE_OPTIONS_FOR_ARCH
+ bool
+ default y
+ select ARCH_ANY_ENDIAN
+ select ARCH_HAS_NO_MMU
+
+choice
+ prompt "Target Processor Type"
+ default CONFIG_GENERIC_C6X
+
+config CONFIG_GENERIC_C6X
+ bool "Generic C6X DSP"
+
+config CONFIG_TMS320C64X
+ bool "TMS320C64X"
+
+config CONFIG_TMS320C64XPLUS
+ bool "TMS320C64X+"
+
+endchoice
+
diff --git a/extra/Configs/Config.cris b/extra/Configs/Config.cris
index 18c75fb58..c49817f65 100644
--- a/extra/Configs/Config.cris
+++ b/extra/Configs/Config.cris
@@ -11,18 +11,16 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_LITTLE_ENDIAN
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target Architecture Type"
default CONFIG_CRIS
help
- This is the architecture type of your CPU. This information is used for
- optimizing purposes.
+ This is the architecture type of your CPU. This information
+ is used for optimizing purposes.
- These are the possible settings:
+ Possible settings:
- CRIS Generic support for Axis' CRIS architecture.
- CRISv32 Support for Axis' CRISv32 architecture.
diff --git a/extra/Configs/Config.e1 b/extra/Configs/Config.e1
deleted file mode 100644
index 144d9d34d..000000000
--- a/extra/Configs/Config.e1
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see extra/config/Kconfig-language.txt
-#
-
-config TARGET_ARCH
- string
- default "e1"
-
-config FORCE_OPTIONS_FOR_ARCH
- bool
- default y
- select ARCH_BIG_ENDIAN
- select ARCH_HAS_NO_MMU
- select ARCH_HAS_NO_SHARED
-
-config ARCH_E1
- bool
- default y
-
-config ARCH_CFLAGS
- string
- default "-mgnu-param"
diff --git a/extra/Configs/Config.frv b/extra/Configs/Config.frv
index 63bbfed72..d7eeaf90e 100644
--- a/extra/Configs/Config.frv
+++ b/extra/Configs/Config.frv
@@ -13,6 +13,4 @@ config FORCE_OPTIONS_FOR_ARCH
select ARCH_BIG_ENDIAN
select UCLIBC_HAS_FPU
select ARCH_HAS_NO_MMU
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.h8300 b/extra/Configs/Config.h8300
index 262a0d245..0c5486cdc 100644
--- a/extra/Configs/Config.h8300
+++ b/extra/Configs/Config.h8300
@@ -10,8 +10,10 @@ config TARGET_ARCH
config FORCE_OPTIONS_FOR_ARCH
bool
default y
- select ARCH_ANY_ENDIAN
+ select ARCH_BIG_ENDIAN
select ARCH_HAS_NO_MMU
+ select ARCH_HAS_NO_LDSO
+ select HAVE_NO_PIC
choice
prompt "Target Processor"
@@ -26,6 +28,3 @@ config CONFIG_H8S
bool "H8S (edosk2674)"
endchoice
-
-config ARCH_CFLAGS
- string
diff --git a/extra/Configs/Config.hppa b/extra/Configs/Config.hppa
index 1c264a800..938e2e35b 100644
--- a/extra/Configs/Config.hppa
+++ b/extra/Configs/Config.hppa
@@ -15,6 +15,4 @@ config FORCE_OPTIONS_FOR_ARCH
select HAS_NO_THREADS
select ARCH_HAS_NO_LDSO
select HAVE_NO_SSP
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.i386 b/extra/Configs/Config.i386
index 850ab8ea8..c928ac1a2 100644
--- a/extra/Configs/Config.i386
+++ b/extra/Configs/Config.i386
@@ -12,44 +12,17 @@ config FORCE_OPTIONS_FOR_ARCH
default y
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_MMU
+ select ARCH_HAS_UCONTEXT
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target x86 Processor Family"
- default CONFIG_GENERIC_386
+ default CONFIG_686
help
This is the processor type of your CPU. This information is used for
- optimizing purposes. To build a library that will run on all x86 CPU
- types (albeit not optimally fast), you can specify "386" here. If
- you pick anything other than "386", there is no guarantee that uClibc
- will even run on anything other than the selected processor type.
-
- Here are the settings recommended for greatest speed:
- - "Generic 386" select this if your compiler is already setup to
- optimize things properly.
- - "386" for the AMD/Cyrix/Intel 386DX/DXL/SL/SLC/SX, Cyrix/TI
- 486DLC/DLC2, UMC 486SX-S and NexGen Nx586. Only "386" kernels
- will run on a 386 class machine.
- - "486" for the AMD/Cyrix/IBM/Intel 486DX/DX2/DX4 or
- SL/SLC/SLC2/SLC3/SX/SX2 and UMC U5D or U5S.
- - "586" for Intel Pentium and other generic Pentium CPUs
- - "Pentium-MMX" for the Intel Pentium MMX.
- - "Pentium-Pro" for the Intel Pentium Pro/Celeron/Pentium II.
- - "Pentium-III" for the Intel Pentium III
- and Celerons based on the Coppermine core.
- - "Pentium-4" for the Intel Pentium 4.
- - "K6" for the AMD K6, K6-II and K6-III (aka K6-3D).
- - "Athlon" for the AMD K7 family (Athlon/Duron/Thunderbird).
- - "Elan" for the AMD Elan.
- - "Crusoe" for the Transmeta Crusoe series.
- - "Winchip-C6" for original IDT Winchip.
- - "Winchip-2/Winchip-2A/Winchip-3" for IDT Winchip CPUs
- - "CyrixIII/VIA C3" for VIA Cyrix III or VIA C3.
- - "VIA C3-2 Nehemiah" model 9 and above.
-
- If you don't know what to do, choose "386".
-
-config CONFIG_GENERIC_386
- bool "Generic 386"
+ selecting different handcoded optimization functions. Nowadays, most
+ people have an i686 CPU. If you don't, you most likely know what this
+ means and can pick the right one for your processor.
config CONFIG_386
bool "386"
@@ -58,45 +31,9 @@ config CONFIG_486
bool "486"
config CONFIG_586
- bool "Pentium/586/K5/5x86/6x86/6x86MX"
-
-config CONFIG_586MMX
- bool "Pentium-MMX"
+ bool "586"
config CONFIG_686
- bool "Pentium-Pro"
-
-config CONFIG_PENTIUMII
- bool "Celeron/Pentium-II"
-
-config CONFIG_PENTIUMIII
- bool "Pentium-III/Celeron(Coppermine)/Pentium-III Xeon"
-
-config CONFIG_PENTIUM4
- bool "Pentium-4/Celeron(P4-based)/Xeon"
-
-config CONFIG_K6
- bool "K6/K6-II/K6-III"
-
-config CONFIG_K7
- bool "Athlon/Duron/K7"
-
-config CONFIG_ELAN
- bool "Elan"
-
-config CONFIG_CRUSOE
- bool "Crusoe"
-
-config CONFIG_WINCHIPC6
- bool "Winchip-C6"
-
-config CONFIG_WINCHIP2
- bool "Winchip-2/Winchip-2A/Winchip-3"
-
-config CONFIG_CYRIXIII
- bool "CyrixIII/VIA-C3"
-
-config CONFIG_NEHEMIAH
- bool "VIA C3-2 (Nehemiah)"
+ bool "686"
endchoice
diff --git a/extra/Configs/Config.i960 b/extra/Configs/Config.i960
deleted file mode 100644
index cb325c7ea..000000000
--- a/extra/Configs/Config.i960
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see extra/config/Kconfig-language.txt
-#
-
-config TARGET_ARCH
- string
- default "i960"
-
-config FORCE_OPTIONS_FOR_ARCH
- bool
- default y
- select ARCH_LITTLE_ENDIAN
- select ARCH_HAS_NO_MMU
- select HAS_NO_THREADS
-
-config ARCH_CFLAGS
- string
- default "-mh -mint32 -fsigned-char"
diff --git a/extra/Configs/Config.ia64 b/extra/Configs/Config.ia64
index dc13319b3..983b3ee54 100644
--- a/extra/Configs/Config.ia64
+++ b/extra/Configs/Config.ia64
@@ -13,6 +13,4 @@ config FORCE_OPTIONS_FOR_ARCH
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_MMU
select ARCH_HAS_NO_LDSO
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index 4aca400b5..3afc2912d 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -3,16 +3,50 @@
# see extra/config/Kconfig-language.txt
#
-mainmenu "uClibc C Library Configuration"
+mainmenu "uClibc-ng $VERSION C Library Configuration"
+
+config DESIRED_TARGET_ARCH
+ string
+ option env="ARCH"
+
+config VERSION
+ string
+ option env="VERSION"
choice
prompt "Target Architecture"
- help
- Stuff
+ default TARGET_alpha if DESIRED_TARGET_ARCH = "alpha"
+ default TARGET_arc if DESIRED_TARGET_ARCH = "arc"
+ default TARGET_arm if DESIRED_TARGET_ARCH = "arm"
+ default TARGET_avr32 if DESIRED_TARGET_ARCH = "avr32"
+ default TARGET_bfin if DESIRED_TARGET_ARCH = "bfin"
+ default TARGET_cris if DESIRED_TARGET_ARCH = "cris"
+ default TARGET_frv if DESIRED_TARGET_ARCH = "frv"
+ default TARGET_h8300 if DESIRED_TARGET_ARCH = "h8300"
+ default TARGET_hppa if DESIRED_TARGET_ARCH = "hppa"
+ default TARGET_i386 if DESIRED_TARGET_ARCH = "i386"
+ default TARGET_ia64 if DESIRED_TARGET_ARCH = "ia64"
+ default TARGET_lm32 if DESIRED_TARGET_ARCH = "lm32"
+ default TARGET_m68k if DESIRED_TARGET_ARCH = "m68k"
+ default TARGET_metag if DESIRED_TARGET_ARCH = "metag"
+ default TARGET_microblaze if DESIRED_TARGET_ARCH = "microblaze"
+ default TARGET_mips if DESIRED_TARGET_ARCH = "mips"
+ default TARGET_nios2 if DESIRED_TARGET_ARCH = "nios2"
+ default TARGET_or1k if DESIRED_TARGET_ARCH = "or1k"
+ default TARGET_powerpc if DESIRED_TARGET_ARCH = "powerpc"
+ default TARGET_sh if DESIRED_TARGET_ARCH = "sh"
+ default TARGET_sparc if DESIRED_TARGET_ARCH = "sparc"
+ default TARGET_x86_64 if DESIRED_TARGET_ARCH = "x86_64"
+ default TARGET_xtensa if DESIRED_TARGET_ARCH = "xtensa"
+ help
+ The architecture of your target.
config TARGET_alpha
bool "alpha"
+config TARGET_arc
+ bool "arc"
+
config TARGET_arm
bool "arm"
@@ -22,17 +56,19 @@ config TARGET_avr32
config TARGET_bfin
bool "bfin"
+# someone could sync this tree:
+# http://linux-c6x.org/git/?p=uClibc.git;a=summary
+config TARGET_c6x
+ bool "c6x"
+
config TARGET_cris
bool "cris"
-config TARGET_e1
- bool "e1 (BROKEN)"
-
-config TARGET_frv
- bool "frv (BROKEN)"
+#config TARGET_frv
+# bool "frv (BROKEN)"
config TARGET_h8300
- bool "h8300 (BROKEN)"
+ bool "h8300"
config TARGET_hppa
bool "hppa"
@@ -40,45 +76,39 @@ config TARGET_hppa
config TARGET_i386
bool "i386"
-config TARGET_i960
- bool "i960 (BROKEN)"
-
config TARGET_ia64
bool "ia64"
+config TARGET_lm32
+ bool "lm32"
+
config TARGET_m68k
bool "m68k"
+config TARGET_metag
+ bool "metag"
+
config TARGET_microblaze
- bool "microblaze (BROKEN)"
+ bool "microblaze"
config TARGET_mips
bool "mips"
-config TARGET_nios
- bool "nios"
-
config TARGET_nios2
bool "nios2"
+config TARGET_or1k
+ bool "or1k"
+
config TARGET_powerpc
bool "powerpc"
config TARGET_sh
bool "superh"
-config TARGET_sh64
- bool "sh64"
-
config TARGET_sparc
bool "sparc"
-config TARGET_v850
- bool "v850 (BROKEN)"
-
-config TARGET_vax
- bool "vax"
-
config TARGET_x86_64
bool "x86_64"
@@ -110,10 +140,6 @@ if TARGET_cris
source "extra/Configs/Config.cris"
endif
-if TARGET_e1
-source "extra/Configs/Config.e1"
-endif
-
if TARGET_frv
source "extra/Configs/Config.frv"
endif
@@ -130,20 +156,20 @@ if TARGET_i386
source "extra/Configs/Config.i386"
endif
-if TARGET_i960
-source "extra/Configs/Config.i960"
-endif
-
if TARGET_ia64
source "extra/Configs/Config.ia64"
endif
+if TARGET_lm32
+source "extra/Configs/Config.lm32"
+endif
+
if TARGET_m68k
source "extra/Configs/Config.m68k"
endif
-if TARGET_nios
-source "extra/Configs/Config.nios"
+if TARGET_metag
+source "extra/Configs/Config.metag"
endif
if TARGET_nios2
@@ -158,6 +184,10 @@ if TARGET_mips
source "extra/Configs/Config.mips"
endif
+if TARGET_or1k
+source "extra/Configs/Config.or1k"
+endif
+
if TARGET_powerpc
source "extra/Configs/Config.powerpc"
endif
@@ -166,22 +196,10 @@ if TARGET_sh
source "extra/Configs/Config.sh"
endif
-if TARGET_sh64
-source "extra/Configs/Config.sh64"
-endif
-
if TARGET_sparc
source "extra/Configs/Config.sparc"
endif
-if TARGET_v850
-source "extra/Configs/Config.v850"
-endif
-
-if TARGET_vax
-source "extra/Configs/Config.vax"
-endif
-
if TARGET_x86_64
source "extra/Configs/Config.x86_64"
endif
@@ -190,11 +208,25 @@ if TARGET_xtensa
source "extra/Configs/Config.xtensa"
endif
+if TARGET_c6x
+source "extra/Configs/Config.c6x"
+endif
+
+if TARGET_arc
+source "extra/Configs/Config.arc"
+endif
+
config TARGET_SUBARCH
string
default "e500" if CONFIG_E500
default "classic" if CONFIG_CLASSIC
default "sh4" if CONFIG_SH4
+ default "sh4" if CONFIG_SH4A
+ default "" if CONFIG_386
+ default "i486" if CONFIG_486
+ default "i586" if CONFIG_586
+ default "i686" if CONFIG_686
+ default "arcv2" if CONFIG_ARC_CPU_HS
default ""
source "extra/Configs/Config.in.arch"
@@ -205,7 +237,6 @@ menu "General Library Settings"
config HAVE_NO_PIC
bool
- default n
config DOPIC
bool "Generate only Position Independent Code (PIC)"
@@ -217,15 +248,16 @@ config DOPIC
config ARCH_HAS_NO_SHARED
bool
- default n
config ARCH_HAS_NO_LDSO
bool
select ARCH_HAS_NO_SHARED
- default n
+
+config ARCH_HAS_UCONTEXT
+ bool
config HAVE_SHARED
- bool "Enable support for shared libraries"
+ bool "Enable shared libraries"
depends on !ARCH_HAS_NO_SHARED
default y
help
@@ -236,28 +268,29 @@ config HAVE_SHARED
config FORCE_SHAREABLE_TEXT_SEGMENTS
bool "Only load shared libraries which can share their text segment"
depends on HAVE_SHARED
- default n
+ select DOPIC
help
If you answer Y here, the uClibc native shared library loader will
- only load shared libraries, which do not need to modify any non-writable
- segments. These libraries haven't set the DT_TEXTREL tag in the dynamic
- section (==> objdump). All your libraries must be compiled with
- -fPIC or -fpic, and all assembler function must be written as position
- independent code (PIC).
+ only load shared libraries, which do not need to modify any
+ non-writable segments. These libraries haven't set the DT_TEXTREL
+ tag in the dynamic section (==> objdump).
+ All your libraries must be compiled with -fPIC or -fpic, and all
+ assembler function must be written as position independent code (PIC).
Enabling this option will make uClibc's shared library loader a
- little bit smaller and guarantee that no memory will be wasted by badly
- coded shared libraries.
+ little bit smaller and guarantee that no memory will be wasted by
+ badly coded shared libraries.
config LDSO_LDD_SUPPORT
bool "Native 'ldd' support"
depends on HAVE_SHARED
default y
help
- Enable this to enable all the code needed to support traditional ldd,
+ Enable all the code needed to support traditional ldd,
which executes the shared library loader to resolve all dependencies
and then provide a list of shared libraries that are required for an
- application to function. Disabling this option will makes uClibc's
- shared library loader a little bit smaller. Most people will answer Y.
+ application to function. Disabling this option will make uClibc's
+ shared library loader a little bit smaller.
+ Most people will answer Y.
config LDSO_CACHE_SUPPORT
bool "Enable library loader cache (ld.so.conf)"
@@ -269,10 +302,21 @@ config LDSO_CACHE_SUPPORT
After updating this file, it is necessary to run 'ldconfig' to update
the /etc/ld.so.cache shared library loader cache file.
+config LDSO_PRELOAD_ENV_SUPPORT
+ bool "Enable library loader LD_PRELOAD environment"
+ depends on HAVE_SHARED
+ default y
+ help
+ Enable this to make use of LD_PRELOAD environment variable.
+ A whitespace-separated list of additional, user-specified, ELF shared
+ libraries to be loaded before all others. This can be used to
+ selectively override functions in other shared libraries. For
+ set-user-ID/set-group-ID ELF binaries, only libraries in the standard
+ search directories that are also set-user-ID will be loaded.
+
config LDSO_PRELOAD_FILE_SUPPORT
bool "Enable library loader preload file (ld.so.preload)"
depends on HAVE_SHARED
- default n
help
Enable this to make use of /etc/ld.so.preload. This file contains a
whitespace separated list of shared libraries to be loaded before
@@ -295,6 +339,32 @@ config LDSO_BASE_FILENAME
WARNING: Changing the default prefix could cause problems with
binutils' ld !
+config LDSO_STANDALONE_SUPPORT
+ bool "Dynamic linker stand-alone mode support"
+ depends on HAVE_SHARED
+ help
+ The dynamic linker can be run either indirectly through running some
+ dynamically linked program or library (in which case no command line
+ options to the dynamic linker can be passed and, in the ELF case, the
+ dynamic linker which is stored in the .interp section of the program
+ is executed) or directly by running:
+
+ /lib/ld-uClibc.so.* [OPTIONS] [PROGRAM [ARGUMENTS]]
+
+ Stand-alone execution is a prerequisite for adding prelink
+ capabilities to uClibc dynamic linker, as well useful for testing an
+ updated version of the dynamic linker without breaking the system.
+
+config LDSO_PRELINK_SUPPORT
+ bool "Dynamic linker prelink support"
+ depends on HAVE_SHARED
+ select LDSO_STANDALONE_SUPPORT
+ help
+ The dynamic linker can be used in stand-alone mode by the prelink tool
+ for prelinking ELF shared libraries and binaries to speed up startup
+ time. It also is able to load and handle prelinked libraries and
+ binaries at runtime.
+
config UCLIBC_STATIC_LDCONFIG
bool "Link ldconfig statically"
depends on HAVE_SHARED
@@ -303,14 +373,14 @@ config UCLIBC_STATIC_LDCONFIG
Enable this option to statically link the ldconfig binary.
Making ldconfig static can be beneficial if you have a library
- problem and need to use ldconfig to recover. Sometimes, it is
+ problem and need to use ldconfig to recover. Sometimes it is
preferable to instead keep the size of the system down, in which
case you should disable this option.
config LDSO_RUNPATH
bool "Enable ELF RUNPATH tag support"
depends on HAVE_SHARED
- default y
+ default y if LDSO_CACHE_SUPPORT
help
ELF's may have dynamic RPATH/RUNPATH tags. These tags list paths
which extend the library search paths. They are really only useful
@@ -320,8 +390,60 @@ config LDSO_RUNPATH
Usage of RUNPATH tags is not too common, so disabling this feature
should be safe for most people.
+config LDSO_RUNPATH_OF_EXECUTABLE
+ bool "Use executables RUNPATH/RPATH when searching for libraries."
+ depends on LDSO_RUNPATH
+ default n
+ help
+ Use the executables RUNPATH/RPATH to find to find libraries even
+ though this behavour is not standard. Setting this option causes
+ the uclibc dynamic linker behavour to match the glibc dynamic linker.
+
+config LDSO_SAFE_RUNPATH
+ bool "Allow only RUNPATH beginning with /"
+ depends on LDSO_RUNPATH
+ default y
+ help
+ Allow only absolute path in RPATH/RUNPATH.
+
+config LDSO_SEARCH_INTERP_PATH
+ bool "Add ldso path to lib search path"
+ depends on HAVE_SHARED
+ default y
+ help
+ The ldso is told where it is being executed from and can use that
+ path to find related core libraries. This is useful by default,
+ but can be annoying in a mixed development environment.
+
+ i.e. if the ldso is run from /foo/boo/ldso.so, it will start its
+ library search with /foo/boo/
+
+ If unsure, simply say Y here.
+
+config LDSO_LD_LIBRARY_PATH
+ bool "Add LD_LIBRARY_PATH to lib search path"
+ depends on HAVE_SHARED
+ default y
+ help
+ On hardened system it could be useful to disable the use of
+ LD_LIBRARY_PATH environment variable (a colon-separated list of
+ directories in which to search for ELF libraries at execution-time).
+
+ If unsure, simply say Y here.
+
+config LDSO_NO_CLEANUP
+ bool "Disable automatic unloading of dynamically loaded shared objects"
+ depends on HAVE_SHARED
+ help
+ If you need complete allocation traces when debugging memory leaks
+ using Valgrind in a process that dynamically loads shared objects,
+ then answer Y here. Unlike glibc, uClibc unloads all dynamically
+ loaded shared objects when a process exits, which prevents Valgrind
+ from correctly resolving the symbols from the unloaded shared objects.
+ Unless you know you need this, you should answer N.
+
config UCLIBC_CTOR_DTOR
- bool "Support global constructors and destructors"
+ bool
default y
help
If you wish to build uClibc with support for global constructor
@@ -340,39 +462,112 @@ config UCLIBC_CTOR_DTOR
config LDSO_GNU_HASH_SUPPORT
bool "Enable GNU hash style support"
depends on HAVE_SHARED
- default n
help
Newest binutils support a new hash style named GNU-hash. The dynamic
linker will use the new GNU-hash section (.gnu.hash) for symbol lookup
if present into the ELF binaries, otherwise it will use the old SysV
- hash style (.hash). This ensures that it is completely backward compatible.
+ hash style (.hash). This ensures that it is completely backward
+ compatible.
Further, being the hash table implementation self-contained into each
executable and shared libraries, objects with mixed hash style can
peacefully coexist in the same process.
If you want to use this new feature, answer Y
-config HAS_NO_THREADS
- bool
- default n
-
-config UCLIBC_HAS_THREADS
- bool "POSIX Threading support"
- depends on !HAS_NO_THREADS
- default y
- # linuxthreads and linuxthreads.old need nanosleep()
- select UCLIBC_HAS_REALTIME
+choice
+ prompt "Thread support"
+ #default UCLIBC_HAS_THREADS_NATIVE if (TARGET_alpha || TARGET_arm || TARGET_i386 || TARGET_mips || TARGET_powerpc || TARGET_sh || TARGET_sh64)
+ default HAS_NO_THREADS
help
If you want to compile uClibc with pthread support, then answer Y.
This will increase the size of uClibc by adding a bunch of locking
to critical data structures, and adding extra code to ensure that
functions are properly reentrant.
- If your applications require pthreads, answer Y.
+config HAS_NO_THREADS
+ bool "none"
+ help
+ Disable thread support.
+
+config LINUXTHREADS_OLD
+ bool "older (stable) version of linuxthreads"
+ # linuxthreads and linuxthreads.old need nanosleep()
+ select UCLIBC_HAS_REALTIME
+ depends on !TARGET_arc && \
+ !TARGET_arm && \
+ !TARGET_i386 && \
+ !TARGET_metag && \
+ !TARGET_mips && \
+ !TARGET_powerpc && \
+ !TARGET_sparc && \
+ !TARGET_x86_64 && \
+ !TARGET_xtensa || \
+ !ARCH_USE_MMU
+ help
+ There are two versions of linuxthreads. The older (stable) version
+ has been in uClibc for quite a long time but hasn't seen too many
+ updates other than bugfixes.
+
+
+config LINUXTHREADS_NEW
+ bool "slightly newer version of linuxthreads"
+ depends on ARCH_HAS_DEPRECATED_SYSCALLS
+ depends on !TARGET_arc && \
+ !TARGET_arm && \
+ !TARGET_i386 && \
+ !TARGET_metag && \
+ !TARGET_mips && \
+ !TARGET_powerpc && \
+ !TARGET_sh && \
+ !TARGET_sparc && \
+ !TARGET_x86_64 && \
+ !TARGET_xtensa || \
+ !ARCH_USE_MMU
+ help
+ The new version has not been tested much, and lacks ports for arches
+ which glibc does not support (like bfin/frv/etc...), but is based on
+ the latest code from glibc, so it may be the only choice for the
+ newer ports (like alpha/amd64/64bit arches and hppa).
+
+config UCLIBC_HAS_THREADS_NATIVE
+ bool "Native POSIX Threading (NPTL)"
+ select UCLIBC_HAS_TLS
+ select UCLIBC_HAS_STDIO_FUTEXES
+ select UCLIBC_HAS_REALTIME
+ # i386 has no lowlevellock support (yet) as opposed to i486 onward
+ depends on !CONFIG_386 && \
+ !TARGET_alpha && \
+ !TARGET_avr32 && \
+ !TARGET_bfin && \
+ !TARGET_c6x && \
+ !TARGET_cris && \
+ !TARGET_h8300 && \
+ !TARGET_hppa && \
+ !TARGET_ia64 && \
+ !TARGET_m68k && \
+ !TARGET_microblaze && \
+ !TARGET_nios2 && \
+ !TARGET_or1k && \
+ ARCH_USE_MMU
+ help
+ If you want to compile uClibc with NPTL support, then answer Y.
+
+endchoice
+
+config UCLIBC_HAS_THREADS
+ def_bool y if !HAS_NO_THREADS
+
+config UCLIBC_HAS_TLS
+ bool "Thread-Local Storage"
+ depends on UCLIBC_HAS_THREADS_NATIVE
+ help
+ If you want to enable TLS support then answer Y.
+ This is fast an efficient way to store per-thread local data
+ which is not on stack. It needs __thread support enabled in
+ gcc.
config PTHREADS_DEBUG_SUPPORT
bool "Build pthreads debugging support"
- default n
depends on UCLIBC_HAS_THREADS
help
Say Y here if you wish to be able to debug applications that use
@@ -387,19 +582,6 @@ config PTHREADS_DEBUG_SUPPORT
If you are doing development and want to debug applications using
uClibc's pthread library, answer Y. Otherwise, answer N.
-config LINUXTHREADS_OLD
- bool "Use the older (stable) version of linuxthreads"
- default y
- depends on UCLIBC_HAS_THREADS
- help
- There are two versions of linuxthreads. The older (stable) version
- has been in uClibc for quite a long time but hasn't seen too many
- updates other than bugfixes.
-
- The new version has not been tested much, and lacks ports for arches
- which glibc does not support (like bfin/frv/etc...), but is based on
- the latest code from glibc, so it may be the only choice for the
- newer ports (like alpha/amd64/64bit arches and hppa).
config UCLIBC_HAS_SYSLOG
bool "Syslog support"
@@ -423,20 +605,34 @@ choice
prompt "Malloc Implementation"
default MALLOC if ! ARCH_USE_MMU
default MALLOC_STANDARD if ARCH_USE_MMU
+
+config MALLOC
+ bool "malloc"
help
- "malloc" use mmap for all allocations and so works very well on MMU-less
- systems that do not support the brk() system call. It is pretty smart
- about reusing already allocated memory, and minimizing memory wastage.
+ "malloc" use mmap for all allocations and so works very well on
+ MMU-less systems that do not support the brk() system call. It is
+ pretty smart about reusing already allocated memory, and minimizing
+ memory wastage.
This is the default for uClinux MMU-less systems.
- "malloc-simple" was written from scratch for uClibc, and is the
- simplest possible (and therefore smallest) malloc implementation.
- This uses only the mmap() system call to allocation memory, and does
- not use the brk() system call at all, making it a fine choice for
- MMU-less systems with very limited memory. It is rather dumb, and
- certainly isn't the fastest. But it is 100% standards compliant,
- thread safe, and very small.
+config MALLOC_SIMPLE
+ bool "malloc-simple"
+ help
+ "malloc-simple" is trivially simple and slow as molasses. It
+ was written from scratch for uClibc, and is the simplest possible
+ (and therefore smallest) malloc implementation.
+
+ This uses only the mmap() system call to allocate and free memory,
+ and does not use the brk() system call at all, making it a fine
+ choice for MMU-less systems with very limited memory. It's 100%
+ standards compliant, thread safe, very small, and releases freed
+ memory back to the OS immediately rather than keeping it in the
+ process's heap for reallocation. It is also VERY SLOW.
+config MALLOC_STANDARD
+ bool "malloc-standard"
+ depends on ARCH_USE_MMU
+ help
"malloc-standard" is derived from the public domain dlmalloc
implementation by Doug Lea. It is quite fast, and is pretty smart
about reusing already allocated memory, and minimizing memory
@@ -446,21 +642,10 @@ choice
If unsure, answer "malloc-standard".
-config MALLOC
- bool "malloc"
-
-config MALLOC_SIMPLE
- bool "malloc-simple"
-
-config MALLOC_STANDARD
- bool "malloc-standard"
- depends on ARCH_USE_MMU
-
endchoice
config MALLOC_GLIBC_COMPAT
bool "Malloc returns live pointer for malloc(0)"
- default n
help
The behavior of malloc(0) is listed as implementation-defined by
SuSv3. Glibc returns a valid pointer to something, while uClibc
@@ -476,6 +661,15 @@ config MALLOC_GLIBC_COMPAT
does not detect glibc style returning-a-valid-pointer-for-malloc(0)
behavior). Most people can safely answer N.
+config UCLIBC_HAS_OBSTACK
+ bool "Obstack Support (gnu extension)"
+ help
+ When this option is enabled, uClibc will provide support for obstacks.
+ An obstack is a structure in which memory can be dynamically allocated
+ as a 'stack of objects'. Many programs need this GNU extention and
+ you should say Y if you are using any. Otherwise, say N to save some
+ space.
+
config UCLIBC_DYNAMIC_ATEXIT
bool "Dynamic atexit() Support"
default y
@@ -493,45 +687,116 @@ config UCLIBC_DYNAMIC_ATEXIT
config COMPAT_ATEXIT
bool "Old (visible) atexit Support"
- default n
help
- Enable this option if you want to update from 0.9.28 to svn/0.9.29, else
- you will be missing atexit() until you rebuild all apps.
+ Enable this option if you want to update from 0.9.28 to git/0.9.29,
+ else you will be missing atexit() until you rebuild all apps.
+
+config UCLIBC_HAS_UTMPX
+ bool "utmpx based support for tracking login/logouts to/from the system"
+ help
+ Answer y to enable support for accessing user accounting database.
+ It can be used to track all login/logout to the system.
+
+config UCLIBC_HAS_UTMP
+ bool "utmp support (XPG2 compat, SVr4 compat)"
+ depends on UCLIBC_HAS_UTMPX
+ help
+ Answer y to enable legacy SVID support for accessing
+ user accounting database:
+ getutent(), getutid(), getutline(), pututline(),
+ setutent(), endutent(), utmpname() in utmp.h
+ It can be used to track all login/logout to the system.
+
+ If unsure, answer N and use corresponding POSIX functions
+ from utmpx.h
+
+config UCLIBC_SUSV2_LEGACY
+ bool "Enable SuSv2 LEGACY functions"
+ help
+ Enable this option if you want to have SuSv2 LEGACY functions
+ Currently applies to:
+
+ valloc
+
+ WARNING! ABI incompatibility.
config UCLIBC_SUSV3_LEGACY
bool "Enable SuSv3 LEGACY functions"
- default n
+ #vfork,
+ # h_errno
+ # gethostbyaddr
+ # gethostbyname
help
Enable this option if you want to have SuSv3 LEGACY functions
in the library, else they are replaced by SuSv3 proposed macros.
- Currently applies to bcopy/bzero/bcmp/index/rindex/ftime.
+ Currently applies to:
+
+ bcmp, bcopy, bzero, index, rindex, ftime,
+ bsd_signal, (ecvt), (fcvt), gcvt, (getcontext),
+ (getwd), (makecontext),
+ mktemp, (pthread_attr_getstackaddr), (pthread_attr_setstackaddr),
+ scalb, (setcontext), (swapcontext), ualarm, usleep,
+ wcswcs.
+
WARNING! ABI incompatibility.
+config UCLIBC_HAS_CONTEXT_FUNCS
+ bool "Use obsolescent context control functions"
+ depends on UCLIBC_SUSV3_LEGACY && ARCH_HAS_UCONTEXT
+ help
+ Add into library the SuSv3 obsolescent functions used for context
+ control. The setcontext family allows the implementation in C of
+ advanced control flow patterns such as iterators, fibers, and
+ coroutines. They may be viewed as an advanced version of
+ setjmp/longjmp; whereas the latter allows only a single non-local jump
+ up the stack, setcontext allows the creation of multiple cooperative
+ threads of control, each with its own stack.
+ These functions are: setcontext, getcontext, makecontext, swapcontext.
+
config UCLIBC_SUSV3_LEGACY_MACROS
bool "Enable SuSv3 LEGACY macros"
- default n
help
Enable this option if you want to have SuSv3 LEGACY macros.
Currently applies to bcopy/bzero/bcmp/index/rindex et al.
WARNING! ABI incompatibility.
+config UCLIBC_SUSV4_LEGACY
+ bool "Enable SuSv4 LEGACY or obsolescent functions"
+ help
+ Enable this option if you want to have SuSv4 LEGACY functions
+ and macros in the library.
+ Currently applies to:
+
+ - XSI functions:
+ _longjmp, _setjmp, _tolower, _toupper, ftw, getitimer,
+ gettimeofday, isascii, pthread_getconcurrency,
+ pthread_setconcurrency, setitimer, setpgrp, sighold,
+ sigignore, sigpause, sigrelse, sigset, siginterrupt,
+ tempnam, toascii, ulimit.
+
+ - Base functions:
+ asctime, asctime_r, ctime, ctime_r, gets, rand_r,
+ tmpnam, utime.
+
+ WARNING! ABI incompatibility.
+
+config UCLIBC_STRICT_HEADERS
+ bool "Hide structures and constants for unsupported features"
+ help
+ Hide structures and constants in headers that should not be used,
+ because the respective feature is disabled.
+
+ WARNING! enabling this option requires to patch many faulty apps,
+ since they make (wrongly) use of these structures/constants,
+ although the feature was disabled.
+
config UCLIBC_HAS_STUBS
bool "Provide stubs for unavailable functionality"
- default n
help
With this option uClibc provides non-functional stubs for
functions which are impossible to implement on the target
architecture. Otherwise, such functions are simply omitted.
- As of 2008-07, this option makes uClibc provide fork() stub
- on NOMMU targets. It always sets errno to ENOSYS and returns -1.
-
- This may be useful if you port a lot of software and cannot
- audit all of it and replace or disable fork() usage.
- With this option, a program which uses fork() will build
- successfully. Of course, it may be useless if fork()
- is essential for its operation.
-
config UCLIBC_HAS_SHADOW
bool "Shadow Password Support"
default y
@@ -541,7 +806,6 @@ config UCLIBC_HAS_SHADOW
config UCLIBC_HAS_PROGRAM_INVOCATION_NAME
bool "Support for program_invocation_name"
- default n
help
Support for the GNU-specific program_invocation_name and
program_invocation_short_name strings. Some GNU packages
@@ -556,7 +820,6 @@ config UCLIBC_HAS_PROGRAM_INVOCATION_NAME
config UCLIBC_HAS___PROGNAME
bool "Support for __progname"
default y
- depends on UCLIBC_HAS_PROGRAM_INVOCATION_NAME
help
Some packages (like openssh) like to peek into internal libc
symbols to make their output a bit more user friendly.
@@ -602,7 +865,6 @@ config UNIX98PTY_ONLY
if UNIX98PTY_ONLY
config UCLIBC_HAS_GETPT
bool "Support getpt() (glibc-compat)"
- default n
depends on UCLIBC_HAS_PTY
help
Some packages may need getpt().
@@ -619,6 +881,30 @@ config UCLIBC_HAS_GETPT
def_bool y
endif
+config UCLIBC_HAS_LIBUTIL
+ bool "Provide libutil library and functions"
+ depends on UCLIBC_HAS_PTY
+ help
+ Provide a libutil library.
+ This non-standard conforming library provides the following
+ utility functions:
+
+ forkpty(): combines openpty(), fork(2), and login_tty() to
+ create a new process operating in a pseudo-terminal.
+ login(): write utmp and wtmp entries
+ login_tty(): prepares for a login on the tty fd by creating a
+ new session, making fd the controlling terminal for
+ the calling process, setting fd to be the standard
+ input, output, and error streams of the current
+ process, and closing fd.
+ logout(): write utmp and wtmp entries
+ logwtmp(): constructs a utmp structure and calls updwtmp() to
+ append the structure to the utmp file.
+ openpty(): finds an available pseudo-terminal and returns
+ file descriptors for the master and slave
+
+ This library adds about 3k-4k to your system.
+
config UCLIBC_HAS_TM_EXTENSIONS
bool "Support 'struct tm' timezone extension fields"
default y
@@ -658,7 +944,7 @@ config UCLIBC_HAS_TZ_FILE
file consists of a single line (newline required) of text describing
the timezone in the format specified for the TZ environment variable.
- Simply doing 'echo CST6CDT > /etc/TZ' is enough to create a valid file.
+ Doing 'echo CST6CDT > /etc/TZ' is enough to create a valid file.
See
http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap08.html
for details on valid settings of 'TZ'.
@@ -671,10 +957,10 @@ config UCLIBC_HAS_TZ_FILE_READ_MANY
default y
help
Answer Y to enable repeated reading of the '/etc/TZ' file even after
- a valid value has been read. This incurs the overhead of an open/read/close
- for each tzset() call (explicit or implied). However, setting this
- will allows applications to update their timezone information if the contents
- of the file change.
+ a valid value has been read. This incurs the overhead of an
+ open/read/close for each tzset() call (explicit or implied). However,
+ setting this will allow applications to update their timezone
+ information if the contents of the file change.
Most people will answer Y.
@@ -687,6 +973,17 @@ config UCLIBC_TZ_FILE_PATH
Most people will use the default of '/etc/TZ'.
+config UCLIBC_FALLBACK_TO_ETC_LOCALTIME
+ bool "Use /etc/localtime as a fallback"
+ depends on UCLIBC_HAS_TZ_FILE
+ default y
+ help
+ Answer Y to try to use /etc/localtime file.
+ On glibc systems this file (if it is in TZif2 format)
+ contains timezone string at the end.
+
+ Most people will answer Y.
+
endmenu
menu "Advanced Library Settings"
@@ -713,22 +1010,41 @@ config UCLIBC_GRP_BUFFER_SIZE
comment "Support various families of functions"
-config UCLIBC_LINUX_MODULE_24
- bool "Linux kernel module functions"
+config UCLIBC_LINUX_MODULE_26
+ bool "Linux kernel module functions (2.6)"
default y
help
- init_module, create_module, query_module, delete_module
- are used in linux (allegedly prior to 2.6) for loadable
- kernel modules.
+ delete_module, init_module
+ are used in linux for loadable kernel modules.
Say N if you do not use kernel modules.
+config UCLIBC_LINUX_MODULE_24
+ bool "Linux kernel module functions (<2.6)"
+ depends on !TARGET_bfin && !TARGET_c6x
+ help
+ create_module, query_module
+ are used in linux (prior to 2.6) for loadable kernel modules.
+
+ Say N if you do not use kernel modules, or you only support
+ Linux 2.6+.
+
config UCLIBC_LINUX_SPECIFIC
bool "Linux specific functions"
default y
help
- fstatfs(), inotify_*(), ioperm(), iopl(), madvise(), modify_ldt(),
- personality(), ppoll(), setresuid()
+ accept4(), bdflush(),
+ capget(), capset(), eventfd(), fallocate(),
+ fstatfs(), getrandom(), inotify_*(), ioperm(), iopl(),
+ madvise(), modify_ldt(), pipe2(), personality(),
+ prctl()/arch_prctl(), pivot_root(), modify_ldt(),
+ ppoll(), readahead(), reboot(), remap_file_pages(),
+ sched_getaffinity(), sched_setaffinity(), sendfile(),
+ setfsgid(), setfsuid(), setresgid(), setresuid(),
+ splice(), vmsplice(), tee(), signalfd(), statfs(),
+ swapoff(), swapon(), sync_file_range(), syncfs(),
+ _sysctl(), sysinfo(), timerfd_*(), vhangup(), umount(),
+ umount2()
config UCLIBC_HAS_GNU_ERROR
bool "Support GNU extensions for error-reporting"
@@ -761,9 +1077,8 @@ config UCLIBC_HAS_BSD_ERR
config UCLIBC_HAS_OBSOLETE_BSD_SIGNAL
bool "BSD obsolete signal functions"
- default n
help
- These functions are provided as a compatibility interface for
+ These functions are provided as a compatibility interface for
programs that make use of the historical System V signal API.
This API is obsolete:
new applications should use the POSIX signal API (sigaction(2),
@@ -776,7 +1091,6 @@ config UCLIBC_HAS_OBSOLETE_BSD_SIGNAL
config UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL
bool "SYSV obsolete signal functions"
- default n
help
Use of sysv_signal() should be avoided; use sigaction(2) instead.
@@ -784,7 +1098,6 @@ config UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL
config UCLIBC_NTP_LEGACY
bool "ntp_*() aliases"
- default n
help
Provide legacy aliases for ntp functions:
ntp_adjtime(), ntp_gettime()
@@ -793,7 +1106,6 @@ config UCLIBC_NTP_LEGACY
config UCLIBC_SV4_DEPRECATED
bool "Enable SVr4 deprecated functions"
- default n
help
These functions are DEPRECATED in System V release 4.
Say N unless you desparately need one of the functions below:
@@ -803,8 +1115,6 @@ config UCLIBC_SV4_DEPRECATED
config UCLIBC_HAS_REALTIME
bool "Realtime-related family of SUSv functions"
default y
- # glitch in mq_{send,receive} currently forces this on
- select UCLIBC_HAS_ADVANCED_REALTIME
help
These functions are part of the Timers option and need not
be available on all implementations.
@@ -945,6 +1255,20 @@ config UCLIBC_HAS_CRYPT_IMPL
help
libcrypt contains crypt(), setkey() and encrypt()
+config UCLIBC_HAS_SHA256_CRYPT_IMPL
+ bool "libcrypt SHA256 support"
+ depends on UCLIBC_HAS_CRYPT_IMPL
+ help
+ This adds support for SHA256 password hashing via the crypt() function.
+ Say N here if you do not need SHA256 crypt support.
+
+config UCLIBC_HAS_SHA512_CRYPT_IMPL
+ bool "libcrypt SHA512 support"
+ depends on UCLIBC_HAS_CRYPT_IMPL
+ help
+ This adds support for SHA512 password hashing via the crypt() function.
+ Say N here if you do not need SHA512 crypt support.
+
config UCLIBC_HAS_CRYPT_STUB
bool "libcrypt stubs"
default y
@@ -985,7 +1309,6 @@ config UCLIBC_HAS_IPV4
config UCLIBC_HAS_IPV6
bool "IP version 6 support"
- default n
select UCLIBC_HAS_SOCKET
help
If you want to include support for the next version of the Internet
@@ -995,12 +1318,14 @@ config UCLIBC_HAS_IPV6
config UCLIBC_HAS_RPC
bool "Remote Procedure Call (RPC) support"
- default n
+ # RPC+socket-ipvX doesn't currently work.
+ depends on UCLIBC_HAS_IPV4 || UCLIBC_HAS_IPV6
help
If you want to include RPC support, enable this. RPC is rarely used
- for anything except for the NFS filesystem. Unless you plan to use NFS,
- you can probably leave this set to N and save some space. If you need
- to use NFS then you should answer Y.
+ for anything except for the NFS filesystem. Unless you plan to use
+ NFS, you can probably leave this set to N and save some space.
+
+ If you need to use NFS then you should answer Y.
config UCLIBC_HAS_FULL_RPC
bool "Full RPC support"
@@ -1023,7 +1348,6 @@ config UCLIBC_HAS_REENTRANT_RPC
config UCLIBC_USE_NETLINK
bool "Use netlink to query interfaces"
- default n
depends on UCLIBC_HAS_SOCKET
help
In newer versions of Linux (2.4.17+), support was added for querying
@@ -1038,7 +1362,6 @@ config UCLIBC_USE_NETLINK
config UCLIBC_SUPPORT_AI_ADDRCONFIG
bool "Support the AI_ADDRCONFIG flag"
depends on UCLIBC_USE_NETLINK
- default n
help
The implementation of AI_ADDRCONFIG is aligned with the glibc
implementation using netlink to query interfaces to find both
@@ -1049,13 +1372,55 @@ config UCLIBC_SUPPORT_AI_ADDRCONFIG
config UCLIBC_HAS_BSD_RES_CLOSE
bool "Support res_close() (bsd-compat)"
- default n
help
Answer Y if you desperately want to support BSD compatibility in
the network code.
Most people will say N.
+config UCLIBC_HAS_COMPAT_RES_STATE
+ bool "Use compatible but bloated _res"
+ default y
+ help
+ Answer Y if you build network utilities and they muck with resolver
+ internals a lot (_res global structure). uclibc does not use most
+ of _res.XXX fields, and with this option OFF they won't even exist.
+ Which will make e.g. dig build fail.
+ Answering N saves around 400 bytes in bss.
+
+config UCLIBC_HAS_EXTRA_COMPAT_RES_STATE
+ bool "Use extra compatible but extra bloated _res"
+ help
+ Answer Y if selecting UCLIBC_HAS_COMPAT_RES_STATE is not enough.
+ As far as I can say, this should never be needed.
+
+config UCLIBC_HAS_RESOLVER_SUPPORT
+ bool "DNS resolver functions"
+ select UCLIBC_HAS_COMPAT_RES_STATE
+ depends on UCLIBC_HAS_IPV4 || UCLIBC_HAS_IPV6
+ help
+ Provide implementations for DNS resolver functions.
+ In particular, the following functions will be added to the
+ library:
+
+ ns_skiprr, ns_initparse, ns_parserr, ns_msg_getflag,
+ res_mkquery, res_init, res_ninit, res_close, res_nclose
+ res_query, res_search, res_querydomain,
+ dn_expand, dn_comp,
+ ns_name_uncompress, ns_name_ntop, ns_name_pton, ns_name_unpack,
+ ns_name_pack, ns_name_compress, ns_name_skip, dn_skipname,
+ ns_get16, ns_get32, ns_put16, ns_put32
+
+config UCLIBC_HAS_LIBRESOLV_STUB
+ bool "Provide libresolv stub"
+ help
+ Provide a dummy resolv library.
+
+config UCLIBC_HAS_LIBNSL_STUB
+ bool "Provide libnsl stub"
+ help
+ Provide a dummy nsl library.
+
endif
@@ -1086,6 +1451,13 @@ config UCLIBC_HAS_STRING_ARCH_OPT
These are small and fast, the only reason _not_ to say Y here is
for debugging purposes.
+config UCLIBC_HAS_STDIO_FUTEXES
+ bool "Use futexes for multithreaded I/O locking"
+ depends on UCLIBC_HAS_THREADS_NATIVE
+ help
+ If you want to compile uClibc to use futexes for low-level
+ I/O locking, answer Y. Otherwise, answer N.
+
config UCLIBC_HAS_CTYPE_TABLES
bool "Use Table Versions Of 'ctype.h' Functions."
default y
@@ -1114,7 +1486,8 @@ choice
depends on UCLIBC_HAS_CTYPE_TABLES
default UCLIBC_HAS_CTYPE_UNSAFE
help
- Please select the invalid arg behavior you want for the 'ctype' functions.
+ Please select the invalid arg behavior you want for the 'ctype'
+ functions.
The 'ctype' functions are now implemented using table lookups, with
the arg being the index. This can result in incorrect memory accesses
@@ -1137,7 +1510,6 @@ endchoice
config UCLIBC_HAS_WCHAR
bool "Wide Character Support"
- default n
help
Answer Y to enable wide character support. This will make uClibc
much larger. It is also currently required for locale support.
@@ -1148,7 +1520,6 @@ config UCLIBC_HAS_LOCALE
bool "Locale Support"
select UCLIBC_HAS_WCHAR
select UCLIBC_HAS_CTYPE_TABLES
- default n
help
uClibc now has full ANSI/ISO C99 locale support (except for
wcsftime() and collating items in regex). Be aware that enabling
@@ -1165,43 +1536,49 @@ config UCLIBC_HAS_LOCALE
Answer Y to enable locale support. Most people will answer N.
-config UCLIBC_PREGENERATED_LOCALE_DATA
- bool "Use Pre-generated Locale Data"
+choice
+
+prompt "Locale data"
+ depends on UCLIBC_HAS_LOCALE
+ default UCLIBC_BUILD_ALL_LOCALE
+
+config UCLIBC_BUILD_ALL_LOCALE
+ bool "All locales"
depends on UCLIBC_HAS_LOCALE
- default n
help
- If you are selective and only want locale data for a few particular
- locales, or you enjoy pain, or you are a rabid do-it-yourself sort of
- person, you can turn this option off and manually walk through the
- mostly undocumented procedure needed to generate your own locale
- data.
+ This builds all the locales that are available on your
+ host-box.
- Mere mortals will answer Y and use the default set of pregenerated
- locale data, which supports 169 UTF-8 locales, and 144 locales for
- other codesets (for the complete list see extra/locale/LOCALES).
+config UCLIBC_BUILD_MINIMAL_LOCALE
+ bool "Only selected locales"
+ depends on UCLIBC_HAS_LOCALE
+ help
+ If you do not need all locales that are available on your
+ host-box, then set this to 'Y'.
-config UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA
- bool "Automagically Download the Pre-generated Locale Data (if necessary)"
- depends on UCLIBC_PREGENERATED_LOCALE_DATA
- default n
+endchoice
+
+config UCLIBC_BUILD_MINIMAL_LOCALES
+ string "locales to use"
+ depends on UCLIBC_BUILD_MINIMAL_LOCALE
+ default "en_US"
help
- If you would like the build process to use 'wget' to automatically
- download the pregenerated locale data, enable this option. Otherwise
- you will need to obtain the locale data yourself from:
- http://www.uclibc.org/downloads/uClibc-locale-030818.tgz
- and place the uClibc-locale-030818.tgz tarball in the extra/locale/
- directory.
+ Space separated list of locales to use.
- Go ahead and make life easy for yourself... Answer Y.
+ E.g.:
+ en_US en_GB de_AT
+ default:
+ en_US
config UCLIBC_HAS_XLOCALE
bool "Extended Locale Support (experimental/incomplete)"
depends on UCLIBC_HAS_LOCALE
- default n
help
Answer Y to enable extended locale support similar to that provided
- by glibc. This is primarily intended to support libstd++ functionality.
- However, it also allows thread-specific locale selection via uselocale().
+ by glibc. This is primarily intended to support libstd++
+ functionality.
+ However, it also allows thread-specific locale selection via
+ uselocale().
Most people will answer N.
@@ -1209,7 +1586,6 @@ config UCLIBC_HAS_HEXADECIMAL_FLOATS
bool "Support hexadecimal float notation"
depends on UCLIBC_HAS_CTYPE_TABLES
depends on UCLIBC_HAS_FLOATS
- default n
help
Answer Y to enable support for hexadecimal float notation in the
(wchar and) char string to floating point conversion functions, as
@@ -1222,11 +1598,11 @@ config UCLIBC_HAS_GLIBC_DIGIT_GROUPING
bool "Support glibc's \"'\" flag for allowing locale-specific digit grouping"
depends on UCLIBC_HAS_LOCALE
depends on UCLIBC_HAS_FLOATS
- default n
help
- Answer Y to enable support for glibc's \"'\" flag for allowing locale-specific
- digit grouping in base 10 integer conversions and appropriate floating point
- conversions in the *printf() and *scanf() functions.
+ Answer Y to enable support for glibc's \"'\" flag for allowing
+ locale-specific digit grouping in base 10 integer conversions and
+ appropriate floating point conversions in the *printf() and *scanf()
+ functions.
Most people will answer N.
@@ -1235,23 +1611,24 @@ config UCLIBC_HAS_SCANF_LENIENT_DIGIT_GROUPING
depends on UCLIBC_HAS_GLIBC_DIGIT_GROUPING
default y
help
- Answer Y to make digit grouping optional when the \"'\" flag is specified.
+ Answer Y to make digit grouping optional when the \"'\" flag is
+ specified.
This is the standard glibc behavior. If the initial string of digits
- exceeds the maximum group number, the input will be treated as a normal
- non-grouped number.
+ exceeds the maximum group number, the input will be treated as a
+ normal non-grouped number.
Most people will answer N.
config UCLIBC_HAS_GLIBC_CUSTOM_PRINTF
bool "Support glibc's register_printf_function() (glibc-compat)"
depends on !USE_OLD_VFPRINTF
- default n
help
Answer Y to support glibc's register_printf_function() to allow an
application to add its own printf conversion specifiers.
+ parse_printf_format() is also enabled.
- NOTE: This implementation limits the number or registered specifiers to 10.
- NOTE: This implementation requires new conversion specifiers to be ASCII
+ NOTE: Limits the number or registered specifiers to 10.
+ NOTE: Requires new conversion specifiers to be ASCII
characters (0-0x7f). This is to avoid problems with processing
format strings in locales with different multibyte conversions.
@@ -1260,11 +1637,11 @@ config UCLIBC_HAS_GLIBC_CUSTOM_PRINTF
config USE_OLD_VFPRINTF
bool "Use the old vfprintf implementation"
depends on !UCLIBC_HAS_WCHAR
- default n
help
- Set to true to use the old vfprintf instead of the new. This is roughly
- C89 compliant with some extensions, and is much smaller. However, it does
- not support wide chars, positional args, or glibc custom printf specifiers.
+ Set to true to use the old vfprintf instead of the new. This is
+ roughly C89 compliant with some extensions, and is much smaller.
+ However, it does not support wide chars, positional args, or glibc
+ custom printf specifiers.
Most people will answer N.
@@ -1273,28 +1650,17 @@ config UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS
depends on !USE_OLD_VFPRINTF
default 9
help
- Set the maximum number of positional args supported by the printf/scanf
- functions. The Single Unix Specification Version 3 requires a minimum
- value of 9. Setting this to a value lower than 9 will disable positional
- arg support and cause the NL_ARGMAX macro in limits.h to be #undef'd.
- WARNING! The workspace to support positional args is currently allocated
- on the stack. You probably don't want to set this to too high a value.
-
- Most people will answer 9.
-
-
-config UCLIBC_HAS_SCANF_GLIBC_A_FLAG
- bool "Support glibc's 'a' flag for scanf string conversions (not implemented)"
- default n
- help
- NOTE!!! Currently Not Implemented!!! Just A Place Holder!! NOTE!!!
- NOTE!!! Conflicts with an ANSI/ISO C99 scanf flag!! NOTE!!!
+ Set the maximum number of positional args supported by the
+ printf/scanf functions. The Single Unix Specification Version 3
+ requires a minimum value of 9. Setting this to a value lower than
+ 9 will disable positional arg support and cause the NL_ARGMAX macro
+ in limits.h to be #undef'd.
- Answer Y to enable support for glibc's 'a' flag for the scanf string
- conversions '%s', '%[', '%ls', '%l[', and '%S'. This is used to
- auto-allocate sufficient memory to hold the data retrieved.
+ WARNING! The workspace to support positional args is currently
+ allocated on the stack. You probably don't want to set
+ this to too high a value.
- Most people will answer N.
+ Most people will answer 9.
choice
prompt "Stdio buffer size"
@@ -1363,11 +1729,11 @@ endchoice
config UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT
bool "Attempt to shutdown stdio subsystem when abort() is called."
- default n
help
- ANSI/ISO C99 requires abort() to be asyn-signal-safe. So there was a behavioral
- change made in SUSv3. Previously, abort() was required to have the affect of
- fclose() on all open streams. The wording has been changed to "may" from "shall".
+ ANSI/ISO C99 requires abort() to be asyn-signal-safe. So there was
+ a behavioral change made in SUSv3. Previously, abort() was required
+ to have the affect of fclose() on all open streams. The wording has
+ been changed to "may" from "shall".
Most people will answer N.
@@ -1394,22 +1760,23 @@ config UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION
default y
help
Answer Y to enable the stdio subsystem to automaticly transition
- between reading and writing. This relaxes the ANSI/ISO C99 requirement:
-
- When a file is opened with update mode ('+' as the second or third character
- in the list of mode argument values), both input and output may be performed
- on the associated stream. However, output shall not be directly followed by
- input without an intervening call to the fflush function or to a file
- positioning function (fseek, fsetpos, or rewind), and input shall not be
- directly followed by output without an intervening call to a file positioning
- function, unless the input operation encounters end­of­file.
+ between reading and writing. This relaxes the ANSI/ISO C99
+ requirement:
+
+ When a file is opened with update mode ('+' as the second or third
+ character in the list of mode argument values), both input and output
+ may be performed on the associated stream. However, output shall not
+ be directly followed by input without an intervening call to the
+ fflush function or to a file positioning function (fseek, fsetpos,
+ or rewind), and input shall not be directly followed by output without
+ an intervening call to a file positioning function, unless the input
+ operation encounters end­of­file.
Most people will answer Y.
config UCLIBC_HAS_FOPEN_LARGEFILE_MODE
bool "Support an fopen() 'F' flag for large file mode (uClibc-specific)"
depends on UCLIBC_HAS_LFS
- default n
help
Answer Y to enable a uClibc-specific extension to allow passing an
additional 'F' flag in the mode string for fopen() to specify that
@@ -1419,7 +1786,6 @@ config UCLIBC_HAS_FOPEN_LARGEFILE_MODE
config UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE
bool "Support an fopen() 'x' flag for exclusive mode (glibc-compat)"
- default n
help
Answer Y to support a glibc extension to allow passing
additional 'x' flag in the mode string for fopen() to specify that
@@ -1427,9 +1793,17 @@ config UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE
Most people will answer N.
+config UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE
+ bool "Support an fopen() 'e' flag for close-on-exec mode (glibc-compat)"
+ help
+ Answer Y to support a glibc extension to allow passing
+ additional 'e' flag in the mode string for fopen() to specify that
+ the file should be open()ed with the O_CLOEXEC flag set.
+
+ Most people will answer N.
+
config UCLIBC_HAS_GLIBC_CUSTOM_STREAMS
bool "Support fmemopen(), open_memstream(), and fopencookie() (glibc-compat)"
- default n
help
Answer Y to support the glibc 'custom stream' extension functions
fmemopen(), open_memstream(), and fopencookie().
@@ -1440,11 +1814,11 @@ config UCLIBC_HAS_GLIBC_CUSTOM_STREAMS
config UCLIBC_HAS_PRINTF_M_SPEC
bool "Support the '%m' specifier in printf format strings (glibc-compat)"
- default n
help
Answer Y to support a glibc extension to interpret '%m' in printf
format strings as an instruction to output the error message string
- (as generated by strerror) corresponding to the current value of 'errno'.
+ (as generated by strerror) corresponding to the current value of
+ 'errno'.
Most people will answer N.
@@ -1461,14 +1835,14 @@ config UCLIBC_HAS_ERRNO_MESSAGES
config UCLIBC_HAS_SYS_ERRLIST
bool "Support sys_errlist[] (obsolete-compat)"
depends on UCLIBC_HAS_ERRNO_MESSAGES
- default n
help
Answer Y if you want to support the obsolete sys_errlist[].
This adds about 0.5k to the library, except for the mips
arch where it adds over 4K.
WARNING! In the future, support for sys_errlist[] may be unavailable
- in at least some configurations. In fact, it may be removed altogether.
+ in at least some configurations. In fact, it may be removed
+ altogether.
Most people will answer N.
@@ -1487,19 +1861,18 @@ config UCLIBC_HAS_SIGNUM_MESSAGES
config UCLIBC_HAS_SYS_SIGLIST
bool "Support sys_siglist[] (bsd-compat)"
depends on UCLIBC_HAS_SIGNUM_MESSAGES
- default n
help
Answer Y if you want to support sys_siglist[].
WARNING! In the future, support for sys_siglist[] may be unavailable
- in at least some configurations. In fact, it may be removed altogether.
+ in at least some configurations. In fact, it may be removed
+ altogether.
Most people will answer N.
config UCLIBC_HAS_GETTEXT_AWARENESS
bool "Include gettext awareness"
depends on UCLIBC_HAS_LOCALE && UCLIBC_MJN3_ONLY
- default n
help
NOTE!!! Not yet integrated with strerror and strsignal. NOTE!!!
@@ -1517,27 +1890,44 @@ config UCLIBC_HAS_GNU_GETOPT
help
Answer Y if you want to include full gnu getopt() instead of a
(much smaller) SUSv3 compatible getopt().
+ Note that getopt_long, getopt_long_only as well as getsubopt
+ are implemented on top of this choice.
Most people will answer Y.
config UCLIBC_HAS_GETOPT_LONG
- bool "Support getopt_long/getopt_long_only"
- depends on !UCLIBC_HAS_GNU_GETOPT
+ bool "Support getopt_long/getopt_long_only (glibc-compat)"
default y
help
- Answer Y if you want to include getopt_long[_only() used by many
- apps, even busybox.
+ Answer Y if you want to include getopt_long[_only()] used by many
+ apps.
Most people will answer Y.
config UCLIBC_HAS_GNU_GETSUBOPT
- bool "Support glibc getsubopt"
+ bool "Support getsubopt"
default y
help
- Answer Y if you want to include glibc getsubopt() instead of a
- smaller SUSv3 compatible getsubopt().
+ Answer Y if you want to include getsubopt().
Most people will answer Y.
+
+config UCLIBC_HAS_ARGP
+ bool "Support argp (as standalone shared object)"
+ default n
+ help
+ Argp is an interface for parsing unix-style argument vectors. Unlike
+ the common getopt interface, it provides many advanced features in
+ addition to parsing options, such as automatic output in response to
+ `--help' and `--version' options.
+ A library can export an argp option parser, which programs can easily
+ use in conjunction with their own option parser.
+ A new shared object "libuargp" is created. The "libc.so" linker script
+ contains the AS_NEEDED entry for getting the libuargp linked automatically.
+ Argp support is needed by elfutils libdw.
+
+ Most people can safely answer N.
+
endmenu
@@ -1591,7 +1981,6 @@ config UCLIBC_HAS_FNMATCH_OLD
config UCLIBC_HAS_WORDEXP
bool "Support the wordexp() interface"
depends on UCLIBC_HAS_GLOB
- default n
help
The SuSv3 wordexp() interface performs word expansions per the Shell
and Utilities volume of IEEE Std 1003.1-2001, Section 2.6. It is
@@ -1601,15 +1990,36 @@ config UCLIBC_HAS_WORDEXP
This interface is rarely used, and very large. Unless you have a
pressing need for wordexp(), you should probably answer N.
+config UCLIBC_HAS_NFTW
+ bool "Support the nftw() interface"
+ help
+ The SuSv3 nftw() interface is used to recursively descend
+ directory paths while repeatedly calling a function.
+
+ This interface is rarely used, and adds around 4.5k. Unless you have
+ a pressing need for nftw(), you should probably answer N.
+
config UCLIBC_HAS_FTW
- bool "Support the ftw() and nftw() interfaces"
- default n
+ bool "Support the ftw() interface (SUSv4-obsolete)"
+ depends on UCLIBC_SUSV4_LEGACY
help
- The SuSv3 ftw() and nftw() interfaces are used to recursively descend
+ The SuSv3 ftw() interface is used to recursively descend
directory paths while repeatedly calling a function.
This interface is rarely used, and adds around 4.5k. Unless you have
- a pressing need for ftw() or nftw(), you should probably answer N.
+ a pressing need for ftw(), you should probably answer N.
+
+config UCLIBC_HAS_FTS
+ bool "Support the fts() interface (bsd-compat)"
+ help
+ The fts functions are provided for traversing UNIX file hierarchies.
+
+ This interface is currently used by the elfutils and adds
+ around 7.5k.
+ You should port your application to use the POSIX nftw()
+ interface.
+
+ Unless you need to build/use elfutils, you should prolly answer N.
config UCLIBC_HAS_GLOB
bool "Support the glob() interface"
@@ -1626,14 +2036,13 @@ config UCLIBC_HAS_GLOB
config UCLIBC_HAS_GNU_GLOB
bool "Support gnu glob() interface"
depends on UCLIBC_HAS_GLOB
- default n
help
- The gnu glob interface is somewhat larger (weighing in at about 4,2k) than
- it's SuSv3 counterpart (and is out of date). It is an old copy from glibc and
- does not support all the GNU specific options.
+ The gnu glob interface is somewhat larger (weighing in at about 4,2k)
+ than it's SuSv3 counterpart (and is out of date). It is an old copy
+ from glibc and does not support all the GNU specific options.
- Answer Y if you want to include full gnu glob() instead of the smaller SUSv3
- compatible glob().
+ Answer Y if you want to include full gnu glob() instead of the smaller
+ SUSv3 compatible glob().
Most people will answer N.
@@ -1644,23 +2053,6 @@ endmenu
menu "Library Installation Options"
-config SHARED_LIB_LOADER_PREFIX
- string "Shared library loader path"
- depends on HAVE_SHARED
- default "$(RUNTIME_PREFIX)lib"
- help
- When using shared libraries, this path is the location where the
- shared library will be invoked. This value will be compiled into
- every binary compiled with uClibc.
-
- For a typical target system this should be set to "/lib", such that
- 'make install' will install /lib/ld-uClibc.so.0.
-
- BIG FAT WARNING:
- If you do not have a shared library loader with the correct name
- sitting in the directory this points to, your binaries will not
- run.
-
config RUNTIME_PREFIX
string "uClibc runtime library directory"
default "/usr/$(TARGET_ARCH)-linux-uclibc/"
@@ -1695,6 +2087,39 @@ config DEVEL_PREFIX
For a typical target system this should be set to "/usr", such that
'make install' will install /usr/include/<header files>.
+config MULTILIB_DIR
+ string "library path component"
+ default "lib"
+ help
+ Path component where libraries reside.
+
+ For a typical target system this should be set to "lib", such that
+ 'make install' will install libraries to "/lib" and "/usr/lib"
+ respectively
+ DEVEL_PREFIX/MULTILIB_DIR
+ RUNTIME_PREFIX/MULTILIB_DIR
+
+ Other settings may include "lib32" or "lib64".
+
+config HARDWIRED_ABSPATH
+ bool "Hardwire absolute paths into linker scripts"
+ default y
+ help
+ This prepends absolute paths to the libraries mentioned in linker
+ scripts such as libc.so.
+
+ This is a build time optimization. It has no impact on dynamic
+ linking at runtime, which doesn't use linker scripts.
+
+ You must disable this to use uClibc with old non-sysroot toolchains,
+ such as the prebuilt binary cross compilers at:
+ http://uclibc.org/downloads/binaries
+
+ The amount of time saved by this optimization is actually too small to
+ measure. The linker just had to search the library path to find the
+ linker script, so the dentries are cache hot if it has to search the
+ same path again. But it's what glibc does, so we do it too.
+
endmenu
@@ -1705,18 +2130,20 @@ config UCLIBC_BUILD_PIE
depends on HAVE_SHARED
depends on TARGET_arm || TARGET_frv || TARGET_i386 || TARGET_mips || TARGET_powerpc
select FORCE_SHAREABLE_TEXT_SEGMENTS
- default n
help
- If you answer Y here, ldd and iconv are built as ET_DYN/PIE executables.
+ If you answer Y here, ldd and iconv are built as ET_DYN/PIE
+ executables.
+
It requires gcc-3.4 and binutils-2.15 (for arm 2.16) or later.
More about ET_DYN/PIE binaries on <http://pax.grsecurity.net/> .
- WARNING: This option also enables FORCE_SHAREABLE_TEXT_SEGMENTS, so all
- libraries have to be built with -fPIC or -fpic, and all assembler
- functions must be written as position independent code (PIC).
+
+ WARNING: This option also enables FORCE_SHAREABLE_TEXT_SEGMENTS, so
+ all libraries have to be built with -fPIC or -fpic, and all
+ assembler functions must be written as position independent
+ code (PIC).
config UCLIBC_HAS_ARC4RANDOM
bool "Include the arc4random() function"
- default n
help
Answer Y to support the OpenBSD-like arc4random() function. This
function picks a random number between 0 and N, and will always return
@@ -1727,14 +2154,22 @@ config UCLIBC_HAS_ARC4RANDOM
Most people will answer N.
+config ARC4RANDOM_USES_NODEV
+ bool "Do not use /dev/urandom with arc4random()"
+ depends on UCLIBC_HAS_ARC4RANDOM
+ help
+ Answer Y to use gettimeofday(2) and getpid(2) exclusively for
+ arc4random(). This is not a bad idea for a diskless system, but
+ it uses a lot of syscalls to stir each array element.
+
+ Most people will answer N.
+
config HAVE_NO_SSP
bool
- default n
config UCLIBC_HAS_SSP
bool "Support for GCC stack smashing protector"
depends on !HAVE_NO_SSP
- default n
help
Add code to support GCC's -fstack-protector[-all] option to uClibc.
This requires GCC 4.1 or newer. GCC does not have to provide libssp,
@@ -1755,7 +2190,6 @@ config UCLIBC_HAS_SSP
config UCLIBC_HAS_SSP_COMPAT
bool "Support for gcc-3.x propolice smashing stack protector"
depends on UCLIBC_HAS_SSP
- default n
help
Add gcc-3.x propolice smashing stack protector to the library.
@@ -1772,7 +2206,6 @@ config UCLIBC_HAS_SSP_COMPAT
config SSP_QUICK_CANARY
bool "Use simple guard values without accessing /dev/urandom"
depends on UCLIBC_HAS_SSP
- default n
help
Use gettimeofday(2) to define the __guard without accessing
/dev/urandom.
@@ -1783,8 +2216,8 @@ config SSP_QUICK_CANARY
choice
prompt "Propolice protection blocking signal"
depends on UCLIBC_HAS_SSP
- default PROPOLICE_BLOCK_ABRT if ! DODEBUG
- default PROPOLICE_BLOCK_SEGV if DODEBUG
+ depends on DODEBUG
+ default PROPOLICE_BLOCK_SEGV
help
"abort" use SIGABRT to block offending programs.
This is the default implementation.
@@ -1805,7 +2238,6 @@ endchoice
config UCLIBC_BUILD_SSP
bool "Build uClibc with -fstack-protector"
depends on UCLIBC_HAS_SSP
- default n
help
Build all uClibc libraries and executables with -fstack-protector,
adding extra stack overflow checking to most uClibc functions.
@@ -1835,7 +2267,6 @@ config UCLIBC_BUILD_RELRO
config UCLIBC_BUILD_NOW
bool "Build uClibc with linker option -z NOW"
depends on HAVE_SHARED
- default n
help
Build all libraries and executables with "ld -z now".
@@ -1874,7 +2305,7 @@ config UCLIBC_BUILD_NOEXECSTACK
endmenu
-menu "uClibc development/debugging options"
+menu "Development/debugging options"
config CROSS_COMPILER_PREFIX
string "Cross-compiling toolchain prefix"
@@ -1885,14 +2316,13 @@ config CROSS_COMPILER_PREFIX
then enter 'arm-linux-uclibc-' here.
config UCLIBC_EXTRA_CFLAGS
- string "Enter any extra CFLAGS to use to build uClibc"
+ string "Extra CFLAGS"
default ""
help
Add any additional CFLAGS to be used to build uClibc.
config DODEBUG
- bool "Build uClibc with debugging symbols"
- default n
+ bool "Enable debugging symbols"
select EXTRA_WARNINGS
help
Say Y here if you wish to compile uClibc with debugging symbols.
@@ -1906,7 +2336,6 @@ config DODEBUG
config DODEBUG_PT
bool "Build pthread with debugging output"
depends on UCLIBC_HAS_THREADS && LINUXTHREADS_OLD
- default n
help
Enable debug output in libpthread. This is only useful when doing
development in libpthread itself.
@@ -1924,8 +2353,7 @@ config DOSTRIP
Most people will answer Y.
config DOASSERTS
- bool "Build uClibc with run-time assertion testing"
- default n
+ bool "Build with run-time assertion testing"
help
Say Y here to include runtime assertion tests.
This enables runtime assertion testing in some code, which can
@@ -1935,7 +2363,6 @@ config DOASSERTS
config SUPPORT_LD_DEBUG
bool "Build the shared library loader with debugging support"
depends on HAVE_SHARED
- default n
help
Answer Y here to enable all the extra code needed to debug the uClibc
native shared library loader. The level of debugging noise that is
@@ -1948,9 +2375,11 @@ config SUPPORT_LD_DEBUG
detail provide more information for some options
move display copy processing
symbols display symbol table processing
- reloc display relocation processing; detail shows the relocation patch
+ reloc display relocation processing; detail shows the
+ relocation patch
nofixups never fixes up jump relocations
- bindings displays the resolve processing (function calls); detail shows the relocation patch
+ bindings displays the resolve processing (function calls);
+ detail shows the relocation patch
all Enable everything!
The additional environment variable:
@@ -1969,7 +2398,6 @@ config SUPPORT_LD_DEBUG
config SUPPORT_LD_DEBUG_EARLY
bool "Build the shared library loader with early debugging support"
depends on HAVE_SHARED
- default n
help
Answer Y here to if you find the uClibc shared library loader is
crashing or otherwise not working very early on. This is typical
@@ -1983,37 +2411,55 @@ config SUPPORT_LD_DEBUG_EARLY
config UCLIBC_MALLOC_DEBUGGING
bool "Build malloc with debugging support"
depends on MALLOC || MALLOC_STANDARD
- default n
+ select DOASSERTS
help
Answer Y here to compile extra debugging support code into malloc.
Malloc debugging output may then be enabled at runtime using the
MALLOC_DEBUG environment variable.
- The value of MALLOC_DEBUG should be an integer, which is interpreted as
- a bitmask with the following bits:
+ The value of MALLOC_DEBUG should be an integer, which is interpreted
+ as a bitmask with the following bits:
1 - do extra consistency checking
- 2 - output messages for malloc/free calls and OS allocation calls
+ 2 - output messages for malloc/free calls and OS
+ allocation calls
4 - output messages for the `MMB' layer
- 8 - output messages for internal malloc heap manipulation calls
+ 8 - output messages for internal malloc heap manipulation
+ calls
Because this increases the size of malloc appreciably (due to strings
etc), you should say N unless you need to debug a malloc problem.
+config UCLIBC_HAS_BACKTRACE
+ bool "Add support for application self-debugging"
+ depends on HAVE_SHARED
+ help
+ Answer Y here to compile support for application self-debugging, by adding
+ a new shared object "libubacktrace.so" that provides the following new
+ functions:
+ backtrace, backtrace_symbols, backtrace_symbols_fd
+
+ The backtrace functionality is currently supported on SH platform, and it
+ based on dwarf2 informations to properly work, so any application that
+ want to use backtrace needs to be built with -fexceptions flag.
+
+ The symbol names may be unavailable without the use of special linker
+ options. For systems using the GNU linker, it is necessary to use the
+ -rdynamic linker option too. Note that names of "static" functions are not
+ exposed, and won't be available in the backtrace.
+
config WARNINGS
string "Compiler Warnings"
default "-Wall"
help
- Set this to the set of gcc warnings you wish to see while compiling.
+ Set this to the set of compiler warnings you wish to see while compiling.
config EXTRA_WARNINGS
bool "Enable extra annoying warnings"
- default n
help
If you wish to build with extra warnings enabled, say Y here.
config DOMULTI
bool "Compile all sources at once into an object"
- default n
help
Set this to compile all sources at once into an object (IMA).
This mode of compilation uses alot of memory but may produce
@@ -2024,12 +2470,4 @@ config DOMULTI
If unsure, keep the default of N.
-config UCLIBC_MJN3_ONLY
- bool "Manuel's hidden warnings"
- default n
- help
- Answer Y here to see all Manuel's personal notes, warnings, and todos.
-
- Most people will answer N.
-
endmenu
diff --git a/extra/Configs/Config.in.arch b/extra/Configs/Config.in.arch
index 2a912a109..92f45d969 100644
--- a/extra/Configs/Config.in.arch
+++ b/extra/Configs/Config.in.arch
@@ -10,23 +10,25 @@
if !ARCH_USE_MMU
choice
prompt "Target File Format"
-config UCLIBC_FORMAT_ELF
- bool "ELF"
- depends on ARCH_USE_MMU
config UCLIBC_FORMAT_FDPIC_ELF
bool "FDPIC ELF"
- depends on !ARCH_USE_MMU
+ depends on !ARCH_USE_MMU && (TARGET_bfin || TARGET_frv)
+ select DOPIC
+config UCLIBC_FORMAT_DSBT_ELF
+ bool "DBST ELF"
+ depends on !ARCH_USE_MMU && TARGET_c6x
+ select DOPIC
config UCLIBC_FORMAT_FLAT
bool "STATIC FLAT"
- depends on !ARCH_USE_MMU
+ depends on !ARCH_USE_MMU && !TARGET_frv
select ARCH_HAS_NO_LDSO
config UCLIBC_FORMAT_FLAT_SEP_DATA
bool "STATIC FLAT (sep-data)"
- depends on !ARCH_USE_MMU
+ depends on !ARCH_USE_MMU && !TARGET_frv
select ARCH_HAS_NO_LDSO
config UCLIBC_FORMAT_SHARED_FLAT
bool "SHARED FLAT"
- depends on !ARCH_USE_MMU
+ depends on !ARCH_USE_MMU && !TARGET_frv
select ARCH_HAS_NO_LDSO
help
Pick this one if you are using uClinux and wish to build
@@ -37,6 +39,14 @@ if ARCH_USE_MMU
comment "Using ELF file format"
endif
+config ARCH_HAS_DEPRECATED_SYSCALLS
+ bool
+ help
+ New architectures do not support deprecated system calls. However,
+ these system calls are needed to build linuxthreads (old and new) so
+ this symbol controls whether there is support for these threading libraries
+ or not.
+
config UCLIBC_SHARED_FLAT_ID
int "Shared library ID"
default 1
@@ -128,7 +138,6 @@ config UCLIBC_HAS_FLOATS
config UCLIBC_HAS_FPU
bool "Target CPU has a floating point unit (FPU)"
- depends on UCLIBC_HAS_FLOATS
default y
help
If your target CPU does not have a Floating Point Unit (FPU) or a
@@ -148,7 +157,6 @@ config UCLIBC_HAS_SOFT_FLOAT
config DO_C99_MATH
bool "Enable full C99 math library support"
depends on UCLIBC_HAS_FLOATS
- default n
help
If you want the uClibc math library to contain the full set C99
math library features, then answer Y. If you leave this set to
@@ -159,18 +167,40 @@ config DO_C99_MATH
If your applications require the newer C99 math library functions,
then answer Y.
+config DO_XSI_MATH
+ bool "Enable XSI math extensions to the ISO C standard (bessel)"
+ depends on UCLIBC_HAS_FLOATS
+ help
+ X/Open System Interfaces extensions to ISO C math functions
+ (differential equation functions):
+
+ j0, j1, jn - Bessel functions of the first kind
+ y0, y1, yn - Bessel functions of the second kind
+
config UCLIBC_HAS_FENV
bool "Enable C99 Floating-point environment"
depends on UCLIBC_HAS_FLOATS
- default n
help
If you want the uClibc math library to contain the C99 floating
point environment, rounding and exception handling functions then
say Y here.
+ NOTE: Supported architectures currently include:
+ i386
+
+config UCLIBC_HAS_LONG_DOUBLE_MATH
+ bool "Enable long double support"
+ depends on DO_C99_MATH
+ depends on TARGET_aarch64 || TARGET_alpha || TARGET_i386 || TARGET_ia64 || TARGET_m68k || TARGET_powerpc || TARGET_s390 || TARGET_sparc || TARGET_tile || TARGET_x86_64
+ default y
+ help
+ If you want the uClibc math library to contain the full set of C99
+ long double math library features, then answer Y. Don't enable it
+ for sparc w/ 32bit ABI.
+
config KERNEL_HEADERS
string "Linux kernel header location"
- default "/usr/include"
+ default ""
help
The kernel source you use to compile with should be the same
as the Linux kernel you run your apps on. uClibc doesn't even
@@ -181,12 +211,9 @@ config KERNEL_HEADERS
but then run on Linux 2.0.x, lchown will be compiled into uClibc,
but won't work at all. You have been warned.
-config UCLIBC_UCLINUX_BROKEN_MUNMAP
- bool
- depends on !ARCH_USE_MMU
- default y
+ If you don't set this, we'll assume the toolchain can find them.
-config EXCLUDE_BRK
+config UCLIBC_UCLINUX_BROKEN_MUNMAP
bool
depends on !ARCH_USE_MMU
default y
diff --git a/extra/Configs/Config.v850 b/extra/Configs/Config.lm32
index a668bba7c..807726702 100644
--- a/extra/Configs/Config.v850
+++ b/extra/Configs/Config.lm32
@@ -5,18 +5,13 @@
config TARGET_ARCH
string
- default "v850"
+ default "lm32"
config FORCE_OPTIONS_FOR_ARCH
bool
default y
- select ARCH_LITTLE_ENDIAN
+ select ARCH_BIG_ENDIAN
select ARCH_HAS_NO_MMU
+ select ARCH_HAS_NO_LDSO
select HAVE_NO_PIC
-
-config ARCH_CFLAGS
- string
-
-config CROSS
- string
- default "v850e-elf-"
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.m68k b/extra/Configs/Config.m68k
index f86ca35b4..5888067bc 100644
--- a/extra/Configs/Config.m68k
+++ b/extra/Configs/Config.m68k
@@ -11,7 +11,4 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_BIG_ENDIAN
-
-config ARCH_CFLAGS
- string
- default "-Wa,--bitwise-or"
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.metag b/extra/Configs/Config.metag
new file mode 100644
index 000000000..e55822281
--- /dev/null
+++ b/extra/Configs/Config.metag
@@ -0,0 +1,32 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+# Copyright (C) 2013, Imagination Technologies Ltd.
+#
+# Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+#
+
+config TARGET_ARCH
+ default "metag"
+
+config FORCE_OPTIONS_FOR_ARCH
+ bool
+ default y
+ select ARCH_LITTLE_ENDIAN
+ select ARCH_HAS_MMU
+
+choice
+ prompt "Target Processor Type"
+ default CONFIG_META_2_1
+ help
+ This is the processor type of your CPU. This information is used for
+ optimizing purposes.
+
+config CONFIG_META_1_2
+ bool "Meta 1.2"
+
+config CONFIG_META_2_1
+ bool "Meta 2.1"
+
+endchoice
diff --git a/extra/Configs/Config.microblaze b/extra/Configs/Config.microblaze
index a89914ef1..60d10d6ef 100644
--- a/extra/Configs/Config.microblaze
+++ b/extra/Configs/Config.microblaze
@@ -10,12 +10,5 @@ config TARGET_ARCH
config FORCE_OPTIONS_FOR_ARCH
bool
default y
- select ARCH_BIG_ENDIAN
- select ARCH_HAS_NO_MMU
-
-config ARCH_CFLAGS
- string
-
-config CROSS
- string
- default "mb-"
+ select ARCH_ANY_ENDIAN
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.mips b/extra/Configs/Config.mips
index 442209884..e0b62dd67 100644
--- a/extra/Configs/Config.mips
+++ b/extra/Configs/Config.mips
@@ -11,10 +11,8 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_ANY_ENDIAN
-
-config ARCH_CFLAGS
- string
- default "-mno-split-addresses"
+ select ARCH_HAS_UCONTEXT
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target ABI"
@@ -33,42 +31,3 @@ config CONFIG_MIPS_N64_ABI
bool "N64 ABI"
endchoice
-
-choice
- prompt "Target Processor Architecture"
- default CONFIG_MIPS_ISA_1 if CONFIG_MIPS_O32_ABI
- default CONFIG_MIPS_ISA_3 if CONFIG_MIPS_N32_ABI
- default CONFIG_MIPS_ISA_3 if CONFIG_MIPS_N64_ABI
- help
- This selects the instruction set architecture of your MIPS CPU. This
- information is used for optimizing purposes. To build a library that
- will run on any MIPS CPU, you can specify "Generic (MIPS I)" here.
- If you pick anything other than "Generic (MIPS I)," there is no
- guarantee that uClibc will even run on anything other than the
- selected processor type.
-
- You should probably select the MIPS ISA that best matches the
- CPU you will be using on your device. uClibc will be tuned
- for that architecture.
-
- If you don't know what to do, choose "Generic (MIPS I)"
-
-config CONFIG_MIPS_ISA_1
- bool "Generic (MIPS I)"
-
-config CONFIG_MIPS_ISA_2
- bool "MIPS II"
-
-config CONFIG_MIPS_ISA_3
- bool "MIPS III"
-
-config CONFIG_MIPS_ISA_4
- bool "MIPS IV"
-
-config CONFIG_MIPS_ISA_MIPS32
- bool "MIPS32"
-
-config CONFIG_MIPS_ISA_MIPS64
- bool "MIPS64"
-
-endchoice
diff --git a/extra/Configs/Config.nios b/extra/Configs/Config.nios
deleted file mode 100644
index f1dbd6c42..000000000
--- a/extra/Configs/Config.nios
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see extra/config/Kconfig-language.txt
-#
-
-config TARGET_ARCH
- string
- default "nios"
-
-config FORCE_OPTIONS_FOR_ARCH
- bool
- default y
- select ARCH_LITTLE_ENDIAN
- select ARCH_HAS_NO_MMU
- select ARCH_HAS_NO_LDSO
- select HAVE_NO_PIC
-
-config ARCH_CFLAGS
- string
- default "-funaligned-struct-hack"
-
-config CROSS
- string
diff --git a/extra/Configs/Config.nios2 b/extra/Configs/Config.nios2
index 1f945556b..2310a46c0 100644
--- a/extra/Configs/Config.nios2
+++ b/extra/Configs/Config.nios2
@@ -14,9 +14,3 @@ config FORCE_OPTIONS_FOR_ARCH
select ARCH_HAS_NO_MMU
select ARCH_HAS_NO_LDSO
select HAVE_NO_PIC
-
-config ARCH_CFLAGS
- string
-
-config CROSS
- string
diff --git a/extra/Configs/Config.or1k b/extra/Configs/Config.or1k
new file mode 100644
index 000000000..45e6f0a57
--- /dev/null
+++ b/extra/Configs/Config.or1k
@@ -0,0 +1,35 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+
+config TARGET_ARCH
+ default "or1k"
+
+config ARCH_CFLAGS
+ string
+
+config ARCH_LDFLAGS
+ string
+
+config LIBGCC_CFLAGS
+ string
+
+choice
+ prompt "Target Architecture Type"
+ default CONFIG_OR1K
+ help
+ This is the architecture type of your CPU. This information is used for
+ optimizing purposes.
+
+ These are the possible settings:
+ - or1k Generic support for OpenCores OpenRISC/or1k architecture.
+
+config CONFIG_OR1K
+ select ARCH_HAS_MMU
+ select UCLIBC_HAS_FPU
+ select ARCH_BIG_ENDIAN
+ select HAS_NO_THREADS
+ bool "or1k"
+
+endchoice
diff --git a/extra/Configs/Config.powerpc b/extra/Configs/Config.powerpc
index 8ba267cf1..7698022ae 100644
--- a/extra/Configs/Config.powerpc
+++ b/extra/Configs/Config.powerpc
@@ -12,9 +12,7 @@ config FORCE_OPTIONS_FOR_ARCH
default y
select ARCH_BIG_ENDIAN
select ARCH_HAS_MMU
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target Processor Type"
diff --git a/extra/Configs/Config.sh b/extra/Configs/Config.sh
index 8538bcc65..1367b1c4f 100644
--- a/extra/Configs/Config.sh
+++ b/extra/Configs/Config.sh
@@ -11,9 +11,7 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_ANY_ENDIAN
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target Processor Type"
@@ -29,6 +27,7 @@ choice
- "SH2" SuperH SH-2
- "SH3" SuperH SH-3
- "SH4" SuperH SH-4
+ - "SH4A" SuperH SH-4a
config CONFIG_SH2A
select ARCH_HAS_NO_MMU
@@ -44,9 +43,11 @@ config CONFIG_SH3
bool "SH3"
config CONFIG_SH4
- select FORCE_SHAREABLE_TEXT_SEGMENTS
bool "SH4"
+config CONFIG_SH4A
+ bool "SH4A"
+
endchoice
config ARCH_HAS_BWD_MEMCPY
diff --git a/extra/Configs/Config.sh64 b/extra/Configs/Config.sh64
deleted file mode 100644
index 54d738e36..000000000
--- a/extra/Configs/Config.sh64
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see extra/config/Kconfig-language.txt
-#
-
-config TARGET_ARCH
- string
- default "sh64"
-
-config FORCE_OPTIONS_FOR_ARCH
- bool
- default y
- select ARCH_ANY_ENDIAN
-
-config ARCH_CFLAGS
- string
-
-choice
- prompt "Target Processor Type"
- default CONFIG_SH5
- help
- This is the processor type of your CPU. This information is used for
- optimizing purposes, as well as to determine if your CPU has an MMU,
- an FPU, etc. If you pick the wrong CPU type, there is no guarantee
- that uClibc will work at all....
-
- Here are the available choices:
- - "SH5" SuperH SH-5 101, 103
-
-config CONFIG_SH5
- select ARCH_HAS_MMU
- select UCLIBC_HAS_LFS
- bool "SH5"
-
-endchoice
diff --git a/extra/Configs/Config.sparc b/extra/Configs/Config.sparc
index 3b19f9d14..47c8ac289 100644
--- a/extra/Configs/Config.sparc
+++ b/extra/Configs/Config.sparc
@@ -11,9 +11,7 @@ config FORCE_OPTIONS_FOR_ARCH
bool
default y
select ARCH_BIG_ENDIAN
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_DEPRECATED_SYSCALLS
choice
prompt "Target Processor Type"
@@ -22,20 +20,10 @@ choice
This is the processor type of your CPU. This information is used for
optimizing purposes. Building for a v8 SPARC is pretty safe nowadays.
- Warning: shared library support requires v8 or better, so building for
- SPARC v7 will give you only static support.
-
config CONFIG_SPARC_V7
- select ARCH_HAS_NO_SHARED
bool "SPARC v7"
config CONFIG_SPARC_V8
bool "SPARC v8"
-config CONFIG_SPARC_V9
- bool "SPARC v9"
-
-config CONFIG_SPARC_V9B
- bool "SPARC v9b"
-
endchoice
diff --git a/extra/Configs/Config.vax b/extra/Configs/Config.vax
deleted file mode 100644
index 4192e28c2..000000000
--- a/extra/Configs/Config.vax
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see extra/config/Kconfig-language.txt
-#
-
-config TARGET_ARCH
- string
- default "vax"
-
-config FORCE_OPTIONS_FOR_ARCH
- bool
- default y
- select ARCH_LITTLE_ENDIAN
- select ARCH_HAS_NO_LDSO
-
-config ARCH_CFLAGS
- string
-
-config ARCH_LDFLAGS
- string
-
-config CROSS
- string
- default "vax-linux-uclibc-"
diff --git a/extra/Configs/Config.x86_64 b/extra/Configs/Config.x86_64
index 7ae357f61..317a5007f 100644
--- a/extra/Configs/Config.x86_64
+++ b/extra/Configs/Config.x86_64
@@ -12,6 +12,5 @@ config FORCE_OPTIONS_FOR_ARCH
default y
select ARCH_LITTLE_ENDIAN
select ARCH_HAS_MMU
-
-config ARCH_CFLAGS
- string
+ select ARCH_HAS_UCONTEXT
+ select ARCH_HAS_DEPRECATED_SYSCALLS
diff --git a/extra/Configs/Config.xtensa b/extra/Configs/Config.xtensa
index 75132471a..3ee8817ba 100644
--- a/extra/Configs/Config.xtensa
+++ b/extra/Configs/Config.xtensa
@@ -7,6 +7,8 @@ config TARGET_ARCH
string
default "xtensa"
-config ARCH_CFLAGS
- string
-
+config FORCE_OPTIONS_FOR_ARCH
+ bool
+ default y
+ select ARCH_HAS_DEPRECATED_SYSCALLS
+ select ARCH_ANY_ENDIAN
diff --git a/extra/Configs/defconfigs/alpha b/extra/Configs/defconfigs/alpha/defconfig
index 05243d7bb..05243d7bb 100644
--- a/extra/Configs/defconfigs/alpha
+++ b/extra/Configs/defconfigs/alpha/defconfig
diff --git a/extra/Configs/defconfigs/arc/arcv2_defconfig b/extra/Configs/defconfigs/arc/arcv2_defconfig
new file mode 100644
index 000000000..2d1235817
--- /dev/null
+++ b/extra/Configs/defconfigs/arc/arcv2_defconfig
@@ -0,0 +1,39 @@
+CONFIG_ARC_CPU_HS=y
+ARCH_WANTS_LITTLE_ENDIAN=y
+# UCLIBC_HAS_FPU is not set
+DO_C99_MATH=y
+KERNEL_HEADERS="%KERNEL_HEADERS%"
+# DOPIC is not set
+# LDSO_CACHE_SUPPORT is not set
+LDSO_RUNPATH=y
+# LDSO_SAFE_RUNPATH is not set
+UCLIBC_HAS_THREADS_NATIVE=y
+PTHREADS_DEBUG_SUPPORT=y
+UCLIBC_HAS_UTMPX=y
+UCLIBC_HAS_UTMP=y
+UCLIBC_SUSV2_LEGACY=y
+UCLIBC_SUSV3_LEGACY=y
+UCLIBC_SUSV4_LEGACY=y
+UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y
+UCLIBC_HAS_LIBUTIL=y
+UCLIBC_HAS_OBSOLETE_BSD_SIGNAL=y
+UCLIBC_SV4_DEPRECATED=y
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+UCLIBC_USE_NETLINK=y
+UCLIBC_SUPPORT_AI_ADDRCONFIG=y
+UCLIBC_HAS_RESOLVER_SUPPORT=y
+UCLIBC_HAS_LIBRESOLV_STUB=y
+UCLIBC_HAS_LIBNSL_STUB=y
+UCLIBC_HAS_LOCALE=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+UCLIBC_HAS_NFTW=y
+UCLIBC_HAS_FTW=y
+UCLIBC_HAS_GNU_GLOB=y
+RUNTIME_PREFIX="%RUNTIME_PREFIX%"
+DEVEL_PREFIX="%DEVEL_PREFIX%"
+CROSS_COMPILER_PREFIX="arc-linux-uclibc-"
+# DOSTRIP is not set
+SUPPORT_LD_DEBUG=y
+UCLIBC_HAS_BACKTRACE=y
diff --git a/extra/Configs/defconfigs/arc/defconfig b/extra/Configs/defconfigs/arc/defconfig
new file mode 100644
index 000000000..f582eb5a9
--- /dev/null
+++ b/extra/Configs/defconfigs/arc/defconfig
@@ -0,0 +1,38 @@
+ARCH_WANTS_LITTLE_ENDIAN=y
+# UCLIBC_HAS_FPU is not set
+DO_C99_MATH=y
+KERNEL_HEADERS="%KERNEL_HEADERS%"
+# DOPIC is not set
+# LDSO_CACHE_SUPPORT is not set
+LDSO_RUNPATH=y
+# LDSO_SAFE_RUNPATH is not set
+UCLIBC_HAS_THREADS_NATIVE=y
+PTHREADS_DEBUG_SUPPORT=y
+UCLIBC_HAS_UTMPX=y
+UCLIBC_HAS_UTMP=y
+UCLIBC_SUSV2_LEGACY=y
+UCLIBC_SUSV3_LEGACY=y
+UCLIBC_SUSV4_LEGACY=y
+UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y
+UCLIBC_HAS_LIBUTIL=y
+UCLIBC_HAS_OBSOLETE_BSD_SIGNAL=y
+UCLIBC_SV4_DEPRECATED=y
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+UCLIBC_USE_NETLINK=y
+UCLIBC_SUPPORT_AI_ADDRCONFIG=y
+UCLIBC_HAS_RESOLVER_SUPPORT=y
+UCLIBC_HAS_LIBRESOLV_STUB=y
+UCLIBC_HAS_LIBNSL_STUB=y
+UCLIBC_HAS_LOCALE=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+UCLIBC_HAS_NFTW=y
+UCLIBC_HAS_FTW=y
+UCLIBC_HAS_GNU_GLOB=y
+RUNTIME_PREFIX="%RUNTIME_PREFIX%"
+DEVEL_PREFIX="%DEVEL_PREFIX%"
+CROSS_COMPILER_PREFIX="arc-linux-uclibc-"
+# DOSTRIP is not set
+SUPPORT_LD_DEBUG=y
+UCLIBC_HAS_BACKTRACE=y
diff --git a/extra/Configs/defconfigs/arc/tb10x_defconfig b/extra/Configs/defconfigs/arc/tb10x_defconfig
new file mode 100644
index 000000000..405a4eac7
--- /dev/null
+++ b/extra/Configs/defconfigs/arc/tb10x_defconfig
@@ -0,0 +1,38 @@
+ARCH_WANTS_LITTLE_ENDIAN=y
+# UCLIBC_HAS_FPU is not set
+DO_C99_MATH=y
+KERNEL_HEADERS="%KERNEL_HEADERS%"
+# DOPIC is not set
+# LDSO_CACHE_SUPPORT is not set
+LDSO_RUNPATH=y
+# LDSO_SAFE_RUNPATH is not set
+LINUXTHREADS_OLD=y
+PTHREADS_DEBUG_SUPPORT=y
+MALLOC_GLIBC_COMPAT=y
+UCLIBC_SUSV3_LEGACY=y
+UCLIBC_SUSV4_LEGACY=y
+UCLIBC_HAS_GETPT=y
+UCLIBC_HAS_LIBUTIL=y
+UCLIBC_HAS_OBSOLETE_BSD_SIGNAL=y
+UCLIBC_SV4_DEPRECATED=y
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+UCLIBC_HAS_REENTRANT_RPC=y
+UCLIBC_HAS_RESOLVER_SUPPORT=y
+UCLIBC_HAS_LIBRESOLV_STUB=y
+UCLIBC_HAS_LIBNSL_STUB=y
+UCLIBC_HAS_CTYPE_CHECKED=y
+UCLIBC_HAS_LOCALE=y
+UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE=y
+UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE=y
+UCLIBC_HAS_GLIBC_CUSTOM_STREAMS=y
+UCLIBC_HAS_PRINTF_M_SPEC=y
+UCLIBC_HAS_NFTW=y
+UCLIBC_HAS_FTW=y
+UCLIBC_HAS_GNU_GLOB=y
+RUNTIME_PREFIX="%RUNTIME_PREFIX%"
+DEVEL_PREFIX="%DEVEL_PREFIX%"
+CROSS_COMPILER_PREFIX="arc-linux-uclibc-"
+# DOSTRIP is not set
+SUPPORT_LD_DEBUG=y
diff --git a/extra/Configs/defconfigs/arm b/extra/Configs/defconfigs/arm/defconfig
index aa6789032..aa6789032 100644
--- a/extra/Configs/defconfigs/arm
+++ b/extra/Configs/defconfigs/arm/defconfig
diff --git a/extra/Configs/defconfigs/avr32 b/extra/Configs/defconfigs/avr32/defconfig
index 0b890a291..0b890a291 100644
--- a/extra/Configs/defconfigs/avr32
+++ b/extra/Configs/defconfigs/avr32/defconfig
diff --git a/extra/Configs/defconfigs/bfin b/extra/Configs/defconfigs/bfin/defconfig
index fb5c5ebe0..fb5c5ebe0 100644
--- a/extra/Configs/defconfigs/bfin
+++ b/extra/Configs/defconfigs/bfin/defconfig
diff --git a/extra/Configs/defconfigs/cris b/extra/Configs/defconfigs/cris/defconfig
index 4e9818083..4e9818083 100644
--- a/extra/Configs/defconfigs/cris
+++ b/extra/Configs/defconfigs/cris/defconfig
diff --git a/extra/Configs/defconfigs/e1 b/extra/Configs/defconfigs/e1
deleted file mode 100644
index e204c8778..000000000
--- a/extra/Configs/defconfigs/e1
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_e1=y
diff --git a/extra/Configs/defconfigs/frv b/extra/Configs/defconfigs/frv/defconfig
index 8230316b6..8230316b6 100644
--- a/extra/Configs/defconfigs/frv
+++ b/extra/Configs/defconfigs/frv/defconfig
diff --git a/extra/Configs/defconfigs/h8300 b/extra/Configs/defconfigs/h8300/defconfig
index 66c4a33b3..66c4a33b3 100644
--- a/extra/Configs/defconfigs/h8300
+++ b/extra/Configs/defconfigs/h8300/defconfig
diff --git a/extra/Configs/defconfigs/hppa b/extra/Configs/defconfigs/hppa/defconfig
index 6358dbd1b..6358dbd1b 100644
--- a/extra/Configs/defconfigs/hppa
+++ b/extra/Configs/defconfigs/hppa/defconfig
diff --git a/extra/Configs/defconfigs/i386 b/extra/Configs/defconfigs/i386/defconfig
index 7c3517808..7c3517808 100644
--- a/extra/Configs/defconfigs/i386
+++ b/extra/Configs/defconfigs/i386/defconfig
diff --git a/extra/Configs/defconfigs/i960 b/extra/Configs/defconfigs/i960
deleted file mode 100644
index 5abe6dc8b..000000000
--- a/extra/Configs/defconfigs/i960
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_i960=y
diff --git a/extra/Configs/defconfigs/ia64 b/extra/Configs/defconfigs/ia64/defconfig
index 7f26470a1..7f26470a1 100644
--- a/extra/Configs/defconfigs/ia64
+++ b/extra/Configs/defconfigs/ia64/defconfig
diff --git a/extra/Configs/defconfigs/lm32 b/extra/Configs/defconfigs/lm32
new file mode 100644
index 000000000..63fb19d79
--- /dev/null
+++ b/extra/Configs/defconfigs/lm32
@@ -0,0 +1 @@
+TARGET_lm32=y
diff --git a/extra/Configs/defconfigs/m68k b/extra/Configs/defconfigs/m68k/defconfig
index da874a89c..da874a89c 100644
--- a/extra/Configs/defconfigs/m68k
+++ b/extra/Configs/defconfigs/m68k/defconfig
diff --git a/extra/Configs/defconfigs/metag/defconfig b/extra/Configs/defconfigs/metag/defconfig
new file mode 100644
index 000000000..a6f57df72
--- /dev/null
+++ b/extra/Configs/defconfigs/metag/defconfig
@@ -0,0 +1 @@
+TARGET_metag=y
diff --git a/extra/Configs/defconfigs/microblaze b/extra/Configs/defconfigs/microblaze/defconfig
index 44012004a..44012004a 100644
--- a/extra/Configs/defconfigs/microblaze
+++ b/extra/Configs/defconfigs/microblaze/defconfig
diff --git a/extra/Configs/defconfigs/mips b/extra/Configs/defconfigs/mips/defconfig
index 0114a9bd1..0114a9bd1 100644
--- a/extra/Configs/defconfigs/mips
+++ b/extra/Configs/defconfigs/mips/defconfig
diff --git a/extra/Configs/defconfigs/nios b/extra/Configs/defconfigs/nios
deleted file mode 100644
index 2a110b893..000000000
--- a/extra/Configs/defconfigs/nios
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_nios=y
diff --git a/extra/Configs/defconfigs/nios2 b/extra/Configs/defconfigs/nios2/defconfig
index 870bd538a..870bd538a 100644
--- a/extra/Configs/defconfigs/nios2
+++ b/extra/Configs/defconfigs/nios2/defconfig
diff --git a/extra/Configs/defconfigs/or1k/defconfig b/extra/Configs/defconfigs/or1k/defconfig
new file mode 100644
index 000000000..e0e08ce11
--- /dev/null
+++ b/extra/Configs/defconfigs/or1k/defconfig
@@ -0,0 +1,242 @@
+#
+# Automatically generated make config: don't edit
+# Version: 0.9.34-git
+# Wed Oct 10 16:27:15 2012
+#
+# TARGET_alpha is not set
+# TARGET_arm is not set
+# TARGET_avr32 is not set
+# TARGET_bfin is not set
+# TARGET_c6x is not set
+# TARGET_cris is not set
+# TARGET_e1 is not set
+# TARGET_frv is not set
+# TARGET_h8300 is not set
+# TARGET_hppa is not set
+# TARGET_i386 is not set
+# TARGET_ia64 is not set
+# TARGET_m68k is not set
+# TARGET_microblaze is not set
+# TARGET_mips is not set
+# TARGET_nios is not set
+# TARGET_nios2 is not set
+TARGET_or1k=y
+# TARGET_powerpc is not set
+# TARGET_sh is not set
+# TARGET_sh64 is not set
+# TARGET_sparc is not set
+# TARGET_x86_64 is not set
+# TARGET_xtensa is not set
+
+#
+# Target Architecture Features and Options
+#
+TARGET_ARCH="or1k"
+CONFIG_OR1K=y
+TARGET_SUBARCH=""
+
+#
+# Using ELF file format
+#
+ARCH_BIG_ENDIAN=y
+
+#
+# Using Big Endian
+#
+ARCH_HAS_MMU=y
+ARCH_USE_MMU=y
+UCLIBC_HAS_FLOATS=y
+UCLIBC_HAS_FPU=y
+DO_C99_MATH=y
+# DO_XSI_MATH is not set
+# UCLIBC_HAS_FENV is not set
+KERNEL_HEADERS="${SYSROOT}/usr/include"
+HAVE_DOT_CONFIG=y
+
+#
+# General Library Settings
+#
+DOPIC=y
+HAVE_SHARED=y
+# FORCE_SHAREABLE_TEXT_SEGMENTS is not set
+LDSO_LDD_SUPPORT=y
+LDSO_CACHE_SUPPORT=y
+LDSO_PRELOAD_ENV_SUPPORT=y
+# LDSO_PRELOAD_FILE_SUPPORT is not set
+LDSO_BASE_FILENAME="ld.so"
+# LDSO_STANDALONE_SUPPORT is not set
+# LDSO_PRELINK_SUPPORT is not set
+UCLIBC_STATIC_LDCONFIG=y
+LDSO_RUNPATH=y
+LDSO_SEARCH_INTERP_PATH=y
+LDSO_LD_LIBRARY_PATH=y
+# LDSO_NO_CLEANUP is not set
+UCLIBC_CTOR_DTOR=y
+# LDSO_GNU_HASH_SUPPORT is not set
+# HAS_NO_THREADS is not set
+LINUXTHREADS_OLD=y
+# LINUXTHREADS_NEW is not set
+# UCLIBC_HAS_THREADS_NATIVE is not set
+UCLIBC_HAS_THREADS=y
+# PTHREADS_DEBUG_SUPPORT is not set
+UCLIBC_HAS_SYSLOG=y
+UCLIBC_HAS_LFS=y
+# MALLOC is not set
+# MALLOC_SIMPLE is not set
+MALLOC_STANDARD=y
+# MALLOC_GLIBC_COMPAT is not set
+# UCLIBC_DYNAMIC_ATEXIT is not set
+COMPAT_ATEXIT=y
+UCLIBC_SUSV3_LEGACY=y
+# UCLIBC_SUSV3_LEGACY_MACROS is not set
+UCLIBC_SUSV4_LEGACY=y
+# UCLIBC_STRICT_HEADERS is not set
+# UCLIBC_HAS_STUBS is not set
+UCLIBC_HAS_SHADOW=y
+UCLIBC_HAS_PROGRAM_INVOCATION_NAME=y
+UCLIBC_HAS___PROGNAME=y
+UCLIBC_HAS_PTY=y
+ASSUME_DEVPTS=y
+UNIX98PTY_ONLY=y
+# UCLIBC_HAS_GETPT is not set
+# UCLIBC_HAS_LIBUTIL is not set
+UCLIBC_HAS_TM_EXTENSIONS=y
+UCLIBC_HAS_TZ_CACHING=y
+UCLIBC_HAS_TZ_FILE=y
+UCLIBC_HAS_TZ_FILE_READ_MANY=y
+UCLIBC_TZ_FILE_PATH="/etc/TZ"
+UCLIBC_FALLBACK_TO_ETC_LOCALTIME=y
+
+#
+# Advanced Library Settings
+#
+UCLIBC_PWD_BUFFER_SIZE=256
+UCLIBC_GRP_BUFFER_SIZE=256
+
+#
+# Support various families of functions
+#
+UCLIBC_LINUX_MODULE_26=y
+UCLIBC_LINUX_MODULE_24=y
+UCLIBC_LINUX_SPECIFIC=y
+UCLIBC_HAS_GNU_ERROR=y
+UCLIBC_BSD_SPECIFIC=y
+UCLIBC_HAS_BSD_ERR=y
+# UCLIBC_HAS_OBSOLETE_BSD_SIGNAL is not set
+# UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL is not set
+# UCLIBC_NTP_LEGACY is not set
+# UCLIBC_SV4_DEPRECATED is not set
+UCLIBC_HAS_REALTIME=y
+UCLIBC_HAS_ADVANCED_REALTIME=y
+UCLIBC_HAS_EPOLL=y
+UCLIBC_HAS_XATTR=y
+UCLIBC_HAS_PROFILING=y
+UCLIBC_HAS_CRYPT_IMPL=y
+# UCLIBC_HAS_SHA256_CRYPT_IMPL is not set
+# UCLIBC_HAS_SHA512_CRYPT_IMPL is not set
+UCLIBC_HAS_CRYPT=y
+UCLIBC_HAS_NETWORK_SUPPORT=y
+UCLIBC_HAS_SOCKET=y
+UCLIBC_HAS_IPV4=y
+UCLIBC_HAS_IPV6=y
+UCLIBC_HAS_RPC=y
+UCLIBC_HAS_FULL_RPC=y
+UCLIBC_HAS_REENTRANT_RPC=y
+# UCLIBC_USE_NETLINK is not set
+# UCLIBC_HAS_BSD_RES_CLOSE is not set
+UCLIBC_HAS_COMPAT_RES_STATE=y
+# UCLIBC_HAS_EXTRA_COMPAT_RES_STATE is not set
+# UCLIBC_HAS_RESOLVER_SUPPORT is not set
+# UCLIBC_HAS_LIBRESOLV_STUB is not set
+# UCLIBC_HAS_LIBNSL_STUB is not set
+
+#
+# String and Stdio Support
+#
+UCLIBC_HAS_STRING_GENERIC_OPT=y
+UCLIBC_HAS_STRING_ARCH_OPT=y
+UCLIBC_HAS_CTYPE_TABLES=y
+UCLIBC_HAS_CTYPE_SIGNED=y
+UCLIBC_HAS_CTYPE_UNSAFE=y
+# UCLIBC_HAS_CTYPE_CHECKED is not set
+# UCLIBC_HAS_CTYPE_ENFORCED is not set
+UCLIBC_HAS_WCHAR=y
+# UCLIBC_HAS_LOCALE is not set
+# UCLIBC_HAS_HEXADECIMAL_FLOATS is not set
+# UCLIBC_HAS_GLIBC_CUSTOM_PRINTF is not set
+UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
+# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
+# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
+UCLIBC_HAS_STDIO_BUFSIZ_4096=y
+# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
+UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set
+# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set
+# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set
+UCLIBC_HAS_STDIO_GETC_MACRO=y
+UCLIBC_HAS_STDIO_PUTC_MACRO=y
+UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y
+# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set
+# UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE is not set
+# UCLIBC_HAS_FOPEN_CLOSEEXEC_MODE is not set
+# UCLIBC_HAS_GLIBC_CUSTOM_STREAMS is not set
+# UCLIBC_HAS_PRINTF_M_SPEC is not set
+UCLIBC_HAS_ERRNO_MESSAGES=y
+# UCLIBC_HAS_SYS_ERRLIST is not set
+UCLIBC_HAS_SIGNUM_MESSAGES=y
+# UCLIBC_HAS_SYS_SIGLIST is not set
+UCLIBC_HAS_GNU_GETOPT=y
+UCLIBC_HAS_GNU_GETSUBOPT=y
+
+#
+# Big and Tall
+#
+UCLIBC_HAS_REGEX=y
+UCLIBC_HAS_REGEX_OLD=y
+UCLIBC_HAS_FNMATCH=y
+UCLIBC_HAS_FNMATCH_OLD=y
+# UCLIBC_HAS_WORDEXP is not set
+# UCLIBC_HAS_NFTW is not set
+# UCLIBC_HAS_FTW is not set
+# UCLIBC_HAS_FTS is not set
+UCLIBC_HAS_GLOB=y
+# UCLIBC_HAS_GNU_GLOB is not set
+# UCLIBC_HAS_UTMPX is not set
+
+#
+# Library Installation Options
+#
+RUNTIME_PREFIX="/"
+DEVEL_PREFIX="/usr"
+MULTILIB_DIR="lib"
+HARDWIRED_ABSPATH=y
+
+#
+# Security options
+#
+# UCLIBC_HAS_ARC4RANDOM is not set
+# UCLIBC_HAS_SSP is not set
+UCLIBC_BUILD_RELRO=y
+# UCLIBC_BUILD_NOW is not set
+UCLIBC_BUILD_NOEXECSTACK=y
+
+#
+# Development/debugging options
+#
+CROSS_COMPILER_PREFIX="or1k-linux-uclibc-"
+UCLIBC_EXTRA_CFLAGS=""
+# DODEBUG is not set
+# DODEBUG_PT is not set
+# DOSTRIP is not set
+# DOASSERTS is not set
+# SUPPORT_LD_DEBUG is not set
+# SUPPORT_LD_DEBUG_EARLY is not set
+# UCLIBC_MALLOC_DEBUGGING is not set
+# UCLIBC_HAS_BACKTRACE is not set
+WARNINGS="-Wall"
+# EXTRA_WARNINGS is not set
+# DOMULTI is not set
+# UCLIBC_MJN3_ONLY is not set
diff --git a/extra/Configs/defconfigs/powerpc b/extra/Configs/defconfigs/powerpc/defconfig
index 38688970e..38688970e 100644
--- a/extra/Configs/defconfigs/powerpc
+++ b/extra/Configs/defconfigs/powerpc/defconfig
diff --git a/extra/Configs/defconfigs/sh b/extra/Configs/defconfigs/sh/defconfig
index 650d280e0..650d280e0 100644
--- a/extra/Configs/defconfigs/sh
+++ b/extra/Configs/defconfigs/sh/defconfig
diff --git a/extra/Configs/defconfigs/sh64 b/extra/Configs/defconfigs/sh64
deleted file mode 100644
index 4f23a5402..000000000
--- a/extra/Configs/defconfigs/sh64
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_sh64=y
diff --git a/extra/Configs/defconfigs/sparc b/extra/Configs/defconfigs/sparc/defconfig
index c2c74cbab..c2c74cbab 100644
--- a/extra/Configs/defconfigs/sparc
+++ b/extra/Configs/defconfigs/sparc/defconfig
diff --git a/extra/Configs/defconfigs/v850 b/extra/Configs/defconfigs/v850
deleted file mode 100644
index 046d5d4fd..000000000
--- a/extra/Configs/defconfigs/v850
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_v850=y
diff --git a/extra/Configs/defconfigs/vax b/extra/Configs/defconfigs/vax
deleted file mode 100644
index 77a464e29..000000000
--- a/extra/Configs/defconfigs/vax
+++ /dev/null
@@ -1 +0,0 @@
-TARGET_vax=y
diff --git a/extra/Configs/defconfigs/x86_64 b/extra/Configs/defconfigs/x86_64/defconfig
index e03a36aa2..e03a36aa2 100644
--- a/extra/Configs/defconfigs/x86_64
+++ b/extra/Configs/defconfigs/x86_64/defconfig
diff --git a/extra/config/.gitignore b/extra/config/.gitignore
index b49584c93..be603c4fe 100644
--- a/extra/config/.gitignore
+++ b/extra/config/.gitignore
@@ -2,18 +2,21 @@
# Generated files
#
config*
-lex.*.c
+*.lex.c
*.tab.c
*.tab.h
zconf.hash.c
*.moc
-lkc_defs.h
+gconf.glade.h
+*.pot
+*.mo
#
# configuration programs
#
conf
mconf
+nconf
qconf
gconf
kxgettext
diff --git a/extra/config/Makefile b/extra/config/Makefile
index 45ec1f47e..c306a7eb1 100644
--- a/extra/config/Makefile
+++ b/extra/config/Makefile
@@ -1,43 +1,82 @@
-obj := .
-src := .
-top_srcdir=../../
-top_builddir=../../
-srctree := .
-include $(top_builddir)Rules.mak
+top_srcdir ?= ../../
-include Makefile.kconfig
+ifdef O
+top_builddir ?= ../../
+else
+top_builddir = ../../
+endif
+
+include $(top_srcdir)Rules.mak
+include $(top_srcdir)Makerules
+
+# ugh
+top_srcdir:=$(shell cd $(top_srcdir) && pwd)/
+
+src := extra/config
+obj := $(top_builddir)$(src)
+
+generated := $(patsubst %_shipped,%,$(wildcard *_shipped))
+generated := $(addprefix $(obj)/,$(generated:.c=.o))
+
+include $(top_srcdir)extra/config/Makefile.kconfig
+HOST_EXTRACFLAGS += -DCONFIG_='""'
+
+# do not create temporary object in the readonly srctree
+$(obj)/dochecklxdialog: CONFIG_SHELL:=cd $(obj) && $(CONFIG_SHELL)
+HOSTCFLAGS_zconf.lex.o := -I$(top_srcdir)$(src)
+HOSTCFLAGS_zconf.tab.o := -I$(top_srcdir)$(src)
+conf-objs := $(addprefix $(obj)/,$(conf-objs))
+mconf-objs := $(addprefix $(obj)/,$(mconf-objs))
+nconf-objs := $(addprefix $(obj)/,$(nconf-objs))
+kxgettext-objs := $(addprefix $(obj)/,$(kxgettext-objs))
ifeq ($(findstring mconf,$(MAKECMDGOALS)),mconf)
hostprogs-y += mconf
endif
-
--include .depend
-.depend: $(wildcard *.h *.c)
- $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) -MM *.c > .depend 2>/dev/null || :
+ifeq ($(findstring nconf,$(MAKECMDGOALS)),nconf)
+hostprogs-y += nconf
+endif
__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
-host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
+host-csingle:= $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
host-cmulti := $(foreach m,$(__hostprogs),\
$(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
-$(host-csingle): %: %.c
- $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) $< $(HOST_LOADLIBES) -o $@
+conf mconf nconf kxgettext: %: $(obj)/%
+$(obj)/conf $(obj)/mconf $(obj)/nconf $(obj)/kxgettext: BUILD_LDFLAGS=$(HOSTLOADLIBES_$(@F))
+$(obj)/conf: $(conf-objs)
+ $(hcompile.u)
+$(obj)/mconf: $(mconf-objs)
+ $(hcompile.u)
+$(obj)/nconf: $(nconf-objs)
+ $(hcompile.u)
+$(obj)/kxgettext: $(kxgettext-objs)
+ $(hcompile.u)
+
+$(host-csingle) $(host-cmulti) $(host-cobjs): BUILD_CFLAGS+=$(HOST_EXTRACFLAGS) \
+ $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F))
-$(host-cmulti): %: $(host-cobjs) $(host-cshlib)
- $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) $($@-objs) $(HOST_LOADLIBES) -o $@
+host-cobjs.nogen := $(filter-out $(generated),$(host-cobjs))
+host-cobjs.generated := $(filter $(generated),$(host-cobjs))
-$(host-cobjs): %.o: %.c
- $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) -c $< -o $@
+$(host-cobjs.nogen): $(obj)/%.o: $(top_srcdir)$(src)/%.c
+ $(hcompile.o)
+$(host-cobjs.generated): $(obj)/%.o: $(obj)/%.c
+ $(hcompile.o)
-$(obj)/%:: $(src)/%_shipped
+# we use the pre-generated always
+$(obj)/%:: $(top_srcdir)$(src)/%_shipped
+ @$(disp_gen)
$(Q)cat $< > $@
-clean:
- $(Q)rm -f $(clean-files) conf
-distclean: clean
- $(Q)rm -f $(lxdialog) $(conf-objs) $(mconf-objs) $(kxgettext-objs) \
- $(hostprogs-y) $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) .depend
+CLEAN_extra/config menuconfig_clean:
+ $(do_rm) $(clean-files) $(lxdialog) conf $(wildcard *.o)
+distclean: CLEAN_extra/config
+ $(Q)$(RM) -r $(lxdialog) $(conf-objs) $(mconf-objs) $(nconf-objs) \
+ $(kxgettext-objs) \
+ $(hostprogs-y) $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) \
+ .depend \
+ $(top_builddir)include/config $(top_builddir)include/generated
-FORCE:
-.PHONY: FORCE clean distclean
+.PHONY: clean distclean $(PHONY)
diff --git a/extra/config/Makefile.kconfig b/extra/config/Makefile.kconfig
index 32e8c5a22..844bc9da0 100644
--- a/extra/config/Makefile.kconfig
+++ b/extra/config/Makefile.kconfig
@@ -2,9 +2,17 @@
# Kernel configuration targets
# These targets are used from top-level makefile
-PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
+PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \
+ localmodconfig localyesconfig
-Kconfig := arch/$(SRCARCH)/Kconfig
+ifdef KBUILD_KCONFIG
+Kconfig := $(KBUILD_KCONFIG)
+else
+Kconfig := Kconfig
+endif
+
+# We need this, in case the user has it in its environment
+unexport CONFIG_
xconfig: $(obj)/qconf
$< $(Kconfig)
@@ -16,91 +24,121 @@ menuconfig: $(obj)/mconf
$< $(Kconfig)
config: $(obj)/conf
+ $< --oldaskconfig $(Kconfig)
+
+nconfig: $(obj)/nconf
$< $(Kconfig)
oldconfig: $(obj)/conf
- $< -o $(Kconfig)
+ $< --$@ $(Kconfig)
silentoldconfig: $(obj)/conf
- $< -s $(Kconfig)
+ $(Q)mkdir -p include/generated
+ $< --$@ $(Kconfig)
+
+localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
+ $(Q)mkdir -p include/generated
+ $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config
+ $(Q)if [ -f .config ]; then \
+ cmp -s .tmp.config .config || \
+ (mv -f .config .config.old.1; \
+ mv -f .tmp.config .config; \
+ $(obj)/conf --silentoldconfig $(Kconfig); \
+ mv -f .config.old.1 .config.old) \
+ else \
+ mv -f .tmp.config .config; \
+ $(obj)/conf --silentoldconfig $(Kconfig); \
+ fi
+ $(Q)rm -f .tmp.config
# Create new linux.pot file
# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
-# The symlink is used to repair a deficiency in arch/um
update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
- $(Q)echo " GEN config"
- $(Q)xgettext --default-domain=linux \
- --add-comments --keyword=_ --keyword=N_ \
- --from-code=UTF-8 \
- --files-from=scripts/kconfig/POTFILES.in \
+ $(Q)echo " GEN config.pot"
+ $(Q)xgettext --default-domain=linux \
+ --add-comments --keyword=_ --keyword=N_ \
+ --from-code=UTF-8 \
+ --files-from=$(srctree)/scripts/kconfig/POTFILES.in \
+ --directory=$(srctree) --directory=$(objtree) \
--output $(obj)/config.pot
$(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
- $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch
- $(Q)(for i in `ls arch/`; \
+ $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \
+ $(srctree)/arch/*/um/Kconfig`; \
do \
- echo " GEN $$i"; \
- $(obj)/kxgettext arch/$$i/Kconfig \
+ echo " GEN $$i"; \
+ $(obj)/kxgettext $$i \
>> $(obj)/config.pot; \
done )
+ $(Q)echo " GEN linux.pot"
$(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
--output $(obj)/linux.pot
- $(Q)rm -f arch/um/Kconfig.arch
$(Q)rm -f $(obj)/config.pot
-PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
+PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig
+
+allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf
+ $< --$@ $(Kconfig)
-randconfig: $(obj)/conf
- $< -r $(Kconfig)
+PHONY += listnewconfig olddefconfig oldnoconfig savedefconfig defconfig
-allyesconfig: $(obj)/conf
- $< -y $(Kconfig)
+listnewconfig olddefconfig: $(obj)/conf
+ $< --$@ $(Kconfig)
-allnoconfig: $(obj)/conf
- $< -n $(Kconfig)
+# oldnoconfig is an alias of olddefconfig, because people already are dependent
+# on its behavior(sets new symbols to their default value but not 'n') with the
+# counter-intuitive name.
+oldnoconfig: $(obj)/conf
+ $< --olddefconfig $(Kconfig)
-allmodconfig: $(obj)/conf
- $< -m $(Kconfig)
+savedefconfig: $(obj)/conf
+ $< --$@=defconfig $(Kconfig)
defconfig: $(obj)/conf
ifeq ($(KBUILD_DEFCONFIG),)
- $< -d $(Kconfig)
+ $< --defconfig $(Kconfig)
else
@echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
- $(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
+ $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
endif
%_defconfig: $(obj)/conf
- $(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig)
+ $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
# Help text used by make help
help:
@echo ' config - Update current config utilising a line-oriented program'
+ @echo ' nconfig - Update current config utilising a ncurses menu based program'
@echo ' menuconfig - Update current config utilising a menu based program'
@echo ' xconfig - Update current config utilising a QT based front-end'
@echo ' gconfig - Update current config utilising a GTK based front-end'
@echo ' oldconfig - Update current config utilising a provided .config as base'
- @echo ' silentoldconfig - Same as oldconfig, but quietly'
- @echo ' randconfig - New config with random answer to all options'
- @echo ' defconfig - New config with default answer to all options'
- @echo ' allmodconfig - New config selecting modules when possible'
- @echo ' allyesconfig - New config where all options are accepted with yes'
+ @echo ' localmodconfig - Update current config disabling modules not loaded'
+ @echo ' localyesconfig - Update current config converting local mods to core'
+ @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
+ @echo ' defconfig - New config with default from ARCH supplied defconfig'
+ @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
@echo ' allnoconfig - New config where all options are answered with no'
+ @echo ' allyesconfig - New config where all options are accepted with yes'
+ @echo ' allmodconfig - New config selecting modules when possible'
+ @echo ' alldefconfig - New config with all symbols set to default'
+ @echo ' randconfig - New config with random answer to all options'
+ @echo ' listnewconfig - List new options'
+ @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
# lxdialog stuff
check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
# Use recursively expanded variables so we do not call gcc unless
# we really need to do so. (Do not call gcc as part of make mrproper)
-HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
-HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
-
-HOST_EXTRACFLAGS += -DLOCALE
-
+HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
+ -DLOCALE
# ===========================================================================
# Shared Makefile for the various kconfig executables:
# conf: Used for defconfig, oldconfig and related targets
-# mconf: Used for the mconfig target.
+# nconf: Used for the nconfig target.
+# Utilizes ncurses
+# mconf: Used for the menuconfig target
# Utilizes the lxdialog package
# qconf: Used for the xconfig target
# Based on QT which needs to be installed to compile it
@@ -112,15 +150,27 @@ lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
conf-objs := conf.o zconf.tab.o
-mconf-objs := mconf.o zconf.tab.o $(lxdialog)
+mconf-objs := mconf.o zconf.tab.o $(lxdialog)
+nconf-objs := nconf.o zconf.tab.o nconf.gui.o
kxgettext-objs := kxgettext.o zconf.tab.o
+qconf-cxxobjs := qconf.o
+qconf-objs := zconf.tab.o
+gconf-objs := gconf.o zconf.tab.o
+
+hostprogs-y := conf
-hostprogs-y := conf qconf gconf kxgettext
+ifeq ($(MAKECMDGOALS),nconfig)
+ hostprogs-y += nconf
+endif
ifeq ($(MAKECMDGOALS),menuconfig)
hostprogs-y += mconf
endif
+ifeq ($(MAKECMDGOALS),update-po-config)
+ hostprogs-y += kxgettext
+endif
+
ifeq ($(MAKECMDGOALS),xconfig)
qconf-target := 1
endif
@@ -130,24 +180,23 @@ endif
ifeq ($(qconf-target),1)
-qconf-cxxobjs := qconf.o
-qconf-objs := kconfig_load.o zconf.tab.o
+ hostprogs-y += qconf
endif
ifeq ($(gconf-target),1)
-gconf-objs := gconf.o kconfig_load.o zconf.tab.o
+ hostprogs-y += gconf
endif
-clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \
- .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
-clean-files += mconf qconf gconf
+clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
+clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
+clean-files += mconf qconf gconf nconf
clean-files += config.pot linux.pot
# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
PHONY += $(obj)/dochecklxdialog
$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
$(obj)/dochecklxdialog:
- $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES)
+ $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
always := dochecklxdialog
@@ -155,16 +204,24 @@ always := dochecklxdialog
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
# generated files seem to need this to find local include files
-HOSTCFLAGS_lex.zconf.o := -I$(src)
+HOSTCFLAGS_zconf.lex.o := -I$(src)
HOSTCFLAGS_zconf.tab.o := -I$(src)
-HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl
-HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK
+LEX_PREFIX_zconf := zconf
+YACC_PREFIX_zconf := zconf
+
+HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
+HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
- -D LKC_DIRECT_LINK
+ -Wno-missing-prototypes
+
+HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
+HOSTLOADLIBES_nconf = $(shell \
+ pkg-config --libs menu panel ncurses 2>/dev/null \
+ || echo "-lmenu -lpanel -lncurses" )
$(obj)/qconf.o: $(obj)/.tmp_qtcheck
ifeq ($(qconf-target),1)
@@ -174,40 +231,48 @@ $(obj)/.tmp_qtcheck: $(src)/Makefile
# QT needs some extra effort...
$(obj)/.tmp_qtcheck:
@set -e; echo " CHECK qt"; dir=""; pkg=""; \
- pkg-config --exists qt 2> /dev/null && pkg=qt; \
- pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
- if [ -n "$$pkg" ]; then \
- cflags="\$$(shell pkg-config $$pkg --cflags)"; \
- libs="\$$(shell pkg-config $$pkg --libs)"; \
- moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
- dir="$$(pkg-config $$pkg --variable=prefix)"; \
+ if ! pkg-config --exists QtCore 2> /dev/null; then \
+ echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \
+ pkg-config --exists qt 2> /dev/null && pkg=qt; \
+ pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \
+ if [ -n "$$pkg" ]; then \
+ cflags="\$$(shell pkg-config $$pkg --cflags)"; \
+ libs="\$$(shell pkg-config $$pkg --libs)"; \
+ moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \
+ dir="$$(pkg-config $$pkg --variable=prefix)"; \
+ else \
+ for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
+ if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
+ done; \
+ if [ -z "$$dir" ]; then \
+ echo >&2 "*"; \
+ echo >&2 "* Unable to find any QT installation. Please make sure that"; \
+ echo >&2 "* the QT4 or QT3 development package is correctly installed and"; \
+ echo >&2 "* either qmake can be found or install pkg-config or set"; \
+ echo >&2 "* the QTDIR environment variable to the correct location."; \
+ echo >&2 "*"; \
+ false; \
+ fi; \
+ libpath=$$dir/lib; lib=qt; osdir=""; \
+ $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
+ osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
+ test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
+ test -f $$libpath/libqt-mt.so && lib=qt-mt; \
+ cflags="-I$$dir/include"; \
+ libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
+ moc="$$dir/bin/moc"; \
+ fi; \
+ if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
+ echo "*"; \
+ echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
+ echo "*"; \
+ moc="/usr/bin/moc"; \
+ fi; \
else \
- for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \
- if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \
- done; \
- if [ -z "$$dir" ]; then \
- echo "*"; \
- echo "* Unable to find the QT3 installation. Please make sure that"; \
- echo "* the QT3 development package is correctly installed and"; \
- echo "* either install pkg-config or set the QTDIR environment"; \
- echo "* variable to the correct location."; \
- echo "*"; \
- false; \
- fi; \
- libpath=$$dir/lib; lib=qt; osdir=""; \
- $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \
- osdir=x$$($(HOSTCXX) -print-multi-os-directory); \
- test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \
- test -f $$libpath/libqt-mt.so && lib=qt-mt; \
- cflags="-I$$dir/include"; \
- libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \
- moc="$$dir/bin/moc"; \
- fi; \
- if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \
- echo "*"; \
- echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \
- echo "*"; \
- moc="/usr/bin/moc"; \
+ cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \
+ libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \
+ moc="\$$(shell pkg-config QtCore --variable=moc_location)"; \
+ [ -n "$$moc" ] || moc="\$$(shell pkg-config QtCore --variable=prefix)/bin/moc"; \
fi; \
echo "KC_QT_CFLAGS=$$cflags" > $@; \
echo "KC_QT_LIBS=$$libs" >> $@; \
@@ -225,61 +290,33 @@ $(obj)/.tmp_gtkcheck:
if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \
touch $@; \
else \
- echo "*"; \
- echo "* GTK+ is present but version >= 2.0.0 is required."; \
- echo "*"; \
+ echo >&2 "*"; \
+ echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \
+ echo >&2 "*"; \
false; \
fi \
else \
- echo "*"; \
- echo "* Unable to find the GTK+ installation. Please make sure that"; \
- echo "* the GTK+ 2.0 development package is correctly installed..."; \
- echo "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
- echo "*"; \
+ echo >&2 "*"; \
+ echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \
+ echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \
+ echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \
+ echo >&2 "*"; \
false; \
fi
endif
-$(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c
-
-$(obj)/kconfig_load.o: $(obj)/lkc_defs.h
+$(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c
-$(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h
+$(obj)/qconf.o: $(obj)/qconf.moc
-$(obj)/gconf.o: $(obj)/lkc_defs.h
+quiet_cmd_moc = MOC $@
+ cmd_moc = $(KC_QT_MOC) -i $< -o $@
-$(obj)/%.moc: $(src)/%.h
- $(KC_QT_MOC) -i $< -o $@
-
-$(obj)/lkc_defs.h: $(src)/lkc_proto.h
- sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
+$(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck
+ $(call cmd,moc)
# Extract gconf menu items for I18N support
$(obj)/gconf.glade.h: $(obj)/gconf.glade
- intltool-extract --type=gettext/glade $(obj)/gconf.glade
-
-###
-# The following requires flex/bison/gperf
-# By default we use the _shipped versions, uncomment the following line if
-# you are modifying the flex/bison src.
-# LKC_GENPARSER := 1
-
-ifdef LKC_GENPARSER
-
-$(obj)/zconf.tab.c: $(src)/zconf.y
-$(obj)/lex.zconf.c: $(src)/zconf.l
-$(obj)/zconf.hash.c: $(src)/zconf.gperf
+ $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
+ $(obj)/gconf.glade
-%.tab.c: %.y
- bison -l -b $* -p $(notdir $*) $<
- cp $@ $@_shipped
-
-lex.%.c: %.l
- flex -L -P$(notdir $*) -o$@ $<
- cp $@ $@_shipped
-
-%.hash.c: %.gperf
- gperf < $< > $@
- cp $@ $@_shipped
-
-endif
diff --git a/extra/config/README.uClibc b/extra/config/README.uClibc
index fa1a0018f..0dcba9c7c 100644
--- a/extra/config/README.uClibc
+++ b/extra/config/README.uClibc
@@ -5,8 +5,9 @@ To update:
cd extra/config.new
cp /usr/src/linux/Documentation/kbuild/kconfig-language.txt .
mv Makefile Makefile.kconfig
- patch -p1 < ../config/kconfig-to-uclibc.patch
+ tar -O -xzf ../config/kconfig-to-uclibc.tar.gz | patch -p3
cp ../config/README.uClibc .
+ cp ../config/Makefile .
cd ..
rm -rf config
mv config.new config
diff --git a/extra/config/check.sh b/extra/config/check.sh
index fa59cbf9d..854d9c7c6 100755
--- a/extra/config/check.sh
+++ b/extra/config/check.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Needed for systems without gettext
-$* -xc -o /dev/null - > /dev/null 2>&1 << EOF
+$* -x c -o /dev/null - > /dev/null 2>&1 << EOF
#include <libintl.h>
int main()
{
diff --git a/extra/config/conf.c b/extra/config/conf.c
index 6735bfe76..34bb4f587 100644
--- a/extra/config/conf.c
+++ b/extra/config/conf.c
@@ -5,45 +5,53 @@
#include <locale.h>
#include <ctype.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <sys/time.h>
+#include <errno.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
static void conf(struct menu *menu);
static void check_conf(struct menu *menu);
-
-enum {
- ask_all,
- ask_new,
- ask_silent,
- set_default,
- set_yes,
- set_mod,
- set_no,
- set_random
-} input_mode = ask_all;
-char *defconfig_file;
+static void xfgets(char *str, int size, FILE *in);
+
+enum input_mode {
+ oldaskconfig,
+ silentoldconfig,
+ oldconfig,
+ allnoconfig,
+ allyesconfig,
+ allmodconfig,
+ alldefconfig,
+ randconfig,
+ defconfig,
+ savedefconfig,
+ listnewconfig,
+ olddefconfig,
+} input_mode = oldaskconfig;
static int indent = 1;
+static int tty_stdio;
static int valid_stdin = 1;
+static int sync_kconfig;
static int conf_cnt;
-static char line[128];
+static char line[PATH_MAX];
static struct menu *rootEntry;
-static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
-
-static const char *get_help(struct menu *menu)
+static void print_help(struct menu *menu)
{
- if (menu_has_help(menu))
- return _(menu_get_help(menu));
- else
- return nohelp_text;
+ struct gstr help = str_new();
+
+ menu_get_ext_help(menu, &help);
+
+ printf("\n%s\n", str_get(&help));
+ str_free(&help);
}
static void strip(char *str)
@@ -65,7 +73,7 @@ static void strip(char *str)
static void check_stdin(void)
{
- if (!valid_stdin && input_mode == ask_silent) {
+ if (!valid_stdin) {
printf(_("aborted!\n\n"));
printf(_("Console input/output is redirected. "));
printf(_("Run 'make oldconfig' to update configuration.\n\n"));
@@ -76,7 +84,6 @@ static void check_stdin(void)
static int conf_askvalue(struct symbol *sym, const char *def)
{
enum symbol_type type = sym_get_type(sym);
- tristate val;
if (!sym_has_value(sym))
printf(_("(NEW) "));
@@ -92,28 +99,19 @@ static int conf_askvalue(struct symbol *sym, const char *def)
}
switch (input_mode) {
- case set_no:
- case set_mod:
- case set_yes:
- case set_random:
- if (sym_has_value(sym)) {
- printf("%s\n", def);
- return 0;
- }
- break;
- case ask_new:
- case ask_silent:
+ case oldconfig:
+ case silentoldconfig:
if (sym_has_value(sym)) {
printf("%s\n", def);
return 0;
}
check_stdin();
- case ask_all:
+ /* fall through */
+ case oldaskconfig:
fflush(stdout);
- fgets(line, 128, stdin);
- return 1;
- case set_default:
- printf("%s\n", def);
+ xfgets(line, sizeof(line), stdin);
+ if (!tty_stdio)
+ printf("\n");
return 1;
default:
break;
@@ -128,57 +126,11 @@ static int conf_askvalue(struct symbol *sym, const char *def)
default:
;
}
- switch (input_mode) {
- case set_yes:
- if (sym_tristate_within_range(sym, yes)) {
- line[0] = 'y';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- case set_mod:
- if (type == S_TRISTATE) {
- if (sym_tristate_within_range(sym, mod)) {
- line[0] = 'm';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- } else {
- if (sym_tristate_within_range(sym, yes)) {
- line[0] = 'y';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- }
- case set_no:
- if (sym_tristate_within_range(sym, no)) {
- line[0] = 'n';
- line[1] = '\n';
- line[2] = 0;
- break;
- }
- case set_random:
- do {
- val = (tristate)(rand() % 3);
- } while (!sym_tristate_within_range(sym, val));
- switch (val) {
- case no: line[0] = 'n'; break;
- case mod: line[0] = 'm'; break;
- case yes: line[0] = 'y'; break;
- }
- line[1] = '\n';
- line[2] = 0;
- break;
- default:
- break;
- }
printf("%s", line);
return 1;
}
-int conf_string(struct menu *menu)
+static int conf_string(struct menu *menu)
{
struct symbol *sym = menu->sym;
const char *def;
@@ -197,10 +149,11 @@ int conf_string(struct menu *menu)
case '?':
/* print help */
if (line[1] == '\n') {
- printf("\n%s\n", get_help(menu));
+ print_help(menu);
def = NULL;
break;
}
+ /* fall through */
default:
line[strlen(line)-1] = 0;
def = line;
@@ -213,14 +166,12 @@ int conf_string(struct menu *menu)
static int conf_sym(struct menu *menu)
{
struct symbol *sym = menu->sym;
- int type;
tristate oldval, newval;
while (1) {
printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
if (sym->name)
printf("(%s) ", sym->name);
- type = sym_get_type(sym);
putchar('[');
oldval = sym_get_tristate_value(sym);
switch (oldval) {
@@ -277,7 +228,7 @@ static int conf_sym(struct menu *menu)
if (sym_set_tristate_value(sym, newval))
return 0;
help:
- printf("\n%s\n", get_help(menu));
+ print_help(menu);
}
}
@@ -285,11 +236,9 @@ static int conf_choice(struct menu *menu)
{
struct symbol *sym, *def_sym;
struct menu *child;
- int type;
bool is_new;
sym = menu->sym;
- type = sym_get_type(sym);
is_new = !sym_has_value(sym);
if (sym_is_changable(sym)) {
conf_sym(menu);
@@ -351,20 +300,21 @@ static int conf_choice(struct menu *menu)
printf("?");
printf("]: ");
switch (input_mode) {
- case ask_new:
- case ask_silent:
+ case oldconfig:
+ case silentoldconfig:
if (!is_new) {
cnt = def;
printf("%d\n", cnt);
break;
}
check_stdin();
- case ask_all:
+ /* fall through */
+ case oldaskconfig:
fflush(stdout);
- fgets(line, 128, stdin);
+ xfgets(line, sizeof(line), stdin);
strip(line);
if (line[0] == '?') {
- printf("\n%s\n", get_help(menu));
+ print_help(menu);
continue;
}
if (!line[0])
@@ -374,15 +324,7 @@ static int conf_choice(struct menu *menu)
else
continue;
break;
- case set_random:
- if (is_new)
- def = (rand() % cnt) + 1;
- case set_default:
- case set_yes:
- case set_mod:
- case set_no:
- cnt = def;
- printf("%d\n", cnt);
+ default:
break;
}
@@ -395,8 +337,8 @@ static int conf_choice(struct menu *menu)
}
if (!child)
continue;
- if (line[strlen(line) - 1] == '?') {
- printf("\n%s\n", get_help(child));
+ if (line[0] && line[strlen(line) - 1] == '?') {
+ print_help(child);
continue;
}
sym_set_choice_value(sym, child->sym);
@@ -425,10 +367,14 @@ static void conf(struct menu *menu)
switch (prop->type) {
case P_MENU:
- if (input_mode == ask_silent && rootEntry != menu) {
+ if ((input_mode == silentoldconfig ||
+ input_mode == listnewconfig ||
+ input_mode == olddefconfig) &&
+ rootEntry != menu) {
check_conf(menu);
return;
}
+ /* fall through */
case P_COMMENT:
prompt = menu_get_prompt(menu);
if (prompt)
@@ -483,10 +429,16 @@ static void check_conf(struct menu *menu)
if (sym && !sym_has_value(sym)) {
if (sym_is_changable(sym) ||
(sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
- if (!conf_cnt++)
- printf(_("*\n* Restart config...\n*\n"));
- rootEntry = menu_get_parent_menu(menu);
- conf(rootEntry);
+ if (input_mode == listnewconfig) {
+ if (sym->name && !sym_is_choice_value(sym)) {
+ printf("%s%s\n", CONFIG_, sym->name);
+ }
+ } else if (input_mode != olddefconfig) {
+ if (!conf_cnt++)
+ printf(_("*\n* Restart config...\n*\n"));
+ rootEntry = menu_get_parent_menu(menu);
+ conf(rootEntry);
+ }
}
}
@@ -494,63 +446,170 @@ static void check_conf(struct menu *menu)
check_conf(child);
}
+#if 00 // || !defined __UCLIBC__ || \
+ defined __UCLIBC_HAS_GETOPT_LONG__
+static struct option long_opts[] = {
+ {"oldaskconfig", no_argument, NULL, oldaskconfig},
+ {"oldconfig", no_argument, NULL, oldconfig},
+ {"silentoldconfig", no_argument, NULL, silentoldconfig},
+ {"defconfig", optional_argument, NULL, defconfig},
+ {"savedefconfig", required_argument, NULL, savedefconfig},
+ {"allnoconfig", no_argument, NULL, allnoconfig},
+ {"allyesconfig", no_argument, NULL, allyesconfig},
+ {"allmodconfig", no_argument, NULL, allmodconfig},
+ {"alldefconfig", no_argument, NULL, alldefconfig},
+ {"randconfig", no_argument, NULL, randconfig},
+ {"listnewconfig", no_argument, NULL, listnewconfig},
+ {"olddefconfig", no_argument, NULL, olddefconfig},
+ /*
+ * oldnoconfig is an alias of olddefconfig, because people already
+ * are dependent on its behavior(sets new symbols to their default
+ * value but not 'n') with the counter-intuitive name.
+ */
+ {"oldnoconfig", no_argument, NULL, olddefconfig},
+ {NULL, 0, NULL, 0}
+};
+
+static void conf_usage(const char *progname)
+{
+
+ printf("Usage: %s [option] <kconfig-file>\n", progname);
+ printf("[option] is _one_ of the following:\n");
+ printf(" --listnewconfig List new options\n");
+ printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
+ printf(" --oldconfig Update a configuration using a provided .config as base\n");
+ printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n");
+ printf(" --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n");
+ printf(" --oldnoconfig An alias of olddefconfig\n");
+ printf(" --defconfig <file> New config with default defined in <file>\n");
+ printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n");
+ printf(" --allnoconfig New config where all options are answered with no\n");
+ printf(" --allyesconfig New config where all options are answered with yes\n");
+ printf(" --allmodconfig New config where all options are answered with mod\n");
+ printf(" --alldefconfig New config with all symbols set to default\n");
+ printf(" --randconfig New config with random answer to all options\n");
+}
+#else
+static void conf_usage(const char *progname)
+{
+
+ printf("Usage: %s [option] <kconfig-file>\n", progname);
+ printf("[option] is _one_ of the following:\n");
+ printf(" -a, --oldaskconfig Start a new configuration using a line-oriented program\n");
+ printf(" -s, --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n");
+ printf(" -o, --oldconfig Update a configuration using a provided .config as base\n");
+ printf(" -n, --allnoconfig New config where all options are answered with no\n");
+ printf(" -y, --allyesconfig New config where all options are answered with yes\n");
+ printf(" -m, --allmodconfig New config where all options are answered with mod\n");
+ printf(" -A, --alldefconfig New config with all symbols set to default\n");
+ printf(" -r, --randconfig New config with random answer to all options\n");
+ printf(" -D, --defconfig <file> New config with default defined in <file>\n");
+ printf(" -S, --savedefconfig <file> Save the minimal current configuration to <file>\n");
+ printf(" -l, --listnewconfig List new options\n");
+ printf(" -d, --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n");
+ printf(" --oldnoconfig An alias of olddefconfig\n");
+
+}
+#endif
+
int main(int ac, char **av)
{
+ const char *progname = av[0];
int opt;
- const char *name;
+ const char *name, *defconfig_file = NULL /* gcc uninit */;
struct stat tmpstat;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
+ tty_stdio = isatty(0) && isatty(1) && isatty(2);
+
+#if 00// !defined __UCLIBC__ || \
+ defined __UCLIBC_HAS_GETOPT_LONG__
+ while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1)
+#else
+ char *gch = "asonymArDSld";
+ while ((opt = getopt(ac, av, "asonymArD:S:ldh")) != -1)
+#endif
+ {
+ char *x = memchr(gch, opt, strlen(gch));
+ if (x == NULL)
+ opt = '?';
+ else
+ opt = x - gch;
+ input_mode = (enum input_mode)opt;
switch (opt) {
- case 'o':
- input_mode = ask_new;
- break;
- case 's':
- input_mode = ask_silent;
- valid_stdin = isatty(0) && isatty(1) && isatty(2);
- break;
- case 'd':
- input_mode = set_default;
+ case silentoldconfig:
+ sync_kconfig = 1;
break;
- case 'D':
- input_mode = set_default;
+ case defconfig:
+ case savedefconfig:
defconfig_file = optarg;
break;
- case 'n':
- input_mode = set_no;
- break;
- case 'm':
- input_mode = set_mod;
- break;
- case 'y':
- input_mode = set_yes;
- break;
- case 'r':
- input_mode = set_random;
- srand(time(NULL));
+ case randconfig:
+ {
+ struct timeval now;
+ unsigned int seed;
+ char *seed_env;
+
+ /*
+ * Use microseconds derived seed,
+ * compensate for systems where it may be zero
+ */
+ gettimeofday(&now, NULL);
+ seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
+
+ seed_env = getenv("KCONFIG_SEED");
+ if( seed_env && *seed_env ) {
+ char *endp;
+ int tmp = (int)strtol(seed_env, &endp, 0);
+ if (*endp == '\0') {
+ seed = tmp;
+ }
+ }
+ fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed );
+ srand(seed);
break;
- case 'h':
- printf(_("See README for usage info\n"));
- exit(0);
+ }
+ case oldaskconfig:
+ case oldconfig:
+ case allnoconfig:
+ case allyesconfig:
+ case allmodconfig:
+ case alldefconfig:
+ case listnewconfig:
+ case olddefconfig:
break;
- default:
- fprintf(stderr, _("See README for usage info\n"));
+ case '?':
+ conf_usage(progname);
exit(1);
+ break;
}
}
if (ac == optind) {
printf(_("%s: Kconfig file missing\n"), av[0]);
+ conf_usage(progname);
exit(1);
}
name = av[optind];
conf_parse(name);
//zconfdump(stdout);
+ if (sync_kconfig) {
+ name = conf_get_configname();
+ if (stat(name, &tmpstat)) {
+ fprintf(stderr, _("***\n"
+ "*** Configuration file \"%s\" not found!\n"
+ "***\n"
+ "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
+ "*** \"make menuconfig\" or \"make xconfig\").\n"
+ "***\n"), name);
+ exit(1);
+ }
+ }
+
switch (input_mode) {
- case set_default:
+ case defconfig:
if (!defconfig_file)
defconfig_file = conf_get_default_confname();
if (conf_read(defconfig_file)) {
@@ -560,75 +619,136 @@ int main(int ac, char **av)
exit(1);
}
break;
- case ask_silent:
- if (stat(".config", &tmpstat)) {
- printf(_("***\n"
- "*** You have not yet configured!\n"
- "*** (missing .config file)\n"
- "***\n"
- "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
- "*** \"make menuconfig\" or \"make xconfig\").\n"
- "***\n"));
- exit(1);
- }
- case ask_all:
- case ask_new:
+ case savedefconfig:
+ case silentoldconfig:
+ case oldaskconfig:
+ case oldconfig:
+ case listnewconfig:
+ case olddefconfig:
conf_read(NULL);
break;
- case set_no:
- case set_mod:
- case set_yes:
- case set_random:
+ case allnoconfig:
+ case allyesconfig:
+ case allmodconfig:
+ case alldefconfig:
+ case randconfig:
name = getenv("KCONFIG_ALLCONFIG");
- if (name && !stat(name, &tmpstat)) {
- conf_read_simple(name, S_DEF_USER);
+ if (!name)
+ break;
+ if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) {
+ if (conf_read_simple(name, S_DEF_USER)) {
+ fprintf(stderr,
+ _("*** Can't read seed configuration \"%s\"!\n"),
+ name);
+ exit(1);
+ }
break;
}
switch (input_mode) {
- case set_no: name = "allno.config"; break;
- case set_mod: name = "allmod.config"; break;
- case set_yes: name = "allyes.config"; break;
- case set_random: name = "allrandom.config"; break;
+ case allnoconfig: name = "allno.config"; break;
+ case allyesconfig: name = "allyes.config"; break;
+ case allmodconfig: name = "allmod.config"; break;
+ case alldefconfig: name = "alldef.config"; break;
+ case randconfig: name = "allrandom.config"; break;
default: break;
}
- if (!stat(name, &tmpstat))
- conf_read_simple(name, S_DEF_USER);
- else if (!stat("all.config", &tmpstat))
- conf_read_simple("all.config", S_DEF_USER);
+ if (conf_read_simple(name, S_DEF_USER) &&
+ conf_read_simple("all.config", S_DEF_USER)) {
+ fprintf(stderr,
+ _("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"),
+ name);
+ exit(1);
+ }
break;
default:
break;
}
- if (input_mode != ask_silent) {
+ if (sync_kconfig) {
+ if (conf_get_changed()) {
+ name = getenv("KCONFIG_NOSILENTUPDATE");
+ if (name && *name) {
+ fprintf(stderr,
+ _("\n*** The configuration requires explicit update.\n\n"));
+ return 1;
+ }
+ }
+ valid_stdin = tty_stdio;
+ }
+
+ switch (input_mode) {
+ case allnoconfig:
+ conf_set_all_new_symbols(def_no);
+ break;
+ case allyesconfig:
+ conf_set_all_new_symbols(def_yes);
+ break;
+ case allmodconfig:
+ conf_set_all_new_symbols(def_mod);
+ break;
+ case alldefconfig:
+ conf_set_all_new_symbols(def_default);
+ break;
+ case randconfig:
+ /* Really nothing to do in this loop */
+ while (conf_set_all_new_symbols(def_random)) ;
+ break;
+ case defconfig:
+ conf_set_all_new_symbols(def_default);
+ break;
+ case savedefconfig:
+ break;
+ case oldaskconfig:
rootEntry = &rootmenu;
conf(&rootmenu);
- if (input_mode == ask_all) {
- input_mode = ask_silent;
- valid_stdin = 1;
+ input_mode = silentoldconfig;
+ /* fall through */
+ case oldconfig:
+ case listnewconfig:
+ case olddefconfig:
+ case silentoldconfig:
+ /* Update until a loop caused no more changes */
+ do {
+ conf_cnt = 0;
+ check_conf(&rootmenu);
+ } while (conf_cnt &&
+ (input_mode != listnewconfig &&
+ input_mode != olddefconfig));
+ break;
+ }
+
+ if (sync_kconfig) {
+ /* silentoldconfig is used during the build so we shall update autoconf.
+ * All other commands are only used to generate a config.
+ */
+ if (conf_get_changed() && conf_write(NULL)) {
+ fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
+ exit(1);
}
- } else if (conf_get_changed()) {
- name = getenv("KCONFIG_NOSILENTUPDATE");
- if (name && *name) {
- fprintf(stderr, _("\n*** configuration requires explicit update.\n\n"));
+ if (conf_write_autoconf()) {
+ fprintf(stderr, _("\n*** Error during update of the configuration.\n\n"));
return 1;
}
- } else
- goto skip_check;
-
- do {
- conf_cnt = 0;
- check_conf(&rootmenu);
- } while (conf_cnt);
- if (conf_write(NULL)) {
- fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
- return 1;
- }
-skip_check:
- if (/*input_mode == ask_silent &&*/ conf_write_autoconf()) {
- fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
- return 1;
+ } else if (input_mode == savedefconfig) {
+ if (conf_write_defconfig(defconfig_file)) {
+ fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
+ defconfig_file);
+ return 1;
+ }
+ } else if (input_mode != listnewconfig) {
+ if (conf_write(NULL)) {
+ fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
+ exit(1);
+ }
}
-
return 0;
}
+
+/*
+ * Helper function to facilitate fgets() by Jean Sacren.
+ */
+void xfgets(char *str, int size, FILE *in)
+{
+ if (fgets(str, size, in) == NULL)
+ fprintf(stderr, "\nError in reading or end of file.\n");
+}
diff --git a/extra/config/confdata.c b/extra/config/confdata.c
index 59a2fec78..94c63c0e8 100644
--- a/extra/config/confdata.c
+++ b/extra/config/confdata.c
@@ -5,23 +5,27 @@
#include <sys/stat.h>
#include <ctype.h>
+#include <errno.h>
#include <fcntl.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
static void conf_warning(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2)));
+static void conf_message(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
static const char *conf_filename;
static int conf_lineno, conf_warnings, conf_unsaved;
-const char conf_defname[] = "extra/Configs/defconfigs/$ARCH";
+const char conf_defname[] = "arch/$ARCH/defconfig";
static void conf_warning(const char *fmt, ...)
{
@@ -34,6 +38,29 @@ static void conf_warning(const char *fmt, ...)
conf_warnings++;
}
+static void conf_default_message_callback(const char *fmt, va_list ap)
+{
+ printf("#\n# ");
+ vprintf(fmt, ap);
+ printf("\n#\n");
+}
+
+static void (*conf_message_callback) (const char *fmt, va_list ap) =
+ conf_default_message_callback;
+void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap))
+{
+ conf_message_callback = fn;
+}
+
+static void conf_message(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ if (conf_message_callback)
+ conf_message_callback(fmt, ap);
+}
+
const char *conf_get_configname(void)
{
char *name = getenv("KCONFIG_CONFIG");
@@ -41,6 +68,13 @@ const char *conf_get_configname(void)
return name ? name : ".config";
}
+const char *conf_get_autoconfig_name(void)
+{
+ char *name = getenv("KCONFIG_AUTOCONFIG");
+
+ return name ? name : "include/config/auto.conf";
+}
+
static char *conf_expand_value(const char *in)
{
struct symbol *sym;
@@ -94,6 +128,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
sym->flags |= def_flags;
break;
}
+ /* fall through */
case S_BOOLEAN:
if (p[0] == 'y') {
sym->def[def].tri = yes;
@@ -106,7 +141,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
break;
}
conf_warning("symbol value '%s' invalid for %s", p, sym->name);
- break;
+ return 1;
case S_OTHER:
if (*p != '"') {
for (p2 = p; *p2 && !isspace(*p2); p2++)
@@ -114,6 +149,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
sym->type = S_STRING;
goto done;
}
+ /* fall through */
case S_STRING:
if (*p++ != '"')
break;
@@ -128,6 +164,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
conf_warning("invalid string found");
return 1;
}
+ /* fall through */
case S_INT:
case S_HEX:
done:
@@ -145,10 +182,66 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
return 0;
}
+#define LINE_GROWTH 16
+static int add_byte(int c, char **lineptr, size_t slen, size_t *n)
+{
+ char *nline;
+ size_t new_size = slen + 1;
+ if (new_size > *n) {
+ new_size += LINE_GROWTH - 1;
+ new_size *= 2;
+ nline = realloc(*lineptr, new_size);
+ if (!nline)
+ return -1;
+
+ *lineptr = nline;
+ *n = new_size;
+ }
+
+ (*lineptr)[slen] = c;
+
+ return 0;
+}
+
+static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream)
+{
+ char *line = *lineptr;
+ size_t slen = 0;
+
+ for (;;) {
+ int c = getc(stream);
+
+ switch (c) {
+ case '\n':
+ if (add_byte(c, &line, slen, n) < 0)
+ goto e_out;
+ slen++;
+ /* fall through */
+ case EOF:
+ if (add_byte('\0', &line, slen, n) < 0)
+ goto e_out;
+ *lineptr = line;
+ if (slen == 0)
+ return -1;
+ return slen;
+ default:
+ if (add_byte(c, &line, slen, n) < 0)
+ goto e_out;
+ slen++;
+ }
+ }
+
+e_out:
+ line[slen-1] = '\0';
+ *lineptr = line;
+ return -1;
+}
+
int conf_read_simple(const char *name, int def)
{
FILE *in = NULL;
- char line[1024];
+ char *line = NULL;
+ size_t line_asize = 0;
char *p, *p2;
struct symbol *sym;
int i, def_flags;
@@ -163,8 +256,11 @@ int conf_read_simple(const char *name, int def)
if (in)
goto load;
sym_add_change_count(1);
- if (!sym_defconfig_list)
+ if (!sym_defconfig_list) {
+ if (modules_sym)
+ sym_calc_value(modules_sym);
return 1;
+ }
for_all_defaults(sym_defconfig_list, prop) {
if (expr_calc_value(prop->visible.expr) == no ||
@@ -173,9 +269,8 @@ int conf_read_simple(const char *name, int def)
name = conf_expand_value(prop->expr->left.sym->name);
in = zconf_fopen(name);
if (in) {
- printf(_("#\n"
- "# using defaults found in %s\n"
- "#\n"), name);
+ conf_message(_("using defaults found in %s"),
+ name);
goto load;
}
}
@@ -201,33 +296,33 @@ load:
case S_STRING:
if (sym->def[def].val)
free(sym->def[def].val);
+ /* fall through */
default:
sym->def[def].val = NULL;
sym->def[def].tri = no;
}
}
- while (fgets(line, sizeof(line), in)) {
+ while (compat_getline(&line, &line_asize, in) != -1) {
conf_lineno++;
sym = NULL;
- switch (line[0]) {
- case '#':
- if (line[1]!=' ')
+ if (line[0] == '#') {
+ if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
continue;
- p = strchr(line + 2, ' ');
+ p = strchr(line + 2 + strlen(CONFIG_), ' ');
if (!p)
continue;
*p++ = 0;
if (strncmp(p, "is not set", 10))
continue;
if (def == S_DEF_USER) {
- sym = sym_find(line + 2);
+ sym = sym_find(line + 2 + strlen(CONFIG_));
if (!sym) {
- conf_warning("trying to assign nonexistent symbol %s", line + 2);
- break;
+ sym_add_change_count(1);
+ goto setsym;
}
} else {
- sym = sym_lookup(line + 2, 0);
+ sym = sym_lookup(line + 2 + strlen(CONFIG_), 0);
if (sym->type == S_UNKNOWN)
sym->type = S_BOOLEAN;
}
@@ -243,9 +338,8 @@ load:
default:
;
}
- break;
- case 'A' ... 'Z':
- p = strchr(line, '=');
+ } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
+ p = strchr(line + strlen(CONFIG_), '=');
if (!p)
continue;
*p++ = 0;
@@ -256,13 +350,13 @@ load:
*p2 = 0;
}
if (def == S_DEF_USER) {
- sym = sym_find(line);
+ sym = sym_find(line + strlen(CONFIG_));
if (!sym) {
- conf_warning("trying to assign nonexistent symbol %s", line);
- break;
+ sym_add_change_count(1);
+ goto setsym;
}
} else {
- sym = sym_lookup(line, 0);
+ sym = sym_lookup(line + strlen(CONFIG_), 0);
if (sym->type == S_UNKNOWN)
sym->type = S_OTHER;
}
@@ -271,14 +365,12 @@ load:
}
if (conf_set_sym_val(sym, def, def_flags, p))
continue;
- break;
- case '\r':
- case '\n':
- break;
- default:
- conf_warning("unexpected data");
+ } else {
+ if (line[0] != '\r' && line[0] != '\n')
+ conf_warning("unexpected data");
continue;
}
+setsym:
if (sym && sym_is_choice_value(sym)) {
struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
switch (sym->def[def].tri) {
@@ -299,6 +391,7 @@ load:
cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
}
}
+ free(line);
fclose(in);
if (modules_sym)
@@ -308,10 +401,8 @@ load:
int conf_read(const char *name)
{
- struct symbol *sym, *choice_sym;
- struct property *prop;
- struct expr *e;
- int i, flags;
+ struct symbol *sym;
+ int i;
sym_set_change_count(0);
@@ -321,7 +412,7 @@ int conf_read(const char *name)
for_all_symbols(i, sym) {
sym_calc_value(sym);
if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO))
- goto sym_ok;
+ continue;
if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {
/* check that calculated value agrees with saved value */
switch (sym->type) {
@@ -330,29 +421,18 @@ int conf_read(const char *name)
if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym))
break;
if (!sym_is_choice(sym))
- goto sym_ok;
+ continue;
+ /* fall through */
default:
if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val))
- goto sym_ok;
+ continue;
break;
}
} else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE))
/* no previous value and not saved */
- goto sym_ok;
+ continue;
conf_unsaved++;
/* maybe print value in verbose mode... */
- sym_ok:
- if (!sym_is_choice(sym))
- continue;
- /* The choice symbol only has a set value (and thus is not new)
- * if all its visible childs have values.
- */
- prop = sym_get_choice_prop(sym);
- flags = sym->flags;
- expr_list_for_each_sym(prop->expr, e, choice_sym)
- if (choice_sym->visible != no)
- flags &= choice_sym->flags;
- sym->flags &= flags | ~SYMBOL_DEF_USER;
}
for_all_symbols(i, sym) {
@@ -385,41 +465,300 @@ int conf_read(const char *name)
return 0;
}
+/*
+ * Kconfig configuration printer
+ *
+ * This printer is used when generating the resulting configuration after
+ * kconfig invocation and `defconfig' files. Unset symbol might be omitted by
+ * passing a non-NULL argument to the printer.
+ *
+ */
+static void
+kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+{
+
+ switch (sym->type) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ if (*value == 'n') {
+ bool skip_unset = (arg != NULL);
+
+ if (!skip_unset)
+ fprintf(fp, "# %s%s is not set\n",
+ CONFIG_, sym->name);
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+
+ fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value);
+}
+
+static void
+kconfig_print_comment(FILE *fp, const char *value, void *arg)
+{
+ const char *p = value;
+ size_t l;
+
+ for (;;) {
+ l = strcspn(p, "\n");
+ fprintf(fp, "#");
+ if (l) {
+ fprintf(fp, " ");
+ xfwrite(p, l, 1, fp);
+ p += l;
+ }
+ fprintf(fp, "\n");
+ if (*p++ == '\0')
+ break;
+ }
+}
+
+static struct conf_printer kconfig_printer_cb =
+{
+ .print_symbol = kconfig_print_symbol,
+ .print_comment = kconfig_print_comment,
+};
+
+/*
+ * Header printer
+ *
+ * This printer is used when generating the `include/generated/autoconf.h' file.
+ */
+static void
+header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+{
+
+ switch (sym->type) {
+ case S_BOOLEAN:
+ case S_TRISTATE: {
+ const char *suffix = "";
+
+ switch (*value) {
+ case 'n':
+ break;
+ case 'm':
+ suffix = "_MODULE";
+ /* fall through */
+ default:
+ fprintf(fp, "#define %s%s%s 1\n",
+ CONFIG_, sym->name, suffix);
+ }
+ break;
+ }
+ case S_HEX: {
+ const char *prefix = "";
+
+ if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
+ prefix = "0x";
+ fprintf(fp, "#define %s%s %s%s\n",
+ CONFIG_, sym->name, prefix, value);
+ break;
+ }
+ case S_STRING:
+ case S_INT:
+ fprintf(fp, "#define %s%s %s\n",
+ CONFIG_, sym->name, value);
+ break;
+ default:
+ break;
+ }
+
+}
+
+static void
+header_print_comment(FILE *fp, const char *value, void *arg)
+{
+ const char *p = value;
+ size_t l;
+
+ fprintf(fp, "/*\n");
+ for (;;) {
+ l = strcspn(p, "\n");
+ fprintf(fp, " *");
+ if (l) {
+ fprintf(fp, " ");
+ xfwrite(p, l, 1, fp);
+ p += l;
+ }
+ fprintf(fp, "\n");
+ if (*p++ == '\0')
+ break;
+ }
+ fprintf(fp, " */\n");
+}
+
+static struct conf_printer header_printer_cb =
+{
+ .print_symbol = header_print_symbol,
+ .print_comment = header_print_comment,
+};
+
+/*
+ * Tristate printer
+ *
+ * This printer is used when generating the `include/config/tristate.conf' file.
+ */
+static void
+tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+{
+
+ if (sym->type == S_TRISTATE && *value != 'n')
+ fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value));
+}
+
+static struct conf_printer tristate_printer_cb =
+{
+ .print_symbol = tristate_print_symbol,
+ .print_comment = kconfig_print_comment,
+};
+
+static void conf_write_symbol(FILE *fp, struct symbol *sym,
+ struct conf_printer *printer, void *printer_arg)
+{
+ const char *str;
+
+ switch (sym->type) {
+ case S_OTHER:
+ case S_UNKNOWN:
+ break;
+ case S_STRING:
+ str = sym_get_string_value(sym);
+ str = sym_escape_string_value(str);
+ printer->print_symbol(fp, sym, str, printer_arg);
+ free((void *)str);
+ break;
+ default:
+ str = sym_get_string_value(sym);
+ printer->print_symbol(fp, sym, str, printer_arg);
+ }
+}
+
+static void
+conf_write_heading(FILE *fp, struct conf_printer *printer, void *printer_arg)
+{
+ char buf[256];
+
+ snprintf(buf, sizeof(buf),
+ "\n"
+ "Automatically generated file; DO NOT EDIT.\n"
+ "%s\n",
+ rootmenu.prompt->text);
+
+ printer->print_comment(fp, buf, printer_arg);
+}
+
+/*
+ * Write out a minimal config.
+ * All values that has default values are skipped as this is redundant.
+ */
+int conf_write_defconfig(const char *filename)
+{
+ struct symbol *sym;
+ struct menu *menu;
+ FILE *out;
+
+ out = fopen(filename, "w");
+ if (!out)
+ return 1;
+
+ sym_clear_all_valid();
+
+ /* Traverse all menus to find all relevant symbols */
+ menu = rootmenu.list;
+
+ while (menu != NULL)
+ {
+ sym = menu->sym;
+ if (sym == NULL) {
+ if (!menu_is_visible(menu))
+ goto next_menu;
+ } else if (!sym_is_choice(sym)) {
+ sym_calc_value(sym);
+ if (!(sym->flags & SYMBOL_WRITE))
+ goto next_menu;
+ sym->flags &= ~SYMBOL_WRITE;
+ /* If we cannot change the symbol - skip */
+ if (!sym_is_changable(sym))
+ goto next_menu;
+ /* If symbol equals to default value - skip */
+ if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0)
+ goto next_menu;
+
+ /*
+ * If symbol is a choice value and equals to the
+ * default for a choice - skip.
+ * But only if value is bool and equal to "y" and
+ * choice is not "optional".
+ * (If choice is "optional" then all values can be "n")
+ */
+ if (sym_is_choice_value(sym)) {
+ struct symbol *cs;
+ struct symbol *ds;
+
+ cs = prop_get_symbol(sym_get_choice_prop(sym));
+ ds = sym_choice_default(cs);
+ if (!sym_is_optional(cs) && sym == ds) {
+ if ((sym->type == S_BOOLEAN) &&
+ sym_get_tristate_value(sym) == yes)
+ goto next_menu;
+ }
+ }
+ conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
+ }
+next_menu:
+ if (menu->list != NULL) {
+ menu = menu->list;
+ }
+ else if (menu->next != NULL) {
+ menu = menu->next;
+ } else {
+ while ((menu = menu->parent)) {
+ if (menu->next != NULL) {
+ menu = menu->next;
+ break;
+ }
+ }
+ }
+ }
+ fclose(out);
+ return 0;
+}
+
int conf_write(const char *name)
{
FILE *out;
struct symbol *sym;
struct menu *menu;
const char *basename;
- char dirname[128], tmpname[128], newname[128];
- int type, l;
const char *str;
- time_t now;
- int use_timestamp = 1;
- char *env;
+ char tmpname[PATH_MAX+1], newname[PATH_MAX+1];
+ char *env, *dirname = NULL;
- dirname[0] = 0;
if (name && name[0]) {
struct stat st;
char *slash;
if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
- strcpy(dirname, name);
+ dirname = strndup(name, strlen(name) + 1);
strcat(dirname, "/");
basename = conf_get_configname();
} else if ((slash = strrchr(name, '/'))) {
int size = slash - name + 1;
- memcpy(dirname, name, size);
- dirname[size] = 0;
+ dirname = strndup(name, size);
if (slash[1])
basename = slash + 1;
else
basename = conf_get_configname();
} else
basename = name;
- } else
- basename = conf_get_configname();
-
+ } else {
+ dirname = strdup(conf_get_configname());
+ basename = strdup(base_name(dirname));
+ dirname = dir_name(dirname);
+ }
sprintf(newname, "%s%s", dirname, basename);
env = getenv("KCONFIG_OVERWRITECONFIG");
if (!env || !*env) {
@@ -429,22 +768,11 @@ int conf_write(const char *name)
*tmpname = 0;
out = fopen(newname, "w");
}
+ free(dirname);
if (!out)
return 1;
- sym = sym_lookup("VERSION", 0);
- sym_calc_value(sym);
- time(&now);
- env = getenv("KCONFIG_NOTIMESTAMP");
- if (env && *env)
- use_timestamp = 0;
-
- fprintf(out, _("#\n"
- "# Automatically generated make config: don't edit\n"
- "%s%s"
- "#\n"),
- use_timestamp ? "# " : "",
- use_timestamp ? ctime(&now) : "");
+ conf_write_heading(out, &kconfig_printer_cb, NULL);
if (!conf_get_changed())
sym_clear_all_valid();
@@ -465,56 +793,11 @@ int conf_write(const char *name)
if (!(sym->flags & SYMBOL_WRITE))
goto next;
sym->flags &= ~SYMBOL_WRITE;
- type = sym->type;
- if (type == S_TRISTATE) {
- sym_calc_value(modules_sym);
- if (modules_sym->curr.tri == no)
- type = S_BOOLEAN;
- }
- switch (type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- switch (sym_get_tristate_value(sym)) {
- case no:
- fprintf(out, "# %s is not set\n", sym->name);
- break;
- case mod:
- fprintf(out, "%s=m\n", sym->name);
- break;
- case yes:
- fprintf(out, "%s=y\n", sym->name);
- break;
- }
- break;
- case S_STRING:
- str = sym_get_string_value(sym);
- fprintf(out, "%s=\"", sym->name);
- while (1) {
- l = strcspn(str, "\"\\");
- if (l) {
- fwrite(str, l, 1, out);
- str += l;
- }
- if (!*str)
- break;
- fprintf(out, "\\%c", *str++);
- }
- fputs("\"\n", out);
- break;
- case S_HEX:
- str = sym_get_string_value(sym);
- if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
- fprintf(out, "%s=%s\n", sym->name, str);
- break;
- }
- case S_INT:
- str = sym_get_string_value(sym);
- fprintf(out, "%s=%s\n", sym->name, str);
- break;
- }
+
+ conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
}
- next:
+next:
if (menu->list) {
menu = menu->list;
continue;
@@ -531,36 +814,40 @@ int conf_write(const char *name)
fclose(out);
if (*tmpname) {
- strcat(dirname, basename);
+ dirname = malloc(strlen(basename) + 4 + 1);
+ strcpy(dirname, basename);
strcat(dirname, ".old");
rename(newname, dirname);
+ free(dirname);
if (rename(tmpname, newname))
return 1;
}
- printf(_("#\n"
- "# configuration written to %s\n"
- "#\n"), newname);
+ conf_message(_("configuration written to %s"), newname);
sym_set_change_count(0);
return 0;
}
-int conf_split_config(void)
+static int conf_split_config(void)
{
- char *name, path[128];
+ const char *name;
+ char path[PATH_MAX+1], opwd[PATH_MAX+1];
char *s, *d, c;
struct symbol *sym;
struct stat sb;
int res, i, fd;
- name = getenv("KCONFIG_AUTOCONFIG");
- if (!name)
- name = "include/config/auto.conf";
+ if (getcwd(opwd, sizeof(opwd)) == NULL)
+ return 1;
+ name = conf_get_autoconfig_name();
conf_read_simple(name, S_DEF_AUTO);
- if (chdir("include/config"))
+ strcpy(path, name);
+ dir_name(path);
+
+ if (chdir(path))
return 1;
res = 0;
@@ -654,7 +941,7 @@ int conf_split_config(void)
close(fd);
}
out:
- if (chdir("../.."))
+ if (chdir(opwd))
return 1;
return res;
@@ -663,117 +950,82 @@ out:
int conf_write_autoconf(void)
{
struct symbol *sym;
- const char *str;
- char *name;
- FILE *out, *out_h;
- time_t now;
- int i, l;
-
- return 0;
+ const char *name;
+ char cfg_fname[PATH_MAX+1], tristate_fname[PATH_MAX+1],
+ cfgh_fname[PATH_MAX+1];
+ char *dirname;
+ FILE *out, *tristate, *out_h;
+ int i;
sym_clear_all_valid();
- file_write_dep("include/config/auto.conf.cmd");
+ sprintf(cfg_fname, "%s.cmd", conf_get_autoconfig_name());
+ file_write_dep(cfg_fname);
if (conf_split_config())
return 1;
- out = fopen(".tmpconfig", "w");
+ dirname = dir_name(strdup(conf_get_configname()));
+ sprintf(cfg_fname, "%s.tmpconfig", dirname);
+ sprintf(tristate_fname, "%s.tmpconfig_tristate", dirname);
+ sprintf(cfgh_fname, "%s.tmpconfig.h", dirname);
+ free(dirname);
+
+ out = fopen(cfg_fname, "w");
if (!out)
return 1;
- out_h = fopen(".tmpconfig.h", "w");
+ tristate = fopen(tristate_fname, "w");
+ if (!tristate) {
+ fclose(out);
+ return 1;
+ }
+
+ out_h = fopen(cfgh_fname, "w");
if (!out_h) {
fclose(out);
+ fclose(tristate);
return 1;
}
- sym = sym_lookup("VERSION", 0);
- sym_calc_value(sym);
- time(&now);
- fprintf(out, "#\n"
- "# Automatically generated make config: don't edit\n"
- "# %s"
- "#\n",
- ctime(&now));
- fprintf(out_h, "/*\n"
- " * Automatically generated C config: don't edit\n"
- " * %s"
- " */\n",
- ctime(&now));
+ conf_write_heading(out, &kconfig_printer_cb, NULL);
+
+ conf_write_heading(tristate, &tristate_printer_cb, NULL);
+
+ conf_write_heading(out_h, &header_printer_cb, NULL);
for_all_symbols(i, sym) {
sym_calc_value(sym);
if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
continue;
- switch (sym->type) {
- case S_BOOLEAN:
- case S_TRISTATE:
- switch (sym_get_tristate_value(sym)) {
- case no:
- break;
- case mod:
- fprintf(out, "%s=m\n", sym->name);
- fprintf(out_h, "#define %s_MODULE 1\n", sym->name);
- break;
- case yes:
- fprintf(out, "%s=y\n", sym->name);
- fprintf(out_h, "#define %s 1\n", sym->name);
- break;
- }
- break;
- case S_STRING:
- str = sym_get_string_value(sym);
- fprintf(out, "%s=\"", sym->name);
- fprintf(out_h, "#define %s \"", sym->name);
- while (1) {
- l = strcspn(str, "\"\\");
- if (l) {
- fwrite(str, l, 1, out);
- fwrite(str, l, 1, out_h);
- str += l;
- }
- if (!*str)
- break;
- fprintf(out, "\\%c", *str);
- fprintf(out_h, "\\%c", *str);
- str++;
- }
- fputs("\"\n", out);
- fputs("\"\n", out_h);
- break;
- case S_HEX:
- str = sym_get_string_value(sym);
- if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
- fprintf(out, "%s=%s\n", sym->name, str);
- fprintf(out_h, "#define %s 0x%s\n", sym->name, str);
- break;
- }
- case S_INT:
- str = sym_get_string_value(sym);
- fprintf(out, "%s=%s\n", sym->name, str);
- fprintf(out_h, "#define %s %s\n", sym->name, str);
- break;
- default:
- break;
- }
+
+ /* write symbol to auto.conf, tristate and header files */
+ conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
+
+ conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
+
+ conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
}
fclose(out);
+ fclose(tristate);
fclose(out_h);
name = getenv("KCONFIG_AUTOHEADER");
if (!name)
- name = "include/linux/autoconf.h";
- if (rename(".tmpconfig.h", name))
+ name = "include/generated/autoconf.h";
+ if (rename(cfgh_fname, name))
return 1;
- name = getenv("KCONFIG_AUTOCONFIG");
+ name = getenv("KCONFIG_TRISTATE");
if (!name)
- name = "include/config/auto.conf";
+ name = "include/config/tristate.conf";
+ if (rename(tristate_fname, name))
+ return 1;
+ name = conf_get_autoconfig_name();
/*
* This must be the last step, kbuild has a dependency on auto.conf
* and this marks the successful completion of the previous steps.
*/
- if (rename(".tmpconfig", name))
+ if (rename(cfg_fname, name))
return 1;
return 0;
@@ -805,3 +1057,196 @@ void conf_set_changed_callback(void (*fn)(void))
{
conf_changed_callback = fn;
}
+
+static bool randomize_choice_values(struct symbol *csym)
+{
+ struct property *prop;
+ struct symbol *sym;
+ struct expr *e;
+ int cnt, def;
+
+ /*
+ * If choice is mod then we may have more items selected
+ * and if no then no-one.
+ * In both cases stop.
+ */
+ if (csym->curr.tri != yes)
+ return false;
+
+ prop = sym_get_choice_prop(csym);
+
+ /* count entries in choice block */
+ cnt = 0;
+ expr_list_for_each_sym(prop->expr, e, sym)
+ cnt++;
+
+ /*
+ * find a random value and set it to yes,
+ * set the rest to no so we have only one set
+ */
+ def = (rand() % cnt);
+
+ cnt = 0;
+ expr_list_for_each_sym(prop->expr, e, sym) {
+ if (def == cnt++) {
+ sym->def[S_DEF_USER].tri = yes;
+ csym->def[S_DEF_USER].val = sym;
+ }
+ else {
+ sym->def[S_DEF_USER].tri = no;
+ }
+ sym->flags |= SYMBOL_DEF_USER;
+ /* clear VALID to get value calculated */
+ sym->flags &= ~SYMBOL_VALID;
+ }
+ csym->flags |= SYMBOL_DEF_USER;
+ /* clear VALID to get value calculated */
+ csym->flags &= ~(SYMBOL_VALID);
+
+ return true;
+}
+
+void set_all_choice_values(struct symbol *csym)
+{
+ struct property *prop;
+ struct symbol *sym;
+ struct expr *e;
+
+ prop = sym_get_choice_prop(csym);
+
+ /*
+ * Set all non-assinged choice values to no
+ */
+ expr_list_for_each_sym(prop->expr, e, sym) {
+ if (!sym_has_value(sym))
+ sym->def[S_DEF_USER].tri = no;
+ }
+ csym->flags |= SYMBOL_DEF_USER;
+ /* clear VALID to get value calculated */
+ csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES);
+}
+
+bool conf_set_all_new_symbols(enum conf_def_mode mode)
+{
+ struct symbol *sym, *csym;
+ int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y
+ * pty: probability of tristate = y
+ * ptm: probability of tristate = m
+ */
+
+ pby = 50; pty = ptm = 33; /* can't go as the default in switch-case
+ * below, otherwise gcc whines about
+ * -Wmaybe-uninitialized */
+ if (mode == def_random) {
+ int n, p[3];
+ char *env = getenv("KCONFIG_PROBABILITY");
+ n = 0;
+ while( env && *env ) {
+ char *endp;
+ int tmp = strtol( env, &endp, 10 );
+ if( tmp >= 0 && tmp <= 100 ) {
+ p[n++] = tmp;
+ } else {
+ errno = ERANGE;
+ perror( "KCONFIG_PROBABILITY" );
+ exit( 1 );
+ }
+ env = (*endp == ':') ? endp+1 : endp;
+ if( n >=3 ) {
+ break;
+ }
+ }
+ switch( n ) {
+ case 1:
+ pby = p[0]; ptm = pby/2; pty = pby-ptm;
+ break;
+ case 2:
+ pty = p[0]; ptm = p[1]; pby = pty + ptm;
+ break;
+ case 3:
+ pby = p[0]; pty = p[1]; ptm = p[2];
+ break;
+ }
+
+ if( pty+ptm > 100 ) {
+ errno = ERANGE;
+ perror( "KCONFIG_PROBABILITY" );
+ exit( 1 );
+ }
+ }
+ bool has_changed = false;
+
+ for_all_symbols(i, sym) {
+ if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID))
+ continue;
+ switch (sym_get_type(sym)) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ has_changed = true;
+ switch (mode) {
+ case def_yes:
+ sym->def[S_DEF_USER].tri = yes;
+ break;
+ case def_mod:
+ sym->def[S_DEF_USER].tri = mod;
+ break;
+ case def_no:
+ sym->def[S_DEF_USER].tri = no;
+ break;
+ case def_random:
+ sym->def[S_DEF_USER].tri = no;
+ cnt = rand() % 100;
+ if (sym->type == S_TRISTATE) {
+ if (cnt < pty)
+ sym->def[S_DEF_USER].tri = yes;
+ else if (cnt < (pty+ptm))
+ sym->def[S_DEF_USER].tri = mod;
+ } else if (cnt < pby)
+ sym->def[S_DEF_USER].tri = yes;
+ break;
+ default:
+ continue;
+ }
+ if (!(sym_is_choice(sym) && mode == def_random))
+ sym->flags |= SYMBOL_DEF_USER;
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ sym_clear_all_valid();
+
+ /*
+ * We have different type of choice blocks.
+ * If curr.tri equals to mod then we can select several
+ * choice symbols in one block.
+ * In this case we do nothing.
+ * If curr.tri equals yes then only one symbol can be
+ * selected in a choice block and we set it to yes,
+ * and the rest to no.
+ */
+ if (mode != def_random) {
+ for_all_symbols(i, csym) {
+ if ((sym_is_choice(csym) && !sym_has_value(csym)) ||
+ sym_is_choice_value(csym))
+ csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES;
+ }
+ }
+
+ for_all_symbols(i, csym) {
+ if (sym_has_value(csym) || !sym_is_choice(csym))
+ continue;
+
+ sym_calc_value(csym);
+ if (mode == def_random)
+ has_changed = randomize_choice_values(csym);
+ else {
+ set_all_choice_values(csym);
+ has_changed = true;
+ }
+ }
+
+ return has_changed;
+}
diff --git a/extra/config/expr.c b/extra/config/expr.c
index 579ece4fa..d6626521f 100644
--- a/extra/config/expr.c
+++ b/extra/config/expr.c
@@ -7,15 +7,13 @@
#include <stdlib.h>
#include <string.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
#define DEBUG_EXPR 0
struct expr *expr_alloc_symbol(struct symbol *sym)
{
- struct expr *e = malloc(sizeof(*e));
- memset(e, 0, sizeof(*e));
+ struct expr *e = xcalloc(1, sizeof(*e));
e->type = E_SYMBOL;
e->left.sym = sym;
return e;
@@ -23,8 +21,7 @@ struct expr *expr_alloc_symbol(struct symbol *sym)
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
{
- struct expr *e = malloc(sizeof(*e));
- memset(e, 0, sizeof(*e));
+ struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.expr = ce;
return e;
@@ -32,8 +29,7 @@ struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2)
{
- struct expr *e = malloc(sizeof(*e));
- memset(e, 0, sizeof(*e));
+ struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.expr = e1;
e->right.expr = e2;
@@ -42,8 +38,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2)
{
- struct expr *e = malloc(sizeof(*e));
- memset(e, 0, sizeof(*e));
+ struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.sym = s1;
e->right.sym = s2;
@@ -64,14 +59,14 @@ struct expr *expr_alloc_or(struct expr *e1, struct expr *e2)
return e2 ? expr_alloc_two(E_OR, e1, e2) : e1;
}
-struct expr *expr_copy(struct expr *org)
+struct expr *expr_copy(const struct expr *org)
{
struct expr *e;
if (!org)
return NULL;
- e = malloc(sizeof(*org));
+ e = xmalloc(sizeof(*org));
memcpy(e, org, sizeof(*org));
switch (org->type) {
case E_SYMBOL:
@@ -348,7 +343,7 @@ struct expr *expr_trans_bool(struct expr *e)
/*
* e1 || e2 -> ?
*/
-struct expr *expr_join_or(struct expr *e1, struct expr *e2)
+static struct expr *expr_join_or(struct expr *e1, struct expr *e2)
{
struct expr *tmp;
struct symbol *sym1, *sym2;
@@ -412,7 +407,7 @@ struct expr *expr_join_or(struct expr *e1, struct expr *e2)
return NULL;
}
-struct expr *expr_join_and(struct expr *e1, struct expr *e2)
+static struct expr *expr_join_and(struct expr *e1, struct expr *e2)
{
struct expr *tmp;
struct symbol *sym1, *sym2;
@@ -1013,6 +1008,48 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
#endif
}
+static inline struct expr *
+expr_get_leftmost_symbol(const struct expr *e)
+{
+
+ if (e == NULL)
+ return NULL;
+
+ while (e->type != E_SYMBOL)
+ e = e->left.expr;
+
+ return expr_copy(e);
+}
+
+/*
+ * Given expression `e1' and `e2', returns the leaf of the longest
+ * sub-expression of `e1' not containing 'e2.
+ */
+struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
+{
+ struct expr *ret;
+
+ switch (e1->type) {
+ case E_OR:
+ return expr_alloc_and(
+ expr_simplify_unmet_dep(e1->left.expr, e2),
+ expr_simplify_unmet_dep(e1->right.expr, e2));
+ case E_AND: {
+ struct expr *e;
+ e = expr_alloc_and(expr_copy(e1), expr_copy(e2));
+ e = expr_eliminate_dups(e);
+ ret = (!expr_eq(e, e1)) ? e1 : NULL;
+ expr_free(e);
+ break;
+ }
+ default:
+ ret = e1;
+ break;
+ }
+
+ return expr_get_leftmost_symbol(ret);
+}
+
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
{
if (!e) {
@@ -1087,7 +1124,7 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
static void expr_print_file_helper(void *data, struct symbol *sym, const char *str)
{
- fwrite(str, strlen(str), 1, data);
+ xfwrite(str, strlen(str), 1, data);
}
void expr_fprint(struct expr *e, FILE *out)
@@ -1097,7 +1134,32 @@ void expr_fprint(struct expr *e, FILE *out)
static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
{
- str_append((struct gstr*)data, str);
+ struct gstr *gs = (struct gstr*)data;
+ const char *sym_str = NULL;
+
+ if (sym)
+ sym_str = sym_get_string_value(sym);
+
+ if (gs->max_width) {
+ unsigned extra_length = strlen(str);
+ const char *last_cr = strrchr(gs->s, '\n');
+ unsigned last_line_length;
+
+ if (sym_str)
+ extra_length += 4 + strlen(sym_str);
+
+ if (!last_cr)
+ last_cr = gs->s;
+
+ last_line_length = strlen(gs->s) - (last_cr - gs->s);
+
+ if ((last_line_length + extra_length) > gs->max_width)
+ str_append(gs, "\\\n");
+ }
+
+ str_append(gs, str);
+ if (sym && sym->type != S_UNKNOWN)
+ str_printf(gs, " [=%s]", sym_str);
}
void expr_gstr_print(struct expr *e, struct gstr *gs)
diff --git a/extra/config/expr.h b/extra/config/expr.h
index 9d60dd330..df198a5f4 100644
--- a/extra/config/expr.h
+++ b/extra/config/expr.h
@@ -10,7 +10,9 @@
extern "C" {
#endif
+#include <assert.h>
#include <stdio.h>
+#include "list.h"
#ifndef __cplusplus
#include <stdbool.h>
#endif
@@ -18,14 +20,10 @@ extern "C" {
struct file {
struct file *next;
struct file *parent;
- char *name;
+ const char *name;
int lineno;
- int flags;
};
-#define FILE_BUSY 0x0001
-#define FILE_SCANNED 0x0002
-
typedef enum tristate {
no, mod, yes
} tristate;
@@ -65,9 +63,13 @@ enum symbol_type {
S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
};
+/* enum values are used as index to symbol.def[] */
enum {
S_DEF_USER, /* main user value */
- S_DEF_AUTO,
+ S_DEF_AUTO, /* values read from auto.conf */
+ S_DEF_DEF3, /* Reserved for UI usage */
+ S_DEF_DEF4, /* Reserved for UI usage */
+ S_DEF_COUNT
};
struct symbol {
@@ -75,51 +77,77 @@ struct symbol {
char *name;
enum symbol_type type;
struct symbol_value curr;
- struct symbol_value def[4];
+ struct symbol_value def[S_DEF_COUNT];
tristate visible;
int flags;
struct property *prop;
+ struct expr_value dir_dep;
struct expr_value rev_dep;
};
-#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
-
-#define SYMBOL_CONST 0x0001
-#define SYMBOL_CHECK 0x0008
-#define SYMBOL_CHOICE 0x0010
-#define SYMBOL_CHOICEVAL 0x0020
-#define SYMBOL_VALID 0x0080
-#define SYMBOL_OPTIONAL 0x0100
-#define SYMBOL_WRITE 0x0200
-#define SYMBOL_CHANGED 0x0400
-#define SYMBOL_AUTO 0x1000
-#define SYMBOL_CHECKED 0x2000
-#define SYMBOL_WARNED 0x8000
-#define SYMBOL_DEF 0x10000
-#define SYMBOL_DEF_USER 0x10000
-#define SYMBOL_DEF_AUTO 0x20000
-#define SYMBOL_DEF3 0x40000
-#define SYMBOL_DEF4 0x80000
+#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
+
+#define SYMBOL_CONST 0x0001 /* symbol is const */
+#define SYMBOL_CHECK 0x0008 /* used during dependency checking */
+#define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */
+#define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */
+#define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */
+#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */
+#define SYMBOL_WRITE 0x0200 /* ? */
+#define SYMBOL_CHANGED 0x0400 /* ? */
+#define SYMBOL_AUTO 0x1000 /* value from environment variable */
+#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */
+#define SYMBOL_WARNED 0x8000 /* warning has been issued */
+
+/* Set when symbol.def[] is used */
+#define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */
+#define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */
+#define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */
+#define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */
+#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */
+
+/* choice values need to be set before calculating this symbol value */
+#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000
#define SYMBOL_MAXLENGTH 256
-#define SYMBOL_HASHSIZE 257
-#define SYMBOL_HASHMASK 0xff
-
+#define SYMBOL_HASHSIZE 9973
+
+/* A property represent the config options that can be associated
+ * with a config "symbol".
+ * Sample:
+ * config FOO
+ * default y
+ * prompt "foo prompt"
+ * select BAR
+ * config BAZ
+ * int "BAZ Value"
+ * range 1..255
+ */
enum prop_type {
- P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE,
- P_SELECT, P_RANGE, P_ENV
+ P_UNKNOWN,
+ P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */
+ P_COMMENT, /* text associated with a comment */
+ P_MENU, /* prompt associated with a menuconfig option */
+ P_DEFAULT, /* default y */
+ P_CHOICE, /* choice value */
+ P_SELECT, /* select BAR */
+ P_RANGE, /* range 7..100 (for a symbol) */
+ P_ENV, /* value from environment variable */
+ P_SYMBOL, /* where a symbol is defined */
};
struct property {
- struct property *next;
- struct symbol *sym;
- enum prop_type type;
- const char *text;
+ struct property *next; /* next property - null if last */
+ struct symbol *sym; /* the symbol for which the property is associated */
+ enum prop_type type; /* type of property */
+ const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */
struct expr_value visible;
- struct expr *expr;
- struct menu *menu;
- struct file *file;
- int lineno;
+ struct expr *expr; /* the optional conditional part of the property */
+ struct menu *menu; /* the menu the property are associated with
+ * valid for: P_SELECT, P_RANGE, P_CHOICE,
+ * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */
+ struct file *file; /* what file was this property defined */
+ int lineno; /* what lineno was this property defined */
};
#define for_all_properties(sym, st, tok) \
@@ -137,6 +165,7 @@ struct menu {
struct menu *list;
struct symbol *sym;
struct property *prompt;
+ struct expr *visibility;
struct expr *dep;
unsigned int flags;
char *help;
@@ -148,7 +177,14 @@ struct menu {
#define MENU_CHANGED 0x0001
#define MENU_ROOT 0x0002
-#ifndef SWIG
+struct jump_key {
+ struct list_head entries;
+ size_t offset;
+ struct menu *target;
+ int index;
+};
+
+#define JUMP_NB 9
extern struct file *file_list;
extern struct file *current_file;
@@ -164,7 +200,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
-struct expr *expr_copy(struct expr *org);
+struct expr *expr_copy(const struct expr *org);
void expr_free(struct expr *e);
int expr_eq(struct expr *e1, struct expr *e2);
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
@@ -179,21 +215,21 @@ struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
+struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
void expr_fprint(struct expr *e, FILE *out);
struct gstr; /* forward */
void expr_gstr_print(struct expr *e, struct gstr *gs);
-static __inline__ int expr_is_yes(struct expr *e)
+static inline int expr_is_yes(struct expr *e)
{
return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes);
}
-static __inline__ int expr_is_no(struct expr *e)
+static inline int expr_is_no(struct expr *e)
{
return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
}
-#endif
#ifdef __cplusplus
}
diff --git a/extra/config/gconf.c b/extra/config/gconf.c
index 540a0ff98..f2bee70e2 100644
--- a/extra/config/gconf.c
+++ b/extra/config/gconf.c
@@ -10,6 +10,7 @@
# include <config.h>
#endif
+#include <stdlib.h>
#include "lkc.h"
#include "images.c"
@@ -22,7 +23,6 @@
#include <string.h>
#include <unistd.h>
#include <time.h>
-#include <stdlib.h>
//#define DEBUG
@@ -30,13 +30,16 @@ enum {
SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW
};
+enum {
+ OPT_NORMAL, OPT_ALL, OPT_PROMPT
+};
+
static gint view_mode = FULL_VIEW;
static gboolean show_name = TRUE;
static gboolean show_range = TRUE;
static gboolean show_value = TRUE;
-static gboolean show_all = FALSE;
-static gboolean show_debug = FALSE;
static gboolean resizeable = FALSE;
+static int opt_mode = OPT_NORMAL;
GtkWidget *main_wnd = NULL;
GtkWidget *tree1_w = NULL; // left frame
@@ -76,36 +79,7 @@ static void conf_changed(void);
/* Helping/Debugging Functions */
-
-const char *dbg_print_stype(int val)
-{
- static char buf[256];
-
- bzero(buf, 256);
-
- if (val == S_UNKNOWN)
- strcpy(buf, "unknown");
- if (val == S_BOOLEAN)
- strcpy(buf, "boolean");
- if (val == S_TRISTATE)
- strcpy(buf, "tristate");
- if (val == S_INT)
- strcpy(buf, "int");
- if (val == S_HEX)
- strcpy(buf, "hex");
- if (val == S_STRING)
- strcpy(buf, "string");
- if (val == S_OTHER)
- strcpy(buf, "other");
-
-#ifdef DEBUG
- printf("%s", buf);
-#endif
-
- return buf;
-}
-
-const char *dbg_print_flags(int val)
+const char *dbg_sym_flags(int val)
{
static char buf[256];
@@ -131,40 +105,10 @@ const char *dbg_print_flags(int val)
strcat(buf, "auto/");
buf[strlen(buf) - 1] = '\0';
-#ifdef DEBUG
- printf("%s", buf);
-#endif
return buf;
}
-const char *dbg_print_ptype(int val)
-{
- static char buf[256];
-
- bzero(buf, 256);
-
- if (val == P_UNKNOWN)
- strcpy(buf, "unknown");
- if (val == P_PROMPT)
- strcpy(buf, "prompt");
- if (val == P_COMMENT)
- strcpy(buf, "comment");
- if (val == P_MENU)
- strcpy(buf, "menu");
- if (val == P_DEFAULT)
- strcpy(buf, "default");
- if (val == P_CHOICE)
- strcpy(buf, "choice");
-
-#ifdef DEBUG
- printf("%s", buf);
-#endif
-
- return buf;
-}
-
-
void replace_button_icon(GladeXML * xml, GdkDrawable * window,
GtkStyle * style, gchar * btn_name, gchar ** xpm)
{
@@ -189,7 +133,6 @@ void init_main_window(const gchar * glade_file)
GladeXML *xml;
GtkWidget *widget;
GtkTextBuffer *txtbuf;
- char title[256];
GtkStyle *style;
xml = glade_xml_new(glade_file, "window1", NULL);
@@ -266,9 +209,7 @@ void init_main_window(const gchar * glade_file)
/*"style", PANGO_STYLE_OBLIQUE, */
NULL);
- sprintf(title, _("uClibc v%s Configuration"),
- getenv("VERSION"));
- gtk_window_set_title(GTK_WINDOW(main_wnd), title);
+ gtk_window_set_title(GTK_WINDOW(main_wnd), rootmenu.prompt->text);
gtk_widget_show(main_wnd);
}
@@ -312,7 +253,7 @@ void init_left_tree(void)
gtk_tree_view_set_model(view, model1);
gtk_tree_view_set_headers_visible(view, TRUE);
- gtk_tree_view_set_rules_hint(view, FALSE);
+ gtk_tree_view_set_rules_hint(view, TRUE);
column = gtk_tree_view_column_new();
gtk_tree_view_append_column(view, column);
@@ -344,8 +285,6 @@ void init_left_tree(void)
static void renderer_edited(GtkCellRendererText * cell,
const gchar * path_string,
const gchar * new_text, gpointer user_data);
-static void renderer_toggled(GtkCellRendererToggle * cellrenderertoggle,
- gchar * arg1, gpointer user_data);
void init_right_tree(void)
{
@@ -357,7 +296,7 @@ void init_right_tree(void)
gtk_tree_view_set_model(view, model2);
gtk_tree_view_set_headers_visible(view, TRUE);
- gtk_tree_view_set_rules_hint(view, FALSE);
+ gtk_tree_view_set_rules_hint(view, TRUE);
column = gtk_tree_view_column_new();
gtk_tree_view_append_column(view, column);
@@ -379,8 +318,6 @@ void init_right_tree(void)
"inconsistent", COL_BTNINC,
"visible", COL_BTNVIS,
"radio", COL_BTNRAD, NULL);
- /*g_signal_connect(G_OBJECT(renderer), "toggled",
- G_CALLBACK(renderer_toggled), NULL); */
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column),
renderer, FALSE);
@@ -456,19 +393,9 @@ static void text_insert_help(struct menu *menu)
GtkTextBuffer *buffer;
GtkTextIter start, end;
const char *prompt = _(menu_get_prompt(menu));
- gchar *name;
- const char *help;
-
- help = menu_get_help(menu);
-
- /* Gettextize if the help text not empty */
- if ((help != 0) && (help[0] != 0))
- help = _(help);
+ struct gstr help = str_new();
- if (menu->sym && menu->sym->name)
- name = g_strdup_printf(menu->sym->name);
- else
- name = g_strdup("");
+ menu_get_ext_help(menu, &help);
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w));
gtk_text_buffer_get_bounds(buffer, &start, &end);
@@ -478,14 +405,11 @@ static void text_insert_help(struct menu *menu)
gtk_text_buffer_get_end_iter(buffer, &end);
gtk_text_buffer_insert_with_tags(buffer, &end, prompt, -1, tag1,
NULL);
- gtk_text_buffer_insert_at_cursor(buffer, " ", 1);
- gtk_text_buffer_get_end_iter(buffer, &end);
- gtk_text_buffer_insert_with_tags(buffer, &end, name, -1, tag1,
- NULL);
gtk_text_buffer_insert_at_cursor(buffer, "\n\n", 2);
gtk_text_buffer_get_end_iter(buffer, &end);
- gtk_text_buffer_insert_with_tags(buffer, &end, help, -1, tag2,
+ gtk_text_buffer_insert_with_tags(buffer, &end, str_get(&help), -1, tag2,
NULL);
+ str_free(&help);
}
@@ -710,20 +634,29 @@ void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data)
void
-on_show_all_options1_activate(GtkMenuItem * menuitem, gpointer user_data)
+on_set_option_mode1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
- show_all = GTK_CHECK_MENU_ITEM(menuitem)->active;
+ opt_mode = OPT_NORMAL;
+ gtk_tree_store_clear(tree2);
+ display_tree(&rootmenu); /* instead of update_tree to speed-up */
+}
+
+void
+on_set_option_mode2_activate(GtkMenuItem *menuitem, gpointer user_data)
+{
+ opt_mode = OPT_ALL;
gtk_tree_store_clear(tree2);
- display_tree(&rootmenu); // instead of update_tree to speed-up
+ display_tree(&rootmenu); /* instead of update_tree to speed-up */
}
void
-on_show_debug_info1_activate(GtkMenuItem * menuitem, gpointer user_data)
+on_set_option_mode3_activate(GtkMenuItem *menuitem, gpointer user_data)
{
- show_debug = GTK_CHECK_MENU_ITEM(menuitem)->active;
- update_tree(&rootmenu, NULL);
+ opt_mode = OPT_PROMPT;
+ gtk_tree_store_clear(tree2);
+ display_tree(&rootmenu); /* instead of update_tree to speed-up */
}
@@ -732,7 +665,6 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
GtkWidget *dialog;
const gchar *intro_text = _(
"Welcome to gkc, the GTK+ graphical configuration tool\n"
- "for uClibc.\n"
"For each option, a blank box indicates the feature is disabled, a\n"
"check indicates it is enabled, and a dot indicates that it is to\n"
"be compiled as a module. Clicking on the box will cycle through the three states.\n"
@@ -751,7 +683,7 @@ void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data)
dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE, intro_text);
+ GTK_BUTTONS_CLOSE, "%s", intro_text);
g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
G_CALLBACK(gtk_widget_destroy),
GTK_OBJECT(dialog));
@@ -769,7 +701,7 @@ void on_about1_activate(GtkMenuItem * menuitem, gpointer user_data)
dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE, about_text);
+ GTK_BUTTONS_CLOSE, "%s", about_text);
g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
G_CALLBACK(gtk_widget_destroy),
GTK_OBJECT(dialog));
@@ -788,7 +720,7 @@ void on_license1_activate(GtkMenuItem * menuitem, gpointer user_data)
dialog = gtk_message_dialog_new(GTK_WINDOW(main_wnd),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
- GTK_BUTTONS_CLOSE, license_text);
+ GTK_BUTTONS_CLOSE, "%s", license_text);
g_signal_connect_swapped(GTK_OBJECT(dialog), "response",
G_CALLBACK(gtk_widget_destroy),
GTK_OBJECT(dialog));
@@ -820,7 +752,6 @@ void on_load_clicked(GtkButton * button, gpointer user_data)
void on_single_clicked(GtkButton * button, gpointer user_data)
{
view_mode = SINGLE_VIEW;
- gtk_paned_set_position(GTK_PANED(hpaned), 0);
gtk_widget_hide(tree1_w);
current = &rootmenu;
display_tree_part();
@@ -846,7 +777,6 @@ void on_split_clicked(GtkButton * button, gpointer user_data)
void on_full_clicked(GtkButton * button, gpointer user_data)
{
view_mode = FULL_VIEW;
- gtk_paned_set_position(GTK_PANED(hpaned), 0);
gtk_widget_hide(tree1_w);
if (tree2)
gtk_tree_store_clear(tree2);
@@ -900,7 +830,7 @@ static void renderer_edited(GtkCellRendererText * cell,
static void change_sym_value(struct menu *menu, gint col)
{
struct symbol *sym = menu->sym;
- tristate oldval, newval;
+ tristate newval;
if (!sym)
return;
@@ -917,7 +847,6 @@ static void change_sym_value(struct menu *menu, gint col)
switch (sym_get_type(sym)) {
case S_BOOLEAN:
case S_TRISTATE:
- oldval = sym_get_tristate_value(sym);
if (!sym_tristate_within_range(sym, newval))
newval = yes;
sym_set_tristate_value(sym, newval);
@@ -954,35 +883,6 @@ static void toggle_sym_value(struct menu *menu)
display_tree_part(); //fixme: keep exp/coll
}
-static void renderer_toggled(GtkCellRendererToggle * cell,
- gchar * path_string, gpointer user_data)
-{
- GtkTreePath *path, *sel_path = NULL;
- GtkTreeIter iter, sel_iter;
- GtkTreeSelection *sel;
- struct menu *menu;
-
- path = gtk_tree_path_new_from_string(path_string);
- if (!gtk_tree_model_get_iter(model2, &iter, path))
- return;
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree2_w));
- if (gtk_tree_selection_get_selected(sel, NULL, &sel_iter))
- sel_path = gtk_tree_model_get_path(model2, &sel_iter);
- if (!sel_path)
- goto out1;
- if (gtk_tree_path_compare(path, sel_path))
- goto out2;
-
- gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
- toggle_sym_value(menu);
-
- out2:
- gtk_tree_path_free(sel_path);
- out1:
- gtk_tree_path_free(path);
-}
-
static gint column2index(GtkTreeViewColumn * column)
{
gint i;
@@ -1174,9 +1074,12 @@ static gchar **fill_row(struct menu *menu)
row[COL_OPTION] =
g_strdup_printf("%s %s", _(menu_get_prompt(menu)),
- sym && sym_has_value(sym) ? "(NEW)" : "");
+ sym && !sym_has_value(sym) ? "(NEW)" : "");
- if (show_all && !menu_is_visible(menu))
+ if (opt_mode == OPT_ALL && !menu_is_visible(menu))
+ row[COL_COLOR] = g_strdup("DarkGray");
+ else if (opt_mode == OPT_PROMPT &&
+ menu_has_prompt(menu) && !menu_is_visible(menu))
row[COL_COLOR] = g_strdup("DarkGray");
else
row[COL_COLOR] = g_strdup("Black");
@@ -1235,6 +1138,7 @@ static gchar **fill_row(struct menu *menu)
row[COL_BTNVIS] = GINT_TO_POINTER(TRUE);
if (sym_is_choice(sym))
break;
+ /* fall through */
case S_TRISTATE:
val = sym_get_tristate_value(sym);
switch (val) {
@@ -1373,7 +1277,6 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
gboolean valid;
GtkTreeIter *sibling;
struct symbol *sym;
- struct property *prop;
struct menu *menu1, *menu2;
if (src == &rootmenu)
@@ -1382,7 +1285,6 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
valid = gtk_tree_model_iter_children(model2, child2, dst);
for (child1 = src->list; child1; child1 = child1->next) {
- prop = child1->prompt;
sym = child1->sym;
reparse:
@@ -1399,16 +1301,20 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
menu2 ? menu_get_prompt(menu2) : "nil");
#endif
- if (!menu_is_visible(child1) && !show_all) { // remove node
+ if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) ||
+ (opt_mode == OPT_PROMPT && !menu_has_prompt(child1)) ||
+ (opt_mode == OPT_ALL && !menu_get_prompt(child1))) {
+
+ /* remove node */
if (gtktree_iter_find_node(dst, menu1) != NULL) {
memcpy(&tmp, child2, sizeof(GtkTreeIter));
valid = gtk_tree_model_iter_next(model2,
child2);
gtk_tree_store_remove(tree2, &tmp);
if (!valid)
- return; // next parent
+ return; /* next parent */
else
- goto reparse; // next child
+ goto reparse; /* next child */
} else
continue;
}
@@ -1477,17 +1383,19 @@ static void display_tree(struct menu *menu)
&& (tree == tree2))
continue;
- if (menu_is_visible(child) || show_all)
+ if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) ||
+ (opt_mode == OPT_PROMPT && menu_has_prompt(child)) ||
+ (opt_mode == OPT_ALL && menu_get_prompt(child)))
place_node(child, fill_row(child));
#ifdef DEBUG
printf("%*c%s: ", indent, ' ', menu_get_prompt(child));
printf("%s", child->flags & MENU_ROOT ? "rootmenu | " : "");
- dbg_print_ptype(ptype);
+ printf("%s", prop_get_type_name(ptype));
printf(" | ");
if (sym) {
- dbg_print_stype(sym->type);
+ printf("%s", sym_type_name(sym->type));
printf(" | ");
- dbg_print_flags(sym->flags);
+ printf("%s", dbg_sym_flags(sym->flags));
printf("\n");
} else
printf("\n");
@@ -1499,6 +1407,12 @@ static void display_tree(struct menu *menu)
if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT))
|| (view_mode == FULL_VIEW)
|| (view_mode == SPLIT_VIEW))*/
+
+ /* Change paned position if the view is not in 'split mode' */
+ if (view_mode == SINGLE_VIEW || view_mode == FULL_VIEW) {
+ gtk_paned_set_position(GTK_PANED(hpaned), 0);
+ }
+
if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT))
|| (view_mode == FULL_VIEW)
|| (view_mode == SPLIT_VIEW)) {
@@ -1557,10 +1471,6 @@ int main(int ac, char *av[])
char *env;
gchar *glade_file;
-#ifndef LKC_DIRECT_LINK
- kconfig_load();
-#endif
-
bindtextdomain(PACKAGE, LOCALEDIR);
bind_textdomain_codeset(PACKAGE, "UTF-8");
textdomain(PACKAGE);
@@ -1582,12 +1492,6 @@ int main(int ac, char *av[])
else
glade_file = g_strconcat(g_get_current_dir(), "/", av[0], ".glade", NULL);
- /* Load the interface and connect signals */
- init_main_window(glade_file);
- init_tree_model();
- init_left_tree();
- init_right_tree();
-
/* Conf stuffs */
if (ac > 1 && av[1][0] == '-') {
switch (av[1][1]) {
@@ -1607,6 +1511,12 @@ int main(int ac, char *av[])
fixup_rootmenu(&rootmenu);
conf_read(NULL);
+ /* Load the interface and connect signals */
+ init_main_window(glade_file);
+ init_tree_model();
+ init_left_tree();
+ init_right_tree();
+
switch (view_mode) {
case SINGLE_VIEW:
display_tree_part();
diff --git a/extra/config/gconf.glade b/extra/config/gconf.glade
index 2e2e2f9db..d449d3251 100644
--- a/extra/config/gconf.glade
+++ b/extra/config/gconf.glade
@@ -1,11 +1,10 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="window1">
<property name="visible">True</property>
- <property name="title" translatable="yes">Gtk uClibc Configurator</property>
+ <property name="title" translatable="yes">Gtk uCLibc Configurator</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
@@ -190,26 +189,40 @@
</child>
<child>
- <widget class="GtkCheckMenuItem" id="show_all_options1">
+ <widget class="GtkRadioMenuItem" id="set_option_mode1">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Show normal options</property>
+ <property name="label" translatable="yes">Show normal options</property>
+ <property name="use_underline">True</property>
+ <property name="active">True</property>
+ <signal name="activate" handler="on_set_option_mode1_activate"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkRadioMenuItem" id="set_option_mode2">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Show all options</property>
<property name="label" translatable="yes">Show all _options</property>
<property name="use_underline">True</property>
<property name="active">False</property>
- <signal name="activate" handler="on_show_all_options1_activate"/>
+ <property name="group">set_option_mode1</property>
+ <signal name="activate" handler="on_set_option_mode2_activate"/>
</widget>
</child>
<child>
- <widget class="GtkCheckMenuItem" id="show_debug_info1">
+ <widget class="GtkRadioMenuItem" id="set_option_mode3">
<property name="visible">True</property>
- <property name="tooltip" translatable="yes">Show masked options</property>
- <property name="label" translatable="yes">Show _debug info</property>
+ <property name="tooltip" translatable="yes">Show all options with prompts</property>
+ <property name="label" translatable="yes">Show all prompt options</property>
<property name="use_underline">True</property>
<property name="active">False</property>
- <signal name="activate" handler="on_show_debug_info1_activate"/>
+ <property name="group">set_option_mode1</property>
+ <signal name="activate" handler="on_set_option_mode3_activate"/>
</widget>
</child>
+
</widget>
</child>
</widget>
@@ -547,7 +560,7 @@
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
- <property name="enable_search">True</property>
+ <property name="enable_search">False</property>
<signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:58:22 GMT"/>
<signal name="button_press_event" handler="on_treeview1_button_press_event" last_modification_time="Sun, 12 Jan 2003 16:03:52 GMT"/>
<signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 16:11:44 GMT"/>
@@ -582,7 +595,7 @@
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
- <property name="enable_search">True</property>
+ <property name="enable_search">False</property>
<signal name="cursor_changed" handler="on_treeview2_cursor_changed" last_modification_time="Sun, 12 Jan 2003 15:57:55 GMT"/>
<signal name="button_press_event" handler="on_treeview2_button_press_event" last_modification_time="Sun, 12 Jan 2003 15:57:58 GMT"/>
<signal name="key_press_event" handler="on_treeview2_key_press_event" last_modification_time="Sun, 12 Jan 2003 15:58:01 GMT"/>
diff --git a/extra/config/kconfig-language.txt b/extra/config/kconfig-language.txt
index 649cb8799..c858f8419 100644
--- a/extra/config/kconfig-language.txt
+++ b/extra/config/kconfig-language.txt
@@ -104,14 +104,21 @@ applicable everywhere (see syntax).
Reverse dependencies can only be used with boolean or tristate
symbols.
Note:
- select is evil.... select will by brute force set a symbol
- equal to 'y' without visiting the dependencies. So abusing
- select you are able to select a symbol FOO even if FOO depends
- on BAR that is not set. In general use select only for
- non-visible symbols (no prompts anywhere) and for symbols with
- no dependencies. That will limit the usefulness but on the
- other hand avoid the illegal configurations all over. kconfig
- should one day warn about such things.
+ select should be used with care. select will force
+ a symbol to a value without visiting the dependencies.
+ By abusing select you are able to select a symbol FOO even
+ if FOO depends on BAR that is not set.
+ In general use select only for non-visible symbols
+ (no prompts anywhere) and for symbols with no dependencies.
+ That will limit the usefulness but on the other hand avoid
+ the illegal configurations all over.
+
+- limiting menu display: "visible if" <expr>
+ This attribute is only applicable to menu blocks, if the condition is
+ false, the menu block is not displayed to the user (the symbols
+ contained there can still be selected by other symbols, though). It is
+ similar to a conditional "prompt" attribute for individual menu
+ entries. Default value of "visible" is true.
- numerical ranges: "range" <symbol> <symbol> ["if" <expr>]
This allows to limit the range of possible input values for int
@@ -180,7 +187,7 @@ Expressions are listed in decreasing order of precedence.
(7) Returns the result of max(/expr/, /expr/).
An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2
-respectively for calculations). A menu entry becomes visible when it's
+respectively for calculations). A menu entry becomes visible when its
expression evaluates to 'm' or 'y'.
There are two types of symbols: constant and non-constant symbols.
@@ -267,7 +274,7 @@ separate list of options.
choices:
- "choice"
+ "choice" [symbol]
<choice options>
<choice block>
"endchoice"
@@ -281,6 +288,10 @@ single driver can be compiled/loaded into the kernel, but all drivers
can be compiled as modules.
A choice accepts another option "optional", which allows to set the
choice to 'n' and no entry needs to be selected.
+If no [symbol] is associated with a choice, then you can not have multiple
+definitions of that choice. If a [symbol] is associated to the choice,
+then you may define the same choice (ie. with the same entries) in another
+place.
comment:
@@ -299,7 +310,8 @@ menu:
"endmenu"
This defines a menu block, see "Menu structure" above for more
-information. The only possible options are dependencies.
+information. The only possible options are dependencies and "visible"
+attributes.
if:
@@ -321,7 +333,8 @@ mainmenu:
"mainmenu" <prompt>
This sets the config program's title bar if the config program chooses
-to use it.
+to use it. It should be placed at the top of the configuration, before any
+other statement.
Kconfig hints
@@ -375,28 +388,3 @@ config FOO
depends on BAR && m
limits FOO to module (=m) or disabled (=n).
-
-
-Build limited by a third config symbol which may be =y or =m
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-A common idiom that we see (and sometimes have problems with) is this:
-
-When option C in B (module or subsystem) uses interfaces from A (module
-or subsystem), and both A and B are tristate (could be =y or =m if they
-were independent of each other, but they aren't), then we need to limit
-C such that it cannot be built statically if A is built as a loadable
-module. (C already depends on B, so there is no dependency issue to
-take care of here.)
-
-If A is linked statically into the kernel image, C can be built
-statically or as loadable module(s). However, if A is built as loadable
-module(s), then C must be restricted to loadable module(s) also. This
-can be expressed in kconfig language as:
-
-config C
- depends on A = y || A = B
-
-or for real examples, use this command in a kernel tree:
-
-$ find . -name Kconfig\* | xargs grep -ns "depends on.*=.*||.*=" | grep -v orig
-
diff --git a/extra/config/kconfig-to-uclibc.patch.gz b/extra/config/kconfig-to-uclibc.patch.gz
deleted file mode 100644
index df28093ba..000000000
--- a/extra/config/kconfig-to-uclibc.patch.gz
+++ /dev/null
Binary files differ
diff --git a/extra/config/kconfig-to-uclibc.tar.gz b/extra/config/kconfig-to-uclibc.tar.gz
new file mode 100644
index 000000000..bd018cc4c
--- /dev/null
+++ b/extra/config/kconfig-to-uclibc.tar.gz
Binary files differ
diff --git a/extra/config/kconfig_load.c b/extra/config/kconfig_load.c
deleted file mode 100644
index dbdcaad82..000000000
--- a/extra/config/kconfig_load.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <dlfcn.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "lkc.h"
-
-#define P(name,type,arg) type (*name ## _p) arg
-#include "lkc_proto.h"
-#undef P
-
-void kconfig_load(void)
-{
- void *handle;
- char *error;
-
- handle = dlopen("./libkconfig.so", RTLD_LAZY);
- if (!handle) {
- handle = dlopen("./scripts/kconfig/libkconfig.so", RTLD_LAZY);
- if (!handle) {
- fprintf(stderr, "%s\n", dlerror());
- exit(1);
- }
- }
-
-#define P(name,type,arg) \
-{ \
- name ## _p = dlsym(handle, #name); \
- if ((error = dlerror())) { \
- fprintf(stderr, "%s\n", error); \
- exit(1); \
- } \
-}
-#include "lkc_proto.h"
-#undef P
-}
diff --git a/extra/config/kxgettext.c b/extra/config/kxgettext.c
index 6eb72a7f2..2858738b2 100644
--- a/extra/config/kxgettext.c
+++ b/extra/config/kxgettext.c
@@ -7,7 +7,6 @@
#include <stdlib.h>
#include <string.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
static char *escape(const char* text, char *bf, int len)
@@ -43,6 +42,10 @@ static char *escape(const char* text, char *bf, int len)
++text;
goto next;
}
+ else if (*text == '\\') {
+ *bfp++ = '\\';
+ len--;
+ }
*bfp++ = *text++;
next:
--len;
@@ -59,11 +62,11 @@ next:
struct file_line {
struct file_line *next;
- char* file;
- int lineno;
+ const char *file;
+ int lineno;
};
-static struct file_line *file_line__new(char *file, int lineno)
+static struct file_line *file_line__new(const char *file, int lineno)
{
struct file_line *self = malloc(sizeof(*self));
@@ -86,7 +89,8 @@ struct message {
static struct message *message__list;
-static struct message *message__new(const char *msg, char *option, char *file, int lineno)
+static struct message *message__new(const char *msg, char *option,
+ const char *file, int lineno)
{
struct message *self = malloc(sizeof(*self));
@@ -126,7 +130,8 @@ static struct message *mesage__find(const char *msg)
return m;
}
-static int message__add_file_line(struct message *self, char *file, int lineno)
+static int message__add_file_line(struct message *self, const char *file,
+ int lineno)
{
int rc = -1;
struct file_line *fl = file_line__new(file, lineno);
@@ -141,7 +146,8 @@ out:
return rc;
}
-static int message__add(const char *msg, char *option, char *file, int lineno)
+static int message__add(const char *msg, char *option, const char *file,
+ int lineno)
{
int rc = 0;
char bf[16384];
@@ -162,7 +168,7 @@ static int message__add(const char *msg, char *option, char *file, int lineno)
return rc;
}
-void menu_build_message_list(struct menu *menu)
+static void menu_build_message_list(struct menu *menu)
{
struct menu *child;
@@ -207,7 +213,7 @@ static void message__print_gettext_msgid_msgstr(struct message *self)
"msgstr \"\"\n", self->msg);
}
-void menu__xgettext(void)
+static void menu__xgettext(void)
{
struct message *m = message__list;
diff --git a/extra/config/list.h b/extra/config/list.h
new file mode 100644
index 000000000..685d80e1b
--- /dev/null
+++ b/extra/config/list.h
@@ -0,0 +1,131 @@
+#ifndef LIST_H
+#define LIST_H
+
+/*
+ * Copied from include/linux/...
+ */
+
+#undef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+
+
+struct list_head {
+ struct list_head *next, *prev;
+};
+
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+ struct list_head name = LIST_HEAD_INIT(name)
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr: the &struct list_head pointer.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+ container_of(ptr, type, member)
+
+/**
+ * list_for_each_entry - iterate over list of given type
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry(pos, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static inline int list_empty(const struct list_head *head)
+{
+ return head->next == head;
+}
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_add(struct list_head *_new,
+ struct list_head *prev,
+ struct list_head *next)
+{
+ next->prev = _new;
+ _new->next = next;
+ _new->prev = prev;
+ prev->next = _new;
+}
+
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static inline void list_add_tail(struct list_head *_new, struct list_head *head)
+{
+ __list_add(_new, head->prev, head);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_del(struct list_head *prev, struct list_head *next)
+{
+ next->prev = prev;
+ prev->next = next;
+}
+
+#define LIST_POISON1 ((void *) 0x00100100)
+#define LIST_POISON2 ((void *) 0x00200200)
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty() on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static inline void list_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ entry->next = (struct list_head*)LIST_POISON1;
+ entry->prev = (struct list_head*)LIST_POISON2;
+}
+#endif
diff --git a/extra/config/lkc.h b/extra/config/lkc.h
index c55c2fbd7..22d356146 100644
--- a/extra/config/lkc.h
+++ b/extra/config/lkc.h
@@ -11,37 +11,53 @@
#ifndef KBUILD_NO_NLS
# include <libintl.h>
#else
-# define gettext(Msgid) ((const char *) (Msgid))
-# define textdomain(Domainname) ((const char *) (Domainname))
-# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname))
+static inline const char *gettext(const char *txt) { return txt; }
+static inline void textdomain(const char *domainname) {}
+static inline void bindtextdomain(const char *name, const char *dir) {}
+static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; }
#endif
#ifdef __cplusplus
extern "C" {
#endif
-#ifdef LKC_DIRECT_LINK
#define P(name,type,arg) extern type name arg
-#else
-#include "lkc_defs.h"
-#define P(name,type,arg) extern type (*name ## _p) arg
-#endif
#include "lkc_proto.h"
#undef P
#define SRCTREE "srctree"
+#ifndef PACKAGE
#define PACKAGE "linux"
+#endif
+
#define LOCALEDIR "/usr/share/locale"
#define _(text) gettext(text)
#define N_(text) (text)
+#ifndef CONFIG_
+#define CONFIG_ "CONFIG_"
+#endif
+static inline const char *CONFIG_prefix(void)
+{
+ return getenv( "CONFIG_" ) ?: CONFIG_;
+}
+#undef CONFIG_
+#define CONFIG_ CONFIG_prefix()
#define TF_COMMAND 0x0001
#define TF_PARAM 0x0002
#define TF_OPTION 0x0004
+enum conf_def_mode {
+ def_default,
+ def_yes,
+ def_mod,
+ def_no,
+ def_random
+};
+
#define T_OPT_MODULES 1
#define T_OPT_DEFCONFIG_LIST 2
#define T_OPT_ENV 3
@@ -53,34 +69,49 @@ struct kconf_id {
enum symbol_type stype;
};
+extern int zconfdebug;
+
int zconfparse(void);
void zconfdump(FILE *out);
-
-extern int zconfdebug;
void zconf_starthelp(void);
FILE *zconf_fopen(const char *name);
void zconf_initscan(const char *name);
void zconf_nextfile(const char *name);
int zconf_lineno(void);
-char *zconf_curname(void);
+const char *zconf_curname(void);
/* confdata.c */
const char *conf_get_configname(void);
+const char *conf_get_autoconfig_name(void);
char *conf_get_default_confname(void);
void sym_set_change_count(int count);
void sym_add_change_count(int count);
+bool conf_set_all_new_symbols(enum conf_def_mode mode);
+void set_all_choice_values(struct symbol *csym);
-/* kconfig_load.c */
-void kconfig_load(void);
+struct conf_printer {
+ void (*print_symbol)(FILE *, struct symbol *, const char *, void *);
+ void (*print_comment)(FILE *, const char *, void *);
+};
+
+/* confdata.c and expr.c */
+static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
+{
+ assert(len != 0);
+
+ if (fwrite(str, len, count, out) != count)
+ fprintf(stderr, "Error in writing or end of file.\n");
+}
/* menu.c */
-void menu_init(void);
+void _menu_init(void);
void menu_warn(struct menu *menu, const char *fmt, ...);
struct menu *menu_add_menu(void);
void menu_end_menu(void);
void menu_add_entry(struct symbol *sym);
void menu_end_entry(void);
void menu_add_dep(struct expr *dep);
+void menu_add_visibility(struct expr *dep);
struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep);
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
@@ -92,10 +123,19 @@ void menu_set_type(int type);
/* util.c */
struct file *file_lookup(const char *name);
int file_write_dep(const char *name);
+void *xmalloc(size_t size);
+void *xcalloc(size_t nmemb, size_t size);
+char *dir_name(char *path);
+char *base_name(char *path);
struct gstr {
size_t len;
char *s;
+ /*
+ * when max_width is not zero long lines in string s (if any) get
+ * wrapped not to exceed the max_width value
+ */
+ int max_width;
};
struct gstr str_new(void);
struct gstr str_assign(const char *s);
@@ -111,43 +151,45 @@ void sym_init(void);
void sym_clear_all_valid(void);
void sym_set_all_changed(void);
void sym_set_changed(struct symbol *sym);
+struct symbol *sym_choice_default(struct symbol *sym);
+const char *sym_get_string_default(struct symbol *sym);
struct symbol *sym_check_deps(struct symbol *sym);
struct property *prop_alloc(enum prop_type type, struct symbol *sym);
struct symbol *prop_get_symbol(struct property *prop);
struct property *sym_get_env_prop(struct symbol *sym);
-static __inline__ tristate sym_get_tristate_value(struct symbol *sym)
+static inline tristate sym_get_tristate_value(struct symbol *sym)
{
return sym->curr.tri;
}
-static __inline__ struct symbol *sym_get_choice_value(struct symbol *sym)
+static inline struct symbol *sym_get_choice_value(struct symbol *sym)
{
return (struct symbol *)sym->curr.val;
}
-static __inline__ bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
+static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
{
return sym_set_tristate_value(chval, yes);
}
-static __inline__ bool sym_is_choice(struct symbol *sym)
+static inline bool sym_is_choice(struct symbol *sym)
{
return sym->flags & SYMBOL_CHOICE ? true : false;
}
-static __inline__ bool sym_is_choice_value(struct symbol *sym)
+static inline bool sym_is_choice_value(struct symbol *sym)
{
return sym->flags & SYMBOL_CHOICEVAL ? true : false;
}
-static __inline__ bool sym_is_optional(struct symbol *sym)
+static inline bool sym_is_optional(struct symbol *sym)
{
return sym->flags & SYMBOL_OPTIONAL ? true : false;
}
-static __inline__ bool sym_has_value(struct symbol *sym)
+static inline bool sym_has_value(struct symbol *sym)
{
return sym->flags & SYMBOL_DEF_USER ? true : false;
}
diff --git a/extra/config/lkc_proto.h b/extra/config/lkc_proto.h
index 4d09f6dde..ecdb9659b 100644
--- a/extra/config/lkc_proto.h
+++ b/extra/config/lkc_proto.h
@@ -1,28 +1,40 @@
+#include <stdarg.h>
/* confdata.c */
P(conf_parse,void,(const char *name));
P(conf_read,int,(const char *name));
P(conf_read_simple,int,(const char *name, int));
+P(conf_write_defconfig,int,(const char *name));
P(conf_write,int,(const char *name));
P(conf_write_autoconf,int,(void));
P(conf_get_changed,bool,(void));
P(conf_set_changed_callback, void,(void (*fn)(void)));
+P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));
/* menu.c */
P(rootmenu,struct menu,);
-P(menu_is_visible,bool,(struct menu *menu));
+P(menu_is_empty, bool, (struct menu *menu));
+P(menu_is_visible, bool, (struct menu *menu));
+P(menu_has_prompt, bool, (struct menu *menu));
P(menu_get_prompt,const char *,(struct menu *menu));
P(menu_get_root_menu,struct menu *,(struct menu *menu));
P(menu_get_parent_menu,struct menu *,(struct menu *menu));
P(menu_has_help,bool,(struct menu *menu));
P(menu_get_help,const char *,(struct menu *menu));
+P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head
+ *head));
+P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head
+ *head));
+P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
/* symbol.c */
P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
-P(sym_lookup,struct symbol *,(const char *name, int isconst));
+P(sym_lookup,struct symbol *,(const char *name, int flags));
P(sym_find,struct symbol *,(const char *name));
+P(sym_expand_string_value,const char *,(const char *in));
+P(sym_escape_string_value, const char *,(const char *in));
P(sym_re_search,struct symbol **,(const char *pattern));
P(sym_type_name,const char *,(enum symbol_type type));
P(sym_calc_value,void,(struct symbol *sym));
diff --git a/extra/config/lxdialog/check-lxdialog.sh b/extra/config/lxdialog/check-lxdialog.sh
index 5552154cb..9d2a4c585 100755..100644
--- a/extra/config/lxdialog/check-lxdialog.sh
+++ b/extra/config/lxdialog/check-lxdialog.sh
@@ -4,7 +4,9 @@
# What library to link
ldflags()
{
- for ext in so a dylib ; do
+ pkg-config --libs ncursesw 2>/dev/null && exit
+ pkg-config --libs ncurses 2>/dev/null && exit
+ for ext in so a dll.a dylib ; do
for lib in ncursesw ncurses curses ; do
$cc -print-file-name=lib${lib}.${ext} | grep -q /
if [ $? -eq 0 ]; then
@@ -19,10 +21,13 @@ ldflags()
# Where is ncurses.h?
ccflags()
{
- if [ -f /usr/include/ncurses/ncurses.h ]; then
+ if [ -f /usr/include/ncursesw/curses.h ]; then
+ echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
+ echo ' -DNCURSES_WIDECHAR=1'
+ elif [ -f /usr/include/ncurses/ncurses.h ]; then
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
elif [ -f /usr/include/ncurses/curses.h ]; then
- echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
+ echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
elif [ -f /usr/include/ncurses.h ]; then
echo '-DCURSES_LOC="<ncurses.h>"'
else
@@ -36,7 +41,7 @@ trap "rm -f $tmp" 0 1 2 3 15
# Check if we can link to ncurses
check() {
- $cc -xc - -o $tmp 2>/dev/null <<'EOF'
+ $cc -x c - -o $tmp 2>/dev/null <<'EOF'
#include CURSES_LOC
main() {}
EOF
@@ -52,7 +57,7 @@ EOF
}
usage() {
- printf "Usage: $0 [-check compiler options|-header|-library]\n"
+ printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
}
if [ $# -eq 0 ]; then
diff --git a/extra/config/lxdialog/checklist.c b/extra/config/lxdialog/checklist.c
index b2a878c93..3b15c08ec 100644
--- a/extra/config/lxdialog/checklist.c
+++ b/extra/config/lxdialog/checklist.c
@@ -31,6 +31,10 @@ static int list_width, check_x, item_x;
static void print_item(WINDOW * win, int choice, int selected)
{
int i;
+ char *list_item = malloc(list_width + 1);
+
+ strncpy(list_item, item_str(), list_width - item_x);
+ list_item[list_width - item_x] = '\0';
/* Clear 'residue' of last item */
wattrset(win, dlg.menubox.atr);
@@ -41,16 +45,18 @@ static void print_item(WINDOW * win, int choice, int selected)
wmove(win, choice, check_x);
wattrset(win, selected ? dlg.check_selected.atr
: dlg.check.atr);
- wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' ');
+ if (!item_is_tag(':'))
+ wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' ');
wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr);
- mvwaddch(win, choice, item_x, item_str()[0]);
+ mvwaddch(win, choice, item_x, list_item[0]);
wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr);
- waddstr(win, (char *)item_str() + 1);
+ waddstr(win, list_item + 1);
if (selected) {
wmove(win, choice, check_x + 1);
wrefresh(win);
}
+ free(list_item);
}
/*
@@ -126,16 +132,16 @@ int dialog_checklist(const char *title, const char *prompt, int height,
}
do_resize:
- if (getmaxy(stdscr) < (height + 6))
+ if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN))
return -ERRDISPLAYTOOSMALL;
- if (getmaxx(stdscr) < (width + 6))
+ if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN))
return -ERRDISPLAYTOOSMALL;
max_choice = MIN(list_height, item_count());
/* center dialog box on screen */
- x = (COLS - width) / 2;
- y = (LINES - height) / 2;
+ x = (getmaxx(stdscr) - width) / 2;
+ y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
@@ -174,6 +180,7 @@ do_resize:
check_x = 0;
item_foreach()
check_x = MAX(check_x, strlen(item_str()) + 4);
+ check_x = MIN(check_x, list_width);
check_x = (list_width - check_x) / 2;
item_x = check_x + 4;
diff --git a/extra/config/lxdialog/dialog.h b/extra/config/lxdialog/dialog.h
index b5211fce0..b4343d384 100644
--- a/extra/config/lxdialog/dialog.h
+++ b/extra/config/lxdialog/dialog.h
@@ -106,8 +106,14 @@ struct dialog_color {
int hl; /* highlight this item */
};
+struct subtitle_list {
+ struct subtitle_list *next;
+ const char *text;
+};
+
struct dialog_info {
const char *backtitle;
+ struct subtitle_list *subtitles;
struct dialog_color screen;
struct dialog_color shadow;
struct dialog_color dialog;
@@ -144,6 +150,7 @@ struct dialog_info {
*/
extern struct dialog_info dlg;
extern char dialog_input_result[];
+extern int saved_x, saved_y; /* Needed in signal handler in mconf.c */
/*
* Function prototypes
@@ -193,8 +200,23 @@ int item_is_tag(char tag);
int on_key_esc(WINDOW *win);
int on_key_resize(void);
+/* minimum (re)size values */
+#define CHECKLIST_HEIGTH_MIN 6 /* For dialog_checklist() */
+#define CHECKLIST_WIDTH_MIN 6
+#define INPUTBOX_HEIGTH_MIN 2 /* For dialog_inputbox() */
+#define INPUTBOX_WIDTH_MIN 2
+#define MENUBOX_HEIGTH_MIN 15 /* For dialog_menu() */
+#define MENUBOX_WIDTH_MIN 65
+#define TEXTBOX_HEIGTH_MIN 8 /* For dialog_textbox() */
+#define TEXTBOX_WIDTH_MIN 8
+#define YESNO_HEIGTH_MIN 4 /* For dialog_yesno() */
+#define YESNO_WIDTH_MIN 4
+#define WINDOW_HEIGTH_MIN 19 /* For init_dialog() */
+#define WINDOW_WIDTH_MIN 80
+
int init_dialog(const char *backtitle);
void set_dialog_backtitle(const char *backtitle);
+void set_dialog_subtitles(struct subtitle_list *subtitles);
void end_dialog(int x, int y);
void attr_clear(WINDOW * win, int height, int width, chtype attr);
void dialog_clear(void);
@@ -209,12 +231,17 @@ int first_alpha(const char *string, const char *exempt);
int dialog_yesno(const char *title, const char *prompt, int height, int width);
int dialog_msgbox(const char *title, const char *prompt, int height,
int width, int pause);
-int dialog_textbox(const char *title, const char *file, int height, int width);
+
+
+typedef void (*update_text_fn)(char *buf, size_t start, size_t end, void
+ *_data);
+int dialog_textbox(const char *title, char *tbuf, int initial_height,
+ int initial_width, int *keys, int *_vscroll, int *_hscroll,
+ update_text_fn update_text, void *data);
int dialog_menu(const char *title, const char *prompt,
const void *selected, int *s_scroll);
int dialog_checklist(const char *title, const char *prompt, int height,
int width, int list_height);
-extern char dialog_input_result[];
int dialog_inputbox(const char *title, const char *prompt, int height,
int width, const char *init);
diff --git a/extra/config/lxdialog/inputbox.c b/extra/config/lxdialog/inputbox.c
index 4946bd02b..447a58219 100644
--- a/extra/config/lxdialog/inputbox.c
+++ b/extra/config/lxdialog/inputbox.c
@@ -45,7 +45,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
const char *init)
{
int i, x, y, box_y, box_x, box_width;
- int input_x = 0, scroll = 0, key = 0, button = -1;
+ int input_x = 0, key = 0, button = -1;
+ int show_x, len, pos;
char *instr = dialog_input_result;
WINDOW *dialog;
@@ -55,14 +56,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
strcpy(instr, init);
do_resize:
- if (getmaxy(stdscr) <= (height - 2))
+ if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGTH_MIN))
return -ERRDISPLAYTOOSMALL;
- if (getmaxx(stdscr) <= (width - 2))
+ if (getmaxx(stdscr) <= (width - INPUTBOX_WIDTH_MIN))
return -ERRDISPLAYTOOSMALL;
/* center dialog box on screen */
- x = (COLS - width) / 2;
- y = (LINES - height) / 2;
+ x = (getmaxx(stdscr) - width) / 2;
+ y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
@@ -89,7 +90,7 @@ do_resize:
box_y = y + 2;
box_x = (width - box_width) / 2;
draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2,
- dlg.border.atr, dlg.dialog.atr);
+ dlg.dialog.atr, dlg.border.atr);
print_buttons(dialog, height, width, 0);
@@ -97,14 +98,17 @@ do_resize:
wmove(dialog, box_y, box_x);
wattrset(dialog, dlg.inputbox.atr);
- input_x = strlen(instr);
+ len = strlen(instr);
+ pos = len;
- if (input_x >= box_width) {
- scroll = input_x - box_width + 1;
+ if (len >= box_width) {
+ show_x = len - box_width + 1;
input_x = box_width - 1;
for (i = 0; i < box_width - 1; i++)
- waddch(dialog, instr[scroll + i]);
+ waddch(dialog, instr[show_x + i]);
} else {
+ show_x = 0;
+ input_x = len;
waddstr(dialog, instr);
}
@@ -121,45 +125,104 @@ do_resize:
case KEY_UP:
case KEY_DOWN:
break;
- case KEY_LEFT:
- continue;
- case KEY_RIGHT:
- continue;
case KEY_BACKSPACE:
case 127:
- if (input_x || scroll) {
+ if (pos) {
wattrset(dialog, dlg.inputbox.atr);
- if (!input_x) {
- scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1);
- wmove(dialog, box_y, box_x);
- for (i = 0; i < box_width; i++)
- waddch(dialog,
- instr[scroll + input_x + i] ?
- instr[scroll + input_x + i] : ' ');
- input_x = strlen(instr) - scroll;
+ if (input_x == 0) {
+ show_x--;
} else
input_x--;
- instr[scroll + input_x] = '\0';
- mvwaddch(dialog, box_y, input_x + box_x, ' ');
+
+ if (pos < len) {
+ for (i = pos - 1; i < len; i++) {
+ instr[i] = instr[i+1];
+ }
+ }
+
+ pos--;
+ len--;
+ instr[len] = '\0';
+ wmove(dialog, box_y, box_x);
+ for (i = 0; i < box_width; i++) {
+ if (!instr[show_x + i]) {
+ waddch(dialog, ' ');
+ break;
+ }
+ waddch(dialog, instr[show_x + i]);
+ }
wmove(dialog, box_y, input_x + box_x);
wrefresh(dialog);
}
continue;
+ case KEY_LEFT:
+ if (pos > 0) {
+ if (input_x > 0) {
+ wmove(dialog, box_y, --input_x + box_x);
+ } else if (input_x == 0) {
+ show_x--;
+ wmove(dialog, box_y, box_x);
+ for (i = 0; i < box_width; i++) {
+ if (!instr[show_x + i]) {
+ waddch(dialog, ' ');
+ break;
+ }
+ waddch(dialog, instr[show_x + i]);
+ }
+ wmove(dialog, box_y, box_x);
+ }
+ pos--;
+ }
+ continue;
+ case KEY_RIGHT:
+ if (pos < len) {
+ if (input_x < box_width - 1) {
+ wmove(dialog, box_y, ++input_x + box_x);
+ } else if (input_x == box_width - 1) {
+ show_x++;
+ wmove(dialog, box_y, box_x);
+ for (i = 0; i < box_width; i++) {
+ if (!instr[show_x + i]) {
+ waddch(dialog, ' ');
+ break;
+ }
+ waddch(dialog, instr[show_x + i]);
+ }
+ wmove(dialog, box_y, input_x + box_x);
+ }
+ pos++;
+ }
+ continue;
default:
if (key < 0x100 && isprint(key)) {
- if (scroll + input_x < MAX_LEN) {
+ if (len < MAX_LEN) {
wattrset(dialog, dlg.inputbox.atr);
- instr[scroll + input_x] = key;
- instr[scroll + input_x + 1] = '\0';
+ if (pos < len) {
+ for (i = len; i > pos; i--)
+ instr[i] = instr[i-1];
+ instr[pos] = key;
+ } else {
+ instr[len] = key;
+ }
+ pos++;
+ len++;
+ instr[len] = '\0';
+
if (input_x == box_width - 1) {
- scroll++;
- wmove(dialog, box_y, box_x);
- for (i = 0; i < box_width - 1; i++)
- waddch(dialog, instr [scroll + i]);
+ show_x++;
} else {
- wmove(dialog, box_y, input_x++ + box_x);
- waddch(dialog, key);
+ input_x++;
+ }
+
+ wmove(dialog, box_y, box_x);
+ for (i = 0; i < box_width; i++) {
+ if (!instr[show_x + i]) {
+ waddch(dialog, ' ');
+ break;
+ }
+ waddch(dialog, instr[show_x + i]);
}
+ wmove(dialog, box_y, input_x + box_x);
wrefresh(dialog);
} else
flash(); /* Alarm user about overflow */
@@ -180,7 +243,7 @@ do_resize:
case KEY_LEFT:
switch (button) {
case -1:
- button = 1; /* Indicates "Cancel" button is selected */
+ button = 1; /* Indicates "Help" button is selected */
print_buttons(dialog, height, width, 1);
break;
case 0:
@@ -204,7 +267,7 @@ do_resize:
print_buttons(dialog, height, width, 0);
break;
case 0:
- button = 1; /* Indicates "Cancel" button is selected */
+ button = 1; /* Indicates "Help" button is selected */
print_buttons(dialog, height, width, 1);
break;
case 1:
diff --git a/extra/config/lxdialog/menubox.c b/extra/config/lxdialog/menubox.c
index c689fc03b..c93de0b2f 100644
--- a/extra/config/lxdialog/menubox.c
+++ b/extra/config/lxdialog/menubox.c
@@ -154,12 +154,14 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x,
*/
static void print_buttons(WINDOW * win, int height, int width, int selected)
{
- int x = width / 2 - 16;
+ int x = width / 2 - 28;
int y = height - 2;
print_button(win, gettext("Select"), y, x, selected == 0);
print_button(win, gettext(" Exit "), y, x + 12, selected == 1);
print_button(win, gettext(" Help "), y, x + 24, selected == 2);
+ print_button(win, gettext(" Save "), y, x + 36, selected == 3);
+ print_button(win, gettext(" Load "), y, x + 48, selected == 4);
wmove(win, y, x + 1 + 12 * selected);
wrefresh(win);
@@ -191,7 +193,7 @@ int dialog_menu(const char *title, const char *prompt,
do_resize:
height = getmaxy(stdscr);
width = getmaxx(stdscr);
- if (height < 15 || width < 65)
+ if (height < MENUBOX_HEIGTH_MIN || width < MENUBOX_WIDTH_MIN)
return -ERRDISPLAYTOOSMALL;
height -= 4;
@@ -201,8 +203,8 @@ do_resize:
max_choice = MIN(menu_height, item_count());
/* center dialog box on screen */
- x = (COLS - width) / 2;
- y = (LINES - height) / 2;
+ x = (getmaxx(stdscr) - width) / 2;
+ y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
@@ -301,10 +303,11 @@ do_resize:
}
}
- if (i < max_choice ||
- key == KEY_UP || key == KEY_DOWN ||
- key == '-' || key == '+' ||
- key == KEY_PPAGE || key == KEY_NPAGE) {
+ if (item_count() != 0 &&
+ (i < max_choice ||
+ key == KEY_UP || key == KEY_DOWN ||
+ key == '-' || key == '+' ||
+ key == KEY_PPAGE || key == KEY_NPAGE)) {
/* Remove highligt of current item */
print_item(scroll + choice, choice, FALSE);
@@ -372,7 +375,7 @@ do_resize:
case TAB:
case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0)
- ? 2 : (button > 2 ? 0 : button);
+ ? 4 : (button > 4 ? 0 : button);
print_buttons(dialog, height, width, button);
wrefresh(menu);
@@ -383,6 +386,10 @@ do_resize:
case 'n':
case 'm':
case '/':
+ case 'h':
+ case '?':
+ case 'z':
+ case '\n':
/* save scroll info */
*s_scroll = scroll;
delwin(menu);
@@ -390,30 +397,26 @@ do_resize:
item_set(scroll + choice);
item_set_selected(1);
switch (key) {
+ case 'h':
+ case '?':
+ return 2;
case 's':
- return 3;
case 'y':
- return 3;
+ return 5;
case 'n':
- return 4;
+ return 6;
case 'm':
- return 5;
+ return 7;
case ' ':
- return 6;
+ return 8;
case '/':
- return 7;
+ return 9;
+ case 'z':
+ return 10;
+ case '\n':
+ return button;
}
return 0;
- case 'h':
- case '?':
- button = 2;
- case '\n':
- *s_scroll = scroll;
- delwin(menu);
- delwin(dialog);
- item_set(scroll + choice);
- item_set_selected(1);
- return button;
case 'e':
case 'x':
key = KEY_ESC;
diff --git a/extra/config/lxdialog/textbox.c b/extra/config/lxdialog/textbox.c
index c704712d0..1773319b9 100644
--- a/extra/config/lxdialog/textbox.c
+++ b/extra/config/lxdialog/textbox.c
@@ -22,23 +22,25 @@
#include "dialog.h"
static void back_lines(int n);
-static void print_page(WINDOW * win, int height, int width);
-static void print_line(WINDOW * win, int row, int width);
+static void print_page(WINDOW *win, int height, int width, update_text_fn
+ update_text, void *data);
+static void print_line(WINDOW *win, int row, int width);
static char *get_line(void);
static void print_position(WINDOW * win);
static int hscroll;
static int begin_reached, end_reached, page_length;
-static const char *buf;
-static const char *page;
+static char *buf;
+static char *page;
/*
* refresh window content
*/
static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw,
- int cur_y, int cur_x)
+ int cur_y, int cur_x, update_text_fn update_text,
+ void *data)
{
- print_page(box, boxh, boxw);
+ print_page(box, boxh, boxw, update_text, data);
print_position(dialog);
wmove(dialog, cur_y, cur_x); /* Restore cursor position */
wrefresh(dialog);
@@ -47,14 +49,18 @@ static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw,
/*
* Display text from a file in a dialog box.
+ *
+ * keys is a null-terminated array
+ * update_text() may not add or remove any '\n' or '\0' in tbuf
*/
-int dialog_textbox(const char *title, const char *tbuf,
- int initial_height, int initial_width)
+int dialog_textbox(const char *title, char *tbuf, int initial_height,
+ int initial_width, int *keys, int *_vscroll, int *_hscroll,
+ update_text_fn update_text, void *data)
{
int i, x, y, cur_x, cur_y, key = 0;
int height, width, boxh, boxw;
- int passed_end;
WINDOW *dialog, *box;
+ bool done = false;
begin_reached = 1;
end_reached = 0;
@@ -63,9 +69,18 @@ int dialog_textbox(const char *title, const char *tbuf,
buf = tbuf;
page = buf; /* page is pointer to start of page to be displayed */
+ if (_vscroll && *_vscroll) {
+ begin_reached = 0;
+
+ for (i = 0; i < *_vscroll; i++)
+ get_line();
+ }
+ if (_hscroll)
+ hscroll = *_hscroll;
+
do_resize:
getmaxyx(stdscr, height, width);
- if (height < 8 || width < 8)
+ if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN)
return -ERRDISPLAYTOOSMALL;
if (initial_height != 0)
height = initial_height;
@@ -83,8 +98,8 @@ do_resize:
width = 0;
/* center dialog box on screen */
- x = (COLS - width) / 2;
- y = (LINES - height) / 2;
+ x = (getmaxx(stdscr) - width) / 2;
+ y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
@@ -120,25 +135,28 @@ do_resize:
/* Print first page of text */
attr_clear(box, boxh, boxw, dlg.dialog.atr);
- refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x, update_text,
+ data);
- while ((key != KEY_ESC) && (key != '\n')) {
+ while (!done) {
key = wgetch(dialog);
switch (key) {
case 'E': /* Exit */
case 'e':
case 'X':
case 'x':
- delwin(box);
- delwin(dialog);
- return 0;
+ case 'q':
+ case '\n':
+ done = true;
+ break;
case 'g': /* First page */
case KEY_HOME:
if (!begin_reached) {
begin_reached = 1;
page = buf;
refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ cur_y, cur_x, update_text,
+ data);
}
break;
case 'G': /* Last page */
@@ -148,78 +166,48 @@ do_resize:
/* point to last char in buf */
page = buf + strlen(buf);
back_lines(boxh);
- refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case 'K': /* Previous line */
case 'k':
case KEY_UP:
- if (!begin_reached) {
- back_lines(page_length + 1);
-
- /* We don't call print_page() here but use
- * scrolling to ensure faster screen update.
- * However, 'end_reached' and 'page_length'
- * should still be updated, and 'page' should
- * point to start of next page. This is done
- * by calling get_line() in the following
- * 'for' loop. */
- scrollok(box, TRUE);
- wscrl(box, -1); /* Scroll box region down one line */
- scrollok(box, FALSE);
- page_length = 0;
- passed_end = 0;
- for (i = 0; i < boxh; i++) {
- if (!i) {
- /* print first line of page */
- print_line(box, 0, boxw);
- wnoutrefresh(box);
- } else
- /* Called to update 'end_reached' and 'page' */
- get_line();
- if (!passed_end)
- page_length++;
- if (end_reached && !passed_end)
- passed_end = 1;
- }
+ if (begin_reached)
+ break;
- print_position(dialog);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
+ back_lines(page_length + 1);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case 'B': /* Previous page */
case 'b':
+ case 'u':
case KEY_PPAGE:
if (begin_reached)
break;
back_lines(page_length + boxh);
- refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case 'J': /* Next line */
case 'j':
case KEY_DOWN:
- if (!end_reached) {
- begin_reached = 0;
- scrollok(box, TRUE);
- scroll(box); /* Scroll box region up one line */
- scrollok(box, FALSE);
- print_line(box, boxh - 1, boxw);
- wnoutrefresh(box);
- print_position(dialog);
- wmove(dialog, cur_y, cur_x); /* Restore cursor position */
- wrefresh(dialog);
- }
+ if (end_reached)
+ break;
+
+ back_lines(page_length - 1);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case KEY_NPAGE: /* Next page */
case ' ':
+ case 'd':
if (end_reached)
break;
begin_reached = 0;
- refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case '0': /* Beginning of line */
case 'H': /* Scroll left */
@@ -234,8 +222,8 @@ do_resize:
hscroll--;
/* Reprint current page to scroll horizontally */
back_lines(page_length);
- refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case 'L': /* Scroll right */
case 'l':
@@ -245,11 +233,12 @@ do_resize:
hscroll++;
/* Reprint current page to scroll horizontally */
back_lines(page_length);
- refresh_text_box(dialog, box, boxh, boxw,
- cur_y, cur_x);
+ refresh_text_box(dialog, box, boxh, boxw, cur_y,
+ cur_x, update_text, data);
break;
case KEY_ESC:
- key = on_key_esc(dialog);
+ if (on_key_esc(dialog) == KEY_ESC)
+ done = true;
break;
case KEY_RESIZE:
back_lines(height);
@@ -257,11 +246,31 @@ do_resize:
delwin(dialog);
on_key_resize();
goto do_resize;
+ default:
+ for (i = 0; keys[i]; i++) {
+ if (key == keys[i]) {
+ done = true;
+ break;
+ }
+ }
}
}
delwin(box);
delwin(dialog);
- return key; /* ESC pressed */
+ if (_vscroll) {
+ const char *s;
+
+ s = buf;
+ *_vscroll = 0;
+ back_lines(page_length);
+ while (s < page && (s = strchr(s, '\n'))) {
+ (*_vscroll)++;
+ s++;
+ }
+ }
+ if (_hscroll)
+ *_hscroll = hscroll;
+ return key;
}
/*
@@ -298,12 +307,23 @@ static void back_lines(int n)
}
/*
- * Print a new page of text. Called by dialog_textbox().
+ * Print a new page of text.
*/
-static void print_page(WINDOW * win, int height, int width)
+static void print_page(WINDOW *win, int height, int width, update_text_fn
+ update_text, void *data)
{
int i, passed_end = 0;
+ if (update_text) {
+ char *end;
+
+ for (i = 0; i < height; i++)
+ get_line();
+ end = page;
+ back_lines(height);
+ update_text(buf, page - buf, end - buf, data);
+ }
+
page_length = 0;
for (i = 0; i < height; i++) {
print_line(win, i, width);
@@ -316,11 +336,10 @@ static void print_page(WINDOW * win, int height, int width)
}
/*
- * Print a new line of text. Called by dialog_textbox() and print_page().
+ * Print a new line of text.
*/
static void print_line(WINDOW * win, int row, int width)
{
- int y, x;
char *line;
line = get_line();
@@ -329,10 +348,10 @@ static void print_line(WINDOW * win, int row, int width)
waddch(win, ' ');
waddnstr(win, line, MIN(strlen(line), width - 2));
- getyx(win, y, x);
/* Clear 'residue' of previous line */
#if OLD_NCURSES
{
+ int x = getcurx(win);
int i;
for (i = 0; i < width - x; i++)
waddch(win, ' ');
@@ -355,10 +374,8 @@ static char *get_line(void)
end_reached = 0;
while (*page != '\n') {
if (*page == '\0') {
- if (!end_reached) {
- end_reached = 1;
- break;
- }
+ end_reached = 1;
+ break;
} else if (i < MAX_LEN)
line[i++] = *(page++);
else {
@@ -371,7 +388,7 @@ static char *get_line(void)
if (i <= MAX_LEN)
line[i] = '\0';
if (!end_reached)
- page++; /* move pass '\n' */
+ page++; /* move past '\n' */
return line;
}
diff --git a/extra/config/lxdialog/util.c b/extra/config/lxdialog/util.c
index 86d95cca4..58a8289dd 100644
--- a/extra/config/lxdialog/util.c
+++ b/extra/config/lxdialog/util.c
@@ -19,8 +19,13 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <stdarg.h>
+
#include "dialog.h"
+/* Needed in signal handler in mconf.c */
+int saved_x, saved_y;
+
struct dialog_info dlg;
static void set_mono_theme(void)
@@ -249,15 +254,56 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr)
void dialog_clear(void)
{
- attr_clear(stdscr, LINES, COLS, dlg.screen.atr);
+ int lines, columns;
+
+ lines = getmaxy(stdscr);
+ columns = getmaxx(stdscr);
+
+ attr_clear(stdscr, lines, columns, dlg.screen.atr);
/* Display background title if it exists ... - SLH */
if (dlg.backtitle != NULL) {
- int i;
+ int i, len = 0, skip = 0;
+ struct subtitle_list *pos;
wattrset(stdscr, dlg.screen.atr);
mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle);
+
+ for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
+ /* 3 is for the arrow and spaces */
+ len += strlen(pos->text) + 3;
+ }
+
wmove(stdscr, 1, 1);
- for (i = 1; i < COLS - 1; i++)
+ if (len > columns - 2) {
+ const char *ellipsis = "[...] ";
+ waddstr(stdscr, ellipsis);
+ skip = len - (columns - 2 - strlen(ellipsis));
+ }
+
+ for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
+ if (skip == 0)
+ waddch(stdscr, ACS_RARROW);
+ else
+ skip--;
+
+ if (skip == 0)
+ waddch(stdscr, ' ');
+ else
+ skip--;
+
+ if (skip < strlen(pos->text)) {
+ waddstr(stdscr, pos->text + skip);
+ skip = 0;
+ } else
+ skip -= strlen(pos->text);
+
+ if (skip == 0)
+ waddch(stdscr, ' ');
+ else
+ skip--;
+ }
+
+ for (i = len + 1; i < columns - 1; i++)
waddch(stdscr, ACS_HLINE);
}
wnoutrefresh(stdscr);
@@ -271,8 +317,12 @@ int init_dialog(const char *backtitle)
int height, width;
initscr(); /* Init curses */
+
+ /* Get current cursor position for signal handler in mconf.c */
+ getyx(stdscr, saved_y, saved_x);
+
getmaxyx(stdscr, height, width);
- if (height < 19 || width < 80) {
+ if (height < WINDOW_HEIGTH_MIN || width < WINDOW_WIDTH_MIN) {
endwin();
return -ERRDISPLAYTOOSMALL;
}
@@ -293,6 +343,11 @@ void set_dialog_backtitle(const char *backtitle)
dlg.backtitle = backtitle;
}
+void set_dialog_subtitles(struct subtitle_list *subtitles)
+{
+ dlg.subtitles = subtitles;
+}
+
/*
* End using dialog functions.
*/
@@ -321,27 +376,19 @@ void print_title(WINDOW *dialog, const char *title, int width)
/*
* Print a string of text in a window, automatically wrap around to the
* next line if the string is too long to fit on one line. Newline
- * characters '\n' are replaced by spaces. We start on a new line
+ * characters '\n' are propperly processed. We start on a new line
* if there is no room for at least 4 nonblanks following a double-space.
*/
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
{
int newl, cur_x, cur_y;
- int i, prompt_len, room, wlen;
- char tempstr[MAX_LEN + 1], *word, *sp, *sp2;
+ int prompt_len, room, wlen;
+ char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;
strcpy(tempstr, prompt);
prompt_len = strlen(tempstr);
- /*
- * Remove newlines
- */
- for (i = 0; i < prompt_len; i++) {
- if (tempstr[i] == '\n')
- tempstr[i] = ' ';
- }
-
if (prompt_len <= width - x * 2) { /* If prompt is short */
wmove(win, y, (width - prompt_len) / 2);
waddstr(win, tempstr);
@@ -351,7 +398,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
newl = 1;
word = tempstr;
while (word && *word) {
- sp = strchr(word, ' ');
+ sp = strpbrk(word, "\n ");
+ if (sp && *sp == '\n')
+ newline_separator = sp;
+
if (sp)
*sp++ = 0;
@@ -363,7 +413,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
if (wlen > room ||
(newl && wlen < 4 && sp
&& wlen + 1 + strlen(sp) > room
- && (!(sp2 = strchr(sp, ' '))
+ && (!(sp2 = strpbrk(sp, "\n "))
|| wlen + 1 + (sp2 - sp) > room))) {
cur_y++;
cur_x = x;
@@ -371,7 +421,15 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
wmove(win, cur_y, cur_x);
waddstr(win, word);
getyx(win, cur_y, cur_x);
- cur_x++;
+
+ /* Move to the next line if the word separator was a newline */
+ if (newline_separator) {
+ cur_y++;
+ cur_x = x;
+ newline_separator = 0;
+ } else
+ cur_x++;
+
if (sp && *sp == ' ') {
cur_x++; /* double space */
while (*++sp == ' ') ;
diff --git a/extra/config/lxdialog/yesno.c b/extra/config/lxdialog/yesno.c
index 4e6e8090c..676fb2f82 100644
--- a/extra/config/lxdialog/yesno.c
+++ b/extra/config/lxdialog/yesno.c
@@ -45,14 +45,14 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width)
WINDOW *dialog;
do_resize:
- if (getmaxy(stdscr) < (height + 4))
+ if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN))
return -ERRDISPLAYTOOSMALL;
- if (getmaxx(stdscr) < (width + 4))
+ if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN))
return -ERRDISPLAYTOOSMALL;
/* center dialog box on screen */
- x = (COLS - width) / 2;
- y = (LINES - height) / 2;
+ x = (getmaxx(stdscr) - width) / 2;
+ y = (getmaxy(stdscr) - height) / 2;
draw_shadow(stdscr, y, x, height, width);
diff --git a/extra/config/mconf.c b/extra/config/mconf.c
index 3effa5b5b..fcf6478ec 100644
--- a/extra/config/mconf.c
+++ b/extra/config/mconf.c
@@ -15,20 +15,19 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
+#include <signal.h>
#include <unistd.h>
#include <locale.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
#include "lxdialog/dialog.h"
static const char mconf_readme[] = N_(
"Overview\n"
"--------\n"
-"Some features may be built directly into uClibc. Some features\n"
-"may be completely removed altogether. There are also certain\n"
-"parameters which are not really features, but must be\n"
-"entered in as decimal or hexadecimal numbers or possibly text.\n"
+"This interface let you select features and parameters for the build.\n"
+"Features can either be built-in, modularized, or ignored. Parameters\n"
+"must be entered in as decimal or hexadecimal numbers or text.\n"
"\n"
"Menu items beginning with following braces represent features that\n"
" [ ] can be built in or removed\n"
@@ -49,7 +48,7 @@ static const char mconf_readme[] = N_(
"----------\n"
"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
" you wish to change or submenu wish to select and press <Enter>.\n"
-" Submenus are designated by \"--->\".\n"
+" Submenus are designated by \"--->\", empty ones by \"----\".\n"
"\n"
" Shortcut: Press the option's highlighted letter (hotkey).\n"
" Pressing a hotkey more than once will sequence\n"
@@ -66,13 +65,15 @@ static const char mconf_readme[] = N_(
" there is a delayed response which you may find annoying.\n"
"\n"
" Also, the <TAB> and cursor keys will cycle between <Select>,\n"
-" <Exit> and <Help>\n"
+" <Exit> and <Help>.\n"
"\n"
"o To get help with an item, use the cursor keys to highlight <Help>\n"
-" and Press <ENTER>.\n"
+" and press <ENTER>.\n"
"\n"
" Shortcut: Press <H> or <?>.\n"
"\n"
+"o To toggle the display of hidden options, press <Z>.\n"
+"\n"
"\n"
"Radiolists (Choice lists)\n"
"-----------\n"
@@ -104,10 +105,10 @@ static const char mconf_readme[] = N_(
"Text Box (Help Window)\n"
"--------\n"
"o Use the cursor keys to scroll up/down/left/right. The VI editor\n"
-" keys h,j,k,l function here as do <SPACE BAR> and <B> for those\n"
-" who are familiar with less and lynx.\n"
+" keys h,j,k,l function here as do <u>, <d>, <SPACE BAR> and <B> for \n"
+" those who are familiar with less and lynx.\n"
"\n"
-"o Press <E>, <X>, <Enter> or <Esc><Esc> to exit.\n"
+"o Press <E>, <X>, <q>, <Enter> or <Esc><Esc> to exit.\n"
"\n"
"\n"
"Alternate Configuration Files\n"
@@ -147,9 +148,9 @@ static const char mconf_readme[] = N_(
"\n"
"Optional personality available\n"
"------------------------------\n"
-"If you prefer to have all of the options listed in a single\n"
-"menu, rather than the default multimenu hierarchy, run the menuconfig\n"
-"with MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
+"If you prefer to have all of the options listed in a single menu, rather\n"
+"than the default multimenu hierarchy, run the menuconfig with\n"
+"MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
"\n"
"make MENUCONFIG_MODE=single_menu menuconfig\n"
"\n"
@@ -175,11 +176,11 @@ static const char mconf_readme[] = N_(
"\n"),
menu_instructions[] = N_(
"Arrow keys navigate the menu. "
- "<Enter> selects submenus --->. "
+ "<Enter> selects submenus ---> (or empty submenus ----). "
"Highlighted letters are hotkeys. "
- "Pressing <Y> selectes a feature, while <N> will exclude a feature. "
+ "Pressing <Y> includes, <N> excludes, <M> modularizes features. "
"Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
- "Legend: [*] feature is selected [ ] feature is excluded"),
+ "Legend: [*] built-in [ ] excluded <M> module < > module capable"),
radiolist_instructions[] = N_(
"Use the arrow keys to navigate this window or "
"press the hotkey of the item you wish to select "
@@ -198,8 +199,6 @@ inputbox_instructions_string[] = N_(
setmod_text[] = N_(
"This feature depends on another which has been configured as a module.\n"
"As a result, this feature will be built as a module."),
-nohelp_text[] = N_(
- "There is no help available for this option.\n"),
load_config_text[] = N_(
"Enter the name of the configuration file you wish to load. "
"Accept the name shown to restore the configuration you "
@@ -210,18 +209,18 @@ load_config_help[] = N_(
"configurations available on a single machine.\n"
"\n"
"If you have saved a previous configuration in a file other than the\n"
- "default, entering the name of the file here will allow you\n"
- "to modify that configuration.\n"
+ "default one, entering its name here will allow you to modify that\n"
+ "configuration.\n"
"\n"
"If you are uncertain, then you have probably never used alternate\n"
- "configuration files. You should therefor leave this blank to abort.\n"),
+ "configuration files. You should therefore leave this blank to abort.\n"),
save_config_text[] = N_(
"Enter a filename to which this configuration should be saved "
"as an alternate. Leave blank to abort."),
save_config_help[] = N_(
"\n"
- "For various reasons, one may wish to keep different\n"
- "configurations available on a single machine.\n"
+ "For various reasons, one may wish to keep different configurations\n"
+ "available on a single machine.\n"
"\n"
"Entering a file name here will allow you to later retrieve, modify\n"
"and use the current configuration as an alternate to whatever\n"
@@ -231,32 +230,39 @@ save_config_help[] = N_(
"leave this blank.\n"),
search_help[] = N_(
"\n"
- "Search for CONFIG_ symbols and display their relations.\n"
+ "Search for symbols and display their relations.\n"
"Regular expressions are allowed.\n"
"Example: search for \"^FOO\"\n"
"Result:\n"
"-----------------------------------------------------------------\n"
"Symbol: FOO [=m]\n"
+ "Type : tristate\n"
"Prompt: Foo bus is used to drive the bar HW\n"
- "Defined at drivers/pci/Kconfig:47\n"
- "Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
- "Location:\n"
- " -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n"
- " -> PCI support (PCI [=y])\n"
- " -> PCI access mode (<choice> [=y])\n"
- "Selects: LIBCRC32\n"
- "Selected by: BAR\n"
+ " Defined at drivers/pci/Kconfig:47\n"
+ " Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
+ " Location:\n"
+ " -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
+ " -> PCI support (PCI [=y])\n"
+ "(1) -> PCI access mode (<choice> [=y])\n"
+ " Selects: LIBCRC32\n"
+ " Selected by: BAR\n"
"-----------------------------------------------------------------\n"
+ "o The line 'Type:' shows the type of the configuration option for\n"
+ " this symbol (boolean, tristate, string, ...)\n"
"o The line 'Prompt:' shows the text used in the menu structure for\n"
- " this CONFIG_ symbol\n"
+ " this symbol\n"
"o The 'Defined at' line tell at what file / line number the symbol\n"
" is defined\n"
"o The 'Depends on:' line tell what symbols needs to be defined for\n"
" this symbol to be visible in the menu (selectable)\n"
"o The 'Location:' lines tell where in the menu structure this symbol\n"
" is located\n"
- " A location followed by a [=y] indicate that this is a selectable\n"
- " menu item - and current value is displayed inside brackets.\n"
+ " A location followed by a [=y] indicates that this is a\n"
+ " selectable menu item - and the current value is displayed inside\n"
+ " brackets.\n"
+ " Press the key in the (#) prefix to jump directly to that\n"
+ " location. You will be returned to the current search results\n"
+ " after exiting this new menu.\n"
"o The 'Selects:' line tell what symbol will be automatically\n"
" selected if this symbol is selected (y or m)\n"
"o The 'Selected by' line tell what symbol has selected this symbol\n"
@@ -264,131 +270,144 @@ search_help[] = N_(
"Only relevant lines are shown.\n"
"\n\n"
"Search examples:\n"
- "Examples: USB => find all CONFIG_ symbols containing USB\n"
- " ^USB => find all CONFIG_ symbols starting with USB\n"
- " USB$ => find all CONFIG_ symbols ending with USB\n"
+ "Examples: USB => find all symbols containing USB\n"
+ " ^USB => find all symbols starting with USB\n"
+ " USB$ => find all symbols ending with USB\n"
"\n");
static int indent;
static struct menu *current_menu;
static int child_count;
static int single_menu_mode;
+static int show_all_options;
+static int save_and_exit;
-static void conf(struct menu *menu);
+static void conf(struct menu *menu, struct menu *active_menu);
static void conf_choice(struct menu *menu);
static void conf_string(struct menu *menu);
static void conf_load(void);
static void conf_save(void);
+static int show_textbox_ext(const char *title, char *text, int r, int c,
+ int *keys, int *vscroll, int *hscroll,
+ update_text_fn update_text, void *data);
static void show_textbox(const char *title, const char *text, int r, int c);
static void show_helptext(const char *title, const char *text);
static void show_help(struct menu *menu);
-static void get_prompt_str(struct gstr *r, struct property *prop)
+static char filename[PATH_MAX+1];
+static void set_config_filename(const char *config_filename)
{
- int i, j;
- struct menu *submenu[8], *menu;
-
- str_printf(r, _("Prompt: %s\n"), _(prop->text));
- str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
- prop->menu->lineno);
- if (!expr_is_yes(prop->visible.expr)) {
- str_append(r, _(" Depends on: "));
- expr_gstr_print(prop->visible.expr, r);
- str_append(r, "\n");
+ static char menu_backtitle[PATH_MAX+128];
+ int size;
+
+ size = snprintf(menu_backtitle, sizeof(menu_backtitle),
+ "%s - %s", config_filename, rootmenu.prompt->text);
+ if (size >= sizeof(menu_backtitle))
+ menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
+ set_dialog_backtitle(menu_backtitle);
+
+ size = snprintf(filename, sizeof(filename), "%s", config_filename);
+ if (size >= sizeof(filename))
+ filename[sizeof(filename)-1] = '\0';
+}
+
+struct subtitle_part {
+ struct list_head entries;
+ const char *text;
+};
+static LIST_HEAD(trail);
+
+static struct subtitle_list *subtitles;
+static void set_subtitle(void)
+{
+ struct subtitle_part *sp;
+ struct subtitle_list *pos, *tmp;
+
+ for (pos = subtitles; pos != NULL; pos = tmp) {
+ tmp = pos->next;
+ free(pos);
}
- menu = prop->menu->parent;
- for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
- submenu[i++] = menu;
- if (i > 0) {
- str_printf(r, _(" Location:\n"));
- for (j = 4; --i >= 0; j += 2) {
- menu = submenu[i];
- str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
- if (menu->sym) {
- str_printf(r, " (%s [=%s])", menu->sym->name ?
- menu->sym->name : _("<choice>"),
- sym_get_string_value(menu->sym));
+
+ subtitles = NULL;
+ list_for_each_entry(sp, &trail, entries) {
+ if (sp->text) {
+ if (pos) {
+ pos->next = xcalloc(sizeof(*pos), 1);
+ pos = pos->next;
+ } else {
+ subtitles = pos = xcalloc(sizeof(*pos), 1);
}
- str_append(r, "\n");
+ pos->text = sp->text;
}
}
+
+ set_dialog_subtitles(subtitles);
}
-static void get_symbol_str(struct gstr *r, struct symbol *sym)
+static void reset_subtitle(void)
{
- bool hit;
- struct property *prop;
+ struct subtitle_list *pos, *tmp;
- if (sym && sym->name)
- str_printf(r, "Symbol: %s [=%s]\n", sym->name,
- sym_get_string_value(sym));
- for_all_prompts(sym, prop)
- get_prompt_str(r, prop);
- hit = false;
- for_all_properties(sym, prop, P_SELECT) {
- if (!hit) {
- str_append(r, " Selects: ");
- hit = true;
- } else
- str_printf(r, " && ");
- expr_gstr_print(prop->expr, r);
+ for (pos = subtitles; pos != NULL; pos = tmp) {
+ tmp = pos->next;
+ free(pos);
}
- if (hit)
- str_append(r, "\n");
- if (sym->rev_dep.expr) {
- str_append(r, _(" Selected by: "));
- expr_gstr_print(sym->rev_dep.expr, r);
- str_append(r, "\n");
- }
- str_append(r, "\n\n");
+ subtitles = NULL;
+ set_dialog_subtitles(subtitles);
}
-static struct gstr get_relations_str(struct symbol **sym_arr)
+struct search_data {
+ struct list_head *head;
+ struct menu **targets;
+ int *keys;
+};
+
+static void update_text(char *buf, size_t start, size_t end, void *_data)
{
- struct symbol *sym;
- struct gstr res = str_new();
- int i;
+ struct search_data *data = _data;
+ struct jump_key *pos;
+ int k = 0;
- for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
- get_symbol_str(&res, sym);
- if (!i)
- str_append(&res, _("No matches found.\n"));
- return res;
-}
+ list_for_each_entry(pos, data->head, entries) {
+ if (pos->offset >= start && pos->offset < end) {
+ char header[4];
-static char filename[PATH_MAX+1];
-static void set_config_filename(const char *config_filename)
-{
- static char menu_backtitle[PATH_MAX+128];
- int size;
- struct symbol *sym;
+ if (k < JUMP_NB) {
+ int key = '0' + (pos->index % JUMP_NB) + 1;
- sym = sym_lookup("VERSION", 0);
- sym_calc_value(sym);
- size = snprintf(menu_backtitle, sizeof(menu_backtitle),
- _("%s - uClibc v%s Configuration"),
- config_filename, sym_get_string_value(sym));
- if (size >= sizeof(menu_backtitle))
- menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
- set_dialog_backtitle(menu_backtitle);
+ sprintf(header, "(%c)", key);
+ data->keys[k] = key;
+ data->targets[k] = pos->target;
+ k++;
+ } else {
+ sprintf(header, " ");
+ }
- size = snprintf(filename, sizeof(filename), "%s", config_filename);
- if (size >= sizeof(filename))
- filename[sizeof(filename)-1] = '\0';
+ memcpy(buf + pos->offset, header, sizeof(header) - 1);
+ }
+ }
+ data->keys[k] = 0;
}
-
static void search_conf(void)
{
struct symbol **sym_arr;
struct gstr res;
+ struct gstr title;
char *dialog_input;
- int dres;
+ int dres, vscroll = 0, hscroll = 0;
+ bool again;
+ struct gstr sttext;
+ struct subtitle_part stpart;
+
+ title = str_new();
+ str_printf( &title, _("Enter %s (sub)string or regexp to search for "
+ "(with or without \"%s\")"), CONFIG_, CONFIG_);
+
again:
dialog_clear();
dres = dialog_inputbox(_("Search Configuration Parameter"),
- _("Enter CONFIG_ (sub)string to search for "
- "(with or without \"CONFIG\")"),
+ str_get(&title),
10, 75, "");
switch (dres) {
case 0:
@@ -397,19 +416,52 @@ again:
show_helptext(_("Search Configuration"), search_help);
goto again;
default:
+ str_free(&title);
return;
}
- /* strip CONFIG_ if necessary */
+ /* strip the prefix if necessary */
dialog_input = dialog_input_result;
- if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0)
- dialog_input += 7;
+ if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
+ dialog_input += strlen(CONFIG_);
+
+ sttext = str_new();
+ str_printf(&sttext, "Search (%s)", dialog_input_result);
+ stpart.text = str_get(&sttext);
+ list_add_tail(&stpart.entries, &trail);
sym_arr = sym_re_search(dialog_input);
- res = get_relations_str(sym_arr);
+ do {
+ LIST_HEAD(head);
+ struct menu *targets[JUMP_NB];
+ int keys[JUMP_NB + 1], i;
+ struct search_data data = {
+ .head = &head,
+ .targets = targets,
+ .keys = keys,
+ };
+ struct jump_key *pos, *tmp;
+
+ res = get_relations_str(sym_arr, &head);
+ set_subtitle();
+ dres = show_textbox_ext(_("Search Results"), (char *)
+ str_get(&res), 0, 0, keys, &vscroll,
+ &hscroll, &update_text, (void *)
+ &data);
+ again = false;
+ for (i = 0; i < JUMP_NB && keys[i]; i++)
+ if (dres == keys[i]) {
+ conf(targets[i]->parent, targets[i]);
+ again = true;
+ }
+ str_free(&res);
+ list_for_each_entry_safe(pos, tmp, &head, entries)
+ free(pos);
+ } while (again);
free(sym_arr);
- show_textbox(_("Search Results"), str_get(&res), 0, 0);
- str_free(&res);
+ str_free(&title);
+ list_del(trail.prev);
+ str_free(&sttext);
}
static void build_conf(struct menu *menu)
@@ -420,8 +472,16 @@ static void build_conf(struct menu *menu)
int type, tmp, doint = 2;
tristate val;
char ch;
+ bool visible;
- if (!menu_is_visible(menu))
+ /*
+ * note: menu_is_visible() has side effect that it will
+ * recalc the value of the symbol.
+ */
+ visible = menu_is_visible(menu);
+ if (show_all_options && !menu_has_prompt(menu))
+ return;
+ else if (!show_all_options && !visible)
return;
sym = menu->sym;
@@ -438,8 +498,9 @@ static void build_conf(struct menu *menu)
menu->data ? "-->" : "++>",
indent + 1, ' ', prompt);
} else
- item_make(" %*c%s --->", indent + 1, ' ', prompt);
-
+ item_make(" %*c%s %s",
+ indent + 1, ' ', prompt,
+ menu_is_empty(menu) ? "----" : "--->");
item_set_tag('m');
item_set_data(menu);
if (single_menu_mode && menu->data)
@@ -570,7 +631,7 @@ static void build_conf(struct menu *menu)
(sym_has_value(sym) || !sym_is_changable(sym)) ?
"" : _(" (NEW)"));
if (menu->prompt->type == P_MENU) {
- item_add_str(" --->");
+ item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
return;
}
}
@@ -582,40 +643,40 @@ conf_childs:
indent -= doint;
}
-static void conf(struct menu *menu)
+static void conf(struct menu *menu, struct menu *active_menu)
{
struct menu *submenu;
const char *prompt = menu_get_prompt(menu);
+ struct subtitle_part stpart;
struct symbol *sym;
- struct menu *active_menu = NULL;
int res;
int s_scroll = 0;
+ if (menu != &rootmenu)
+ stpart.text = menu_get_prompt(menu);
+ else
+ stpart.text = NULL;
+ list_add_tail(&stpart.entries, &trail);
+
while (1) {
item_reset();
current_menu = menu;
build_conf(menu);
if (!child_count)
break;
- if (menu == &rootmenu) {
- item_make("--- ");
- item_set_tag(':');
- item_make(_(" Load an Alternate Configuration File"));
- item_set_tag('L');
- item_make(_(" Save an Alternate Configuration File"));
- item_set_tag('S');
- }
+ set_subtitle();
dialog_clear();
res = dialog_menu(prompt ? _(prompt) : _("Main Menu"),
_(menu_instructions),
active_menu, &s_scroll);
if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
break;
- if (!item_activate_selected())
- continue;
- if (!item_tag())
- continue;
-
+ if (item_count() != 0) {
+ if (!item_activate_selected())
+ continue;
+ if (!item_tag())
+ continue;
+ }
submenu = item_data();
active_menu = item_data();
if (submenu)
@@ -630,32 +691,36 @@ static void conf(struct menu *menu)
if (single_menu_mode)
submenu->data = (void *) (long) !submenu->data;
else
- conf(submenu);
+ conf(submenu, NULL);
break;
case 't':
if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
conf_choice(submenu);
else if (submenu->prompt->type == P_MENU)
- conf(submenu);
+ conf(submenu, NULL);
break;
case 's':
conf_string(submenu);
break;
- case 'L':
- conf_load();
- break;
- case 'S':
- conf_save();
- break;
}
break;
case 2:
if (sym)
show_help(submenu);
- else
+ else {
+ reset_subtitle();
show_helptext(_("README"), _(mconf_readme));
+ }
break;
case 3:
+ reset_subtitle();
+ conf_save();
+ break;
+ case 4:
+ reset_subtitle();
+ conf_load();
+ break;
+ case 5:
if (item_is_tag('t')) {
if (sym_set_tristate_value(sym, yes))
break;
@@ -663,31 +728,45 @@ static void conf(struct menu *menu)
show_textbox(NULL, setmod_text, 6, 74);
}
break;
- case 4:
+ case 6:
if (item_is_tag('t'))
sym_set_tristate_value(sym, no);
break;
- case 5:
+ case 7:
if (item_is_tag('t'))
sym_set_tristate_value(sym, mod);
break;
- case 6:
+ case 8:
if (item_is_tag('t'))
sym_toggle_tristate_value(sym);
else if (item_is_tag('m'))
- conf(submenu);
+ conf(submenu, NULL);
break;
- case 7:
+ case 9:
search_conf();
break;
+ case 10:
+ show_all_options = !show_all_options;
+ break;
}
}
+
+ list_del(trail.prev);
}
-static void show_textbox(const char *title, const char *text, int r, int c)
+static int show_textbox_ext(const char *title, char *text, int r, int c, int
+ *keys, int *vscroll, int *hscroll, update_text_fn
+ update_text, void *data)
{
dialog_clear();
- dialog_textbox(title, text, r, c);
+ return dialog_textbox(title, text, r, c, keys, vscroll, hscroll,
+ update_text, data);
+}
+
+static void show_textbox(const char *title, const char *text, int r, int c)
+{
+ show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL,
+ NULL, NULL);
}
static void show_helptext(const char *title, const char *text)
@@ -695,22 +774,24 @@ static void show_helptext(const char *title, const char *text)
show_textbox(title, text, 0, 0);
}
+static void conf_message_callback(const char *fmt, va_list ap)
+{
+ char buf[PATH_MAX+1];
+
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ if (save_and_exit)
+ printf("%s", buf);
+ else
+ show_textbox(NULL, buf, 6, 60);
+}
+
static void show_help(struct menu *menu)
{
struct gstr help = str_new();
- struct symbol *sym = menu->sym;
-
- if (menu_has_help(menu))
- {
- if (sym->name) {
- str_printf(&help, "%s:\n\n", sym->name);
- str_append(&help, _(menu_get_help(menu)));
- str_append(&help, "\n");
- }
- } else {
- str_append(&help, nohelp_text);
- }
- get_symbol_str(&help, sym);
+
+ help.max_width = getmaxx(stdscr) - 10;
+ menu_get_ext_help(menu, &help);
+
show_helptext(_(menu_get_prompt(menu)), str_get(&help));
str_free(&help);
}
@@ -731,7 +812,12 @@ static void conf_choice(struct menu *menu)
for (child = menu->list; child; child = child->next) {
if (!menu_is_visible(child))
continue;
- item_make("%s", _(menu_get_prompt(child)));
+ if (child->sym)
+ item_make("%s", _(menu_get_prompt(child)));
+ else {
+ item_make("*** %s ***", _(menu_get_prompt(child)));
+ item_set_tag(':');
+ }
item_set_data(child);
if (child->sym == active)
item_set_selected(1);
@@ -741,12 +827,17 @@ static void conf_choice(struct menu *menu)
dialog_clear();
res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"),
_(radiolist_instructions),
- 15, 70, 6);
+ MENUBOX_HEIGTH_MIN,
+ MENUBOX_WIDTH_MIN,
+ CHECKLIST_HEIGTH_MIN);
selected = item_activate_selected();
switch (res) {
case 0:
if (selected) {
child = item_data();
+ if (!child->sym)
+ break;
+
sym_set_tristate_value(child->sym, yes);
}
return;
@@ -772,7 +863,7 @@ static void conf_string(struct menu *menu)
while (1) {
int res;
- char *heading;
+ const char *heading;
switch (sym_get_type(menu->sym)) {
case S_INT:
@@ -860,9 +951,58 @@ static void conf_save(void)
}
}
+static int handle_exit(void)
+{
+ int res;
+
+ save_and_exit = 1;
+ reset_subtitle();
+ dialog_clear();
+ if (conf_get_changed())
+ res = dialog_yesno(NULL,
+ _("Do you wish to save your new configuration?\n"
+ "(Press <ESC><ESC> to continue configuration.)"),
+ 6, 60);
+ else
+ res = -1;
+
+ end_dialog(saved_x, saved_y);
+
+ switch (res) {
+ case 0:
+ if (conf_write(filename)) {
+ fprintf(stderr, _("\n\n"
+ "Error while writing of the configuration.\n"
+ "Your configuration changes were NOT saved."
+ "\n\n"));
+ return 1;
+ }
+ /* fall through */
+ case -1:
+ printf(_("\n\n"
+ "*** End of the configuration.\n"
+ "*** Execute 'make' to start the build or try 'make help'."
+ "\n\n"));
+ res = 0;
+ break;
+ default:
+ fprintf(stderr, _("\n\n"
+ "Your configuration changes were NOT saved."
+ "\n\n"));
+ if (res != KEY_ESC)
+ res = 0;
+ }
+
+ return res;
+}
+
+static void sig_handler(int signo)
+{
+ exit(handle_exit());
+}
+
int main(int ac, char **av)
{
- int saved_x, saved_y;
char *mode;
int res;
@@ -870,6 +1010,8 @@ int main(int ac, char **av)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ signal(SIGINT, sig_handler);
+
conf_parse(av[1]);
conf_read(NULL);
@@ -879,7 +1021,6 @@ int main(int ac, char **av)
single_menu_mode = 1;
}
- getyx(stdscr, saved_y, saved_x);
if (init_dialog(NULL)) {
fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
@@ -887,40 +1028,12 @@ int main(int ac, char **av)
}
set_config_filename(conf_get_configname());
+ conf_set_message_callback(conf_message_callback);
do {
- conf(&rootmenu);
- dialog_clear();
- if (conf_get_changed())
- res = dialog_yesno(NULL,
- _("Do you wish to save your "
- "new configuration?\n"
- "<ESC><ESC> to continue."),
- 6, 60);
- else
- res = -1;
+ conf(&rootmenu, NULL);
+ res = handle_exit();
} while (res == KEY_ESC);
- end_dialog(saved_x, saved_y);
- switch (res) {
- case 0:
- if (conf_write(filename)) {
- fprintf(stderr, _("\n\n"
- "Error during writing of the configuration.\n"
- "Your configuration changes were NOT saved."
- "\n\n"));
- return 1;
- }
- case -1:
- printf(_("\n\n"
- "*** End of configuration.\n"
- "*** Execute 'make' to build or try 'make help'."
- "\n\n"));
- break;
- default:
- fprintf(stderr, _("\n\n"
- "Your configuration changes were NOT saved."
- "\n\n"));
- }
-
- return conf_write_autoconf();
+ return res;
}
+
diff --git a/extra/config/menu.c b/extra/config/menu.c
index 606ceb9e7..7e233a6ca 100644
--- a/extra/config/menu.c
+++ b/extra/config/menu.c
@@ -3,12 +3,15 @@
* Released under the terms of the GNU GPL v2.0.
*/
+#include <ctype.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
+static const char nohelp_text[] = "There is no help available for this option.";
+
struct menu rootmenu;
static struct menu **last_entry_ptr;
@@ -35,7 +38,7 @@ static void prop_warn(struct property *prop, const char *fmt, ...)
va_end(ap);
}
-void menu_init(void)
+void _menu_init(void)
{
current_entry = current_menu = &rootmenu;
last_entry_ptr = &rootmenu.list;
@@ -45,7 +48,7 @@ void menu_add_entry(struct symbol *sym)
{
struct menu *menu;
- menu = malloc(sizeof(*menu));
+ menu = xmalloc(sizeof(*menu));
memset(menu, 0, sizeof(*menu));
menu->sym = sym;
menu->parent = current_menu;
@@ -55,6 +58,8 @@ void menu_add_entry(struct symbol *sym)
*last_entry_ptr = menu;
last_entry_ptr = &menu->next;
current_entry = menu;
+ if (sym)
+ menu_add_symbol(P_SYMBOL, sym, NULL);
}
void menu_end_entry(void)
@@ -74,7 +79,7 @@ void menu_end_menu(void)
current_menu = current_menu->parent;
}
-struct expr *menu_check_dep(struct expr *e)
+static struct expr *menu_check_dep(struct expr *e)
{
if (!e)
return e;
@@ -133,8 +138,35 @@ struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *e
while (isspace(*prompt))
prompt++;
}
- if (current_entry->prompt)
+ if (current_entry->prompt && current_entry != &rootmenu)
prop_warn(prop, "prompt redefined");
+
+ /* Apply all upper menus' visibilities to actual prompts. */
+ if(type == P_PROMPT) {
+ struct menu *menu = current_entry;
+
+ while ((menu = menu->parent) != NULL) {
+ struct expr *dup_expr;
+
+ if (!menu->visibility)
+ continue;
+ /*
+ * Do not add a reference to the
+ * menu's visibility expression but
+ * use a copy of it. Otherwise the
+ * expression reduction functions
+ * will modify expressions that have
+ * multiple references which can
+ * cause unwanted side effects.
+ */
+ dup_expr = expr_copy(menu->visibility);
+
+ prop->visible.expr
+ = expr_alloc_and(prop->visible.expr,
+ dup_expr);
+ }
+ }
+
current_entry->prompt = prop;
}
prop->text = prompt;
@@ -147,6 +179,12 @@ struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr
return menu_add_prop(type, prompt, NULL, dep);
}
+void menu_add_visibility(struct expr *expr)
+{
+ current_entry->visibility = expr_alloc_and(current_entry->visibility,
+ expr);
+}
+
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
{
menu_add_prop(type, NULL, expr, dep);
@@ -178,13 +216,13 @@ void menu_add_option(int token, char *arg)
}
}
-static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
+static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
{
return sym2->type == S_INT || sym2->type == S_HEX ||
(sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
}
-void sym_check_prop(struct symbol *sym)
+static void sym_check_prop(struct symbol *sym)
{
struct property *prop;
struct symbol *sym2;
@@ -194,8 +232,17 @@ void sym_check_prop(struct symbol *sym)
if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) &&
prop->expr->type != E_SYMBOL)
prop_warn(prop,
- "default for config symbol '%'"
+ "default for config symbol '%s'"
" must be a single symbol", sym->name);
+ if (prop->expr->type != E_SYMBOL)
+ break;
+ sym2 = prop_get_symbol(prop);
+ if (sym->type == S_HEX || sym->type == S_INT) {
+ if (!menu_validate_number(sym, sym2))
+ prop_warn(prop,
+ "'%s': number is invalid",
+ sym->name);
+ }
break;
case P_SELECT:
sym2 = prop_get_symbol(prop);
@@ -215,8 +262,8 @@ void sym_check_prop(struct symbol *sym)
if (sym->type != S_INT && sym->type != S_HEX)
prop_warn(prop, "range is only allowed "
"for int or hex symbols");
- if (!menu_range_valid_sym(sym, prop->expr->left.sym) ||
- !menu_range_valid_sym(sym, prop->expr->right.sym))
+ if (!menu_validate_number(sym, prop->expr->left.sym) ||
+ !menu_validate_number(sym, prop->expr->right.sym))
prop_warn(prop, "range is invalid");
break;
default:
@@ -235,18 +282,22 @@ void menu_finalize(struct menu *parent)
sym = parent->sym;
if (parent->list) {
if (sym && sym_is_choice(sym)) {
- /* find the first choice value and find out choice type */
- for (menu = parent->list; menu; menu = menu->next) {
- if (menu->sym) {
- current_entry = parent;
- if (sym->type == S_UNKNOWN)
+ if (sym->type == S_UNKNOWN) {
+ /* find the first choice value to find out choice type */
+ current_entry = parent;
+ for (menu = parent->list; menu; menu = menu->next) {
+ if (menu->sym && menu->sym->type != S_UNKNOWN) {
menu_set_type(menu->sym->type);
- current_entry = menu;
- if (menu->sym->type == S_UNKNOWN)
- menu_set_type(sym->type);
- break;
+ break;
+ }
}
}
+ /* set the type of the remaining choice values */
+ for (menu = parent->list; menu; menu = menu->next) {
+ current_entry = menu;
+ if (menu->sym && menu->sym->type == S_UNKNOWN)
+ menu_set_type(sym->type);
+ }
parentdep = expr_alloc_symbol(sym);
} else if (parent->prompt)
parentdep = parent->prompt->visible.expr;
@@ -311,52 +362,40 @@ void menu_finalize(struct menu *parent)
parent->next = last_menu->next;
last_menu->next = NULL;
}
+
+ sym->dir_dep.expr = expr_alloc_or(sym->dir_dep.expr, parent->dep);
}
for (menu = parent->list; menu; menu = menu->next) {
- if (sym && sym_is_choice(sym) && menu->sym) {
+ if (sym && sym_is_choice(sym) &&
+ menu->sym && !sym_is_choice_value(menu->sym)) {
+ current_entry = menu;
menu->sym->flags |= SYMBOL_CHOICEVAL;
if (!menu->prompt)
menu_warn(menu, "choice value must have a prompt");
for (prop = menu->sym->prop; prop; prop = prop->next) {
- if (prop->type == P_PROMPT && prop->menu != menu) {
- prop_warn(prop, "choice values "
- "currently only support a "
- "single prompt");
- }
if (prop->type == P_DEFAULT)
prop_warn(prop, "defaults for choice "
- "values not supported");
+ "values not supported");
+ if (prop->menu == menu)
+ continue;
+ if (prop->type == P_PROMPT &&
+ prop->menu->parent->sym != sym)
+ prop_warn(prop, "choice value used outside its choice group");
}
- current_entry = menu;
- if (menu->sym->type == S_UNKNOWN)
- menu_set_type(sym->type);
/* Non-tristate choice values of tristate choices must
* depend on the choice being set to Y. The choice
* values' dependencies were propagated to their
* properties above, so the change here must be re-
- * propagated. */
+ * propagated.
+ */
if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) {
basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes);
- basedep = expr_alloc_and(basedep, menu->dep);
- basedep = expr_eliminate_dups(basedep);
- menu->dep = basedep;
+ menu->dep = expr_alloc_and(basedep, menu->dep);
for (prop = menu->sym->prop; prop; prop = prop->next) {
if (prop->menu != menu)
continue;
- dep = expr_alloc_and(expr_copy(basedep),
- prop->visible.expr);
- dep = expr_eliminate_dups(dep);
- dep = expr_trans_bool(dep);
- prop->visible.expr = dep;
- if (prop->type == P_SELECT) {
- struct symbol *es = prop_get_symbol(prop);
- dep2 = expr_alloc_symbol(menu->sym);
- dep = expr_alloc_and(dep2,
- expr_copy(dep));
- dep = expr_alloc_or(es->rev_dep.expr, dep);
- dep = expr_eliminate_dups(dep);
- es->rev_dep.expr = dep;
- }
+ prop->visible.expr = expr_alloc_and(expr_copy(basedep),
+ prop->visible.expr);
}
}
menu_add_symbol(P_CHOICE, sym, NULL);
@@ -397,6 +436,29 @@ void menu_finalize(struct menu *parent)
}
}
+bool menu_has_prompt(struct menu *menu)
+{
+ if (!menu->prompt)
+ return false;
+ return true;
+}
+
+/*
+ * Determine if a menu is empty.
+ * A menu is considered empty if it contains no or only
+ * invisible entries.
+ */
+bool menu_is_empty(struct menu *menu)
+{
+ struct menu *child;
+
+ for (child = menu->list; child; child = child->next) {
+ if (menu_is_visible(child))
+ return(false);
+ }
+ return(true);
+}
+
bool menu_is_visible(struct menu *menu)
{
struct menu *child;
@@ -405,6 +467,12 @@ bool menu_is_visible(struct menu *menu)
if (!menu->prompt)
return false;
+
+ if (menu->visibility) {
+ if (expr_calc_value(menu->visibility) == no)
+ return no;
+ }
+
sym = menu->sym;
if (sym) {
sym_calc_value(sym);
@@ -414,12 +482,18 @@ bool menu_is_visible(struct menu *menu)
if (visible != no)
return true;
+
if (!sym || sym_get_tristate_value(menu->sym) == no)
return false;
- for (child = menu->list; child; child = child->next)
- if (menu_is_visible(child))
+ for (child = menu->list; child; child = child->next) {
+ if (menu_is_visible(child)) {
+ if (sym)
+ sym->flags |= SYMBOL_DEF_USER;
return true;
+ }
+ }
+
return false;
}
@@ -461,3 +535,156 @@ const char *menu_get_help(struct menu *menu)
else
return "";
}
+
+static void get_prompt_str(struct gstr *r, struct property *prop,
+ struct list_head *head)
+{
+ int i, j;
+ struct menu *submenu[8], *menu, *location = NULL;
+ struct jump_key *jump;
+
+ str_printf(r, _("Prompt: %s\n"), _(prop->text));
+ menu = prop->menu->parent;
+ for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
+ bool accessible = menu_is_visible(menu);
+
+ submenu[i++] = menu;
+ if (location == NULL && accessible)
+ location = menu;
+ }
+ if (head && location) {
+ jump = xmalloc(sizeof(struct jump_key));
+
+ if (menu_is_visible(prop->menu)) {
+ /*
+ * There is not enough room to put the hint at the
+ * beginning of the "Prompt" line. Put the hint on the
+ * last "Location" line even when it would belong on
+ * the former.
+ */
+ jump->target = prop->menu;
+ } else
+ jump->target = location;
+
+ if (list_empty(head))
+ jump->index = 0;
+ else
+ jump->index = list_entry(head->prev, struct jump_key,
+ entries)->index + 1;
+
+ list_add_tail(&jump->entries, head);
+ }
+
+ if (i > 0) {
+ str_printf(r, _(" Location:\n"));
+ for (j = 4; --i >= 0; j += 2) {
+ menu = submenu[i];
+ if (head && location && menu == location)
+ jump->offset = r->len - 1;
+ str_printf(r, "%*c-> %s", j, ' ',
+ _(menu_get_prompt(menu)));
+ if (menu->sym) {
+ str_printf(r, " (%s [=%s])", menu->sym->name ?
+ menu->sym->name : _("<choice>"),
+ sym_get_string_value(menu->sym));
+ }
+ str_append(r, "\n");
+ }
+ }
+}
+
+/*
+ * get peoperty of type P_SYMBOL
+ */
+static struct property *get_symbol_prop(struct symbol *sym)
+{
+ struct property *prop = NULL;
+
+ for_all_properties(sym, prop, P_SYMBOL)
+ break;
+ return prop;
+}
+
+/*
+ * head is optional and may be NULL
+ */
+void get_symbol_str(struct gstr *r, struct symbol *sym,
+ struct list_head *head)
+{
+ bool hit;
+ struct property *prop;
+
+ if (sym && sym->name) {
+ str_printf(r, "Symbol: %s [=%s]\n", sym->name,
+ sym_get_string_value(sym));
+ str_printf(r, "Type : %s\n", sym_type_name(sym->type));
+ if (sym->type == S_INT || sym->type == S_HEX) {
+ prop = sym_get_range_prop(sym);
+ if (prop) {
+ str_printf(r, "Range : ");
+ expr_gstr_print(prop->expr, r);
+ str_append(r, "\n");
+ }
+ }
+ }
+ for_all_prompts(sym, prop)
+ get_prompt_str(r, prop, head);
+
+ prop = get_symbol_prop(sym);
+ if (prop) {
+ str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
+ prop->menu->lineno);
+ if (!expr_is_yes(prop->visible.expr)) {
+ str_append(r, _(" Depends on: "));
+ expr_gstr_print(prop->visible.expr, r);
+ str_append(r, "\n");
+ }
+ }
+
+ hit = false;
+ for_all_properties(sym, prop, P_SELECT) {
+ if (!hit) {
+ str_append(r, " Selects: ");
+ hit = true;
+ } else
+ str_printf(r, " && ");
+ expr_gstr_print(prop->expr, r);
+ }
+ if (hit)
+ str_append(r, "\n");
+ if (sym->rev_dep.expr) {
+ str_append(r, _(" Selected by: "));
+ expr_gstr_print(sym->rev_dep.expr, r);
+ str_append(r, "\n");
+ }
+ str_append(r, "\n\n");
+}
+
+struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head)
+{
+ struct symbol *sym;
+ struct gstr res = str_new();
+ int i;
+
+ for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
+ get_symbol_str(&res, sym, head);
+ if (!i)
+ str_append(&res, _("No matches found.\n"));
+ return res;
+}
+
+
+void menu_get_ext_help(struct menu *menu, struct gstr *help)
+{
+ struct symbol *sym = menu->sym;
+ const char *help_text = nohelp_text;
+
+ if (menu_has_help(menu)) {
+ if (sym->name)
+ str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
+ help_text = menu_get_help(menu);
+ }
+ str_printf(help, "%s\n", _(help_text));
+ if (sym)
+ get_symbol_str(help, sym, NULL);
+}
diff --git a/extra/config/merge_config.sh b/extra/config/merge_config.sh
new file mode 100755
index 000000000..81b0c61bb
--- /dev/null
+++ b/extra/config/merge_config.sh
@@ -0,0 +1,150 @@
+#!/bin/sh
+# merge_config.sh - Takes a list of config fragment values, and merges
+# them one by one. Provides warnings on overridden values, and specified
+# values that did not make it to the resulting .config file (due to missed
+# dependencies or config symbol removal).
+#
+# Portions reused from kconf_check and generate_cfg:
+# http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/kconf_check
+# http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/generate_cfg
+#
+# Copyright (c) 2009-2010 Wind River Systems, Inc.
+# Copyright 2011 Linaro
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+
+clean_up() {
+ rm -f $TMP_FILE
+ exit
+}
+trap clean_up HUP INT TERM
+
+usage() {
+ echo "Usage: $0 [OPTIONS] [CONFIG [...]]"
+ echo " -h display this help text"
+ echo " -m only merge the fragments, do not execute the make command"
+ echo " -n use allnoconfig instead of alldefconfig"
+ echo " -r list redundant entries when merging fragments"
+ echo " -O dir to put generated output files"
+}
+
+MAKE=true
+ALLTARGET=alldefconfig
+WARNREDUN=false
+OUTPUT=.
+
+while true; do
+ case $1 in
+ "-n")
+ ALLTARGET=allnoconfig
+ shift
+ continue
+ ;;
+ "-m")
+ MAKE=false
+ shift
+ continue
+ ;;
+ "-h")
+ usage
+ exit
+ ;;
+ "-r")
+ WARNREDUN=true
+ shift
+ continue
+ ;;
+ "-O")
+ if [ -d $2 ];then
+ OUTPUT=$(echo $2 | sed 's/\/*$//')
+ else
+ echo "output directory $2 does not exist" 1>&2
+ exit 1
+ fi
+ shift 2
+ continue
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+INITFILE=$1
+shift;
+
+MERGE_LIST=$*
+SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p"
+TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX)
+
+echo "Using $INITFILE as base"
+cat $INITFILE > $TMP_FILE
+
+# Merge files, printing warnings on overrided values
+for MERGE_FILE in $MERGE_LIST ; do
+ echo "Merging $MERGE_FILE"
+ CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE)
+
+ for CFG in $CFG_LIST ; do
+ grep -q -w $CFG $TMP_FILE
+ if [ $? -eq 0 ] ; then
+ PREV_VAL=$(grep -w $CFG $TMP_FILE)
+ NEW_VAL=$(grep -w $CFG $MERGE_FILE)
+ if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
+ echo Value of $CFG is redefined by fragment $MERGE_FILE:
+ echo Previous value: $PREV_VAL
+ echo New value: $NEW_VAL
+ echo
+ elif [ "$WARNREDUN" = "true" ]; then
+ echo Value of $CFG is redundant by fragment $MERGE_FILE:
+ fi
+ sed -i "/$CFG[ =]/d" $TMP_FILE
+ fi
+ done
+ cat $MERGE_FILE >> $TMP_FILE
+done
+
+if [ "$MAKE" = "false" ]; then
+ cp $TMP_FILE $OUTPUT/.config
+ echo "#"
+ echo "# merged configuration written to $OUTPUT/.config (needs make)"
+ echo "#"
+ clean_up
+ exit
+fi
+
+# If we have an output dir, setup the O= argument, otherwise leave
+# it blank, since O=. will create an unnecessary ./source softlink
+OUTPUT_ARG=""
+if [ "$OUTPUT" != "." ] ; then
+ OUTPUT_ARG="O=$OUTPUT"
+fi
+
+
+# Use the merged file as the starting point for:
+# alldefconfig: Fills in any missing symbols with Kconfig default
+# allnoconfig: Fills in any missing symbols with # CONFIG_* is not set
+make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET
+
+
+# Check all specified config values took (might have missed-dependency issues)
+for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do
+
+ REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
+ ACTUAL_VAL=$(grep -w -e "$CFG" $OUTPUT/.config)
+ if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then
+ echo "Value requested for $CFG not in final .config"
+ echo "Requested value: $REQUESTED_VAL"
+ echo "Actual value: $ACTUAL_VAL"
+ echo ""
+ fi
+done
+
+clean_up
diff --git a/extra/config/nconf.c b/extra/config/nconf.c
new file mode 100644
index 000000000..4e416cfcb
--- /dev/null
+++ b/extra/config/nconf.c
@@ -0,0 +1,1557 @@
+/*
+ * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
+ * Released under the terms of the GNU GPL v2.0.
+ *
+ * Derived from menuconfig.
+ *
+ */
+#define _GNU_SOURCE
+#include <string.h>
+#include <stdlib.h>
+
+#include "lkc.h"
+#include "nconf.h"
+#include <ctype.h>
+
+static const char nconf_global_help[] = N_(
+"Help windows\n"
+"------------\n"
+"o Global help: Unless in a data entry window, pressing <F1> will give \n"
+" you the global help window, which you are just reading.\n"
+"\n"
+"o A short version of the global help is available by pressing <F3>.\n"
+"\n"
+"o Local help: To get help related to the current menu entry, use any\n"
+" of <?> <h>, or if in a data entry window then press <F1>.\n"
+"\n"
+"\n"
+"Menu entries\n"
+"------------\n"
+"This interface lets you select features and parameters for the \n"
+"build. Features can either be built-in, modularized, or removed.\n"
+"Parameters must be entered as text or decimal or hexadecimal numbers.\n"
+"\n"
+"Menu entries beginning with following braces represent features that\n"
+" [ ] can be built in or removed\n"
+" < > can be built in, modularized or removed\n"
+" { } can be built in or modularized, are selected by another feature\n"
+" - - are selected by another feature\n"
+" XXX cannot be selected. Symbol Info <F2> tells you why.\n"
+"*, M or whitespace inside braces means to build in, build as a module\n"
+"or to exclude the feature respectively.\n"
+"\n"
+"To change any of these features, highlight it with the movement keys\n"
+"listed below and press <y> to build it in, <m> to make it a module or\n"
+"<n> to remove it. You may press the <Space> key to cycle through the\n"
+"available options.\n"
+"\n"
+"A trailing \"--->\" designates a submenu, a trailing \"----\" an\n"
+"empty submenu.\n"
+"\n"
+"Menu navigation keys\n"
+"----------------------------------------------------------------------\n"
+"Linewise up <Up>\n"
+"Linewise down <Down>\n"
+"Pagewise up <Page Up>\n"
+"Pagewise down <Page Down>\n"
+"First entry <Home>\n"
+"Last entry <End>\n"
+"Enter a submenu <Right> <Enter>\n"
+"Go back to parent menu <Left> <Esc> <F5>\n"
+"Close a help window <Enter> <Esc> <F5>\n"
+"Close entry window, apply <Enter>\n"
+"Close entry window, forget <Esc> <F5>\n"
+"Start incremental, case-insensitive search for STRING in menu entries,\n"
+" no regex support, STRING is displayed in upper left corner\n"
+" </>STRING\n"
+" Remove last character <Backspace>\n"
+" Jump to next hit <Down>\n"
+" Jump to previous hit <Up>\n"
+"Exit menu search mode </> <Esc>\n"
+"Search for configuration variables with or without leading CONFIG_\n"
+" <F8>RegExpr<Enter>\n"
+"Verbose search help <F8><F1>\n"
+"----------------------------------------------------------------------\n"
+"\n"
+"Unless in a data entry window, key <1> may be used instead of <F1>,\n"
+"<2> instead of <F2>, etc.\n"
+"\n"
+"\n"
+"Radiolist (Choice list)\n"
+"-----------------------\n"
+"Use the movement keys listed above to select the option you wish to set\n"
+"and press <Space>.\n"
+"\n"
+"\n"
+"Data entry\n"
+"----------\n"
+"Enter the requested information and press <Enter>. Hexadecimal values\n"
+"may be entered without the \"0x\" prefix.\n"
+"\n"
+"\n"
+"Text Box (Help Window)\n"
+"----------------------\n"
+"Use movement keys as listed in table above.\n"
+"\n"
+"Press any of <Enter> <Esc> <q> <F5> <F9> to exit.\n"
+"\n"
+"\n"
+"Alternate configuration files\n"
+"-----------------------------\n"
+"nconfig supports switching between different configurations.\n"
+"Press <F6> to save your current configuration. Press <F7> and enter\n"
+"a file name to load a previously saved configuration.\n"
+"\n"
+"\n"
+"Terminal configuration\n"
+"----------------------\n"
+"If you use nconfig in a xterm window, make sure your TERM environment\n"
+"variable specifies a terminal configuration which supports at least\n"
+"16 colors. Otherwise nconfig will look rather bad.\n"
+"\n"
+"If the \"stty size\" command reports the current terminalsize correctly,\n"
+"nconfig will adapt to sizes larger than the traditional 80x25 \"standard\"\n"
+"and display longer menus properly.\n"
+"\n"
+"\n"
+"Single menu mode\n"
+"----------------\n"
+"If you prefer to have all of the menu entries listed in a single menu,\n"
+"rather than the default multimenu hierarchy, run nconfig with\n"
+"NCONFIG_MODE environment variable set to single_menu. Example:\n"
+"\n"
+"make NCONFIG_MODE=single_menu nconfig\n"
+"\n"
+"<Enter> will then unfold the appropriate category, or fold it if it\n"
+"is already unfolded. Folded menu entries will be designated by a\n"
+"leading \"++>\" and unfolded entries by a leading \"-->\".\n"
+"\n"
+"Note that this mode can eventually be a little more CPU expensive than\n"
+"the default mode, especially with a larger number of unfolded submenus.\n"
+"\n"),
+menu_no_f_instructions[] = N_(
+"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
+"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
+"\n"
+"Use the following keys to navigate the menus:\n"
+"Move up or down with <Up> and <Down>.\n"
+"Enter a submenu with <Enter> or <Right>.\n"
+"Exit a submenu to its parent menu with <Esc> or <Left>.\n"
+"Pressing <y> includes, <n> excludes, <m> modularizes features.\n"
+"Pressing <Space> cycles through the available options.\n"
+"To search for menu entries press </>.\n"
+"<Esc> always leaves the current window.\n"
+"\n"
+"You do not have function keys support.\n"
+"Press <1> instead of <F1>, <2> instead of <F2>, etc.\n"
+"For verbose global help use key <1>.\n"
+"For help related to the current menu entry press <?> or <h>.\n"),
+menu_instructions[] = N_(
+"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
+"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
+"\n"
+"Use the following keys to navigate the menus:\n"
+"Move up or down with <Up> or <Down>.\n"
+"Enter a submenu with <Enter> or <Right>.\n"
+"Exit a submenu to its parent menu with <Esc> or <Left>.\n"
+"Pressing <y> includes, <n> excludes, <m> modularizes features.\n"
+"Pressing <Space> cycles through the available options.\n"
+"To search for menu entries press </>.\n"
+"<Esc> always leaves the current window.\n"
+"\n"
+"Pressing <1> may be used instead of <F1>, <2> instead of <F2>, etc.\n"
+"For verbose global help press <F1>.\n"
+"For help related to the current menu entry press <?> or <h>.\n"),
+radiolist_instructions[] = N_(
+"Press <Up>, <Down>, <Home> or <End> to navigate a radiolist, select\n"
+"with <Space>.\n"
+"For help related to the current entry press <?> or <h>.\n"
+"For global help press <F1>.\n"),
+inputbox_instructions_int[] = N_(
+"Please enter a decimal value.\n"
+"Fractions will not be accepted.\n"
+"Press <Enter> to apply, <Esc> to cancel."),
+inputbox_instructions_hex[] = N_(
+"Please enter a hexadecimal value.\n"
+"Press <Enter> to apply, <Esc> to cancel."),
+inputbox_instructions_string[] = N_(
+"Please enter a string value.\n"
+"Press <Enter> to apply, <Esc> to cancel."),
+setmod_text[] = N_(
+"This feature depends on another feature which has been configured as a\n"
+"module. As a result, the current feature will be built as a module too."),
+load_config_text[] = N_(
+"Enter the name of the configuration file you wish to load.\n"
+"Accept the name shown to restore the configuration you last\n"
+"retrieved. Leave empty to abort."),
+load_config_help[] = N_(
+"For various reasons, one may wish to keep several different\n"
+"configurations available on a single machine.\n"
+"\n"
+"If you have saved a previous configuration in a file other than the\n"
+"default one, entering its name here will allow you to load and modify\n"
+"that configuration.\n"
+"\n"
+"Leave empty to abort.\n"),
+save_config_text[] = N_(
+"Enter a filename to which this configuration should be saved\n"
+"as an alternate. Leave empty to abort."),
+save_config_help[] = N_(
+"For various reasons, one may wish to keep several different\n"
+"configurations available on a single machine.\n"
+"\n"
+"Entering a file name here will allow you to later retrieve, modify\n"
+"and use the current configuration as an alternate to whatever\n"
+"configuration options you have selected at that time.\n"
+"\n"
+"Leave empty to abort.\n"),
+search_help[] = N_(
+"Search for symbols (configuration variable names CONFIG_*) and display\n"
+"their relations. Regular expressions are supported.\n"
+"Example: Search for \"^FOO\".\n"
+"Result:\n"
+"-----------------------------------------------------------------\n"
+"Symbol: FOO [ = m]\n"
+"Prompt: Foo bus is used to drive the bar HW\n"
+"Defined at drivers/pci/Kconfig:47\n"
+"Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
+"Location:\n"
+" -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
+" -> PCI support (PCI [ = y])\n"
+" -> PCI access mode (<choice> [ = y])\n"
+"Selects: LIBCRC32\n"
+"Selected by: BAR\n"
+"-----------------------------------------------------------------\n"
+"o The line 'Prompt:' shows the text displayed for this symbol in\n"
+" the menu hierarchy.\n"
+"o The 'Defined at' line tells at what file / line number the symbol is\n"
+" defined.\n"
+"o The 'Depends on:' line lists symbols that need to be defined for\n"
+" this symbol to be visible and selectable in the menu.\n"
+"o The 'Location:' lines tell, where in the menu structure this symbol\n"
+" is located. A location followed by a [ = y] indicates that this is\n"
+" a selectable menu item, and the current value is displayed inside\n"
+" brackets.\n"
+"o The 'Selects:' line tells, what symbol will be automatically selected\n"
+" if this symbol is selected (y or m).\n"
+"o The 'Selected by' line tells what symbol has selected this symbol.\n"
+"\n"
+"Only relevant lines are shown.\n"
+"\n\n"
+"Search examples:\n"
+"USB => find all symbols containing USB\n"
+"^USB => find all symbols starting with USB\n"
+"USB$ => find all symbols ending with USB\n"
+"\n");
+
+struct mitem {
+ char str[256];
+ char tag;
+ void *usrptr;
+ int is_visible;
+};
+
+#define MAX_MENU_ITEMS 4096
+static int show_all_items;
+static int indent;
+static struct menu *current_menu;
+static int child_count;
+static int single_menu_mode;
+/* the window in which all information appears */
+static WINDOW *main_window;
+/* the largest size of the menu window */
+static int mwin_max_lines;
+static int mwin_max_cols;
+/* the window in which we show option buttons */
+static MENU *curses_menu;
+static ITEM *curses_menu_items[MAX_MENU_ITEMS];
+static struct mitem k_menu_items[MAX_MENU_ITEMS];
+static int items_num;
+static int global_exit;
+/* the currently selected button */
+const char *current_instructions = menu_instructions;
+
+static char *dialog_input_result;
+static int dialog_input_result_len;
+
+static void conf(struct menu *menu);
+static void conf_choice(struct menu *menu);
+static void conf_string(struct menu *menu);
+static void conf_load(void);
+static void conf_save(void);
+static void show_help(struct menu *menu);
+static int do_exit(void);
+static void setup_windows(void);
+static void search_conf(void);
+
+typedef void (*function_key_handler_t)(int *key, struct menu *menu);
+static void handle_f1(int *key, struct menu *current_item);
+static void handle_f2(int *key, struct menu *current_item);
+static void handle_f3(int *key, struct menu *current_item);
+static void handle_f4(int *key, struct menu *current_item);
+static void handle_f5(int *key, struct menu *current_item);
+static void handle_f6(int *key, struct menu *current_item);
+static void handle_f7(int *key, struct menu *current_item);
+static void handle_f8(int *key, struct menu *current_item);
+static void handle_f9(int *key, struct menu *current_item);
+
+struct function_keys {
+ const char *key_str;
+ const char *func;
+ function_key key;
+ function_key_handler_t handler;
+};
+
+static const int function_keys_num = 9;
+struct function_keys function_keys[] = {
+ {
+ .key_str = "F1",
+ .func = "Help",
+ .key = F_HELP,
+ .handler = handle_f1,
+ },
+ {
+ .key_str = "F2",
+ .func = "SymInfo",
+ .key = F_SYMBOL,
+ .handler = handle_f2,
+ },
+ {
+ .key_str = "F3",
+ .func = "Help 2",
+ .key = F_INSTS,
+ .handler = handle_f3,
+ },
+ {
+ .key_str = "F4",
+ .func = "ShowAll",
+ .key = F_CONF,
+ .handler = handle_f4,
+ },
+ {
+ .key_str = "F5",
+ .func = "Back",
+ .key = F_BACK,
+ .handler = handle_f5,
+ },
+ {
+ .key_str = "F6",
+ .func = "Save",
+ .key = F_SAVE,
+ .handler = handle_f6,
+ },
+ {
+ .key_str = "F7",
+ .func = "Load",
+ .key = F_LOAD,
+ .handler = handle_f7,
+ },
+ {
+ .key_str = "F8",
+ .func = "SymSearch",
+ .key = F_SEARCH,
+ .handler = handle_f8,
+ },
+ {
+ .key_str = "F9",
+ .func = "Exit",
+ .key = F_EXIT,
+ .handler = handle_f9,
+ },
+};
+
+static void print_function_line(void)
+{
+ int i;
+ int offset = 1;
+ const int skip = 1;
+ int lines = getmaxy(stdscr);
+
+ for (i = 0; i < function_keys_num; i++) {
+ (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]);
+ mvwprintw(main_window, lines-3, offset,
+ "%s",
+ function_keys[i].key_str);
+ (void) wattrset(main_window, attributes[FUNCTION_TEXT]);
+ offset += strlen(function_keys[i].key_str);
+ mvwprintw(main_window, lines-3,
+ offset, "%s",
+ function_keys[i].func);
+ offset += strlen(function_keys[i].func) + skip;
+ }
+ (void) wattrset(main_window, attributes[NORMAL]);
+}
+
+/* help */
+static void handle_f1(int *key, struct menu *current_item)
+{
+ show_scroll_win(main_window,
+ _("Global help"), _(nconf_global_help));
+ return;
+}
+
+/* symbole help */
+static void handle_f2(int *key, struct menu *current_item)
+{
+ show_help(current_item);
+ return;
+}
+
+/* instructions */
+static void handle_f3(int *key, struct menu *current_item)
+{
+ show_scroll_win(main_window,
+ _("Short help"),
+ _(current_instructions));
+ return;
+}
+
+/* config */
+static void handle_f4(int *key, struct menu *current_item)
+{
+ int res = btn_dialog(main_window,
+ _("Show all symbols?"),
+ 2,
+ " <Show All> ",
+ "<Don't show all>");
+ if (res == 0)
+ show_all_items = 1;
+ else if (res == 1)
+ show_all_items = 0;
+
+ return;
+}
+
+/* back */
+static void handle_f5(int *key, struct menu *current_item)
+{
+ *key = KEY_LEFT;
+ return;
+}
+
+/* save */
+static void handle_f6(int *key, struct menu *current_item)
+{
+ conf_save();
+ return;
+}
+
+/* load */
+static void handle_f7(int *key, struct menu *current_item)
+{
+ conf_load();
+ return;
+}
+
+/* search */
+static void handle_f8(int *key, struct menu *current_item)
+{
+ search_conf();
+ return;
+}
+
+/* exit */
+static void handle_f9(int *key, struct menu *current_item)
+{
+ do_exit();
+ return;
+}
+
+/* return != 0 to indicate the key was handles */
+static int process_special_keys(int *key, struct menu *menu)
+{
+ int i;
+
+ if (*key == KEY_RESIZE) {
+ setup_windows();
+ return 1;
+ }
+
+ for (i = 0; i < function_keys_num; i++) {
+ if (*key == KEY_F(function_keys[i].key) ||
+ *key == '0' + function_keys[i].key){
+ function_keys[i].handler(key, menu);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static void clean_items(void)
+{
+ int i;
+ for (i = 0; curses_menu_items[i]; i++)
+ free_item(curses_menu_items[i]);
+ bzero(curses_menu_items, sizeof(curses_menu_items));
+ bzero(k_menu_items, sizeof(k_menu_items));
+ items_num = 0;
+}
+
+typedef enum {MATCH_TINKER_PATTERN_UP, MATCH_TINKER_PATTERN_DOWN,
+ FIND_NEXT_MATCH_DOWN, FIND_NEXT_MATCH_UP} match_f;
+
+/* return the index of the matched item, or -1 if no such item exists */
+static int get_mext_match(const char *match_str, match_f flag)
+{
+ int match_start = item_index(current_item(curses_menu));
+ int index;
+
+ if (flag == FIND_NEXT_MATCH_DOWN)
+ ++match_start;
+ else if (flag == FIND_NEXT_MATCH_UP)
+ --match_start;
+
+ index = match_start;
+ index = (index + items_num) % items_num;
+ while (true) {
+ char *str = k_menu_items[index].str;
+ if (strcasestr(str, match_str) != 0)
+ return index;
+ if (flag == FIND_NEXT_MATCH_UP ||
+ flag == MATCH_TINKER_PATTERN_UP)
+ --index;
+ else
+ ++index;
+ index = (index + items_num) % items_num;
+ if (index == match_start)
+ return -1;
+ }
+}
+
+/* Make a new item. */
+static void item_make(struct menu *menu, char tag, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (items_num > MAX_MENU_ITEMS-1)
+ return;
+
+ bzero(&k_menu_items[items_num], sizeof(k_menu_items[0]));
+ k_menu_items[items_num].tag = tag;
+ k_menu_items[items_num].usrptr = menu;
+ if (menu != NULL)
+ k_menu_items[items_num].is_visible =
+ menu_is_visible(menu);
+ else
+ k_menu_items[items_num].is_visible = 1;
+
+ va_start(ap, fmt);
+ vsnprintf(k_menu_items[items_num].str,
+ sizeof(k_menu_items[items_num].str),
+ fmt, ap);
+ va_end(ap);
+
+ if (!k_menu_items[items_num].is_visible)
+ memcpy(k_menu_items[items_num].str, "XXX", 3);
+
+ curses_menu_items[items_num] = new_item(
+ k_menu_items[items_num].str,
+ k_menu_items[items_num].str);
+ set_item_userptr(curses_menu_items[items_num],
+ &k_menu_items[items_num]);
+ /*
+ if (!k_menu_items[items_num].is_visible)
+ item_opts_off(curses_menu_items[items_num], O_SELECTABLE);
+ */
+
+ items_num++;
+ curses_menu_items[items_num] = NULL;
+}
+
+/* very hackish. adds a string to the last item added */
+static void item_add_str(const char *fmt, ...)
+{
+ va_list ap;
+ int index = items_num-1;
+ char new_str[256];
+ char tmp_str[256];
+
+ if (index < 0)
+ return;
+
+ va_start(ap, fmt);
+ vsnprintf(new_str, sizeof(new_str), fmt, ap);
+ va_end(ap);
+ snprintf(tmp_str, sizeof(tmp_str), "%s%s",
+ k_menu_items[index].str, new_str);
+ strncpy(k_menu_items[index].str,
+ tmp_str,
+ sizeof(k_menu_items[index].str));
+
+ free_item(curses_menu_items[index]);
+ curses_menu_items[index] = new_item(
+ k_menu_items[index].str,
+ k_menu_items[index].str);
+ set_item_userptr(curses_menu_items[index],
+ &k_menu_items[index]);
+}
+
+/* get the tag of the currently selected item */
+static char item_tag(void)
+{
+ ITEM *cur;
+ struct mitem *mcur;
+
+ cur = current_item(curses_menu);
+ if (cur == NULL)
+ return 0;
+ mcur = (struct mitem *) item_userptr(cur);
+ return mcur->tag;
+}
+
+static int curses_item_index(void)
+{
+ return item_index(current_item(curses_menu));
+}
+
+static void *item_data(void)
+{
+ ITEM *cur;
+ struct mitem *mcur;
+
+ cur = current_item(curses_menu);
+ if (!cur)
+ return NULL;
+ mcur = (struct mitem *) item_userptr(cur);
+ return mcur->usrptr;
+
+}
+
+static int item_is_tag(char tag)
+{
+ return item_tag() == tag;
+}
+
+static char filename[PATH_MAX+1];
+static char menu_backtitle[PATH_MAX+128];
+static const char *set_config_filename(const char *config_filename)
+{
+ int size;
+
+ size = snprintf(menu_backtitle, sizeof(menu_backtitle),
+ "%s - %s", config_filename, rootmenu.prompt->text);
+ if (size >= sizeof(menu_backtitle))
+ menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
+
+ size = snprintf(filename, sizeof(filename), "%s", config_filename);
+ if (size >= sizeof(filename))
+ filename[sizeof(filename)-1] = '\0';
+ return menu_backtitle;
+}
+
+/* return = 0 means we are successful.
+ * -1 means go on doing what you were doing
+ */
+static int do_exit(void)
+{
+ int res;
+ if (!conf_get_changed()) {
+ global_exit = 1;
+ return 0;
+ }
+ res = btn_dialog(main_window,
+ _("Do you wish to save your new configuration?\n"
+ "<ESC> to cancel and resume nconfig."),
+ 2,
+ " <save> ",
+ "<don't save>");
+ if (res == KEY_EXIT) {
+ global_exit = 0;
+ return -1;
+ }
+
+ /* if we got here, the user really wants to exit */
+ switch (res) {
+ case 0:
+ res = conf_write(filename);
+ if (res)
+ btn_dialog(
+ main_window,
+ _("Error during writing of configuration.\n"
+ "Your configuration changes were NOT saved."),
+ 1,
+ "<OK>");
+ break;
+ default:
+ btn_dialog(
+ main_window,
+ _("Your configuration changes were NOT saved."),
+ 1,
+ "<OK>");
+ break;
+ }
+ global_exit = 1;
+ return 0;
+}
+
+
+static void search_conf(void)
+{
+ struct symbol **sym_arr;
+ struct gstr res;
+ struct gstr title;
+ char *dialog_input;
+ int dres;
+
+ title = str_new();
+ str_printf( &title, _("Enter %s (sub)string or regexp to search for "
+ "(with or without \"%s\")"), CONFIG_, CONFIG_);
+
+again:
+ dres = dialog_inputbox(main_window,
+ _("Search Configuration Parameter"),
+ str_get(&title),
+ "", &dialog_input_result, &dialog_input_result_len);
+ switch (dres) {
+ case 0:
+ break;
+ case 1:
+ show_scroll_win(main_window,
+ _("Search Configuration"), search_help);
+ goto again;
+ default:
+ str_free(&title);
+ return;
+ }
+
+ /* strip the prefix if necessary */
+ dialog_input = dialog_input_result;
+ if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
+ dialog_input += strlen(CONFIG_);
+
+ sym_arr = sym_re_search(dialog_input);
+ res = get_relations_str(sym_arr, NULL);
+ free(sym_arr);
+ show_scroll_win(main_window,
+ _("Search Results"), str_get(&res));
+ str_free(&res);
+ str_free(&title);
+}
+
+
+static void build_conf(struct menu *menu)
+{
+ struct symbol *sym;
+ struct property *prop;
+ struct menu *child;
+ int type, tmp, doint = 2;
+ tristate val;
+ char ch;
+
+ if (!menu || (!show_all_items && !menu_is_visible(menu)))
+ return;
+
+ sym = menu->sym;
+ prop = menu->prompt;
+ if (!sym) {
+ if (prop && menu != current_menu) {
+ const char *prompt = menu_get_prompt(menu);
+ enum prop_type ptype;
+ ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
+ switch (ptype) {
+ case P_MENU:
+ child_count++;
+ prompt = _(prompt);
+ if (single_menu_mode) {
+ item_make(menu, 'm',
+ "%s%*c%s",
+ menu->data ? "-->" : "++>",
+ indent + 1, ' ', prompt);
+ } else
+ item_make(menu, 'm',
+ " %*c%s %s",
+ indent + 1, ' ', prompt,
+ menu_is_empty(menu) ? "----" : "--->");
+
+ if (single_menu_mode && menu->data)
+ goto conf_childs;
+ return;
+ case P_COMMENT:
+ if (prompt) {
+ child_count++;
+ item_make(menu, ':',
+ " %*c*** %s ***",
+ indent + 1, ' ',
+ _(prompt));
+ }
+ break;
+ default:
+ if (prompt) {
+ child_count++;
+ item_make(menu, ':', "---%*c%s",
+ indent + 1, ' ',
+ _(prompt));
+ }
+ }
+ } else
+ doint = 0;
+ goto conf_childs;
+ }
+
+ type = sym_get_type(sym);
+ if (sym_is_choice(sym)) {
+ struct symbol *def_sym = sym_get_choice_value(sym);
+ struct menu *def_menu = NULL;
+
+ child_count++;
+ for (child = menu->list; child; child = child->next) {
+ if (menu_is_visible(child) && child->sym == def_sym)
+ def_menu = child;
+ }
+
+ val = sym_get_tristate_value(sym);
+ if (sym_is_changable(sym)) {
+ switch (type) {
+ case S_BOOLEAN:
+ item_make(menu, 't', "[%c]",
+ val == no ? ' ' : '*');
+ break;
+ case S_TRISTATE:
+ switch (val) {
+ case yes:
+ ch = '*';
+ break;
+ case mod:
+ ch = 'M';
+ break;
+ default:
+ ch = ' ';
+ break;
+ }
+ item_make(menu, 't', "<%c>", ch);
+ break;
+ }
+ } else {
+ item_make(menu, def_menu ? 't' : ':', " ");
+ }
+
+ item_add_str("%*c%s", indent + 1,
+ ' ', _(menu_get_prompt(menu)));
+ if (val == yes) {
+ if (def_menu) {
+ item_add_str(" (%s)",
+ _(menu_get_prompt(def_menu)));
+ item_add_str(" --->");
+ if (def_menu->list) {
+ indent += 2;
+ build_conf(def_menu);
+ indent -= 2;
+ }
+ }
+ return;
+ }
+ } else {
+ if (menu == current_menu) {
+ item_make(menu, ':',
+ "---%*c%s", indent + 1,
+ ' ', _(menu_get_prompt(menu)));
+ goto conf_childs;
+ }
+ child_count++;
+ val = sym_get_tristate_value(sym);
+ if (sym_is_choice_value(sym) && val == yes) {
+ item_make(menu, ':', " ");
+ } else {
+ switch (type) {
+ case S_BOOLEAN:
+ if (sym_is_changable(sym))
+ item_make(menu, 't', "[%c]",
+ val == no ? ' ' : '*');
+ else
+ item_make(menu, 't', "-%c-",
+ val == no ? ' ' : '*');
+ break;
+ case S_TRISTATE:
+ switch (val) {
+ case yes:
+ ch = '*';
+ break;
+ case mod:
+ ch = 'M';
+ break;
+ default:
+ ch = ' ';
+ break;
+ }
+ if (sym_is_changable(sym)) {
+ if (sym->rev_dep.tri == mod)
+ item_make(menu,
+ 't', "{%c}", ch);
+ else
+ item_make(menu,
+ 't', "<%c>", ch);
+ } else
+ item_make(menu, 't', "-%c-", ch);
+ break;
+ default:
+ tmp = 2 + strlen(sym_get_string_value(sym));
+ item_make(menu, 's', " (%s)",
+ sym_get_string_value(sym));
+ tmp = indent - tmp + 4;
+ if (tmp < 0)
+ tmp = 0;
+ item_add_str("%*c%s%s", tmp, ' ',
+ _(menu_get_prompt(menu)),
+ (sym_has_value(sym) ||
+ !sym_is_changable(sym)) ? "" :
+ _(" (NEW)"));
+ goto conf_childs;
+ }
+ }
+ item_add_str("%*c%s%s", indent + 1, ' ',
+ _(menu_get_prompt(menu)),
+ (sym_has_value(sym) || !sym_is_changable(sym)) ?
+ "" : _(" (NEW)"));
+ if (menu->prompt && menu->prompt->type == P_MENU) {
+ item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
+ return;
+ }
+ }
+
+conf_childs:
+ indent += doint;
+ for (child = menu->list; child; child = child->next)
+ build_conf(child);
+ indent -= doint;
+}
+
+static void reset_menu(void)
+{
+ unpost_menu(curses_menu);
+ clean_items();
+}
+
+/* adjust the menu to show this item.
+ * prefer not to scroll the menu if possible*/
+static void center_item(int selected_index, int *last_top_row)
+{
+ int toprow;
+
+ set_top_row(curses_menu, *last_top_row);
+ toprow = top_row(curses_menu);
+ if (selected_index < toprow ||
+ selected_index >= toprow+mwin_max_lines) {
+ toprow = max(selected_index-mwin_max_lines/2, 0);
+ if (toprow >= item_count(curses_menu)-mwin_max_lines)
+ toprow = item_count(curses_menu)-mwin_max_lines;
+ set_top_row(curses_menu, toprow);
+ }
+ set_current_item(curses_menu,
+ curses_menu_items[selected_index]);
+ *last_top_row = toprow;
+ post_menu(curses_menu);
+ refresh_all_windows(main_window);
+}
+
+/* this function assumes reset_menu has been called before */
+static void show_menu(const char *prompt, const char *instructions,
+ int selected_index, int *last_top_row)
+{
+ int maxx, maxy;
+ WINDOW *menu_window;
+
+ current_instructions = instructions;
+
+ clear();
+ (void) wattrset(main_window, attributes[NORMAL]);
+ print_in_middle(stdscr, 1, 0, getmaxx(stdscr),
+ menu_backtitle,
+ attributes[MAIN_HEADING]);
+
+ (void) wattrset(main_window, attributes[MAIN_MENU_BOX]);
+ box(main_window, 0, 0);
+ (void) wattrset(main_window, attributes[MAIN_MENU_HEADING]);
+ mvwprintw(main_window, 0, 3, " %s ", prompt);
+ (void) wattrset(main_window, attributes[NORMAL]);
+
+ set_menu_items(curses_menu, curses_menu_items);
+
+ /* position the menu at the middle of the screen */
+ scale_menu(curses_menu, &maxy, &maxx);
+ maxx = min(maxx, mwin_max_cols-2);
+ maxy = mwin_max_lines;
+ menu_window = derwin(main_window,
+ maxy,
+ maxx,
+ 2,
+ (mwin_max_cols-maxx)/2);
+ keypad(menu_window, TRUE);
+ set_menu_win(curses_menu, menu_window);
+ set_menu_sub(curses_menu, menu_window);
+
+ /* must reassert this after changing items, otherwise returns to a
+ * default of 16
+ */
+ set_menu_format(curses_menu, maxy, 1);
+ center_item(selected_index, last_top_row);
+ set_menu_format(curses_menu, maxy, 1);
+
+ print_function_line();
+
+ /* Post the menu */
+ post_menu(curses_menu);
+ refresh_all_windows(main_window);
+}
+
+static void adj_match_dir(match_f *match_direction)
+{
+ if (*match_direction == FIND_NEXT_MATCH_DOWN)
+ *match_direction =
+ MATCH_TINKER_PATTERN_DOWN;
+ else if (*match_direction == FIND_NEXT_MATCH_UP)
+ *match_direction =
+ MATCH_TINKER_PATTERN_UP;
+ /* else, do no change.. */
+}
+
+struct match_state
+{
+ int in_search;
+ match_f match_direction;
+ char pattern[256];
+};
+
+/* Return 0 means I have handled the key. In such a case, ans should hold the
+ * item to center, or -1 otherwise.
+ * Else return -1 .
+ */
+static int do_match(int key, struct match_state *state, int *ans)
+{
+ char c = (char) key;
+ int terminate_search = 0;
+ *ans = -1;
+ if (key == '/' || (state->in_search && key == 27)) {
+ move(0, 0);
+ refresh();
+ clrtoeol();
+ state->in_search = 1-state->in_search;
+ bzero(state->pattern, sizeof(state->pattern));
+ state->match_direction = MATCH_TINKER_PATTERN_DOWN;
+ return 0;
+ } else if (!state->in_search)
+ return 1;
+
+ if (isalnum(c) || isgraph(c) || c == ' ') {
+ state->pattern[strlen(state->pattern)] = c;
+ state->pattern[strlen(state->pattern)] = '\0';
+ adj_match_dir(&state->match_direction);
+ *ans = get_mext_match(state->pattern,
+ state->match_direction);
+ } else if (key == KEY_DOWN) {
+ state->match_direction = FIND_NEXT_MATCH_DOWN;
+ *ans = get_mext_match(state->pattern,
+ state->match_direction);
+ } else if (key == KEY_UP) {
+ state->match_direction = FIND_NEXT_MATCH_UP;
+ *ans = get_mext_match(state->pattern,
+ state->match_direction);
+ } else if (key == KEY_BACKSPACE || key == 127) {
+ state->pattern[strlen(state->pattern)-1] = '\0';
+ adj_match_dir(&state->match_direction);
+ } else
+ terminate_search = 1;
+
+ if (terminate_search) {
+ state->in_search = 0;
+ bzero(state->pattern, sizeof(state->pattern));
+ move(0, 0);
+ refresh();
+ clrtoeol();
+ return -1;
+ }
+ return 0;
+}
+
+static void conf(struct menu *menu)
+{
+ struct menu *submenu = 0;
+ const char *prompt = menu_get_prompt(menu);
+ struct symbol *sym;
+ int res;
+ int current_index = 0;
+ int last_top_row = 0;
+ struct match_state match_state = {
+ .in_search = 0,
+ .match_direction = MATCH_TINKER_PATTERN_DOWN,
+ .pattern = "",
+ };
+
+ while (!global_exit) {
+ reset_menu();
+ current_menu = menu;
+ build_conf(menu);
+ if (!child_count)
+ break;
+
+ show_menu(prompt ? _(prompt) : _("Main Menu"),
+ _(menu_instructions),
+ current_index, &last_top_row);
+ keypad((menu_win(curses_menu)), TRUE);
+ while (!global_exit) {
+ if (match_state.in_search) {
+ mvprintw(0, 0,
+ "searching: %s", match_state.pattern);
+ clrtoeol();
+ }
+ refresh_all_windows(main_window);
+ res = wgetch(menu_win(curses_menu));
+ if (!res)
+ break;
+ if (do_match(res, &match_state, &current_index) == 0) {
+ if (current_index != -1)
+ center_item(current_index,
+ &last_top_row);
+ continue;
+ }
+ if (process_special_keys(&res,
+ (struct menu *) item_data()))
+ break;
+ switch (res) {
+ case KEY_DOWN:
+ menu_driver(curses_menu, REQ_DOWN_ITEM);
+ break;
+ case KEY_UP:
+ menu_driver(curses_menu, REQ_UP_ITEM);
+ break;
+ case KEY_NPAGE:
+ menu_driver(curses_menu, REQ_SCR_DPAGE);
+ break;
+ case KEY_PPAGE:
+ menu_driver(curses_menu, REQ_SCR_UPAGE);
+ break;
+ case KEY_HOME:
+ menu_driver(curses_menu, REQ_FIRST_ITEM);
+ break;
+ case KEY_END:
+ menu_driver(curses_menu, REQ_LAST_ITEM);
+ break;
+ case 'h':
+ case '?':
+ show_help((struct menu *) item_data());
+ break;
+ }
+ if (res == 10 || res == 27 ||
+ res == 32 || res == 'n' || res == 'y' ||
+ res == KEY_LEFT || res == KEY_RIGHT ||
+ res == 'm')
+ break;
+ refresh_all_windows(main_window);
+ }
+
+ refresh_all_windows(main_window);
+ /* if ESC or left*/
+ if (res == 27 || (menu != &rootmenu && res == KEY_LEFT))
+ break;
+
+ /* remember location in the menu */
+ last_top_row = top_row(curses_menu);
+ current_index = curses_item_index();
+
+ if (!item_tag())
+ continue;
+
+ submenu = (struct menu *) item_data();
+ if (!submenu || !menu_is_visible(submenu))
+ continue;
+ sym = submenu->sym;
+
+ switch (res) {
+ case ' ':
+ if (item_is_tag('t'))
+ sym_toggle_tristate_value(sym);
+ else if (item_is_tag('m'))
+ conf(submenu);
+ break;
+ case KEY_RIGHT:
+ case 10: /* ENTER WAS PRESSED */
+ switch (item_tag()) {
+ case 'm':
+ if (single_menu_mode)
+ submenu->data =
+ (void *) (long) !submenu->data;
+ else
+ conf(submenu);
+ break;
+ case 't':
+ if (sym_is_choice(sym) &&
+ sym_get_tristate_value(sym) == yes)
+ conf_choice(submenu);
+ else if (submenu->prompt &&
+ submenu->prompt->type == P_MENU)
+ conf(submenu);
+ else if (res == 10)
+ sym_toggle_tristate_value(sym);
+ break;
+ case 's':
+ conf_string(submenu);
+ break;
+ }
+ break;
+ case 'y':
+ if (item_is_tag('t')) {
+ if (sym_set_tristate_value(sym, yes))
+ break;
+ if (sym_set_tristate_value(sym, mod))
+ btn_dialog(main_window, setmod_text, 0);
+ }
+ break;
+ case 'n':
+ if (item_is_tag('t'))
+ sym_set_tristate_value(sym, no);
+ break;
+ case 'm':
+ if (item_is_tag('t'))
+ sym_set_tristate_value(sym, mod);
+ break;
+ }
+ }
+}
+
+static void conf_message_callback(const char *fmt, va_list ap)
+{
+ char buf[1024];
+
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ btn_dialog(main_window, buf, 1, "<OK>");
+}
+
+static void show_help(struct menu *menu)
+{
+ struct gstr help;
+
+ if (!menu)
+ return;
+
+ help = str_new();
+ menu_get_ext_help(menu, &help);
+ show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help));
+ str_free(&help);
+}
+
+static void conf_choice(struct menu *menu)
+{
+ const char *prompt = _(menu_get_prompt(menu));
+ struct menu *child = 0;
+ struct symbol *active;
+ int selected_index = 0;
+ int last_top_row = 0;
+ int res, i = 0;
+ struct match_state match_state = {
+ .in_search = 0,
+ .match_direction = MATCH_TINKER_PATTERN_DOWN,
+ .pattern = "",
+ };
+
+ active = sym_get_choice_value(menu->sym);
+ /* this is mostly duplicated from the conf() function. */
+ while (!global_exit) {
+ reset_menu();
+
+ for (i = 0, child = menu->list; child; child = child->next) {
+ if (!show_all_items && !menu_is_visible(child))
+ continue;
+
+ if (child->sym == sym_get_choice_value(menu->sym))
+ item_make(child, ':', "<X> %s",
+ _(menu_get_prompt(child)));
+ else if (child->sym)
+ item_make(child, ':', " %s",
+ _(menu_get_prompt(child)));
+ else
+ item_make(child, ':', "*** %s ***",
+ _(menu_get_prompt(child)));
+
+ if (child->sym == active){
+ last_top_row = top_row(curses_menu);
+ selected_index = i;
+ }
+ i++;
+ }
+ show_menu(prompt ? _(prompt) : _("Choice Menu"),
+ _(radiolist_instructions),
+ selected_index,
+ &last_top_row);
+ while (!global_exit) {
+ if (match_state.in_search) {
+ mvprintw(0, 0, "searching: %s",
+ match_state.pattern);
+ clrtoeol();
+ }
+ refresh_all_windows(main_window);
+ res = wgetch(menu_win(curses_menu));
+ if (!res)
+ break;
+ if (do_match(res, &match_state, &selected_index) == 0) {
+ if (selected_index != -1)
+ center_item(selected_index,
+ &last_top_row);
+ continue;
+ }
+ if (process_special_keys(
+ &res,
+ (struct menu *) item_data()))
+ break;
+ switch (res) {
+ case KEY_DOWN:
+ menu_driver(curses_menu, REQ_DOWN_ITEM);
+ break;
+ case KEY_UP:
+ menu_driver(curses_menu, REQ_UP_ITEM);
+ break;
+ case KEY_NPAGE:
+ menu_driver(curses_menu, REQ_SCR_DPAGE);
+ break;
+ case KEY_PPAGE:
+ menu_driver(curses_menu, REQ_SCR_UPAGE);
+ break;
+ case KEY_HOME:
+ menu_driver(curses_menu, REQ_FIRST_ITEM);
+ break;
+ case KEY_END:
+ menu_driver(curses_menu, REQ_LAST_ITEM);
+ break;
+ case 'h':
+ case '?':
+ show_help((struct menu *) item_data());
+ break;
+ }
+ if (res == 10 || res == 27 || res == ' ' ||
+ res == KEY_LEFT){
+ break;
+ }
+ refresh_all_windows(main_window);
+ }
+ /* if ESC or left */
+ if (res == 27 || res == KEY_LEFT)
+ break;
+
+ child = item_data();
+ if (!child || !menu_is_visible(child) || !child->sym)
+ continue;
+ switch (res) {
+ case ' ':
+ case 10:
+ case KEY_RIGHT:
+ sym_set_tristate_value(child->sym, yes);
+ return;
+ case 'h':
+ case '?':
+ show_help(child);
+ active = child->sym;
+ break;
+ case KEY_EXIT:
+ return;
+ }
+ }
+}
+
+static void conf_string(struct menu *menu)
+{
+ const char *prompt = menu_get_prompt(menu);
+
+ while (1) {
+ int res;
+ const char *heading;
+
+ switch (sym_get_type(menu->sym)) {
+ case S_INT:
+ heading = _(inputbox_instructions_int);
+ break;
+ case S_HEX:
+ heading = _(inputbox_instructions_hex);
+ break;
+ case S_STRING:
+ heading = _(inputbox_instructions_string);
+ break;
+ default:
+ heading = _("Internal nconf error!");
+ }
+ res = dialog_inputbox(main_window,
+ prompt ? _(prompt) : _("Main Menu"),
+ heading,
+ sym_get_string_value(menu->sym),
+ &dialog_input_result,
+ &dialog_input_result_len);
+ switch (res) {
+ case 0:
+ if (sym_set_string_value(menu->sym,
+ dialog_input_result))
+ return;
+ btn_dialog(main_window,
+ _("You have made an invalid entry."), 0);
+ break;
+ case 1:
+ show_help(menu);
+ break;
+ case KEY_EXIT:
+ return;
+ }
+ }
+}
+
+static void conf_load(void)
+{
+ while (1) {
+ int res;
+ res = dialog_inputbox(main_window,
+ NULL, load_config_text,
+ filename,
+ &dialog_input_result,
+ &dialog_input_result_len);
+ switch (res) {
+ case 0:
+ if (!dialog_input_result[0])
+ return;
+ if (!conf_read(dialog_input_result)) {
+ set_config_filename(dialog_input_result);
+ sym_set_change_count(1);
+ return;
+ }
+ btn_dialog(main_window, _("File does not exist!"), 0);
+ break;
+ case 1:
+ show_scroll_win(main_window,
+ _("Load Alternate Configuration"),
+ load_config_help);
+ break;
+ case KEY_EXIT:
+ return;
+ }
+ }
+}
+
+static void conf_save(void)
+{
+ while (1) {
+ int res;
+ res = dialog_inputbox(main_window,
+ NULL, save_config_text,
+ filename,
+ &dialog_input_result,
+ &dialog_input_result_len);
+ switch (res) {
+ case 0:
+ if (!dialog_input_result[0])
+ return;
+ res = conf_write(dialog_input_result);
+ if (!res) {
+ set_config_filename(dialog_input_result);
+ return;
+ }
+ btn_dialog(main_window, _("Can't create file! "
+ "Probably a nonexistent directory."),
+ 1, "<OK>");
+ break;
+ case 1:
+ show_scroll_win(main_window,
+ _("Save Alternate Configuration"),
+ save_config_help);
+ break;
+ case KEY_EXIT:
+ return;
+ }
+ }
+}
+
+void setup_windows(void)
+{
+ int lines, columns;
+
+ getmaxyx(stdscr, lines, columns);
+
+ if (main_window != NULL)
+ delwin(main_window);
+
+ /* set up the menu and menu window */
+ main_window = newwin(lines-2, columns-2, 2, 1);
+ keypad(main_window, TRUE);
+ mwin_max_lines = lines-7;
+ mwin_max_cols = columns-6;
+
+ /* panels order is from bottom to top */
+ new_panel(main_window);
+}
+
+int main(int ac, char **av)
+{
+ int lines, columns;
+ char *mode;
+
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ conf_parse(av[1]);
+ conf_read(NULL);
+
+ mode = getenv("NCONFIG_MODE");
+ if (mode) {
+ if (!strcasecmp(mode, "single_menu"))
+ single_menu_mode = 1;
+ }
+
+ /* Initialize curses */
+ initscr();
+ /* set color theme */
+ set_colors();
+
+ cbreak();
+ noecho();
+ keypad(stdscr, TRUE);
+ curs_set(0);
+
+ getmaxyx(stdscr, lines, columns);
+ if (columns < 75 || lines < 20) {
+ endwin();
+ printf("Your terminal should have at "
+ "least 20 lines and 75 columns\n");
+ return 1;
+ }
+
+ notimeout(stdscr, FALSE);
+#if NCURSES_REENTRANT
+ set_escdelay(1);
+#else
+ ESCDELAY = 1;
+#endif
+
+ /* set btns menu */
+ curses_menu = new_menu(curses_menu_items);
+ menu_opts_off(curses_menu, O_SHOWDESC);
+ menu_opts_on(curses_menu, O_SHOWMATCH);
+ menu_opts_on(curses_menu, O_ONEVALUE);
+ menu_opts_on(curses_menu, O_NONCYCLIC);
+ menu_opts_on(curses_menu, O_IGNORECASE);
+ set_menu_mark(curses_menu, " ");
+ set_menu_fore(curses_menu, attributes[MAIN_MENU_FORE]);
+ set_menu_back(curses_menu, attributes[MAIN_MENU_BACK]);
+ set_menu_grey(curses_menu, attributes[MAIN_MENU_GREY]);
+
+ set_config_filename(conf_get_configname());
+ setup_windows();
+
+ /* check for KEY_FUNC(1) */
+ if (has_key(KEY_F(1)) == FALSE) {
+ show_scroll_win(main_window,
+ _("Instructions"),
+ _(menu_no_f_instructions));
+ }
+
+ conf_set_message_callback(conf_message_callback);
+ /* do the work */
+ while (!global_exit) {
+ conf(&rootmenu);
+ if (!global_exit && do_exit() == 0)
+ break;
+ }
+ /* ok, we are done */
+ unpost_menu(curses_menu);
+ free_menu(curses_menu);
+ delwin(main_window);
+ clear();
+ refresh();
+ endwin();
+ return 0;
+}
+
diff --git a/extra/config/nconf.gui.c b/extra/config/nconf.gui.c
new file mode 100644
index 000000000..8275f0e55
--- /dev/null
+++ b/extra/config/nconf.gui.c
@@ -0,0 +1,656 @@
+/*
+ * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
+ * Released under the terms of the GNU GPL v2.0.
+ *
+ * Derived from menuconfig.
+ *
+ */
+#include "nconf.h"
+
+/* a list of all the different widgets we use */
+attributes_t attributes[ATTR_MAX+1] = {0};
+
+/* available colors:
+ COLOR_BLACK 0
+ COLOR_RED 1
+ COLOR_GREEN 2
+ COLOR_YELLOW 3
+ COLOR_BLUE 4
+ COLOR_MAGENTA 5
+ COLOR_CYAN 6
+ COLOR_WHITE 7
+ */
+static void set_normal_colors(void)
+{
+ init_pair(NORMAL, -1, -1);
+ init_pair(MAIN_HEADING, COLOR_MAGENTA, -1);
+
+ /* FORE is for the selected item */
+ init_pair(MAIN_MENU_FORE, -1, -1);
+ /* BACK for all the rest */
+ init_pair(MAIN_MENU_BACK, -1, -1);
+ init_pair(MAIN_MENU_GREY, -1, -1);
+ init_pair(MAIN_MENU_HEADING, COLOR_GREEN, -1);
+ init_pair(MAIN_MENU_BOX, COLOR_YELLOW, -1);
+
+ init_pair(SCROLLWIN_TEXT, -1, -1);
+ init_pair(SCROLLWIN_HEADING, COLOR_GREEN, -1);
+ init_pair(SCROLLWIN_BOX, COLOR_YELLOW, -1);
+
+ init_pair(DIALOG_TEXT, -1, -1);
+ init_pair(DIALOG_BOX, COLOR_YELLOW, -1);
+ init_pair(DIALOG_MENU_BACK, COLOR_YELLOW, -1);
+ init_pair(DIALOG_MENU_FORE, COLOR_RED, -1);
+
+ init_pair(INPUT_BOX, COLOR_YELLOW, -1);
+ init_pair(INPUT_HEADING, COLOR_GREEN, -1);
+ init_pair(INPUT_TEXT, -1, -1);
+ init_pair(INPUT_FIELD, -1, -1);
+
+ init_pair(FUNCTION_HIGHLIGHT, -1, -1);
+ init_pair(FUNCTION_TEXT, COLOR_YELLOW, -1);
+}
+
+/* available attributes:
+ A_NORMAL Normal display (no highlight)
+ A_STANDOUT Best highlighting mode of the terminal.
+ A_UNDERLINE Underlining
+ A_REVERSE Reverse video
+ A_BLINK Blinking
+ A_DIM Half bright
+ A_BOLD Extra bright or bold
+ A_PROTECT Protected mode
+ A_INVIS Invisible or blank mode
+ A_ALTCHARSET Alternate character set
+ A_CHARTEXT Bit-mask to extract a character
+ COLOR_PAIR(n) Color-pair number n
+ */
+static void normal_color_theme(void)
+{
+ /* automatically add color... */
+#define mkattr(name, attr) do { \
+attributes[name] = attr | COLOR_PAIR(name); } while (0)
+ mkattr(NORMAL, NORMAL);
+ mkattr(MAIN_HEADING, A_BOLD | A_UNDERLINE);
+
+ mkattr(MAIN_MENU_FORE, A_REVERSE);
+ mkattr(MAIN_MENU_BACK, A_NORMAL);
+ mkattr(MAIN_MENU_GREY, A_NORMAL);
+ mkattr(MAIN_MENU_HEADING, A_BOLD);
+ mkattr(MAIN_MENU_BOX, A_NORMAL);
+
+ mkattr(SCROLLWIN_TEXT, A_NORMAL);
+ mkattr(SCROLLWIN_HEADING, A_BOLD);
+ mkattr(SCROLLWIN_BOX, A_BOLD);
+
+ mkattr(DIALOG_TEXT, A_BOLD);
+ mkattr(DIALOG_BOX, A_BOLD);
+ mkattr(DIALOG_MENU_FORE, A_STANDOUT);
+ mkattr(DIALOG_MENU_BACK, A_NORMAL);
+
+ mkattr(INPUT_BOX, A_NORMAL);
+ mkattr(INPUT_HEADING, A_BOLD);
+ mkattr(INPUT_TEXT, A_NORMAL);
+ mkattr(INPUT_FIELD, A_UNDERLINE);
+
+ mkattr(FUNCTION_HIGHLIGHT, A_BOLD);
+ mkattr(FUNCTION_TEXT, A_REVERSE);
+}
+
+static void no_colors_theme(void)
+{
+ /* automatically add highlight, no color */
+#define mkattrn(name, attr) { attributes[name] = attr; }
+
+ mkattrn(NORMAL, NORMAL);
+ mkattrn(MAIN_HEADING, A_BOLD | A_UNDERLINE);
+
+ mkattrn(MAIN_MENU_FORE, A_STANDOUT);
+ mkattrn(MAIN_MENU_BACK, A_NORMAL);
+ mkattrn(MAIN_MENU_GREY, A_NORMAL);
+ mkattrn(MAIN_MENU_HEADING, A_BOLD);
+ mkattrn(MAIN_MENU_BOX, A_NORMAL);
+
+ mkattrn(SCROLLWIN_TEXT, A_NORMAL);
+ mkattrn(SCROLLWIN_HEADING, A_BOLD);
+ mkattrn(SCROLLWIN_BOX, A_BOLD);
+
+ mkattrn(DIALOG_TEXT, A_NORMAL);
+ mkattrn(DIALOG_BOX, A_BOLD);
+ mkattrn(DIALOG_MENU_FORE, A_STANDOUT);
+ mkattrn(DIALOG_MENU_BACK, A_NORMAL);
+
+ mkattrn(INPUT_BOX, A_BOLD);
+ mkattrn(INPUT_HEADING, A_BOLD);
+ mkattrn(INPUT_TEXT, A_NORMAL);
+ mkattrn(INPUT_FIELD, A_UNDERLINE);
+
+ mkattrn(FUNCTION_HIGHLIGHT, A_BOLD);
+ mkattrn(FUNCTION_TEXT, A_REVERSE);
+}
+
+void set_colors()
+{
+ start_color();
+ use_default_colors();
+ set_normal_colors();
+ if (has_colors()) {
+ normal_color_theme();
+ } else {
+ /* give defaults */
+ no_colors_theme();
+ }
+}
+
+
+/* this changes the windows attributes !!! */
+void print_in_middle(WINDOW *win,
+ int starty,
+ int startx,
+ int width,
+ const char *string,
+ chtype color)
+{ int length, x, y;
+ float temp;
+
+
+ if (win == NULL)
+ win = stdscr;
+ getyx(win, y, x);
+ if (startx != 0)
+ x = startx;
+ if (starty != 0)
+ y = starty;
+ if (width == 0)
+ width = 80;
+
+ length = strlen(string);
+ temp = (width - length) / 2;
+ x = startx + (int)temp;
+ (void) wattrset(win, color);
+ mvwprintw(win, y, x, "%s", string);
+ refresh();
+}
+
+int get_line_no(const char *text)
+{
+ int i;
+ int total = 1;
+
+ if (!text)
+ return 0;
+
+ for (i = 0; text[i] != '\0'; i++)
+ if (text[i] == '\n')
+ total++;
+ return total;
+}
+
+const char *get_line(const char *text, int line_no)
+{
+ int i;
+ int lines = 0;
+
+ if (!text)
+ return 0;
+
+ for (i = 0; text[i] != '\0' && lines < line_no; i++)
+ if (text[i] == '\n')
+ lines++;
+ return text+i;
+}
+
+int get_line_length(const char *line)
+{
+ int res = 0;
+ while (*line != '\0' && *line != '\n') {
+ line++;
+ res++;
+ }
+ return res;
+}
+
+/* print all lines to the window. */
+void fill_window(WINDOW *win, const char *text)
+{
+ int x, y;
+ int total_lines = get_line_no(text);
+ int i;
+
+ getmaxyx(win, y, x);
+ /* do not go over end of line */
+ total_lines = min(total_lines, y);
+ for (i = 0; i < total_lines; i++) {
+ char tmp[x+10];
+ const char *line = get_line(text, i);
+ int len = get_line_length(line);
+ strncpy(tmp, line, min(len, x));
+ tmp[len] = '\0';
+ mvwprintw(win, i, 0, "%s", tmp);
+ }
+}
+
+/* get the message, and buttons.
+ * each button must be a char*
+ * return the selected button
+ *
+ * this dialog is used for 2 different things:
+ * 1) show a text box, no buttons.
+ * 2) show a dialog, with horizontal buttons
+ */
+int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
+{
+ va_list ap;
+ char *btn;
+ int btns_width = 0;
+ int msg_lines = 0;
+ int msg_width = 0;
+ int total_width;
+ int win_rows = 0;
+ WINDOW *win;
+ WINDOW *msg_win;
+ WINDOW *menu_win;
+ MENU *menu;
+ ITEM *btns[btn_num+1];
+ int i, x, y;
+ int res = -1;
+
+
+ va_start(ap, btn_num);
+ for (i = 0; i < btn_num; i++) {
+ btn = va_arg(ap, char *);
+ btns[i] = new_item(btn, "");
+ btns_width += strlen(btn)+1;
+ }
+ va_end(ap);
+ btns[btn_num] = NULL;
+
+ /* find the widest line of msg: */
+ msg_lines = get_line_no(msg);
+ for (i = 0; i < msg_lines; i++) {
+ const char *line = get_line(msg, i);
+ int len = get_line_length(line);
+ if (msg_width < len)
+ msg_width = len;
+ }
+
+ total_width = max(msg_width, btns_width);
+ /* place dialog in middle of screen */
+ y = (getmaxy(stdscr)-(msg_lines+4))/2;
+ x = (getmaxx(stdscr)-(total_width+4))/2;
+
+
+ /* create the windows */
+ if (btn_num > 0)
+ win_rows = msg_lines+4;
+ else
+ win_rows = msg_lines+2;
+
+ win = newwin(win_rows, total_width+4, y, x);
+ keypad(win, TRUE);
+ menu_win = derwin(win, 1, btns_width, win_rows-2,
+ 1+(total_width+2-btns_width)/2);
+ menu = new_menu(btns);
+ msg_win = derwin(win, win_rows-2, msg_width, 1,
+ 1+(total_width+2-msg_width)/2);
+
+ set_menu_fore(menu, attributes[DIALOG_MENU_FORE]);
+ set_menu_back(menu, attributes[DIALOG_MENU_BACK]);
+
+ (void) wattrset(win, attributes[DIALOG_BOX]);
+ box(win, 0, 0);
+
+ /* print message */
+ (void) wattrset(msg_win, attributes[DIALOG_TEXT]);
+ fill_window(msg_win, msg);
+
+ set_menu_win(menu, win);
+ set_menu_sub(menu, menu_win);
+ set_menu_format(menu, 1, btn_num);
+ menu_opts_off(menu, O_SHOWDESC);
+ menu_opts_off(menu, O_SHOWMATCH);
+ menu_opts_on(menu, O_ONEVALUE);
+ menu_opts_on(menu, O_NONCYCLIC);
+ set_menu_mark(menu, "");
+ post_menu(menu);
+
+
+ touchwin(win);
+ refresh_all_windows(main_window);
+ while ((res = wgetch(win))) {
+ switch (res) {
+ case KEY_LEFT:
+ menu_driver(menu, REQ_LEFT_ITEM);
+ break;
+ case KEY_RIGHT:
+ menu_driver(menu, REQ_RIGHT_ITEM);
+ break;
+ case 10: /* ENTER */
+ case 27: /* ESCAPE */
+ case ' ':
+ case KEY_F(F_BACK):
+ case KEY_F(F_EXIT):
+ break;
+ }
+ touchwin(win);
+ refresh_all_windows(main_window);
+
+ if (res == 10 || res == ' ') {
+ res = item_index(current_item(menu));
+ break;
+ } else if (res == 27 || res == KEY_F(F_BACK) ||
+ res == KEY_F(F_EXIT)) {
+ res = KEY_EXIT;
+ break;
+ }
+ }
+
+ unpost_menu(menu);
+ free_menu(menu);
+ for (i = 0; i < btn_num; i++)
+ free_item(btns[i]);
+
+ delwin(win);
+ return res;
+}
+
+int dialog_inputbox(WINDOW *main_window,
+ const char *title, const char *prompt,
+ const char *init, char **resultp, int *result_len)
+{
+ int prompt_lines = 0;
+ int prompt_width = 0;
+ WINDOW *win;
+ WINDOW *prompt_win;
+ WINDOW *form_win;
+ PANEL *panel;
+ int i, x, y;
+ int res = -1;
+ int cursor_position = strlen(init);
+ int cursor_form_win;
+ char *result = *resultp;
+
+ if (strlen(init)+1 > *result_len) {
+ *result_len = strlen(init)+1;
+ *resultp = result = realloc(result, *result_len);
+ }
+
+ /* find the widest line of msg: */
+ prompt_lines = get_line_no(prompt);
+ for (i = 0; i < prompt_lines; i++) {
+ const char *line = get_line(prompt, i);
+ int len = get_line_length(line);
+ prompt_width = max(prompt_width, len);
+ }
+
+ if (title)
+ prompt_width = max(prompt_width, strlen(title));
+
+ /* place dialog in middle of screen */
+ y = (getmaxy(stdscr)-(prompt_lines+4))/2;
+ x = (getmaxx(stdscr)-(prompt_width+4))/2;
+
+ strncpy(result, init, *result_len);
+
+ /* create the windows */
+ win = newwin(prompt_lines+6, prompt_width+7, y, x);
+ prompt_win = derwin(win, prompt_lines+1, prompt_width, 2, 2);
+ form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2);
+ keypad(form_win, TRUE);
+
+ (void) wattrset(form_win, attributes[INPUT_FIELD]);
+
+ (void) wattrset(win, attributes[INPUT_BOX]);
+ box(win, 0, 0);
+ (void) wattrset(win, attributes[INPUT_HEADING]);
+ if (title)
+ mvwprintw(win, 0, 3, "%s", title);
+
+ /* print message */
+ (void) wattrset(prompt_win, attributes[INPUT_TEXT]);
+ fill_window(prompt_win, prompt);
+
+ mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
+ cursor_form_win = min(cursor_position, prompt_width-1);
+ mvwprintw(form_win, 0, 0, "%s",
+ result + cursor_position-cursor_form_win);
+
+ /* create panels */
+ panel = new_panel(win);
+
+ /* show the cursor */
+ curs_set(1);
+
+ touchwin(win);
+ refresh_all_windows(main_window);
+ while ((res = wgetch(form_win))) {
+ int len = strlen(result);
+ switch (res) {
+ case 10: /* ENTER */
+ case 27: /* ESCAPE */
+ case KEY_F(F_HELP):
+ case KEY_F(F_EXIT):
+ case KEY_F(F_BACK):
+ break;
+ case 127:
+ case KEY_BACKSPACE:
+ if (cursor_position > 0) {
+ memmove(&result[cursor_position-1],
+ &result[cursor_position],
+ len-cursor_position+1);
+ cursor_position--;
+ cursor_form_win--;
+ len--;
+ }
+ break;
+ case KEY_DC:
+ if (cursor_position >= 0 && cursor_position < len) {
+ memmove(&result[cursor_position],
+ &result[cursor_position+1],
+ len-cursor_position+1);
+ len--;
+ }
+ break;
+ case KEY_UP:
+ case KEY_RIGHT:
+ if (cursor_position < len) {
+ cursor_position++;
+ cursor_form_win++;
+ }
+ break;
+ case KEY_DOWN:
+ case KEY_LEFT:
+ if (cursor_position > 0) {
+ cursor_position--;
+ cursor_form_win--;
+ }
+ break;
+ case KEY_HOME:
+ cursor_position = 0;
+ cursor_form_win = 0;
+ break;
+ case KEY_END:
+ cursor_position = len;
+ cursor_form_win = min(cursor_position, prompt_width-1);
+ break;
+ default:
+ if ((isgraph(res) || isspace(res))) {
+ /* one for new char, one for '\0' */
+ if (len+2 > *result_len) {
+ *result_len = len+2;
+ *resultp = result = realloc(result,
+ *result_len);
+ }
+ /* insert the char at the proper position */
+ memmove(&result[cursor_position+1],
+ &result[cursor_position],
+ len-cursor_position+1);
+ result[cursor_position] = res;
+ cursor_position++;
+ cursor_form_win++;
+ len++;
+ } else {
+ mvprintw(0, 0, "unknown key: %d\n", res);
+ }
+ break;
+ }
+ if (cursor_form_win < 0)
+ cursor_form_win = 0;
+ else if (cursor_form_win > prompt_width-1)
+ cursor_form_win = prompt_width-1;
+
+ wmove(form_win, 0, 0);
+ wclrtoeol(form_win);
+ mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
+ mvwprintw(form_win, 0, 0, "%s",
+ result + cursor_position-cursor_form_win);
+ wmove(form_win, 0, cursor_form_win);
+ touchwin(win);
+ refresh_all_windows(main_window);
+
+ if (res == 10) {
+ res = 0;
+ break;
+ } else if (res == 27 || res == KEY_F(F_BACK) ||
+ res == KEY_F(F_EXIT)) {
+ res = KEY_EXIT;
+ break;
+ } else if (res == KEY_F(F_HELP)) {
+ res = 1;
+ break;
+ }
+ }
+
+ /* hide the cursor */
+ curs_set(0);
+ del_panel(panel);
+ delwin(prompt_win);
+ delwin(form_win);
+ delwin(win);
+ return res;
+}
+
+/* refresh all windows in the correct order */
+void refresh_all_windows(WINDOW *main_window)
+{
+ update_panels();
+ touchwin(main_window);
+ refresh();
+}
+
+/* layman's scrollable window... */
+void show_scroll_win(WINDOW *main_window,
+ const char *title,
+ const char *text)
+{
+ int res;
+ int total_lines = get_line_no(text);
+ int x, y, lines, columns;
+ int start_x = 0, start_y = 0;
+ int text_lines = 0, text_cols = 0;
+ int total_cols = 0;
+ int win_cols = 0;
+ int win_lines = 0;
+ int i = 0;
+ WINDOW *win;
+ WINDOW *pad;
+ PANEL *panel;
+
+ getmaxyx(stdscr, lines, columns);
+
+ /* find the widest line of msg: */
+ total_lines = get_line_no(text);
+ for (i = 0; i < total_lines; i++) {
+ const char *line = get_line(text, i);
+ int len = get_line_length(line);
+ total_cols = max(total_cols, len+2);
+ }
+
+ /* create the pad */
+ pad = newpad(total_lines+10, total_cols+10);
+ (void) wattrset(pad, attributes[SCROLLWIN_TEXT]);
+ fill_window(pad, text);
+
+ win_lines = min(total_lines+4, lines-2);
+ win_cols = min(total_cols+2, columns-2);
+ text_lines = max(win_lines-4, 0);
+ text_cols = max(win_cols-2, 0);
+
+ /* place window in middle of screen */
+ y = (lines-win_lines)/2;
+ x = (columns-win_cols)/2;
+
+ win = newwin(win_lines, win_cols, y, x);
+ keypad(win, TRUE);
+ /* show the help in the help window, and show the help panel */
+ (void) wattrset(win, attributes[SCROLLWIN_BOX]);
+ box(win, 0, 0);
+ (void) wattrset(win, attributes[SCROLLWIN_HEADING]);
+ mvwprintw(win, 0, 3, " %s ", title);
+ panel = new_panel(win);
+
+ /* handle scrolling */
+ do {
+
+ copywin(pad, win, start_y, start_x, 2, 2, text_lines,
+ text_cols, 0);
+ print_in_middle(win,
+ text_lines+2,
+ 0,
+ text_cols,
+ "<OK>",
+ attributes[DIALOG_MENU_FORE]);
+ wrefresh(win);
+
+ res = wgetch(win);
+ switch (res) {
+ case KEY_NPAGE:
+ case ' ':
+ case 'd':
+ start_y += text_lines-2;
+ break;
+ case KEY_PPAGE:
+ case 'u':
+ start_y -= text_lines+2;
+ break;
+ case KEY_HOME:
+ start_y = 0;
+ break;
+ case KEY_END:
+ start_y = total_lines-text_lines;
+ break;
+ case KEY_DOWN:
+ case 'j':
+ start_y++;
+ break;
+ case KEY_UP:
+ case 'k':
+ start_y--;
+ break;
+ case KEY_LEFT:
+ case 'h':
+ start_x--;
+ break;
+ case KEY_RIGHT:
+ case 'l':
+ start_x++;
+ break;
+ }
+ if (res == 10 || res == 27 || res == 'q' ||
+ res == KEY_F(F_HELP) || res == KEY_F(F_BACK) ||
+ res == KEY_F(F_EXIT))
+ break;
+ if (start_y < 0)
+ start_y = 0;
+ if (start_y >= total_lines-text_lines)
+ start_y = total_lines-text_lines;
+ if (start_x < 0)
+ start_x = 0;
+ if (start_x >= total_cols-text_cols)
+ start_x = total_cols-text_cols;
+ } while (res);
+
+ del_panel(panel);
+ delwin(win);
+ refresh_all_windows(main_window);
+}
diff --git a/extra/config/nconf.h b/extra/config/nconf.h
new file mode 100644
index 000000000..0d5261705
--- /dev/null
+++ b/extra/config/nconf.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
+ * Released under the terms of the GNU GPL v2.0.
+ *
+ * Derived from menuconfig.
+ *
+ */
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <locale.h>
+#include <curses.h>
+#include <menu.h>
+#include <panel.h>
+#include <form.h>
+
+#include <stdio.h>
+#include <time.h>
+#include <sys/time.h>
+
+#include "ncurses.h"
+
+#define max(a, b) ({\
+ typeof(a) _a = a;\
+ typeof(b) _b = b;\
+ _a > _b ? _a : _b; })
+
+#define min(a, b) ({\
+ typeof(a) _a = a;\
+ typeof(b) _b = b;\
+ _a < _b ? _a : _b; })
+
+typedef enum {
+ NORMAL = 1,
+ MAIN_HEADING,
+ MAIN_MENU_BOX,
+ MAIN_MENU_FORE,
+ MAIN_MENU_BACK,
+ MAIN_MENU_GREY,
+ MAIN_MENU_HEADING,
+ SCROLLWIN_TEXT,
+ SCROLLWIN_HEADING,
+ SCROLLWIN_BOX,
+ DIALOG_TEXT,
+ DIALOG_MENU_FORE,
+ DIALOG_MENU_BACK,
+ DIALOG_BOX,
+ INPUT_BOX,
+ INPUT_HEADING,
+ INPUT_TEXT,
+ INPUT_FIELD,
+ FUNCTION_TEXT,
+ FUNCTION_HIGHLIGHT,
+ ATTR_MAX
+} attributes_t;
+extern attributes_t attributes[];
+
+typedef enum {
+ F_HELP = 1,
+ F_SYMBOL = 2,
+ F_INSTS = 3,
+ F_CONF = 4,
+ F_BACK = 5,
+ F_SAVE = 6,
+ F_LOAD = 7,
+ F_SEARCH = 8,
+ F_EXIT = 9,
+} function_key;
+
+void set_colors(void);
+
+/* this changes the windows attributes !!! */
+void print_in_middle(WINDOW *win,
+ int starty,
+ int startx,
+ int width,
+ const char *string,
+ chtype color);
+int get_line_length(const char *line);
+int get_line_no(const char *text);
+const char *get_line(const char *text, int line_no);
+void fill_window(WINDOW *win, const char *text);
+int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...);
+int dialog_inputbox(WINDOW *main_window,
+ const char *title, const char *prompt,
+ const char *init, char **resultp, int *result_len);
+void refresh_all_windows(WINDOW *main_window);
+void show_scroll_win(WINDOW *main_window,
+ const char *title,
+ const char *text);
diff --git a/extra/config/qconf.cc b/extra/config/qconf.cc
index ec3b5bb1e..8db89b8b0 100644
--- a/extra/config/qconf.cc
+++ b/extra/config/qconf.cc
@@ -3,24 +3,43 @@
* Released under the terms of the GNU GPL v2.0.
*/
-#include <qapplication.h>
+#include <qglobal.h>
+
+#if QT_VERSION < 0x040000
+#include <stddef.h>
#include <qmainwindow.h>
+#include <qvbox.h>
+#include <qvaluelist.h>
+#include <qtextbrowser.h>
+#include <qaction.h>
+#include <qheader.h>
+#include <qfiledialog.h>
+#include <qdragobject.h>
+#include <qpopupmenu.h>
+#else
+#include <q3mainwindow.h>
+#include <q3vbox.h>
+#include <q3valuelist.h>
+#include <q3textbrowser.h>
+#include <q3action.h>
+#include <q3header.h>
+#include <q3filedialog.h>
+#include <q3dragobject.h>
+#include <q3popupmenu.h>
+#endif
+
+#include <qapplication.h>
+#include <qdesktopwidget.h>
#include <qtoolbar.h>
#include <qlayout.h>
-#include <qvbox.h>
#include <qsplitter.h>
-#include <qlistview.h>
-#include <qtextbrowser.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qmenubar.h>
#include <qmessagebox.h>
-#include <qaction.h>
-#include <qheader.h>
-#include <qfiledialog.h>
-#include <qdragobject.h>
#include <qregexp.h>
+#include <qevent.h>
#include <stdlib.h>
@@ -38,7 +57,7 @@
static QApplication *configApp;
static ConfigSettings *configSettings;
-QAction *ConfigMainWindow::saveAction;
+Q3Action *ConfigMainWindow::saveAction;
static inline QString qgettext(const char* str)
{
@@ -53,15 +72,14 @@ static inline QString qgettext(const QString& str)
/**
* Reads a list of integer values from the application settings.
*/
-QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
+Q3ValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
{
- QValueList<int> result;
+ Q3ValueList<int> result;
QStringList entryList = readListEntry(key, ok);
- if (ok) {
- QStringList::Iterator it;
- for (it = entryList.begin(); it != entryList.end(); ++it)
- result.push_back((*it).toInt());
- }
+ QStringList::Iterator it;
+
+ for (it = entryList.begin(); it != entryList.end(); ++it)
+ result.push_back((*it).toInt());
return result;
}
@@ -69,10 +87,10 @@ QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok)
/**
* Writes a list of integer values to the application settings.
*/
-bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value)
+bool ConfigSettings::writeSizes(const QString& key, const Q3ValueList<int>& value)
{
QStringList stringList;
- QValueList<int>::ConstIterator it;
+ Q3ValueList<int>::ConstIterator it;
for (it = value.begin(); it != value.end(); ++it)
stringList.push_back(QString::number(*it));
@@ -80,7 +98,6 @@ bool ConfigSettings::writeSizes(const QString& key, const QValueList<int>& value
}
-#if QT_VERSION >= 300
/*
* set the new data
* TODO check the value
@@ -91,7 +108,6 @@ void ConfigItem::okRename(int col)
sym_set_string_value(menu->sym, text(dataColIdx).latin1());
listView()->updateList(this);
}
-#endif
/*
* update the displayed of a menu entry
@@ -148,7 +164,7 @@ void ConfigItem::updateMenu(void)
case S_TRISTATE:
char ch;
- if (!sym_is_changable(sym) && !list->showAll) {
+ if (!sym_is_changable(sym) && list->optMode == normalOpt) {
setPixmap(promptColIdx, 0);
setText(noColIdx, QString::null);
setText(modColIdx, QString::null);
@@ -195,11 +211,9 @@ void ConfigItem::updateMenu(void)
data = sym_get_string_value(sym);
-#if QT_VERSION >= 300
int i = list->mapIdx(dataColIdx);
if (i >= 0)
setRenameEnabled(i, TRUE);
-#endif
setText(dataColIdx, data);
if (type == S_STRING)
prompt = QString("%1: %2").arg(prompt).arg(data);
@@ -297,10 +311,10 @@ void ConfigLineEdit::show(ConfigItem* i)
void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
{
switch (e->key()) {
- case Key_Escape:
+ case Qt::Key_Escape:
break;
- case Key_Return:
- case Key_Enter:
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
sym_set_string_value(item->menu->sym, text().latin1());
parent()->updateList(item);
break;
@@ -319,7 +333,7 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),
- showAll(false), showName(false), showRange(false), showData(false),
+ showName(false), showRange(false), showData(false), optMode(normalOpt),
rootEntry(0), headerPopup(0)
{
int i;
@@ -336,10 +350,10 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
if (name) {
configSettings->beginGroup(name);
- showAll = configSettings->readBoolEntry("/showAll", false);
showName = configSettings->readBoolEntry("/showName", false);
showRange = configSettings->readBoolEntry("/showRange", false);
showData = configSettings->readBoolEntry("/showData", false);
+ optMode = (enum optionMode)configSettings->readNumEntry("/optionMode", false);
configSettings->endGroup();
connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
}
@@ -351,6 +365,17 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
reinit();
}
+bool ConfigList::menuSkip(struct menu *menu)
+{
+ if (optMode == normalOpt && menu_is_visible(menu))
+ return false;
+ if (optMode == promptOpt && menu_has_prompt(menu))
+ return false;
+ if (optMode == allOpt)
+ return false;
+ return true;
+}
+
void ConfigList::reinit(void)
{
removeColumn(dataColIdx);
@@ -379,7 +404,7 @@ void ConfigList::saveSettings(void)
configSettings->writeEntry("/showName", showName);
configSettings->writeEntry("/showRange", showRange);
configSettings->writeEntry("/showData", showData);
- configSettings->writeEntry("/showAll", showAll);
+ configSettings->writeEntry("/optionMode", (int)optMode);
configSettings->endGroup();
}
}
@@ -421,7 +446,7 @@ void ConfigList::updateList(ConfigItem* item)
if (!rootEntry) {
if (mode != listMode)
goto update;
- QListViewItemIterator it(this);
+ Q3ListViewItemIterator it(this);
ConfigItem* item;
for (; it.current(); ++it) {
@@ -516,11 +541,9 @@ void ConfigList::changeValue(ConfigItem* item)
case S_INT:
case S_HEX:
case S_STRING:
-#if QT_VERSION >= 300
if (colMap[dataColIdx] >= 0)
item->startRename(colMap[dataColIdx]);
else
-#endif
parent()->lineEdit->show(item);
break;
}
@@ -552,7 +575,7 @@ void ConfigList::setParentMenu(void)
return;
setRootMenu(menu_get_parent_menu(rootEntry->parent));
- QListViewItemIterator it(this);
+ Q3ListViewItemIterator it(this);
for (; (item = (ConfigItem*)it.current()); it++) {
if (item->menu == oldroot) {
setCurrentItem(item);
@@ -605,7 +628,7 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu)
}
visible = menu_is_visible(child);
- if (showAll || visible) {
+ if (!menuSkip(child)) {
if (!child->sym && !child->list && !child->prompt)
continue;
if (!item || item->menu != child)
@@ -634,12 +657,12 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu)
void ConfigList::keyPressEvent(QKeyEvent* ev)
{
- QListViewItem* i = currentItem();
+ Q3ListViewItem* i = currentItem();
ConfigItem* item;
struct menu *menu;
enum prop_type type;
- if (ev->key() == Key_Escape && mode != fullMode && mode != listMode) {
+ if (ev->key() == Qt::Key_Escape && mode != fullMode && mode != listMode) {
emit parentSelected();
ev->accept();
return;
@@ -652,8 +675,8 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
item = (ConfigItem*)i;
switch (ev->key()) {
- case Key_Return:
- case Key_Enter:
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
if (item->goParent) {
emit parentSelected();
break;
@@ -667,16 +690,16 @@ void ConfigList::keyPressEvent(QKeyEvent* ev)
emit menuSelected(menu);
break;
}
- case Key_Space:
+ case Qt::Key_Space:
changeValue(item);
break;
- case Key_N:
+ case Qt::Key_N:
setValue(item, no);
break;
- case Key_M:
+ case Qt::Key_M:
setValue(item, mod);
break;
- case Key_Y:
+ case Qt::Key_Y:
setValue(item, yes);
break;
default:
@@ -800,10 +823,10 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
{
if (e->y() <= header()->geometry().bottom()) {
if (!headerPopup) {
- QAction *action;
+ Q3Action *action;
- headerPopup = new QPopupMenu(this);
- action = new QAction(NULL, _("Show Name"), 0, this);
+ headerPopup = new Q3PopupMenu(this);
+ action = new Q3Action(NULL, _("Show Name"), 0, this);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)),
parent(), SLOT(setShowName(bool)));
@@ -811,7 +834,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
action, SLOT(setOn(bool)));
action->setOn(showName);
action->addTo(headerPopup);
- action = new QAction(NULL, _("Show Range"), 0, this);
+ action = new Q3Action(NULL, _("Show Range"), 0, this);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)),
parent(), SLOT(setShowRange(bool)));
@@ -819,7 +842,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
action, SLOT(setOn(bool)));
action->setOn(showRange);
action->addTo(headerPopup);
- action = new QAction(NULL, _("Show Data"), 0, this);
+ action = new Q3Action(NULL, _("Show Data"), 0, this);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)),
parent(), SLOT(setShowData(bool)));
@@ -834,7 +857,10 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
e->ignore();
}
-ConfigView* ConfigView::viewList;
+ConfigView*ConfigView::viewList;
+QAction *ConfigView::showNormalAction;
+QAction *ConfigView::showAllAction;
+QAction *ConfigView::showPromptAction;
ConfigView::ConfigView(QWidget* parent, const char *name)
: Parent(parent, name)
@@ -859,13 +885,16 @@ ConfigView::~ConfigView(void)
}
}
-void ConfigView::setShowAll(bool b)
+void ConfigView::setOptionMode(QAction *act)
{
- if (list->showAll != b) {
- list->showAll = b;
- list->updateListAll();
- emit showAllChanged(b);
- }
+ if (act == showNormalAction)
+ list->optMode = normalOpt;
+ else if (act == showAllAction)
+ list->optMode = allOpt;
+ else
+ list->optMode = promptOpt;
+
+ list->updateListAll();
}
void ConfigView::setShowName(bool b)
@@ -897,7 +926,7 @@ void ConfigView::setShowData(bool b)
void ConfigList::setAllOpen(bool open)
{
- QListViewItemIterator it(this);
+ Q3ListViewItemIterator it(this);
for (; it.current(); it++)
it.current()->setOpen(open);
@@ -920,7 +949,7 @@ void ConfigView::updateListAll(void)
}
ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
- : Parent(parent, name), menu(0), sym(0)
+ : Parent(parent, name), sym(0), _menu(0)
{
if (name) {
configSettings->beginGroup(name);
@@ -943,7 +972,7 @@ void ConfigInfoView::setShowDebug(bool b)
{
if (_showDebug != b) {
_showDebug = b;
- if (menu)
+ if (_menu)
menuInfo();
else if (sym)
symbolInfo();
@@ -953,44 +982,16 @@ void ConfigInfoView::setShowDebug(bool b)
void ConfigInfoView::setInfo(struct menu *m)
{
- if (menu == m)
+ if (_menu == m)
return;
- menu = m;
+ _menu = m;
sym = NULL;
- if (!menu)
+ if (!_menu)
clear();
else
menuInfo();
}
-void ConfigInfoView::setSource(const QString& name)
-{
- const char *p = name.latin1();
-
- menu = NULL;
- sym = NULL;
-
- switch (p[0]) {
- case 'm':
- struct menu *m;
-
- if (sscanf(p, "m%p", &m) == 1 && menu != m) {
- menu = m;
- menuInfo();
- emit menuSelected(menu);
- }
- break;
- case 's':
- struct symbol *s;
-
- if (sscanf(p, "s%p", &s) == 1 && sym != s) {
- sym = s;
- symbolInfo();
- }
- break;
- }
-}
-
void ConfigInfoView::symbolInfo(void)
{
QString str;
@@ -1012,11 +1013,11 @@ void ConfigInfoView::menuInfo(void)
struct symbol* sym;
QString head, debug, help;
- sym = menu->sym;
+ sym = _menu->sym;
if (sym) {
- if (menu->prompt) {
+ if (_menu->prompt) {
head += "<big><b>";
- head += print_filter(_(menu->prompt->text));
+ head += print_filter(_(_menu->prompt->text));
head += "</b></big>";
if (sym->name) {
head += " (";
@@ -1041,26 +1042,24 @@ void ConfigInfoView::menuInfo(void)
if (showDebug())
debug = debug_info(sym);
- help = menu_get_help(menu);
- /* Gettextize if the help text not empty */
- if (help.isEmpty())
- help = print_filter(menu_get_help(menu));
- else
- help = print_filter(_(menu_get_help(menu)));
- } else if (menu->prompt) {
+ struct gstr help_gstr = str_new();
+ menu_get_ext_help(_menu, &help_gstr);
+ help = print_filter(str_get(&help_gstr));
+ str_free(&help_gstr);
+ } else if (_menu->prompt) {
head += "<big><b>";
- head += print_filter(_(menu->prompt->text));
+ head += print_filter(_(_menu->prompt->text));
head += "</b></big><br><br>";
if (showDebug()) {
- if (menu->prompt->visible.expr) {
+ if (_menu->prompt->visible.expr) {
debug += "&nbsp;&nbsp;dep: ";
- expr_print(menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
+ expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
debug += "<br><br>";
}
}
}
if (showDebug())
- debug += QString().sprintf("defined at %s:%d<br><br>", menu->file->name, menu->lineno);
+ debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno);
setText(head + debug + help);
}
@@ -1163,10 +1162,10 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
*text += str2;
}
-QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
+Q3PopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
{
- QPopupMenu* popup = Parent::createPopupMenu(pos);
- QAction* action = new QAction(NULL, _("Show Debug Info"), 0, popup);
+ Q3PopupMenu* popup = Parent::createPopupMenu(pos);
+ Q3Action* action = new Q3Action(NULL, _("Show Debug Info"), 0, popup);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
@@ -1199,7 +1198,7 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam
layout1->addLayout(layout2);
split = new QSplitter(this);
- split->setOrientation(QSplitter::Vertical);
+ split->setOrientation(Qt::Vertical);
list = new ConfigView(split, name);
list->list->mode = listMode;
info = new ConfigInfoView(split, name);
@@ -1223,7 +1222,7 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam
y = configSettings->readNumEntry("/window y", 0, &ok);
if (ok)
move(x, y);
- QValueList<int> sizes = configSettings->readSizes("/split", &ok);
+ Q3ValueList<int> sizes = configSettings->readSizes("/split", &ok);
if (ok)
split->setSizes(sizes);
configSettings->endGroup();
@@ -1275,9 +1274,15 @@ ConfigMainWindow::ConfigMainWindow(void)
int x, y, width, height;
char title[256];
- QWidget *d = configApp->desktop();
- snprintf(title, sizeof(title), _("uClibc v%s Configuration"),
- getenv("VERSION"));
+ QDesktopWidget *d = configApp->desktop();
+ snprintf(title, sizeof(title), "%s%s",
+ rootmenu.prompt->text,
+#if QT_VERSION < 0x040000
+ " (Qt3)"
+#else
+ ""
+#endif
+ );
setCaption(title);
width = configSettings->readNumEntry("/window width", d->width() - 64);
@@ -1290,14 +1295,14 @@ ConfigMainWindow::ConfigMainWindow(void)
move(x, y);
split1 = new QSplitter(this);
- split1->setOrientation(QSplitter::Horizontal);
+ split1->setOrientation(Qt::Horizontal);
setCentralWidget(split1);
menuView = new ConfigView(split1, "menu");
menuList = menuView->list;
split2 = new QSplitter(split1);
- split2->setOrientation(QSplitter::Vertical);
+ split2->setOrientation(Qt::Vertical);
// create config tree
configView = new ConfigView(split2, "config");
@@ -1310,60 +1315,79 @@ ConfigMainWindow::ConfigMainWindow(void)
configList->setFocus();
menu = menuBar();
- toolBar = new QToolBar("Tools", this);
+ toolBar = new Q3ToolBar("Tools", this);
- backAction = new QAction("Back", QPixmap(xpm_back), _("Back"), 0, this);
+ backAction = new Q3Action("Back", QPixmap(xpm_back), _("Back"), 0, this);
connect(backAction, SIGNAL(activated()), SLOT(goBack()));
backAction->setEnabled(FALSE);
- QAction *quitAction = new QAction("Quit", _("&Quit"), CTRL+Key_Q, this);
+ Q3Action *quitAction = new Q3Action("Quit", _("&Quit"), Qt::CTRL + Qt::Key_Q, this);
connect(quitAction, SIGNAL(activated()), SLOT(close()));
- QAction *loadAction = new QAction("Load", QPixmap(xpm_load), _("&Load"), CTRL+Key_L, this);
+ Q3Action *loadAction = new Q3Action("Load", QPixmap(xpm_load), _("&Load"), Qt::CTRL + Qt::Key_L, this);
connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
- saveAction = new QAction("Save", QPixmap(xpm_save), _("&Save"), CTRL+Key_S, this);
+ saveAction = new Q3Action("Save", QPixmap(xpm_save), _("&Save"), Qt::CTRL + Qt::Key_S, this);
connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
conf_set_changed_callback(conf_changed);
// Set saveAction's initial state
conf_changed();
- QAction *saveAsAction = new QAction("Save As...", _("Save &As..."), 0, this);
+ Q3Action *saveAsAction = new Q3Action("Save As...", _("Save &As..."), 0, this);
connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
- QAction *searchAction = new QAction("Find", _("&Find"), CTRL+Key_F, this);
+ Q3Action *searchAction = new Q3Action("Find", _("&Find"), Qt::CTRL + Qt::Key_F, this);
connect(searchAction, SIGNAL(activated()), SLOT(searchConfig()));
- QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this);
+ Q3Action *singleViewAction = new Q3Action("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this);
connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
- QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this);
+ Q3Action *splitViewAction = new Q3Action("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this);
connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
- QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this);
+ Q3Action *fullViewAction = new Q3Action("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this);
connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
- QAction *showNameAction = new QAction(NULL, _("Show Name"), 0, this);
+ Q3Action *showNameAction = new Q3Action(NULL, _("Show Name"), 0, this);
showNameAction->setToggleAction(TRUE);
connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool)));
connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool)));
showNameAction->setOn(configView->showName());
- QAction *showRangeAction = new QAction(NULL, _("Show Range"), 0, this);
+ Q3Action *showRangeAction = new Q3Action(NULL, _("Show Range"), 0, this);
showRangeAction->setToggleAction(TRUE);
connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool)));
connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool)));
showRangeAction->setOn(configList->showRange);
- QAction *showDataAction = new QAction(NULL, _("Show Data"), 0, this);
+ Q3Action *showDataAction = new Q3Action(NULL, _("Show Data"), 0, this);
showDataAction->setToggleAction(TRUE);
connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
showDataAction->setOn(configList->showData);
- QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this);
- showAllAction->setToggleAction(TRUE);
- connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool)));
- connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool)));
- showAllAction->setOn(configList->showAll);
- QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this);
+
+ QActionGroup *optGroup = new QActionGroup(this);
+ optGroup->setExclusive(TRUE);
+ connect(optGroup, SIGNAL(selected(QAction *)), configView,
+ SLOT(setOptionMode(QAction *)));
+ connect(optGroup, SIGNAL(selected(QAction *)), menuView,
+ SLOT(setOptionMode(QAction *)));
+
+#if QT_VERSION >= 0x040000
+ configView->showNormalAction = new QAction(_("Show Normal Options"), optGroup);
+ configView->showAllAction = new QAction(_("Show All Options"), optGroup);
+ configView->showPromptAction = new QAction(_("Show Prompt Options"), optGroup);
+#else
+ configView->showNormalAction = new QAction(_("Show Normal Options"), 0, optGroup);
+ configView->showAllAction = new QAction(_("Show All Options"), 0, optGroup);
+ configView->showPromptAction = new QAction(_("Show Prompt Options"), 0, optGroup);
+#endif
+ configView->showNormalAction->setToggleAction(TRUE);
+ configView->showNormalAction->setOn(configList->optMode == normalOpt);
+ configView->showAllAction->setToggleAction(TRUE);
+ configView->showAllAction->setOn(configList->optMode == allOpt);
+ configView->showPromptAction->setToggleAction(TRUE);
+ configView->showPromptAction->setOn(configList->optMode == promptOpt);
+
+ Q3Action *showDebugAction = new Q3Action(NULL, _("Show Debug Info"), 0, this);
showDebugAction->setToggleAction(TRUE);
connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool)));
showDebugAction->setOn(helpText->showDebug());
- QAction *showIntroAction = new QAction(NULL, _("Introduction"), 0, this);
+ Q3Action *showIntroAction = new Q3Action(NULL, _("Introduction"), 0, this);
connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
- QAction *showAboutAction = new QAction(NULL, _("About"), 0, this);
+ Q3Action *showAboutAction = new Q3Action(NULL, _("About"), 0, this);
connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
// init tool bar
@@ -1377,7 +1401,7 @@ ConfigMainWindow::ConfigMainWindow(void)
fullViewAction->addTo(toolBar);
// create config menu
- QPopupMenu* config = new QPopupMenu(this);
+ Q3PopupMenu* config = new Q3PopupMenu(this);
menu->insertItem(_("&File"), config);
loadAction->addTo(config);
saveAction->addTo(config);
@@ -1386,22 +1410,22 @@ ConfigMainWindow::ConfigMainWindow(void)
quitAction->addTo(config);
// create edit menu
- QPopupMenu* editMenu = new QPopupMenu(this);
+ Q3PopupMenu* editMenu = new Q3PopupMenu(this);
menu->insertItem(_("&Edit"), editMenu);
searchAction->addTo(editMenu);
// create options menu
- QPopupMenu* optionMenu = new QPopupMenu(this);
+ Q3PopupMenu* optionMenu = new Q3PopupMenu(this);
menu->insertItem(_("&Option"), optionMenu);
showNameAction->addTo(optionMenu);
showRangeAction->addTo(optionMenu);
showDataAction->addTo(optionMenu);
optionMenu->insertSeparator();
- showAllAction->addTo(optionMenu);
- showDebugAction->addTo(optionMenu);
+ optGroup->addTo(optionMenu);
+ optionMenu->insertSeparator();
// create help menu
- QPopupMenu* helpMenu = new QPopupMenu(this);
+ Q3PopupMenu* helpMenu = new Q3PopupMenu(this);
menu->insertSeparator();
menu->insertItem(_("&Help"), helpMenu);
showIntroAction->addTo(helpMenu);
@@ -1436,7 +1460,7 @@ ConfigMainWindow::ConfigMainWindow(void)
showSplitView();
// UI setup done, restore splitter positions
- QValueList<int> sizes = configSettings->readSizes("/split1", &ok);
+ Q3ValueList<int> sizes = configSettings->readSizes("/split1", &ok);
if (ok)
split1->setSizes(sizes);
@@ -1447,7 +1471,7 @@ ConfigMainWindow::ConfigMainWindow(void)
void ConfigMainWindow::loadConfig(void)
{
- QString s = QFileDialog::getOpenFileName(".config", NULL, this);
+ QString s = Q3FileDialog::getOpenFileName(conf_get_configname(), NULL, this);
if (s.isNull())
return;
if (conf_read(QFile::encodeName(s)))
@@ -1455,19 +1479,21 @@ void ConfigMainWindow::loadConfig(void)
ConfigView::updateListAll();
}
-void ConfigMainWindow::saveConfig(void)
+bool ConfigMainWindow::saveConfig(void)
{
- if (conf_write(NULL))
+ if (conf_write(NULL)) {
QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
+ return false;
+ }
+ return true;
}
void ConfigMainWindow::saveConfigAs(void)
{
- QString s = QFileDialog::getSaveFileName(".config", NULL, this);
+ QString s = Q3FileDialog::getSaveFileName(conf_get_configname(), NULL, this);
if (s.isNull())
return;
- if (conf_write(QFile::encodeName(s)))
- QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
+ saveConfig();
}
void ConfigMainWindow::searchConfig(void)
@@ -1492,7 +1518,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
ConfigList* list = NULL;
ConfigItem* item;
- if (!menu_is_visible(menu) && !configView->showAll())
+ if (configList->menuSkip(menu))
return;
switch (configList->mode) {
@@ -1524,6 +1550,8 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
case fullMode:
list = configList;
break;
+ default:
+ break;
}
if (list) {
@@ -1618,7 +1646,11 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
switch (mb.exec()) {
case QMessageBox::Yes:
- conf_write(NULL);
+ if (saveConfig())
+ e->accept();
+ else
+ e->ignore();
+ break;
case QMessageBox::No:
e->accept();
break;
@@ -1630,7 +1662,7 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
void ConfigMainWindow::showIntro(void)
{
- static const QString str = _("Welcome to the qconf graphical configuration tool for uClibc.\n\n"
+ static const QString str = _("Welcome to the qconf graphical configuration tool.\n\n"
"For each option, a blank box indicates the feature is disabled, a check\n"
"indicates it is enabled, and a dot indicates that it is to be compiled\n"
"as a module. Clicking on the box will cycle through the three states.\n\n"
@@ -1673,6 +1705,9 @@ void ConfigMainWindow::saveSettings(void)
case fullMode :
entry = "full";
break;
+
+ default:
+ break;
}
configSettings->writeEntry("/listMode", entry);
@@ -1718,10 +1753,6 @@ int main(int ac, char** av)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
-#ifndef LKC_DIRECT_LINK
- kconfig_load();
-#endif
-
progname = av[0];
configApp = new QApplication(ac, av);
if (ac > 1 && av[1][0] == '-') {
diff --git a/extra/config/qconf.h b/extra/config/qconf.h
index b3b5657b6..3715b3e72 100644
--- a/extra/config/qconf.h
+++ b/extra/config/qconf.h
@@ -3,26 +3,25 @@
* Released under the terms of the GNU GPL v2.0.
*/
+#if QT_VERSION < 0x040000
#include <qlistview.h>
-#if QT_VERSION >= 300
-#include <qsettings.h>
#else
-class QSettings {
-public:
- void beginGroup(const QString& group) { }
- void endGroup(void) { }
- bool readBoolEntry(const QString& key, bool def = FALSE, bool* ok = 0) const
- { if (ok) *ok = FALSE; return def; }
- int readNumEntry(const QString& key, int def = 0, bool* ok = 0) const
- { if (ok) *ok = FALSE; return def; }
- QString readEntry(const QString& key, const QString& def = QString::null, bool* ok = 0) const
- { if (ok) *ok = FALSE; return def; }
- QStringList readListEntry(const QString& key, bool* ok = 0) const
- { if (ok) *ok = FALSE; return QStringList(); }
- template <class t>
- bool writeEntry(const QString& key, t value)
- { return TRUE; }
-};
+#include <q3listview.h>
+#endif
+#include <qsettings.h>
+
+#if QT_VERSION < 0x040000
+#define Q3ValueList QValueList
+#define Q3PopupMenu QPopupMenu
+#define Q3ListView QListView
+#define Q3ListViewItem QListViewItem
+#define Q3VBox QVBox
+#define Q3TextBrowser QTextBrowser
+#define Q3MainWindow QMainWindow
+#define Q3Action QAction
+#define Q3ToolBar QToolBar
+#define Q3ListViewItemIterator QListViewItemIterator
+#define Q3FileDialog QFileDialog
#endif
class ConfigView;
@@ -31,11 +30,10 @@ class ConfigItem;
class ConfigLineEdit;
class ConfigMainWindow;
-
class ConfigSettings : public QSettings {
public:
- QValueList<int> readSizes(const QString& key, bool *ok);
- bool writeSizes(const QString& key, const QValueList<int>& value);
+ Q3ValueList<int> readSizes(const QString& key, bool *ok);
+ bool writeSizes(const QString& key, const Q3ValueList<int>& value);
};
enum colIdx {
@@ -44,10 +42,13 @@ enum colIdx {
enum listMode {
singleMode, menuMode, symbolMode, fullMode, listMode
};
+enum optionMode {
+ normalOpt = 0, allOpt, promptOpt
+};
-class ConfigList : public QListView {
+class ConfigList : public Q3ListView {
Q_OBJECT
- typedef class QListView Parent;
+ typedef class Q3ListView Parent;
public:
ConfigList(ConfigView* p, const char *name = 0);
void reinit(void);
@@ -115,6 +116,8 @@ public:
void setAllOpen(bool open);
void setParentMenu(void);
+ bool menuSkip(struct menu *);
+
template <class P>
void updateMenuList(P*, struct menu*);
@@ -124,22 +127,23 @@ public:
QPixmap choiceYesPix, choiceNoPix;
QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
- bool showAll, showName, showRange, showData;
+ bool showName, showRange, showData;
enum listMode mode;
+ enum optionMode optMode;
struct menu *rootEntry;
QColorGroup disabledColorGroup;
QColorGroup inactivedColorGroup;
- QPopupMenu* headerPopup;
+ Q3PopupMenu* headerPopup;
private:
int colMap[colNr];
int colRevMap[colNr];
};
-class ConfigItem : public QListViewItem {
- typedef class QListViewItem Parent;
+class ConfigItem : public Q3ListViewItem {
+ typedef class Q3ListViewItem Parent;
public:
- ConfigItem(QListView *parent, ConfigItem *after, struct menu *m, bool v)
+ ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v)
: Parent(parent, after), menu(m), visible(v), goParent(false)
{
init();
@@ -149,16 +153,14 @@ public:
{
init();
}
- ConfigItem(QListView *parent, ConfigItem *after, bool v)
+ ConfigItem(Q3ListView *parent, ConfigItem *after, bool v)
: Parent(parent, after), menu(0), visible(v), goParent(true)
{
init();
}
~ConfigItem(void);
void init(void);
-#if QT_VERSION >= 300
void okRename(int col);
-#endif
void updateMenu(void);
void testUpdateMenu(bool v);
ConfigList* listView() const
@@ -213,26 +215,24 @@ public:
ConfigItem *item;
};
-class ConfigView : public QVBox {
+class ConfigView : public Q3VBox {
Q_OBJECT
- typedef class QVBox Parent;
+ typedef class Q3VBox Parent;
public:
ConfigView(QWidget* parent, const char *name = 0);
~ConfigView(void);
static void updateList(ConfigItem* item);
static void updateListAll(void);
- bool showAll(void) const { return list->showAll; }
bool showName(void) const { return list->showName; }
bool showRange(void) const { return list->showRange; }
bool showData(void) const { return list->showData; }
public slots:
- void setShowAll(bool);
void setShowName(bool);
void setShowRange(bool);
void setShowData(bool);
+ void setOptionMode(QAction *);
signals:
- void showAllChanged(bool);
void showNameChanged(bool);
void showRangeChanged(bool);
void showDataChanged(bool);
@@ -242,11 +242,15 @@ public:
static ConfigView* viewList;
ConfigView* nextView;
+
+ static QAction *showNormalAction;
+ static QAction *showAllAction;
+ static QAction *showPromptAction;
};
-class ConfigInfoView : public QTextBrowser {
+class ConfigInfoView : public Q3TextBrowser {
Q_OBJECT
- typedef class QTextBrowser Parent;
+ typedef class Q3TextBrowser Parent;
public:
ConfigInfoView(QWidget* parent, const char *name = 0);
bool showDebug(void) const { return _showDebug; }
@@ -254,7 +258,6 @@ public:
public slots:
void setInfo(struct menu *menu);
void saveSettings(void);
- void setSource(const QString& name);
void setShowDebug(bool);
signals:
@@ -267,11 +270,11 @@ protected:
QString debug_info(struct symbol *sym);
static QString print_filter(const QString &str);
static void expr_print_help(void *data, struct symbol *sym, const char *str);
- QPopupMenu* createPopupMenu(const QPoint& pos);
+ Q3PopupMenu* createPopupMenu(const QPoint& pos);
void contentsContextMenuEvent(QContextMenuEvent *e);
struct symbol *sym;
- struct menu *menu;
+ struct menu *_menu;
bool _showDebug;
};
@@ -295,10 +298,10 @@ protected:
struct symbol **result;
};
-class ConfigMainWindow : public QMainWindow {
+class ConfigMainWindow : public Q3MainWindow {
Q_OBJECT
- static QAction *saveAction;
+ static Q3Action *saveAction;
static void conf_changed(void);
public:
ConfigMainWindow(void);
@@ -308,7 +311,7 @@ public slots:
void listFocusChanged(void);
void goBack(void);
void loadConfig(void);
- void saveConfig(void);
+ bool saveConfig(void);
void saveConfigAs(void);
void searchConfig(void);
void showSingleView(void);
@@ -327,8 +330,8 @@ protected:
ConfigView *configView;
ConfigList *configList;
ConfigInfoView *helpText;
- QToolBar *toolBar;
- QAction *backAction;
+ Q3ToolBar *toolBar;
+ Q3Action *backAction;
QSplitter* split1;
QSplitter* split2;
};
diff --git a/extra/config/streamline_config.pl b/extra/config/streamline_config.pl
new file mode 100644
index 000000000..4606cdfb8
--- /dev/null
+++ b/extra/config/streamline_config.pl
@@ -0,0 +1,640 @@
+#!/usr/bin/perl -w
+#
+# Copyright 2005-2009 - Steven Rostedt
+# Licensed under the terms of the GNU GPL License version 2
+#
+# It's simple enough to figure out how this works.
+# If not, then you can ask me at stripconfig@goodmis.org
+#
+# What it does?
+#
+# If you have installed a Linux kernel from a distribution
+# that turns on way too many modules than you need, and
+# you only want the modules you use, then this program
+# is perfect for you.
+#
+# It gives you the ability to turn off all the modules that are
+# not loaded on your system.
+#
+# Howto:
+#
+# 1. Boot up the kernel that you want to stream line the config on.
+# 2. Change directory to the directory holding the source of the
+# kernel that you just booted.
+# 3. Copy the configuraton file to this directory as .config
+# 4. Have all your devices that you need modules for connected and
+# operational (make sure that their corresponding modules are loaded)
+# 5. Run this script redirecting the output to some other file
+# like config_strip.
+# 6. Back up your old config (if you want too).
+# 7. copy the config_strip file to .config
+# 8. Run "make oldconfig"
+#
+# Now your kernel is ready to be built with only the modules that
+# are loaded.
+#
+# Here's what I did with my Debian distribution.
+#
+# cd /usr/src/linux-2.6.10
+# cp /boot/config-2.6.10-1-686-smp .config
+# ~/bin/streamline_config > config_strip
+# mv .config config_sav
+# mv config_strip .config
+# make oldconfig
+#
+use strict;
+use Getopt::Long;
+
+# set the environment variable LOCALMODCONFIG_DEBUG to get
+# debug output.
+my $debugprint = 0;
+$debugprint = 1 if (defined($ENV{LOCALMODCONFIG_DEBUG}));
+
+sub dprint {
+ return if (!$debugprint);
+ print STDERR @_;
+}
+
+my $config = ".config";
+
+my $uname = `uname -r`;
+chomp $uname;
+
+my @searchconfigs = (
+ {
+ "file" => ".config",
+ "exec" => "cat",
+ },
+ {
+ "file" => "/proc/config.gz",
+ "exec" => "zcat",
+ },
+ {
+ "file" => "/boot/config-$uname",
+ "exec" => "cat",
+ },
+ {
+ "file" => "/boot/vmlinuz-$uname",
+ "exec" => "scripts/extract-ikconfig",
+ "test" => "scripts/extract-ikconfig",
+ },
+ {
+ "file" => "vmlinux",
+ "exec" => "scripts/extract-ikconfig",
+ "test" => "scripts/extract-ikconfig",
+ },
+ {
+ "file" => "/lib/modules/$uname/kernel/kernel/configs.ko",
+ "exec" => "scripts/extract-ikconfig",
+ "test" => "scripts/extract-ikconfig",
+ },
+ {
+ "file" => "kernel/configs.ko",
+ "exec" => "scripts/extract-ikconfig",
+ "test" => "scripts/extract-ikconfig",
+ },
+ {
+ "file" => "kernel/configs.o",
+ "exec" => "scripts/extract-ikconfig",
+ "test" => "scripts/extract-ikconfig",
+ },
+);
+
+sub read_config {
+ foreach my $conf (@searchconfigs) {
+ my $file = $conf->{"file"};
+
+ next if ( ! -f "$file");
+
+ if (defined($conf->{"test"})) {
+ `$conf->{"test"} $conf->{"file"} 2>/dev/null`;
+ next if ($?);
+ }
+
+ my $exec = $conf->{"exec"};
+
+ print STDERR "using config: '$file'\n";
+
+ open(my $infile, '-|', "$exec $file") || die "Failed to run $exec $file";
+ my @x = <$infile>;
+ close $infile;
+ return @x;
+ }
+ die "No config file found";
+}
+
+my @config_file = read_config;
+
+# Parse options
+my $localmodconfig = 0;
+my $localyesconfig = 0;
+
+GetOptions("localmodconfig" => \$localmodconfig,
+ "localyesconfig" => \$localyesconfig);
+
+# Get the build source and top level Kconfig file (passed in)
+my $ksource = ($ARGV[0] ? $ARGV[0] : '.');
+my $kconfig = $ARGV[1];
+my $lsmod_file = $ENV{'LSMOD'};
+
+my @makefiles = `find $ksource -name Makefile 2>/dev/null`;
+chomp @makefiles;
+
+my %depends;
+my %selects;
+my %prompts;
+my %objects;
+my $var;
+my $iflevel = 0;
+my @ifdeps;
+
+# prevent recursion
+my %read_kconfigs;
+
+sub read_kconfig {
+ my ($kconfig) = @_;
+
+ my $state = "NONE";
+ my $config;
+
+ my $cont = 0;
+ my $line;
+
+ my $source = "$ksource/$kconfig";
+ my $last_source = "";
+
+ # Check for any environment variables used
+ while ($source =~ /\$(\w+)/ && $last_source ne $source) {
+ my $env = $1;
+ $last_source = $source;
+ $source =~ s/\$$env/$ENV{$env}/;
+ }
+
+ open(my $kinfile, '<', $source) || die "Can't open $kconfig";
+ while (<$kinfile>) {
+ chomp;
+
+ # Make sure that lines ending with \ continue
+ if ($cont) {
+ $_ = $line . " " . $_;
+ }
+
+ if (s/\\$//) {
+ $cont = 1;
+ $line = $_;
+ next;
+ }
+
+ $cont = 0;
+
+ # collect any Kconfig sources
+ if (/^source\s*"(.*)"/) {
+ my $kconfig = $1;
+ # prevent reading twice.
+ if (!defined($read_kconfigs{$kconfig})) {
+ $read_kconfigs{$kconfig} = 1;
+ read_kconfig($kconfig);
+ }
+ next;
+ }
+
+ # configs found
+ if (/^\s*(menu)?config\s+(\S+)\s*$/) {
+ $state = "NEW";
+ $config = $2;
+
+ # Add depends for 'if' nesting
+ for (my $i = 0; $i < $iflevel; $i++) {
+ if ($i) {
+ $depends{$config} .= " " . $ifdeps[$i];
+ } else {
+ $depends{$config} = $ifdeps[$i];
+ }
+ $state = "DEP";
+ }
+
+ # collect the depends for the config
+ } elsif ($state eq "NEW" && /^\s*depends\s+on\s+(.*)$/) {
+ $state = "DEP";
+ $depends{$config} = $1;
+ } elsif ($state eq "DEP" && /^\s*depends\s+on\s+(.*)$/) {
+ $depends{$config} .= " " . $1;
+
+ # Get the configs that select this config
+ } elsif ($state ne "NONE" && /^\s*select\s+(\S+)/) {
+ my $conf = $1;
+ if (defined($selects{$conf})) {
+ $selects{$conf} .= " " . $config;
+ } else {
+ $selects{$conf} = $config;
+ }
+
+ # configs without prompts must be selected
+ } elsif ($state ne "NONE" && /^\s*tristate\s\S/) {
+ # note if the config has a prompt
+ $prompts{$config} = 1;
+
+ # Check for if statements
+ } elsif (/^if\s+(.*\S)\s*$/) {
+ my $deps = $1;
+ # remove beginning and ending non text
+ $deps =~ s/^[^a-zA-Z0-9_]*//;
+ $deps =~ s/[^a-zA-Z0-9_]*$//;
+
+ my @deps = split /[^a-zA-Z0-9_]+/, $deps;
+
+ $ifdeps[$iflevel++] = join ':', @deps;
+
+ } elsif (/^endif/) {
+
+ $iflevel-- if ($iflevel);
+
+ # stop on "help"
+ } elsif (/^\s*help\s*$/) {
+ $state = "NONE";
+ }
+ }
+ close($kinfile);
+}
+
+if ($kconfig) {
+ read_kconfig($kconfig);
+}
+
+# Makefiles can use variables to define their dependencies
+sub convert_vars {
+ my ($line, %vars) = @_;
+
+ my $process = "";
+
+ while ($line =~ s/^(.*?)(\$\((.*?)\))//) {
+ my $start = $1;
+ my $variable = $2;
+ my $var = $3;
+
+ if (defined($vars{$var})) {
+ $process .= $start . $vars{$var};
+ } else {
+ $process .= $start . $variable;
+ }
+ }
+
+ $process .= $line;
+
+ return $process;
+}
+
+# Read all Makefiles to map the configs to the objects
+foreach my $makefile (@makefiles) {
+
+ my $line = "";
+ my %make_vars;
+
+ open(my $infile, '<', $makefile) || die "Can't open $makefile";
+ while (<$infile>) {
+ # if this line ends with a backslash, continue
+ chomp;
+ if (/^(.*)\\$/) {
+ $line .= $1;
+ next;
+ }
+
+ $line .= $_;
+ $_ = $line;
+ $line = "";
+
+ my $objs;
+
+ # Convert variables in a line (could define configs)
+ $_ = convert_vars($_, %make_vars);
+
+ # collect objects after obj-$(CONFIG_FOO_BAR)
+ if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) {
+ $var = $1;
+ $objs = $2;
+
+ # check if variables are set
+ } elsif (/^\s*(\S+)\s*[:]?=\s*(.*\S)/) {
+ $make_vars{$1} = $2;
+ }
+ if (defined($objs)) {
+ foreach my $obj (split /\s+/,$objs) {
+ $obj =~ s/-/_/g;
+ if ($obj =~ /(.*)\.o$/) {
+ # Objects may be enabled by more than one config.
+ # Store configs in an array.
+ my @arr;
+
+ if (defined($objects{$1})) {
+ @arr = @{$objects{$1}};
+ }
+
+ $arr[$#arr+1] = $var;
+
+ # The objects have a hash mapping to a reference
+ # of an array of configs.
+ $objects{$1} = \@arr;
+ }
+ }
+ }
+ }
+ close($infile);
+}
+
+my %modules;
+my $linfile;
+
+if (defined($lsmod_file)) {
+ if ( ! -f $lsmod_file) {
+ if ( -f $ENV{'objtree'}."/".$lsmod_file) {
+ $lsmod_file = $ENV{'objtree'}."/".$lsmod_file;
+ } else {
+ die "$lsmod_file not found";
+ }
+ }
+
+ my $otype = ( -x $lsmod_file) ? '-|' : '<';
+ open($linfile, $otype, $lsmod_file);
+
+} else {
+
+ # see what modules are loaded on this system
+ my $lsmod;
+
+ foreach my $dir ( ("/sbin", "/bin", "/usr/sbin", "/usr/bin") ) {
+ if ( -x "$dir/lsmod" ) {
+ $lsmod = "$dir/lsmod";
+ last;
+ }
+}
+ if (!defined($lsmod)) {
+ # try just the path
+ $lsmod = "lsmod";
+ }
+
+ open($linfile, '-|', $lsmod) || die "Can not call lsmod with $lsmod";
+}
+
+while (<$linfile>) {
+ next if (/^Module/); # Skip the first line.
+ if (/^(\S+)/) {
+ $modules{$1} = 1;
+ }
+}
+close ($linfile);
+
+# add to the configs hash all configs that are needed to enable
+# a loaded module. This is a direct obj-${CONFIG_FOO} += bar.o
+# where we know we need bar.o so we add FOO to the list.
+my %configs;
+foreach my $module (keys(%modules)) {
+ if (defined($objects{$module})) {
+ my @arr = @{$objects{$module}};
+ foreach my $conf (@arr) {
+ $configs{$conf} = $module;
+ dprint "$conf added by direct ($module)\n";
+ if ($debugprint) {
+ my $c=$conf;
+ $c =~ s/^CONFIG_//;
+ if (defined($depends{$c})) {
+ dprint " deps = $depends{$c}\n";
+ } else {
+ dprint " no deps\n";
+ }
+ }
+ }
+ } else {
+ # Most likely, someone has a custom (binary?) module loaded.
+ print STDERR "$module config not found!!\n";
+ }
+}
+
+# Read the current config, and see what is enabled. We want to
+# ignore configs that we would not enable anyway.
+
+my %orig_configs;
+my $valid = "A-Za-z_0-9";
+
+foreach my $line (@config_file) {
+ $_ = $line;
+
+ if (/(CONFIG_[$valid]*)=(m|y)/) {
+ $orig_configs{$1} = $2;
+ }
+}
+
+my $repeat = 1;
+
+my $depconfig;
+
+#
+# Note, we do not care about operands (like: &&, ||, !) we want to add any
+# config that is in the depend list of another config. This script does
+# not enable configs that are not already enabled. If we come across a
+# config A that depends on !B, we can still add B to the list of depends
+# to keep on. If A was on in the original config, B would not have been
+# and B would not be turned on by this script.
+#
+sub parse_config_depends
+{
+ my ($p) = @_;
+
+ while ($p =~ /[$valid]/) {
+
+ if ($p =~ /^[^$valid]*([$valid]+)/) {
+ my $conf = "CONFIG_" . $1;
+
+ $p =~ s/^[^$valid]*[$valid]+//;
+
+ # We only need to process if the depend config is a module
+ if (!defined($orig_configs{$conf}) || !$orig_configs{conf} eq "m") {
+ next;
+ }
+
+ if (!defined($configs{$conf})) {
+ # We must make sure that this config has its
+ # dependencies met.
+ $repeat = 1; # do again
+ dprint "$conf selected by depend $depconfig\n";
+ $configs{$conf} = 1;
+ }
+ } else {
+ die "this should never happen";
+ }
+ }
+}
+
+# Select is treated a bit differently than depends. We call this
+# when a config has no prompt and requires another config to be
+# selected. We use to just select all configs that selected this
+# config, but found that that can balloon into enabling hundreds
+# of configs that we do not care about.
+#
+# The idea is we look at all the configs that select it. If one
+# is already in our list of configs to enable, then there's nothing
+# else to do. If there isn't, we pick the first config that was
+# enabled in the orignal config and use that.
+sub parse_config_selects
+{
+ my ($config, $p) = @_;
+
+ my $next_config;
+
+ while ($p =~ /[$valid]/) {
+
+ if ($p =~ /^[^$valid]*([$valid]+)/) {
+ my $conf = "CONFIG_" . $1;
+
+ $p =~ s/^[^$valid]*[$valid]+//;
+
+ # Make sure that this config exists in the current .config file
+ if (!defined($orig_configs{$conf})) {
+ dprint "$conf not set for $config select\n";
+ next;
+ }
+
+ # Check if something other than a module selects this config
+ if (defined($orig_configs{$conf}) && $orig_configs{$conf} ne "m") {
+ dprint "$conf (non module) selects config, we are good\n";
+ # we are good with this
+ return;
+ }
+ if (defined($configs{$conf})) {
+ dprint "$conf selects $config so we are good\n";
+ # A set config selects this config, we are good
+ return;
+ }
+ # Set this config to be selected
+ if (!defined($next_config)) {
+ $next_config = $conf;
+ }
+ } else {
+ die "this should never happen";
+ }
+ }
+
+ # If no possible config selected this, then something happened.
+ if (!defined($next_config)) {
+ print STDERR "WARNING: $config is required, but nothing in the\n";
+ print STDERR " current config selects it.\n";
+ return;
+ }
+
+ # If we are here, then we found no config that is set and
+ # selects this config. Repeat.
+ $repeat = 1;
+ # Make this config need to be selected
+ $configs{$next_config} = 1;
+ dprint "$next_config selected by select $config\n";
+}
+
+my %process_selects;
+
+# loop through all configs, select their dependencies.
+sub loop_depend {
+ $repeat = 1;
+
+ while ($repeat) {
+ $repeat = 0;
+
+ forloop:
+ foreach my $config (keys %configs) {
+
+ # If this config is not a module, we do not need to process it
+ if (defined($orig_configs{$config}) && $orig_configs{$config} ne "m") {
+ next forloop;
+ }
+
+ $config =~ s/^CONFIG_//;
+ $depconfig = $config;
+
+ if (defined($depends{$config})) {
+ # This config has dependencies. Make sure they are also included
+ parse_config_depends $depends{$config};
+ }
+
+ # If the config has no prompt, then we need to check if a config
+ # that is enabled selected it. Or if we need to enable one.
+ if (!defined($prompts{$config}) && defined($selects{$config})) {
+ $process_selects{$config} = 1;
+ }
+ }
+ }
+}
+
+sub loop_select {
+
+ foreach my $config (keys %process_selects) {
+ $config =~ s/^CONFIG_//;
+
+ dprint "Process select $config\n";
+
+ # config has no prompt and must be selected.
+ parse_config_selects $config, $selects{$config};
+ }
+}
+
+while ($repeat) {
+ # Get the first set of configs and their dependencies.
+ loop_depend;
+
+ $repeat = 0;
+
+ # Now we need to see if we have to check selects;
+ loop_select;
+}
+
+my %setconfigs;
+
+# Finally, read the .config file and turn off any module enabled that
+# we could not find a reason to keep enabled.
+foreach my $line (@config_file) {
+ $_ = $line;
+
+ if (/CONFIG_IKCONFIG/) {
+ if (/# CONFIG_IKCONFIG is not set/) {
+ # enable IKCONFIG at least as a module
+ print "CONFIG_IKCONFIG=m\n";
+ # don't ask about PROC
+ print "# CONFIG_IKCONFIG_PROC is not set\n";
+ } else {
+ print;
+ }
+ next;
+ }
+
+ if (/^(CONFIG.*)=(m|y)/) {
+ if (defined($configs{$1})) {
+ if ($localyesconfig) {
+ $setconfigs{$1} = 'y';
+ print "$1=y\n";
+ next;
+ } else {
+ $setconfigs{$1} = $2;
+ }
+ } elsif ($2 eq "m") {
+ print "# $1 is not set\n";
+ next;
+ }
+ }
+ print;
+}
+
+# Integrity check, make sure all modules that we want enabled do
+# indeed have their configs set.
+loop:
+foreach my $module (keys(%modules)) {
+ if (defined($objects{$module})) {
+ my @arr = @{$objects{$module}};
+ foreach my $conf (@arr) {
+ if (defined($setconfigs{$conf})) {
+ next loop;
+ }
+ }
+ print STDERR "module $module did not have configs";
+ foreach my $conf (@arr) {
+ print STDERR " " , $conf;
+ }
+ print STDERR "\n";
+ }
+}
diff --git a/extra/config/symbol.c b/extra/config/symbol.c
index f8cd319f8..d550300ec 100644
--- a/extra/config/symbol.c
+++ b/extra/config/symbol.c
@@ -7,8 +7,8 @@
#include <stdlib.h>
#include <string.h>
#include <regex.h>
+#include <sys/utsname.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
struct symbol symbol_yes = {
@@ -35,30 +35,29 @@ tristate modules_val;
struct expr *sym_env_list;
-void sym_add_default(struct symbol *sym, const char *def)
+static void sym_add_default(struct symbol *sym, const char *def)
{
struct property *prop = prop_alloc(P_DEFAULT, sym);
- prop->expr = expr_alloc_symbol(sym_lookup(def, 1));
+ prop->expr = expr_alloc_symbol(sym_lookup(def, SYMBOL_CONST));
}
void sym_init(void)
{
struct symbol *sym;
- char *p;
+ struct utsname uts;
static bool inited = false;
if (inited)
return;
inited = true;
- p = getenv("VERSION");
- if (p) {
- sym = sym_lookup("VERSION", 0);
- sym->type = S_STRING;
- sym->flags |= SYMBOL_AUTO;
- sym_add_default(sym, p);
- }
+ uname(&uts);
+
+ sym = sym_lookup("UNAME_RELEASE", 0);
+ sym->type = S_STRING;
+ sym->flags |= SYMBOL_AUTO;
+ sym_add_default(sym, uts.release);
}
enum symbol_type sym_get_type(struct symbol *sym)
@@ -125,7 +124,7 @@ struct property *sym_get_default_prop(struct symbol *sym)
return NULL;
}
-struct property *sym_get_range_prop(struct symbol *sym)
+static struct property *sym_get_range_prop(struct symbol *sym)
{
struct property *prop;
@@ -137,7 +136,7 @@ struct property *sym_get_range_prop(struct symbol *sym)
return NULL;
}
-static int sym_get_range_val(struct symbol *sym, int base)
+static long sym_get_range_val(struct symbol *sym, int base)
{
sym_calc_value(sym);
switch (sym->type) {
@@ -156,7 +155,7 @@ static int sym_get_range_val(struct symbol *sym, int base)
static void sym_validate_range(struct symbol *sym)
{
struct property *prop;
- int base, val, val2;
+ long base, val, val2;
char str[64];
switch (sym->type) {
@@ -180,9 +179,9 @@ static void sym_validate_range(struct symbol *sym)
return;
}
if (sym->type == S_INT)
- sprintf(str, "%d", val2);
+ sprintf(str, "%ld", val2);
else
- sprintf(str, "0x%x", val2);
+ sprintf(str, "0x%lx", val2);
sym->curr.val = strdup(str);
}
@@ -205,6 +204,16 @@ static void sym_calc_visibility(struct symbol *sym)
}
if (sym_is_choice_value(sym))
return;
+ /* defaulting to "yes" if no explicit "depends on" are given */
+ tri = yes;
+ if (sym->dir_dep.expr)
+ tri = expr_calc_value(sym->dir_dep.expr);
+ if (tri == mod)
+ tri = yes;
+ if (sym->dir_dep.tri != tri) {
+ sym->dir_dep.tri = tri;
+ sym_set_changed(sym);
+ }
tri = no;
if (sym->rev_dep.expr)
tri = expr_calc_value(sym->rev_dep.expr);
@@ -216,42 +225,68 @@ static void sym_calc_visibility(struct symbol *sym)
}
}
-static struct symbol *sym_calc_choice(struct symbol *sym)
+/*
+ * Find the default symbol for a choice.
+ * First try the default values for the choice symbol
+ * Next locate the first visible choice value
+ * Return NULL if none was found
+ */
+struct symbol *sym_choice_default(struct symbol *sym)
{
struct symbol *def_sym;
struct property *prop;
struct expr *e;
- /* is the user choice visible? */
- def_sym = sym->def[S_DEF_USER].val;
- if (def_sym) {
- sym_calc_visibility(def_sym);
- if (def_sym->visible != no)
- return def_sym;
- }
-
/* any of the defaults visible? */
for_all_defaults(sym, prop) {
prop->visible.tri = expr_calc_value(prop->visible.expr);
if (prop->visible.tri == no)
continue;
def_sym = prop_get_symbol(prop);
- sym_calc_visibility(def_sym);
if (def_sym->visible != no)
return def_sym;
}
/* just get the first visible value */
prop = sym_get_choice_prop(sym);
+ expr_list_for_each_sym(prop->expr, e, def_sym)
+ if (def_sym->visible != no)
+ return def_sym;
+
+ /* failed to locate any defaults */
+ return NULL;
+}
+
+static struct symbol *sym_calc_choice(struct symbol *sym)
+{
+ struct symbol *def_sym;
+ struct property *prop;
+ struct expr *e;
+ int flags;
+
+ /* first calculate all choice values' visibilities */
+ flags = sym->flags;
+ prop = sym_get_choice_prop(sym);
expr_list_for_each_sym(prop->expr, e, def_sym) {
sym_calc_visibility(def_sym);
if (def_sym->visible != no)
- return def_sym;
+ flags &= def_sym->flags;
}
- /* no choice? reset tristate value */
- sym->curr.tri = no;
- return NULL;
+ sym->flags &= flags | ~SYMBOL_DEF_USER;
+
+ /* is the user choice visible? */
+ def_sym = sym->def[S_DEF_USER].val;
+ if (def_sym && def_sym->visible != no)
+ return def_sym;
+
+ def_sym = sym_choice_default(sym);
+
+ if (def_sym == NULL)
+ /* no choice? reset tristate value */
+ sym->curr.tri = no;
+
+ return def_sym;
}
void sym_calc_value(struct symbol *sym)
@@ -265,6 +300,14 @@ void sym_calc_value(struct symbol *sym)
if (sym->flags & SYMBOL_VALID)
return;
+
+ if (sym_is_choice_value(sym) &&
+ sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) {
+ sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES;
+ prop = sym_get_choice_prop(sym);
+ sym_calc_value(prop_get_symbol(prop));
+ }
+
sym->flags |= SYMBOL_VALID;
oldval = sym->curr;
@@ -321,6 +364,18 @@ void sym_calc_value(struct symbol *sym)
}
}
calc_newval:
+ if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
+ struct expr *e;
+ e = expr_simplify_unmet_dep(sym->rev_dep.expr,
+ sym->dir_dep.expr);
+ fprintf(stderr, "warning: (");
+ expr_fprint(e, stderr);
+ fprintf(stderr, ") selects %s which has unmet direct dependencies (",
+ sym->name);
+ expr_fprint(sym->dir_dep.expr, stderr);
+ fprintf(stderr, ")\n");
+ expr_free(e);
+ }
newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
}
if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
@@ -350,9 +405,6 @@ void sym_calc_value(struct symbol *sym)
;
}
- if (sym->flags & SYMBOL_AUTO)
- sym->flags &= ~SYMBOL_WRITE;
-
sym->curr = newval;
if (sym_is_choice(sym) && newval.tri == yes)
sym->curr.val = sym_calc_choice(sym);
@@ -368,15 +420,22 @@ void sym_calc_value(struct symbol *sym)
if (sym_is_choice(sym)) {
struct symbol *choice_sym;
- int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
prop = sym_get_choice_prop(sym);
expr_list_for_each_sym(prop->expr, e, choice_sym) {
- choice_sym->flags |= flags;
- if (flags & SYMBOL_CHANGED)
+ if ((sym->flags & SYMBOL_WRITE) &&
+ choice_sym->visible != no)
+ choice_sym->flags |= SYMBOL_WRITE;
+ if (sym->flags & SYMBOL_CHANGED)
sym_set_changed(choice_sym);
}
}
+
+ if (sym->flags & SYMBOL_AUTO)
+ sym->flags &= ~SYMBOL_WRITE;
+
+ if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
+ set_all_choice_values(sym);
}
void sym_clear_all_valid(void)
@@ -535,7 +594,7 @@ bool sym_string_valid(struct symbol *sym, const char *str)
bool sym_string_within_range(struct symbol *sym, const char *str)
{
struct property *prop;
- int val;
+ long val;
switch (sym->type) {
case S_STRING:
@@ -608,11 +667,11 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
size = strlen(newval) + 1;
if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
size += 2;
- sym->def[S_DEF_USER].val = val = malloc(size);
+ sym->def[S_DEF_USER].val = val = xmalloc(size);
*val++ = '0';
*val++ = 'x';
} else if (!oldval || strcmp(oldval, newval))
- sym->def[S_DEF_USER].val = val = malloc(size);
+ sym->def[S_DEF_USER].val = val = xmalloc(size);
else
return true;
@@ -623,6 +682,80 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
return true;
}
+/*
+ * Find the default value associated to a symbol.
+ * For tristate symbol handle the modules=n case
+ * in which case "m" becomes "y".
+ * If the symbol does not have any default then fallback
+ * to the fixed default values.
+ */
+const char *sym_get_string_default(struct symbol *sym)
+{
+ struct property *prop;
+ struct symbol *ds;
+ const char *str;
+ tristate val;
+
+ sym_calc_visibility(sym);
+ sym_calc_value(modules_sym);
+ val = symbol_no.curr.tri;
+ str = symbol_empty.curr.val;
+
+ /* If symbol has a default value look it up */
+ prop = sym_get_default_prop(sym);
+ if (prop != NULL) {
+ switch (sym->type) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ /* The visibility may limit the value from yes => mod */
+ val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
+ break;
+ default:
+ /*
+ * The following fails to handle the situation
+ * where a default value is further limited by
+ * the valid range.
+ */
+ ds = prop_get_symbol(prop);
+ if (ds != NULL) {
+ sym_calc_value(ds);
+ str = (const char *)ds->curr.val;
+ }
+ }
+ }
+
+ /* Handle select statements */
+ val = EXPR_OR(val, sym->rev_dep.tri);
+
+ /* transpose mod to yes if modules are not enabled */
+ if (val == mod)
+ if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
+ val = yes;
+
+ /* transpose mod to yes if type is bool */
+ if (sym->type == S_BOOLEAN && val == mod)
+ val = yes;
+
+ switch (sym->type) {
+ case S_BOOLEAN:
+ case S_TRISTATE:
+ switch (val) {
+ case no: return "n";
+ case mod: return "m";
+ case yes: return "y";
+ }
+ case S_INT:
+ case S_HEX:
+ return str;
+ case S_STRING:
+ return str;
+ case S_OTHER:
+ case S_UNKNOWN:
+ break;
+ }
+ return "";
+}
+
const char *sym_get_string_value(struct symbol *sym)
{
tristate val;
@@ -635,7 +768,8 @@ const char *sym_get_string_value(struct symbol *sym)
case no:
return "n";
case mod:
- return "m";
+ sym_calc_value(modules_sym);
+ return (modules_sym->curr.tri == no) ? "n" : "m";
case yes:
return "y";
}
@@ -651,12 +785,20 @@ bool sym_is_changable(struct symbol *sym)
return sym->visible > sym->rev_dep.tri;
}
-struct symbol *sym_lookup(const char *name, int isconst)
+static unsigned strhash(const char *s)
+{
+ /* fnv32 hash */
+ unsigned hash = 2166136261U;
+ for (; *s; s++)
+ hash = (hash ^ *s) * 0x01000193;
+ return hash;
+}
+
+struct symbol *sym_lookup(const char *name, int flags)
{
struct symbol *symbol;
- const char *ptr;
char *new_name;
- int hash = 0;
+ int hash;
if (name) {
if (name[0] && !name[1]) {
@@ -666,29 +808,26 @@ struct symbol *sym_lookup(const char *name, int isconst)
case 'n': return &symbol_no;
}
}
- for (ptr = name; *ptr; ptr++)
- hash += *ptr;
- hash &= 0xff;
+ hash = strhash(name) % SYMBOL_HASHSIZE;
for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
- if (!strcmp(symbol->name, name)) {
- if ((isconst && symbol->flags & SYMBOL_CONST) ||
- (!isconst && !(symbol->flags & SYMBOL_CONST)))
- return symbol;
- }
+ if (symbol->name &&
+ !strcmp(symbol->name, name) &&
+ (flags ? symbol->flags & flags
+ : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
+ return symbol;
}
new_name = strdup(name);
} else {
new_name = NULL;
- hash = 256;
+ hash = 0;
}
- symbol = malloc(sizeof(*symbol));
+ symbol = xmalloc(sizeof(*symbol));
memset(symbol, 0, sizeof(*symbol));
symbol->name = new_name;
symbol->type = S_UNKNOWN;
- if (isconst)
- symbol->flags |= SYMBOL_CONST;
+ symbol->flags |= flags;
symbol->next = symbol_hash[hash];
symbol_hash[hash] = symbol;
@@ -699,7 +838,6 @@ struct symbol *sym_lookup(const char *name, int isconst)
struct symbol *sym_find(const char *name)
{
struct symbol *symbol = NULL;
- const char *ptr;
int hash = 0;
if (!name)
@@ -712,12 +850,11 @@ struct symbol *sym_find(const char *name)
case 'n': return &symbol_no;
}
}
- for (ptr = name; *ptr; ptr++)
- hash += *ptr;
- hash &= 0xff;
+ hash = strhash(name) % SYMBOL_HASHSIZE;
for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
- if (!strcmp(symbol->name, name) &&
+ if (symbol->name &&
+ !strcmp(symbol->name, name) &&
!(symbol->flags & SYMBOL_CONST))
break;
}
@@ -725,44 +862,301 @@ struct symbol *sym_find(const char *name)
return symbol;
}
+/*
+ * Expand symbol's names embedded in the string given in argument. Symbols'
+ * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to
+ * the empty string.
+ */
+const char *sym_expand_string_value(const char *in)
+{
+ const char *src;
+ char *res;
+ size_t reslen;
+
+ reslen = strlen(in) + 1;
+ res = xmalloc(reslen);
+ res[0] = '\0';
+
+ while ((src = strchr(in, '$'))) {
+ char *p, name[SYMBOL_MAXLENGTH];
+ const char *symval = "";
+ struct symbol *sym;
+ size_t newlen;
+
+ strncat(res, in, src - in);
+ src++;
+
+ p = name;
+ while (isalnum(*src) || *src == '_')
+ *p++ = *src++;
+ *p = '\0';
+
+ sym = sym_find(name);
+ if (sym != NULL) {
+ sym_calc_value(sym);
+ symval = sym_get_string_value(sym);
+ }
+
+ newlen = strlen(res) + strlen(symval) + strlen(src) + 1;
+ if (newlen > reslen) {
+ reslen = newlen;
+ res = realloc(res, reslen);
+ }
+
+ strcat(res, symval);
+ in = src;
+ }
+ strcat(res, in);
+
+ return res;
+}
+
+const char *sym_escape_string_value(const char *in)
+{
+ const char *p;
+ size_t reslen;
+ char *res;
+ size_t l;
+
+ reslen = strlen(in) + strlen("\"\"") + 1;
+
+ p = in;
+ for (;;) {
+ l = strcspn(p, "\"\\");
+ p += l;
+
+ if (p[0] == '\0')
+ break;
+
+ reslen++;
+ p++;
+ }
+
+ res = xmalloc(reslen);
+ res[0] = '\0';
+
+ strcat(res, "\"");
+
+ p = in;
+ for (;;) {
+ l = strcspn(p, "\"\\");
+ strncat(res, p, l);
+ p += l;
+
+ if (p[0] == '\0')
+ break;
+
+ strcat(res, "\\");
+ strncat(res, p++, 1);
+ }
+
+ strcat(res, "\"");
+ return res;
+}
+
+struct sym_match {
+ struct symbol *sym;
+ off_t so, eo;
+};
+
+/* Compare matched symbols as thus:
+ * - first, symbols that match exactly
+ * - then, alphabetical sort
+ */
+static int sym_rel_comp( const void *sym1, const void *sym2 )
+{
+ struct sym_match *s1 = *(struct sym_match **)sym1;
+ struct sym_match *s2 = *(struct sym_match **)sym2;
+ int l1, l2;
+
+ /* Exact match:
+ * - if matched length on symbol s1 is the length of that symbol,
+ * then this symbol should come first;
+ * - if matched length on symbol s2 is the length of that symbol,
+ * then this symbol should come first.
+ * Note: since the search can be a regexp, both symbols may match
+ * exactly; if this is the case, we can't decide which comes first,
+ * and we fallback to sorting alphabetically.
+ */
+ l1 = s1->eo - s1->so;
+ l2 = s2->eo - s2->so;
+ if (l1 == strlen(s1->sym->name) && l2 != strlen(s2->sym->name))
+ return -1;
+ if (l1 != strlen(s1->sym->name) && l2 == strlen(s2->sym->name))
+ return 1;
+
+ /* As a fallback, sort symbols alphabetically */
+ return strcmp(s1->sym->name, s2->sym->name);
+}
+
struct symbol **sym_re_search(const char *pattern)
{
struct symbol *sym, **sym_arr = NULL;
+ struct sym_match **sym_match_arr = NULL;
int i, cnt, size;
regex_t re;
+ regmatch_t match[1];
cnt = size = 0;
/* Skip if empty */
if (strlen(pattern) == 0)
return NULL;
- if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE))
+ if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
return NULL;
for_all_symbols(i, sym) {
+ struct sym_match *tmp_sym_match;
if (sym->flags & SYMBOL_CONST || !sym->name)
continue;
- if (regexec(&re, sym->name, 0, NULL, 0))
+ if (regexec(&re, sym->name, 1, match, 0))
continue;
if (cnt + 1 >= size) {
- void *tmp = sym_arr;
+ void *tmp;
size += 16;
- sym_arr = realloc(sym_arr, size * sizeof(struct symbol *));
- if (!sym_arr) {
- free(tmp);
- return NULL;
+ tmp = realloc(sym_match_arr, size * sizeof(struct sym_match *));
+ if (!tmp) {
+ goto sym_re_search_free;
}
+ sym_match_arr = tmp;
}
- sym_arr[cnt++] = sym;
+ sym_calc_value(sym);
+ tmp_sym_match = (struct sym_match*)malloc(sizeof(struct sym_match));
+ if (!tmp_sym_match)
+ goto sym_re_search_free;
+ tmp_sym_match->sym = sym;
+ /* As regexec return 0, we know we have a match, so
+ * we can use match[0].rm_[se]o without further checks
+ */
+ tmp_sym_match->so = match[0].rm_so;
+ tmp_sym_match->eo = match[0].rm_eo;
+ sym_match_arr[cnt++] = tmp_sym_match;
}
- if (sym_arr)
+ if (sym_match_arr) {
+ qsort(sym_match_arr, cnt, sizeof(struct sym_match*), sym_rel_comp);
+ sym_arr = malloc((cnt+1) * sizeof(struct symbol));
+ if (!sym_arr)
+ goto sym_re_search_free;
+ for (i = 0; i < cnt; i++)
+ sym_arr[i] = sym_match_arr[i]->sym;
sym_arr[cnt] = NULL;
+ }
+sym_re_search_free:
+ if (sym_match_arr) {
+ for (i = 0; i < cnt; i++)
+ free(sym_match_arr[i]);
+ free(sym_match_arr);
+ }
regfree(&re);
return sym_arr;
}
+/*
+ * When we check for recursive dependencies we use a stack to save
+ * current state so we can print out relevant info to user.
+ * The entries are located on the call stack so no need to free memory.
+ * Note inser() remove() must always match to properly clear the stack.
+ */
+static struct dep_stack {
+ struct dep_stack *prev, *next;
+ struct symbol *sym;
+ struct property *prop;
+ struct expr *expr;
+} *check_top;
-struct symbol *sym_check_deps(struct symbol *sym);
+static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym)
+{
+ memset(stack, 0, sizeof(*stack));
+ if (check_top)
+ check_top->next = stack;
+ stack->prev = check_top;
+ stack->sym = sym;
+ check_top = stack;
+}
+
+static void dep_stack_remove(void)
+{
+ check_top = check_top->prev;
+ if (check_top)
+ check_top->next = NULL;
+}
+
+/*
+ * Called when we have detected a recursive dependency.
+ * check_top point to the top of the stact so we use
+ * the ->prev pointer to locate the bottom of the stack.
+ */
+static void sym_check_print_recursive(struct symbol *last_sym)
+{
+ struct dep_stack *stack;
+ struct symbol *sym, *next_sym;
+ struct menu *menu = NULL;
+ struct property *prop;
+ struct dep_stack cv_stack;
+
+ if (sym_is_choice_value(last_sym)) {
+ dep_stack_insert(&cv_stack, last_sym);
+ last_sym = prop_get_symbol(sym_get_choice_prop(last_sym));
+ }
+
+ for (stack = check_top; stack != NULL; stack = stack->prev)
+ if (stack->sym == last_sym)
+ break;
+ if (!stack) {
+ fprintf(stderr, "unexpected recursive dependency error\n");
+ return;
+ }
+
+ for (; stack; stack = stack->next) {
+ sym = stack->sym;
+ next_sym = stack->next ? stack->next->sym : last_sym;
+ prop = stack->prop;
+ if (prop == NULL)
+ prop = stack->sym->prop;
+
+ /* for choice values find the menu entry (used below) */
+ if (sym_is_choice(sym) || sym_is_choice_value(sym)) {
+ for (prop = sym->prop; prop; prop = prop->next) {
+ menu = prop->menu;
+ if (prop->menu)
+ break;
+ }
+ }
+ if (stack->sym == last_sym)
+ fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
+ prop->file->name, prop->lineno);
+ if (stack->expr) {
+ fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
+ prop->file->name, prop->lineno,
+ sym->name ? sym->name : "<choice>",
+ prop_get_type_name(prop->type),
+ next_sym->name ? next_sym->name : "<choice>");
+ } else if (stack->prop) {
+ fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
+ prop->file->name, prop->lineno,
+ sym->name ? sym->name : "<choice>",
+ next_sym->name ? next_sym->name : "<choice>");
+ } else if (sym_is_choice(sym)) {
+ fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
+ menu->file->name, menu->lineno,
+ sym->name ? sym->name : "<choice>",
+ next_sym->name ? next_sym->name : "<choice>");
+ } else if (sym_is_choice_value(sym)) {
+ fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
+ menu->file->name, menu->lineno,
+ sym->name ? sym->name : "<choice>",
+ next_sym->name ? next_sym->name : "<choice>");
+ } else {
+ fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
+ prop->file->name, prop->lineno,
+ sym->name ? sym->name : "<choice>",
+ next_sym->name ? next_sym->name : "<choice>");
+ }
+ }
+
+ if (check_top == &cv_stack)
+ dep_stack_remove();
+}
static struct symbol *sym_check_expr_deps(struct expr *e)
{
@@ -795,20 +1189,14 @@ static struct symbol *sym_check_expr_deps(struct expr *e)
}
/* return NULL when dependencies are OK */
-struct symbol *sym_check_deps(struct symbol *sym)
+static struct symbol *sym_check_sym_deps(struct symbol *sym)
{
struct symbol *sym2;
struct property *prop;
+ struct dep_stack stack;
- if (sym->flags & SYMBOL_CHECK) {
- fprintf(stderr, "%s:%d:error: found recursive dependency: %s",
- sym->prop->file->name, sym->prop->lineno, sym->name);
- return sym;
- }
- if (sym->flags & SYMBOL_CHECKED)
- return NULL;
+ dep_stack_insert(&stack, sym);
- sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
sym2 = sym_check_expr_deps(sym->rev_dep.expr);
if (sym2)
goto out;
@@ -816,19 +1204,93 @@ struct symbol *sym_check_deps(struct symbol *sym)
for (prop = sym->prop; prop; prop = prop->next) {
if (prop->type == P_CHOICE || prop->type == P_SELECT)
continue;
+ stack.prop = prop;
sym2 = sym_check_expr_deps(prop->visible.expr);
if (sym2)
- goto out;
+ break;
if (prop->type != P_DEFAULT || sym_is_choice(sym))
continue;
+ stack.expr = prop->expr;
sym2 = sym_check_expr_deps(prop->expr);
if (sym2)
- goto out;
+ break;
+ stack.expr = NULL;
}
+
out:
+ dep_stack_remove();
+
+ return sym2;
+}
+
+static struct symbol *sym_check_choice_deps(struct symbol *choice)
+{
+ struct symbol *sym, *sym2;
+ struct property *prop;
+ struct expr *e;
+ struct dep_stack stack;
+
+ dep_stack_insert(&stack, choice);
+
+ prop = sym_get_choice_prop(choice);
+ expr_list_for_each_sym(prop->expr, e, sym)
+ sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
+
+ choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
+ sym2 = sym_check_sym_deps(choice);
+ choice->flags &= ~SYMBOL_CHECK;
if (sym2)
- fprintf(stderr, " -> %s%s", sym->name, sym2 == sym? "\n": "");
- sym->flags &= ~SYMBOL_CHECK;
+ goto out;
+
+ expr_list_for_each_sym(prop->expr, e, sym) {
+ sym2 = sym_check_sym_deps(sym);
+ if (sym2)
+ break;
+ }
+out:
+ expr_list_for_each_sym(prop->expr, e, sym)
+ sym->flags &= ~SYMBOL_CHECK;
+
+ if (sym2 && sym_is_choice_value(sym2) &&
+ prop_get_symbol(sym_get_choice_prop(sym2)) == choice)
+ sym2 = choice;
+
+ dep_stack_remove();
+
+ return sym2;
+}
+
+struct symbol *sym_check_deps(struct symbol *sym)
+{
+ struct symbol *sym2;
+ struct property *prop;
+
+ if (sym->flags & SYMBOL_CHECK) {
+ sym_check_print_recursive(sym);
+ return sym;
+ }
+ if (sym->flags & SYMBOL_CHECKED)
+ return NULL;
+
+ if (sym_is_choice_value(sym)) {
+ struct dep_stack stack;
+
+ /* for choice groups start the check with main choice symbol */
+ dep_stack_insert(&stack, sym);
+ prop = sym_get_choice_prop(sym);
+ sym2 = sym_check_deps(prop_get_symbol(prop));
+ dep_stack_remove();
+ } else if (sym_is_choice(sym)) {
+ sym2 = sym_check_choice_deps(sym);
+ } else {
+ sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
+ sym2 = sym_check_sym_deps(sym);
+ sym->flags &= ~SYMBOL_CHECK;
+ }
+
+ if (sym2 && sym2 == sym)
+ sym2 = NULL;
+
return sym2;
}
@@ -837,7 +1299,7 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym)
struct property *prop;
struct property **propp;
- prop = malloc(sizeof(*prop));
+ prop = xmalloc(sizeof(*prop));
memset(prop, 0, sizeof(*prop));
prop->type = type;
prop->sym = sym;
@@ -881,13 +1343,15 @@ const char *prop_get_type_name(enum prop_type type)
return "select";
case P_RANGE:
return "range";
+ case P_SYMBOL:
+ return "symbol";
case P_UNKNOWN:
break;
}
return "unknown";
}
-void prop_add_env(const char *env)
+static void prop_add_env(const char *env)
{
struct symbol *sym, *sym2;
struct property *prop;
@@ -904,7 +1368,7 @@ void prop_add_env(const char *env)
}
prop = prop_alloc(P_ENV, sym);
- prop->expr = expr_alloc_symbol(sym_lookup(env, 1));
+ prop->expr = expr_alloc_symbol(sym_lookup(env, SYMBOL_CONST));
sym_env_list = expr_alloc_one(E_LIST, sym_env_list);
sym_env_list->right.sym = sym;
diff --git a/extra/config/util.c b/extra/config/util.c
index f8e73c039..f1374e6de 100644
--- a/extra/config/util.c
+++ b/extra/config/util.c
@@ -5,6 +5,8 @@
* Released under the terms of the GNU GPL v2.0.
*/
+#include <stdarg.h>
+#include <stdlib.h>
#include <string.h>
#include "lkc.h"
@@ -12,15 +14,18 @@
struct file *file_lookup(const char *name)
{
struct file *file;
+ const char *file_name = sym_expand_string_value(name);
for (file = file_list; file; file = file->next) {
- if (!strcmp(name, file->name))
+ if (!strcmp(name, file->name)) {
+ free((void *)file_name);
return file;
+ }
}
- file = malloc(sizeof(*file));
+ file = xmalloc(sizeof(*file));
memset(file, 0, sizeof(*file));
- file->name = strdup(name);
+ file->name = file_name;
file->next = file_list;
file_list = file;
return file;
@@ -32,11 +37,15 @@ int file_write_dep(const char *name)
struct symbol *sym, *env_sym;
struct expr *e;
struct file *file;
+ char tmpf[PATH_MAX+1];
FILE *out;
if (!name)
name = ".kconfig.d";
- out = fopen("..config.tmp", "w");
+ strcpy(tmpf, name);
+ dir_name(tmpf);
+ strcat(tmpf, "..config.tmp");
+ out = fopen(tmpf, "w");
if (!out)
return 1;
fprintf(out, "deps_config := \\\n");
@@ -46,8 +55,8 @@ int file_write_dep(const char *name)
else
fprintf(out, "\t%s\n", file->name);
}
- fprintf(out, "\ninclude/config/auto.conf: \\\n"
- "\t$(deps_config)\n\n");
+ fprintf(out, "\n%s: \\\n"
+ "\t$(deps_config)\n\n", conf_get_autoconfig_name());
expr_list_for_each_sym(sym_env_list, e, sym) {
struct property *prop;
@@ -61,23 +70,24 @@ int file_write_dep(const char *name)
if (!value)
value = "";
fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value);
- fprintf(out, "include/config/auto.conf: FORCE\n");
+ fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name());
fprintf(out, "endif\n");
}
fprintf(out, "\n$(deps_config): ;\n");
fclose(out);
- rename("..config.tmp", name);
+ rename(tmpf, name);
return 0;
}
-/* Allocate initial growable sting */
+/* Allocate initial growable string */
struct gstr str_new(void)
{
struct gstr gs;
- gs.s = malloc(sizeof(char) * 64);
- gs.len = 16;
+ gs.s = xmalloc(sizeof(char) * 64);
+ gs.len = 64;
+ gs.max_width = 0;
strcpy(gs.s, "\0");
return gs;
}
@@ -88,6 +98,7 @@ struct gstr str_assign(const char *s)
struct gstr gs;
gs.s = strdup(s);
gs.len = strlen(s) + 1;
+ gs.max_width = 0;
return gs;
}
@@ -131,3 +142,40 @@ const char *str_get(struct gstr *gs)
return gs->s;
}
+void *xmalloc(size_t size)
+{
+ void *p = malloc(size);
+ if (p)
+ return p;
+ fprintf(stderr, "Out of memory.\n");
+ exit(1);
+}
+
+void *xcalloc(size_t nmemb, size_t size)
+{
+ void *p = calloc(nmemb, size);
+ if (p)
+ return p;
+ fprintf(stderr, "Out of memory.\n");
+ exit(1);
+}
+
+/* basename, dirname - parse pathname components */
+char *dir_name(char *path)
+{
+ char *slash = strrchr(path, '/');
+ int size = 0;
+ if (slash)
+ size = slash - path + 1;
+ path[size] = 0;
+ return path;
+}
+char *base_name(char *path)
+{
+ char *slash = strrchr(path, '/');
+ if (slash)
+ path += slash - path + 1;
+ return path;
+
+}
+
diff --git a/extra/config/zconf.gperf b/extra/config/zconf.gperf
index 25ef5d01c..f14ab4115 100644
--- a/extra/config/zconf.gperf
+++ b/extra/config/zconf.gperf
@@ -9,6 +9,8 @@
struct kconf_id;
+static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
+
%%
mainmenu, T_MAINMENU, TF_COMMAND
menu, T_MENU, TF_COMMAND
@@ -36,6 +38,7 @@ hex, T_TYPE, TF_COMMAND, S_HEX
string, T_TYPE, TF_COMMAND, S_STRING
select, T_SELECT, TF_COMMAND
range, T_RANGE, TF_COMMAND
+visible, T_VISIBLE, TF_COMMAND
option, T_OPTION, TF_COMMAND
on, T_ON, TF_PARAM
modules, T_OPT_MODULES, TF_OPTION
diff --git a/extra/config/zconf.hash.c_shipped b/extra/config/zconf.hash.c_shipped
index 5c73d5133..40df0005d 100644
--- a/extra/config/zconf.hash.c_shipped
+++ b/extra/config/zconf.hash.c_shipped
@@ -1,6 +1,5 @@
-/* ANSI-C code produced by gperf version 3.0.3 */
-/* Command-line: gperf */
-/* Computed positions: -k'1,3' */
+/* ANSI-C code produced by gperf version 3.0.4 */
+/* Command-line: gperf -t --output-file scripts/kconfig/zconf.hash.c_shipped -a -C -E -g -k '1,3,$' -p -t scripts/kconfig/zconf.gperf */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
@@ -29,8 +28,11 @@
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
#endif
+#line 10 "scripts/kconfig/zconf.gperf"
struct kconf_id;
-/* maximum key range = 47, duplicates = 0 */
+
+static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
+/* maximum key range = 71, duplicates = 0 */
#ifdef __GNUC__
__inline
@@ -42,34 +44,34 @@ inline
static unsigned int
kconf_id_hash (register const char *str, register unsigned int len)
{
- static unsigned char asso_values[] =
+ static const unsigned char asso_values[] =
{
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 11, 5,
- 0, 0, 5, 49, 5, 20, 49, 49, 5, 20,
- 5, 0, 30, 49, 0, 15, 0, 10, 0, 49,
- 25, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 25, 25,
+ 0, 0, 0, 5, 0, 0, 73, 73, 5, 0,
+ 10, 5, 45, 73, 20, 20, 0, 15, 15, 73,
+ 20, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73
};
register int hval = len;
@@ -83,137 +85,183 @@ kconf_id_hash (register const char *str, register unsigned int len)
hval += asso_values[(unsigned char)str[0]];
break;
}
- return hval;
+ return hval + asso_values[(unsigned char)str[len - 1]];
}
struct kconf_id_strings_t
{
- char kconf_id_strings_str2[sizeof("on")];
- char kconf_id_strings_str3[sizeof("env")];
+ char kconf_id_strings_str2[sizeof("if")];
+ char kconf_id_strings_str3[sizeof("int")];
char kconf_id_strings_str5[sizeof("endif")];
- char kconf_id_strings_str6[sizeof("option")];
- char kconf_id_strings_str7[sizeof("endmenu")];
- char kconf_id_strings_str8[sizeof("optional")];
+ char kconf_id_strings_str7[sizeof("default")];
+ char kconf_id_strings_str8[sizeof("tristate")];
char kconf_id_strings_str9[sizeof("endchoice")];
- char kconf_id_strings_str10[sizeof("range")];
- char kconf_id_strings_str11[sizeof("choice")];
- char kconf_id_strings_str12[sizeof("default")];
+ char kconf_id_strings_str12[sizeof("def_tristate")];
char kconf_id_strings_str13[sizeof("def_bool")];
- char kconf_id_strings_str14[sizeof("help")];
- char kconf_id_strings_str15[sizeof("bool")];
- char kconf_id_strings_str16[sizeof("config")];
- char kconf_id_strings_str17[sizeof("def_tristate")];
- char kconf_id_strings_str18[sizeof("boolean")];
- char kconf_id_strings_str19[sizeof("defconfig_list")];
- char kconf_id_strings_str21[sizeof("string")];
- char kconf_id_strings_str22[sizeof("if")];
- char kconf_id_strings_str23[sizeof("int")];
- char kconf_id_strings_str26[sizeof("select")];
+ char kconf_id_strings_str14[sizeof("defconfig_list")];
+ char kconf_id_strings_str17[sizeof("on")];
+ char kconf_id_strings_str18[sizeof("optional")];
+ char kconf_id_strings_str21[sizeof("option")];
+ char kconf_id_strings_str22[sizeof("endmenu")];
+ char kconf_id_strings_str23[sizeof("mainmenu")];
+ char kconf_id_strings_str25[sizeof("menuconfig")];
char kconf_id_strings_str27[sizeof("modules")];
- char kconf_id_strings_str28[sizeof("tristate")];
char kconf_id_strings_str29[sizeof("menu")];
- char kconf_id_strings_str31[sizeof("source")];
+ char kconf_id_strings_str31[sizeof("select")];
char kconf_id_strings_str32[sizeof("comment")];
- char kconf_id_strings_str33[sizeof("hex")];
- char kconf_id_strings_str35[sizeof("menuconfig")];
- char kconf_id_strings_str36[sizeof("prompt")];
- char kconf_id_strings_str37[sizeof("depends")];
- char kconf_id_strings_str48[sizeof("mainmenu")];
+ char kconf_id_strings_str33[sizeof("env")];
+ char kconf_id_strings_str35[sizeof("range")];
+ char kconf_id_strings_str36[sizeof("choice")];
+ char kconf_id_strings_str39[sizeof("bool")];
+ char kconf_id_strings_str41[sizeof("source")];
+ char kconf_id_strings_str42[sizeof("visible")];
+ char kconf_id_strings_str43[sizeof("hex")];
+ char kconf_id_strings_str46[sizeof("config")];
+ char kconf_id_strings_str47[sizeof("boolean")];
+ char kconf_id_strings_str51[sizeof("string")];
+ char kconf_id_strings_str54[sizeof("help")];
+ char kconf_id_strings_str56[sizeof("prompt")];
+ char kconf_id_strings_str72[sizeof("depends")];
};
-static struct kconf_id_strings_t kconf_id_strings_contents =
+static const struct kconf_id_strings_t kconf_id_strings_contents =
{
- "on",
- "env",
+ "if",
+ "int",
"endif",
+ "default",
+ "tristate",
+ "endchoice",
+ "def_tristate",
+ "def_bool",
+ "defconfig_list",
+ "on",
+ "optional",
"option",
"endmenu",
- "optional",
- "endchoice",
+ "mainmenu",
+ "menuconfig",
+ "modules",
+ "menu",
+ "select",
+ "comment",
+ "env",
"range",
"choice",
- "default",
- "def_bool",
- "help",
"bool",
+ "source",
+ "visible",
+ "hex",
"config",
- "def_tristate",
"boolean",
- "defconfig_list",
"string",
- "if",
- "int",
- "select",
- "modules",
- "tristate",
- "menu",
- "source",
- "comment",
- "hex",
- "menuconfig",
+ "help",
"prompt",
- "depends",
- "mainmenu"
+ "depends"
};
#define kconf_id_strings ((const char *) &kconf_id_strings_contents)
#ifdef __GNUC__
__inline
-#ifdef __GNUC_STDC_INLINE__
+#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
-struct kconf_id *
+const struct kconf_id *
kconf_id_lookup (register const char *str, register unsigned int len)
{
enum
{
- TOTAL_KEYWORDS = 31,
+ TOTAL_KEYWORDS = 32,
MIN_WORD_LENGTH = 2,
MAX_WORD_LENGTH = 14,
MIN_HASH_VALUE = 2,
- MAX_HASH_VALUE = 48
+ MAX_HASH_VALUE = 72
};
- static struct kconf_id wordlist[] =
+ static const struct kconf_id wordlist[] =
{
{-1}, {-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_ON, TF_PARAM},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_OPT_ENV, TF_OPTION},
+#line 25 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_IF, TF_COMMAND|TF_PARAM},
+#line 36 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_TYPE, TF_COMMAND, S_INT},
{-1},
+#line 26 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6, T_OPTION, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_ENDMENU, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_OPTIONAL, TF_COMMAND},
+ {-1},
+#line 29 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
+#line 31 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TYPE, TF_COMMAND, S_TRISTATE},
+#line 20 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_RANGE, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11, T_CHOICE, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
+ {-1}, {-1},
+#line 32 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_TRISTATE},
+#line 35 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str15, T_TYPE, TF_COMMAND, S_BOOLEAN},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_BOOLEAN},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION},
- {-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_TYPE, TF_COMMAND, S_STRING},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT},
+#line 45 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_OPT_DEFCONFIG_LIST,TF_OPTION},
+ {-1}, {-1},
+#line 43 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_ON, TF_PARAM},
+#line 28 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_OPTIONAL, TF_COMMAND},
{-1}, {-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SELECT, TF_COMMAND},
+#line 42 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_OPTION, TF_COMMAND},
+#line 17 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_ENDMENU, TF_COMMAND},
+#line 15 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_MAINMENU, TF_COMMAND},
+ {-1},
+#line 23 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str25, T_MENUCONFIG, TF_COMMAND},
+ {-1},
+#line 44 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE},
+ {-1},
+#line 16 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND},
{-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SOURCE, TF_COMMAND},
+#line 39 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SELECT, TF_COMMAND},
+#line 21 "scripts/kconfig/zconf.gperf"
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_TYPE, TF_COMMAND, S_HEX},
+#line 46 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_OPT_ENV, TF_OPTION},
{-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_PROMPT, TF_COMMAND},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_DEPENDS, TF_COMMAND},
- {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#line 40 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_RANGE, TF_COMMAND},
+#line 19 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_CHOICE, TF_COMMAND},
+ {-1}, {-1},
+#line 33 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str39, T_TYPE, TF_COMMAND, S_BOOLEAN},
+ {-1},
+#line 18 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_SOURCE, TF_COMMAND},
+#line 41 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_VISIBLE, TF_COMMAND},
+#line 37 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str43, T_TYPE, TF_COMMAND, S_HEX},
+ {-1}, {-1},
+#line 22 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_CONFIG, TF_COMMAND},
+#line 34 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN},
+ {-1}, {-1}, {-1},
+#line 38 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_TYPE, TF_COMMAND, S_STRING},
+ {-1}, {-1},
+#line 24 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str54, T_HELP, TF_COMMAND},
{-1},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND}
+#line 30 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str56, T_PROMPT, TF_COMMAND},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+ {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
+#line 27 "scripts/kconfig/zconf.gperf"
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str72, T_DEPENDS, TF_COMMAND}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -234,4 +282,5 @@ kconf_id_lookup (register const char *str, register unsigned int len)
}
return 0;
}
+#line 47 "scripts/kconfig/zconf.gperf"
diff --git a/extra/config/zconf.l b/extra/config/zconf.l
index 4cea5c85c..6555a4754 100644
--- a/extra/config/zconf.l
+++ b/extra/config/zconf.l
@@ -1,5 +1,6 @@
-%option backup nostdinit noyywrap never-interactive full ecs
-%option 8bit backup nodefault perf-report perf-report
+%option nostdinit noyywrap never-interactive full ecs
+%option 8bit nodefault perf-report perf-report
+%option noinput
%x COMMAND HELP STRING PARAM
%{
/*
@@ -13,7 +14,6 @@
#include <string.h>
#include <unistd.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
#define START_STRSIZE 16
@@ -38,15 +38,15 @@ static int last_ts, first_ts;
static void zconf_endhelp(void);
static void zconf_endfile(void);
-void new_string(void)
+static void new_string(void)
{
- text = malloc(START_STRSIZE);
+ text = xmalloc(START_STRSIZE);
text_asize = START_STRSIZE;
text_size = 0;
*text = 0;
}
-void append_string(const char *str, int size)
+static void append_string(const char *str, int size)
{
int new_size = text_size + size + 1;
if (new_size > text_asize) {
@@ -60,9 +60,9 @@ void append_string(const char *str, int size)
text[text_size] = 0;
}
-void alloc_string(const char *str, int size)
+static void alloc_string(const char *str, int size)
{
- text = malloc(size + 1);
+ text = xmalloc(size + 1);
memcpy(text, str, size);
text[size] = 0;
}
@@ -95,7 +95,7 @@ n [A-Za-z0-9_]
<COMMAND>{
{n}+ {
- struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
+ const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
BEGIN(PARAM);
current_pos.file = current_file;
current_pos.lineno = current_file->lineno;
@@ -131,7 +131,7 @@ n [A-Za-z0-9_]
\n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
--- /* ignore */
({n}|[-/.])+ {
- struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
+ const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
if (id && id->flags & TF_PARAM) {
zconflval.id = id;
return id->token;
@@ -288,39 +288,50 @@ void zconf_initscan(const char *name)
exit(1);
}
- current_buf = malloc(sizeof(*current_buf));
+ current_buf = xmalloc(sizeof(*current_buf));
memset(current_buf, 0, sizeof(*current_buf));
current_file = file_lookup(name);
current_file->lineno = 1;
- current_file->flags = FILE_BUSY;
}
void zconf_nextfile(const char *name)
{
+ struct file *iter;
struct file *file = file_lookup(name);
- struct buffer *buf = malloc(sizeof(*buf));
+ struct buffer *buf = xmalloc(sizeof(*buf));
memset(buf, 0, sizeof(*buf));
current_buf->state = YY_CURRENT_BUFFER;
- yyin = zconf_fopen(name);
+ yyin = zconf_fopen(file->name);
if (!yyin) {
- printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
+ printf("%s:%d: can't open file \"%s\"\n",
+ zconf_curname(), zconf_lineno(), file->name);
exit(1);
}
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
buf->parent = current_buf;
current_buf = buf;
- if (file->flags & FILE_BUSY) {
- printf("recursive scan (%s)?\n", name);
- exit(1);
- }
- if (file->flags & FILE_SCANNED) {
- printf("file %s already scanned?\n", name);
- exit(1);
+ for (iter = current_file->parent; iter; iter = iter->parent ) {
+ if (!strcmp(current_file->name,iter->name) ) {
+ printf("%s:%d: recursive inclusion detected. "
+ "Inclusion path:\n current file : '%s'\n",
+ zconf_curname(), zconf_lineno(),
+ zconf_curname());
+ iter = current_file->parent;
+ while (iter && \
+ strcmp(iter->name,current_file->name)) {
+ printf(" included from: '%s:%d'\n",
+ iter->name, iter->lineno-1);
+ iter = iter->parent;
+ }
+ if (iter)
+ printf(" included from: '%s:%d'\n",
+ iter->name, iter->lineno+1);
+ exit(1);
+ }
}
- file->flags |= FILE_BUSY;
file->lineno = 1;
file->parent = current_file;
current_file = file;
@@ -330,8 +341,6 @@ static void zconf_endfile(void)
{
struct buffer *parent;
- current_file->flags |= FILE_SCANNED;
- current_file->flags &= ~FILE_BUSY;
current_file = current_file->parent;
parent = current_buf->parent;
@@ -349,7 +358,7 @@ int zconf_lineno(void)
return current_pos.lineno;
}
-char *zconf_curname(void)
+const char *zconf_curname(void)
{
return current_pos.file ? current_pos.file->name : "<none>";
}
diff --git a/extra/config/lex.zconf.c_shipped b/extra/config/zconf.lex.c_shipped
index 6a1ea6f9e..a0521aa59 100644
--- a/extra/config/lex.zconf.c_shipped
+++ b/extra/config/zconf.lex.c_shipped
@@ -1,5 +1,5 @@
-#line 3 "scripts/kconfig/lex.zconf.c"
+#line 3 "scripts/kconfig/zconf.lex.c_shipped"
#define YY_INT_ALIGNED short int
@@ -27,7 +27,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
+#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -49,10 +49,10 @@
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-#if __STDC_VERSION__ >= 199901L
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
+ * if you want the limit (max/min) macros for int types.
*/
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS 1
@@ -112,11 +112,12 @@ typedef unsigned int flex_uint32_t;
#else /* ! __cplusplus */
-#if __STDC__
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
#define YY_USE_CONST
-#endif /* __STDC__ */
+#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
@@ -196,14 +197,9 @@ extern FILE *zconfin, *zconfout;
#define unput(c) yyunput( c, (yytext_ptr) )
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
+typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -767,6 +763,7 @@ int zconf_flex_debug = 0;
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
char *zconftext;
+#define YY_NO_INPUT 1
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
@@ -779,7 +776,6 @@ char *zconftext;
#include <string.h>
#include <unistd.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
#define START_STRSIZE 16
@@ -804,15 +800,15 @@ static int last_ts, first_ts;
static void zconf_endhelp(void);
static void zconf_endfile(void);
-void new_string(void)
+static void new_string(void)
{
- text = malloc(START_STRSIZE);
+ text = xmalloc(START_STRSIZE);
text_asize = START_STRSIZE;
text_size = 0;
*text = 0;
}
-void append_string(const char *str, int size)
+static void append_string(const char *str, int size)
{
int new_size = text_size + size + 1;
if (new_size > text_asize) {
@@ -826,9 +822,9 @@ void append_string(const char *str, int size)
text[text_size] = 0;
}
-void alloc_string(const char *str, int size)
+static void alloc_string(const char *str, int size)
{
- text = malloc(size + 1);
+ text = xmalloc(size + 1);
memcpy(text, str, size);
text[size] = 0;
}
@@ -853,6 +849,35 @@ void alloc_string(const char *str, int size)
static int yy_init_globals (void );
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int zconflex_destroy (void );
+
+int zconfget_debug (void );
+
+void zconfset_debug (int debug_flag );
+
+YY_EXTRA_TYPE zconfget_extra (void );
+
+void zconfset_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *zconfget_in (void );
+
+void zconfset_in (FILE * in_str );
+
+FILE *zconfget_out (void );
+
+void zconfset_out (FILE * out_str );
+
+int zconfget_leng (void );
+
+char *zconfget_text (void );
+
+int zconfget_lineno (void );
+
+void zconfset_lineno (int line_number );
+
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
@@ -895,7 +920,7 @@ static int input (void );
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO (void) fwrite( zconftext, zconfleng, 1, zconfout )
+#define ECHO do { if (fwrite( zconftext, zconfleng, 1, zconfout )) {} } while (0)
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -1060,7 +1085,7 @@ YY_RULE_SETUP
case 6:
YY_RULE_SETUP
{
- struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
+ const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
BEGIN(PARAM);
current_pos.file = current_file;
current_pos.lineno = current_file->lineno;
@@ -1135,7 +1160,7 @@ YY_RULE_SETUP
case 19:
YY_RULE_SETUP
{
- struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
+ const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng);
if (id && id->flags & TF_PARAM) {
zconflval.id = id;
return id->token;
@@ -1535,7 +1560,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), num_to_read );
+ (yy_n_chars), (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
@@ -1559,6 +1584,14 @@ static int yy_get_next_buffer (void)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) zconfrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
(yy_n_chars) += number_to_move;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
@@ -1945,7 +1978,9 @@ static void zconfensure_buffer_stack (void)
(yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
-
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" );
+
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
@@ -1963,6 +1998,8 @@ static void zconfensure_buffer_stack (void)
((yy_buffer_stack),
num_to_alloc * sizeof(struct yy_buffer_state*)
);
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" );
/* zero only the new slots.*/
memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -2007,7 +2044,7 @@ YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size )
/** Setup the input buffer state to scan a string. The next call to zconflex() will
* scan from a @e copy of @a str.
- * @param str a NUL-terminated string to scan
+ * @param yystr a NUL-terminated string to scan
*
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
@@ -2306,39 +2343,50 @@ void zconf_initscan(const char *name)
exit(1);
}
- current_buf = malloc(sizeof(*current_buf));
+ current_buf = xmalloc(sizeof(*current_buf));
memset(current_buf, 0, sizeof(*current_buf));
current_file = file_lookup(name);
current_file->lineno = 1;
- current_file->flags = FILE_BUSY;
}
void zconf_nextfile(const char *name)
{
+ struct file *iter;
struct file *file = file_lookup(name);
- struct buffer *buf = malloc(sizeof(*buf));
+ struct buffer *buf = xmalloc(sizeof(*buf));
memset(buf, 0, sizeof(*buf));
current_buf->state = YY_CURRENT_BUFFER;
- zconfin = zconf_fopen(name);
+ zconfin = zconf_fopen(file->name);
if (!zconfin) {
- printf("%s:%d: can't open file \"%s\"\n", zconf_curname(), zconf_lineno(), name);
+ printf("%s:%d: can't open file \"%s\"\n",
+ zconf_curname(), zconf_lineno(), file->name);
exit(1);
}
zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE));
buf->parent = current_buf;
current_buf = buf;
- if (file->flags & FILE_BUSY) {
- printf("recursive scan (%s)?\n", name);
- exit(1);
- }
- if (file->flags & FILE_SCANNED) {
- printf("file %s already scanned?\n", name);
- exit(1);
+ for (iter = current_file->parent; iter; iter = iter->parent ) {
+ if (!strcmp(current_file->name,iter->name) ) {
+ printf("%s:%d: recursive inclusion detected. "
+ "Inclusion path:\n current file : '%s'\n",
+ zconf_curname(), zconf_lineno(),
+ zconf_curname());
+ iter = current_file->parent;
+ while (iter && \
+ strcmp(iter->name,current_file->name)) {
+ printf(" included from: '%s:%d'\n",
+ iter->name, iter->lineno-1);
+ iter = iter->parent;
+ }
+ if (iter)
+ printf(" included from: '%s:%d'\n",
+ iter->name, iter->lineno+1);
+ exit(1);
+ }
}
- file->flags |= FILE_BUSY;
file->lineno = 1;
file->parent = current_file;
current_file = file;
@@ -2348,8 +2396,6 @@ static void zconf_endfile(void)
{
struct buffer *parent;
- current_file->flags |= FILE_SCANNED;
- current_file->flags &= ~FILE_BUSY;
current_file = current_file->parent;
parent = current_buf->parent;
@@ -2367,7 +2413,7 @@ int zconf_lineno(void)
return current_pos.lineno;
}
-char *zconf_curname(void)
+const char *zconf_curname(void)
{
return current_pos.file ? current_pos.file->name : "<none>";
}
diff --git a/extra/config/zconf.tab.c_shipped b/extra/config/zconf.tab.c_shipped
index eb4982948..208f20087 100644
--- a/extra/config/zconf.tab.c_shipped
+++ b/extra/config/zconf.tab.c_shipped
@@ -1,24 +1,22 @@
-/* A Bison parser, made by GNU Bison 2.3. */
+/* A Bison parser, made by GNU Bison 2.4.3. */
/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2009, 2010 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +27,7 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
@@ -47,7 +45,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.3"
+#define YYBISON_VERSION "2.4.3"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -55,94 +53,23 @@
/* Pure parsers. */
#define YYPURE 0
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
/* Using locations. */
#define YYLSP_NEEDED 0
/* Substitute the variable and function names. */
-#define yyparse zconfparse
-#define yylex zconflex
-#define yyerror zconferror
-#define yylval zconflval
-#define yychar zconfchar
-#define yydebug zconfdebug
-#define yynerrs zconfnerrs
-
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- T_MAINMENU = 258,
- T_MENU = 259,
- T_ENDMENU = 260,
- T_SOURCE = 261,
- T_CHOICE = 262,
- T_ENDCHOICE = 263,
- T_COMMENT = 264,
- T_CONFIG = 265,
- T_MENUCONFIG = 266,
- T_HELP = 267,
- T_HELPTEXT = 268,
- T_IF = 269,
- T_ENDIF = 270,
- T_DEPENDS = 271,
- T_OPTIONAL = 272,
- T_PROMPT = 273,
- T_TYPE = 274,
- T_DEFAULT = 275,
- T_SELECT = 276,
- T_RANGE = 277,
- T_OPTION = 278,
- T_ON = 279,
- T_WORD = 280,
- T_WORD_QUOTE = 281,
- T_UNEQUAL = 282,
- T_CLOSE_PAREN = 283,
- T_OPEN_PAREN = 284,
- T_EOL = 285,
- T_OR = 286,
- T_AND = 287,
- T_EQUAL = 288,
- T_NOT = 289
- };
-#endif
-/* Tokens. */
-#define T_MAINMENU 258
-#define T_MENU 259
-#define T_ENDMENU 260
-#define T_SOURCE 261
-#define T_CHOICE 262
-#define T_ENDCHOICE 263
-#define T_COMMENT 264
-#define T_CONFIG 265
-#define T_MENUCONFIG 266
-#define T_HELP 267
-#define T_HELPTEXT 268
-#define T_IF 269
-#define T_ENDIF 270
-#define T_DEPENDS 271
-#define T_OPTIONAL 272
-#define T_PROMPT 273
-#define T_TYPE 274
-#define T_DEFAULT 275
-#define T_SELECT 276
-#define T_RANGE 277
-#define T_OPTION 278
-#define T_ON 279
-#define T_WORD 280
-#define T_WORD_QUOTE 281
-#define T_UNEQUAL 282
-#define T_CLOSE_PAREN 283
-#define T_OPEN_PAREN 284
-#define T_EOL 285
-#define T_OR 286
-#define T_AND 287
-#define T_EQUAL 288
-#define T_NOT 289
-
-
+#define yyparse zconfparse
+#define yylex zconflex
+#define yyerror zconferror
+#define yylval zconflval
+#define yychar zconfchar
+#define yydebug zconfdebug
+#define yynerrs zconfnerrs
/* Copy the first part of user declarations. */
@@ -160,11 +87,8 @@
#include <string.h>
#include <stdbool.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
-#include "zconf.hash.c"
-
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
#define PRINTD 0x0001
@@ -176,21 +100,18 @@ extern int zconflex(void);
static void zconfprint(const char *err, ...);
static void zconf_error(const char *err, ...);
static void zconferror(const char *err);
-static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
+static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
-struct symbol *symbol_hash[257];
+struct symbol *symbol_hash[SYMBOL_HASHSIZE];
static struct menu *current_menu, *current_entry;
-#define YYDEBUG 0
-#if YYDEBUG
-#define YYERROR_VERBOSE
-#endif
+
/* Enabling traces. */
#ifndef YYDEBUG
-# define YYDEBUG 0
+# define YYDEBUG 1
#endif
/* Enabling verbose error messages. */
@@ -206,31 +127,78 @@ static struct menu *current_menu, *current_entry;
# define YYTOKEN_TABLE 0
#endif
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ T_MAINMENU = 258,
+ T_MENU = 259,
+ T_ENDMENU = 260,
+ T_SOURCE = 261,
+ T_CHOICE = 262,
+ T_ENDCHOICE = 263,
+ T_COMMENT = 264,
+ T_CONFIG = 265,
+ T_MENUCONFIG = 266,
+ T_HELP = 267,
+ T_HELPTEXT = 268,
+ T_IF = 269,
+ T_ENDIF = 270,
+ T_DEPENDS = 271,
+ T_OPTIONAL = 272,
+ T_PROMPT = 273,
+ T_TYPE = 274,
+ T_DEFAULT = 275,
+ T_SELECT = 276,
+ T_RANGE = 277,
+ T_VISIBLE = 278,
+ T_OPTION = 279,
+ T_ON = 280,
+ T_WORD = 281,
+ T_WORD_QUOTE = 282,
+ T_UNEQUAL = 283,
+ T_CLOSE_PAREN = 284,
+ T_OPEN_PAREN = 285,
+ T_EOL = 286,
+ T_OR = 287,
+ T_AND = 288,
+ T_EQUAL = 289,
+ T_NOT = 290
+ };
+#endif
+
+
+
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-
{
+
+
char *string;
struct file *file;
struct symbol *symbol;
struct expr *expr;
struct menu *menu;
- struct kconf_id *id;
-}
-/* Line 187 of yacc.c. */
+ const struct kconf_id *id;
+
+
- YYSTYPE;
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
#endif
-
/* Copy the second part of user declarations. */
-/* Line 216 of yacc.c. */
+/* Include zconf.hash.c here so it can see the token constants. */
+#include "zconf.hash.c"
+
#ifdef short
@@ -281,7 +249,7 @@ typedef short int yytype_int16;
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
-# if YYENABLE_NLS
+# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
@@ -306,14 +274,14 @@ typedef short int yytype_int16;
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
-YYID (int i)
+YYID (int yyi)
#else
static int
-YYID (i)
- int i;
+YYID (yyi)
+ int yyi;
#endif
{
- return i;
+ return yyi;
}
#endif
@@ -394,9 +362,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
/* A type that is properly aligned for any stack member. */
union yyalloc
{
- yytype_int16 yyss;
- YYSTYPE yyvs;
- };
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
@@ -430,12 +398,12 @@ union yyalloc
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
-# define YYSTACK_RELOCATE(Stack) \
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
@@ -444,22 +412,22 @@ union yyalloc
#endif
/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 3
+#define YYFINAL 11
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 258
+#define YYLAST 290
/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 35
+#define YYNTOKENS 36
/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 45
+#define YYNNTS 50
/* YYNRULES -- Number of rules. */
-#define YYNRULES 108
+#define YYNRULES 118
/* YYNRULES -- Number of states. */
-#define YYNSTATES 178
+#define YYNSTATES 191
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2
-#define YYMAXUTOK 289
+#define YYMAXUTOK 290
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -495,7 +463,8 @@ static const yytype_uint8 yytranslate[] =
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+ 35
};
#if YYDEBUG
@@ -503,70 +472,75 @@ static const yytype_uint8 yytranslate[] =
YYRHS. */
static const yytype_uint16 yyprhs[] =
{
- 0, 0, 3, 5, 6, 9, 12, 15, 20, 23,
- 28, 33, 37, 39, 41, 43, 45, 47, 49, 51,
- 53, 55, 57, 59, 61, 63, 67, 70, 74, 77,
- 81, 84, 85, 88, 91, 94, 97, 100, 103, 107,
- 112, 117, 122, 128, 132, 133, 137, 138, 141, 144,
- 147, 149, 153, 154, 157, 160, 163, 166, 169, 174,
- 178, 181, 186, 187, 190, 194, 196, 200, 201, 204,
- 207, 210, 214, 217, 219, 223, 224, 227, 230, 233,
- 237, 241, 244, 247, 250, 251, 254, 257, 260, 265,
- 266, 269, 271, 273, 276, 279, 282, 284, 287, 288,
- 291, 293, 297, 301, 305, 308, 312, 316, 318
+ 0, 0, 3, 6, 8, 11, 13, 14, 17, 20,
+ 23, 26, 31, 36, 40, 42, 44, 46, 48, 50,
+ 52, 54, 56, 58, 60, 62, 64, 66, 68, 72,
+ 75, 79, 82, 86, 89, 90, 93, 96, 99, 102,
+ 105, 108, 112, 117, 122, 127, 133, 137, 138, 142,
+ 143, 146, 150, 153, 155, 159, 160, 163, 166, 169,
+ 172, 175, 180, 184, 187, 192, 193, 196, 200, 202,
+ 206, 207, 210, 213, 216, 220, 224, 228, 230, 234,
+ 235, 238, 241, 244, 248, 252, 255, 258, 261, 262,
+ 265, 268, 271, 276, 277, 280, 283, 286, 287, 290,
+ 292, 294, 297, 300, 303, 305, 308, 309, 312, 314,
+ 318, 322, 326, 329, 333, 337, 339, 341, 342
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] =
{
- 36, 0, -1, 37, -1, -1, 37, 39, -1, 37,
- 53, -1, 37, 64, -1, 37, 3, 74, 76, -1,
- 37, 75, -1, 37, 25, 1, 30, -1, 37, 38,
- 1, 30, -1, 37, 1, 30, -1, 16, -1, 18,
- -1, 19, -1, 21, -1, 17, -1, 22, -1, 20,
- -1, 30, -1, 59, -1, 68, -1, 42, -1, 44,
- -1, 66, -1, 25, 1, 30, -1, 1, 30, -1,
- 10, 25, 30, -1, 41, 45, -1, 11, 25, 30,
- -1, 43, 45, -1, -1, 45, 46, -1, 45, 47,
- -1, 45, 72, -1, 45, 70, -1, 45, 40, -1,
- 45, 30, -1, 19, 73, 30, -1, 18, 74, 77,
- 30, -1, 20, 78, 77, 30, -1, 21, 25, 77,
- 30, -1, 22, 79, 79, 77, 30, -1, 23, 48,
- 30, -1, -1, 48, 25, 49, -1, -1, 33, 74,
- -1, 7, 30, -1, 50, 54, -1, 75, -1, 51,
- 56, 52, -1, -1, 54, 55, -1, 54, 72, -1,
- 54, 70, -1, 54, 30, -1, 54, 40, -1, 18,
- 74, 77, 30, -1, 19, 73, 30, -1, 17, 30,
- -1, 20, 25, 77, 30, -1, -1, 56, 39, -1,
- 14, 78, 76, -1, 75, -1, 57, 60, 58, -1,
- -1, 60, 39, -1, 60, 64, -1, 60, 53, -1,
- 4, 74, 30, -1, 61, 71, -1, 75, -1, 62,
- 65, 63, -1, -1, 65, 39, -1, 65, 64, -1,
- 65, 53, -1, 6, 74, 30, -1, 9, 74, 30,
- -1, 67, 71, -1, 12, 30, -1, 69, 13, -1,
- -1, 71, 72, -1, 71, 30, -1, 71, 40, -1,
- 16, 24, 78, 30, -1, -1, 74, 77, -1, 25,
- -1, 26, -1, 5, 30, -1, 8, 30, -1, 15,
- 30, -1, 30, -1, 76, 30, -1, -1, 14, 78,
- -1, 79, -1, 79, 33, 79, -1, 79, 27, 79,
- -1, 29, 78, 28, -1, 34, 78, -1, 78, 31,
- 78, -1, 78, 32, 78, -1, 25, -1, 26, -1
+ 37, 0, -1, 81, 38, -1, 38, -1, 63, 39,
+ -1, 39, -1, -1, 39, 41, -1, 39, 55, -1,
+ 39, 67, -1, 39, 80, -1, 39, 26, 1, 31,
+ -1, 39, 40, 1, 31, -1, 39, 1, 31, -1,
+ 16, -1, 18, -1, 19, -1, 21, -1, 17, -1,
+ 22, -1, 20, -1, 23, -1, 31, -1, 61, -1,
+ 71, -1, 44, -1, 46, -1, 69, -1, 26, 1,
+ 31, -1, 1, 31, -1, 10, 26, 31, -1, 43,
+ 47, -1, 11, 26, 31, -1, 45, 47, -1, -1,
+ 47, 48, -1, 47, 49, -1, 47, 75, -1, 47,
+ 73, -1, 47, 42, -1, 47, 31, -1, 19, 78,
+ 31, -1, 18, 79, 82, 31, -1, 20, 83, 82,
+ 31, -1, 21, 26, 82, 31, -1, 22, 84, 84,
+ 82, 31, -1, 24, 50, 31, -1, -1, 50, 26,
+ 51, -1, -1, 34, 79, -1, 7, 85, 31, -1,
+ 52, 56, -1, 80, -1, 53, 58, 54, -1, -1,
+ 56, 57, -1, 56, 75, -1, 56, 73, -1, 56,
+ 31, -1, 56, 42, -1, 18, 79, 82, 31, -1,
+ 19, 78, 31, -1, 17, 31, -1, 20, 26, 82,
+ 31, -1, -1, 58, 41, -1, 14, 83, 81, -1,
+ 80, -1, 59, 62, 60, -1, -1, 62, 41, -1,
+ 62, 67, -1, 62, 55, -1, 3, 79, 81, -1,
+ 4, 79, 31, -1, 64, 76, 74, -1, 80, -1,
+ 65, 68, 66, -1, -1, 68, 41, -1, 68, 67,
+ -1, 68, 55, -1, 6, 79, 31, -1, 9, 79,
+ 31, -1, 70, 74, -1, 12, 31, -1, 72, 13,
+ -1, -1, 74, 75, -1, 74, 31, -1, 74, 42,
+ -1, 16, 25, 83, 31, -1, -1, 76, 77, -1,
+ 76, 31, -1, 23, 82, -1, -1, 79, 82, -1,
+ 26, -1, 27, -1, 5, 31, -1, 8, 31, -1,
+ 15, 31, -1, 31, -1, 81, 31, -1, -1, 14,
+ 83, -1, 84, -1, 84, 34, 84, -1, 84, 28,
+ 84, -1, 30, 83, 29, -1, 35, 83, -1, 83,
+ 32, 83, -1, 83, 33, 83, -1, 26, -1, 27,
+ -1, -1, 26, -1
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 104, 104, 106, 108, 109, 110, 111, 112, 113,
- 114, 118, 122, 122, 122, 122, 122, 122, 122, 126,
- 127, 128, 129, 130, 131, 135, 136, 142, 150, 156,
- 164, 174, 176, 177, 178, 179, 180, 181, 184, 192,
- 198, 208, 214, 220, 223, 225, 236, 237, 242, 251,
- 256, 264, 267, 269, 270, 271, 272, 273, 276, 282,
- 293, 299, 309, 311, 316, 324, 332, 335, 337, 338,
- 339, 344, 351, 356, 364, 367, 369, 370, 371, 374,
- 382, 389, 396, 402, 409, 411, 412, 413, 416, 424,
- 426, 431, 432, 435, 436, 437, 441, 442, 445, 446,
- 449, 450, 451, 452, 453, 454, 455, 458, 459
+ 0, 104, 104, 104, 106, 106, 108, 110, 111, 112,
+ 113, 114, 115, 119, 123, 123, 123, 123, 123, 123,
+ 123, 123, 127, 128, 129, 130, 131, 132, 136, 137,
+ 143, 151, 157, 165, 175, 177, 178, 179, 180, 181,
+ 182, 185, 193, 199, 209, 215, 221, 224, 226, 237,
+ 238, 243, 252, 257, 265, 268, 270, 271, 272, 273,
+ 274, 277, 283, 294, 300, 310, 312, 317, 325, 333,
+ 336, 338, 339, 340, 345, 352, 359, 364, 372, 375,
+ 377, 378, 379, 382, 390, 397, 404, 410, 417, 419,
+ 420, 421, 424, 432, 434, 435, 438, 445, 447, 452,
+ 453, 456, 457, 458, 462, 463, 466, 467, 470, 471,
+ 472, 473, 474, 475, 476, 479, 480, 483, 484
};
#endif
@@ -579,18 +553,19 @@ static const char *const yytname[] =
"T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG",
"T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS",
"T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_RANGE",
- "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL",
+ "T_VISIBLE", "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL",
"T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL",
- "T_NOT", "$accept", "input", "stmt_list", "option_name", "common_stmt",
- "option_error", "config_entry_start", "config_stmt",
+ "T_NOT", "$accept", "input", "start", "stmt_list", "option_name",
+ "common_stmt", "option_error", "config_entry_start", "config_stmt",
"menuconfig_entry_start", "menuconfig_stmt", "config_option_list",
"config_option", "symbol_option", "symbol_option_list",
"symbol_option_arg", "choice", "choice_entry", "choice_end",
"choice_stmt", "choice_option_list", "choice_option", "choice_block",
- "if_entry", "if_end", "if_stmt", "if_block", "menu", "menu_entry",
- "menu_end", "menu_stmt", "menu_block", "source_stmt", "comment",
- "comment_stmt", "help_start", "help", "depends_list", "depends",
- "prompt_stmt_opt", "prompt", "end", "nl", "if_expr", "expr", "symbol", 0
+ "if_entry", "if_end", "if_stmt", "if_block", "mainmenu_stmt", "menu",
+ "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt",
+ "comment", "comment_stmt", "help_start", "help", "depends_list",
+ "depends", "visibility_list", "visible", "prompt_stmt_opt", "prompt",
+ "end", "nl", "if_expr", "expr", "symbol", "word_opt", 0
};
#endif
@@ -602,40 +577,42 @@ static const yytype_uint16 yytoknum[] =
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289
+ 285, 286, 287, 288, 289, 290
};
# endif
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
- 0, 35, 36, 37, 37, 37, 37, 37, 37, 37,
- 37, 37, 38, 38, 38, 38, 38, 38, 38, 39,
- 39, 39, 39, 39, 39, 40, 40, 41, 42, 43,
- 44, 45, 45, 45, 45, 45, 45, 45, 46, 46,
- 46, 46, 46, 47, 48, 48, 49, 49, 50, 51,
- 52, 53, 54, 54, 54, 54, 54, 54, 55, 55,
- 55, 55, 56, 56, 57, 58, 59, 60, 60, 60,
- 60, 61, 62, 63, 64, 65, 65, 65, 65, 66,
- 67, 68, 69, 70, 71, 71, 71, 71, 72, 73,
- 73, 74, 74, 75, 75, 75, 76, 76, 77, 77,
- 78, 78, 78, 78, 78, 78, 78, 79, 79
+ 0, 36, 37, 37, 38, 38, 39, 39, 39, 39,
+ 39, 39, 39, 39, 40, 40, 40, 40, 40, 40,
+ 40, 40, 41, 41, 41, 41, 41, 41, 42, 42,
+ 43, 44, 45, 46, 47, 47, 47, 47, 47, 47,
+ 47, 48, 48, 48, 48, 48, 49, 50, 50, 51,
+ 51, 52, 53, 54, 55, 56, 56, 56, 56, 56,
+ 56, 57, 57, 57, 57, 58, 58, 59, 60, 61,
+ 62, 62, 62, 62, 63, 64, 65, 66, 67, 68,
+ 68, 68, 68, 69, 70, 71, 72, 73, 74, 74,
+ 74, 74, 75, 76, 76, 76, 77, 78, 78, 79,
+ 79, 80, 80, 80, 81, 81, 82, 82, 83, 83,
+ 83, 83, 83, 83, 83, 84, 84, 85, 85
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
- 0, 2, 1, 0, 2, 2, 2, 4, 2, 4,
- 4, 3, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 3, 2, 3, 2, 3,
- 2, 0, 2, 2, 2, 2, 2, 2, 3, 4,
- 4, 4, 5, 3, 0, 3, 0, 2, 2, 2,
- 1, 3, 0, 2, 2, 2, 2, 2, 4, 3,
- 2, 4, 0, 2, 3, 1, 3, 0, 2, 2,
- 2, 3, 2, 1, 3, 0, 2, 2, 2, 3,
- 3, 2, 2, 2, 0, 2, 2, 2, 4, 0,
- 2, 1, 1, 2, 2, 2, 1, 2, 0, 2,
- 1, 3, 3, 3, 2, 3, 3, 1, 1
+ 0, 2, 2, 1, 2, 1, 0, 2, 2, 2,
+ 2, 4, 4, 3, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 3, 2,
+ 3, 2, 3, 2, 0, 2, 2, 2, 2, 2,
+ 2, 3, 4, 4, 4, 5, 3, 0, 3, 0,
+ 2, 3, 2, 1, 3, 0, 2, 2, 2, 2,
+ 2, 4, 3, 2, 4, 0, 2, 3, 1, 3,
+ 0, 2, 2, 2, 3, 3, 3, 1, 3, 0,
+ 2, 2, 2, 3, 3, 2, 2, 2, 0, 2,
+ 2, 2, 4, 0, 2, 2, 2, 0, 2, 1,
+ 1, 2, 2, 2, 1, 2, 0, 2, 1, 3,
+ 3, 3, 2, 3, 3, 1, 1, 0, 1
};
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -643,158 +620,172 @@ static const yytype_uint8 yyr2[] =
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
- 3, 0, 0, 1, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 12, 16, 13, 14,
- 18, 15, 17, 0, 19, 0, 4, 31, 22, 31,
- 23, 52, 62, 5, 67, 20, 84, 75, 6, 24,
- 84, 21, 8, 11, 91, 92, 0, 0, 93, 0,
- 48, 94, 0, 0, 0, 107, 108, 0, 0, 0,
- 100, 95, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 96, 7, 71, 79, 80, 27, 29, 0,
- 104, 0, 0, 64, 0, 0, 9, 10, 0, 0,
- 0, 0, 89, 0, 0, 0, 44, 0, 37, 36,
- 32, 33, 0, 35, 34, 0, 0, 89, 0, 56,
- 57, 53, 55, 54, 63, 51, 50, 68, 70, 66,
- 69, 65, 86, 87, 85, 76, 78, 74, 77, 73,
- 97, 103, 105, 106, 102, 101, 26, 82, 0, 98,
- 0, 98, 98, 98, 0, 0, 0, 83, 60, 98,
- 0, 98, 0, 0, 0, 38, 90, 0, 0, 98,
- 46, 43, 25, 0, 59, 0, 88, 99, 39, 40,
- 41, 0, 0, 45, 58, 61, 42, 47
+ 6, 0, 104, 0, 3, 0, 6, 6, 99, 100,
+ 0, 1, 0, 0, 0, 0, 117, 0, 0, 0,
+ 0, 0, 0, 14, 18, 15, 16, 20, 17, 19,
+ 21, 0, 22, 0, 7, 34, 25, 34, 26, 55,
+ 65, 8, 70, 23, 93, 79, 9, 27, 88, 24,
+ 10, 0, 105, 2, 74, 13, 0, 101, 0, 118,
+ 0, 102, 0, 0, 0, 115, 116, 0, 0, 0,
+ 108, 103, 0, 0, 0, 0, 0, 0, 0, 88,
+ 0, 0, 75, 83, 51, 84, 30, 32, 0, 112,
+ 0, 0, 67, 0, 0, 11, 12, 0, 0, 0,
+ 0, 97, 0, 0, 0, 47, 0, 40, 39, 35,
+ 36, 0, 38, 37, 0, 0, 97, 0, 59, 60,
+ 56, 58, 57, 66, 54, 53, 71, 73, 69, 72,
+ 68, 106, 95, 0, 94, 80, 82, 78, 81, 77,
+ 90, 91, 89, 111, 113, 114, 110, 109, 29, 86,
+ 0, 106, 0, 106, 106, 106, 0, 0, 0, 87,
+ 63, 106, 0, 106, 0, 96, 0, 0, 41, 98,
+ 0, 0, 106, 49, 46, 28, 0, 62, 0, 107,
+ 92, 42, 43, 44, 0, 0, 48, 61, 64, 45,
+ 50
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int16 yydefgoto[] =
{
- -1, 1, 2, 25, 26, 99, 27, 28, 29, 30,
- 64, 100, 101, 145, 173, 31, 32, 115, 33, 66,
- 111, 67, 34, 119, 35, 68, 36, 37, 127, 38,
- 70, 39, 40, 41, 102, 103, 69, 104, 140, 141,
- 42, 73, 154, 59, 60
+ -1, 3, 4, 5, 33, 34, 108, 35, 36, 37,
+ 38, 74, 109, 110, 157, 186, 39, 40, 124, 41,
+ 76, 120, 77, 42, 128, 43, 78, 6, 44, 45,
+ 137, 46, 80, 47, 48, 49, 111, 112, 81, 113,
+ 79, 134, 152, 153, 50, 7, 165, 69, 70, 60
};
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
-#define YYPACT_NINF -78
+#define YYPACT_NINF -90
static const yytype_int16 yypact[] =
{
- -78, 33, 130, -78, -28, 73, 73, 7, 73, 36,
- 41, 73, 26, 52, -4, 58, -78, -78, -78, -78,
- -78, -78, -78, 90, -78, 94, -78, -78, -78, -78,
- -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
- -78, -78, -78, -78, -78, -78, 74, 85, -78, 96,
- -78, -78, 131, 134, 147, -78, -78, -4, -4, 193,
- -10, -78, 162, 164, 38, 102, 64, 148, 5, 192,
- 5, 165, -78, 174, -78, -78, -78, -78, -78, 65,
- -78, -4, -4, 174, 103, 103, -78, -78, 175, 185,
- 197, 73, 73, -4, 194, 103, -78, 231, -78, -78,
- -78, -78, 220, -78, -78, 204, 73, 73, 210, -78,
- -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
- -78, -78, -78, -78, -78, -78, -78, -78, -78, -78,
- -78, -78, 205, -78, -78, -78, -78, -78, -4, 222,
- 208, 222, 195, 222, 103, 2, 209, -78, -78, 222,
- 211, 222, 199, -4, 212, -78, -78, 213, 214, 222,
- 207, -78, -78, 215, -78, 216, -78, 111, -78, -78,
- -78, 217, 73, -78, -78, -78, -78, -78
+ 4, 42, -90, 96, -90, 111, -90, 15, -90, -90,
+ 75, -90, 82, 42, 104, 42, 110, 107, 42, 115,
+ 125, -4, 121, -90, -90, -90, -90, -90, -90, -90,
+ -90, 162, -90, 163, -90, -90, -90, -90, -90, -90,
+ -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
+ -90, 139, -90, -90, 138, -90, 142, -90, 143, -90,
+ 152, -90, 164, 167, 168, -90, -90, -4, -4, 77,
+ -18, -90, 177, 185, 33, 71, 195, 247, 236, -2,
+ 236, 171, -90, -90, -90, -90, -90, -90, 41, -90,
+ -4, -4, 138, 97, 97, -90, -90, 186, 187, 194,
+ 42, 42, -4, 196, 97, -90, 219, -90, -90, -90,
+ -90, 210, -90, -90, 204, 42, 42, 199, -90, -90,
+ -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
+ -90, 222, -90, 223, -90, -90, -90, -90, -90, -90,
+ -90, -90, -90, -90, 215, -90, -90, -90, -90, -90,
+ -4, 222, 228, 222, -5, 222, 97, 35, 229, -90,
+ -90, 222, 232, 222, -4, -90, 135, 233, -90, -90,
+ 234, 235, 222, 240, -90, -90, 237, -90, 239, -13,
+ -90, -90, -90, -90, 244, 42, -90, -90, -90, -90,
+ -90
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int16 yypgoto[] =
{
- -78, -78, -78, -78, 121, -35, -78, -78, -78, -78,
- 219, -78, -78, -78, -78, -78, -78, -78, -44, -78,
- -78, -78, -78, -78, -78, -78, -78, -78, -78, -6,
- -78, -78, -78, -78, -78, 183, 218, 21, 143, -5,
- 146, 196, 69, -53, -77
+ -90, -90, 269, 271, -90, 23, -70, -90, -90, -90,
+ -90, 243, -90, -90, -90, -90, -90, -90, -90, -48,
+ -90, -90, -90, -90, -90, -90, -90, -90, -90, -90,
+ -90, -20, -90, -90, -90, -90, -90, 206, 205, -68,
+ -90, -90, 169, -1, 27, -7, 118, -66, -89, -90
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If zero, do what YYDEFACT says.
If YYTABLE_NINF, syntax error. */
-#define YYTABLE_NINF -82
+#define YYTABLE_NINF -86
static const yytype_int16 yytable[] =
{
- 46, 47, 43, 49, 79, 80, 52, 134, 135, 6,
- 7, 8, 9, 10, 11, 12, 13, 84, 144, 14,
- 15, 55, 56, 85, 118, 57, 126, 160, 132, 133,
- 58, 110, 161, 3, 123, 24, 123, 48, -28, 88,
- 142, -28, -28, -28, -28, -28, -28, -28, -28, -28,
- 89, 53, -28, -28, 90, -28, 91, 92, 93, 94,
- 95, 96, 120, 97, 128, 88, 50, 159, 98, -49,
- -49, 51, -49, -49, -49, -49, 89, 54, -49, -49,
- 90, 105, 106, 107, 108, 152, 139, 113, 61, 97,
- 124, 62, 124, 131, 109, 63, 81, 82, 44, 45,
- 167, 149, -30, 88, 72, -30, -30, -30, -30, -30,
- -30, -30, -30, -30, 89, 74, -30, -30, 90, -30,
- 91, 92, 93, 94, 95, 96, 75, 97, 55, 56,
- -2, 4, 98, 5, 6, 7, 8, 9, 10, 11,
- 12, 13, 81, 82, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 7, 8, 23, 10, 11, 12, 13,
- 24, 76, 14, 15, 77, -81, 88, 177, -81, -81,
- -81, -81, -81, -81, -81, -81, -81, 78, 24, -81,
- -81, 90, -81, -81, -81, -81, -81, -81, 114, 117,
- 97, 125, 86, 88, 87, 122, -72, -72, -72, -72,
- -72, -72, -72, -72, 130, 136, -72, -72, 90, 153,
- 156, 157, 158, 116, 121, 137, 129, 97, 163, 143,
- 165, 138, 122, 72, 81, 82, 81, 82, 171, 166,
- 81, 82, 146, 147, 148, 151, 153, 82, 155, 162,
- 172, 164, 168, 169, 170, 174, 175, 176, 65, 112,
- 150, 0, 0, 0, 0, 83, 0, 0, 71
+ 10, 88, 89, 54, 146, 147, 119, 1, 122, 164,
+ 93, 141, 56, 142, 58, 156, 94, 62, 1, 90,
+ 91, 131, 65, 66, 144, 145, 67, 90, 91, 132,
+ 127, 68, 136, -31, 97, 2, 154, -31, -31, -31,
+ -31, -31, -31, -31, -31, 98, 52, -31, -31, 99,
+ -31, 100, 101, 102, 103, 104, -31, 105, 129, 106,
+ 138, 173, 92, 141, 107, 142, 174, 172, 8, 9,
+ 143, -33, 97, 90, 91, -33, -33, -33, -33, -33,
+ -33, -33, -33, 98, 166, -33, -33, 99, -33, 100,
+ 101, 102, 103, 104, -33, 105, 11, 106, 179, 151,
+ 123, 126, 107, 135, 125, 130, 2, 139, 2, 90,
+ 91, -5, 12, 55, 161, 13, 14, 15, 16, 17,
+ 18, 19, 20, 65, 66, 21, 22, 23, 24, 25,
+ 26, 27, 28, 29, 30, 57, 59, 31, 61, -4,
+ 12, 63, 32, 13, 14, 15, 16, 17, 18, 19,
+ 20, 64, 71, 21, 22, 23, 24, 25, 26, 27,
+ 28, 29, 30, 72, 73, 31, 180, 90, 91, 52,
+ 32, -85, 97, 82, 83, -85, -85, -85, -85, -85,
+ -85, -85, -85, 84, 190, -85, -85, 99, -85, -85,
+ -85, -85, -85, -85, -85, 85, 97, 106, 86, 87,
+ -52, -52, 140, -52, -52, -52, -52, 98, 95, -52,
+ -52, 99, 114, 115, 116, 117, 96, 148, 149, 150,
+ 158, 106, 155, 159, 97, 163, 118, -76, -76, -76,
+ -76, -76, -76, -76, -76, 160, 164, -76, -76, 99,
+ 13, 14, 15, 16, 17, 18, 19, 20, 91, 106,
+ 21, 22, 14, 15, 140, 17, 18, 19, 20, 168,
+ 175, 21, 22, 177, 181, 182, 183, 32, 187, 167,
+ 188, 169, 170, 171, 185, 189, 53, 51, 32, 176,
+ 75, 178, 121, 0, 133, 162, 0, 0, 0, 0,
+ 184
};
static const yytype_int16 yycheck[] =
{
- 5, 6, 30, 8, 57, 58, 11, 84, 85, 4,
- 5, 6, 7, 8, 9, 10, 11, 27, 95, 14,
- 15, 25, 26, 33, 68, 29, 70, 25, 81, 82,
- 34, 66, 30, 0, 69, 30, 71, 30, 0, 1,
- 93, 3, 4, 5, 6, 7, 8, 9, 10, 11,
- 12, 25, 14, 15, 16, 17, 18, 19, 20, 21,
- 22, 23, 68, 25, 70, 1, 30, 144, 30, 5,
- 6, 30, 8, 9, 10, 11, 12, 25, 14, 15,
- 16, 17, 18, 19, 20, 138, 91, 66, 30, 25,
- 69, 1, 71, 28, 30, 1, 31, 32, 25, 26,
- 153, 106, 0, 1, 30, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 30, 14, 15, 16, 17,
- 18, 19, 20, 21, 22, 23, 30, 25, 25, 26,
- 0, 1, 30, 3, 4, 5, 6, 7, 8, 9,
- 10, 11, 31, 32, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 5, 6, 25, 8, 9, 10, 11,
- 30, 30, 14, 15, 30, 0, 1, 172, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 30, 30, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 67, 68,
- 25, 70, 30, 1, 30, 30, 4, 5, 6, 7,
- 8, 9, 10, 11, 30, 30, 14, 15, 16, 14,
- 141, 142, 143, 67, 68, 30, 70, 25, 149, 25,
- 151, 24, 30, 30, 31, 32, 31, 32, 159, 30,
- 31, 32, 1, 13, 30, 25, 14, 32, 30, 30,
- 33, 30, 30, 30, 30, 30, 30, 30, 29, 66,
- 107, -1, -1, -1, -1, 59, -1, -1, 40
+ 1, 67, 68, 10, 93, 94, 76, 3, 76, 14,
+ 28, 81, 13, 81, 15, 104, 34, 18, 3, 32,
+ 33, 23, 26, 27, 90, 91, 30, 32, 33, 31,
+ 78, 35, 80, 0, 1, 31, 102, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 31, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 78, 26,
+ 80, 26, 69, 133, 31, 133, 31, 156, 26, 27,
+ 29, 0, 1, 32, 33, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 150, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 23, 24, 0, 26, 164, 100,
+ 77, 78, 31, 80, 77, 78, 31, 80, 31, 32,
+ 33, 0, 1, 31, 115, 4, 5, 6, 7, 8,
+ 9, 10, 11, 26, 27, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 23, 31, 26, 26, 31, 0,
+ 1, 26, 31, 4, 5, 6, 7, 8, 9, 10,
+ 11, 26, 31, 14, 15, 16, 17, 18, 19, 20,
+ 21, 22, 23, 1, 1, 26, 31, 32, 33, 31,
+ 31, 0, 1, 31, 31, 4, 5, 6, 7, 8,
+ 9, 10, 11, 31, 185, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 23, 31, 1, 26, 31, 31,
+ 5, 6, 31, 8, 9, 10, 11, 12, 31, 14,
+ 15, 16, 17, 18, 19, 20, 31, 31, 31, 25,
+ 1, 26, 26, 13, 1, 26, 31, 4, 5, 6,
+ 7, 8, 9, 10, 11, 31, 14, 14, 15, 16,
+ 4, 5, 6, 7, 8, 9, 10, 11, 33, 26,
+ 14, 15, 5, 6, 31, 8, 9, 10, 11, 31,
+ 31, 14, 15, 31, 31, 31, 31, 31, 31, 151,
+ 31, 153, 154, 155, 34, 31, 7, 6, 31, 161,
+ 37, 163, 76, -1, 79, 116, -1, -1, -1, -1,
+ 172
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
- 0, 36, 37, 0, 1, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 25, 30, 38, 39, 41, 42, 43,
- 44, 50, 51, 53, 57, 59, 61, 62, 64, 66,
- 67, 68, 75, 30, 25, 26, 74, 74, 30, 74,
- 30, 30, 74, 25, 25, 25, 26, 29, 34, 78,
- 79, 30, 1, 1, 45, 45, 54, 56, 60, 71,
- 65, 71, 30, 76, 30, 30, 30, 30, 30, 78,
- 78, 31, 32, 76, 27, 33, 30, 30, 1, 12,
- 16, 18, 19, 20, 21, 22, 23, 25, 30, 40,
- 46, 47, 69, 70, 72, 17, 18, 19, 20, 30,
- 40, 55, 70, 72, 39, 52, 75, 39, 53, 58,
- 64, 75, 30, 40, 72, 39, 53, 63, 64, 75,
- 30, 28, 78, 78, 79, 79, 30, 30, 24, 74,
- 73, 74, 78, 25, 79, 48, 1, 13, 30, 74,
- 73, 25, 78, 14, 77, 30, 77, 77, 77, 79,
- 25, 30, 30, 77, 30, 77, 30, 78, 30, 30,
- 30, 77, 33, 49, 30, 30, 30, 74
+ 0, 3, 31, 37, 38, 39, 63, 81, 26, 27,
+ 79, 0, 1, 4, 5, 6, 7, 8, 9, 10,
+ 11, 14, 15, 16, 17, 18, 19, 20, 21, 22,
+ 23, 26, 31, 40, 41, 43, 44, 45, 46, 52,
+ 53, 55, 59, 61, 64, 65, 67, 69, 70, 71,
+ 80, 39, 31, 38, 81, 31, 79, 31, 79, 26,
+ 85, 31, 79, 26, 26, 26, 27, 30, 35, 83,
+ 84, 31, 1, 1, 47, 47, 56, 58, 62, 76,
+ 68, 74, 31, 31, 31, 31, 31, 31, 83, 83,
+ 32, 33, 81, 28, 34, 31, 31, 1, 12, 16,
+ 18, 19, 20, 21, 22, 24, 26, 31, 42, 48,
+ 49, 72, 73, 75, 17, 18, 19, 20, 31, 42,
+ 57, 73, 75, 41, 54, 80, 41, 55, 60, 67,
+ 80, 23, 31, 74, 77, 41, 55, 66, 67, 80,
+ 31, 42, 75, 29, 83, 83, 84, 84, 31, 31,
+ 25, 79, 78, 79, 83, 26, 84, 50, 1, 13,
+ 31, 79, 78, 26, 14, 82, 83, 82, 31, 82,
+ 82, 82, 84, 26, 31, 31, 82, 31, 82, 83,
+ 31, 31, 31, 31, 82, 34, 51, 31, 31, 31,
+ 79
};
#define yyerrok (yyerrstatus = 0)
@@ -809,9 +800,18 @@ static const yytype_uint8 yystos[] =
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
+ Once GCC version 2 has supplanted version 1, this can go. However,
+ YYFAIL appears to be in use. Nevertheless, it is formally deprecated
+ in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+ discussed. */
#define YYFAIL goto yyerrlab
+#if defined YYFAIL
+ /* This is here to suppress warnings from the GCC cpp's
+ -Wunused-macros. Normally we don't worry about that warning, but
+ some users do, and we want to make it easy for users to remove
+ YYFAIL uses, which will produce warnings from Bison 2.5. */
+#endif
#define YYRECOVERING() (!!yyerrstatus)
@@ -868,7 +868,7 @@ while (YYID (0))
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
-# if YYLTYPE_IS_TRIVIAL
+# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
@@ -979,17 +979,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep)
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
-yy_stack_print (bottom, top)
- yytype_int16 *bottom;
- yytype_int16 *top;
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
#endif
{
YYFPRINTF (stderr, "Stack now");
- for (; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
YYFPRINTF (stderr, "\n");
}
@@ -1023,11 +1026,11 @@ yy_reduce_print (yyvsp, yyrule)
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
- fprintf (stderr, " $%d = ", yyi + 1);
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
);
- fprintf (stderr, "\n");
+ YYFPRINTF (stderr, "\n");
}
}
@@ -1275,6 +1278,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
}
}
#endif /* YYERROR_VERBOSE */
+
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
@@ -1301,7 +1305,7 @@ yydestruct (yymsg, yytype, yyvaluep)
switch (yytype)
{
- case 51: /* "choice_entry" */
+ case 53: /* "choice_entry" */
{
fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1311,7 +1315,7 @@ yydestruct (yymsg, yytype, yyvaluep)
};
break;
- case 57: /* "if_entry" */
+ case 59: /* "if_entry" */
{
fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1321,7 +1325,7 @@ yydestruct (yymsg, yytype, yyvaluep)
};
break;
- case 62: /* "menu_entry" */
+ case 65: /* "menu_entry" */
{
fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -1336,10 +1340,8 @@ yydestruct (yymsg, yytype, yyvaluep)
break;
}
}
-
/* Prevent warnings from -Wmissing-prototypes. */
-
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
@@ -1355,11 +1357,10 @@ int yyparse ();
#endif /* ! YYPARSE_PARAM */
-
-/* The look-ahead symbol. */
+/* The lookahead symbol. */
int yychar;
-/* The semantic value of the look-ahead symbol. */
+/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
/* Number of syntax errors so far. */
@@ -1367,9 +1368,9 @@ int yynerrs;
-/*----------.
-| yyparse. |
-`----------*/
+/*-------------------------.
+| yyparse or yypush_parse. |
+`-------------------------*/
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1393,66 +1394,68 @@ yyparse ()
#endif
#endif
{
-
- int yystate;
- int yyn;
- int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Look-ahead token as an internal (translated) token number. */
- int yytoken = 0;
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss = yyssa;
- yytype_int16 *yyssp;
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp;
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
- YYSIZE_T yystacksize = YYINITDEPTH;
+ YYSIZE_T yystacksize;
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
+ yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
-
yyssp = yyss;
yyvsp = yyvs;
@@ -1482,7 +1485,6 @@ yyparse ()
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
-
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
@@ -1490,7 +1492,6 @@ yyparse ()
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
-
&yystacksize);
yyss = yyss1;
@@ -1513,9 +1514,8 @@ yyparse ()
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
-
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
@@ -1526,7 +1526,6 @@ yyparse ()
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
-
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
@@ -1536,6 +1535,9 @@ yyparse ()
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
goto yybackup;
/*-----------.
@@ -1544,16 +1546,16 @@ yyparse ()
yybackup:
/* Do appropriate processing given the current state. Read a
- look-ahead token if we need one and don't already have one. */
+ lookahead token if we need one and don't already have one. */
- /* First try to decide what to do without reference to look-ahead token. */
+ /* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
goto yydefault;
- /* Not known => get a look-ahead token if don't already have one. */
+ /* Not known => get a lookahead token if don't already have one. */
- /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
@@ -1585,20 +1587,16 @@ yybackup:
goto yyreduce;
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
- /* Shift the look-ahead token. */
+ /* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
- /* Discard the shifted token unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
yystate = yyn;
*++yyvsp = yylval;
@@ -1637,39 +1635,39 @@ yyreduce:
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
- case 8:
+ case 10:
{ zconf_error("unexpected end statement"); ;}
break;
- case 9:
+ case 11:
{ zconf_error("unknown statement \"%s\"", (yyvsp[(2) - (4)].string)); ;}
break;
- case 10:
+ case 12:
{
zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[(2) - (4)].id)->name);
;}
break;
- case 11:
+ case 13:
{ zconf_error("invalid statement"); ;}
break;
- case 25:
+ case 28:
{ zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); ;}
break;
- case 26:
+ case 29:
{ zconf_error("invalid option"); ;}
break;
- case 27:
+ case 30:
{
struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0);
@@ -1679,7 +1677,7 @@ yyreduce:
;}
break;
- case 28:
+ case 31:
{
menu_end_entry();
@@ -1687,7 +1685,7 @@ yyreduce:
;}
break;
- case 29:
+ case 32:
{
struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0);
@@ -1697,7 +1695,7 @@ yyreduce:
;}
break;
- case 30:
+ case 33:
{
if (current_entry->prompt)
@@ -1709,7 +1707,7 @@ yyreduce:
;}
break;
- case 38:
+ case 41:
{
menu_set_type((yyvsp[(1) - (3)].id)->stype);
@@ -1719,7 +1717,7 @@ yyreduce:
;}
break;
- case 39:
+ case 42:
{
menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
@@ -1727,7 +1725,7 @@ yyreduce:
;}
break;
- case 40:
+ case 43:
{
menu_add_expr(P_DEFAULT, (yyvsp[(2) - (4)].expr), (yyvsp[(3) - (4)].expr));
@@ -1739,7 +1737,7 @@ yyreduce:
;}
break;
- case 41:
+ case 44:
{
menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr));
@@ -1747,7 +1745,7 @@ yyreduce:
;}
break;
- case 42:
+ case 45:
{
menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr));
@@ -1755,10 +1753,10 @@ yyreduce:
;}
break;
- case 45:
+ case 48:
{
- struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string)));
+ const struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string)));
if (id && id->flags & TF_OPTION)
menu_add_option(id->token, (yyvsp[(3) - (3)].string));
else
@@ -1767,35 +1765,35 @@ yyreduce:
;}
break;
- case 46:
+ case 49:
{ (yyval.string) = NULL; ;}
break;
- case 47:
+ case 50:
{ (yyval.string) = (yyvsp[(2) - (2)].string); ;}
break;
- case 48:
+ case 51:
{
- struct symbol *sym = sym_lookup(NULL, 0);
- sym->flags |= SYMBOL_CHOICE;
+ struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), SYMBOL_CHOICE);
+ sym->flags |= SYMBOL_AUTO;
menu_add_entry(sym);
menu_add_expr(P_CHOICE, NULL, NULL);
printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
;}
break;
- case 49:
+ case 52:
{
(yyval.menu) = menu_add_menu();
;}
break;
- case 50:
+ case 53:
{
if (zconf_endtoken((yyvsp[(1) - (1)].id), T_CHOICE, T_ENDCHOICE)) {
@@ -1805,7 +1803,7 @@ yyreduce:
;}
break;
- case 58:
+ case 61:
{
menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
@@ -1813,7 +1811,7 @@ yyreduce:
;}
break;
- case 59:
+ case 62:
{
if ((yyvsp[(1) - (3)].id)->stype == S_BOOLEAN || (yyvsp[(1) - (3)].id)->stype == S_TRISTATE) {
@@ -1826,7 +1824,7 @@ yyreduce:
;}
break;
- case 60:
+ case 63:
{
current_entry->sym->flags |= SYMBOL_OPTIONAL;
@@ -1834,7 +1832,7 @@ yyreduce:
;}
break;
- case 61:
+ case 64:
{
if ((yyvsp[(1) - (4)].id)->stype == S_UNKNOWN) {
@@ -1846,7 +1844,7 @@ yyreduce:
;}
break;
- case 64:
+ case 67:
{
printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
@@ -1856,7 +1854,7 @@ yyreduce:
;}
break;
- case 65:
+ case 68:
{
if (zconf_endtoken((yyvsp[(1) - (1)].id), T_IF, T_ENDIF)) {
@@ -1866,7 +1864,14 @@ yyreduce:
;}
break;
- case 71:
+ case 74:
+
+ {
+ menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL);
+;}
+ break;
+
+ case 75:
{
menu_add_entry(NULL);
@@ -1875,14 +1880,14 @@ yyreduce:
;}
break;
- case 72:
+ case 76:
{
(yyval.menu) = menu_add_menu();
;}
break;
- case 73:
+ case 77:
{
if (zconf_endtoken((yyvsp[(1) - (1)].id), T_MENU, T_ENDMENU)) {
@@ -1892,7 +1897,7 @@ yyreduce:
;}
break;
- case 79:
+ case 83:
{
printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string));
@@ -1900,7 +1905,7 @@ yyreduce:
;}
break;
- case 80:
+ case 84:
{
menu_add_entry(NULL);
@@ -1909,14 +1914,14 @@ yyreduce:
;}
break;
- case 81:
+ case 85:
{
menu_end_entry();
;}
break;
- case 82:
+ case 86:
{
printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
@@ -1924,14 +1929,14 @@ yyreduce:
;}
break;
- case 83:
+ case 87:
{
current_entry->help = (yyvsp[(2) - (2)].string);
;}
break;
- case 88:
+ case 92:
{
menu_add_dep((yyvsp[(3) - (4)].expr));
@@ -1939,85 +1944,96 @@ yyreduce:
;}
break;
- case 90:
+ case 96:
+
+ {
+ menu_add_visibility((yyvsp[(2) - (2)].expr));
+;}
+ break;
+
+ case 98:
{
menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr));
;}
break;
- case 93:
+ case 101:
{ (yyval.id) = (yyvsp[(1) - (2)].id); ;}
break;
- case 94:
+ case 102:
{ (yyval.id) = (yyvsp[(1) - (2)].id); ;}
break;
- case 95:
+ case 103:
{ (yyval.id) = (yyvsp[(1) - (2)].id); ;}
break;
- case 98:
+ case 106:
{ (yyval.expr) = NULL; ;}
break;
- case 99:
+ case 107:
{ (yyval.expr) = (yyvsp[(2) - (2)].expr); ;}
break;
- case 100:
+ case 108:
{ (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); ;}
break;
- case 101:
+ case 109:
{ (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;}
break;
- case 102:
+ case 110:
{ (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;}
break;
- case 103:
+ case 111:
{ (yyval.expr) = (yyvsp[(2) - (3)].expr); ;}
break;
- case 104:
+ case 112:
{ (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); ;}
break;
- case 105:
+ case 113:
{ (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;}
break;
- case 106:
+ case 114:
{ (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;}
break;
- case 107:
+ case 115:
{ (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); ;}
break;
- case 108:
+ case 116:
- { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 1); free((yyvsp[(1) - (1)].string)); ;}
+ { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); ;}
+ break;
+
+ case 117:
+
+ { (yyval.string) = NULL; ;}
break;
-/* Line 1267 of yacc.c. */
default: break;
}
@@ -2029,7 +2045,6 @@ yyreduce:
*++yyvsp = yyval;
-
/* Now `shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
@@ -2094,7 +2109,7 @@ yyerrlab:
if (yyerrstatus == 3)
{
- /* If just tried and failed to reuse look-ahead token after an
+ /* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
@@ -2111,7 +2126,7 @@ yyerrlab:
}
}
- /* Else will try to reuse look-ahead token after shifting the error
+ /* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
@@ -2168,9 +2183,6 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
*++yyvsp = yylval;
@@ -2195,7 +2207,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
-#ifndef yyoverflow
+#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
@@ -2206,7 +2218,7 @@ yyexhaustedlab:
#endif
yyreturn:
- if (yychar != YYEOF && yychar != YYEMPTY)
+ if (yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval);
/* Do not reclaim the symbols of the rule which action triggered
@@ -2243,16 +2255,14 @@ void conf_parse(const char *name)
zconf_initscan(name);
sym_init();
- menu_init();
+ _menu_init();
modules_sym = sym_lookup(NULL, 0);
modules_sym->type = S_BOOLEAN;
modules_sym->flags |= SYMBOL_AUTO;
rootmenu.prompt = menu_add_prompt(P_MENU, "uClibc Configuration", NULL);
-#if YYDEBUG
if (getenv("ZCONF_DEBUG"))
zconfdebug = 1;
-#endif
zconfparse();
if (zconfnerrs)
exit(1);
@@ -2262,6 +2272,10 @@ void conf_parse(const char *name)
prop = prop_alloc(P_DEFAULT, modules_sym);
prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
}
+
+ rootmenu.prompt->text = _(rootmenu.prompt->text);
+ rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
+
menu_finalize(&rootmenu);
for_all_symbols(i, sym) {
if (sym_check_deps(sym))
@@ -2272,7 +2286,7 @@ void conf_parse(const char *name)
sym_set_change_count(1);
}
-const char *zconf_tokenname(int token)
+static const char *zconf_tokenname(int token)
{
switch (token) {
case T_MENU: return "menu";
@@ -2282,11 +2296,12 @@ const char *zconf_tokenname(int token)
case T_IF: return "if";
case T_ENDIF: return "endif";
case T_DEPENDS: return "depends";
+ case T_VISIBLE: return "visible";
}
return "<token>";
}
-static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken)
+static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken)
{
if (id->token != endtoken) {
zconf_error("unexpected '%s' within %s block",
@@ -2331,12 +2346,10 @@ static void zconf_error(const char *err, ...)
static void zconferror(const char *err)
{
-#if YYDEBUG
fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
-#endif
}
-void print_quoted_string(FILE *out, const char *str)
+static void print_quoted_string(FILE *out, const char *str)
{
const char *p;
int len;
@@ -2353,15 +2366,15 @@ void print_quoted_string(FILE *out, const char *str)
putc('"', out);
}
-void print_symbol(FILE *out, struct menu *menu)
+static void print_symbol(FILE *out, struct menu *menu)
{
struct symbol *sym = menu->sym;
struct property *prop;
if (sym_is_choice(sym))
- fprintf(out, "choice\n");
+ fprintf(out, "\nchoice\n");
else
- fprintf(out, "config %s\n", sym->name);
+ fprintf(out, "\nconfig %s\n", sym->name);
switch (sym->type) {
case S_BOOLEAN:
fputs(" boolean\n", out);
@@ -2407,6 +2420,21 @@ void print_symbol(FILE *out, struct menu *menu)
case P_CHOICE:
fputs(" #choice value\n", out);
break;
+ case P_SELECT:
+ fputs( " select ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_RANGE:
+ fputs( " range ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_MENU:
+ fputs( " menu ", out);
+ print_quoted_string(out, prop->text);
+ fputc('\n', out);
+ break;
default:
fprintf(out, " unknown prop %d!\n", prop->type);
break;
@@ -2418,7 +2446,6 @@ void print_symbol(FILE *out, struct menu *menu)
menu->help[len] = 0;
fprintf(out, " help\n%s\n", menu->help);
}
- fputc('\n', out);
}
void zconfdump(FILE *out)
@@ -2451,7 +2478,6 @@ void zconfdump(FILE *out)
expr_fprint(prop->visible.expr, out);
fputc('\n', out);
}
- fputs("\n", out);
}
if (menu->list)
@@ -2469,7 +2495,7 @@ void zconfdump(FILE *out)
}
}
-#include "lex.zconf.c"
+#include "zconf.lex.c"
#include "util.c"
#include "confdata.c"
#include "expr.c"
diff --git a/extra/config/zconf.y b/extra/config/zconf.y
index 4c6a8e3a3..2cfcfbadc 100644
--- a/extra/config/zconf.y
+++ b/extra/config/zconf.y
@@ -11,11 +11,8 @@
#include <string.h>
#include <stdbool.h>
-#define LKC_DIRECT_LINK
#include "lkc.h"
-#include "zconf.hash.c"
-
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
#define PRINTD 0x0001
@@ -27,18 +24,14 @@ extern int zconflex(void);
static void zconfprint(const char *err, ...);
static void zconf_error(const char *err, ...);
static void zconferror(const char *err);
-static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
+static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
-struct symbol *symbol_hash[257];
+struct symbol *symbol_hash[SYMBOL_HASHSIZE];
static struct menu *current_menu, *current_entry;
-#define YYDEBUG 0
-#if YYDEBUG
-#define YYERROR_VERBOSE
-#endif
%}
-%expect 26
+%expect 30
%union
{
@@ -47,7 +40,7 @@ static struct menu *current_menu, *current_entry;
struct symbol *symbol;
struct expr *expr;
struct menu *menu;
- struct kconf_id *id;
+ const struct kconf_id *id;
}
%token <id>T_MAINMENU
@@ -70,6 +63,7 @@ static struct menu *current_menu, *current_entry;
%token <id>T_DEFAULT
%token <id>T_SELECT
%token <id>T_RANGE
+%token <id>T_VISIBLE
%token <id>T_OPTION
%token <id>T_ON
%token <string> T_WORD
@@ -91,7 +85,7 @@ static struct menu *current_menu, *current_entry;
%type <id> end
%type <id> option_name
%type <menu> if_entry menu_entry choice_entry
-%type <string> symbol_option_arg
+%type <string> symbol_option_arg word_opt
%destructor {
fprintf(stderr, "%s:%d: missing end statement for this entry\n",
@@ -100,15 +94,21 @@ static struct menu *current_menu, *current_entry;
menu_end_menu();
} if_entry menu_entry choice_entry
+%{
+/* Include zconf.hash.c here so it can see the token constants. */
+#include "zconf.hash.c"
+%}
+
%%
-input: stmt_list;
+input: nl start | start;
+
+start: mainmenu_stmt stmt_list | stmt_list;
stmt_list:
/* empty */
| stmt_list common_stmt
| stmt_list choice_stmt
| stmt_list menu_stmt
- | stmt_list T_MAINMENU prompt nl
| stmt_list end { zconf_error("unexpected end statement"); }
| stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); }
| stmt_list option_name error T_EOL
@@ -119,7 +119,7 @@ stmt_list:
;
option_name:
- T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT
+ T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE
;
common_stmt:
@@ -224,7 +224,7 @@ symbol_option_list:
/* empty */
| symbol_option_list T_WORD symbol_option_arg
{
- struct kconf_id *id = kconf_id_lookup($2, strlen($2));
+ const struct kconf_id *id = kconf_id_lookup($2, strlen($2));
if (id && id->flags & TF_OPTION)
menu_add_option(id->token, $3);
else
@@ -239,10 +239,10 @@ symbol_option_arg:
/* choice entry */
-choice: T_CHOICE T_EOL
+choice: T_CHOICE word_opt T_EOL
{
- struct symbol *sym = sym_lookup(NULL, 0);
- sym->flags |= SYMBOL_CHOICE;
+ struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE);
+ sym->flags |= SYMBOL_AUTO;
menu_add_entry(sym);
menu_add_expr(P_CHOICE, NULL, NULL);
printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
@@ -339,6 +339,13 @@ if_block:
| if_block choice_stmt
;
+/* mainmenu entry */
+
+mainmenu_stmt: T_MAINMENU prompt nl
+{
+ menu_add_prompt(P_MENU, $2, NULL);
+};
+
/* menu entry */
menu: T_MENU prompt T_EOL
@@ -348,7 +355,7 @@ menu: T_MENU prompt T_EOL
printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
};
-menu_entry: menu depends_list
+menu_entry: menu visibility_list depends_list
{
$$ = menu_add_menu();
};
@@ -419,6 +426,19 @@ depends: T_DEPENDS T_ON expr T_EOL
printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
};
+/* visibility option */
+
+visibility_list:
+ /* empty */
+ | visibility_list visible
+ | visibility_list T_EOL
+;
+
+visible: T_VISIBLE if_expr
+{
+ menu_add_visibility($2);
+};
+
/* prompt statement */
prompt_stmt_opt:
@@ -456,9 +476,12 @@ expr: symbol { $$ = expr_alloc_symbol($1); }
;
symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); }
- | T_WORD_QUOTE { $$ = sym_lookup($1, 1); free($1); }
+ | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); }
;
+word_opt: /* empty */ { $$ = NULL; }
+ | T_WORD
+
%%
void conf_parse(const char *name)
@@ -469,16 +492,14 @@ void conf_parse(const char *name)
zconf_initscan(name);
sym_init();
- menu_init();
+ _menu_init();
modules_sym = sym_lookup(NULL, 0);
modules_sym->type = S_BOOLEAN;
modules_sym->flags |= SYMBOL_AUTO;
rootmenu.prompt = menu_add_prompt(P_MENU, "uClibc Configuration", NULL);
-#if YYDEBUG
if (getenv("ZCONF_DEBUG"))
zconfdebug = 1;
-#endif
zconfparse();
if (zconfnerrs)
exit(1);
@@ -488,6 +509,10 @@ void conf_parse(const char *name)
prop = prop_alloc(P_DEFAULT, modules_sym);
prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
}
+
+ rootmenu.prompt->text = _(rootmenu.prompt->text);
+ rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
+
menu_finalize(&rootmenu);
for_all_symbols(i, sym) {
if (sym_check_deps(sym))
@@ -498,7 +523,7 @@ void conf_parse(const char *name)
sym_set_change_count(1);
}
-const char *zconf_tokenname(int token)
+static const char *zconf_tokenname(int token)
{
switch (token) {
case T_MENU: return "menu";
@@ -508,11 +533,12 @@ const char *zconf_tokenname(int token)
case T_IF: return "if";
case T_ENDIF: return "endif";
case T_DEPENDS: return "depends";
+ case T_VISIBLE: return "visible";
}
return "<token>";
}
-static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken)
+static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken)
{
if (id->token != endtoken) {
zconf_error("unexpected '%s' within %s block",
@@ -557,12 +583,10 @@ static void zconf_error(const char *err, ...)
static void zconferror(const char *err)
{
-#if YYDEBUG
fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
-#endif
}
-void print_quoted_string(FILE *out, const char *str)
+static void print_quoted_string(FILE *out, const char *str)
{
const char *p;
int len;
@@ -579,15 +603,15 @@ void print_quoted_string(FILE *out, const char *str)
putc('"', out);
}
-void print_symbol(FILE *out, struct menu *menu)
+static void print_symbol(FILE *out, struct menu *menu)
{
struct symbol *sym = menu->sym;
struct property *prop;
if (sym_is_choice(sym))
- fprintf(out, "choice\n");
+ fprintf(out, "\nchoice\n");
else
- fprintf(out, "config %s\n", sym->name);
+ fprintf(out, "\nconfig %s\n", sym->name);
switch (sym->type) {
case S_BOOLEAN:
fputs(" boolean\n", out);
@@ -633,6 +657,21 @@ void print_symbol(FILE *out, struct menu *menu)
case P_CHOICE:
fputs(" #choice value\n", out);
break;
+ case P_SELECT:
+ fputs( " select ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_RANGE:
+ fputs( " range ", out);
+ expr_fprint(prop->expr, out);
+ fputc('\n', out);
+ break;
+ case P_MENU:
+ fputs( " menu ", out);
+ print_quoted_string(out, prop->text);
+ fputc('\n', out);
+ break;
default:
fprintf(out, " unknown prop %d!\n", prop->type);
break;
@@ -644,7 +683,6 @@ void print_symbol(FILE *out, struct menu *menu)
menu->help[len] = 0;
fprintf(out, " help\n%s\n", menu->help);
}
- fputc('\n', out);
}
void zconfdump(FILE *out)
@@ -677,7 +715,6 @@ void zconfdump(FILE *out)
expr_fprint(prop->visible.expr, out);
fputc('\n', out);
}
- fputs("\n", out);
}
if (menu->list)
@@ -695,7 +732,7 @@ void zconfdump(FILE *out)
}
}
-#include "lex.zconf.c"
+#include "zconf.lex.c"
#include "util.c"
#include "confdata.c"
#include "expr.c"
diff --git a/extra/locale/.gitignore b/extra/locale/.gitignore
new file mode 100644
index 000000000..3ea196522
--- /dev/null
+++ b/extra/locale/.gitignore
@@ -0,0 +1,26 @@
+#
+# Never ignore these
+#
+!.gitignore
+
+#
+# Generated files
+#
+/c8tables.h
+/codesets.txt
+/locale_collate.h
+/locale_data.c
+/locale_tables.h
+/locales.txt
+/lt_defines.h
+/uClibc_locale_data.h
+/wctables.h
+#
+# generators
+#
+/gen_collate
+/gen_ldc
+/gen_locale
+/gen_wc8bit
+/gen_wctype
+
diff --git a/extra/locale/Makefile b/extra/locale/Makefile
index 11f362a5e..ff229e20c 100644
--- a/extra/locale/Makefile
+++ b/extra/locale/Makefile
@@ -4,10 +4,10 @@
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-
top_srcdir=../../
-top_builddir=../../
+top_builddir=$(if $(O),$(O),../../)/
+
all: objs
-include $(top_builddir)Rules.mak
+include $(top_srcdir)Rules.mak
include Makefile.in
include $(top_srcdir)Makerules
diff --git a/extra/locale/Makefile.in b/extra/locale/Makefile.in
index 52de0f26e..117993fd0 100644
--- a/extra/locale/Makefile.in
+++ b/extra/locale/Makefile.in
@@ -1,55 +1,72 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
+locale_DIR := $(top_srcdir)extra/locale
+locale_OUT := $(top_builddir)extra/locale
+
# command used to download source code
WGET := wget --passive-ftp
-LOCALE_DATA_FILENAME := uClibc-locale-030818.tgz
+LOCALE_DATA_FILENAME := uClibc-locale-20081111-$(ARCH_NATIVE_BIT)-$(if $(ARCH_LITTLE_ENDIAN),el,eb).tgz
BUILD_CFLAGS-locale-common := \
-D__UCLIBC_GEN_LOCALE \
- -DUCLIBC_CTYPE_HEADER='"$(top_builddir)include/bits/uClibc_ctype.h"'
+ -I$(top_builddir)
BUILD_CFLAGS-gen_wc8bit := $(BUILD_CFLAGS-locale-common) -DCTYPE_PACKED=1
-
BUILD_CFLAGS-gen_wctype := $(BUILD_CFLAGS-locale-common)
-
-BUILD_CFLAGS-gen_ldc :=
+BUILD_CFLAGS-gen_ldc := -I$(locale_OUT)
ifeq ($(UCLIBC_HAS_WCHAR),y)
BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1
BUILD_CFLAGS-gen_ldc += -D__WCHAR_ENABLED=1
endif
+BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE -I$(locale_OUT)
+BUILD_CFLAGS-gen_collate := -D_GNU_SOURCE
-BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE
+locale_headers-$(UCLIBC_HAS_LOCALE) := $(top_builddir)include/bits/uClibc_locale_data.h
-DEPH-locale := $(top_builddir)include/bits/sysnum.h
-DEPH-gen_locale := c8tables.h
-DEPH-gen_ldc := c8tables.h wctables.h locale_tables.h locale_collate.h
+headers_dep += $(locale_headers-y)
-locale_DIR := $(top_srcdir)extra/locale
-locale_OUT := $(top_builddir)extra/locale
+DEPH-locale := $(top_builddir)include/bits/uClibc_config.h
+DEPH-gen_collate := $(DEPH-locale)
+DEPH-gen_ldc := $(addprefix $(locale_OUT)/,c8tables.h wctables.h locale_tables.h locale_collate.h) $(DEPH-locale)
+DEPH-gen_locale := $(addprefix $(locale_OUT)/,c8tables.h) $(DEPH-locale)
+DEPH-gen_wc8bit := $(top_builddir)include/bits/uClibc_ctype.h $(DEPH-locale)
+DEPH-gen_wctype := $(top_builddir)include/bits/uClibc_ctype.h $(DEPH-locale)
-#locale_HOBJ := gen_collate gen_ldc gen_locale gen_wc8bit gen_wctype
-locale_HOBJ := gen_collate gen_wc8bit gen_wctype
-locale_HOBJ := $(patsubst %,$(locale_OUT)/%,$(locale_HOBJ))
+locale_HOBJ := gen_collate gen_ldc gen_locale gen_wc8bit gen_wctype
+locale_HOBJ := $(addprefix $(locale_OUT)/,$(locale_HOBJ))
+$(locale_HOBJ): | $(locale_OUT)
locale_SRC := $(locale_OUT)/locale_data.c
locale_OBJ := $(locale_OUT)/locale_data.o
CFLAGS-locale_data.c := -D__WCHAR_ENABLED -I$(locale_OUT) -I$(locale_DIR)
-# produces a loop
-#headers-$(UCLIBC_HAS_LOCALE) += locale_headers
-
libc-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
-
libc-nomulti-$(UCLIBC_HAS_LOCALE) += $(locale_OBJ)
-locale_headers: $(top_builddir)include/bits/uClibc_locale_data.h
+$(locale_OUT)%.o: $(locale_OUT)%.c FORCE ; $(compile.c)
+$(locale_OUT)%.os: $(locale_OUT)%.c FORCE ; $(compile.c)
+$(locale_OUT)%.oS: $(locale_OUT)%.c FORCE ; $(compile.c)
+$(locale_OUT)%.o: $(locale_OUT)%.S FORCE ; $(compile.S)
+$(locale_OUT)%.os: $(locale_OUT)%.S FORCE ; $(compile.S)
+$(locale_OUT)%.oS: $(locale_OUT)%.S FORCE ; $(compile.S)
+$(locale_OUT)%.o: $(locale_OUT)%.s FORCE ; $(compile.S)
+$(locale_OUT)%.os: $(locale_OUT)%.s FORCE ; $(compile.S)
+$(locale_OUT)%.oS: $(locale_OUT)%.s FORCE ; $(compile.S)
+$(locale_OUT)%.i: $(locale_OUT)%.c FORCE ; $(compile.i)
+$(locale_OUT)%.i: $(locale_OUT)%.S FORCE ; $(compile.i)
+$(locale_OUT)%.s: $(locale_OUT)%.c FORCE ; $(compile.s)
+$(locale_OUT)%.s: $(locale_OUT)%.S FORCE ; $(compile.s)
+$(locale_OUT)%.dep:
+
+
+locale_headers: $(locale_headers-y)
# make sure that the host system has locales (this check is ok for uClibc/glibc)
# we do not know though which locales were really enabled for libc at build time
@@ -61,12 +78,12 @@ $(locale_OUT)/codesets.txt:
echo " "; \
echo "You do not have a codesets.txt file. Please create this "; \
echo "file in the $(locale_OUT) directory by running something like: "; \
- echo -e " find $(locale_DIR)/charmaps -name \"*.pairs\" > \\"; \
- echo -e " $@"; \
+ echo " find $(CURDIR)/$(locale_DIR)/charmaps -name \"*.pairs\" > \\"; \
+ echo " $@"; \
echo "and then edit that file to disable/enable the codesets you wish to support. "; \
echo " "; \
false; \
- fi;
+ fi
$(locale_OUT)/locales.txt:
@if [ ! -f $@ ] ; then \
@@ -81,99 +98,115 @@ $(locale_OUT)/locales.txt:
echo "to support. "; \
echo " "; \
false; \
- fi;
+ fi
else
$(locale_OUT)/codesets.txt:
+ @$(disp_gen)
ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
- echo "$(locale_DIR)/charmaps/ASCII.pairs" > $@ ; \
- echo "$(locale_DIR)/charmaps/ISO-8859-1.pairs" >> $@
+ $(Q)echo "$(CURDIR)/$(locale_DIR)/charmaps/ASCII.pairs" > $@
+ $(Q)echo "$(CURDIR)/$(locale_DIR)/charmaps/ISO-8859-1.pairs" >> $@
else
- find $(locale_DIR)/charmaps -name '*.pairs' | sort > $@
+ $(Q)set -e; \
+ find $(CURDIR)/$(locale_DIR)/charmaps/ -name '*.pairs' | \
+ sort > $@.new; \
+ [ -s $@.new ]; \
+ cmp -s $@ $@.new && $(RM) $@.new || mv -f $@.new $@
endif
# the lines beginning w/ '#-' are mandatory
# at least one conversion is needed (euro/cyrillic)
$(locale_OUT)/locales.txt: $(locale_DIR)/LOCALES
+ @$(disp_gen)
ifeq ($(UCLIBC_BUILD_MINIMAL_LOCALE),y)
- echo "@euro e" > $@ ; \
- echo "#-" >> $@ ; \
- echo "UTF-8 yes" >> $@ ; \
- echo "8-BIT yes" >> $@ ; \
- echo "#-" >> $@ ; \
- echo "en_US.UTF-8 UTF-8" >> $@ ; \
- echo "en_US ISO-8859-1" >> $@
+ $(Q)echo "@euro e" > $@
+ $(Q)echo "#-" >> $@
+ $(Q)echo "UTF-8 yes" >> $@
+ $(Q)echo "8-BIT yes" >> $@
+ $(Q)echo "#-" >> $@
+ $(Q)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)); do \
+ echo "$$locale.UTF-8 UTF-8"; \
+ echo "$$locale ISO-8859-1"; \
+ done >> $@
else
- cp $< $@
+ $(Q)cat $< > $@
endif
endif
-$(locale_HOBJ): $(locale_OUT)/% : $(locale_DIR)/%.c | $(DEPH-locale)
+$(locale_DIR)/gen_collate.c: $(DEPH-gen_collate)
+$(locale_OUT)/gen_collate : $(locale_DIR)/gen_collate.c
$(hcompile.u)
-
-$(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c | $(DEPH-locale) $(patsubst %,$(locale_OUT)/%,$(DEPH-gen_locale))
+$(locale_DIR)/gen_ldc.c: $(DEPH-gen_ldc)
+$(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c
$(hcompile.u)
-
-$(locale_OUT)/gen_ldc : $(locale_DIR)/gen_ldc.c | $(DEPH-locale) $(patsubst %,$(locale_OUT)/%,$(DEPH-gen_ldc))
+$(locale_DIR)/gen_locale.c: $(DEPH-gen_locale)
+$(locale_OUT)/gen_locale : $(locale_DIR)/gen_locale.c
+ $(hcompile.u)
+$(locale_DIR)/gen_wc8bit.c: $(DEPH-gen_wc8bit)
+$(locale_OUT)/gen_wc8bit : $(locale_DIR)/gen_wc8bit.c
+ $(hcompile.u)
+$(locale_DIR)/gen_wctype.c: $(DEPH-gen_wctype)
+$(locale_OUT)/gen_wctype : $(locale_DIR)/gen_wctype.c
$(hcompile.u)
+ifneq ($(V),)
+ifeq ($(V),1)
+FLAG-locale-verbose := -v -v
+endif
+ifeq ($(V),2)
+FLAG-locale-verbose := -v
+endif
+endif
+
# code needs to be modified to support top_builddir in almost all apps that write directly to a file
# grep fopen *.c
$(locale_OUT)/c8tables.h: $(locale_OUT)/gen_wc8bit $(locale_OUT)/codesets.txt
- $< `cat $(word 2,$^)`
+ @$(disp_gen)
+ $(Q)$< `cat $(word 2,$^)` > $@
# Warning! Beware tr_TR toupper/tolower exceptions!
$(locale_OUT)/wctables.h: $(locale_OUT)/gen_wctype
- $< en_US
+ @$(disp_gen)
+ $(Q)for locale in $(call qstrip,$(UCLIBC_BUILD_MINIMAL_LOCALES)) en_US en_GB; do \
+ $< $(FLAG-locale-verbose) $$locale > $@ || \
+ $< $(FLAG-locale-verbose) $$locale.UTF-8 > $@ || \
+ $< $(FLAG-locale-verbose) $$locale.iso8859-1 > $@ && break; \
+ done
$(locale_OUT)/locale_tables.h: $(locale_OUT)/gen_locale $(locale_OUT)/locales.txt
- $< $(word 2,$^)
+ @$(disp_gen)
+ $(Q)$< $(FLAG-locale-verbose) -o $@ $(word 2,$^)
$(locale_OUT)/lt_defines.h: $(locale_OUT)/locale_tables.h $(locale_OUT)/locale_collate.h
- grep "^#define" $< > $@
- grep "^#define __lc" $(word 2,$^) >> $@
+ @$(disp_gen)
+ $(Q)grep "^#define" $< > $@
+ $(Q)grep "^#define __lc" $(word 2,$^) >> $@
$(locale_OUT)/locale_collate.h: $(locale_OUT)/gen_collate $(locale_OUT)/locale_tables.h
- grep COL_IDX_ $(word 2,$^) | sed -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | \
- sort | uniq | xargs $<
-
-$(locale_OUT)/$(LOCALE_DATA_FILENAME):
-ifeq ($(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA),y)
- ( cd $(dir $@); $(WGET) http://www.uclibc.org/downloads/$(notdir $@) )
-endif
-
-ifeq ($(UCLIBC_PREGENERATED_LOCALE_DATA),y)
+ @$(disp_gen)
+ $(Q)grep COL_IDX_ $(word 2,$^) | \
+ $(SED) -e "s/^.*COL_IDX_\([^, ]*\).*$$/\1/" | sort | uniq | \
+ xargs $< $(locale_DIR)/collation $(FLAG-locale-verbose) -o $@
-$(locale_SRC): $(locale_OUT)/$(LOCALE_DATA_FILENAME)
- zcat $< | tar -xv -C $(dir $@) -f -
- touch $@
- # we use the one in locale_DIR
- #$(RM) $(locale_OUT)/locale_mmap.h
-
-# for arch specific versions we have to at least overwrite lt_defines.h/locale_data.c/uClibc_locale_data.h
-
-$(locale_OUT)/uClibc_locale_data.h: $(locale_SRC)
-
-else
-
-$(locale_SRC): $(locale_OUT)/gen_ldc
- $<
+$(locale_SRC): $(locale_OUT)/gen_ldc $(locale_OUT)/lt_defines.h
+ @$(disp_gen)
+ $(Q)$< $@
$(locale_OUT)/uClibc_locale_data.h: $(locale_OUT)/lt_defines.h $(locale_OUT)/c8tables.h $(locale_OUT)/wctables.h $(locale_DIR)/locale_mmap.h | $(locale_SRC)
- grep -v "define __LC" $< > $@
- cat $(wordlist 2,4,$^) >> $@
-
-endif
+ @$(disp_gen)
+ $(Q)grep -v "define __LC" $< > $@
+ $(Q)cat $(wordlist 2,4,$^) >> $@
$(top_builddir)include/bits/uClibc_locale_data.h: $(locale_OUT)/uClibc_locale_data.h | $(top_builddir)include/bits/uClibc_config.h
- cat $< | awk 'BEGIN{i=1}{ if ( /WANT_/ ) i = /endif/ ; else if (i) print $0 }' > $@
+ @$(disp_gen)
+ $(Q)$(AWK) 'BEGIN{i=1}{if (/WANT_/) i=/endif/;else if (i) print $0}' \
+ $< > $@
-objclean-y += locale_clean
+objclean-y += CLEAN_extra/locale
# lmmtolso.c/gen_mmap.c/tst-*.c not used
-locale_clean:
- $(RM) $(locale_HOBJ) $(locale_SRC) $(locale_OUT)/{*.{o,os,txt},gen_locale,gen_ldc}
- $(RM) $(locale_OUT)/{uClibc_locale_data,lt_defines,c8tables,wctables,locale_tables,locale_collate}.h
- $(RM) $(locale_OUT)/{lmmtolso,gen_mmap,locale.mmap}
+CLEAN_extra/locale:
+ $(do_rm) $(locale_HOBJ) $(locale_SRC) $(addprefix $(locale_OUT)/*., o os txt) \
+ $(addprefix $(locale_OUT)/,$(addsuffix .h,uClibc_locale_data lt_defines c8tables wctables locale_tables locale_collate) lmmtolso gen_mmap locale.mmap)
diff --git a/extra/locale/gen_collate.c b/extra/locale/gen_collate.c
index 77dc5ff9e..15582c1ba 100644
--- a/extra/locale/gen_collate.c
+++ b/extra/locale/gen_collate.c
@@ -1,3 +1,12 @@
+/*
+ * Usage:
+ * gen_collate <INPUTDIR> [-o OUTPUTFILE] LOCALE ...
+ *
+ * Generate collation data from locales LOCALE.
+ * Reads all LOCALE from INPUTDIR and writes collation data to OUTPUTFILE.
+ *
+ * The output file defaults to "locales_collate.h".
+ */
/* TODO:
*
* add UNDEFINED at end if not specified
@@ -24,6 +33,7 @@
#include <limits.h>
#include <ctype.h>
#include <assert.h>
+#include <errno.h>
#include <search.h>
typedef struct {
@@ -253,6 +263,14 @@ static void *root_sym = NULL;
static size_t num_sym = 0;
static size_t mem_sym = 0;
+static const char *inputdir;
+static size_t inputdir_len;
+static unsigned verbose = 0;
+enum {
+ VINFO = (1<<0),
+ VDETAIL = (1<<1),
+};
+
static void error_msg(const char *fmt, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
static void *xmalloc(size_t n);
static char *xsymdup(const char *s); /* only allocate once... store in a tree */
@@ -294,6 +312,18 @@ enum {
DT_RANGE = 0x10,
};
+static int verbose_msg(const unsigned lvl, const char *fmt, ...)
+{
+ va_list arg;
+ int ret = 0;
+
+ if (verbose & lvl) {
+ va_start(arg, fmt);
+ ret = vfprintf(stderr, fmt, arg);
+ va_end(arg);
+ }
+ return ret;
+}
static section_t *new_section(const char *name)
{
section_t *p;
@@ -310,7 +340,7 @@ static section_t *new_section(const char *name)
++anonsection;
}
#warning devel code
-/* fprintf(stderr, "section %s\n", name); */
+/* verbose_msg(VDETAIL, "section %s\n", name); */
p->name = xsymdup(name);
p->itm_list = NULL;
p->num_items = 0;
@@ -328,7 +358,7 @@ static section_t *new_section(const char *name)
p->rules[3] |= R_POSITION;
cur_rule[3] |= R_POSITION;
}
-/* fprintf(stderr, "new section %s -- cur_num_weights = %d\n", p->name, cur_num_weights); */
+/* verbose_msg(VDETAIL, "new section %s -- cur_num_weights = %d\n", p->name, cur_num_weights); */
return p;
}
@@ -379,7 +409,7 @@ static void do_unrecognized(void)
#if 1
error_msg("warning: unrecognized: %s", pos);
#else
-/* fprintf(stderr, "warning: unrecognized initial keyword \"%s\"\n", pos); */
+/* verbose_msg(VDETAIL, "warning: unrecognized initial keyword \"%s\"\n", pos); */
fprintf(stderr, "warning: unrecognized: %s", pos);
if (end_of_token) {
fprintf(stderr, "%c%s", end_of_token, pos_e+1);
@@ -587,10 +617,10 @@ static void add_superset_weight(char *t)
lli = new_ll_item(DT_REORDER, cur_section);
lli->prev = lli->next = lli;
insque(lli, comm_prev_ptr);
-/* fprintf(stderr, " subsection -----------------------\n"); */
+/* verbose_msg(VDETAIL, " subsection -----------------------\n"); */
}
-/* fprintf(stderr, " %s %s\n", t, ((weighted_item_t *)(comm_cur_ptr->data))->symbol); */
+/* verbose_msg(VDETAIL, " %s %s\n", t, ((weighted_item_t *)(comm_cur_ptr->data))->symbol); */
wi = add_weight(t);
lli = new_ll_item(DT_WEIGHTED, wi);
mark_reordered(wi->symbol);
@@ -745,7 +775,7 @@ static void processfile(void)
}
if (cur_base == cur_col) {
- fprintf(stderr, "Base: %15s", cur_col->name);
+ verbose_msg(VDETAIL, "Base: %15s", cur_col->name);
} else {
#if 1
if (!cur_col->undefined_idx) {
@@ -794,20 +824,21 @@ static void processfile(void)
}
#endif
- fprintf(stderr, " Der: %15s", cur_col->name);
+ verbose_msg(VDETAIL, " Der: %15s", cur_col->name);
}
{
+#if 0
ll_item_t *p = cur_col->section_list;
-
- fprintf(stderr, "%6u weights", tnumnodes(cur_col->root_wi_index));
+#endif
+ verbose_msg(VDETAIL, "%6u weights", tnumnodes(cur_col->root_wi_index));
if (cur_base) {
- fprintf(stderr, " %6u der %6u reor %6u starter - %u new stubs",
+ verbose_msg(VDETAIL, " %6u der %6u reor %6u starter - %u new stubs",
tnumnodes(cur_base->root_derived_wi),
tnumnodes(cur_base->root_wi_index_reordered),
tnumnodes(cur_base->root_starter_char),
ll_count(cur_col->section_list, DT_REORDER));
}
- fprintf(stderr, "\n");
+ verbose_msg(VDETAIL, "\n");
#if 0
while (p) {
@@ -826,7 +857,7 @@ static void processfile(void)
if ((*((section_t *)(p->data))->name != 'a')
|| (((section_t *)(p->data))->num_items > 0)
) {
- fprintf(stderr,
+ verbose_msg(VDETAIL,
/* "\t%-15s %zu\n", */
"\t%-15s %6u\n",
((section_t *)(p->data))->name,
@@ -1089,18 +1120,35 @@ int main(int argc, char **argv)
ll_item_t *lli;
int i;
int total;
+ char *output_file = "locale_collate.h";
+ unsigned verbosity = 0;
- if (argc < 2) {
+ if (argc < 3) {
return EXIT_FAILURE;
}
-
+ --argc;
+ inputdir = strdup(*++argv);
+ inputdir_len = strlen(inputdir);
init_locale_list();
while (--argc) {
- p = (const deps_t *) bsearch(*++argv, deps, sizeof(deps)/sizeof(deps[0]), sizeof(deps[0]), dep_cmp);
+ ++argv;
+ if (!strcmp(*argv, "-o")) {
+ --argc;
+ if (*++argv == NULL) {
+ printf("-o <outfile> requires an argument\n");
+ return EXIT_FAILURE;
+ }
+ output_file = strdup(*argv);
+ continue;
+ } else if (!strcmp(*argv, "-v")) {
+ verbosity++;
+ continue;
+ }
+ p = (const deps_t *) bsearch(*argv, deps, sizeof(deps)/sizeof(deps[0]), sizeof(deps[0]), dep_cmp);
if (!p) {
if (!strcmp("C", *argv)) {
- printf("ignoring C locale\n");
+ printf("ignoring %s locale\n", *argv);
continue;
} else {
printf("%s not found\n", *argv);
@@ -1125,10 +1173,10 @@ int main(int argc, char **argv)
total = 0;
for (i=0 ; i < BASE_MAX ; i++) {
-/* printf("der_count[%2d] = %3d\n", i, der_count[i]); */
+/* printf("der_count[%2d] = %3d\n", i, der_count[i]); */
total += der_count[i];
}
-/* printf("total = %d\n", total); */
+/* printf("total = %d\n", total); */
new_args[new_arg_count++] = "dummyprogramname";
for (i=0 ; i < BASE_MAX ; i++) {
@@ -1143,11 +1191,16 @@ int main(int argc, char **argv)
} while (lli != locale_list[i]);
new_args[new_arg_count++] = "-f";
}
+ for (i=0; i < verbosity; i++)
+ new_args[new_arg_count++] = "-v";
-/* for (i=0 ; i < new_arg_count ; i++) { */
-/* printf("%3d: %s\n", i, new_args[i]); */
-/* } */
-
+ new_args[new_arg_count++] = "-o";
+ new_args[new_arg_count++] = output_file;
+/*
+ for (i=0 ; i < new_arg_count ; i++) {
+ printf("%3d: %s\n", i, new_args[i]);
+ }
+*/
return old_main(new_arg_count, (char **) new_args);
}
@@ -1158,6 +1211,7 @@ static int old_main(int argc, char **argv)
{
int next_is_base = 0;
int next_is_subset = 0;
+ char *output_file = NULL;
superset = 0;
@@ -1185,6 +1239,11 @@ static int old_main(int argc, char **argv)
next_is_subset = 0;
next_is_base = 2;
superset = 0;
+ } else if (((*argv)[1] == 'o') && !(*argv)[2]) { /* output file */
+ --argc;
+ output_file = *++argv;
+ } else if (((*argv)[1] == 'v') && !(*argv)[2]) { /* verbose */
+ ++verbose;
} else {
error_msg("unrecognized option %s", *argv);
}
@@ -1198,7 +1257,7 @@ static int old_main(int argc, char **argv)
cur_derived = cur_col;
}
pushfile(*argv);
-/* fprintf(stderr, "processing file %s\n", *argv); */
+/* verbose_msg(VDETAIL, "processing file %s\n", *argv); */
processfile(); /* this does a popfile */
/* twalk(cur_col->root_colitem, print_colnode); */
@@ -1212,17 +1271,17 @@ static int old_main(int argc, char **argv)
}
}
- fprintf(stderr, "success!\n");
- fprintf(stderr,
+ verbose_msg(VINFO, "success!\n");
+ verbose_msg(VINFO,
/* "num_sym=%zu mem_sym=%zu unique_weights=%zu\n", */
"num_sym=%u mem_sym=%u unique_weights=%u\n",
num_sym, mem_sym, unique_weights);
/* twalk(root_weight, print_weight_node); */
- fprintf(stderr, "num base locales = %d num derived locales = %d\n",
+ verbose_msg(VINFO, "num base locales = %d num derived locales = %d\n",
base_locale_len, der_locale_len);
- fprintf(stderr,
+ verbose_msg(VINFO,
"override_len = %d multistart_len = %d weightstr_len = %d\n"
"wcs2colidt_len = %d index2weight_len = %d index2ruleidx_len = %d\n"
"ruletable_len = %d\n"
@@ -1250,10 +1309,10 @@ static int old_main(int argc, char **argv)
#endif
{
- FILE *fp = fopen("locale_collate.h", "w");
+ FILE *fp = fopen(output_file, "w");
if (!fp) {
- error_msg("couldn't open output file!");
+ error_msg("cannot open output file '%s'!", output_file);
}
dump_collate(fp);
if (ferror(fp) || fclose(fp)) {
@@ -1282,20 +1341,23 @@ static void error_msg(const char *fmt, ...)
static void pushfile(char *filename)
{
- static char fbuf[PATH_MAX];
-
- snprintf(fbuf, PATH_MAX, "collation/%s", filename);
+ char *inputfile;
+ size_t inputfile_len;
if (fno >= MAX_FNO) {
error_msg("file stack size exceeded");
}
- if (!(fstack[++fno] = fopen(fbuf, "r"))) {
+ inputfile_len = inputdir_len + strlen(filename) + 2;
+ inputfile = xmalloc(inputfile_len);
+ memset(inputfile, 0, inputfile_len);
+ sprintf(inputfile, "%s/%s", inputdir, filename);
+ if (!(fstack[++fno] = fopen(inputfile, "r"))) {
--fno; /* oops */
- error_msg("cannot open file %s", fbuf);
+ error_msg("cannot open file %s: %s", inputfile, strerror(errno));
}
- fname[fno] = xsymdup(filename);
+ fname[fno] = xsymdup(inputfile);
lineno[fno] = 0;
}
@@ -1452,11 +1514,11 @@ static void do_copy(void)
*e = 0;
++s;
if (cur_base && !strcmp(cur_base->name,s)) {
-/* fprintf(stderr, "skipping copy of base file %s\n", s); */
+/* verbose_msg(VDETAIL, "skipping copy of base file %s\n", s); */
#warning need to update last in order and position or check
return;
}
-/* fprintf(stderr, "full copy of %s\n", s); */
+/* verbose_msg(VDETAIL, "full copy of %s\n", s); */
pushfile(s);
return;
}
@@ -1541,7 +1603,7 @@ static ll_item_t *find_section_list_item(const char *name, col_locale_t *loc)
while (p) {
#warning devel code
/* if (!((p->data_type == DT_SECTION) || (p->data_type == DT_REORDER))) { */
-/* fprintf(stderr, "fsli = %d\n", p->data_type); */
+/* verbose_msg(VDETAIL, "fsli = %d\n", p->data_type); */
/* } */
assert((p->data_type == DT_SECTION) || (p->data_type == DT_REORDER));
if (!strcmp(name, ((section_t *)(p->data))->name)) {
@@ -1685,11 +1747,11 @@ static void add_colitem(char *item, char *def)
#warning devel code
if (superset) {
if (tfind(p, &cur_base->root_colitem, colitem_cmp)) {
-/* fprintf(stderr, "skipping superset duplicate collating item \"%s\"\n", p->string); */
+/* verbose_msg(VDETAIL, "skipping superset duplicate collating item \"%s\"\n", p->string); */
del_colitem(p);
return;
/* } else { */
-/* fprintf(stderr, "superset: new collating item \"%s\" = %s\n", p->string, p->element); */
+/* verbose_msg(VDETAIL, "superset: new collating item \"%s\" = %s\n", p->string, p->element); */
}
}
@@ -1850,7 +1912,7 @@ static void do_order_start(void)
cur_section = sect;
-/* fprintf(stderr, "setting cur_num_weights to %d for %s\n", sect->num_rules, sect->name); */
+/* verbose_msg(VDETAIL, "setting cur_num_weights to %d for %s\n", sect->num_rules, sect->name); */
cur_num_weights = sect->num_rules;
memcpy(cur_rule, sect->rules, MAX_COLLATION_WEIGHTS);
}
@@ -1923,7 +1985,7 @@ static void do_reorder_after(void)
insque(l1, l2);
l3 = find_ll_last(cur_col->section_list);
- fprintf(stderr, "reorder_after %p %p %p %s\n", l1, l2, l3, cur_section->name);
+ verbose_msg(VDETAIL, "reorder_after %p %p %p %s\n", l1, l2, l3, cur_section->name);
}
#else
insque(new_ll_item(DT_REORDER, cur_section), find_ll_last(cur_col->section_list));
@@ -1935,7 +1997,7 @@ static void do_reorder_after(void)
#warning devel code
-/* fprintf(stderr, "reorder -- %s %d\n", ((weighted_item_t *)(lli->data))->symbol, w->num_weights); */
+/* verbose_msg(VDETAIL, "reorder -- %s %d\n", ((weighted_item_t *)(lli->data))->symbol, w->num_weights); */
#warning hack to get around hu_HU reorder-after problem
/* if (!w->num_weights) { */
@@ -1945,7 +2007,7 @@ static void do_reorder_after(void)
/* memcpy(cur_rule, w->rule, MAX_COLLATION_WEIGHTS); */
/* } */
-/* fprintf(stderr, "reorder_after succeeded for %s\n", t); */
+/* verbose_msg(VDETAIL, "reorder_after succeeded for %s\n", t); */
}
static void do_reorder_end(void)
@@ -1986,9 +2048,9 @@ static void do_reorder_sections_after(void)
lli = cur_base->section_list;
do {
-/* fprintf(stderr, "hmm -- |%s|%d|\n", ((section_t *)(lli->data))->name, lli->data_type); */
+/* verbose_msg(VDETAIL, "hmm -- |%s|%d|\n", ((section_t *)(lli->data))->name, lli->data_type); */
if (lli->data_type & DT_SECTION) {
-/* fprintf(stderr, "checking |%s|%s|\n", ((section_t *)(lli->data))->name, t); */
+/* verbose_msg(VDETAIL, "checking |%s|%s|\n", ((section_t *)(lli->data))->name, t); */
if (!strcmp(((section_t *)(lli->data))->name, t)) {
reorder_section_ptr = lli;
return;
@@ -2025,7 +2087,7 @@ static ll_item_t *new_ll_item(int data_type, void *data)
static int sym_cmp(const void *n1, const void *n2)
{
-/* fprintf(stderr, "sym_cmp: |%s| |%s|\n", (const char *)n1, (const char *)n2); */
+/* verbose_msg(VDETAIL, "sym_cmp: |%s| |%s|\n", (const char *)n1, (const char *)n2); */
return strcmp((const char *) n1, (const char *) n2);
}
@@ -2039,9 +2101,9 @@ static char *xsymdup(const char *s)
}
++num_sym;
mem_sym += strlen(s) + 1;
-/* fprintf(stderr, "xsymdup: alloc |%s| %p |%s| %p\n", *(char **)p, p, s, s); */
+/* verbose_msg(VDETAIL, "xsymdup: alloc |%s| %p |%s| %p\n", *(char **)p, p, s, s); */
/* } else { */
-/* fprintf(stderr, "xsymdup: found |%s| %p\n", *(char **)p, p); */
+/* verbose_msg(VDETAIL, "xsymdup: found |%s| %p\n", *(char **)p, p); */
}
return *(char **) p;
}
@@ -2079,7 +2141,7 @@ static weight_t *register_weight(weight_t *w)
}
++unique_weights;
/* } else { */
-/* fprintf(stderr, "rw: found\n"); */
+/* verbose_msg(VDETAIL, "rw: found\n"); */
}
return *(weight_t **)p;
}
@@ -2200,7 +2262,7 @@ static void add_final_col_index(const char *s)
ci.element = NULL; /* don't care */
v = tfind(&ci, &cur_base->root_colitem, colitem_cmp);
if (!v) {
- fprintf(stderr, "%s NOT DEFINED!!!\n", s);
+ verbose_msg(VDETAIL, "%s NOT DEFINED!!!\n", s);
} else {
p = *((colitem_t **) v);
if (p->element != NULL) {
@@ -2347,11 +2409,11 @@ static ll_item_t *init_comm_ptr(void)
#warning devel code
/* { */
/* ll_item_t *p = comm_cur_ptr; */
-/* fprintf(stderr, "init_comm_ptr\n"); */
+/* verbose_msg(VDETAIL, "init_comm_ptr\n"); */
/* while (p != comm_cur_ptr) { */
/* if (p->data_type & DT_WEIGHTED) { */
-/* fprintf(stderr, "%s", ((weighted_item_t *)p)->symbol); */
+/* verbose_msg(VDETAIL, "%s", ((weighted_item_t *)p)->symbol); */
/* } */
/* p = p->next; */
/* } */
@@ -2359,7 +2421,7 @@ static ll_item_t *init_comm_ptr(void)
assert(comm_cur_ptr);
-/* fprintf(stderr, "init_comm_ptr -- %s %p %p %p %d\n", */
+/* verbose_msg(VDETAIL, "init_comm_ptr -- %s %p %p %p %d\n", */
/* ((weighted_item_t *)(comm_cur_ptr->data))->symbol, */
/* comm_cur_ptr, comm_cur_ptr->prev, comm_cur_ptr->next, */
/* ll_len(comm_cur_ptr)); */
@@ -2625,7 +2687,7 @@ static void finalize_base(void)
for (s = cur_base->section_list ; s ; s = s->next) {
#if 1
if (s->data_type & DT_REORDER) { /* a reordered section */
- fprintf(stderr, "pass1: reordered section %s - xxx\n", ((section_t *)(s->data))->name);
+ verbose_msg(VDETAIL, "pass1: reordered section %s - xxx\n", ((section_t *)(s->data))->name);
lli = ((section_t *)(s->data))->itm_list;
r = 0;
if (lli) {
@@ -2635,7 +2697,7 @@ static void finalize_base(void)
if (r > mr) {
mr = r;
}
- fprintf(stderr, "pass1: reordered section %s - %d\n", ((section_t *)(s->data))->name, r);
+ verbose_msg(VDETAIL, "pass1: reordered section %s - %d\n", ((section_t *)(s->data))->name, r);
continue;
}
#endif
@@ -2652,11 +2714,11 @@ static void finalize_base(void)
lli->idx = i;
assert(!rli);
rli = lli;
- fprintf(stderr, "range pre = %d after = ", i);
+ verbose_msg(VDETAIL, "range pre = %d after = ", i);
i += ((range_item_t *)(lli->data))->length + 1;
#warning check ko_kR and 9
/* ++i; */
- fprintf(stderr, "%d\n", i);
+ verbose_msg(VDETAIL, "%d\n", i);
if (!index2weight_len_inc) { /* ko_KR hack */
final_index += ((range_item_t *)(lli->data))->length + 1;
}
@@ -2726,7 +2788,7 @@ static void finalize_base(void)
/* cur_base->name, lli->idx, final_index_val(w->symbol), w->symbol); */
} else {
-/* fprintf(stderr, "section: %s %d %d\n", ((section_t *)(s->data))->name, */
+/* verbose_msg(VDETAIL, "section: %s %d %d\n", ((section_t *)(s->data))->name, */
/* s->data_type, lli->data_type); */
/* assert(!(s->data_type & DT_REORDER)); */
/* assert(lli->data_type & DT_REORDER); */
@@ -2772,7 +2834,7 @@ static void finalize_base(void)
mr = mi;
for (cli = cur_base->derived_list ; cli ; cli = cli->next) {
cl = (col_locale_t *)(cli->data);
-/* fprintf(stderr, "pass3: %d %s\n", cli->data_type, cl->name); */
+/* verbose_msg(VDETAIL, "pass3: %d %s\n", cli->data_type, cl->name); */
/* fprintf(stdout, "pass3: %d %s\n", cli->data_type, cl->name); */
@@ -2790,7 +2852,7 @@ static void finalize_base(void)
do {
assert(!(lli->data_type & DT_RANGE));
if (lli->data_type & DT_WEIGHTED) {
-/* fprintf(stderr, " %d %d %s\n", lli->data_type, lli->idx, ((weighted_item_t *)(lli->data))->symbol); */
+/* verbose_msg(VDETAIL, " %d %d %s\n", lli->data_type, lli->idx, ((weighted_item_t *)(lli->data))->symbol); */
add_final_col_index(((weighted_item_t *)(lli->data))->symbol);
if (s->data_type & DT_REORDER) {
continue;
@@ -2850,10 +2912,10 @@ static void finalize_base(void)
++wcs2index_count;
if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) {
wcs2index[i] = ++starter_index;
-/* fprintf(stderr, "wcs2index[ %#06x ] = %d (starter)\n", i, wcs2index[i]); */
+/* verbose_msg(VDETAIL, "wcs2index[ %#06x ] = %d (starter)\n", i, wcs2index[i]); */
} else {
wcs2index[i] = (int)(p->data);
-/* fprintf(stderr, "wcs2index[ %#06x ] = %d\n", i, wcs2index[i]); */
+/* verbose_msg(VDETAIL, "wcs2index[ %#06x ] = %d\n", i, wcs2index[i]); */
}
} else {
if ((tfind(buf, &cur_base->root_starter_char, sym_cmp)) != NULL) {
@@ -2898,7 +2960,7 @@ static void finalize_base(void)
smallest = newopt(wcs2index, RANGE, n, &table);
assert(t == smallest);
wcs2colidt_len += smallest;
-/* fprintf(stderr, "smallest = %d wcs2colidt_len = %d\n", smallest, wcs2colidt_len); */
+/* verbose_msg(VDETAIL, "smallest = %d wcs2colidt_len = %d\n", smallest, wcs2colidt_len); */
#if 0
{
@@ -2919,15 +2981,15 @@ static void finalize_base(void)
u >>= __LOCALE_DATA_WCctype_II_SHIFT;
i0 = tbl->ii[u];
- fprintf(stderr, "i0 = %d\n", i0);
+ verbose_msg(VDETAIL, "i0 = %d\n", i0);
i0 <<= __LOCALE_DATA_WCctype_II_SHIFT;
i1 = tbl->ii[__LOCALE_DATA_WCctype_II_LEN + i0 + n];
/* i1 = tbl->ti[i0 + n]; */
- fprintf(stderr, "i1 = %d\n", i1);
+ verbose_msg(VDETAIL, "i1 = %d\n", i1);
i1 <<= __LOCALE_DATA_WCctype_TI_SHIFT;
/* return *(uint16_t *)(&(tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc])); */
- fprintf(stderr, "i2 = %d\n", __LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc);
- fprintf(stderr, "val = %d\n", tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc]);
+ verbose_msg(VDETAIL, "i2 = %d\n", __LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc);
+ verbose_msg(VDETAIL, "val = %d\n", tbl->ii[__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + i1 + sc]);
/* return tbl->ut[i1 + sc]; */
@@ -2944,7 +3006,7 @@ static void finalize_base(void)
base_locale_array[base_locale_len].max_col_index = final_index;
base_locale_array[base_locale_len].max_weight = max_weight;
- fprintf(stderr, "%s: %6u invariant %6u varying %6u derived %6u total %6u max weight %6u wcs2\n",
+ verbose_msg(VDETAIL, "%s: %6u invariant %6u varying %6u derived %6u total %6u max weight %6u wcs2\n",
cur_base->name, num_invariant, num_varying,
tnumnodes(cur_base->root_derived_wi), final_index, max_weight,
wcs2index_count);
@@ -2960,7 +3022,7 @@ static void finalize_base(void)
for (s = cur_base->section_list ; s ; s = s->next) {
#if 1
if (s->data_type & DT_REORDER) {
- fprintf(stderr, "1: skipping reordered section %s\n", ((section_t *)(s->data))->name);
+ verbose_msg(VDETAIL, "1: skipping reordered section %s\n", ((section_t *)(s->data))->name);
continue;
}
#endif
@@ -2988,7 +3050,7 @@ static void finalize_base(void)
for (s = cur_base->section_list ; s ; s = s->next) {
#if 1
if (s->data_type & DT_REORDER) {
- fprintf(stderr, "2: skipping reordered section %s\n", ((section_t *)(s->data))->name);
+ verbose_msg(VDETAIL, "2: skipping reordered section %s\n", ((section_t *)(s->data))->name);
continue;
}
#endif
@@ -3015,7 +3077,7 @@ static void finalize_base(void)
do_starter_lists(cur_base);
-/* fprintf(stderr,"updated final_index = %d\n", final_index); */
+/* verbose_msg(VDETAIL,"updated final_index = %d\n", final_index); */
if (rli) {
base_locale_array[base_locale_len].range_low
@@ -3042,8 +3104,8 @@ static void finalize_base(void)
&& isupper(cur_base->name[4])
) {
- fprintf(stderr, "adding special derived for %s\n", cur_base->name);
-/* fprintf(stderr,"updated final_index = %d\n", final_index); */
+ verbose_msg(VDETAIL, "adding special derived for %s\n", cur_base->name);
+/* verbose_msg(VDETAIL,"updated final_index = %d\n", final_index); */
assert(der_locale_len+1 < DER_LOCALE_LEN);
@@ -3080,7 +3142,7 @@ static void finalize_base(void)
++der_locale_len;
} else {
- fprintf(stderr, "NOT adding special derived for %s\n", cur_base->name);
+ verbose_msg(VDETAIL, "NOT adding special derived for %s\n", cur_base->name);
}
/* now all the derived... */
@@ -3102,7 +3164,7 @@ static void finalize_base(void)
}
/* we do this in two passes... first all sequences, then all single reorders */
for (s = cl->section_list ; s ; s = s->next) {
-/* fprintf(stderr, "doing section %s\n", ((section_t *)(s->data))->name); */
+/* verbose_msg(VDETAIL, "doing section %s\n", ((section_t *)(s->data))->name); */
h = lli = ((section_t *)(s->data))->itm_list;
if (!lli) {
/* fprintf(stdout, "EMPTY ITEM LIST IN SECTION %s\n", ((section_t *)(s->data))->name ); */
@@ -3195,7 +3257,7 @@ static void finalize_base(void)
++base_locale_len;
/* if (tnumnodes(cur_base->root_starter_char)) { */
-/* fprintf(stderr, "starter nodes\n"); */
+/* verbose_msg(VDETAIL, "starter nodes\n"); */
/* twalk(cur_base->root_starter_char, print_starter_node); */
/* } */
}
@@ -3287,7 +3349,7 @@ static void process_starter_node(const void *ptr, VISIT order, int level)
if (++u16_starter < base_locale_array[base_locale_len].num_starters) {
u16_buf[u16_starter] = u16_buf_len;
}
-/* fprintf(stderr, "ucode - %d %d\n", u16_buf[u16_starter-1], u16_buf_len); */
+/* verbose_msg(VDETAIL, "ucode - %d %d\n", u16_buf[u16_starter-1], u16_buf_len); */
} else {
x.string = w->symbol;
x.element = NULL;
@@ -3299,7 +3361,7 @@ static void process_starter_node(const void *ptr, VISIT order, int level)
assert(u16_buf[u16_buf_len-1]);
assert(*s == '"');
n = is_ucode(++s);
-/* fprintf(stderr, "s is |%s| with len %d (%d)\n", s, strlen(s), n); */
+/* verbose_msg(VDETAIL, "s is |%s| with len %d (%d)\n", s, strlen(s), n); */
assert(n);
s += n;
while (*s != '"') {
@@ -3307,7 +3369,7 @@ static void process_starter_node(const void *ptr, VISIT order, int level)
assert(n);
strncpy(buf, s, n+1);
buf[n] = 0;
-/* fprintf(stderr, "buf is |%s| with len %d (%d)\n", buf, strlen(buf), n); */
+/* verbose_msg(VDETAIL, "buf is |%s| with len %d (%d)\n", buf, strlen(buf), n); */
u16_buf[u16_buf_len++] = final_index_val(buf);
assert(u16_buf[u16_buf_len-1]);
s += n;
@@ -3331,7 +3393,7 @@ static void complete_starter_node(const void *ptr, VISIT order, int level)
p = xmalloc(sizeof(weighted_item_t));
p->symbol = w.symbol;
p->weight = NULL;
-/* fprintf(stderr, "complete_starter_node: %s\n", *(const char **) ptr); */
+/* verbose_msg(VDETAIL, "complete_starter_node: %s\n", *(const char **) ptr); */
if (!tsearch(p, p_cl_root_starter_all, starter_all_cmp)) {
error_msg("OUT OF MEMORY");
}
@@ -3377,7 +3439,7 @@ static void do_starter_lists(col_locale_t *cl)
x.element = NULL;
p = tfind(&x, &cur_base->root_colitem, colitem_cmp);
if (!p) {
-/* fprintf(stderr, "Whoa... processing starters for %s and couldn't find %s\n", */
+/* verbose_msg(VDETAIL, "Whoa... processing starters for %s and couldn't find %s\n", */
/* cl->name, w->symbol); */
continue;
}
@@ -3426,13 +3488,13 @@ static void do_starter_lists(col_locale_t *cl)
u16_starter = 0;
u16_buf[0] = u16_buf_len = base_locale_array[base_locale_len].num_starters;
twalk(cl->root_starter_all, process_starter_node);
-/* fprintf(stderr, "s=%d n=%d\n", u16_starter, base_locale_array[base_locale_len].num_starters); */
+/* verbose_msg(VDETAIL, "s=%d n=%d\n", u16_starter, base_locale_array[base_locale_len].num_starters); */
assert(u16_starter == base_locale_array[base_locale_len].num_starters);
#if 0
{ int i;
for (i=0 ; i < u16_buf_len ; i++) {
- fprintf(stderr, "starter %2d: %d - %#06x\n", i, u16_buf[i], u16_buf[i]);
+ verbose_msg(VDETAIL, "starter %2d: %d - %#06x\n", i, u16_buf[i], u16_buf[i]);
}}
#endif
@@ -3451,7 +3513,7 @@ static void do_starter_lists(col_locale_t *cl)
der_locale_array[der_locale_len].multistart_offset = multistart_len;
}
multistart_len += u16_buf_len;
-/* fprintf(stderr, "%s: multistart_len = %d u16_buf_len = %d\n", cl->name, multistart_len, u16_buf_len); */
+/* verbose_msg(VDETAIL, "%s: multistart_len = %d u16_buf_len = %d\n", cl->name, multistart_len, u16_buf_len); */
} else if (!(u16_buf_len > multistart_len)) {
assert(mm);
if (cl == cur_base) {
@@ -3459,7 +3521,7 @@ static void do_starter_lists(col_locale_t *cl)
} else {
der_locale_array[der_locale_len].multistart_offset = ((uint16_t *)(mm)) - multistart_buffer;
}
-/* fprintf(stderr, "%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */
+/* verbose_msg(VDETAIL, "%s: memmem found a match with u16_buf_len = %d\n", cl->name, u16_buf_len); */
}
} else {
assert(!base_locale_array[base_locale_len].num_starters);
@@ -3931,5 +3993,5 @@ static void dump_collate(FILE *fp)
fprintf(fp,"}; /* %8lu */\n", collate_pos);
- fprintf(fp,"#define __lc_collate_data_LEN %d\n\n", collate_pos);
+ fprintf(fp,"#define __lc_collate_data_LEN %lu\n\n", collate_pos);
}
diff --git a/extra/locale/gen_ldc.c b/extra/locale/gen_ldc.c
index 2a121610e..2cedbddaf 100644
--- a/extra/locale/gen_ldc.c
+++ b/extra/locale/gen_ldc.c
@@ -148,8 +148,9 @@ void out_size_t(FILE *f, const size_t *p, size_t n, char *comment)
}
-int main(void)
+int main(int argc, char **argv)
{
+ char *output_file = "locale_data.c";
FILE *lso; /* static object */
int i;
#ifdef __LOCALE_DATA_MAGIC_SIZE
@@ -158,8 +159,10 @@ int main(void)
memset(magic, 0, __LOCALE_DATA_MAGIC_SIZE);
#endif /* __LOCALE_DATA_MAGIC_SIZE */
- if (!(lso = fopen("locale_data.c", "w"))) {
- printf("can't open locale_data.c!\n");
+ if (argc == 2)
+ output_file = argv[1];
+ if (!(lso = fopen(output_file, "w"))) {
+ printf("cannot open output file '%s'!\n", output_file);
return EXIT_FAILURE;
}
diff --git a/extra/locale/gen_locale.c b/extra/locale/gen_locale.c
index 31df4156e..5e8936082 100644
--- a/extra/locale/gen_locale.c
+++ b/extra/locale/gen_locale.c
@@ -4,6 +4,7 @@
#include <ctype.h>
#include <limits.h>
#include <assert.h>
+#include <stdarg.h>
#include <locale.h>
#include <langinfo.h>
#include <nl_types.h>
@@ -15,7 +16,7 @@
#define __LOCALE_DATA_CATEGORIES 6
/* must agree with ordering of gen_mmap! */
-static const unsigned char *lc_names[] = {
+static const char *lc_names[] = {
"LC_CTYPE",
"LC_NUMERIC",
"LC_MONETARY",
@@ -89,6 +90,41 @@ static int default_8bit;
static int total_size;
static int null_count;
+static unsigned verbose = 0;
+enum {
+ VINFO = (1<<0),
+ VDETAIL = (1<<1),
+};
+static int verbose_msg(const unsigned lvl, const char *fmt, ...)
+{
+ va_list arg;
+ int ret = 0;
+
+ if (verbose & lvl) {
+ va_start(arg, fmt);
+ ret = vfprintf(stderr, fmt, arg);
+ va_end(arg);
+ }
+ return ret;
+}
+
+static void error_msg(const char *fmt, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
+static void error_msg(const char *fmt, ...)
+{
+ va_list arg;
+
+ fprintf(stderr, "Error: ");
+/* if (fno >= 0) {
+ fprintf(stderr, "file %s (%d): ", fname[fno], lineno[fno]);
+ } */
+ va_start(arg, fmt);
+ vfprintf(stderr, fmt, arg);
+ va_end(arg);
+ fprintf(stderr, "\n");
+
+ exit(EXIT_FAILURE);
+}
+
static void do_locale_names(void)
{
/* "C" locale name is handled specially by the setlocale code. */
@@ -96,8 +132,7 @@ static void do_locale_names(void)
int i;
if (num_locales <= 1) {
-/* printf("error - only C locale?\n"); */
-/* exit(EXIT_FAILURE); */
+/* error_msg("only C locale?"); */
fprintf(ofp, "static const unsigned char __locales[%d];\n", (3 + __LOCALE_DATA_CATEGORIES));
fprintf(ofp, "static const unsigned char __locale_names5[5];\n");
} else {
@@ -131,8 +166,7 @@ static void do_locale_names(void)
} else if (!strcmp(locales[i].glibc_name, "C")) {
fprintf(ofp, "COL_IDX_C , ");
} else {
- printf("don't know how to handle COL_IDX_ for %s\n", locales[i].glibc_name);
- exit(EXIT_FAILURE);
+ error_msg("don't know how to handle COL_IDX_ for %s", locales[i].glibc_name);
}
#else
fprintf(ofp, "%#4x, ", 0); /* place holder for lc_collate */
@@ -196,8 +230,7 @@ static void do_locale_names(void)
}
}
if (pos[__LOCALE_DATA_CATEGORIES-1] > 255) {
- printf("error - lc_names is too big (%d)\n", pos[__LOCALE_DATA_CATEGORIES-1]);
- exit(EXIT_FAILURE);
+ error_msg("lc_names is too big (%d)", pos[__LOCALE_DATA_CATEGORIES-1]);
}
fprintf(ofp, "#define __LC_ALL\t\t%d\n\n", i);
@@ -218,7 +251,7 @@ static void do_locale_names(void)
fprintf(ofp, ";\n\n");
}
- printf("locale data = %d name data = %d for %d uniq\n",
+ verbose_msg(VDETAIL,"locale data = %d name data = %d for %d uniq\n",
num_locales * (3 + __LOCALE_DATA_CATEGORIES), uniq * 5, uniq);
total_size += num_locales * (3 + __LOCALE_DATA_CATEGORIES) + uniq * 5;
@@ -236,8 +269,7 @@ static void read_at_mappings(void)
if (!(p = strtok(line_buf, " \t\n")) || (*p == '#')) {
if (!fgets(line_buf, sizeof(line_buf), fp)) {
if (ferror(fp)) {
- printf("error reading file\n");
- exit(EXIT_FAILURE);
+ error_msg("reading file");
}
return; /* EOF */
}
@@ -248,17 +280,14 @@ static void read_at_mappings(void)
}
if (*p == '@') {
if (p[1] == 0) {
- printf("error: missing @modifier name\n");
- exit(EXIT_FAILURE);
+ error_msg("missing @modifier name");
}
m = p; /* save the modifier name */
if (!(p = strtok(NULL, " \t\n")) || p[1] || (((unsigned char) *p) > 0x7f)) {
- printf("error: missing or illegal @modifier mapping char\n");
- exit(EXIT_FAILURE);
+ error_msg("missing or illegal @modifier mapping char");
}
if (at_mappings[(int)((unsigned char) *p)]) {
- printf("error: reused @modifier mapping char\n");
- exit(EXIT_FAILURE);
+ error_msg("reused @modifier mapping char");
}
at_mappings[(int)((unsigned char) *p)] = 1;
at_mapto[mc] = *p;
@@ -267,10 +296,10 @@ static void read_at_mappings(void)
strcpy(++at_strings_end, m+1);
at_strings_end += (unsigned char) at_strings_end[-1];
- printf("@mapping: \"%s\" to '%c'\n", m, *p);
+ verbose_msg(VDETAIL,"@mapping: \"%s\" to '%c'\n", m, *p);
if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) {
- printf("ignoring trailing text: %s...\n", p);
+ fprintf(stderr,"ignoring trailing text: %s...\n", p);
}
*line_buf = 0;
continue;
@@ -283,12 +312,12 @@ static void read_at_mappings(void)
p = at_strings;
if (!*p) {
- printf("no @ strings\n");
+ verbose_msg(VDETAIL,"no @ strings\n");
return;
}
do {
- printf("%s\n", p+1);
+ verbose_msg(VDETAIL,"%s\n", p+1);
p += 1 + (unsigned char) *p;
} while (*p);
}
@@ -303,8 +332,7 @@ static void read_enable_disable(void)
if (!(p = strtok(line_buf, " =\t\n")) || (*p == '#')) {
if (!fgets(line_buf, sizeof(line_buf), fp)) {
if (ferror(fp)) {
- printf("error reading file\n");
- exit(EXIT_FAILURE);
+ error_msg("reading file");
}
return; /* EOF */
}
@@ -316,25 +344,23 @@ static void read_enable_disable(void)
if (!strcmp(p, "UTF-8")) {
if (!(p = strtok(NULL, " =\t\n"))
|| ((toupper(*p) != 'Y') && (toupper(*p) != 'N'))) {
- printf("error: missing or illegal UTF-8 setting\n");
- exit(EXIT_FAILURE);
+ error_msg("missing or illegal UTF-8 setting");
}
default_utf8 = (toupper(*p) == 'Y');
- printf("UTF-8 locales are %sabled\n", "dis\0en"+ (default_utf8 << 2));
+ verbose_msg(VINFO,"UTF-8 locales are %sabled\n", "dis\0en"+ (default_utf8 << 2));
} else if (!strcmp(p, "8-BIT")) {
if (!(p = strtok(NULL, " =\t\n"))
|| ((toupper(*p) != 'Y') && (toupper(*p) != 'N'))) {
- printf("error: missing or illegal 8-BIT setting\n");
- exit(EXIT_FAILURE);
+ error_msg("missing or illegal 8-BIT setting");
}
default_8bit = (toupper(*p) == 'Y');
- printf("8-BIT locales are %sabled\n", "dis\0en" + (default_8bit << 2));
+ verbose_msg(VINFO,"8-BIT locales are %sabled\n", "dis\0en" + (default_8bit << 2));
} else {
break;
}
if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) {
- printf("ignoring trailing text: %s...\n", p);
+ fprintf(stderr,"ignoring trailing text: %s...\n", p);
}
*line_buf = 0;
continue;
@@ -354,13 +380,12 @@ static int find_codeset_num(const char *cs)
if (strcmp(cs, "UTF-8") != 0) {
++r;
while (*s && strcmp(__LOCALE_DATA_CODESET_LIST+ ((unsigned char) *s), cs)) {
-/* printf("tried %s\n", __LOCALE_DATA_CODESET_LIST + ((unsigned char) *s)); */
+/* verbose_msg(VDETAIL,"tried %s\n", __LOCALE_DATA_CODESET_LIST + ((unsigned char) *s)); */
++r;
++s;
}
if (!*s) {
- printf("error: unsupported codeset %s\n", cs);
- exit(EXIT_FAILURE);
+ error_msg("unsupported codeset %s", cs);
}
}
return r;
@@ -375,8 +400,7 @@ static int find_codeset_num(const char *cs)
/* 7-bit is 1, UTF-8 is 2, 8-bits are > 2 */
if (strcmp(cs, "UTF-8") != 0) {
- printf("error: unsupported codeset %s\n", cs);
- exit(EXIT_FAILURE);
+ error_msg("unsupported codeset %s", cs);
}
return r;
}
@@ -396,8 +420,7 @@ static int find_at_string_num(const char *as)
p += 1 + (unsigned char) *p;
}
- printf("error: unmapped @string %s\n", as);
- exit(EXIT_FAILURE);
+ error_msg("error: unmapped @string %s", as);
}
static void read_locale_list(void)
@@ -429,8 +452,7 @@ static void read_locale_list(void)
if (!(p = strtok(line_buf, " \t\n")) || (*p == '#')) {
if (!fgets(line_buf, sizeof(line_buf), fp)) {
if (ferror(fp)) {
- printf("error reading file\n");
- exit(EXIT_FAILURE);
+ error_msg("reading file");
}
return; /* EOF */
}
@@ -448,7 +470,7 @@ static void read_locale_list(void)
s += 1 + ((unsigned char) *s);
}
if (i < num_locales) {
- printf("ignoring dulplicate locale name: %s", p);
+ fprintf(stderr,"ignoring duplicate locale name: %s", p);
*line_buf = 0;
continue;
}
@@ -460,24 +482,23 @@ static void read_locale_list(void)
ln = p; /* save locale name */
if (!(p = strtok(NULL, " \t\n"))) {
- printf("error: missing codeset for locale %s\n", ln);
- exit(EXIT_FAILURE);
+ error_msg("missing codeset for locale %s", ln);
}
cs = p;
i = find_codeset_num(p);
if ((i == 2) && !default_utf8) {
- printf("ignoring UTF-8 locale %s\n", ln);
+ fprintf(stderr,"ignoring UTF-8 locale %s\n", ln);
*line_buf = 0;
continue;
} else if ((i > 2) && !default_8bit) {
- printf("ignoring 8-bit codeset locale %s\n", ln);
+ fprintf(stderr,"ignoring 8-bit codeset locale %s\n", ln);
*line_buf = 0;
continue;
}
locales[num_locales].cs = (char)((unsigned char) i);
if (((p = strtok(NULL, " \t\n")) != NULL) && (*p != '#')) {
- printf("ignoring trailing text: %s...\n", p);
+ verbose_msg(VINFO,"ignoring trailing text: %s...\n", p);
}
/* Now go back to locale string for .codeset and @modifier */
@@ -492,19 +513,18 @@ static void read_locale_list(void)
ls = ln;
if ((strlen(ls) != 5) || (ls[2] != '_')) {
- printf("error: illegal locale name %s\n", ls);
- exit(EXIT_FAILURE);
+ error_msg("illegal locale name %s", ls);
}
i = 0; /* value for unspecified codeset */
if (ds) {
i = find_codeset_num(ds);
if ((i == 2) && !default_utf8) {
- printf("ignoring UTF-8 locale %s\n", ln);
+ fprintf(stderr,"ignoring UTF-8 locale %s\n", ln);
*line_buf = 0;
continue;
} else if ((i > 2) && !default_8bit) {
- printf("ignoring 8-bit codeset locale %s\n", ln);
+ fprintf(stderr,"ignoring 8-bit codeset locale %s\n", ln);
*line_buf = 0;
continue;
}
@@ -516,7 +536,7 @@ static void read_locale_list(void)
ls[2] = at_mapto[i];
}
memcpy(locales[num_locales].name, ls, 5);
-/* printf("locale: %5.5s %2d %2d %s\n", */
+/* verbose_msg(VDETAIL,"locale: %5.5s %2d %2d %s\n", */
/* locales[num_locales].name, */
/* locales[num_locales].cs, */
/* locales[num_locales].dot_cs, */
@@ -554,10 +574,24 @@ static int le_cmp(const void *a, const void *b)
int main(int argc, char **argv)
{
- if ((argc != 2) || (!(fp = fopen(*++argv, "r")))) {
- printf("error: missing filename or file!\n");
- return EXIT_FAILURE;
+ char *output_file = NULL;
+
+ while (--argc) {
+ ++argv;
+ if (!strcmp(*argv, "-o")) {
+ --argc;
+ output_file = strdup(*++argv);
+ } else if (!strcmp(*argv, "-v")) {
+ verbose++;
+ } else if (!(fp = fopen(*argv, "r"))) {
+no_inputfile:
+ error_msg("missing filename or file!");
+ }
}
+ if (fp == NULL)
+ goto no_inputfile;
+ if (output_file == NULL)
+ output_file = strdup("locale_tables.h");
at_strings_end = at_strings;
@@ -572,7 +606,7 @@ int main(int argc, char **argv)
#if 0
for (i=0 ; i < num_locales ; i++) {
- printf("locale: %5.5s %2d %2d %s\n",
+ verbose_msg(VDETAIL,"locale: %5.5s %2d %2d %s\n",
locales[i].name,
locales[i].cs,
locales[i].dot_cs,
@@ -580,10 +614,10 @@ int main(int argc, char **argv)
);
}
#endif
-
- if (!(ofp = fopen("locale_tables.h", "w"))) {
- printf("error: can not open locale_tables.h for writing!\n");
- return EXIT_FAILURE;
+ if (argc == 3)
+ output_file = *++argv;
+ if (output_file == NULL || !(ofp = fopen(output_file, "w"))) {
+ error_msg("cannot open output file '%s'!", output_file);
}
do_lc_time();
@@ -596,8 +630,8 @@ int main(int argc, char **argv)
fclose(ofp);
- printf("total data size = %d\n", total_size);
- printf("null count = %d\n", null_count);
+ verbose_msg(VINFO, "total data size = %d\n", total_size);
+ verbose_msg(VDETAIL, "null count = %d\n", null_count);
return EXIT_SUCCESS;
}
@@ -622,12 +656,10 @@ static int addblock(const char *s, size_t n) /* l includes nul terminator */
}
}
if (uniq >= sizeof(idx)) {
- printf("too many uniq strings!\n");
- exit(EXIT_FAILURE);
+ error_msg("too many uniq strings!");
}
if (last + n >= buf + sizeof(buf)) {
- printf("need to increase size of buf!\n");
- exit(EXIT_FAILURE);
+ error_msg("need to increase size of buf!");
}
idx[uniq] = last;
@@ -653,13 +685,11 @@ static int addstring(const char *s)
}
}
if (uniq >= sizeof(idx)) {
- printf("too many uniq strings!\n");
- exit(EXIT_FAILURE);
+ error_msg("too many uniq strings!");
}
l = strlen(s) + 1;
if (last + l >= buf + sizeof(buf)) {
- printf("need to increase size of buf!\n");
- exit(EXIT_FAILURE);
+ error_msg("need to increase size of buf!");
}
idx[uniq] = last;
@@ -670,9 +700,9 @@ static int addstring(const char *s)
}
#define DO_LC_COMMON(CATEGORY) \
- printf("buf-size=%d uniq=%d rows=%d\n", \
+ verbose_msg(VDETAIL, "buf-size=%d uniq=%d rows=%d\n", \
(int)(last - buf), uniq, lc_##CATEGORY##_uniq); \
- printf("total = %d + %d * %d + %d = %d\n", \
+ verbose_msg(VDETAIL, "total = %d + %d * %d + %d = %d\n", \
num_locales, lc_##CATEGORY##_uniq, NUM_NL_##CATEGORY, (int)(last - buf), \
i = num_locales + lc_##CATEGORY##_uniq*NUM_NL_##CATEGORY + (int)(last - buf)); \
total_size += i; \
@@ -701,8 +731,7 @@ static int addstring(const char *s)
#define DL_LC_LOOPTAIL(CATEGORY) \
if (k > NUM_NL_##CATEGORY) { \
- printf("error -- lc_" #CATEGORY " nl_item count > %d!\n", NUM_NL_##CATEGORY); \
- exit(EXIT_FAILURE); \
+ error_msg("lc_" #CATEGORY " nl_item count > %d!", NUM_NL_##CATEGORY); \
} \
{ \
int r; \
@@ -715,8 +744,7 @@ static int addstring(const char *s)
if (r == lc_##CATEGORY##_uniq) { /* new locale row */ \
++lc_##CATEGORY##_uniq; \
if (lc_##CATEGORY##_uniq > 255) { \
- printf("too many unique lc_" #CATEGORY " rows!\n"); \
- exit(EXIT_FAILURE); \
+ error_msg("too many unique lc_" #CATEGORY " rows!"); \
} \
} \
locales[i].lc_##CATEGORY##_row = r; \
@@ -781,8 +809,7 @@ static void dump_table16(const char *name, const int *tbl, int len)
fprintf(ofp, "\n\t");
}
if (tbl[i] != (uint16_t) tbl[i]) {
- printf("error - falls outside uint16 range!\n");
- exit(EXIT_FAILURE);
+ error_msg("falls outside uint16 range!");
}
fprintf(ofp, "%#6x, ", tbl[i]);
}
@@ -823,7 +850,7 @@ static void lc_time_S(int X, int k)
len = p - s;
}
j = addblock(s, len);
-/* if (len > 1) fprintf(stderr, "alt_digit: called addblock with len %zd\n", len); */
+/* if (len > 1) verbose_msg(VDETAIL, "alt_digit: called addblock with len %zd\n", len); */
} else if (X == ERA) {
if (!s) {
s = nulbuf;
@@ -837,7 +864,7 @@ static void lc_time_S(int X, int k)
}
++p;
j = addblock(s, p - s);
-/* if (p-s > 1) fprintf(stderr, "era: called addblock with len %d\n", p-s); */
+/* if (p-s > 1) verbose_msg(VDETAIL, "era: called addblock with len %d\n", p-s); */
} else {
j = addstring(s);
}
@@ -848,8 +875,7 @@ static void lc_time_S(int X, int k)
}
if (m == lc_time_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_time\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_time", k);
}
lc_time_item[k][m] = j;
++lc_time_count[k];
@@ -870,7 +896,7 @@ static void do_lc_time(void)
k = 0;
if (!setlocale(LC_ALL, locales[i].glibc_name)) {
- printf("setlocale(LC_ALL,%s) failed!\n",
+ verbose_msg(VDETAIL, "setlocale(LC_ALL,%s) failed!\n",
locales[i].glibc_name);
}
@@ -973,8 +999,7 @@ static void lc_numeric_S(int X, int k)
++e;
}
if ((e - s) > sizeof(buf)) {
- printf("grouping specifier too long\n");
- exit(EXIT_FAILURE);
+ error_msg("grouping specifier too long");
}
strncpy(buf, s, (e-s));
e = buf + (e-s);
@@ -1000,13 +1025,12 @@ static void lc_numeric_S(int X, int k)
}
if (m == lc_numeric_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_numeric\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_numeric", k);
}
lc_numeric_item[k][m] = j;
++lc_numeric_count[k];
}
-/* printf("\\x%02x", m); */
+/* verbose_msg(VDETAIL, "\\x%02x", m); */
lc_numeric_uniq_X[lc_numeric_uniq][k] = m;
}
@@ -1023,7 +1047,7 @@ static void do_lc_numeric(void)
k = 0;
if (!setlocale(LC_ALL, locales[i].glibc_name)) {
- printf("setlocale(LC_ALL,%s) failed!\n",
+ verbose_msg(VDETAIL,"setlocale(LC_ALL,%s) failed!\n",
locales[i].glibc_name);
}
@@ -1048,7 +1072,7 @@ static int lc_monetary_uniq;
#define DO_NL_S(X) lc_monetary_S(X, k++)
-/* #define DO_NL_C(X) printf("%#02x", (int)(unsigned char)(*nl_langinfo(X))); */
+/* #define DO_NL_C(X) verbose_msg(VDETAIL,"%#02x", (int)(unsigned char)(*nl_langinfo(X))); */
#define DO_NL_C(X) lc_monetary_C(X, k++)
static void lc_monetary_C(int X, int k)
@@ -1068,13 +1092,12 @@ static void lc_monetary_C(int X, int k)
}
if (m == lc_monetary_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_monetary\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_monetary", k);
}
lc_monetary_item[k][m] = j;
++lc_monetary_count[k];
}
-/* printf("\\x%02x", m); */
+/* verbose_msg(VDETAIL,"\\x%02x", m); */
lc_monetary_uniq_X[lc_monetary_uniq][k] = m;
}
@@ -1104,8 +1127,7 @@ static void lc_monetary_S(int X, int k)
++e;
}
if ((e - s) > sizeof(buf)) {
- printf("mon_grouping specifier too long\n");
- exit(EXIT_FAILURE);
+ error_msg("mon_grouping specifier too long");
}
strncpy(buf, s, (e-s));
e = buf + (e-s);
@@ -1131,13 +1153,12 @@ static void lc_monetary_S(int X, int k)
}
if (m == lc_monetary_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_monetary\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_monetary", k);
}
lc_monetary_item[k][m] = j;
++lc_monetary_count[k];
}
-/* printf("\\x%02x", m); */
+/* verbose_msg(VDETAIL,"\\x%02x", m); */
lc_monetary_uniq_X[lc_monetary_uniq][k] = m;
}
@@ -1154,7 +1175,7 @@ static void do_lc_monetary(void)
k = 0;
if (!setlocale(LC_ALL, locales[i].glibc_name)) {
- printf("setlocale(LC_ALL,%s) failed!\n",
+ verbose_msg(VDETAIL,"setlocale(LC_ALL,%s) failed!\n",
locales[i].glibc_name);
}
@@ -1213,13 +1234,12 @@ static void lc_messages_S(int X, int k)
}
if (m == lc_messages_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_messages\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_messages", k);
}
lc_messages_item[k][m] = j;
++lc_messages_count[k];
}
-/* printf("\\x%02x", m); */
+/* verbose_msg(VDETAIL, "\\x%02x", m); */
lc_messages_uniq_X[lc_messages_uniq][k] = m;
}
@@ -1236,7 +1256,7 @@ static void do_lc_messages(void)
k = 0;
if (!setlocale(LC_ALL, locales[i].glibc_name)) {
- printf("setlocale(LC_ALL,%s) failed!\n",
+ verbose_msg(VDETAIL, "setlocale(LC_ALL,%s) failed!\n",
locales[i].glibc_name);
}
@@ -1273,13 +1293,12 @@ static void lc_ctype_S(int X, int k)
}
if (m == lc_ctype_count[k]) { /* new for this nl_item */
if (m > 255) {
- printf("too many nl_item %d entries in lc_ctype\n", k);
- exit(EXIT_FAILURE);
+ error_msg("too many nl_item %d entries in lc_ctype", k);
}
lc_ctype_item[k][m] = j;
++lc_ctype_count[k];
}
-/* printf("\\x%02x", m); */
+/* verbose_msg(VDETAIL, "\\x%02x", m); */
lc_ctype_uniq_X[lc_ctype_uniq][k] = m;
}
@@ -1296,7 +1315,7 @@ static void do_lc_ctype(void)
k = 0;
if (!setlocale(LC_ALL, locales[i].glibc_name)) {
- printf("setlocale(LC_ALL,%s) failed!\n",
+ verbose_msg(VDETAIL, "setlocale(LC_ALL,%s) failed!\n",
locales[i].glibc_name);
}
diff --git a/extra/locale/gen_mmap.c b/extra/locale/gen_mmap.c
index f9bce022c..1cf0bb9e6 100644
--- a/extra/locale/gen_mmap.c
+++ b/extra/locale/gen_mmap.c
@@ -127,7 +127,7 @@ int main(void)
unsigned char *p;
if (!(fp = fopen("locale.mmap", "w"))) {
- printf("error - can't open locale.mmap for writing!");
+ printf("cannot open locale.mmap for writing!");
return EXIT_FAILURE;
}
diff --git a/extra/locale/gen_wc8bit.c b/extra/locale/gen_wc8bit.c
index c6db41231..e16b283a2 100644
--- a/extra/locale/gen_wc8bit.c
+++ b/extra/locale/gen_wc8bit.c
@@ -18,8 +18,10 @@
#ifndef _WCTYPE_H
#define _WCTYPE_H
#endif
-#include UCLIBC_CTYPE_HEADER
+#include "include/bits/uClibc_ctype.h"
+/* TODO: maybe support -v like gen_wctype.c */
+#define verbose_msg(msg...) if (verbose) fprintf(stderr, msg)
/* #define CTYPE_PACKED */
#define UPLOW_IDX_SHIFT 3
@@ -80,7 +82,6 @@ typedef struct {
int main(int argc, char **argv)
{
FILE *fp;
- FILE *out;
charset_data csd[30];
unsigned long max_wchar;
unsigned char *p;
@@ -98,85 +99,107 @@ int main(int argc, char **argv)
int total_size = 0;
if (!setlocale(LC_CTYPE, "en_US.UTF-8")) {
- printf("setlocale(LC_CTYPE,\"en_US.UTF-8\") failed!\n");
- return EXIT_FAILURE;
- }
+ /* Silly foreigners disabling en_US locales */
+ FILE *fp = popen("locale -a", "r");
+ if (!fp)
+ goto locale_failure;
+
+ while (!feof(fp)) {
+ char buf[256];
+ size_t len;
+
+ if (fgets(buf, sizeof(buf) - 10, fp) == NULL)
+ goto locale_failure;
+
+ len = strlen(buf);
+ if (len > 0 && buf[len - 1] == '\n')
+ buf[--len] = '\0';
+ if (len < 5 || strcasecmp(&buf[len-5], ".UTF8") != 0)
+ strcat(buf, ".UTF8");
+ if (setlocale(LC_CTYPE, buf))
+ goto locale_success;
+ }
- if (!(out = fopen("c8tables.h","w"))) {
- printf("error: couldn't open file \"c8tables.h\"\n");
+ locale_failure:
+ printf("could not find a UTF8 locale ... please enable en_US.UTF-8\n");
return EXIT_FAILURE;
+ locale_success:
+ pclose(fp);
}
#if 0
if (argc == 1) {
/* User requested 8-bit codesets, but didn't list any... */
/* Allow to build, just so this feature can be left on in config. */
- fprintf(out, "#ifdef __CTYPE_HAS_8_BIT_LOCALES\n");
- fprintf(out, "#warning ignoring 8 bit codesets request"
+ printf("#ifdef __CTYPE_HAS_8_BIT_LOCALES\n");
+ printf("#warning ignoring 8 bit codesets request"
" as no codesets specified.\n");
- fprintf(out, "#endif\n");
- fprintf(out, "#undef __CTYPE_HAS_8_BIT_LOCALES\n\n");
+ printf("#endif\n");
+ printf("#undef __CTYPE_HAS_8_BIT_LOCALES\n\n");
- fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t0\n");
- fprintf(out, "#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n");
- fclose(out);
+ printf("#define __LOCALE_DATA_NUM_CODESETS\t\t0\n");
+ printf("#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n");
return EXIT_SUCCESS;
}
-/* fprintf(out, "#define __CTYPE_HAS_8_BIT_LOCALES\t1\n\n"); */
- fprintf(out, "#ifdef __CTYPE_HAS_8_BIT_LOCALES\n\n");
+/* printf("#define __CTYPE_HAS_8_BIT_LOCALES\t1\n\n"); */
+ printf("#ifdef __CTYPE_HAS_8_BIT_LOCALES\n\n");
#endif
if (argc == 1) {
- fprintf(out, "#undef __CTYPE_HAS_8_BIT_LOCALES\n\n");
+ printf("#undef __CTYPE_HAS_8_BIT_LOCALES\n\n");
- fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t0\n");
- fprintf(out, "#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n");
+ printf("#define __LOCALE_DATA_NUM_CODESETS\t\t0\n");
+ printf("#define __LOCALE_DATA_CODESET_LIST\t\t\"\"\n");
} else {
- fprintf(out, "#define __CTYPE_HAS_8_BIT_LOCALES\t\t1\n\n");
+ printf("#define __CTYPE_HAS_8_BIT_LOCALES\t\t1\n\n");
}
- fprintf(out, "#define __LOCALE_DATA_Cctype_IDX_SHIFT\t%d\n", CTYPE_IDX_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cctype_IDX_LEN\t\t%d\n", CTYPE_IDX_LEN);
+ printf("#define __LOCALE_DATA_Cctype_IDX_SHIFT\t%d\n", CTYPE_IDX_SHIFT);
+ printf("#define __LOCALE_DATA_Cctype_IDX_LEN\t\t%d\n", CTYPE_IDX_LEN);
#ifdef CTYPE_PACKED
- fprintf(out, "#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN >> 1);
- fprintf(out, "#define __LOCALE_DATA_Cctype_PACKED\t\t1\n");
+ printf("#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN >> 1);
+ printf("#define __LOCALE_DATA_Cctype_PACKED\t\t1\n");
#else
- fprintf(out, "#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN);
- fprintf(out, "#undef __LOCALE_DATA_Cctype_PACKED\n");
+ printf("#define __LOCALE_DATA_Cctype_ROW_LEN\t\t%d\n", CTYPE_ROW_LEN);
+ printf("#undef __LOCALE_DATA_Cctype_PACKED\n");
#endif
- fprintf(out, "\n#define __LOCALE_DATA_Cuplow_IDX_SHIFT\t%d\n", UPLOW_IDX_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cuplow_IDX_LEN\t\t%d\n", UPLOW_IDX_LEN);
- fprintf(out, "#define __LOCALE_DATA_Cuplow_ROW_LEN\t\t%d\n", UPLOW_ROW_LEN);
+ printf("\n#define __LOCALE_DATA_Cuplow_IDX_SHIFT\t%d\n", UPLOW_IDX_SHIFT);
+ printf("#define __LOCALE_DATA_Cuplow_IDX_LEN\t\t%d\n", UPLOW_IDX_LEN);
+ printf("#define __LOCALE_DATA_Cuplow_ROW_LEN\t\t%d\n", UPLOW_ROW_LEN);
#ifdef DO_WIDE_CHAR
- fprintf(out, "\n#define __LOCALE_DATA_Cc2wc_IDX_LEN\t\t%d\n", C2WC_IDX_LEN);
- fprintf(out, "#define __LOCALE_DATA_Cc2wc_IDX_SHIFT\t\t%d\n", C2WC_IDX_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cc2wc_ROW_LEN\t\t%d\n", C2WC_ROW_LEN);
+ printf("\n#define __LOCALE_DATA_Cc2wc_IDX_LEN\t\t%d\n", C2WC_IDX_LEN);
+ printf("#define __LOCALE_DATA_Cc2wc_IDX_SHIFT\t\t%d\n", C2WC_IDX_SHIFT);
+ printf("#define __LOCALE_DATA_Cc2wc_ROW_LEN\t\t%d\n", C2WC_ROW_LEN);
#endif
- fprintf(out, "\ntypedef struct {\n");
- fprintf(out, "\tunsigned char idx8ctype[%d];\n", CTYPE_IDX_LEN);
- fprintf(out, "\tunsigned char idx8uplow[%d];\n", UPLOW_IDX_LEN);
+ printf("\ntypedef struct {\n");
+ printf("\tunsigned char idx8ctype[%d];\n", CTYPE_IDX_LEN);
+ printf("\tunsigned char idx8uplow[%d];\n", UPLOW_IDX_LEN);
#ifdef DO_WIDE_CHAR
- fprintf(out, "\tunsigned char idx8c2wc[%d];\n", C2WC_IDX_LEN);
- fprintf(out, "\tunsigned char idx8wc2c[%d];\n", II_LEN);
+ printf("\tunsigned char idx8c2wc[%d];\n", C2WC_IDX_LEN);
+ printf("\tunsigned char idx8wc2c[%d];\n", II_LEN);
#endif
- fprintf(out, "} __codeset_8_bit_t;\n\n");
+#ifndef __metag__
+ printf("} __codeset_8_bit_t;\n\n");
+#else
+ printf("} __attribute__((__packed__)) __codeset_8_bit_t;\n\n");
+#endif /* __metag__ */
- fprintf(out, "#ifdef WANT_DATA\n\n");
- fprintf(out, "static const __codeset_8_bit_t codeset_8_bit[%d] = {\n", argc-1);
+ printf("#ifdef WANT_DATA\n\n");
+ printf("static const __codeset_8_bit_t codeset_8_bit[%d] = {\n", argc-1);
max_wchar = 0x7f;
numsets = 0;
codeset_index[0] = 0;
while (--argc) {
if (!(fp = fopen(*++argv,"r"))) {
- printf("error: couldn't open file \"%s\"\n", *argv);
+ fprintf(stderr, "cannot open file \"%s\"\n", *argv);
return EXIT_FAILURE;
}
- printf("processing %s... ", *argv);
+ fprintf(stderr, "processing %s... ", *argv);
{
char *s0;
@@ -202,12 +225,12 @@ int main(int argc, char **argv)
/* } */
if (numsets >= sizeof(codeset_index)) {
- printf("error - too many codesets!\n");
+ fprintf(stderr, "error - too many codesets!\n");
return EXIT_FAILURE;
}
if (codeset_list_end + n + 1 + numsets + 1 + 1 >= 256) {
- printf("error - codeset list to big!\n");
+ fprintf(stderr, "error - codeset list to big!\n");
return EXIT_FAILURE;
}
@@ -216,11 +239,11 @@ int main(int argc, char **argv)
codeset_list_end += (n+1);
codeset_list[codeset_list_end - 1] = 0;
- fprintf(out, "\t{ /* %.*s */", n, s0);
+ printf("\t{ /* %.*s */", n, s0);
}
- memset(&csd[numsets],sizeof(charset_data),0);
- memset(xi, sizeof(xi), 0);
+ memset(&csd[numsets], 0, sizeof(charset_data));
+ memset(xi, 0, sizeof(xi));
{
unsigned long c, wc;
int lines;
@@ -228,7 +251,7 @@ int main(int argc, char **argv)
while (fgets(buf,sizeof(buf),fp)) {
if ((2 != sscanf(buf, "{ %lx , %lx", &c, &wc))
|| (c >= 256) || (wc > MAX_WCHAR)) {
- printf("error: scanf failure! \"%s\"\n", buf);
+ fprintf(stderr, "error: scanf failure! \"%s\"\n", buf);
return EXIT_FAILURE;
}
@@ -236,7 +259,7 @@ int main(int argc, char **argv)
if (c <= 0x7f) { /* check the 7bit entries but don't store */
if (c != wc) {
- printf("error: c != wc in %s\n", buf);
+ fprintf(stderr, "error: c != wc in %s\n", buf);
return EXIT_FAILURE;
}
csd[numsets].c2w[c] = wc;
@@ -253,7 +276,7 @@ int main(int argc, char **argv)
}
++lines;
}
- printf("%d lines ", lines);
+ fprintf(stderr, "%d lines ", lines);
for (i = 0 ; i <= MAX_WCHAR ; i += (1 << TT_SHIFT)) {
p = &csd[numsets].w2c[i];
@@ -281,17 +304,17 @@ int main(int argc, char **argv)
++ti_num;
}
csd[numsets].ii[i >> TI_SHIFT] = j;
-/* printf("%d ", i >> TI_SHIFT); */
+/* fprintf(stderr, "%d ", i >> TI_SHIFT); */
}
#if 1
- fprintf(out, "\n\t\t/* idx8ctype data */\n\t\t{");
+ printf("\n\t\t/* idx8ctype data */\n\t\t{");
for (i = 128 ; i < 256 ; i++) {
wchar_t c;
unsigned int d;
/* if (!(i & 0x7)) { */
-/* fprintf(out, "\n"); */
+/* printf("\n"); */
/* } */
c = csd[numsets].c2w[i];
@@ -348,7 +371,7 @@ int main(int argc, char **argv)
}
if (j == n_ctype_rows) { /* new entry */
if (++n_ctype_rows > 256) {
- printf("error -- to many ctype rows!\n");
+ fprintf(stderr, "error -- to many ctype rows!\n");
return EXIT_FAILURE;
}
memcpy(p, row, CTYPE_ROW_LEN);
@@ -357,23 +380,23 @@ int main(int argc, char **argv)
if (!((i >> CTYPE_IDX_SHIFT) & 0x7)
&& (i != (127 + CTYPE_ROW_LEN))
) {
- fprintf(out, "\n\t\t ");
+ printf("\n\t\t ");
}
- fprintf(out, " %#4x,", j);
+ printf(" %#4x,", j);
}
#else
- fprintf(out, " %#4x,", d);
+ printf(" %#4x,", d);
#endif
}
#endif
- fprintf(out, " }");
+ printf(" }");
#if 1
- fprintf(out, ",\n\t\t/* idx8uplow data */\n\t\t{");
+ printf(",\n\t\t/* idx8uplow data */\n\t\t{");
for (i = 128 ; i < 256 ; i++) {
wchar_t c, u, l;
/* if (!(i & 0x7)) { */
-/* fprintf(out, "\n"); */
+/* printf("\n"); */
/* } */
c = csd[numsets].c2w[i];
if ((c != 0) || 1) {
@@ -391,7 +414,7 @@ int main(int argc, char **argv)
/* if ((((u-i) < CHAR_MIN) || ((u-i) > CHAR_MAX)) */
/* || (((i-l) < CHAR_MIN) || ((i-l) > CHAR_MAX)) */
/* ) { */
-/* printf("error - uplow diff out of range! %d %ld %ld\n", */
+/* fprintf(stderr, "error - uplow diff out of range! %d %ld %ld\n", */
/* i, u, l); */
/* return EXIT_FAILURE; */
/* } */
@@ -407,7 +430,7 @@ int main(int argc, char **argv)
}
if (j == n_uplow_rows) { /* new entry */
if (++n_uplow_rows > 256) {
- printf("error -- to many uplow rows!\n");
+ fprintf(stderr, "error -- to many uplow rows!\n");
return EXIT_FAILURE;
}
memcpy(p, row, UPLOW_ROW_LEN);
@@ -416,21 +439,21 @@ int main(int argc, char **argv)
if (!((i >> UPLOW_IDX_SHIFT) & 0x7)
&& (i != (127 + UPLOW_ROW_LEN))
) {
- fprintf(out, "\n\t\t ");
+ printf("\n\t\t ");
}
- fprintf(out, " %#4x,", j);
+ printf(" %#4x,", j);
}
#elif 0
if (!(i & 0x7) && i) {
- fprintf(out, "\n");
+ printf("\n");
}
- fprintf(out, " %4ld,", (l==i) ? (u-i) : (i-l));
-/* fprintf(out, " %4ld,", (l==i) ? u : l); */
+ printf(" %4ld,", (l==i) ? (u-i) : (i-l));
+/* printf(" %4ld,", (l==i) ? u : l); */
#else
if ((u != i) || (l != i)) {
#if 0
- fprintf(out, " %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, \n",
+ printf(" %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, %#08lx, \n",
(unsigned long) i,
(unsigned long) c,
(unsigned long) l,
@@ -439,7 +462,7 @@ int main(int argc, char **argv)
(unsigned long) towupper(c));
#else
- fprintf(out, " %#08lx, %8ld, %d, %8ld, %d, %#08lx\n",
+ printf(" %#08lx, %8ld, %d, %8ld, %d, %#08lx\n",
(unsigned long) i,
(long) (l - i),
iswupper(c),
@@ -451,15 +474,15 @@ int main(int argc, char **argv)
#endif
}
}
- fprintf(out, " }");
+ printf(" }");
#endif
#ifndef DO_WIDE_CHAR
- fprintf(out,"\n");
+ printf("\n");
#else /* DO_WIDE_CHAR */
#if 1
- fprintf(out, ",\n\t\t/* idx8c2wc data */\n\t\t{");
+ printf(",\n\t\t/* idx8c2wc data */\n\t\t{");
for (i = 128 ; i < 256 ; i++) {
#if 1
wrow[i & (C2WC_ROW_LEN-1)] = csd[numsets].c2w[i];
@@ -473,7 +496,7 @@ int main(int argc, char **argv)
}
if (j == n_c2wc_rows) { /* new entry */
if (++n_c2wc_rows > 256) {
- printf("error -- to many c2wc rows!\n");
+ fprintf(stderr, "error -- to many c2wc rows!\n");
return EXIT_FAILURE;
}
memcpy(p, (char *) wrow, 2*C2WC_ROW_LEN);
@@ -482,107 +505,107 @@ int main(int argc, char **argv)
if (!((i >> C2WC_IDX_SHIFT) & 0x7)
&& (i != (127 + C2WC_ROW_LEN))
) {
- fprintf(out, "\n\t\t ");
+ printf("\n\t\t ");
}
- fprintf(out, " %#4x,", j);
+ printf(" %#4x,", j);
}
#else
if (!(i & 0x7) && i) {
- fprintf(out, "\n");
+ printf("\n");
}
- fprintf(out, " %#6lx,", csd[numsets].c2w[i]);
+ printf(" %#6lx,", csd[numsets].c2w[i]);
#endif
}
- fprintf(out, " },\n");
+ printf(" },\n");
#endif
#if 1
-/* fprintf(out, "\nII_LEN = %d\n", II_LEN); */
- fprintf(out, "\t\t/* idx8wc2c data */\n\t\t{");
+/* fprintf(stderr, "\nII_LEN = %d\n", II_LEN); */
+ printf("\t\t/* idx8wc2c data */\n\t\t{");
for (i = 0 ; i < II_LEN ; i++) {
if (!(i & 0x7) && i) {
- fprintf(out, "\n\t\t ");
+ printf("\n\t\t ");
}
- fprintf(out, " %#4x,", csd[numsets].ii[i]);
+ printf(" %#4x,", csd[numsets].ii[i]);
}
- fprintf(out, " }\n");
+ printf(" }\n");
#endif
#endif /* DO_WIDE_CHAR */
- fprintf(out, "\t},\n");
+ printf("\t},\n");
}
++numsets;
- printf("done\n");
+ fprintf(stderr, "done\n");
}
- fprintf(out, "};\n");
- fprintf(out, "\n#endif /* WANT_DATA */\n");
+ printf("};\n");
+ printf("\n#endif /* WANT_DATA */\n");
#ifdef DO_WIDE_CHAR
- fprintf(out, "\n");
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_DOMAIN_MAX\t%#x\n", RANGE);
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_SHIFT\t\t%d\n", TI_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_SHIFT\t\t%d\n", TT_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_II_LEN\t\t%d\n", II_LEN);
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_TI_LEN\t\t%d\n", ti_num << TI_SHIFT);
- fprintf(out, "#define __LOCALE_DATA_Cwc2c_TT_LEN\t\t%d\n", tt_num << TT_SHIFT);
- fprintf(out, "\n");
-
- fprintf(out, "\n#define __LOCALE_DATA_Cwc2c_TBL_LEN\t\t%d\n",
+ printf("\n");
+ printf("#define __LOCALE_DATA_Cwc2c_DOMAIN_MAX\t%#x\n", RANGE);
+ printf("#define __LOCALE_DATA_Cwc2c_TI_SHIFT\t\t%d\n", TI_SHIFT);
+ printf("#define __LOCALE_DATA_Cwc2c_TT_SHIFT\t\t%d\n", TT_SHIFT);
+ printf("#define __LOCALE_DATA_Cwc2c_II_LEN\t\t%d\n", II_LEN);
+ printf("#define __LOCALE_DATA_Cwc2c_TI_LEN\t\t%d\n", ti_num << TI_SHIFT);
+ printf("#define __LOCALE_DATA_Cwc2c_TT_LEN\t\t%d\n", tt_num << TT_SHIFT);
+ printf("\n");
+
+ printf("\n#define __LOCALE_DATA_Cwc2c_TBL_LEN\t\t%d\n",
(ti_num << TI_SHIFT) + (tt_num << TT_SHIFT));
- fprintf(out, "#ifdef WANT_DATA\n\n");
- fprintf(out, "static const unsigned char __LOCALE_DATA_Cwc2c_data[%d] = {\n",
+ printf("#ifdef WANT_DATA\n\n");
+ printf("static const unsigned char __LOCALE_DATA_Cwc2c_data[%d] = {\n",
(ti_num << TI_SHIFT) + (tt_num << TT_SHIFT));
- fprintf(out, "\t/* ti_table */\n\t");
+ printf("\t/* ti_table */\n\t");
for (i=0 ; i < ti_num << TI_SHIFT ; i++) {
if (!(i & 7) && i) {
- fprintf(out, "\n\t");
+ printf("\n\t");
}
- fprintf(out, " %#4x,", ti[i]);
+ printf(" %#4x,", ti[i]);
}
- fprintf(out, "\n");
- fprintf(out, "\t/* tt_table */\n\t");
+ printf("\n");
+ printf("\t/* tt_table */\n\t");
for (i=0 ; i < tt_num << TT_SHIFT ; i++) {
if (!(i & 7) && i) {
- fprintf(out, "\n\t");
+ printf("\n\t");
}
- fprintf(out, " %#4x,", tt[i]);
+ printf(" %#4x,", tt[i]);
}
- fprintf(out, "\n};\n");
+ printf("\n};\n");
- fprintf(out, "\n#endif /* WANT_DATA */\n");
+ printf("\n#endif /* WANT_DATA */\n");
#endif /* DO_WIDE_CHAR */
- fprintf(out, "\n#define __LOCALE_DATA_Cuplow_TBL_LEN\t\t%d\n",
+ printf("\n#define __LOCALE_DATA_Cuplow_TBL_LEN\t\t%d\n",
n_uplow_rows * UPLOW_ROW_LEN);
- fprintf(out, "\n#ifdef WANT_DATA\n\n");
+ printf("\n#ifdef WANT_DATA\n\n");
- fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cuplow_data[%d] = {\n",
+ printf("\nstatic const unsigned char __LOCALE_DATA_Cuplow_data[%d] = {\n",
n_uplow_rows * UPLOW_ROW_LEN);
p = uplow_tbl;
for (j=0 ; j < n_uplow_rows ; j++) {
- fprintf(out, "\t");
+ printf("\t");
for (i=0 ; i < UPLOW_ROW_LEN ; i++) {
- fprintf(out, " %#4x,", (unsigned int)((unsigned char) p[i]));
+ printf(" %#4x,", (unsigned int)((unsigned char) p[i]));
}
- fprintf(out, "\n");
+ printf("\n");
p += UPLOW_ROW_LEN;
}
- fprintf(out, "};\n");
+ printf("};\n");
- fprintf(out, "\n#endif /* WANT_DATA */\n");
- fprintf(out, "\n#define __LOCALE_DATA_Cctype_TBL_LEN\t\t%d\n",
+ printf("\n#endif /* WANT_DATA */\n");
+ printf("\n#define __LOCALE_DATA_Cctype_TBL_LEN\t\t%d\n",
#ifdef CTYPE_PACKED
n_ctype_rows * CTYPE_ROW_LEN / 2
#else
n_ctype_rows * CTYPE_ROW_LEN
#endif
);
- fprintf(out, "\n#ifdef WANT_DATA\n\n");
+ printf("\n#ifdef WANT_DATA\n\n");
- fprintf(out, "\nstatic const unsigned char __LOCALE_DATA_Cctype_data[%d] = {\n",
+ printf("\nstatic const unsigned char __LOCALE_DATA_Cctype_data[%d] = {\n",
#ifdef CTYPE_PACKED
n_ctype_rows * CTYPE_ROW_LEN / 2
#else
@@ -591,59 +614,59 @@ int main(int argc, char **argv)
);
p = ctype_tbl;
for (j=0 ; j < n_ctype_rows ; j++) {
- fprintf(out, "\t");
+ printf("\t");
for (i=0 ; i < CTYPE_ROW_LEN ; i++) {
#ifdef CTYPE_PACKED
- fprintf(out, " %#4x,", (unsigned int)(p[i] + (p[i+1] << 4)));
+ printf(" %#4x,", (unsigned int)(p[i] + (p[i+1] << 4)));
++i;
#else
- fprintf(out, " %#4x,", (unsigned int)p[i]);
+ printf(" %#4x,", (unsigned int)p[i]);
#endif
}
- fprintf(out, "\n");
+ printf("\n");
p += CTYPE_ROW_LEN;
}
- fprintf(out, "};\n");
+ printf("};\n");
- fprintf(out, "\n#endif /* WANT_DATA */\n");
+ printf("\n#endif /* WANT_DATA */\n");
#ifdef DO_WIDE_CHAR
- fprintf(out, "\n#define __LOCALE_DATA_Cc2wc_TBL_LEN\t\t%d\n",
+ printf("\n#define __LOCALE_DATA_Cc2wc_TBL_LEN\t\t%d\n",
n_c2wc_rows * C2WC_ROW_LEN);
- fprintf(out, "\n#ifdef WANT_DATA\n\n");
+ printf("\n#ifdef WANT_DATA\n\n");
- fprintf(out, "\nstatic const unsigned short __LOCALE_DATA_Cc2wc_data[%d] = {\n",
+ printf("\nstatic const unsigned short __LOCALE_DATA_Cc2wc_data[%d] = {\n",
n_c2wc_rows * C2WC_ROW_LEN);
p = (unsigned char *) c2wc_tbl;
for (j=0 ; j < n_c2wc_rows ; j++) {
- fprintf(out, "\t");
+ printf("\t");
for (i=0 ; i < C2WC_ROW_LEN ; i++) {
- fprintf(out, " %#6x,", (unsigned int)(((unsigned short *)p)[i]));
+ printf(" %#6x,", (unsigned int)(((unsigned short *)p)[i]));
}
- fprintf(out, "\n");
+ printf("\n");
p += 2*C2WC_ROW_LEN;
}
- fprintf(out, "};\n");
- fprintf(out, "\n#endif /* WANT_DATA */\n");
+ printf("};\n");
+ printf("\n#endif /* WANT_DATA */\n");
#endif /* DO_WIDE_CHAR */
- fprintf(out, "\n\n");
+ printf("\n\n");
- fprintf(out, "#define __LOCALE_DATA_NUM_CODESETS\t\t%d\n", numsets);
- fprintf(out, "#define __LOCALE_DATA_CODESET_LIST \\\n\t\"");
+ printf("#define __LOCALE_DATA_NUM_CODESETS\t\t%d\n", numsets);
+ printf("#define __LOCALE_DATA_CODESET_LIST \\\n\t\"");
for (i=0 ; i < numsets ; i++) {
- fprintf(out, "\\x%02x", numsets + 1 + (unsigned char) codeset_index[i]);
+ printf("\\x%02x", numsets + 1 + (unsigned char) codeset_index[i]);
if (((i & 7) == 7) && (i + 1 < numsets)) {
- fprintf(out, "\" \\\n\t\"");
+ printf("\" \\\n\t\"");
}
}
- fprintf(out, "\" \\\n\t\"\\0\"");
+ printf("\" \\\n\t\"\\0\"");
for (i=0 ; i < numsets ; i++) {
- fprintf(out, " \\\n\t\"%s\\0\"",
+ printf(" \\\n\t\"%s\\0\"",
codeset_list + ((unsigned char)codeset_index[i]));
}
- fprintf(out, "\n\n");
+ printf("\n\n");
for (i=0 ; i < numsets ; i++) {
char buf[30];
char *z;
@@ -653,24 +676,22 @@ int main(int argc, char **argv)
*z = '_';
}
}
- fprintf(out, "#define __CTYPE_HAS_CODESET_%s\n", buf);
+ printf("#define __CTYPE_HAS_CODESET_%s\n", buf);
}
#ifdef DO_WIDE_CHAR
- fprintf(out, "#define __CTYPE_HAS_CODESET_UTF_8\n");
+ printf("#define __CTYPE_HAS_CODESET_UTF_8\n");
#endif /* DO_WIDE_CHAR */
#if 0
- fprintf(out, "\n#endif /* __CTYPE_HAS_8_BIT_LOCALES */\n\n");
+ printf("\n#endif /* __CTYPE_HAS_8_BIT_LOCALES */\n\n");
#endif
- fclose(out);
-
total_size = 0;
#ifdef DO_WIDE_CHAR
- printf("tt_num = %d ti_num = %d\n", tt_num, ti_num);
- printf("max_wchar = %#lx\n", max_wchar);
+ fprintf(stderr, "tt_num = %d ti_num = %d\n", tt_num, ti_num);
+ fprintf(stderr, "max_wchar = %#lx\n", max_wchar);
- printf("size is %d * %d + %d * %d + %d * %d = %d\n",
+ fprintf(stderr, "size is %d * %d + %d * %d + %d * %d = %d\n",
tt_num, 1 << TT_SHIFT, ti_num, 1 << TI_SHIFT,
((MAX_WCHAR >> (TT_SHIFT + TI_SHIFT)) + 1), numsets,
j = tt_num * (1 << TT_SHIFT) + ti_num * (1 << TI_SHIFT)
@@ -684,26 +705,26 @@ int main(int argc, char **argv)
i = 1;
#endif
- printf("ctype - CTYPE_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n",
+ fprintf(stderr, "ctype - CTYPE_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n",
CTYPE_IDX_SHIFT, numsets, CTYPE_IDX_LEN, n_ctype_rows, CTYPE_ROW_LEN / i,
j = numsets * CTYPE_IDX_LEN + n_ctype_rows * CTYPE_ROW_LEN / i);
total_size += j;
- printf("uplow - UPLOW_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n",
+ fprintf(stderr, "uplow - UPLOW_IDX_SHIFT = %d -- %d * %d + %d * %d = %d\n",
UPLOW_IDX_SHIFT, numsets, UPLOW_IDX_LEN, n_uplow_rows, UPLOW_ROW_LEN,
j = numsets * UPLOW_IDX_LEN + n_uplow_rows * UPLOW_ROW_LEN);
total_size += j;
#ifdef DO_WIDE_CHAR
- printf("c2wc - C2WC_IDX_SHIFT = %d -- %d * %d + 2 * %d * %d = %d\n",
+ fprintf(stderr, "c2wc - C2WC_IDX_SHIFT = %d -- %d * %d + 2 * %d * %d = %d\n",
C2WC_IDX_SHIFT, numsets, C2WC_IDX_LEN, n_c2wc_rows, C2WC_ROW_LEN,
j = numsets * C2WC_IDX_LEN + 2 * n_c2wc_rows * C2WC_ROW_LEN);
total_size += j;
#endif /* DO_WIDE_CHAR */
- printf("total size = %d\n", total_size);
+ fprintf(stderr, "total size = %d\n", total_size);
/* for (i=0 ; i < numsets ; i++) { */
/* printf("codeset_index[i] = %d codeset_list[ci[i]] = \"%s\"\n", */
diff --git a/extra/locale/gen_wctype.c b/extra/locale/gen_wctype.c
index 085ec51b1..d5b5c5c28 100644
--- a/extra/locale/gen_wctype.c
+++ b/extra/locale/gen_wctype.c
@@ -14,13 +14,7 @@
#include <wchar.h>
#include <ctype.h>
-#ifndef _CTYPE_H
-#define _CTYPE_H
-#endif
-#ifndef _WCTYPE_H
-#define _WCTYPE_H
-#endif
-#include UCLIBC_CTYPE_HEADER
+#include "include/bits/uClibc_charclass.h"
/* 0x9 : space blank */
/* 0xa : space */
@@ -62,7 +56,6 @@
/* typecount[15] = 0 empty_slot */
-
/* Set to #if 0 to restrict wchars to 16 bits. */
#if 1
#define RANGE 0x2ffffUL
@@ -72,74 +65,22 @@
#define RANGE 0xffffUL /* Restrict for 16-bit wchar_t... */
#endif
-#if 0
-/* Classification codes. */
-
-static const char *typename[] = {
- "C_unclassified",
- "C_alpha_nonupper_nonlower",
- "C_alpha_lower",
- "C_alpha_upper_lower",
- "C_alpha_upper",
- "C_digit",
- "C_punct",
- "C_graph",
- "C_print_space_nonblank",
- "C_print_space_blank",
- "C_space_nonblank_noncntrl",
- "C_space_blank_noncntrl",
- "C_cntrl_space_nonblank",
- "C_cntrl_space_blank",
- "C_cntrl_nonspace",
- "empty_slot"
-};
-#endif
-
-#if 0
-/* Taking advantage of the C99 mutual-exclusion guarantees for the various
- * (w)ctype classes, including the descriptions of printing and control
- * (w)chars, we can place each in one of the following mutually-exlusive
- * subsets. Since there are less than 16, we can store the data for
- * each (w)chars in a nibble. In contrast, glibc uses an unsigned int
- * per (w)char, with one bit flag for each is* type. While this allows
- * a simple '&' operation to determine the type vs. a range test and a
- * little special handling for the "blank" and "xdigit" types in my
- * approach, it also uses 8 times the space for the tables on the typical
- * 32-bit archs we supported.*/
-enum {
- __CTYPE_unclassified = 0,
- __CTYPE_alpha_nonupper_nonlower,
- __CTYPE_alpha_lower,
- __CTYPE_alpha_upper_lower,
- __CTYPE_alpha_upper,
- __CTYPE_digit,
- __CTYPE_punct,
- __CTYPE_graph,
- __CTYPE_print_space_nonblank,
- __CTYPE_print_space_blank,
- __CTYPE_space_nonblank_noncntrl,
- __CTYPE_space_blank_noncntrl,
- __CTYPE_cntrl_space_nonblank,
- __CTYPE_cntrl_space_blank,
- __CTYPE_cntrl_nonspace,
-};
-#endif
-
-#define __CTYPE_isxdigit(D,X) \
- (__CTYPE_isdigit(D) || (((unsigned int)(((X)|0x20) - 'a')) <= 5))
-
-#define mywalnum(x) __CTYPE_isalnum(d)
-#define mywalpha(x) __CTYPE_isalpha(d)
-#define mywblank(x) __CTYPE_isblank(d)
-#define mywcntrl(x) __CTYPE_iscntrl(d)
-#define mywdigit(x) __CTYPE_isdigit(d)
-#define mywgraph(x) __CTYPE_isgraph(d)
-#define mywlower(x) __CTYPE_islower(d)
-#define mywprint(x) __CTYPE_isprint(d)
-#define mywpunct(x) __CTYPE_ispunct(d)
-#define mywspace(x) __CTYPE_isspace(d)
-#define mywupper(x) __CTYPE_isupper(d)
-#define mywxdigit(x) __CTYPE_isxdigit(d,x)
+/* Some macros that test for various (w)ctype classes when passed one of the
+ * designator values enumerated above. */
+#define mywalnum(D,C) ((unsigned)(D - 1) <= (__CTYPE_digit - 1))
+#define mywalpha(D,C) ((unsigned)(D - 1) <= (__CTYPE_alpha_upper - 1))
+#define mywblank(D,C) ((unsigned)(D - __CTYPE_print_space_nonblank) <= 5 && (D & 1))
+#define mywcntrl(D,C) ((unsigned)(D - __CTYPE_cntrl_space_nonblank) <= 2)
+#define mywdigit(D,C) (D == __CTYPE_digit)
+#define mywgraph(D,C) ((unsigned)(D - 1) <= (__CTYPE_graph - 1))
+#define mywlower(D,C) ((unsigned)(D - __CTYPE_alpha_lower) <= 1)
+#define mywprint(D,C) ((unsigned)(D - 1) <= (__CTYPE_print_space_blank - 1))
+#define mywpunct(D,C) (D == __CTYPE_punct)
+#define mywspace(D,C) ((unsigned)(D - __CTYPE_print_space_nonblank) <= 5)
+#define mywupper(D,C) ((unsigned)(D - __CTYPE_alpha_upper_lower) <= 1)
+/* #define mywxdigit(D,C) -- isxdigit is untestable this way.
+ * But that's ok as isxdigit() (and isdigit() too) are locale-invariant. */
+#define mywxdigit(D,C) (mywdigit(D,C) || (unsigned)(((C) | 0x20) - 'a') <= 5)
typedef struct {
short l;
@@ -159,48 +100,50 @@ typedef struct {
unsigned char *ut;
} table_data;
+static unsigned verbose;
+#define verbose_msg(msg...) if (verbose) fprintf(stderr, msg)
-void output_table(FILE *fp, const char *name, table_data *tbl)
+void output_table(const char *name, table_data *tbl)
{
size_t i;
- fprintf(fp, "#define __LOCALE_DATA_WC%s_II_LEN %7u\n", name, tbl->ii_len);
- fprintf(fp, "#define __LOCALE_DATA_WC%s_TI_LEN %7u\n", name, tbl->ti_len);
- fprintf(fp, "#define __LOCALE_DATA_WC%s_UT_LEN %7u\n", name, tbl->ut_len);
+ printf("#define __LOCALE_DATA_WC%s_II_LEN %7u\n", name, tbl->ii_len);
+ printf("#define __LOCALE_DATA_WC%s_TI_LEN %7u\n", name, tbl->ti_len);
+ printf("#define __LOCALE_DATA_WC%s_UT_LEN %7u\n", name, tbl->ut_len);
- fprintf(fp, "#define __LOCALE_DATA_WC%s_II_SHIFT %7u\n", name, tbl->ii_shift);
- fprintf(fp, "#define __LOCALE_DATA_WC%s_TI_SHIFT %7u\n", name, tbl->ti_shift);
+ printf("#define __LOCALE_DATA_WC%s_II_SHIFT %7u\n", name, tbl->ii_shift);
+ printf("#define __LOCALE_DATA_WC%s_TI_SHIFT %7u\n", name, tbl->ti_shift);
- fprintf(fp, "\n#ifdef WANT_WC%s_data\n", name);
+ printf("\n#ifdef WANT_WC%s_data\n", name);
i = tbl->ii_len + tbl->ti_len + tbl->ut_len;
- fprintf(fp, "\nstatic const unsigned char __LOCALE_DATA_WC%s_data[%zu] = {", name, i);
- for (i=0 ; i < tbl->ii_len ; i++) {
+ printf("\nstatic const unsigned char __LOCALE_DATA_WC%s_data[%zu] = {", name, i);
+ for (i = 0; i < tbl->ii_len; i++) {
if (i % 12 == 0) {
- fprintf(fp, "\n");
+ printf("\n");
}
- fprintf(fp, " %#04x,", tbl->ii[i]);
+ printf(" %#04x,", tbl->ii[i]);
}
- for (i=0 ; i < tbl->ti_len ; i++) {
+ for (i = 0; i < tbl->ti_len; i++) {
if (i % 12 == 0) {
- fprintf(fp, "\n");
+ printf("\n");
}
- fprintf(fp, " %#04x,", tbl->ti[i]);
+ printf(" %#04x,", tbl->ti[i]);
}
- for (i=0 ; i < tbl->ut_len ; i++) {
+ for (i = 0; i < tbl->ut_len; i++) {
if (i % 12 == 0) {
- fprintf(fp, "\n");
+ printf("\n");
}
- fprintf(fp, " %#04x,", tbl->ut[i]);
+ printf(" %#04x,", tbl->ut[i]);
}
- fprintf(fp, "\n};\n\n");
+ printf("\n};\n\n");
- fprintf(fp, "#endif /* WANT_WC%s_data */\n\n", name);
+ printf("#endif /* WANT_WC%s_data */\n\n", name);
}
static void dump_table_data(table_data *tbl)
{
- printf("ii_shift = %d ti_shift = %d\n"
+ verbose_msg("ii_shift = %d ti_shift = %d\n"
"ii_len = %d ti_len = %d ut_len = %d\n"
"total = %d\n",
tbl->ii_shift, tbl->ti_shift,
@@ -231,10 +174,11 @@ int main(int argc, char **argv)
uldiff_entry uldiff[MAXTO];
table_data cttable;
table_data ultable;
+#if 0
table_data combtable;
table_data widthtable;
long int last_comb = 0;
-
+#endif
unsigned char wct[(RANGE/2)+1]; /* wctype table (nibble per wchar) */
unsigned char ult[RANGE+1]; /* upper/lower table */
unsigned char combt[(RANGE/4)+1]; /* combining */
@@ -249,7 +193,7 @@ int main(int argc, char **argv)
#define INIT_TYPENAME(X) typename[__CTYPE_##X] = "C_" #X
- for (i=0 ; i < 16 ; i++) {
+ for (i = 0; i < 16; i++) {
typename[i] = empty_slot;
}
@@ -269,342 +213,348 @@ int main(int argc, char **argv)
INIT_TYPENAME(cntrl_space_blank);
INIT_TYPENAME(cntrl_nonspace);
+ memset(&cttable, 0, sizeof(table_data));
+ memset(&ultable, 0, sizeof(table_data));
+#if 0
+ memset(combtable, 0, sizeof(table_data));
+ memset(widthtable, 0, sizeof(table_data));
+#endif
setvbuf(stdout, NULL, _IONBF, 0);
while (--argc) {
- if (!setlocale(LC_CTYPE, *++argv)) {
- printf("setlocale(LC_CTYPE,%s) failed! Skipping this locale...\n", *argv);
+ ++argv;
+ if (!strcmp(*argv, "-v")) {
+ ++verbose;
continue;
}
-
+ /* setlocale might be just a stub */
+ /* if (!setlocale(LC_CTYPE, *argv)) {
+ verbose_msg("setlocale(LC_CTYPE,%s) failed! Skipping this locale...\n", *argv);
+ continue;
+ }
+ */
if (!(totitle = wctrans("totitle"))) {
- printf("no totitle transformation.\n");
+ verbose_msg("no totitle transformation.\n");
}
if (!(is_comb = wctype("combining"))) {
- printf("no combining wctype.\n");
+ verbose_msg("no combining wctype.\n");
}
if (!(is_comb3 = wctype("combining_level3"))) {
- printf("no combining_level3 wctype.\n");
+ verbose_msg("no combining_level3 wctype.\n");
}
if (!built) {
- built = 1;
- ul_count = 1;
- uldiff[0].u = uldiff[0].l = 0;
+ built = 1;
+ ul_count = 1;
+ uldiff[0].u = uldiff[0].l = 0;
- memset(wct, 0, sizeof(wct));
- memset(combt, 0, sizeof(combt));
- memset(widtht, 0, sizeof(widtht));
+ memset(wct, 0, sizeof(wct));
+ memset(combt, 0, sizeof(combt));
+ memset(widtht, 0, sizeof(widtht));
- for (i = 0 ; i < 16 ; i++) {
- typecount[i] = 0;
- }
+ for (i = 0; i < 16; i++) {
+ typecount[i] = 0;
+ }
- for (c=0 ; c <= RANGE ; c++) {
- if (iswdigit(c)) {
- d = __CTYPE_digit;
- } else if (iswalpha(c)) {
- d = __CTYPE_alpha_nonupper_nonlower;
- if (iswlower(c)) {
- d = __CTYPE_alpha_lower;
- if (iswupper(c)) {
- d = __CTYPE_alpha_upper_lower;
+ for (c = 0; c <= RANGE; c++) {
+ if (iswdigit(c)) {
+ d = __CTYPE_digit;
+ } else if (iswalpha(c)) {
+ d = __CTYPE_alpha_nonupper_nonlower;
+ if (iswlower(c)) {
+ d = __CTYPE_alpha_lower;
+ if (iswupper(c)) {
+ d = __CTYPE_alpha_upper_lower;
+ }
+ } else if (iswupper(c)) {
+ d = __CTYPE_alpha_upper;
}
- } else if (iswupper(c)) {
- d = __CTYPE_alpha_upper;
- }
- } else if (iswpunct(c)) {
- d = __CTYPE_punct;
- } else if (iswgraph(c)) {
- d = __CTYPE_graph;
- } else if (iswprint(c)) {
- d = __CTYPE_print_space_nonblank;
- if (iswblank(c)) {
- d = __CTYPE_print_space_blank;
- }
- } else if (iswspace(c) && !iswcntrl(c)) {
- d = __CTYPE_space_nonblank_noncntrl;
- if (iswblank(c)) {
- d = __CTYPE_space_blank_noncntrl;
- }
- } else if (iswcntrl(c)) {
- d = __CTYPE_cntrl_nonspace;
- if (iswspace(c)) {
- d = __CTYPE_cntrl_space_nonblank;
+ } else if (iswpunct(c)) {
+ d = __CTYPE_punct;
+ } else if (iswgraph(c)) {
+ d = __CTYPE_graph;
+ } else if (iswprint(c)) {
+ d = __CTYPE_print_space_nonblank;
+ if (iswblank(c)) {
+ d = __CTYPE_print_space_blank;
+ }
+ } else if (iswspace(c) && !iswcntrl(c)) {
+ d = __CTYPE_space_nonblank_noncntrl;
if (iswblank(c)) {
- d = __CTYPE_cntrl_space_blank;
+ d = __CTYPE_space_blank_noncntrl;
+ }
+ } else if (iswcntrl(c)) {
+ d = __CTYPE_cntrl_nonspace;
+ if (iswspace(c)) {
+ d = __CTYPE_cntrl_space_nonblank;
+ if (iswblank(c)) {
+ d = __CTYPE_cntrl_space_blank;
+ }
}
+ } else {
+ d = __CTYPE_unclassified;
}
- } else {
- d = __CTYPE_unclassified;
- }
-
- ++typecount[d];
+ ++typecount[d];
#if 0
- if (iswspace(c)) {
- if (iswblank(c)) {
- printf("%#8x : space blank\n", c);
- } else {
- printf("%#8x : space\n", c);
+ if (iswspace(c)) {
+ if (iswblank(c)) {
+ verbose_msg("%#8x : space blank\n", c);
+ } else {
+ verbose_msg("%#8x : space\n", c);
+ }
}
- }
#endif
-
#if 0
- if (c < 256) {
- unsigned int glibc;
-
- glibc = 0;
- if (isalnum(c)) ++glibc; glibc <<= 1;
- if (isalpha(c)) ++glibc; glibc <<= 1;
- if (isblank(c)) ++glibc; glibc <<= 1;
- if (iscntrl(c)) ++glibc; glibc <<= 1;
- if (isdigit(c)) ++glibc; glibc <<= 1;
- if (isgraph(c)) ++glibc; glibc <<= 1;
- if (islower(c)) ++glibc; glibc <<= 1;
- if (isprint(c)) ++glibc; glibc <<= 1;
- if (ispunct(c)) ++glibc; glibc <<= 1;
- if (isspace(c)) ++glibc; glibc <<= 1;
- if (isupper(c)) ++glibc; glibc <<= 1;
- if (isxdigit(c)) ++glibc;
- printf("%#8x : ctype %#4x\n", c, glibc);
- }
+ if (c < 256) {
+ unsigned int curr_stdclib;
+
+ curr_stdclib = 0;
+ if (isalnum(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isalpha(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isblank(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iscntrl(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isdigit(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isgraph(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (islower(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isprint(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (ispunct(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isspace(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isupper(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (isxdigit(c)) ++curr_stdclib;
+ verbose_msg("%#8x : ctype %#4x\n", c, curr_stdclib);
+ }
#endif
-
#if 1
- /* Paranoid checking... */
- {
- unsigned int glibc;
- unsigned int mine;
-
- glibc = 0;
- if (iswalnum(c)) ++glibc; glibc <<= 1;
- if (iswalpha(c)) ++glibc; glibc <<= 1;
- if (iswblank(c)) ++glibc; glibc <<= 1;
- if (iswcntrl(c)) ++glibc; glibc <<= 1;
- if (iswdigit(c)) ++glibc; glibc <<= 1;
- if (iswgraph(c)) ++glibc; glibc <<= 1;
- if (iswlower(c)) ++glibc; glibc <<= 1;
- if (iswprint(c)) ++glibc; glibc <<= 1;
- if (iswpunct(c)) ++glibc; glibc <<= 1;
- if (iswspace(c)) ++glibc; glibc <<= 1;
- if (iswupper(c)) ++glibc; glibc <<= 1;
- if (iswxdigit(c)) ++glibc;
-
- mine = 0;
- if (mywalnum(c)) ++mine; mine <<= 1;
- if (mywalpha(c)) ++mine; mine <<= 1;
- if (mywblank(c)) ++mine; mine <<= 1;
- if (mywcntrl(c)) ++mine; mine <<= 1;
- if (mywdigit(c)) ++mine; mine <<= 1;
- if (mywgraph(c)) ++mine; mine <<= 1;
- if (mywlower(c)) ++mine; mine <<= 1;
- if (mywprint(c)) ++mine; mine <<= 1;
- if (mywpunct(c)) ++mine; mine <<= 1;
- if (mywspace(c)) ++mine; mine <<= 1;
- if (mywupper(c)) ++mine; mine <<= 1;
- if (mywxdigit(c)) ++mine;
-
- if (glibc != mine) {
- printf("%#8x : glibc %#4x != %#4x mine %u\n", c, glibc, mine, d);
- return EXIT_FAILURE;
- }
-
+ /* Paranoid checking... */
+ {
+ unsigned int curr_stdclib;
+ unsigned int mine;
+
+ curr_stdclib = 0;
+ if (iswalnum(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswalpha(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswblank(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswcntrl(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswdigit(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswgraph(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswlower(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswprint(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswpunct(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswspace(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswupper(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswxdigit(c)) ++curr_stdclib;
+
+ mine = 0;
+ if (mywalnum(d,c)) ++mine; mine <<= 1;
+ if (mywalpha(d,c)) ++mine; mine <<= 1;
+ if (mywblank(d,c)) ++mine; mine <<= 1;
+ if (mywcntrl(d,c)) ++mine; mine <<= 1;
+ if (mywdigit(d,c)) ++mine; mine <<= 1;
+ if (mywgraph(d,c)) ++mine; mine <<= 1;
+ if (mywlower(d,c)) ++mine; mine <<= 1;
+ if (mywprint(d,c)) ++mine; mine <<= 1;
+ if (mywpunct(d,c)) ++mine; mine <<= 1;
+ if (mywspace(d,c)) ++mine; mine <<= 1;
+ if (mywupper(d,c)) ++mine; mine <<= 1;
+ if (mywxdigit(d,c)) ++mine;
+
+ if (curr_stdclib != mine) {
+ verbose_msg("%#8x : curr_stdclib %#4x != %#4x mine %u\n", c, curr_stdclib, mine, d);
+ return EXIT_FAILURE;
+ }
#if 0
- if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
-/* if (!iswpunct(c)) { */
- printf("%#8x : %d %d %#4x\n",
- c, iswctype(c,is_comb),iswctype(c,is_comb3), glibc);
-/* } */
- }
+ if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
+/* if (!iswpunct(c)) { */
+ verbose_msg("%#8x : %d %d %#4x\n",
+ c, iswctype(c,is_comb),iswctype(c,is_comb3), curr_stdclib);
+/* } */
+ }
#endif
#if 0
- if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
- if (!last_comb) {
- printf("%#8x - ", c);
- last_comb = c;
- } else if (last_comb + 1 < c) {
- printf("%#8x\n%#8x - ", last_comb, c);
- last_comb = c;
- } else {
- last_comb = c;
+ if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
+ if (!last_comb) {
+ verbose_msg("%#8x - ", c);
+ last_comb = c;
+ } else if (last_comb + 1 < c) {
+ verbose_msg("%#8x\n%#8x - ", last_comb, c);
+ last_comb = c;
+ } else {
+ last_comb = c;
+ }
}
- }
#endif
- }
+ }
#endif
- combt[c/4] |= ((((!!iswctype(c,is_comb)) << 1) | !!iswctype(c,is_comb3))
+ combt[c/4] |= ((((!!iswctype(c,is_comb)) << 1) | !!iswctype(c,is_comb3))
<< ((c & 3) << 1));
-/* comb3t[c/8] |= ((!!iswctype(c,is_comb3)) << (c & 7)); */
+/* comb3t[c/8] |= ((!!iswctype(c,is_comb3)) << (c & 7)); */
-/* widtht[c/4] |= (wcwidth(c) << ((c & 3) << 1)); */
+/* widtht[c/4] |= (wcwidth(c) << ((c & 3) << 1)); */
- if (c & 1) { /* Use the high nibble for odd numbered wchars. */
- d <<= 4;
- }
- wct[c/2] |= d;
-
- l = (long)(int) towlower(c) - c;
- u = (long)(int) towupper(c) - c;
- ult[c] = 0;
- if (l || u) {
- if ((l != (short)l) || (u != (short)u)) {
- printf("range assumption error! %x %ld %ld\n", c, l, u);
- return EXIT_FAILURE;
+ if (c & 1) { /* Use the high nibble for odd numbered wchars. */
+ d <<= 4;
}
- for (i=0 ; i < ul_count ; i++) {
- if ((l == uldiff[i].l) && (u == uldiff[i].u)) {
- goto found;
+ wct[c/2] |= d;
+
+ l = (long)(int) towlower(c) - c;
+ u = (long)(int) towupper(c) - c;
+ ult[c] = 0;
+ if (l || u) {
+ if ((l != (short)l) || (u != (short)u)) {
+ verbose_msg("range assumption error! %x %ld %ld\n", c, l, u);
+ return EXIT_FAILURE;
}
+ for (i = 0; i < ul_count; i++) {
+ if ((l == uldiff[i].l) && (u == uldiff[i].u)) {
+ goto found;
+ }
+ }
+ uldiff[ul_count].l = l;
+ uldiff[ul_count].u = u;
+ ++ul_count;
+ if (ul_count > MAXTO) {
+ verbose_msg("too many touppers/tolowers!\n");
+ return EXIT_FAILURE;
+ }
+ found:
+ ult[c] = i;
}
- uldiff[ul_count].l = l;
- uldiff[ul_count].u = u;
- ++ul_count;
- if (ul_count > MAXTO) {
- printf("too many touppers/tolowers!\n");
- return EXIT_FAILURE;
- }
- found:
- ult[c] = i;
}
- }
-
- for (i = 0 ; i < 16 ; i++) {
- printf("typecount[%2d] = %8ld %s\n", i, typecount[i], typename[i]);
- }
- printf("optimizing is* table..\n");
- n = -1;
- smallest = SIZE_MAX;
- cttable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(wct, (RANGE/2)+1, i, &cttable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ for (i = 0; i < 16; i++) {
+ verbose_msg("typecount[%2d] = %8ld %s\n", i, typecount[i], typename[i]);
}
- }
- printf("smallest = %zu\n", smallest);
- if (!(cttable.ii = malloc(smallest))) {
- printf("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(wct, (RANGE/2)+1, n, &cttable);
- ++cttable.ti_shift; /* correct for nibble mode */
-
-
- printf("optimizing u/l-to table..\n");
- smallest = SIZE_MAX;
- ultable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(ult, RANGE+1, i, &ultable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing is* table..\n");
+ n = -1;
+ smallest = SIZE_MAX;
+ cttable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(wct, (RANGE/2)+1, i, &cttable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- printf("%zu (smallest) + %zu (u/l diffs) = %zu\n",
- smallest, 4 * ul_count, smallest + 4 * ul_count);
- printf("smallest = %zu\n", smallest);
- if (!(ultable.ii = malloc(smallest))) {
- printf("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(ult, RANGE+1, n, &ultable);
-
-
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(cttable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(wct, (RANGE/2)+1, n, &cttable);
+ ++cttable.ti_shift; /* correct for nibble mode */
+
+ verbose_msg("optimizing u/l-to table..\n");
+ smallest = SIZE_MAX;
+ ultable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(ult, RANGE+1, i, &ultable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
+ }
+ verbose_msg("%lu (smallest) + %lu (u/l diffs) = %lu\n",
+ (unsigned long) smallest,
+ (unsigned long) (4 * ul_count),
+ (unsigned long) (smallest + 4 * ul_count)
+ );
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(ultable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(ult, RANGE+1, n, &ultable);
#if 0
- printf("optimizing comb table..\n");
- smallest = SIZE_MAX;
- combtable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(combt, sizeof(combt), i, &combtable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing comb table..\n");
+ smallest = SIZE_MAX;
+ combtable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(combt, sizeof(combt), i, &combtable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- printf("smallest = %zu\n", smallest);
- if (!(combtable.ii = malloc(smallest))) {
- printf("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(combt, sizeof(combt), n, &combtable);
- combtable.ti_shift += 4; /* correct for 4 entries per */
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(combtable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(combt, sizeof(combt), n, &combtable);
+ combtable.ti_shift += 4; /* correct for 4 entries per */
#endif
-
-
#if 0
- printf("optimizing width table..\n");
- smallest = SIZE_MAX;
- widthtable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(widtht, sizeof(widtht), i, &widthtable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing width table..\n");
+ smallest = SIZE_MAX;
+ widthtable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(widtht, sizeof(widtht), i, &widthtable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- printf("smallest = %zu\n", smallest);
- if (!(widthtable.ii = malloc(smallest))) {
- printf("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(widtht, sizeof(widtht), n, &widthtable);
- widthtable.ti_shift += 4; /* correct for 4 entries per */
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(widthtable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(widtht, sizeof(widtht), n, &widthtable);
+ widthtable.ti_shift += 4; /* correct for 4 entries per */
#endif
-
#if 0
- printf("optimizing comb3 table..\n");
- smallest = SIZE_MAX;
- comb3table.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(comb3t, sizeof(comb3t), i, &comb3table);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing comb3 table..\n");
+ smallest = SIZE_MAX;
+ comb3table.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(comb3t, sizeof(comb3t), i, &comb3table);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- printf("smallest = %zu\n", smallest);
- if (!(comb3table.ii = malloc(smallest))) {
- printf("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(comb3t, sizeof(comb3t), n, &comb3table);
- comb3table.ti_shift += 8; /* correct for 4 entries per */
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(comb3table.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(comb3t, sizeof(comb3t), n, &comb3table);
+ comb3table.ti_shift += 8; /* correct for 4 entries per */
#endif
- dump_table_data(&cttable);
- dump_table_data(&ultable);
- dump_table_data(&combtable);
+ dump_table_data(&cttable);
+ dump_table_data(&ultable);
+#if 0
+ dump_table_data(&combtable);
+#endif
}
- printf("verifying for %s...\n", *argv);
+ verbose_msg("verifying for %s...\n", *argv);
#if RANGE == 0xffffU
- for (c=0 ; c <= 0xffffUL ; c++)
+ for (c = 0; c <= 0xffffUL; c++)
#else
- for (c=0 ; c <= 0x10ffffUL ; c++)
+ for (c = 0; c <= 0x10ffffUL; c++)
#endif
- {
- unsigned int glibc;
+ {
+ unsigned int curr_stdclib;
unsigned int mine;
unsigned int upper, lower;
@@ -619,25 +569,24 @@ int main(int argc, char **argv)
}
#endif
#endif
-
- glibc = 0;
- if (iswalnum(c)) ++glibc; glibc <<= 1;
- if (iswalpha(c)) ++glibc; glibc <<= 1;
- if (iswblank(c)) ++glibc; glibc <<= 1;
- if (iswcntrl(c)) ++glibc; glibc <<= 1;
- if (iswdigit(c)) ++glibc; glibc <<= 1;
- if (iswgraph(c)) ++glibc; glibc <<= 1;
- if (iswlower(c)) ++glibc; glibc <<= 1;
- if (iswprint(c)) ++glibc; glibc <<= 1;
- if (iswpunct(c)) ++glibc; glibc <<= 1;
- if (iswspace(c)) ++glibc; glibc <<= 1;
- if (iswupper(c)) ++glibc; glibc <<= 1;
- if (iswxdigit(c)) ++glibc;
+ curr_stdclib = 0;
+ if (iswalnum(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswalpha(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswblank(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswcntrl(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswdigit(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswgraph(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswlower(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswprint(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswpunct(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswspace(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswupper(c)) ++curr_stdclib; curr_stdclib <<= 1;
+ if (iswxdigit(c)) ++curr_stdclib;
{
unsigned int u;
- int n, sc;
- int i0, i1;
+ int n = 0, sc = 0; /* = 0 for verbose_msg only */
+ int i0 = 0, i1 = 0;
u = c;
if (u <= RANGE) {
@@ -649,16 +598,16 @@ int main(int argc, char **argv)
i0 = cttable.ii[u];
i0 <<= cttable.ii_shift;
i1 = cttable.ti[i0 + n];
- i1 <<= (cttable.ti_shift-1);
+ i1 <<= (cttable.ti_shift - 1);
d = cttable.ut[i1 + (sc >> 1)];
if (sc & 1) {
d >>= 4;
}
d &= 0x0f;
- } else if ((((unsigned int)(c - 0xe0020UL)) <= 0x5f) || (c == 0xe0001UL)){
+ } else if (((unsigned)(c - 0xe0020UL) <= 0x5f) || (c == 0xe0001UL)) {
d = __CTYPE_punct;
- } else if (((unsigned int)(c - 0xf0000UL)) < 0x20000UL) {
+ } else if ((unsigned)(c - 0xf0000UL) < 0x20000UL) {
if ((c & 0xffffU) <= 0xfffdU) {
d = __CTYPE_punct;
} else {
@@ -668,26 +617,27 @@ int main(int argc, char **argv)
d = __CTYPE_unclassified;
}
- mine = 0;
- if (mywalnum(c)) ++mine; mine <<= 1;
- if (mywalpha(c)) ++mine; mine <<= 1;
- if (mywblank(c)) ++mine; mine <<= 1;
- if (mywcntrl(c)) ++mine; mine <<= 1;
- if (mywdigit(c)) ++mine; mine <<= 1;
- if (mywgraph(c)) ++mine; mine <<= 1;
- if (mywlower(c)) ++mine; mine <<= 1;
- if (mywprint(c)) ++mine; mine <<= 1;
- if (mywpunct(c)) ++mine; mine <<= 1;
- if (mywspace(c)) ++mine; mine <<= 1;
- if (mywupper(c)) ++mine; mine <<= 1;
- if (mywxdigit(c)) ++mine;
-
- if (glibc != mine) {
- printf("%#8x : glibc %#4x != %#4x mine %d\n", c, glibc, mine, d);
- if (c < 0x30000UL) {
- printf("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc, u, n, i0, i1);
+ mine = 0;
+ if (mywalnum(d,c)) ++mine; mine <<= 1;
+ if (mywalpha(d,c)) ++mine; mine <<= 1;
+ if (mywblank(d,c)) ++mine; mine <<= 1;
+ if (mywcntrl(d,c)) ++mine; mine <<= 1;
+ if (mywdigit(d,c)) ++mine; mine <<= 1;
+ if (mywgraph(d,c)) ++mine; mine <<= 1;
+ if (mywlower(d,c)) ++mine; mine <<= 1;
+ if (mywprint(d,c)) ++mine; mine <<= 1;
+ if (mywpunct(d,c)) ++mine; mine <<= 1;
+ if (mywspace(d,c)) ++mine; mine <<= 1;
+ if (mywupper(d,c)) ++mine; mine <<= 1;
+ if (mywxdigit(d,c)) ++mine;
+
+ if (curr_stdclib != mine) {
+ verbose_msg("%#8x : curr_stdclib %#4x != %#4x mine %d\n", c, curr_stdclib, mine, d);
+ if (c < 0x30000UL) {
+ verbose_msg("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc, u, n, i0, i1);
+ }
}
- }
+
upper = lower = u = c;
if (u <= RANGE) {
sc = u & ((1 << ultable.ti_shift) - 1);
@@ -705,64 +655,52 @@ int main(int argc, char **argv)
lower = c + uldiff[i0].l;
}
- if (towupper(c) != upper) {
- printf("%#8x : towupper glibc %#4x != %#4x mine\n",
- c, towupper(c), upper);
- }
+ if (towupper(c) != upper) {
+ verbose_msg("%#8x : towupper curr_stdclib %#4x != %#4x mine\n",
+ c, towupper(c), upper);
+ }
- if (towlower(c) != lower) {
- printf("%#8x : towlower glibc %#4x != %#4x mine i0 = %d\n",
- c, towlower(c), lower, i0);
- }
+ if (towlower(c) != lower) {
+ verbose_msg("%#8x : towlower curr_stdclib %#4x != %#4x mine i0 = %d\n",
+ c, towlower(c), lower, i0);
+ }
- if (totitle && ((tt = towctrans(c, totitle)) != upper)) {
- printf("%#8x : totitle glibc %#4lx != %#4x mine i0 = %d\n",
- c, tt, upper, i0);
- }
+ if (totitle && ((tt = towctrans(c, totitle)) != upper)) {
+ verbose_msg("%#8x : totitle curr_stdclib %#4lx != %#4x mine i0 = %d\n",
+ c, tt, upper, i0);
+ }
}
-
- if ((c & 0xfff) == 0xfff) printf(".");
+ if ((c & 0xfff) == 0xfff) verbose_msg(".");
}
- printf("done\n");
+ verbose_msg("done\n");
}
- if (1) {
- FILE *fp;
-
- if (!(fp = fopen("wctables.h", "w"))) {
- printf("couldn't open wctables.h!\n");
- return EXIT_FAILURE;
- }
-
- fprintf(fp, "#define __LOCALE_DATA_WC_TABLE_DOMAIN_MAX %#8lx\n\n",
+ if (built) {
+ printf("#define __LOCALE_DATA_WC_TABLE_DOMAIN_MAX %#8lx\n\n",
(unsigned long) RANGE);
- output_table(fp, "ctype", &cttable);
- output_table(fp, "uplow", &ultable);
-
+ output_table("ctype", &cttable);
+ output_table("uplow", &ultable);
#warning fix the upper bound on the upper/lower tables... save 200 bytes or so
- fprintf(fp, "#define __LOCALE_DATA_WCuplow_diffs %7u\n", ul_count);
- fprintf(fp, "\n#ifdef WANT_WCuplow_diff_data\n\n");
- fprintf(fp, "\nstatic const short __LOCALE_DATA_WCuplow_diff_data[%zu] = {",
+ printf("#define __LOCALE_DATA_WCuplow_diffs %7u\n", ul_count);
+ printf("\n#ifdef WANT_WCuplow_diff_data\n\n");
+ printf("\nstatic const short __LOCALE_DATA_WCuplow_diff_data[%zu] = {",
2 * (size_t) ul_count);
- for (i=0 ; i < ul_count ; i++) {
+ for (i = 0; i < ul_count; i++) {
if (i % 4 == 0) {
- fprintf(fp, "\n");
+ printf("\n");
}
- fprintf(fp, " %6d, %6d,", uldiff[i].u, uldiff[i].l);
+ printf(" %6d, %6d,", uldiff[i].u, uldiff[i].l);
}
- fprintf(fp, "\n};\n\n");
- fprintf(fp, "#endif /* WANT_WCuplow_diff_data */\n\n");
-
-
-/* output_table(fp, "comb", &combtable); */
-/* output_table(fp, "width", &widthtable); */
+ printf("\n};\n\n");
+ printf("#endif /* WANT_WCuplow_diff_data */\n\n");
- fclose(fp);
+/* output_table("comb", &combtable); */
+/* output_table("width", &widthtable); */
}
- return EXIT_SUCCESS;
+ return !built;
}
size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
@@ -786,7 +724,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
numblocks = usize >> shift;
/* init table index */
- for (i=j=0 ; i < numblocks ; i++) {
+ for (i=j = 0; i < numblocks; i++) {
ti[i] = ut + j;
j += blocksize;
}
@@ -797,7 +735,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
uniq = 1;
uit[(ti[0]-ut)/blocksize] = 0;
- for (i=1 ; i < numblocks ; i++) {
+ for (i=1; i < numblocks; i++) {
if (memcmp(ti[i-1], ti[i], blocksize) < 0) {
if (++uniq > 255) {
break;
@@ -806,7 +744,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
}
#if 1
else if (memcmp(ti[i-1], ti[i], blocksize) > 0) {
- printf("bad sort %i!\n", i);
+ verbose_msg("bad sort %li!\n", (long) i);
abort();
}
#endif
@@ -815,37 +753,37 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
smallest = SIZE_MAX;
shift2 = -1;
- if (uniq <= 255) {
- smallest = numblocks + uniq * blocksize;
- if (!recurse) {
- ++recurse;
- for (j=1 ; j < 14 ; j++) {
- if ((numblocks >> j) < 2) break;
- if (tbl) {
- ii_save = tbl->ii;
- tbl->ii = NULL;
- }
- if ((t = newopt(uit, numblocks, j, tbl)) < SIZE_MAX) {
- t += uniq * blocksize;
- }
- if (tbl) {
- tbl->ii = ii_save;
- }
- if (smallest >= t) {
- shift2 = j;
- smallest = t;
- if (!tbl->ii) {
- printf("ishift %zu tshift %zu size %zu\n",
- shift2, shift, t);
- }
-/* } else { */
-/* break; */
+
+ if (uniq > 255)
+ return SIZE_MAX;
+
+ smallest = numblocks + uniq * blocksize;
+ if (!recurse) {
+ ++recurse;
+ for (j=1; j < 14; j++) {
+ if ((numblocks >> j) < 2) break;
+ if (tbl) {
+ ii_save = tbl->ii;
+ tbl->ii = NULL;
+ }
+ if ((t = newopt(uit, numblocks, j, tbl)) < SIZE_MAX) {
+ t += uniq * blocksize;
+ }
+ if (tbl) {
+ tbl->ii = ii_save;
+ }
+ if (smallest >= t) {
+ shift2 = j;
+ smallest = t;
+ if (!tbl->ii) {
+ verbose_msg("ishift %u tshift %u size %lu\n",
+ shift2, shift, (unsigned long) t);
}
+/* } else { */
+/* break; */
}
- --recurse;
}
- } else {
- return SIZE_MAX;
+ --recurse;
}
if (tbl->ii) {
@@ -855,22 +793,23 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
memcpy(tbl->ii, uit, numblocks);
tbl->ti = tbl->ii + tbl->ii_len;
tbl->ti_len = uniq * blocksize;
- for (i=0 ; i < uniq ; i++) {
+ for (i = 0; i < uniq; i++) {
memcpy(tbl->ti + i * blocksize, ti[uniqblock[i]], blocksize);
}
} else {
++recurse;
- printf("setting ishift %zu tshift %zu\n",
+ verbose_msg("setting ishift %u tshift %u\n",
shift2, shift);
newopt(uit, numblocks, shift2, tbl);
--recurse;
tbl->ti_shift = shift;
tbl->ut_len = uniq * blocksize;
tbl->ut = tbl->ti + tbl->ti_len;
- for (i=0 ; i < uniq ; i++) {
+ for (i = 0; i < uniq; i++) {
memcpy(tbl->ut + i * blocksize, ti[uniqblock[i]], blocksize);
}
}
}
return smallest;
}
+/* vi: set sw=4 ts=4: */
diff --git a/extra/locale/lmmtolso.c b/extra/locale/lmmtolso.c
index a1876a7dc..2437a8f69 100644
--- a/extra/locale/lmmtolso.c
+++ b/extra/locale/lmmtolso.c
@@ -14,18 +14,18 @@ int main(void)
size_t i;
if (!(lmm = fopen("locale.mmap", "r"))) {
- printf("can't open locale.mmap!\n");
+ printf("cannot open locale.mmap!\n");
return EXIT_FAILURE;
}
if (fstat(fileno(lmm), &fd_stat)) {
- printf("can't stat locale.mmap!\n");
+ printf("cannot stat locale.mmap!\n");
fclose(lmm);
return EXIT_FAILURE;
}
if (!(lso = fopen("locale_data.c", "w"))) {
- printf("can't open locale_data.c!\n");
+ printf("cannot open locale_data.c!\n");
fclose(lmm);
return EXIT_FAILURE;
}
diff --git a/extra/locale/locale_mmap.h b/extra/locale/locale_mmap.h
index 1b748239b..5b0df9074 100644
--- a/extra/locale/locale_mmap.h
+++ b/extra/locale/locale_mmap.h
@@ -8,34 +8,34 @@
/* TODO - fix */
#ifdef __WCHAR_ENABLED
-#define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN)
-#define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN)
+#define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN)
+#define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN)
#define __LOCALE_DATA_WCuplow_diff_TBL_LEN (2 * __LOCALE_DATA_WCuplow_diffs)
/* #define WCcomb_TBL_LEN (WCcomb_II_LEN + WCcomb_TI_LEN + WCcomb_UT_LEN) */
#endif
#undef __PASTE2
-#define __PASTE2(A,B) A ## B
+#define __PASTE2(A,B) A ## B
#undef __PASTE3
-#define __PASTE3(A,B,C) A ## B ## C
+#define __PASTE3(A,B,C) A ## B ## C
#define __LOCALE_DATA_COMMON_MMAP(X) \
- unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)];
+ unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)];
#define __LOCALE_DATA_COMMON_MMIDX(X) \
- unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \
- uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \
- uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \
+ unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \
+ uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \
+ uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \
typedef struct {
#ifdef __LOCALE_DATA_MAGIC_SIZE
unsigned char magic[__LOCALE_DATA_MAGIC_SIZE];
-#endif /* __LOCALE_DATA_MAGIC_SIZE */
+#endif
#ifdef __CTYPE_HAS_8_BIT_LOCALES
const unsigned char tbl8ctype[__LOCALE_DATA_Cctype_TBL_LEN];
- const unsigned char tbl8uplow[__LOCALE_DATA_Cuplow_TBL_LEN];
+ const unsigned char tbl8uplow[__LOCALE_DATA_Cuplow_TBL_LEN];
#ifdef __WCHAR_ENABLED
const uint16_t tbl8c2wc[__LOCALE_DATA_Cc2wc_TBL_LEN]; /* char > 0x7f to wide char */
const unsigned char tbl8wc2c[__LOCALE_DATA_Cwc2c_TBL_LEN];
@@ -48,31 +48,31 @@ typedef struct {
const int16_t tblwuplow_diff[__LOCALE_DATA_WCuplow_diff_TBL_LEN];
/* const unsigned char tblwcomb[WCcomb_TBL_LEN]; */
/* width?? */
-#endif /* __WCHAR_ENABLED */
+#endif
- __LOCALE_DATA_COMMON_MMAP(ctype);
- __LOCALE_DATA_COMMON_MMAP(numeric);
- __LOCALE_DATA_COMMON_MMAP(monetary);
- __LOCALE_DATA_COMMON_MMAP(time);
+ __LOCALE_DATA_COMMON_MMAP(ctype)
+ __LOCALE_DATA_COMMON_MMAP(numeric)
+ __LOCALE_DATA_COMMON_MMAP(monetary)
+ __LOCALE_DATA_COMMON_MMAP(time)
/* collate is different */
- __LOCALE_DATA_COMMON_MMAP(messages);
+ __LOCALE_DATA_COMMON_MMAP(messages)
#ifdef __CTYPE_HAS_8_BIT_LOCALES
const __codeset_8_bit_t codeset_8_bit[__LOCALE_DATA_NUM_CODESETS];
-#endif /* __CTYPE_HAS_8_BIT_LOCALES */
+#endif
- __LOCALE_DATA_COMMON_MMIDX(ctype);
- __LOCALE_DATA_COMMON_MMIDX(numeric);
- __LOCALE_DATA_COMMON_MMIDX(monetary);
- __LOCALE_DATA_COMMON_MMIDX(time);
+ __LOCALE_DATA_COMMON_MMIDX(ctype)
+ __LOCALE_DATA_COMMON_MMIDX(numeric)
+ __LOCALE_DATA_COMMON_MMIDX(monetary)
+ __LOCALE_DATA_COMMON_MMIDX(time)
/* collate is different */
- __LOCALE_DATA_COMMON_MMIDX(messages);
+ __LOCALE_DATA_COMMON_MMIDX(messages)
const uint16_t collate_data[__lc_collate_data_LEN];
unsigned char lc_common_item_offsets_LEN[__LOCALE_DATA_CATEGORIES];
- size_t lc_common_tbl_offsets[__LOCALE_DATA_CATEGORIES * 4];
+ size_t lc_common_tbl_offsets[__LOCALE_DATA_CATEGORIES * 4];
/* offsets from start of locale_mmap_t */
/* rows, item_offsets, item_idx, data */
@@ -80,14 +80,12 @@ typedef struct {
unsigned char locales[__LOCALE_DATA_NUM_LOCALES * __LOCALE_DATA_WIDTH_LOCALES];
unsigned char locale_names5[5*__LOCALE_DATA_NUM_LOCALE_NAMES];
unsigned char locale_at_modifiers[__LOCALE_DATA_AT_MODIFIERS_LENGTH];
-#endif /* __LOCALE_DATA_NUM_LOCALES */
+#endif
unsigned char lc_names[__lc_names_LEN];
#ifdef __CTYPE_HAS_8_BIT_LOCALES
unsigned char codeset_list[sizeof(__LOCALE_DATA_CODESET_LIST)]; /* TODO - fix */
-#endif /* __CTYPE_HAS_8_BIT_LOCALES */
-
-
+#endif
} __locale_mmap_t;
extern const __locale_mmap_t *__locale_mmap;
diff --git a/extra/locale/programs/locale.c b/extra/locale/programs/locale.c
index c8b76bd65..c9fd1f3c2 100644
--- a/extra/locale/programs/locale.c
+++ b/extra/locale/programs/locale.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
*
* Copyright (c) 2008 STMicroelectronics Ltd
@@ -9,12 +10,14 @@
*
*/
-
+#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <langinfo.h>
+#include <unistd.h>
+#ifdef __UCLIBC_HAS_GETOPT_LONG__
#include <getopt.h>
+#endif
typedef struct {
unsigned char idx_name;
@@ -28,7 +31,7 @@ typedef struct {
unsigned char lc_messages_row;
} locale_entry;
-/* Need to include this before locale.h and xlocale.h! */
+/* Need to include this before locale.h! */
#include <bits/uClibc_locale.h>
#undef CODESET_LIST
@@ -39,7 +42,7 @@ typedef struct {
#define LOCALE_AT_MODIFIERS (__locale_mmap->locale_at_modifiers)
#define CATEGORY_NAMES (__locale_mmap->lc_names)
-#define GET_CODESET_NAME(N) (CODESET_LIST + *(CODESET_LIST + N - 3))
+#define GET_CODESET_NAME(N) (const char *)(CODESET_LIST + *(CODESET_LIST + N - 3))
#define GET_LOCALE_ENTRY(R) (locale_entry *)(LOCALES + (__LOCALE_DATA_WIDTH_LOCALES * R))
#define GET_CATEGORY_NAME(X) (CATEGORY_NAMES + *(CATEGORY_NAMES + X))
#define GET_LOCALE_NAME(I) (const char *)(LOCALE_NAMES + 5 * (I - 1))
@@ -129,28 +132,47 @@ static void usage(const char *name)
const char *s;
s = basename(name);
+#ifdef __UCLIBC_HAS_GETOPT_LONG__
fprintf(stderr,
- "Usage: %s [-ck] [--category-name] [--keyword-name] [--help] NAME\n"
- "or: %s [OPTION...] [-a|-m] [--all-locales] [--charmaps] \n", s,
- s);
+ "Usage: %s [-a | -m] [FORMAT] name...\n\n"
+ "\t-a, --all-locales\tWrite names of all available locales\n"
+ "\t-m, --charmaps\tWrite names of available charmaps\n"
+ "\nFORMAT:\n"
+ "\t-c, --category-name\tWrite names of selected categories\n"
+ "\t-k, --keyword-name\tWrite names of selected keywords\n"
+ , s);
+#else
+ fprintf(stderr,
+ "Usage: %s [-a | -m] [FORMAT] name...\n\n"
+ "\t-a\tWrite names of all available locales\n"
+ "\t-m\tWrite names of available charmaps\n"
+ "\nFORMAT:\n"
+ "\t-c\tWrite names of selected categories\n"
+ "\t-k\tWrite names of selected keywords\n"
+ , s);
+#endif
}
static int argp_parse(int argc, char *argv[]);
static int argp_parse(int argc, char *argv[])
{
+ int c;
+ char *progname;
+#ifdef __UCLIBC_HAS_GETOPT_LONG__
static const struct option long_options[] = {
{"all-locales", no_argument, NULL, 'a'},
{"charmaps", no_argument, NULL, 'm'},
{"category-name", no_argument, NULL, 'c'},
{"keyword-name", no_argument, NULL, 'k'},
{"help", no_argument, NULL, 'h'},
- {NULL, 0, NULL, 0}
- };
- int c;
- char *progname;
-
+ {NULL, 0, NULL, 0}};
+#endif
progname = *argv;
+#ifdef __UCLIBC_HAS_GETOPT_LONG__
while ((c = getopt_long(argc, argv, "amckh", long_options, NULL)) >= 0)
+#else
+ while ((c = getopt(argc, argv, "amckh")) >= 0)
+#endif
switch (c) {
case 'a':
do_all = 1;
@@ -215,8 +237,10 @@ static void find_locale_string(locale_entry * loc_rec, char *loc)
if (loc[2] == '_') {
sprintf(loc, "%5.5s%c%s\0", loc, (dotcs != 0) ? '.' : ' ',
- (cs ==
- 1) ? ascii : ((cs == 2) ? utf8 : GET_CODESET_NAME(cs)));
+ (cs == 1) ? ascii
+ : ((cs == 2) ?
+ utf8
+: GET_CODESET_NAME(cs)));
} else {
at = loc[2];
loc[2] = '_';
diff --git a/extra/scripts/.gitignore b/extra/scripts/.gitignore
new file mode 100644
index 000000000..d13eda94e
--- /dev/null
+++ b/extra/scripts/.gitignore
@@ -0,0 +1 @@
+unifdef
diff --git a/extra/scripts/MAKEALL b/extra/scripts/MAKEALL
new file mode 100755
index 000000000..f46d3bd66
--- /dev/null
+++ b/extra/scripts/MAKEALL
@@ -0,0 +1,146 @@
+#!/bin/sh
+#
+# helper script to quick build testing with cross-compilers
+#
+
+: ${MAKE:=make}
+
+: ${BUILD_NCPUS:=$(getconf _NPROCESSORS_ONLN)}
+if [ "$BUILD_NCPUS" -gt 1 ] ; then
+ JOBS=-j$((BUILD_NCPUS + 1))
+else
+ JOBS=""
+fi
+MAKE="${MAKE} ${JOBS}"
+
+: ${CROSS_COMPILE:=${CROSS_COMPILER_PREFIX}}
+
+setconfig()
+{
+ local opt=$1
+ shift
+ case $1 in
+ [yn]) ;;
+ [0-9]*) ;;
+ *) set -- '"'$*'"'
+ esac
+ sed -i \
+ -e "/${opt}=/s:=.*:=$*:" \
+ .config
+ echo " ## setconfig ${opt} $*"
+}
+
+get_arches()
+{
+ case $1 in
+ hppa) echo hppa hppa2.0 hppa1.1 hppa1.0;;
+ i386) echo i386 i486 i586 i686;;
+ sh) echo sh4 sh2 sh3 sh1 sh;;
+ sparc) echo sparc sparc64;;
+ *) echo $1;;
+ esac
+}
+
+find_compiler()
+{
+ local t a v o l
+ for a in $(get_arches $1) ; do
+ for l in uclibc gnu gnueabi "" ; do
+ for v in unknown pc gentoo "" ; do
+ for o in linux uclinux "" ; do
+ t="${a}${v:+-${v}}${o:+-${o}}${l:+-${l}}"
+ if ${t}-gcc --help > /dev/null 2>&1 ; then
+ echo ${t}-
+ return 0
+ fi
+ done
+ done
+ done
+ done
+}
+
+do_make()
+{
+ echo " ## ${MAKE} -s $*"
+ ${MAKE} -s "$@"
+}
+
+mark_arch()
+{
+ local r=$1 a=$2
+ eval $r=\"\$$r $a\"
+}
+
+if [ -z "$*" ] ; then
+ set -- $(awk \
+ '$0 ~ /^config TARGET_/ { sub("TARGET_",""); print $NF }' \
+ extra/Configs/Config.in | grep -v SUBARCH)
+fi
+pass=""
+fail=""
+skip=""
+for a in "$@" ; do
+ if [ -z "${CROSS_COMPILE}" ] ; then
+ CROSS_COMPILE=$(find_compiler ${a})
+ fi
+
+ if [ -z "${CROSS_COMPILE}" ] ; then
+ mark_arch skip $a
+ echo " ### SKIP: ${a}: could not find compiler"
+ continue
+ fi
+
+ rm -f ${a}.log ${a}.fail
+ (
+ set -e
+
+ echo " ### Building target ${a} (${CROSS_COMPILE})"
+
+ do_make distclean
+ do_make ARCH=$a defconfig
+ do_make oldconfig
+
+ setconfig CROSS_COMPILER_PREFIX ${CROSS_COMPILE}
+
+ header_path=${KERNEL_HEADERS:-$(echo '#include <linux/version.h>' | ${CROSS_COMPILE}cpp 2>/dev/null | grep -o '[^"]*linux/version.h')} || :
+ if [ -z "${header_path}" ] ; then
+ for p in /usr/${CROSS_COMPILE%-}/usr/include ; do
+ if [ -e ${p}/linux/version.h ] ; then
+ header_path=${p}
+ break
+ fi
+ done
+ if [ -z "${header_path}" ] ; then
+ echo " ## unable to locate KERNEL_HEADERS"
+ fi
+ fi
+ setconfig KERNEL_HEADERS ${header_path%/linux/version.h}
+
+ if do_make ; then
+ echo " ## PASS"
+ else
+ echo " ## FAIL"
+ touch ${a}.fail
+ fi
+ ) 2>&1 | tee ${a}.log
+
+ if [ -e ${a}.fail ] ; then
+ rm -f ${a}.fail
+ mark_arch fail $a
+ else
+ mark_arch pass $a
+ fi
+
+ unset CROSS_COMPILE
+done
+
+if [ -n "${skip}" ] ; then
+ printf '\nSKIPPED: %s\n' "${skip}"
+fi
+if [ -n "${fail}" ] ; then
+ printf '\nPASSED: %s\nFAILED: %s\n\n' "${pass}" "${fail}"
+ exit 1
+else
+ printf '\nAll arches passed!\n\n'
+ exit 0
+fi
diff --git a/extra/scripts/conf-header.sh b/extra/scripts/conf-header.sh
index 90dfa999a..8044f8c06 100755
--- a/extra/scripts/conf-header.sh
+++ b/extra/scripts/conf-header.sh
@@ -8,7 +8,7 @@ if [ -z "$1" ] ; then
fi
cat <<EOF
-#if !defined __FEATURES_H && !defined __need_uClibc_config_h
+#if !defined _FEATURES_H && !defined __need_uClibc_config_h
# error Never include <bits/uClibc_config.h> directly; use <features.h> instead
#endif
diff --git a/extra/scripts/cppcheck.sh b/extra/scripts/cppcheck.sh
new file mode 100755
index 000000000..127c5096d
--- /dev/null
+++ b/extra/scripts/cppcheck.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+
+# usage:
+#
+# make \
+# REAL_CC=gcc-mine \
+# CC=extra/scripts/cppcheck.sh \
+# CPPCHECK_FLAGS="--enable=style,performance,portability,information,missingInclude --max-configs=256 -j $(($(getconf _NPROCESSORS_ONLN)-1))" \
+# CPPCHECK_LIMIT="yes"
+
+# CPPCHECK_FLAGS are optional and are not set per default.
+# CPPCHECK_LIMIT limits cppcheck to the -D and -U that would be passed to CC.
+# Setting CPPCHECK_LIMIT greatly improves the check-time but obviously
+# just checks a small subset of the defines found in a file.
+
+: ${REAL_CC:=gcc}
+${REAL_CC} $@
+args=""
+limits=""
+next_arg=0
+next_limit=0
+
+for i in $@
+do
+ if [ $next_arg -eq 1 ] ; then
+ next_arg=0
+ case "/$i" in
+ /-*) exit 0 ;;
+ esac
+ [ "x$args" = "x" ] && args="$i" || args="$args $i"
+ continue
+ fi
+ if [ $next_limit -eq 1 ] ; then
+ next_limit=0
+ [ "x$limits" = "x" ] && limits="$i" || limits="$limits $i"
+ continue
+ fi
+ case "/$i" in
+ /-c) next_arg=1 ;;
+ /-isystem)
+ next_arg=1;
+ [ "x$args" = "x" ] && args="-I" || args="$args -I" ;;
+ /-I)
+ next_arg=1;
+ [ "x$args" = "x" ] && args="$i" || args="$args $i" ;;
+ /-I*) [ "x$args" = "x" ] && args="$i" || args="$args $i" ;;
+ /-D|/-U)
+ next_limit=1;
+ [ "x$limit" = "x" ] && limit="$i" || limit="$limit $i" ;;
+ /-D*) [ "x$limits" = "x" ] && limits="$i" || limits="$limits $i" ;;
+ /-s|/-S|/-dump*|/--print*|/-print*) exit 0 ;;
+ *) ;;
+ esac
+done
+[ -z "${CPPCHECK_LIMIT}" ] && limits=""
+[ -z "${args}" ] || exec cppcheck ${CPPCHECK_FLAGS} ${args} ${limits}
diff --git a/extra/scripts/gen-as-const.awk b/extra/scripts/gen-as-const.awk
new file mode 100644
index 000000000..013bd6e85
--- /dev/null
+++ b/extra/scripts/gen-as-const.awk
@@ -0,0 +1,33 @@
+# Script used in producing headers of assembly constants from C expressions.
+# The input to this script looks like:
+# #cpp-directive ...
+# NAME1
+# NAME2 expression ...
+# The output of this script is C code to be run through gcc -S and then
+# massaged to extract the integer constant values of the given C expressions.
+# A line giving just a name implies an expression consisting of just that name.
+
+BEGIN { started = 0 }
+
+# cpp directives go straight through.
+/^#/ { print; next }
+
+NF >= 1 && !started {
+ printf "void dummy(void);\n";
+ print "void dummy(void) {";
+ started = 1;
+}
+
+# Separator.
+$1 == "--" { next }
+
+NF == 1 { sub(/^.*$/, "& &"); }
+
+NF > 1 {
+ name = $1;
+ sub(/^[^ ]+[ ]+/, "");
+ printf "__asm__ (\"@@@name@@@%s@@@value@@@%%0@@@end@@@\" : : \"i\" ((long) %s));\n",
+ name, $0;
+}
+
+END { if (started) print "}" }
diff --git a/extra/scripts/gen_bits_syscall_h.sh b/extra/scripts/gen_bits_syscall_h.sh
index c0b4c25f5..bfd06b832 100755
--- a/extra/scripts/gen_bits_syscall_h.sh
+++ b/extra/scripts/gen_bits_syscall_h.sh
@@ -8,39 +8,53 @@
# June 27, 2001 Manuel Novoa III
#
-# This script expects top_builddir and CC (as used in the Makefiles) to be set
-# in the environment, and outputs the appropriate
-# $top_builddir/include/bits/sysnum.h # corresponding to
-# $top_builddir/include/asm/unistd.h to stdout.
+# This script expects CC (as used in the Makefiles) to be set
+# in the environment, and outputs the appropriate bits/sysnum.h #
+# corresponding to asm/unistd.h to stdout.
#
# Warning!!! This does _no_ error checking!!!
-INCLUDE_OPTS="-nostdinc -I${KERNEL_HEADERS}"
+if [ "${KERNEL_HEADERS:-/}" != "/" ] ; then
+ INCLUDE_OPTS="-nostdinc -I${KERNEL_HEADERS}"
+else
+ # Let the toolchain use its configure paths.
+ INCLUDE_OPTS=
+fi
case $CC in
*icc*) CC_SYSNUM_ARGS="-dM" ;;
+*clang*) CC_SYSNUM_ARGS="-dM" ;;
*) CC_SYSNUM_ARGS="-dN" ;;
esac
( echo "#include <asm/unistd.h>";
echo "#include <asm/unistd.h>" |
$CC -E $CC_SYSNUM_ARGS $INCLUDE_OPTS - |
- sed -ne 's/^[ ]*#define[ ]*__NR_\([A-Za-z0-9_]*\).*/UCLIBC_\1 __NR_\1/gp' \
- -e 's/^[ ]*#undef[ ]*__NR_\([A-Za-z0-9_]*\).*/UNDEFUCLIBC_\1 __NR_\1/gp' # needed to strip out any kernel-internal defines
+ sed -n -r \
+ -e 's/^[ ]*#define[ ]*(__ARM_NR_|__NR_)([A-Za-z0-9_]*).*/UCLIBC\1\2 \1\2/gp' \
+ -e 's/^[ ]*#undef[ ]*(__ARM_NR_|__NR_)([A-Za-z0-9_]*).*/UNDEFUCLIBC\1\2 \1\2/gp' # needed to strip out any kernel-internal defines
) |
$CC -E $INCLUDE_OPTS - |
-( echo "/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */" ;
- echo ;
- echo "#ifndef _BITS_SYSNUM_H" ;
- echo "#define _BITS_SYSNUM_H" ;
- echo ;
- echo "#ifndef _SYSCALL_H" ;
- echo "# error \"Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead.\"" ;
- echo "#endif" ; echo ;
- sed -ne 's/^UCLIBC_\([A-Za-z0-9_]*\) *\(.*\)/#undef __NR_\1\
-#define __NR_\1 \2\
-#define SYS_\1 __NR_\1/gp' \
- -e 's/^UNDEFUCLIBC_\([A-Za-z0-9_]*\).*/#undef __NR_\1/gp'
- echo ;
- echo "#endif" ;
+(
+ cat <<-EOF
+/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */
+/* See $0 for more information. */
+
+#ifndef _BITS_SYSNUM_H
+#define _BITS_SYSNUM_H
+
+#ifndef _SYSCALL_H
+# error "Never use <bits/sysnum.h> directly; include <sys/syscall.h> instead."
+#endif
+
+EOF
+ sed -n -r -e 's/^UCLIBC(__ARM_NR_|__NR_)([A-Za-z0-9_]*) *(.*)/#undef \1\2\
+#define \1\2 \3\
+#define SYS_\2 \1\2/gp' \
+ -e 's/^UNDEFUCLIBC(__ARM_NR_|__NR_)([A-Za-z0-9_]*).*/#undef \1\2\
+#undef SYS_\2/gp'
+ cat <<-EOF
+
+#endif
+EOF
)
diff --git a/extra/scripts/getent b/extra/scripts/getent
index 30d515b7e..5c482a071 100755
--- a/extra/scripts/getent
+++ b/extra/scripts/getent
@@ -1,5 +1,4 @@
#!/bin/sh
-# $Header: /var/cvs/uClibc/extra/scripts/getent,v 1.2 2005/02/02 14:18:01 solar Exp $
#
# Closely (not perfectly) emulate the behavior of glibc's getent utility
#
@@ -9,7 +8,8 @@
# case-insensitive matches not supported (ethers; others?)
# may return false-positives (hosts,protocols,rpc,services,ethers)
-export PATH="${PATH}:/bin:/usr/bin"
+[ -z "$PATH" ] && PATH="/bin:/usr/bin" || PATH="${PATH}:/bin:/usr/bin"
+export PATH
file="/etc/$1"
case $1 in
diff --git a/extra/scripts/install_headers.sh b/extra/scripts/install_headers.sh
index 6d73ad2c6..8c8d715ef 100755
--- a/extra/scripts/install_headers.sh
+++ b/extra/scripts/install_headers.sh
@@ -4,6 +4,10 @@
# $2 = dst dir
# $top_builddir = well you guessed it
+srcdir=${1:-include}
+dstdir=${2:-`. ./.config 2>/dev/null && echo ${DEVEL_PREFIX}/include`}
+: ${top_builddir:=.}
+
die_if_not_dir()
{
for dir in "$@"; do
@@ -19,40 +23,55 @@ umask 022
# Sanity tests
-die_if_not_dir "$1"
-mkdir -p "$2" 2>/dev/null
-die_if_not_dir "$2"
+die_if_not_dir "${srcdir}"
+mkdir -p "${dstdir}" 2>/dev/null
+die_if_not_dir "${dstdir}"
die_if_not_dir "$top_builddir"
if ! test -x "$top_builddir/extra/scripts/unifdef"; then
echo "Error: need '$top_builddir/extra/scripts/unifdef' executable"
exit 1
fi
-
# Sanitize and copy uclibc headers
(
-# We must cd, or else we'll prepend "$1" to filenames!
-cd "$1" || exit 1
-find ! -name '.' -a ! -path '*/.*'
+# We must cd, or else we will prepend "${srcdir}" to filenames!
+cd "${srcdir}" || exit 1
+find . ! -name '.' -a ! -path '*/.*' | sed -e 's/^\.\///' -e '/^config\//d' \
+ -e '/^config$/d'
) | \
(
IFS=''
while read -r filename; do
- filename="${filename#./}"
- if test -d "$1/$filename"; then
- mkdir -p "$2/$filename" 2>/dev/null
- else
- # NB: unifdef exits with 1 if output is not
- # exactly the same as input. That's ok.
- # Do not abort the script if unifdef "fails"!
- "$top_builddir/extra/scripts/unifdef" -UUCLIBC_INTERNAL "$1/$filename" \
- | grep -v '^libc_hidden_proto[ ]*([a-zA-Z0-9_]*)$' >"$2/$filename"
+ if test -d "${srcdir}/$filename"; then
+ mkdir -p "${dstdir}/$filename" 2>/dev/null
+ continue
fi
+ if test x"${filename##libc-*.h}" = x""; then
+ # Do not install libc-XXXX.h files
+ continue
+ fi
+ # Do not abort the script if unifdef "fails"!
+ # NB2: careful with sed command arguments, they contain tab character
+ "$top_builddir/extra/scripts/unifdef" \
+ -B \
+ -t \
+ -x 2 \
+ -f "$top_builddir/include/generated/unifdef_config.h" \
+ -U_LIBC \
+ -U__UCLIBC_GEN_LOCALE \
+ -U__NO_CTYPE \
+ "${srcdir}/$filename" \
+ | sed -e '/^rtld_hidden_proto[ ]*([a-zA-Z0-9_]*)$/d' \
+ | sed -e '/^lib\(c\|m\|resolv\|dl\|intl\|rt\|nsl\|util\|crypt\|pthread\)_hidden_proto[ ]*([a-zA-Z0-9_]*)$/d' \
+ > "${dstdir}/$filename"
done
)
# Fix mode/owner bits
-cd "$2" || exit 1
+cd "${dstdir}" || exit 1
chmod -R u=rwX,go=rX . >/dev/null 2>&1
chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$/\1:\2/'` . >/dev/null 2>&1
+
+# ignore errors on unrelated files
+exit 0
diff --git a/extra/scripts/install_kernel_headers.sh b/extra/scripts/install_kernel_headers.sh
deleted file mode 100755
index 7e86eb850..000000000
--- a/extra/scripts/install_kernel_headers.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/sh
-# Parameters:
-# $1 = source dir
-# $2 = dst dir
-# $top_builddir = well you guessed it
-
-die_if_not_dir()
-{
- for dir in "$@"; do
- test -d "$dir" && continue
- echo "Error: '$dir' is not a directory"
- exit 1
- done
-}
-
-
-# Ensure that created dirs/files have 755/644 perms
-umask 022
-
-
-# Sanity tests
-die_if_not_dir "$1"
-mkdir -p "$2" 2>/dev/null
-die_if_not_dir "$2"
-die_if_not_dir "$top_builddir"
-
-
-# Just copy (no sanitization) some kernel headers.
-eval `grep ^KERNEL_HEADERS "$top_builddir/.config"`
-if ! test "$KERNEL_HEADERS" \
-|| ! test -d "$KERNEL_HEADERS/asm" \
-|| ! test -d "$KERNEL_HEADERS/asm-generic" \
-|| ! test -d "$KERNEL_HEADERS/linux" \
-; then
- echo "Error: '$KERNEL_HEADERS' is not a directory containing kernel headers."
- echo "Check KERNEL_HEADERS= in your .config file."
- exit 1
-fi
-# Do the copying only if src and dst dirs are not the same.
-# Be thorough: do not settle just for textual compare,
-# and guard against "pwd" being handled as shell builtin.
-# Double quoting looks weird, but it works (even bbox ash too).
-if test "`(cd "$KERNEL_HEADERS"; env pwd)`" != "`(cd "$2"; env pwd)`"; then
- # NB: source or target files and directories may be symlinks,
- # and for all we know, good reasons.
- # We must work correctly in these cases. This includes "do not replace
- # target symlink with real directory" rule. So, no rm -rf here please.
- mkdir -p "$2/asm" 2>/dev/null
- mkdir -p "$2/linux" 2>/dev/null
- # Exists, but is not a dir? That's bad, bail out
- die_if_not_dir "$2/asm" "$2/linux"
- # cp -HL creates regular destination files even if sources are symlinks.
- # This is intended.
- # (NB: you need busybox 1.11.x for this. earlier ones are slightly buggy)
- cp -RHL "$KERNEL_HEADERS/asm"/* "$2/asm" || exit 1
- cp -RHL "$KERNEL_HEADERS/linux"/* "$2/linux" || exit 1
- # Linux 2.4 doesn't have it
- if test -d "$KERNEL_HEADERS/asm-generic"; then
- mkdir -p "$2/asm-generic" 2>/dev/null
- die_if_not_dir "$2/asm-generic"
- cp -RHL "$KERNEL_HEADERS/asm-generic"/* "$2/asm-generic" || exit 1
- fi
- if ! test -f "$2/linux/version.h"; then
- echo "Warning: '$KERNEL_HEADERS/linux/version.h' is not found"
- echo "in kernel headers directory specified in .config."
- echo "Some programs won't like that. Consider fixing it by hand."
- fi
-fi
-
-
-# Fix mode/owner bits
-cd "$2" || exit 1
-chmod -R u=rwX,go=rX . >/dev/null 2>&1
-chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$/\1:\2/'` . >/dev/null 2>&1
diff --git a/extra/scripts/none.lds b/extra/scripts/none.lds
new file mode 100644
index 000000000..d6bd05afc
--- /dev/null
+++ b/extra/scripts/none.lds
@@ -0,0 +1,13 @@
+/* GNU ld script
+ * Used by the build system to probe flags.
+ * Discards all output to avoid error
+ * "failed to merge target specific data of file %B". */
+TARGET(binary)
+INPUT(/dev/null)
+/* We could as well omit the whole SECTIONS block.
+ * This redundancy is just for clarity. */
+SECTIONS
+{
+ /DISCARD/ : { *(*) }
+}
+
diff --git a/extra/scripts/randconfig.sh b/extra/scripts/randconfig.sh
index d0be318c8..d83731b6e 100755
--- a/extra/scripts/randconfig.sh
+++ b/extra/scripts/randconfig.sh
@@ -1,19 +1,34 @@
#!/bin/sh
+# build random configurations
+# Usage:
+# ARCH=i386 nohup ./extra/scripts/randconfig.sh & sleep 1800 && touch STOP
+#
+# The above builds random i386 configs and automatically stops after 30 minutes
+
+test "x$AWK" = "x" && AWK=awk
test "x$ARCH" = "x" && ARCH=`uname -m`
KCONFIG_ALLCONFIG=.config.allconfig
(echo TARGET_$ARCH=y
- echo '# UCLIBC_PREGENERATED_LOCALE_DATA is not set'
- echo '# UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA is not set'
+ echo '# DOMULTI is not set'
) > $KCONFIG_ALLCONFIG
export KCONFIG_ALLCONFIG
+if test "x$NCPU" = "x"
+then
+ test -r /proc/cpuinfo && \
+ eval `$AWK 'BEGIN{NCPU=0}
+/processor/{let NCPU++}
+END{if (NCPU<1) {NCPU=1}; print("NCPU="NCPU);}' /proc/cpuinfo` || \
+ NCPU=1
+fi
+MAKELEVEL="-j$NCPU"
i=0
while test ! -f STOP
do
- make $* randconfig > /dev/null
- make $* silentoldconfig > /dev/null
- if (make $*) 2>&1 >& mk.log
+ ARCH=$ARCH make $* randconfig > /dev/null
+ ARCH=$ARCH make $* silentoldconfig > /dev/null
+ if (make $MAKELEVEL $*) 2>&1 >& mk.log
then
:
else
@@ -24,3 +39,4 @@ do
fi
make distclean > /dev/null || true
done
+rm -f STOP
diff --git a/extra/scripts/relative_path.sh b/extra/scripts/relative_path.sh
index c859646a4..4dddefac1 100755
--- a/extra/scripts/relative_path.sh
+++ b/extra/scripts/relative_path.sh
@@ -33,7 +33,10 @@ case $from in
;;
esac
-prefix=`echo $from///$target | sed 's,\(\(/[^/]*\)*\).*///\1.*,\1,'`
+# Without trailing slash, from=/usr/lib and target=/uclibc/lib
+# mistakenly concludes that prefix=/u
+#prefix=`echo $from///$target | sed 's,\(\(/[^/]*\)*\).*///\1.*,\1,'`
+prefix=`echo $from///$target | sed 's,\(\(/[^/]*\)*/\).*///\1.*,\1,'`
dots=`echo $prefix | sed s,.,.,g`
from=`echo $from | sed "s,^$dots,,"`
target=`echo $target | sed "s,^$dots,,"`
diff --git a/extra/scripts/relinfo.pl b/extra/scripts/relinfo.pl
index ec4a5df13..cb990b36f 100755
--- a/extra/scripts/relinfo.pl
+++ b/extra/scripts/relinfo.pl
@@ -1,5 +1,5 @@
#! /usr/bin/perl
-eval "exec /usr/bin/perl -S $0 $*"
+eval "exec /usr/bin/env perl -w -S $0 $@"
if 0;
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
# Written by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -14,8 +14,7 @@ eval "exec /usr/bin/perl -S $0 $*"
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
for ($cnt = 0; $cnt <= $#ARGV; ++$cnt) {
$relent = 0;
diff --git a/extra/scripts/unifdef.c b/extra/scripts/unifdef.c
index 552025e72..0f059205f 100644
--- a/extra/scripts/unifdef.c
+++ b/extra/scripts/unifdef.c
@@ -1,13 +1,5 @@
/*
- * Copyright (c) 2002 - 2005 Tony Finch <dot@dotat.at>. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by Dave Yost.
- * It was rewritten to support ANSI C by Tony Finch. The original version of
- * unifdef carried the following copyright notice. None of its code remains
- * in this version (though some of the names remain).
- *
- * Copyright (c) 1985, 1993
- * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 2002 - 2014 Tony Finch <dot@dotat.at>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,27 +23,15 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-
-#ifndef lint
-#if 0
-static const char copyright[] =
-"@(#) Copyright (c) 1985, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif
-#ifdef __IDSTRING
-__IDSTRING(Berkeley, "@(#)unifdef.c 8.1 (Berkeley) 6/6/93");
-__IDSTRING(NetBSD, "$NetBSD: unifdef.c,v 1.8 2000/07/03 02:51:36 matt Exp $");
-__IDSTRING(dotat, "$dotat: things/unifdef.c,v 1.171 2005/03/08 12:38:48 fanf2 Exp $");
-#endif
-#endif /* not lint */
-#ifdef __FBSDID
-__FBSDID("$FreeBSD: /repoman/r/ncvs/src/usr.bin/unifdef/unifdef.c,v 1.20 2005/05/21 09:55:09 ru Exp $");
-#endif
-
/*
* unifdef - remove ifdef'ed lines
*
+ * This code was derived from software contributed to Berkeley by Dave Yost.
+ * It was rewritten to support ANSI C by Tony Finch. The original version
+ * of unifdef carried the 4-clause BSD copyright licence. None of its code
+ * remains in this version (though some of the names remain) so it now
+ * carries a more liberal licence.
+ *
* Wishlist:
* provide an option which will append the name of the
* appropriate symbol after #else's and #endif's
@@ -59,20 +39,17 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/usr.bin/unifdef/unifdef.c,v 1.20 2005/05
* #else's and #endif's to see that they match their
* corresponding #ifdef or #ifndef
*
- * The first two items above require better buffer handling, which would
- * also make it possible to handle all "dodgy" directives correctly.
+ * These require better buffer handling, which would also make
+ * it possible to handle all "dodgy" directives correctly.
*/
-#include <ctype.h>
-#include <err.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include "unifdef.h"
-size_t strlcpy(char *dst, const char *src, size_t siz);
+static const char copyright[] =
+ #include "version.h"
+ "@(#) $Author: Tony Finch (dot@dotat.at) $\n"
+ "@(#) $URL: http://dotat.at/prog/unifdef $\n"
+;
/* types of input lines: */
typedef enum {
@@ -90,6 +67,7 @@ typedef enum {
LT_DODGY_LAST = LT_DODGY + LT_ENDIF,
LT_PLAIN, /* ordinary line */
LT_EOF, /* end of file */
+ LT_ERROR, /* unevaluable #if */
LT_COUNT
} Linetype;
@@ -100,9 +78,12 @@ static char const * const linetype_name[] = {
"DODGY IF", "DODGY TRUE", "DODGY FALSE",
"DODGY ELIF", "DODGY ELTRUE", "DODGY ELFALSE",
"DODGY ELSE", "DODGY ENDIF",
- "PLAIN", "EOF"
+ "PLAIN", "EOF", "ERROR"
};
+#define linetype_if2elif(lt) ((Linetype)(lt - LT_IF + LT_ELIF))
+#define linetype_2dodgy(lt) ((Linetype)(lt + LT_DODGY))
+
/* state of #if processing */
typedef enum {
IS_OUTSIDE,
@@ -156,7 +137,7 @@ static char const * const linestate_name[] = {
*/
#define MAXDEPTH 64 /* maximum #if nesting */
#define MAXLINE 4096 /* maximum length of line */
-#define MAXSYMS 4096 /* maximum number of symbols */
+#define MAXSYMS 16384 /* maximum number of symbols */
/*
* Sometimes when editing a keyword the replacement text is longer, so
@@ -168,13 +149,17 @@ static char const * const linestate_name[] = {
* Globals.
*/
+static bool compblank; /* -B: compress blank lines */
+static bool lnblank; /* -b: blank deleted lines */
static bool complement; /* -c: do the complement */
static bool debugging; /* -d: debugging reports */
+static bool inplace; /* -m: modify in place */
static bool iocccok; /* -e: fewer IOCCC errors */
+static bool strictlogic; /* -K: keep ambiguous #ifs */
static bool killconsts; /* -k: eval constant #ifs */
-static bool lnblank; /* -l: blank deleted lines */
static bool lnnum; /* -n: add #line directives */
static bool symlist; /* -s: output symbol list */
+static bool symdepth; /* -S: output symbol depth */
static bool text; /* -t: this is a text file */
static const char *symname[MAXSYMS]; /* symbol name */
@@ -185,10 +170,28 @@ static int nsyms; /* number of symbols */
static FILE *input; /* input file pointer */
static const char *filename; /* input file name */
static int linenum; /* current line number */
+static const char *linefile; /* file name for #line */
+static FILE *output; /* output file pointer */
+static const char *ofilename; /* output file name */
+static const char *backext; /* backup extension */
+static char *tempname; /* avoid splatting input */
static char tline[MAXLINE+EDITSLOP];/* input buffer plus space */
static char *keyword; /* used for editing #elif's */
+/*
+ * When processing a file, the output's newline style will match the
+ * input's, and unifdef correctly handles CRLF or LF endings whatever
+ * the platform's native style. The stdio streams are opened in binary
+ * mode to accommodate platforms whose native newline style is CRLF.
+ * When the output isn't a processed input file (when it is error /
+ * debug / diagnostic messages) then unifdef uses native line endings.
+ */
+
+static const char *newline; /* input file format */
+static const char newline_unix[] = "\n";
+static const char newline_crlf[] = "\r\n";
+
static Comment_state incomment; /* comment parser state */
static Line_state linestate; /* #if line parser state */
static Ifstate ifstate[MAXDEPTH]; /* #if processor state */
@@ -196,31 +199,53 @@ static bool ignoring[MAXDEPTH]; /* ignore comments state */
static int stifline[MAXDEPTH]; /* start of current #if */
static int depth; /* current #if nesting */
static int delcount; /* count of deleted lines */
-static bool keepthis; /* don't delete constant #if */
+static unsigned blankcount; /* count of blank lines */
+static unsigned blankmax; /* maximum recent blankcount */
+static bool constexpr; /* constant #if expression */
+static bool zerosyms; /* to format symdepth output */
+static bool firstsym; /* ditto */
+static int exitmode; /* exit status mode */
static int exitstat; /* program exit status */
+static bool altered; /* was this file modified? */
-static void addsym(bool, bool, char *);
+static void addsym1(bool, bool, char *);
+static void addsym2(bool, const char *, const char *);
+static char *astrcat(const char *, const char *);
+static void cleantemp(void);
+static void closeio(void);
static void debug(const char *, ...);
+static void debugsym(const char *, int);
+static bool defundef(void);
+static void defundefile(const char *);
static void done(void);
static void error(const char *);
-static int findsym(const char *);
+static int findsym(const char **);
static void flushline(bool);
-static Linetype getline(void);
+static void hashline(void);
+static void help(void);
static Linetype ifeval(const char **);
static void ignoreoff(void);
static void ignoreon(void);
+static void indirectsym(void);
static void keywordedit(const char *);
+static const char *matchsym(const char *, const char *);
static void nest(void);
+static Linetype parseline(void);
static void process(void);
+static void processinout(const char *, const char *);
+static const char *skipargs(const char *);
static const char *skipcomment(const char *);
+static const char *skiphash(void);
+static const char *skipline(const char *);
static const char *skipsym(const char *);
static void state(Ifstate);
-static int strlcmp(const char *, const char *, size_t);
static void unnest(void);
static void usage(void);
+static void version(void);
+static const char *xstrdup(const char *, const char *);
-#define endsym(c) (!isalpha((unsigned char)c) && !isdigit((unsigned char)c) && c != '_')
+#define endsym(c) (!isalnum((unsigned char)c) && c != '_')
/*
* The main program.
@@ -230,7 +255,7 @@ main(int argc, char *argv[])
{
int opt;
- while ((opt = getopt(argc, argv, "i:D:U:I:cdeklnst")) != -1)
+ while ((opt = getopt(argc, argv, "i:D:U:f:I:M:o:x:bBcdehKklmnsStV")) != -1)
switch (opt) {
case 'i': /* treat stuff controlled by these symbols as text */
/*
@@ -240,20 +265,26 @@ main(int argc, char *argv[])
*/
opt = *optarg++;
if (opt == 'D')
- addsym(true, true, optarg);
+ addsym1(true, true, optarg);
else if (opt == 'U')
- addsym(true, false, optarg);
+ addsym1(true, false, optarg);
else
usage();
break;
case 'D': /* define a symbol */
- addsym(false, true, optarg);
+ addsym1(false, true, optarg);
break;
case 'U': /* undef a symbol */
- addsym(false, false, optarg);
+ addsym1(false, false, optarg);
+ break;
+ case 'I': /* no-op for compatibility with cpp */
break;
- case 'I':
- /* no-op for compatibility with cpp */
+ case 'b': /* blank deleted lines instead of omitting them */
+ case 'l': /* backwards compatibility */
+ lnblank = true;
+ break;
+ case 'B': /* compress blank lines around removed section */
+ compblank = true;
break;
case 'c': /* treat -D as -U and vice versa */
complement = true;
@@ -264,49 +295,214 @@ main(int argc, char *argv[])
case 'e': /* fewer errors from dodgy lines */
iocccok = true;
break;
+ case 'f': /* definitions file */
+ defundefile(optarg);
+ break;
+ case 'h':
+ help();
+ break;
+ case 'K': /* keep ambiguous #ifs */
+ strictlogic = true;
+ break;
case 'k': /* process constant #ifs */
killconsts = true;
break;
- case 'l': /* blank deleted lines instead of omitting them */
- lnblank = true;
+ case 'm': /* modify in place */
+ inplace = true;
+ break;
+ case 'M': /* modify in place and keep backup */
+ inplace = true;
+ backext = optarg;
break;
case 'n': /* add #line directive after deleted lines */
lnnum = true;
break;
+ case 'o': /* output to a file */
+ ofilename = optarg;
+ break;
case 's': /* only output list of symbols that control #ifs */
symlist = true;
break;
+ case 'S': /* list symbols with their nesting depth */
+ symlist = symdepth = true;
+ break;
case 't': /* don't parse C comments */
text = true;
break;
+ case 'V':
+ version();
+ break;
+ case 'x':
+ exitmode = atoi(optarg);
+ if(exitmode < 0 || exitmode > 2)
+ usage();
+ break;
default:
usage();
}
argc -= optind;
argv += optind;
- if (argc > 1) {
- errx(2, "can only do one file");
- } else if (argc == 1 && strcmp(*argv, "-") != 0) {
- filename = *argv;
- input = fopen(filename, "r");
- if (input == NULL)
- err(2, "can't open %s", filename);
- } else {
+ if (compblank && lnblank)
+ errx(2, "-B and -b are mutually exclusive");
+ if (symlist && (ofilename != NULL || inplace || argc > 1))
+ errx(2, "-s only works with one input file");
+ if (argc > 1 && ofilename != NULL)
+ errx(2, "-o cannot be used with multiple input files");
+ if (argc > 1 && !inplace)
+ errx(2, "multiple input files require -m or -M");
+ if (argc == 0)
+ argc = 1;
+ if (argc == 1 && !inplace && ofilename == NULL)
+ ofilename = "-";
+ indirectsym();
+
+ atexit(cleantemp);
+ if (ofilename != NULL)
+ processinout(*argv, ofilename);
+ else while (argc-- > 0) {
+ processinout(*argv, *argv);
+ argv++;
+ }
+ switch(exitmode) {
+ case(0): exit(exitstat);
+ case(1): exit(!exitstat);
+ case(2): exit(0);
+ default: abort(); /* bug */
+ }
+}
+
+/*
+ * File logistics.
+ */
+static void
+processinout(const char *ifn, const char *ofn)
+{
+ struct stat st;
+
+ if (ifn == NULL || strcmp(ifn, "-") == 0) {
filename = "[stdin]";
- input = stdin;
+ linefile = NULL;
+ input = fbinmode(stdin);
+ } else {
+ filename = ifn;
+ linefile = ifn;
+ input = fopen(ifn, "rb");
+ if (input == NULL)
+ err(2, "can't open %s", ifn);
+ }
+ if (strcmp(ofn, "-") == 0) {
+ output = fbinmode(stdout);
+ process();
+ return;
}
+ if (stat(ofn, &st) < 0) {
+ output = fopen(ofn, "wb");
+ if (output == NULL)
+ err(2, "can't create %s", ofn);
+ process();
+ return;
+ }
+
+ tempname = astrcat(ofn, ".XXXXXX");
+ output = mktempmode(tempname, st.st_mode);
+ if (output == NULL)
+ err(2, "can't create %s", tempname);
+
process();
- abort(); /* bug */
+
+ if (backext != NULL) {
+ char *backname = astrcat(ofn, backext);
+ if (rename(ofn, backname) < 0)
+ err(2, "can't rename \"%s\" to \"%s\"", ofn, backname);
+ free(backname);
+ }
+ /* leave file unmodified if unifdef made no changes */
+ if (!altered && backext == NULL) {
+ if (remove(tempname) < 0)
+ warn("can't remove \"%s\"", tempname);
+ } else if (replace(tempname, ofn) < 0)
+ err(2, "can't rename \"%s\" to \"%s\"", tempname, ofn);
+ free(tempname);
+ tempname = NULL;
+}
+
+/*
+ * For cleaning up if there is an error.
+ */
+static void
+cleantemp(void)
+{
+ if (tempname != NULL)
+ remove(tempname);
+}
+
+/*
+ * Self-identification functions.
+ */
+
+static void
+version(void)
+{
+ const char *c = copyright;
+ for (;;) {
+ while (*++c != '$')
+ if (*c == '\0')
+ exit(0);
+ while (*++c != '$')
+ putc(*c, stderr);
+ putc('\n', stderr);
+ }
+}
+
+static void
+synopsis(FILE *fp)
+{
+ fprintf(fp,
+ "usage: unifdef [-bBcdehKkmnsStV] [-x{012}] [-Mext] [-opath] \\\n"
+ " [-[i]Dsym[=val]] [-[i]Usym] [-fpath] ... [file] ...\n");
}
static void
usage(void)
{
- fprintf(stderr, "usage: unifdef [-cdeklnst] [-Ipath]"
- " [-Dsym[=val]] [-Usym] [-iDsym[=val]] [-iUsym] ... [file]\n");
+ synopsis(stderr);
exit(2);
}
+static void
+help(void)
+{
+ synopsis(stdout);
+ printf(
+ " -Dsym=val define preprocessor symbol with given value\n"
+ " -Dsym define preprocessor symbol with value 1\n"
+ " -Usym preprocessor symbol is undefined\n"
+ " -iDsym=val \\ ignore C strings and comments\n"
+ " -iDsym ) in sections controlled by these\n"
+ " -iUsym / preprocessor symbols\n"
+ " -fpath file containing #define and #undef directives\n"
+ " -b blank lines instead of deleting them\n"
+ " -B compress blank lines around deleted section\n"
+ " -c complement (invert) keep vs. delete\n"
+ " -d debugging mode\n"
+ " -e ignore multiline preprocessor directives\n"
+ " -h print help\n"
+ " -Ipath extra include file path (ignored)\n"
+ " -K disable && and || short-circuiting\n"
+ " -k process constant #if expressions\n"
+ " -Mext modify in place and keep backups\n"
+ " -m modify input files in place\n"
+ " -n add #line directives to output\n"
+ " -opath output file name\n"
+ " -S list #if control symbols with nesting\n"
+ " -s list #if control symbols\n"
+ " -t ignore C strings and comments\n"
+ " -V print version\n"
+ " -x{012} exit status mode\n"
+ );
+ exit(0);
+}
+
/*
* A state transition function alters the global #if processing state
* in a particular way. The table below is indexed by the current
@@ -320,7 +516,8 @@ usage(void)
* When we have processed a group that starts off with a known-false
* #if/#elif sequence (which has therefore been deleted) followed by a
* #elif that we don't understand and therefore must keep, we edit the
- * latter into a #if to keep the nesting correct.
+ * latter into a #if to keep the nesting correct. We use memcpy() to
+ * overwrite the 4 byte token "elif" with "if " without a '\0' byte.
*
* When we find a true #elif in a group, the following block will
* always be kept and the rest of the sequence after the next #elif or
@@ -373,69 +570,62 @@ static void Oelif (void) { if (!iocccok) Eioccc(); Pelif(); }
static void Idrop (void) { Fdrop(); ignoreon(); }
static void Itrue (void) { Ftrue(); ignoreon(); }
static void Ifalse(void) { Ffalse(); ignoreon(); }
-/* edit this line */
-static void Mpass (void) { strncpy(keyword, "if ", 4); Pelif(); }
-static void Mtrue (void) { keywordedit("else\n"); state(IS_TRUE_MIDDLE); }
-static void Melif (void) { keywordedit("endif\n"); state(IS_FALSE_TRAILER); }
-static void Melse (void) { keywordedit("endif\n"); state(IS_FALSE_ELSE); }
+/* modify this line */
+static void Mpass (void) { memcpy(keyword, "if ", 4); Pelif(); }
+static void Mtrue (void) { keywordedit("else"); state(IS_TRUE_MIDDLE); }
+static void Melif (void) { keywordedit("endif"); state(IS_FALSE_TRAILER); }
+static void Melse (void) { keywordedit("endif"); state(IS_FALSE_ELSE); }
static state_fn * const trans_table[IS_COUNT][LT_COUNT] = {
/* IS_OUTSIDE */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Eendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Eelif, Eelif, Eelif, Eelse, Eendif,
- print, done },
+ print, done, abort },
/* IS_FALSE_PREFIX */
{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Mpass, Strue, Sfalse,Selse, Dendif,
Idrop, Idrop, Fdrop, Fdrop, Fdrop, Mpass, Eioccc,Eioccc,Eioccc,Eioccc,
- drop, Eeof },
+ drop, Eeof, abort },
/* IS_TRUE_PREFIX */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Dfalse,Dfalse,Dfalse,Delse, Dendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Eioccc,Eioccc,Eioccc,Eioccc,Eioccc,
- print, Eeof },
+ print, Eeof, abort },
/* IS_PASS_MIDDLE */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Pelif, Mtrue, Delif, Pelse, Pendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Pelif, Oelif, Oelif, Pelse, Pendif,
- print, Eeof },
+ print, Eeof, abort },
/* IS_FALSE_MIDDLE */
{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Pelif, Mtrue, Delif, Pelse, Pendif,
Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eioccc,Eioccc,Eioccc,Eioccc,Eioccc,
- drop, Eeof },
+ drop, Eeof, abort },
/* IS_TRUE_MIDDLE */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Melif, Melif, Melif, Melse, Pendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Eioccc,Eioccc,Eioccc,Eioccc,Pendif,
- print, Eeof },
+ print, Eeof, abort },
/* IS_PASS_ELSE */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Pendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Eelif, Eelif, Eelif, Eelse, Pendif,
- print, Eeof },
+ print, Eeof, abort },
/* IS_FALSE_ELSE */
{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eelif, Eelif, Eelif, Eelse, Dendif,
Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eelif, Eelif, Eelif, Eelse, Eioccc,
- drop, Eeof },
+ drop, Eeof, abort },
/* IS_TRUE_ELSE */
{ Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Dendif,
Oiffy, Oiffy, Fpass, Oif, Oif, Eelif, Eelif, Eelif, Eelse, Eioccc,
- print, Eeof },
+ print, Eeof, abort },
/* IS_FALSE_TRAILER */
{ Idrop, Idrop, Fdrop, Fdrop, Fdrop, Dfalse,Dfalse,Dfalse,Delse, Dendif,
Idrop, Idrop, Fdrop, Fdrop, Fdrop, Dfalse,Dfalse,Dfalse,Delse, Eioccc,
- drop, Eeof }
+ drop, Eeof, abort }
/*TRUEI FALSEI IF TRUE FALSE ELIF ELTRUE ELFALSE ELSE ENDIF
TRUEI FALSEI IF TRUE FALSE ELIF ELTRUE ELFALSE ELSE ENDIF (DODGY)
- PLAIN EOF */
+ PLAIN EOF ERROR */
};
/*
* State machine utility functions
*/
static void
-done(void)
-{
- if (incomment)
- error("EOF in comment");
- exit(exitstat);
-}
-static void
ignoreoff(void)
{
if (depth == 0)
@@ -450,22 +640,19 @@ ignoreon(void)
static void
keywordedit(const char *replacement)
{
- size_t size = tline + sizeof(tline) - keyword;
- char *dst = keyword;
- const char *src = replacement;
- if (size != 0) {
- while ((--size != 0) && (*src != '\0'))
- *dst++ = *src++;
- *dst = '\0';
- }
+ snprintf(keyword, tline + sizeof(tline) - keyword,
+ "%s%s", replacement, newline);
+ altered = true;
print();
}
static void
nest(void)
{
- depth += 1;
- if (depth >= MAXDEPTH)
+ if (depth > MAXDEPTH-1)
+ abort(); /* bug */
+ if (depth == MAXDEPTH-1)
error("Too many levels of nesting");
+ depth += 1;
stifline[depth] = linenum;
}
static void
@@ -482,7 +669,20 @@ state(Ifstate is)
}
/*
+ * The last state transition function. When this is called,
+ * lineval == LT_EOF, so the process() loop will terminate.
+ */
+static void
+done(void)
+{
+ if (incomment)
+ error("EOF in comment");
+ closeio();
+}
+
+/*
* Write a line to the output or not, according to command line options.
+ * If writing fails, closeio() will print the error and exit.
*/
static void
flushline(bool keep)
@@ -490,16 +690,58 @@ flushline(bool keep)
if (symlist)
return;
if (keep ^ complement) {
- if (lnnum && delcount > 0)
- printf("#line %d\n", linenum);
- fputs(tline, stdout);
- delcount = 0;
+ bool blankline = tline[strspn(tline, " \t\r\n")] == '\0';
+ if (blankline && compblank && blankcount != blankmax) {
+ delcount += 1;
+ blankcount += 1;
+ } else {
+ if (lnnum && delcount > 0)
+ hashline();
+ if (fputs(tline, output) == EOF)
+ closeio();
+ delcount = 0;
+ blankmax = blankcount = blankline ? blankcount + 1 : 0;
+ }
} else {
- if (lnblank)
- putc('\n', stdout);
- exitstat = 1;
+ if (lnblank && fputs(newline, output) == EOF)
+ closeio();
+ altered = true;
delcount += 1;
+ blankcount = 0;
}
+ if (debugging && fflush(output) == EOF)
+ closeio();
+}
+
+/*
+ * Format of #line directives depends on whether we know the input filename.
+ */
+static void
+hashline(void)
+{
+ int e;
+
+ if (linefile == NULL)
+ e = fprintf(output, "#line %d%s", linenum, newline);
+ else
+ e = fprintf(output, "#line %d \"%s\"%s",
+ linenum, linefile, newline);
+ if (e < 0)
+ closeio();
+}
+
+/*
+ * Flush the output and handle errors.
+ */
+static void
+closeio(void)
+{
+ /* Tidy up after findsym(). */
+ if (symdepth && !zerosyms)
+ printf("\n");
+ if (output != NULL && (ferror(output) || fclose(output) == EOF))
+ err(2, "%s: can't write to output", filename);
+ fclose(input);
}
/*
@@ -508,16 +750,22 @@ flushline(bool keep)
static void
process(void)
{
- Linetype lineval;
-
- for (;;) {
- linenum++;
- lineval = getline();
+ Linetype lineval = LT_PLAIN;
+ /* When compressing blank lines, act as if the file
+ is preceded by a large number of blank lines. */
+ blankmax = blankcount = 1000;
+ zerosyms = true;
+ newline = NULL;
+ linenum = 0;
+ altered = false;
+ while (lineval != LT_EOF) {
+ lineval = parseline();
trans_table[ifstate[depth]][lineval]();
- debug("process %s -> %s depth %d",
- linetype_name[lineval],
+ debug("process line %d %s -> %s depth %d",
+ linenum, linetype_name[lineval],
ifstate_name[ifstate[depth]], depth);
}
+ exitstat |= altered;
}
/*
@@ -526,101 +774,131 @@ process(void)
* help from skipcomment().
*/
static Linetype
-getline(void)
+parseline(void)
{
const char *cp;
int cursym;
- int kwlen;
Linetype retval;
Comment_state wascomment;
- if (fgets(tline, MAXLINE, input) == NULL)
- return (LT_EOF);
- retval = LT_PLAIN;
wascomment = incomment;
- cp = skipcomment(tline);
- if (linestate == LS_START) {
- if (*cp == '#') {
- linestate = LS_HASH;
- cp = skipcomment(cp + 1);
- } else if (*cp != '\0')
- linestate = LS_DIRTY;
+ cp = skiphash();
+ if (cp == NULL)
+ return (LT_EOF);
+ if (newline == NULL) {
+ if (strrchr(tline, '\n') == strrchr(tline, '\r') + 1)
+ newline = newline_crlf;
+ else
+ newline = newline_unix;
}
- if (!incomment && linestate == LS_HASH) {
- keyword = tline + (cp - tline);
- cp = skipsym(cp);
- kwlen = cp - keyword;
- /* no way can we deal with a continuation inside a keyword */
- if (strncmp(cp, "\\\n", 2) == 0)
- Eioccc();
- if (strlcmp("ifdef", keyword, kwlen) == 0 ||
- strlcmp("ifndef", keyword, kwlen) == 0) {
- cp = skipcomment(cp);
- if ((cursym = findsym(cp)) < 0)
- retval = LT_IF;
- else {
- retval = (keyword[2] == 'n')
- ? LT_FALSE : LT_TRUE;
- if (value[cursym] == NULL)
- retval = (retval == LT_TRUE)
- ? LT_FALSE : LT_TRUE;
- if (ignore[cursym])
- retval = (retval == LT_TRUE)
- ? LT_TRUEI : LT_FALSEI;
- }
- cp = skipsym(cp);
- } else if (strlcmp("if", keyword, kwlen) == 0)
- retval = ifeval(&cp);
- else if (strlcmp("elif", keyword, kwlen) == 0)
- retval = ifeval(&cp) - LT_IF + LT_ELIF;
- else if (strlcmp("else", keyword, kwlen) == 0)
- retval = LT_ELSE;
- else if (strlcmp("endif", keyword, kwlen) == 0)
- retval = LT_ENDIF;
+ if (*cp == '\0') {
+ retval = LT_PLAIN;
+ goto done;
+ }
+ keyword = tline + (cp - tline);
+ if ((cp = matchsym("ifdef", keyword)) != NULL ||
+ (cp = matchsym("ifndef", keyword)) != NULL) {
+ cp = skipcomment(cp);
+ if ((cursym = findsym(&cp)) < 0)
+ retval = LT_IF;
else {
- linestate = LS_DIRTY;
- retval = LT_PLAIN;
+ retval = (keyword[2] == 'n')
+ ? LT_FALSE : LT_TRUE;
+ if (value[cursym] == NULL)
+ retval = (retval == LT_TRUE)
+ ? LT_FALSE : LT_TRUE;
+ if (ignore[cursym])
+ retval = (retval == LT_TRUE)
+ ? LT_TRUEI : LT_FALSEI;
}
- cp = skipcomment(cp);
- if (*cp != '\0') {
+ } else if ((cp = matchsym("if", keyword)) != NULL)
+ retval = ifeval(&cp);
+ else if ((cp = matchsym("elif", keyword)) != NULL)
+ retval = linetype_if2elif(ifeval(&cp));
+ else if ((cp = matchsym("else", keyword)) != NULL)
+ retval = LT_ELSE;
+ else if ((cp = matchsym("endif", keyword)) != NULL)
+ retval = LT_ENDIF;
+ else {
+ cp = skipsym(keyword);
+ /* no way can we deal with a continuation inside a keyword */
+ if (strncmp(cp, "\\\r\n", 3) == 0 ||
+ strncmp(cp, "\\\n", 2) == 0)
+ Eioccc();
+ cp = skipline(cp);
+ retval = LT_PLAIN;
+ goto done;
+ }
+ cp = skipcomment(cp);
+ if (*cp != '\0') {
+ cp = skipline(cp);
+ if (retval == LT_TRUE || retval == LT_FALSE ||
+ retval == LT_TRUEI || retval == LT_FALSEI)
+ retval = LT_IF;
+ if (retval == LT_ELTRUE || retval == LT_ELFALSE)
+ retval = LT_ELIF;
+ }
+ /* the following can happen if the last line of the file lacks a
+ newline or if there is too much whitespace in a directive */
+ if (linestate == LS_HASH) {
+ long len = cp - tline;
+ if (fgets(tline + len, MAXLINE - len, input) == NULL) {
+ if (ferror(input))
+ err(2, "can't read %s", filename);
+ /* append the missing newline at eof */
+ strcpy(tline + len, newline);
+ cp += strlen(newline);
+ linestate = LS_START;
+ } else {
linestate = LS_DIRTY;
- if (retval == LT_TRUE || retval == LT_FALSE ||
- retval == LT_TRUEI || retval == LT_FALSEI)
- retval = LT_IF;
- if (retval == LT_ELTRUE || retval == LT_ELFALSE)
- retval = LT_ELIF;
- }
- if (retval != LT_PLAIN && (wascomment || incomment)) {
- retval += LT_DODGY;
- if (incomment)
- linestate = LS_DIRTY;
}
- /* skipcomment should have changed the state */
- if (linestate == LS_HASH)
- abort(); /* bug */
}
- if (linestate == LS_DIRTY) {
- while (*cp != '\0')
- cp = skipcomment(cp + 1);
+ if (retval != LT_PLAIN && (wascomment || linestate != LS_START)) {
+ retval = linetype_2dodgy(retval);
+ linestate = LS_DIRTY;
}
- debug("parser %s comment %s line",
+done:
+ debug("parser line %d state %s comment %s line", linenum,
comment_name[incomment], linestate_name[linestate]);
return (retval);
}
/*
* These are the binary operators that are supported by the expression
- * evaluator. Note that if support for division is added then we also
- * need short-circuiting booleans because of divide-by-zero.
+ * evaluator.
*/
-static int op_lt(int a, int b) { return (a < b); }
-static int op_gt(int a, int b) { return (a > b); }
-static int op_le(int a, int b) { return (a <= b); }
-static int op_ge(int a, int b) { return (a >= b); }
-static int op_eq(int a, int b) { return (a == b); }
-static int op_ne(int a, int b) { return (a != b); }
-static int op_or(int a, int b) { return (a || b); }
-static int op_and(int a, int b) { return (a && b); }
+static Linetype op_strict(long *p, long v, Linetype at, Linetype bt) {
+ if(at == LT_IF || bt == LT_IF) return (LT_IF);
+ return (*p = v, v ? LT_TRUE : LT_FALSE);
+}
+static Linetype op_lt(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a < b, at, bt);
+}
+static Linetype op_gt(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a > b, at, bt);
+}
+static Linetype op_le(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a <= b, at, bt);
+}
+static Linetype op_ge(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a >= b, at, bt);
+}
+static Linetype op_eq(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a == b, at, bt);
+}
+static Linetype op_ne(long *p, Linetype at, long a, Linetype bt, long b) {
+ return op_strict(p, a != b, at, bt);
+}
+static Linetype op_or(long *p, Linetype at, long a, Linetype bt, long b) {
+ if (!strictlogic && (at == LT_TRUE || bt == LT_TRUE))
+ return (*p = 1, LT_TRUE);
+ return op_strict(p, a || b, at, bt);
+}
+static Linetype op_and(long *p, Linetype at, long a, Linetype bt, long b) {
+ if (!strictlogic && (at == LT_FALSE || bt == LT_FALSE))
+ return (*p = 0, LT_FALSE);
+ return op_strict(p, a && b, at, bt);
+}
/*
* An evaluation function takes three arguments, as follows: (1) a pointer to
@@ -629,12 +907,12 @@ static int op_and(int a, int b) { return (a && b); }
* value of the expression; and (3) a pointer to a char* that points to the
* expression to be evaluated and that is updated to the end of the expression
* when evaluation is complete. The function returns LT_FALSE if the value of
- * the expression is zero, LT_TRUE if it is non-zero, or LT_IF if the
- * expression could not be evaluated.
+ * the expression is zero, LT_TRUE if it is non-zero, LT_IF if the expression
+ * depends on an unknown symbol, or LT_ERROR if there is a parse failure.
*/
struct ops;
-typedef Linetype eval_fn(const struct ops *, int *, const char **);
+typedef Linetype eval_fn(const struct ops *, long *, const char **);
static eval_fn eval_table, eval_unary;
@@ -645,13 +923,15 @@ static eval_fn eval_table, eval_unary;
* element of the table. Innermost expressions have special non-table-driven
* handling.
*/
-static const struct ops {
+struct op {
+ const char *str;
+ Linetype (*fn)(long *, Linetype, long, Linetype, long);
+};
+struct ops {
eval_fn *inner;
- struct op {
- const char *str;
- int (*fn)(int, int);
- } op[5];
-} eval_ops[] = {
+ struct op op[5];
+};
+static const struct ops eval_ops[] = {
{ eval_table, { { "||", op_or } } },
{ eval_table, { { "&&", op_and } } },
{ eval_table, { { "==", op_eq },
@@ -662,90 +942,119 @@ static const struct ops {
{ ">", op_gt } } }
};
+/* Current operator precedence level */
+static long prec(const struct ops *ops)
+{
+ return (ops - eval_ops);
+}
+
/*
* Function for evaluating the innermost parts of expressions,
- * viz. !expr (expr) defined(symbol) symbol number
- * We reset the keepthis flag when we find a non-constant subexpression.
+ * viz. !expr (expr) number defined(symbol) symbol
+ * We reset the constexpr flag in the last two cases.
*/
static Linetype
-eval_unary(const struct ops *ops, int *valp, const char **cpp)
+eval_unary(const struct ops *ops, long *valp, const char **cpp)
{
const char *cp;
char *ep;
int sym;
+ bool defparen;
+ Linetype lt;
cp = skipcomment(*cpp);
if (*cp == '!') {
- debug("eval%d !", ops - eval_ops);
+ debug("eval%d !", prec(ops));
cp++;
- if (eval_unary(ops, valp, &cp) == LT_IF)
- return (LT_IF);
- *valp = !*valp;
+ lt = eval_unary(ops, valp, &cp);
+ if (lt == LT_ERROR)
+ return (LT_ERROR);
+ if (lt != LT_IF) {
+ *valp = !*valp;
+ lt = *valp ? LT_TRUE : LT_FALSE;
+ }
} else if (*cp == '(') {
cp++;
- debug("eval%d (", ops - eval_ops);
- if (eval_table(eval_ops, valp, &cp) == LT_IF)
- return (LT_IF);
+ debug("eval%d (", prec(ops));
+ lt = eval_table(eval_ops, valp, &cp);
+ if (lt == LT_ERROR)
+ return (LT_ERROR);
cp = skipcomment(cp);
if (*cp++ != ')')
- return (LT_IF);
+ return (LT_ERROR);
} else if (isdigit((unsigned char)*cp)) {
- debug("eval%d number", ops - eval_ops);
+ debug("eval%d number", prec(ops));
*valp = strtol(cp, &ep, 0);
- cp = skipsym(cp);
- } else if (strncmp(cp, "defined", 7) == 0 && endsym(cp[7])) {
+ if (ep == cp)
+ return (LT_ERROR);
+ lt = *valp ? LT_TRUE : LT_FALSE;
+ cp = ep;
+ } else if (matchsym("defined", cp) != NULL) {
cp = skipcomment(cp+7);
- debug("eval%d defined", ops - eval_ops);
- if (*cp++ != '(')
- return (LT_IF);
- cp = skipcomment(cp);
- sym = findsym(cp);
- if (sym < 0)
- return (LT_IF);
- *valp = (value[sym] != NULL);
- cp = skipsym(cp);
+ if (*cp == '(') {
+ cp = skipcomment(cp+1);
+ defparen = true;
+ } else {
+ defparen = false;
+ }
+ sym = findsym(&cp);
cp = skipcomment(cp);
- if (*cp++ != ')')
- return (LT_IF);
- keepthis = false;
+ if (defparen && *cp++ != ')') {
+ debug("eval%d defined missing ')'", prec(ops));
+ return (LT_ERROR);
+ }
+ if (sym < 0) {
+ debug("eval%d defined unknown", prec(ops));
+ lt = LT_IF;
+ } else {
+ debug("eval%d defined %s", prec(ops), symname[sym]);
+ *valp = (value[sym] != NULL);
+ lt = *valp ? LT_TRUE : LT_FALSE;
+ }
+ constexpr = false;
} else if (!endsym(*cp)) {
- debug("eval%d symbol", ops - eval_ops);
- sym = findsym(cp);
- if (sym < 0)
- return (LT_IF);
- if (value[sym] == NULL)
+ debug("eval%d symbol", prec(ops));
+ sym = findsym(&cp);
+ if (sym < 0) {
+ lt = LT_IF;
+ cp = skipargs(cp);
+ } else if (value[sym] == NULL) {
*valp = 0;
- else {
+ lt = LT_FALSE;
+ } else {
*valp = strtol(value[sym], &ep, 0);
if (*ep != '\0' || ep == value[sym])
- return (LT_IF);
+ return (LT_ERROR);
+ lt = *valp ? LT_TRUE : LT_FALSE;
+ cp = skipargs(cp);
}
- cp = skipsym(cp);
- keepthis = false;
+ constexpr = false;
} else {
- debug("eval%d bad expr", ops - eval_ops);
- return (LT_IF);
+ debug("eval%d bad expr", prec(ops));
+ return (LT_ERROR);
}
*cpp = cp;
- debug("eval%d = %d", ops - eval_ops, *valp);
- return (*valp ? LT_TRUE : LT_FALSE);
+ debug("eval%d = %d", prec(ops), *valp);
+ return (lt);
}
/*
* Table-driven evaluation of binary operators.
*/
static Linetype
-eval_table(const struct ops *ops, int *valp, const char **cpp)
+eval_table(const struct ops *ops, long *valp, const char **cpp)
{
const struct op *op;
const char *cp;
- int val;
+ long val;
+ Linetype lt, rt;
- debug("eval%d", ops - eval_ops);
+ debug("eval%d", prec(ops));
cp = *cpp;
- if (ops->inner(ops+1, valp, &cp) == LT_IF)
- return (LT_IF);
+ lt = ops->inner(ops+1, valp, &cp);
+ if (lt == LT_ERROR)
+ return (LT_ERROR);
for (;;) {
cp = skipcomment(cp);
for (op = ops->op; op->str != NULL; op++)
@@ -754,15 +1063,17 @@ eval_table(const struct ops *ops, int *valp, const char **cpp)
if (op->str == NULL)
break;
cp += strlen(op->str);
- debug("eval%d %s", ops - eval_ops, op->str);
- if (ops->inner(ops+1, &val, &cp) == LT_IF)
- return (LT_IF);
- *valp = op->fn(*valp, val);
+ debug("eval%d %s", prec(ops), op->str);
+ rt = ops->inner(ops+1, &val, &cp);
+ if (rt == LT_ERROR)
+ return (LT_ERROR);
+ lt = op->fn(valp, lt, *valp, rt, val);
}
*cpp = cp;
- debug("eval%d = %d", ops - eval_ops, *valp);
- return (*valp ? LT_TRUE : LT_FALSE);
+ debug("eval%d = %d", prec(ops), *valp);
+ debug("eval%d lt = %s", prec(ops), linetype_name[lt]);
+ return (lt);
}
/*
@@ -773,14 +1084,57 @@ eval_table(const struct ops *ops, int *valp, const char **cpp)
static Linetype
ifeval(const char **cpp)
{
- int ret;
- int val;
+ Linetype ret;
+ long val = 0;
debug("eval %s", *cpp);
- keepthis = killconsts ? false : true;
+ constexpr = killconsts ? false : true;
ret = eval_table(eval_ops, &val, cpp);
debug("eval = %d", val);
- return (keepthis ? LT_IF : ret);
+ return (constexpr ? LT_IF : ret == LT_ERROR ? LT_IF : ret);
+}
+
+/*
+ * Read a line and examine its initial part to determine if it is a
+ * preprocessor directive. Returns NULL on EOF, or a pointer to a
+ * preprocessor directive name, or a pointer to the zero byte at the
+ * end of the line.
+ */
+static const char *
+skiphash(void)
+{
+ const char *cp;
+
+ linenum++;
+ if (fgets(tline, MAXLINE, input) == NULL) {
+ if (ferror(input))
+ err(2, "can't read %s", filename);
+ else
+ return (NULL);
+ }
+ cp = skipcomment(tline);
+ if (linestate == LS_START && *cp == '#') {
+ linestate = LS_HASH;
+ return (skipcomment(cp + 1));
+ } else if (*cp == '\0') {
+ return (cp);
+ } else {
+ return (skipline(cp));
+ }
+}
+
+/*
+ * Mark a line dirty and consume the rest of it, keeping track of the
+ * lexical state.
+ */
+static const char *
+skipline(const char *cp)
+{
+ if (*cp != '\0')
+ linestate = LS_DIRTY;
+ while (*cp != '\0')
+ cp = skipcomment(cp + 1);
+ return (cp);
}
/*
@@ -801,11 +1155,16 @@ skipcomment(const char *cp)
}
while (*cp != '\0')
/* don't reset to LS_START after a line continuation */
- if (strncmp(cp, "\\\n", 2) == 0)
+ if (strncmp(cp, "\\\r\n", 3) == 0)
+ cp += 3;
+ else if (strncmp(cp, "\\\n", 2) == 0)
cp += 2;
else switch (incomment) {
case NO_COMMENT:
- if (strncmp(cp, "/\\\n", 3) == 0) {
+ if (strncmp(cp, "/\\\r\n", 4) == 0) {
+ incomment = STARTING_COMMENT;
+ cp += 4;
+ } else if (strncmp(cp, "/\\\n", 3) == 0) {
incomment = STARTING_COMMENT;
cp += 3;
} else if (strncmp(cp, "/*", 2) == 0) {
@@ -825,7 +1184,7 @@ skipcomment(const char *cp)
} else if (strncmp(cp, "\n", 1) == 0) {
linestate = LS_START;
cp += 1;
- } else if (strchr(" \t", *cp) != NULL) {
+ } else if (strchr(" \r\t", *cp) != NULL) {
cp += 1;
} else
return (cp);
@@ -857,7 +1216,10 @@ skipcomment(const char *cp)
cp += 1;
continue;
case C_COMMENT:
- if (strncmp(cp, "*\\\n", 3) == 0) {
+ if (strncmp(cp, "*\\\r\n", 4) == 0) {
+ incomment = FINISHING_COMMENT;
+ cp += 4;
+ } else if (strncmp(cp, "*\\\n", 3) == 0) {
incomment = FINISHING_COMMENT;
cp += 3;
} else if (strncmp(cp, "*/", 2) == 0) {
@@ -892,6 +1254,31 @@ skipcomment(const char *cp)
}
/*
+ * Skip macro arguments.
+ */
+static const char *
+skipargs(const char *cp)
+{
+ const char *ocp = cp;
+ int level = 0;
+ cp = skipcomment(cp);
+ if (*cp != '(')
+ return (cp);
+ do {
+ if (*cp == '(')
+ level++;
+ if (*cp == ')')
+ level--;
+ cp = skipcomment(cp+1);
+ } while (level != 0 && *cp != '\0');
+ if (level == 0)
+ return (cp);
+ else
+ /* Rewind and re-detect the syntax error later. */
+ return (ocp);
+}
+
+/*
* Skip over an identifier.
*/
static const char *
@@ -903,27 +1290,69 @@ skipsym(const char *cp)
}
/*
- * Look for the symbol in the symbol table. If is is found, we return
+ * Skip whitespace and take a copy of any following identifier.
+ */
+static const char *
+getsym(const char **cpp)
+{
+ const char *cp = *cpp, *sym;
+
+ cp = skipcomment(cp);
+ cp = skipsym(sym = cp);
+ if (cp == sym)
+ return NULL;
+ *cpp = cp;
+ return (xstrdup(sym, cp));
+}
+
+/*
+ * Check that s (a symbol) matches the start of t, and that the
+ * following character in t is not a symbol character. Returns a
+ * pointer to the following character in t if there is a match,
+ * otherwise NULL.
+ */
+static const char *
+matchsym(const char *s, const char *t)
+{
+ while (*s != '\0' && *t != '\0')
+ if (*s != *t)
+ return (NULL);
+ else
+ ++s, ++t;
+ if (*s == '\0' && endsym(*t))
+ return(t);
+ else
+ return(NULL);
+}
+
+/*
+ * Look for the symbol in the symbol table. If it is found, we return
* the symbol table index, else we return -1.
*/
static int
-findsym(const char *str)
+findsym(const char **strp)
{
- const char *cp;
+ const char *str;
int symind;
- cp = skipsym(str);
- if (cp == str)
- return (-1);
+ str = *strp;
+ *strp = skipsym(str);
if (symlist) {
- printf("%.*s\n", (int)(cp-str), str);
+ if (*strp == str)
+ return (-1);
+ if (symdepth && firstsym)
+ printf("%s%3d", zerosyms ? "" : "\n", depth);
+ firstsym = zerosyms = false;
+ printf("%s%.*s%s",
+ symdepth ? " " : "",
+ (int)(*strp-str), str,
+ symdepth ? "" : "\n");
/* we don't care about the value of the symbol */
return (0);
}
for (symind = 0; symind < nsyms; ++symind) {
- if (strlcmp(symname[symind], str, cp-str) == 0) {
- debug("findsym %s %s", symname[symind],
- value[symind] ? value[symind] : "");
+ if (matchsym(symname[symind], str) != NULL) {
+ debugsym("findsym", symind);
return (symind);
}
}
@@ -931,51 +1360,194 @@ findsym(const char *str)
}
/*
+ * Resolve indirect symbol values to their final definitions.
+ */
+static void
+indirectsym(void)
+{
+ const char *cp;
+ int changed, sym, ind;
+
+ do {
+ changed = 0;
+ for (sym = 0; sym < nsyms; ++sym) {
+ if (value[sym] == NULL)
+ continue;
+ cp = value[sym];
+ ind = findsym(&cp);
+ if (ind == -1 || ind == sym ||
+ *cp != '\0' ||
+ value[ind] == NULL ||
+ value[ind] == value[sym])
+ continue;
+ debugsym("indir...", sym);
+ value[sym] = value[ind];
+ debugsym("...ectsym", sym);
+ changed++;
+ }
+ } while (changed);
+}
+
+/*
+ * Add a symbol to the symbol table, specified with the format sym=val
+ */
+static void
+addsym1(bool ignorethis, bool definethis, char *symval)
+{
+ const char *sym, *val;
+
+ sym = symval;
+ val = skipsym(sym);
+ if (definethis && *val == '=') {
+ symval[val - sym] = '\0';
+ val = val + 1;
+ } else if (*val == '\0') {
+ val = definethis ? "1" : NULL;
+ } else {
+ usage();
+ }
+ addsym2(ignorethis, sym, val);
+}
+
+/*
* Add a symbol to the symbol table.
*/
static void
-addsym(bool ignorethis, bool definethis, char *sym)
+addsym2(bool ignorethis, const char *sym, const char *val)
{
+ const char *cp = sym;
int symind;
- char *val;
- symind = findsym(sym);
+ symind = findsym(&cp);
if (symind < 0) {
if (nsyms >= MAXSYMS)
errx(2, "too many symbols");
symind = nsyms++;
}
- symname[symind] = sym;
ignore[symind] = ignorethis;
- val = sym + (skipsym(sym) - sym);
- if (definethis) {
- if (*val == '=') {
- value[symind] = val+1;
- *val = '\0';
- } else if (*val == '\0')
- value[symind] = "";
- else
- usage();
+ symname[symind] = sym;
+ value[symind] = val;
+ debugsym("addsym", symind);
+}
+
+static void
+debugsym(const char *why, int symind)
+{
+ debug("%s %s%c%s", why, symname[symind],
+ value[symind] ? '=' : ' ',
+ value[symind] ? value[symind] : "undef");
+}
+
+/*
+ * Add symbols to the symbol table from a file containing
+ * #define and #undef preprocessor directives.
+ */
+static void
+defundefile(const char *fn)
+{
+ filename = fn;
+ input = fopen(fn, "rb");
+ if (input == NULL)
+ err(2, "can't open %s", fn);
+ linenum = 0;
+ while (defundef())
+ ;
+ if (ferror(input))
+ err(2, "can't read %s", filename);
+ else
+ fclose(input);
+ if (incomment)
+ error("EOF in comment");
+}
+
+/*
+ * Read and process one #define or #undef directive
+ */
+static bool
+defundef(void)
+{
+ const char *cp, *kw, *sym, *val, *end;
+
+ cp = skiphash();
+ if (cp == NULL)
+ return (false);
+ if (*cp == '\0')
+ goto done;
+ /* strip trailing whitespace, and do a fairly rough check to
+ avoid unsupported multi-line preprocessor directives */
+ end = cp + strlen(cp);
+ while (end > tline && strchr(" \t\n\r", end[-1]) != NULL)
+ --end;
+ if (end > tline && end[-1] == '\\')
+ Eioccc();
+
+ kw = cp;
+ if ((cp = matchsym("define", kw)) != NULL) {
+ sym = getsym(&cp);
+ if (sym == NULL)
+ error("missing macro name in #define");
+ if (*cp == '(') {
+ val = "1";
+ } else {
+ cp = skipcomment(cp);
+ val = (cp < end) ? xstrdup(cp, end) : "";
+ }
+ debug("#define");
+ addsym2(false, sym, val);
+ } else if ((cp = matchsym("undef", kw)) != NULL) {
+ sym = getsym(&cp);
+ if (sym == NULL)
+ error("missing macro name in #undef");
+ cp = skipcomment(cp);
+ debug("#undef");
+ addsym2(false, sym, NULL);
} else {
- if (*val != '\0')
- usage();
- value[symind] = NULL;
+ error("unrecognized preprocessor directive");
}
+ skipline(cp);
+done:
+ debug("parser line %d state %s comment %s line", linenum,
+ comment_name[incomment], linestate_name[linestate]);
+ return (true);
}
/*
- * Compare s with n characters of t.
- * The same as strncmp() except that it checks that s[n] == '\0'.
+ * Concatenate two strings into new memory, checking for failure.
*/
-static int
-strlcmp(const char *s, const char *t, size_t n)
+static char *
+astrcat(const char *s1, const char *s2)
{
- while (n-- && *t != '\0')
- if (*s != *t)
- return ((unsigned char)*s - (unsigned char)*t);
- else
- ++s, ++t;
- return ((unsigned char)*s);
+ char *s;
+ int len;
+ size_t size;
+
+ len = snprintf(NULL, 0, "%s%s", s1, s2);
+ if (len < 0)
+ err(2, "snprintf");
+ size = (size_t)len + 1;
+ s = (char *)malloc(size);
+ if (s == NULL)
+ err(2, "malloc");
+ snprintf(s, size, "%s%s", s1, s2);
+ return (s);
+}
+
+/*
+ * Duplicate a segment of a string, checking for failure.
+ */
+static const char *
+xstrdup(const char *start, const char *end)
+{
+ size_t n;
+ char *s;
+
+ if (end < start) abort(); /* bug */
+ n = (size_t)(end - start) + 1;
+ s = malloc(n);
+ if (s == NULL)
+ err(2, "malloc");
+ snprintf(s, n, "%s", start);
+ return (s);
}
/*
@@ -1001,5 +1573,6 @@ error(const char *msg)
else
warnx("%s: %d: %s (#if line %d depth %d)",
filename, linenum, msg, stifline[depth], depth);
+ closeio();
errx(2, "output may be truncated");
}
diff --git a/extra/scripts/unifdef.h b/extra/scripts/unifdef.h
new file mode 100644
index 000000000..276015c82
--- /dev/null
+++ b/extra/scripts/unifdef.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2012 - 2013 Tony Finch <dot@dotat.at>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/stat.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* Avoid err.h since this are non-standard BSD extensions */
+#define vwarnx(fmt, args) ({ fprintf(stderr, "unifdef: "); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); })
+#define warnx(fmt, args...) fprintf(stderr, "unifdef: " fmt "\n", ## args)
+#define warn(fmt, args...) warnx(fmt ": %s", ## args, strerror(errno))
+#define errx(exit_code, fmt, args...) ({ warnx(fmt, ## args); exit(exit_code); })
+#define err(exit_code, fmt, args...) errx(exit_code, fmt ": %s", ## args, strerror(errno))
+
+/* portability stubs */
+
+#define fbinmode(fp) (fp)
+
+#define replace(old,new) rename(old,new)
+
+static FILE *
+mktempmode(char *tmp, int mode)
+{
+ int fd = mkstemp(tmp);
+ if (fd < 0) return (NULL);
+ fchmod(fd, mode & (S_IRWXU|S_IRWXG|S_IRWXO));
+ return (fdopen(fd, "wb"));
+}
diff --git a/extra/scripts/unifdef.test b/extra/scripts/unifdef.test
new file mode 100644
index 000000000..5ba4e48df
--- /dev/null
+++ b/extra/scripts/unifdef.test
@@ -0,0 +1,67 @@
+Run me through unifdef -UA
+*** Nothing should be visible here:
+#if defined A && defined B
+hello world
+#endif
+#if defined A && B
+hello world
+#endif
+#if defined A && 1
+hello world
+#endif
+#if defined A && (1 > 0)
+hello world
+#endif
+#if defined B && defined A
+hello world
+#endif
+#if B && defined A
+hello world
+#endif
+#if 1 && defined A
+hello world
+#endif
+#if (1 > 0) && defined A
+hello world
+#endif
+#if defined A && (defined FOO || defined BAR)
+hello world
+#endif
+#if (defined FOO || defined BAR) && defined A
+hello world
+#endif
+
+*** Everything should be visible here, but #if/#endif removed:
+#if defined B || !defined A
+hello world 1
+#endif
+#if !defined A || defined B
+hello world 2 (last)
+#endif
+
+*** This should be unchanged (#if/#endif not removed):
+#if defined A || defined B
+I am here 1
+#endif
+#if defined B || defined A
+I am here 2
+#endif
+I am here 3
+#if !defined FOO && !defined BAR \
+ && !defined BAZ
+# error "I am here 4"
+#endif
+I am here 5
+#if (!defined FOO \
+ && (defined BAR || defined BAZ \
+ || defined XYZ))
+I am here 6
+#endif
+I am here 7
+#if !defined FOO \
+ && defined BAR
+I am here 8
+#endif
+I am here 9 (last)
+
+*** End
diff --git a/extra/scripts/version.h b/extra/scripts/version.h
new file mode 100644
index 000000000..5636b1b81
--- /dev/null
+++ b/extra/scripts/version.h
@@ -0,0 +1,2 @@
+"@(#) $Version: unifdef-2.10.4.1542ea4 $\n"
+"@(#) $Date: 2014-01-07 22:32:21 +0000 $\n"