make/autoconf/basics.m4
changeset 50266 8090a68b6af5
parent 50073 35b22ca681d1
child 50818 e46b9e514479
equal deleted inserted replaced
50265:6cd6af149326 50266:8090a68b6af5
   113   legal_values=`$ECHO $3 | $TR ' ' '\n'`
   113   legal_values=`$ECHO $3 | $TR ' ' '\n'`
   114   if test -z "$legal_values"; then
   114   if test -z "$legal_values"; then
   115     $1="$2"
   115     $1="$2"
   116   else
   116   else
   117     result=`$GREP -Fvx "$legal_values" <<< "$values_to_check" | $GREP -v '^$'`
   117     result=`$GREP -Fvx "$legal_values" <<< "$values_to_check" | $GREP -v '^$'`
       
   118     $1=${result//$'\n'/ }
       
   119   fi
       
   120 ])
       
   121 
       
   122 ###############################################################################
       
   123 # Check if a list of space-separated words contains any word(s) from a list of
       
   124 # space-separated illegal words. Typical use is to see if a user-specified
       
   125 # set of words contains any from a set of illegal words.
       
   126 #
       
   127 # Sets the specified variable to list of matching illegal words, or to
       
   128 # the empty string if no words are matching the illegal set.
       
   129 #
       
   130 # $1: result variable name
       
   131 # $2: list of values to check
       
   132 # $3: list of illegal values
       
   133 AC_DEFUN([BASIC_GET_MATCHING_VALUES],
       
   134 [
       
   135   # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326
       
   136   # Notice that the original variant fails on SLES 10 and 11
       
   137   # Some grep versions (at least bsd) behaves strangely on the base case with
       
   138   # no legal_values, so make it explicit.
       
   139   values_to_check=`$ECHO $2 | $TR ' ' '\n'`
       
   140   illegal_values=`$ECHO $3 | $TR ' ' '\n'`
       
   141   if test -z "$illegal_values"; then
       
   142     $1=""
       
   143   else
       
   144     result=`$GREP -Fx "$illegal_values" <<< "$values_to_check" | $GREP -v '^$'`
   118     $1=${result//$'\n'/ }
   145     $1=${result//$'\n'/ }
   119   fi
   146   fi
   120 ])
   147 ])
   121 
   148 
   122 ###############################################################################
   149 ###############################################################################