Re: [PATCH 1/2] * config.sub: Properly recognise configs with 4 components
Hi John OK, making some progress. Patch 1 is applied. Thanks, Ben signature.asc Description: PGP signature ___ config-patches mailing list config-patches@gnu.org https://lists.gnu.org/mailman/listinfo/config-patches
[PATCH 1/2] * config.sub: Properly recognise configs with 4 components
--- ChangeLog | 27 ++ config.sub | 65 ++ 2 files changed, 67 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index e32c2c5..1931be3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2018-04-24 John Ericson + + * config.sub: Properly recognise configs with 4 components. + + The old logic was a bit hard to follow due to lots of sed and + unintuitive collapsing of cases. The code now works like this + + * 4 components is always parsed as + CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM + + * 2 components is always parsed as + CPU_TYPE-OPERATING_SYSTEM + + * 1 component is always parsed as + CPU_TYPE + + * 3 components is ambiguous and parsed as either + CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM + CPU_TYPE-KERNEL-OPERATING_SYSTEM + + The old code differed semantically in that + + * The 4-case was awkwardly folded into the 3-case disambiguation + + * The "android-linux" ad-hoc fixdup did something different in + the non-3 cases, but isn't intended to apply in those cases. + 2018-05-01 Ben Elliston * config.sub (maybe_os): Reindent this block. diff --git a/config.sub b/config.sub index 703b313..9992b9c 100755 --- a/config.sub +++ b/config.sub @@ -110,33 +110,48 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; -android-linux) - os=-linux-android - basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; -*) - basic_machine=`echo "$1" | sed 's/-[^-]*$//'` - case $1 in - *-*) - os=`echo "$1" | sed 's/.*-/-/'` - ;; - *) +# Physical components of config +IFS="-" read comp1 comp2 comp3 comp4
Re: [PATCH 1/2] * config.sub: Properly recognise configs with 4 components
That's a wonderful idea; thanks! I'll redo. On 05/04/18 00:03, Ben Elliston wrote: Hi John On Tue, May 01, 2018 at 02:53:46PM -0400, John Ericson wrote: +# Physical components of config +comp1=`echo "$1" | sed 's/^\([^-]*\).*$/\1/'` +comp2=`echo "$1" | sed 's/^[^-]*-\([^-]*\).*$/\1/'` +comp3=`echo "$1" | sed 's/^[^-]*-[^-]*-\([^-]*\).*$/\1/'` +comp4=`echo "$1" | sed 's/^[^-]*-[^-]*-[^-]*-\([^-]*\).*$/\1/'` Can you please rework your patch with something like this, and then we can ditch the nasty sed expressions above completely: IFS="-" read comp1 comp2 comp3 comp4 < ___ config-patches mailing list config-patches@gnu.org https://lists.gnu.org/mailman/listinfo/config-patches
Re: [PATCH 1/2] * config.sub: Properly recognise configs with 4 components
Hi John On Tue, May 01, 2018 at 02:53:46PM -0400, John Ericson wrote: > +# Physical components of config > +comp1=`echo "$1" | sed 's/^\([^-]*\).*$/\1/'` > +comp2=`echo "$1" | sed 's/^[^-]*-\([^-]*\).*$/\1/'` > +comp3=`echo "$1" | sed 's/^[^-]*-[^-]*-\([^-]*\).*$/\1/'` > +comp4=`echo "$1" | sed 's/^[^-]*-[^-]*-[^-]*-\([^-]*\).*$/\1/'` Can you please rework your patch with something like this, and then we can ditch the nasty sed expressions above completely: IFS="-" read comp1 comp2 comp3 comp4 < signature.asc Description: PGP signature ___ config-patches mailing list config-patches@gnu.org https://lists.gnu.org/mailman/listinfo/config-patches
[PATCH 1/2] * config.sub: Properly recognise configs with 4 components
--- ChangeLog | 27 + config.sub | 66 ++ 2 files changed, 68 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index e32c2c5..1931be3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2018-04-24 John Ericson + + * config.sub: Properly recognise configs with 4 components. + + The old logic was a bit hard to follow due to lots of sed and + unintuitive collapsing of cases. The code now works like this + + * 4 components is always parsed as + CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM + + * 2 components is always parsed as + CPU_TYPE-OPERATING_SYSTEM + + * 1 component is always parsed as + CPU_TYPE + + * 3 components is ambiguous and parsed as either + CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM + CPU_TYPE-KERNEL-OPERATING_SYSTEM + + The old code differed semantically in that + + * The 4-case was awkwardly folded into the 3-case disambiguation + + * The "android-linux" ad-hoc fixdup did something different in + the non-3 cases, but isn't intended to apply in those cases. + 2018-05-01 Ben Elliston * config.sub (maybe_os): Reindent this block. diff --git a/config.sub b/config.sub index 703b313..7a05648 100755 --- a/config.sub +++ b/config.sub @@ -110,33 +110,49 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; -android-linux) - os=-linux-android - basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; -*) - basic_machine=`echo "$1" | sed 's/-[^-]*$//'` - case $1 in - *-*) - os=`echo "$1" | sed 's/.*-/-/'` - ;; - *) +# Physical components of config +comp1=`echo "$1" | sed 's/^\([^-]*\).*$/\1/'` +comp2=`echo "$1" | sed 's/^[^-]*-\([^-]*\).*$/\1/'` +comp3=`echo "$1" | sed 's/^[^-]*-[^-]*-\([^-]*\).*$/\1/'` +comp4=`echo "$1" | sed 's/^[^-]*-[^-]*-[^-]*-\([^-]*\).*$/\1/'` + +# Separate into logical components for further validation +case $1 in + *-*-*-*) + basic_machine=$comp1-$comp2 + os=-$comp3-$comp4 + ;; + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$comp2-$comp3 + case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \ + | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$comp1 + os=-$maybe_os + ;; + android-linux) + basic_machine=$comp1-unknown + os=-linux-android + ;; + *) + basic_machine=$comp1-$comp2 + os=-$comp3 + ;; + esac + ;; + *-*) + basic_machine=$comp1 + os=-$comp2 + ;; + *) + basic_machine=$1 os= ;; - esac - ;; esac ### Let's recognize common machines as not being operating systems so -- 2.16.3 ___ config-patches mailing list config-patches@gnu.org https://lists.gnu.org/mailman/listinfo/config-patches