Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 136800 - flag-o-matic.eclass / filter-mfpmath with math error, "${#new_math}-2" must be positive
Summary: flag-o-matic.eclass / filter-mfpmath with math error, "${#new_math}-2" must b...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: SpanKY
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-14 10:05 UTC by Mark Dominik Bürkle
Modified: 2006-07-15 22:49 UTC (History)
0 users

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 Mark Dominik Bürkle 2006-06-14 10:05:54 UTC
(p3 is less important than p2, isn't it?)

Hi,

sorry don't remember the exact error message. And it does not hurt in any way, it's just that it will make users wonder that there is a "math error" in "filter-mfpmath"...

quote:

filter-mfpmath() {
    local orig_mfpmath new_math prune_math

    # save the original -mfpmath flag
    orig_mfpmath="`get-flag -mfpmath`"
    # get the value of the current -mfpmath flag
    new_math=" `get-flag mfpmath | tr , ' '` "
    # figure out which math values are to be removed
    prune_math=""
    for prune_math in "$@" ; do
        new_math="${new_math/ ${prune_math} / }"
    done
    new_math="`echo ${new_math:1:${#new_math}-2} | tr ' ' ,`"

    if [ -z "${new_math}" ] ; then
        # if we're removing all user specified math values are
        # slated for removal, then we just filter the flag
        filter-flags ${orig_mfpmath}
    else
        # if we only want to filter some of the user specified
        # math values, then we replace the current flag
        replace-flags ${orig_mfpmath} -mfpmath=${new_math}
    fi
    return 0
}


Explanation of problem:

If new_math [=" $(get-flag mfpmath | tr , ' ') "] is just composed of flags 
which are to be filtered, e.g.

     new_math=" one_flag "
  or new_math=" sse "

and "$@" contains ( "one_flag" "sse" ), then the resulting new_math 
will be just a single blank, e.g.

  new_math=" "
and will produce a message on stderr, saying sth. like 

    new_math: expression must be positive in filter-mfpmath

Though it won't hurt anywhere at all, it's ugly and might very well confuse
normal users...
 (checked out bugzilla, found some items that did not fit, read through the
postings, and time passed once more...)

Would You mind to check out if sth. like the following might be used in that 
situation:


    array_separated_by() {
        local IFS="$1"
        shift
        echo "$*"
    }

    ...
    done
    new_math="$( array_separated_by "," $new_math )"

or even much more simple

    ...
    done
    new_math="${new_math# }"
    new_math="${new_math% }"
    new_math="${new_math// /,}"

which would be much faster, too, because no fork/exec subshells are used...?


Kind regards,
Dominik
Comment 1 SpanKY gentoo-dev 2006-07-15 22:49:51 UTC
thanks, fixed in cvs