Skip to content
Snippets Groups Projects
Commit fe352d37 authored by Claus-Justus Heine's avatar Claus-Justus Heine
Browse files

Replace "echo -n -e" by printf

parent 847a82cb
Branches
Tags
No related merge requests found
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
DOF_FREE_SIZE=$1 DOF_FREE_SIZE=$1
MAX_STRIDE=$2 MAX_STRIDE=$2
FW=$(( ${DOF_FREE_SIZE} / 4 )) FW=$(( ${DOF_FREE_SIZE} / 4 ))
PRINT="printf"
#echo -n -e
ALLBITS=$(( (1 << ${DOF_FREE_SIZE}) - 1 )) ALLBITS=$(( (1 << ${DOF_FREE_SIZE}) - 1 ))
if test ${ALLBITS} -eq 0; then if test ${ALLBITS} -eq 0; then
...@@ -15,7 +17,7 @@ if test ${MAX_STRIDE} -gt 1; then ...@@ -15,7 +17,7 @@ if test ${MAX_STRIDE} -gt 1; then
#ifndef _ALBERTA_STRIDE_DOF_FREE_BIT_H_ #ifndef _ALBERTA_STRIDE_DOF_FREE_BIT_H_
#define _ALBERTA_STRIDE_DOF_FREE_BIT_H_ #define _ALBERTA_STRIDE_DOF_FREE_BIT_H_
EOF EOF
echo -n -e '\n#define MAX_STRIDE '"${MAX_STRIDE}"'\n\n' ${PRINT} '\n#define MAX_STRIDE '"${MAX_STRIDE}"'\n\n'
cat <<EOF cat <<EOF
const DOF_FREE_UNIT dof_stride_free_bit[MAX_STRIDE][DOF_FREE_SIZE] = { const DOF_FREE_UNIT dof_stride_free_bit[MAX_STRIDE][DOF_FREE_SIZE] = {
EOF EOF
...@@ -39,33 +41,33 @@ while test ${STRIDE} -le ${MAX_STRIDE}; do ...@@ -39,33 +41,33 @@ while test ${STRIDE} -le ${MAX_STRIDE}; do
BIT=0 BIT=0
if test ${MAX_STRIDE} -gt 1; then if test ${MAX_STRIDE} -gt 1; then
echo -n -e ' {\n ' ${PRINT} ' {\n '
else else
echo -n -e ' ' ${PRINT} ' '
fi fi
while test ${BIT} -lt ${DOF_FREE_SIZE}; do while test ${BIT} -lt ${DOF_FREE_SIZE}; do
VALUE=$(( (${MASK} << ${BIT}) & ${ALLBITS} )) VALUE=$(( (${MASK} << ${BIT}) & ${ALLBITS} ))
printf '0x%0'${FW}'x' ${VALUE} ${PRINT} '0x%0'${FW}'x' ${VALUE}
BIT=$(( ${BIT} + 1 )) BIT=$(( ${BIT} + 1 ))
if test ${BIT} -lt $(( ${DOF_FREE_SIZE} + ${MAX_STRIDE} - 1 )); then if test ${BIT} -lt $(( ${DOF_FREE_SIZE} + ${MAX_STRIDE} - 1 )); then
if test $(( ${BIT} % ${WRAP} )) -eq 0; then if test $(( ${BIT} % ${WRAP} )) -eq 0; then
if test ${MAX_STRIDE} -gt 1; then if test ${MAX_STRIDE} -gt 1; then
echo -n -e ',\n ' ${PRINT} ',\n '
else else
echo -n -e ',\n ' ${PRINT} ',\n '
fi fi
else else
echo -n -e ', ' ${PRINT} ', '
fi fi
fi fi
done done
if test ${MAX_STRIDE} -gt 1; then if test ${MAX_STRIDE} -gt 1; then
echo -n -e '\n }' ${PRINT} '\n }'
fi fi
if test ${STRIDE} -lt ${MAX_STRIDE}; then if test ${STRIDE} -lt ${MAX_STRIDE}; then
echo -n -e ',\n' ${PRINT} ',\n'
else else
echo -n -e '\n' ${PRINT} '\n'
fi fi
STRIDE=$(( ${STRIDE} + 1 )) STRIDE=$(( ${STRIDE} + 1 ))
done done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment