Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 54815 - flag-o-matic filter-flags and replace-flags take away one character when argument not found
Summary: flag-o-matic filter-flags and replace-flags take away one character when argu...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: SpanKY
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-22 14:29 UTC by Hans de Graaff
Modified: 2004-06-23 19:55 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans de Graaff gentoo-dev Security 2004-06-22 14:29:11 UTC
Both filter-flags and replace-flags in flag-o-matic.eclass seem to remove one character from the end of the FLAGS variables if the flag they are supposed to remove or replace is not present in the FLAGS variable. Mostly this causes annoyance (e.g. option -pip not valid) but it did stop me from compiling openoffice alltogether because the flags were broken.

I have changed the lines reading CFLAGS="${CFLAGS:1:${#CFLAGS}-2}" to be CFLAGS="${CFLAGS:1:${#CFLAGS}-1}" instead, but I'm not sure if that is the proper fix for this situation.


Reproducible: Always
Steps to Reproduce:
1. run test script included in additional information field
2. observe breakage
3. emerge openoffice to see breakage in real-life action

Actual Results:  
-O -pipe
test.sh: line 109: ${#CXXFLAGS}-2: substring expression < 0
-O -pip -fno-strict-aliasing
-O -pip -fno-strict-aliasin
-O2 -pip -fno-strict-aliasi
-O2 -pip -fno-strict-aliasi


Expected Results:  
-O -pipe
test.sh: line 109: ${#CXXFLAGS}-1: substring expression < 0
-O -pipe -fno-strict-aliasing
-O -pipe -fno-strict-aliasing
-O2 -pipe -fno-strict-aliasing


I have used the following test script:

#!/bin/sh
source /usr/portage/eclass/flag-o-matic.eclass
export CFLAGS="-O -pipe"
echo $CFLAGS
filter-flags "-bozo"
append-flags "-fno-strict-aliasing"
echo $CFLAGS
replace-flags "-O3" "-O2"
echo $CFLAGS
replace-flags "-O" "-O2"
echo $CFLAGS
Comment 1 Chris White (RETIRED) gentoo-dev 2004-06-22 15:20:49 UTC
Re-assigned to dev-portage team.
Comment 2 SpanKY gentoo-dev 2004-06-22 15:42:26 UTC
the -2 is correct because if you look in the functions, the very first thing they do is stick a space onto the beginning and onto the end:
CFLAGS=" ${CFLAGS} "
so the final CFLAG will have a space at the beginning and end and thus will need to have 2 bytes chopped off

i dont know what's wrong on your box but it works fine here:

root@vapier 0 root # cat test.sh 
#!/bin/bash

source /usr/portage/eclass/flag-o-matic.eclass

export CFLAGS="-O -pipe"
echo $CFLAGS
filter-flags "-bozo"
append-flags "-fno-strict-aliasing"
echo $CFLAGS
replace-flags "-O3" "-O2"
echo $CFLAGS
replace-flags "-O" "-O2"
echo $CFLAGS

root@vapier 0 root # ./test.sh 
-O -pipe
-O -pipe -fno-strict-aliasing
-O -pipe -fno-strict-aliasing
-O2 -pipe -fno-strict-aliasing
Comment 3 Hans de Graaff gentoo-dev Security 2004-06-23 00:02:48 UTC
I have now found that the problem is due to not having a full Gentoo system. I've upgraded an existing system to Gentoo, and bash was one of the applications I had not yet updated using Gentoo. Patch-ID bash205b-004 explains the problem as it deals with calculating the length of a string in bash with leading spaces. This was exactly the problem I was having. emerging bash from Gentoo has solved the problem.
Comment 4 SpanKY gentoo-dev 2004-06-23 19:54:50 UTC
ah, that'll do it :)
Comment 5 SpanKY gentoo-dev 2004-06-23 19:55:08 UTC
user's bash was old (not from Gentoo)