Skip to content

Commit bef99c6

Browse files
tedjpoolejwendell
authored andcommitted
Removed bssl-compat dependency on cmake && gawk
Signed-off-by: Ted Poole <tpoole@redhat.com>
1 parent e1a0906 commit bef99c6

File tree

4 files changed

+37
-25
lines changed

4 files changed

+37
-25
lines changed

bssl-compat/patch/crypto/test/file_util.cc.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ set -euo pipefail
55
uncomment.sh "$1" --comment -h \
66
--uncomment-func-impl SkipTempFileTests \
77
--uncomment-func-impl GetTempDir \
8-
--uncomment-regex-range 'TemporaryFile::~TemporaryFile.*' '#endif\n}'
8+
--uncomment-func-impl TemporaryFile::Init \
9+
--uncomment-func-impl TemporaryFile::Open \
10+
--uncomment-func-impl TemporaryFile::OpenFD \
11+
--uncomment-regex-range 'TemporaryFile::~TemporaryFile.*' '}'

bssl-compat/patch/include/openssl/base.h.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ uncomment.sh "$1" --comment -h \
9999
--uncomment-macro OPENSSL_PRINTF_FORMAT_FUNC \
100100
--uncomment-macro BSSL_NAMESPACE_BEGIN \
101101
--uncomment-macro BSSL_NAMESPACE_END \
102-
--uncomment-regex-range 'template\s*<typename\s*T,\s*typename\s*Enable\s*=\s*void>' 'struct\s*DeleterImpl\s*\{\};' \
102+
--uncomment-regex-range 'template\s*<typename\s*T,\s*typename\s*Enable\s*=\s*void>' 'struct\s*DeleterImpl\s*{};' \
103103
--uncomment-struct Deleter \
104104
--uncomment-regex-range 'template\s*<typename\s*T,\s*typename\s*CleanupRet,\s*void\s*(\*init)(T\s*\*),' '};$' \
105105
--uncomment-regex 'template\s*<typename' 'using\s*UniquePtr' \

bssl-compat/patch/include/openssl/stack.h.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ uncomment.sh "$1" --comment -h \
1717
--uncomment-struct DeleterImpl \
1818
--uncomment-class StackIteratorImpl \
1919
--uncomment-using StackIterator \
20-
--uncomment-regex-range 'inline.*' '^}$' \
20+
--uncomment-regex-range 'inline std::enable_if_t.*' '}' \
21+
--uncomment-regex-range 'inline .*StackIterator.*begin' '}' \
22+
--uncomment-regex-range 'inline .*StackIterator.*end' '}' \
2123
--uncomment-regex '}$' \
2224
--uncomment-regex 'namespace internal {' \
2325
--uncomment-regex '} // namespace internal' \

bssl-compat/tools/uncomment.sh

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ HDR_FILE="${1?"HDR_FILE not specified"}"
77
shift
88

99
function info {
10-
true || cmake -E cmake_echo_color --cyan "$1"
10+
true || echo "INFO[$HDR_FILE]: $1"
1111
}
1212

1313
function warn {
14-
false || cmake -E cmake_echo_color --yellow "$1"
14+
echo "WARN[$HDR_FILE]: $1"
1515
}
1616

1717
function error {
18-
cmake -E cmake_echo_color --red "ERROR: $1"
18+
echo "ERROR[$HDR_FILE]: $1"
1919
exit 1
2020
}
2121

2222
cleanup() {
2323
if [[ $? != 0 ]]; then
24-
error "While processing option \"$OPTION\""
24+
echo "ERROR[$HDR_FILE]: Error while processing option \"$OPTION\""
2525
fi
2626
}
2727
trap cleanup EXIT
@@ -67,16 +67,16 @@ uncomment_line_range() {
6767
uncomment_regex_range() {
6868
[[ $# == 2 ]] || error "uncomment_regex_range(): Two regexes required"
6969
L1=$(grep -n "^// $1" "$HDR_FILE" | sed -n 1p | cut -d: -f1)
70-
L2=$(gawk '(NR == '$L1'),/^\/\/ '$2'/{print NR}' "$HDR_FILE" | tail -1)
71-
[ -z "$L1" ] && error "Failed to locate first pattern in -R $1 $2"
72-
[ -z "$L2" ] && error "Failed to locate second pattern in -R $1 $2"
70+
L2=$(grep -n "^// $2" "$HDR_FILE" | awk -F: '$1 > '$L1' {print $1; exit}')
71+
[ -z "$L1" ] && error "Failed to locate first pattern '$1'"
72+
[ -z "$L2" ] && error "Failed to locate second pattern '$2'"
7373
uncomment_line_range $L1 $L2
7474
}
7575

7676
uncomment_preproc_directive() {
7777
[[ $# == 1 ]] || error "uncomment_preproc_directive(): One regex required"
7878
for L1 in $(grep -n "^// #\s*$1" "$HDR_FILE" | cut -d: -f1); do
79-
L2=$(gawk '(NR == '$L1'),/[^\\]$/{print NR}' "$HDR_FILE" | tail -1)
79+
L2=$(awk '(NR == '$L1'),/[^\\]$/{print NR}' "$HDR_FILE" | tail -1)
8080
uncomment_line_range $L1 $L2
8181
done
8282
}
@@ -89,7 +89,7 @@ comment_line_range() {
8989
comment_regex_range() {
9090
[[ $# == 2 ]] || error "comment_regex_range(): Two regexes required"
9191
L1=$(grep -n "$1" "$HDR_FILE" | sed -n 1p | cut -d: -f1)
92-
L2=$(gawk '(NR == '$L1'),/'$2'/{print NR}' "$HDR_FILE" | tail -1)
92+
L2=$(awk '(NR == '$L1'),/'$2'/{print NR}' "$HDR_FILE" | tail -1)
9393
[ -z "$L1" ] && error "comment_regex_range(): Failed to locate first pattern"
9494
[ -z "$L2" ] && error "comment_regex_range(): Failed to locate second pattern"
9595
comment_line_range $L1 $L2
@@ -141,15 +141,17 @@ while [ $# -ne 0 ]; do
141141
if [[ ${#PATTERNS[@]} == 1 ]]; then
142142
run_sed_expression "s%^// \(${PATTERNS[0]}\)%\1%"
143143
else
144-
AWK=
145-
for ((i=0; i < ${#PATTERNS[@]} ; i++)); do
146-
AWK="$AWK /^\/\/ ${PATTERNS[i]}/"
147-
[[ $i == 0 ]] && AWK="$AWK {l1=NR}" || AWK="$AWK && NR==(l1+$i) {}"
144+
for L1 in $(grep -n "^// ${PATTERNS[0]}" "$HDR_FILE" | cut -d: -f1); do
145+
for ((i=1; i < ${#PATTERNS[@]} ; i++)); do
146+
L2=$((L1 + i))
147+
if grep -n "^// ${PATTERNS[i]}" "$HDR_FILE" | cut -d: -f1 | grep -q "^$L2$"; then
148+
if (( i == ${#PATTERNS[@]} - 1 )); then
149+
uncomment_line_range $L1 $L2
150+
break 2 # exit both loops
151+
fi
152+
fi
153+
done
148154
done
149-
AWK="${AWK::-2} {printf \"%d %d\n\", l1, NR; exit 0}"
150-
RANGE=$(gawk "$AWK" "$HDR_FILE")
151-
[ -z "$RANGE" ] && error "Failed to locate --uncomment-regex ${PATTERNS[@]}"
152-
uncomment_line_range $RANGE
153155
fi
154156
;;
155157
--uncomment-macro-redef) # -d Redefine macro <X> to be ossl_<x>
@@ -168,7 +170,7 @@ while [ $# -ne 0 ]; do
168170
[[ $2 ]] && [[ $2 != -* ]] || error "Insufficient arguments for $1"
169171
option_end "$2"
170172
for L1 in $(grep -n "^// #\s*define\s*$2\>" "$HDR_FILE" | cut -d: -f1); do
171-
L2=$(gawk '(NR == '$L1'),/[^\\]$/{print NR}' "$HDR_FILE" | tail -1)
173+
L2=$(awk '(NR == '$L1'),/[^\\]$/{print NR}' "$HDR_FILE" | tail -1)
172174
uncomment_line_range $L1 $L2
173175
done
174176
shift
@@ -222,7 +224,7 @@ while [ $# -ne 0 ]; do
222224
LINE=$(grep -n "^// \s*\<typedef\>.*\<$2\>.*" "$HDR_FILE" | sed -n 1p)
223225
L1=$(echo "$LINE" | cut -d: -f1) && L2=$L1
224226
if [[ ! "$LINE" =~ \;$ ]]; then # multi-line
225-
L2=$(gawk '(NR == '$L1'),/^\/\/ .*;$/{print NR}' "$HDR_FILE" | tail -1)
227+
L2=$(awk '(NR == '$L1'),/^\/\/ .*;$/{print NR}' "$HDR_FILE" | tail -1)
226228
fi
227229
uncomment_line_range $L1 $L2
228230
shift
@@ -233,7 +235,7 @@ while [ $# -ne 0 ]; do
233235
LINE=$(grep -n "^// [^ !].*\b$2\s*(.*[^;]$" "$HDR_FILE" | sed -n 1p)
234236
L1=$(echo "$LINE" | cut -d: -f1) && L2=$L1
235237
if [[ ! "$LINE" =~ }$ ]]; then # multi-line
236-
L2=$(gawk '(NR == '$L1'),/^\/\/ }$/{print NR}' "$HDR_FILE" | tail -1)
238+
L2=$(awk '(NR == '$L1'),/^\/\/ }$/{print NR}' "$HDR_FILE" | tail -1)
237239
fi
238240
uncomment_line_range $L1 $L2
239241
shift
@@ -244,15 +246,20 @@ while [ $# -ne 0 ]; do
244246
LINE=$(grep -n "^// static\s*.*\b$2\b\s*(" "$HDR_FILE" | sed -n 1p)
245247
L1=$(echo "$LINE" | cut -d: -f1) && L2=$L1
246248
if [[ ! "$LINE" =~ }$ ]]; then # multi-line
247-
L2=$(gawk '(NR == '$L1'),/^\/\/ }$/{print NR}' "$HDR_FILE" | tail -1)
249+
L2=$(awk '(NR == '$L1'),/^\/\/ }$/{print NR}' "$HDR_FILE" | tail -1)
248250
fi
249251
uncomment_line_range $L1 $L2
250252
shift
251253
;;
252254
--uncomment-using)
253255
[[ $2 ]] && [[ $2 != -* ]] || error "Insufficient arguments for $1"
254256
option_end "$2"
255-
uncomment_regex_range "using\s*$2\>" ".*;$"
257+
LINE=$(grep -n "^// \s*\<using\>.*\<$2\>.*" "$HDR_FILE" | sed -n 1p)
258+
L1=$(echo "$LINE" | cut -d: -f1) && L2=$L1
259+
if [[ ! "$LINE" =~ \;$ ]]; then # multi-line
260+
L2=$(awk '(NR == '$L1'),/^\/\/ .*;$/{print NR}' "$HDR_FILE" | tail -1)
261+
fi
262+
uncomment_line_range $L1 $L2
256263
shift
257264
;;
258265
--comment-regex-range) # comment multi-line matching regex

0 commit comments

Comments
 (0)