Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 641c368

Browse files
committed
Change configure.in to note that since we are using expr(1)'s regex match
command, the entries in template/.similar can really be regular expressions. This isn't a new feature, just an observation of what the code already did.
1 parent b178865 commit 641c368

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

src/configure.in

+20-22
Original file line numberDiff line numberDiff line change
@@ -96,30 +96,28 @@ host="`echo $host | tr '[[A-Z]]' '[[a-z]]'`"
9696
if test -f "template/$host"
9797
then TEMPLATE="$host"
9898
else
99-
# Next try for an exact match to a .similar entry.
100-
# There shouldn't be multiple matches, but take the last if there are.
101-
GUESS=`grep "^$host=" template/.similar | sed 's/^.*=//' | tail -1`
99+
# Scan template/.similar for a rule that tells us which template to use.
100+
# The format of each line of the file is
101+
# hostnamepattern=templatefilename
102+
# where the hostnamepattern is evaluated per the rules of expr(1) ---
103+
# namely, it is a standard regular expression with an implicit ^ at the
104+
# start. If multiple lines match, we will end up using the last match.
105+
GUESS=""
106+
exec 4<template/.similar
107+
while read LINE <&4
108+
do
109+
SIMHOST=`expr "$LINE" : '\(.*\)='`
110+
MATCH=`expr "$host" : "$SIMHOST"`
111+
if test "$MATCH" != 0
112+
then GUESS=`echo "$LINE" | sed 's/^.*=//'`
113+
fi
114+
done
115+
exec 4<&-
102116
if test "$GUESS"
103117
then TEMPLATE="$GUESS"
104118
else
105-
# Next look for a .similar entry that is a prefix of $host.
106-
# If there are multiple matches, take the last one.
107-
exec 4<template/.similar
108-
while read LINE <&4
109-
do
110-
SIMHOST=`expr "$LINE" : '\(.*\)='`
111-
MATCH=`expr "$host" : "$SIMHOST"`
112-
if test "$MATCH" != 0
113-
then GUESS=`echo "$LINE" | sed 's/^.*=//'`
114-
fi
115-
done
116-
exec 4<&-
117-
if test "$GUESS"
118-
then TEMPLATE="$GUESS"
119-
else
120-
# Last chance ... maybe uname -s will match an entry.
121-
TEMPLATE=`uname -s | tr '[[A-Z]]' '[[a-z]]'`
122-
fi
119+
# Last chance ... maybe uname -s will match an entry.
120+
TEMPLATE=`uname -s | tr '[[A-Z]]' '[[a-z]]'`
123121
fi
124122
fi
125123
])
@@ -130,7 +128,7 @@ if test ! -f "template/$TEMPLATE"; then
130128
echo ""
131129
echo "$TEMPLATE does not exist"
132130
echo ""
133-
echo "Available Templates (set using --with-template):"
131+
echo "Available Templates (select one using --with-template):"
134132
echo ""
135133
ls template
136134
echo ""

0 commit comments

Comments
 (0)