Modified the "makedbh" script to avoid intermixing "printf" and

"echo", because there is at least one OS variant out there where
the two buffer independently and cause the output to have lines
out of order.  The script had previously used "printf" because
"echo -n" is not POSIX-compliant and so not necessarily universally
compatible.  The script was changed to use "printf" throughout.
This commit is contained in:
Tim Edwards 2018-12-07 10:10:22 -05:00
parent ba9dfb7765
commit 4da51bc42a
1 changed files with 64 additions and 64 deletions

View File

@ -47,143 +47,143 @@ while (${maskwords} >= 0)
@ maskwords-- @ maskwords--
end end
# Definitions # NOTE: echo -n is not POSIX, not portable to newer Bourne-shells, so use printf
set ECHO_N = printf # NOTE: Some OSes are known to buffer printf and echo independently, so do not
# echo -n is not POSIX, not portable to newer Bourne-shells # intermix "echo" and "printf" or output may have lines out of order.
echo "#define TTMaskZero(m) ( \" >> $2 printf "#define TTMaskZero(m) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " (m)->tt_words[$i] = 0" >> $2 printf " (m)->tt_words[$i] = 0" >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
echo "" >> $2 printf "\n" >> $2
else else
echo ", \" >> $2 printf ", \\\n" >> $2
endif endif
end end
echo "#define TTMaskIsZero(m) ( \" >> $2 printf "#define TTMaskIsZero(m) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " (m)->tt_words[$i] == 0" >> $2 printf " (m)->tt_words[$i] == 0" >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
echo "" >> $2 printf "\n" >> $2
else else
echo " && \" >> $2 printf " && \\\n" >> $2
endif endif
end end
echo "#define TTMaskEqual(m, n) ( \" >> $2 printf "#define TTMaskEqual(m, n) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " (m)->tt_words[$i] == (n)->tt_words[$i]" >> $2 printf " (m)->tt_words[$i] == (n)->tt_words[$i]" >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
echo "" >> $2 printf "\n" >> $2
else else
echo " && \" >> $2 printf " && \\\n" >> $2
endif endif
end end
echo "#define TTMaskIntersect(m, n) ( \" >> $2 printf "#define TTMaskIntersect(m, n) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " ((m)->tt_words[$i] & (n)->tt_words[$i])" >> $2 printf " ((m)->tt_words[$i] & (n)->tt_words[$i])" >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
echo "" >> $2 printf "\n" >> $2
else else
echo " || \" >> $2 printf " || \\\n" >> $2
endif endif
end end
echo "#define TTMaskCom(m) ( \" >> $2 printf "#define TTMaskCom(m) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " ((m)->tt_words[$i] = ~(m)->tt_words[$i])" >> $2 printf " ((m)->tt_words[$i] = ~(m)->tt_words[$i])" >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
echo "" >> $2 printf "\n" >> $2
else else
echo ", \" >> $2 printf ", \\\n" >> $2
endif endif
end end
echo "#define TTMaskCom2(m, n) ( \" >> $2 printf "#define TTMaskCom2(m, n) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " ((m)->tt_words[$i] = ~(n)->tt_words[$i])" >> $2 printf " ((m)->tt_words[$i] = ~(n)->tt_words[$i])" >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
echo "" >> $2 printf "\n" >> $2
else else
echo ", \" >> $2 printf ", \\\n" >> $2
endif endif
end end
echo "#define TTMaskSetMask(m, n) ( \" >> $2 printf "#define TTMaskSetMask(m, n) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " ((m)->tt_words[$i] |= (n)->tt_words[$i])" >> $2 printf " ((m)->tt_words[$i] |= (n)->tt_words[$i])" >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
echo "" >> $2 printf "\n" >> $2
else else
echo ", \" >> $2 printf ", \\\n" >> $2
endif endif
end end
echo "#define TTMaskSetMask3(m, n, o) ( \" >> $2 printf "#define TTMaskSetMask3(m, n, o) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " ((m)->tt_words[$i] |= (n)->tt_words[$i] | (o)->tt_words[$i])" \ printf " ((m)->tt_words[$i] |= (n)->tt_words[$i] | (o)->tt_words[$i])" \
>> $2 >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
echo "" >> $2 printf "\n" >> $2
else else
echo ", \" >> $2 printf ", \\\n" >> $2
endif endif
end end
echo "#define TTMaskAndMask(m, n) ( \" >> $2 printf "#define TTMaskAndMask(m, n) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " ((m)->tt_words[$i] &= (n)->tt_words[$i])" >> $2 printf " ((m)->tt_words[$i] &= (n)->tt_words[$i])" >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
echo "" >> $2 printf "\n" >> $2
else else
echo ", \" >> $2 printf ", \\\n" >> $2
endif endif
end end
echo "#define TTMaskAndMask3(m, n, o) ( \" >> $2 printf "#define TTMaskAndMask3(m, n, o) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " ((m)->tt_words[$i] = (n)->tt_words[$i] & (o)->tt_words[$i])" \ printf " ((m)->tt_words[$i] = (n)->tt_words[$i] & (o)->tt_words[$i])" \
>> $2 >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
echo "" >> $2 printf "\n" >> $2
else else
echo ", \" >> $2 printf ", \\\n" >> $2
endif endif
end end
echo "#define TTMaskClearMask(m, n) ( \" >> $2 printf "#define TTMaskClearMask(m, n) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " ((m)->tt_words[$i] &= ~(n)->tt_words[$i])" >> $2 printf " ((m)->tt_words[$i] &= ~(n)->tt_words[$i])" >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
echo "" >> $2 printf "\n" >> $2
else else
echo ", \" >> $2 printf ", \\\n" >> $2
endif endif
end end
echo "#define TTMaskClearMask3(m, n, o) ( \" >> $2 printf "#define TTMaskClearMask3(m, n, o) ( \\\n" >> $2
foreach i (${count}) foreach i (${count})
${ECHO_N} " ((m)->tt_words[$i] = (n)->tt_words[$i] & ~(o)->tt_words[$i])" \ printf " ((m)->tt_words[$i] = (n)->tt_words[$i] & ~(o)->tt_words[$i])" \
>> $2 >> $2
if ($i == 0) then if ($i == 0) then
echo ")" >> $2 printf ")\n" >> $2
else else
echo ", \" >> $2 printf ", \\\n" >> $2
endif endif
end end
echo "" >> $2 printf "\n" >> $2
echo "#endif /* _DATABASE_H */" >> $2 printf "#endif /* _DATABASE_H */\n" >> $2