diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 13:16:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 13:16:35 +0000 |
commit | e2bbf175a2184bd76f6c54ccf8456babeb1a46fc (patch) | |
tree | f0b76550d6e6f500ada964a3a4ee933a45e5a6f1 /tools/convert-fixedwidth.sh | |
parent | Initial commit. (diff) | |
download | frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.tar.xz frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.zip |
Adding upstream version 9.1.upstream/9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | tools/convert-fixedwidth.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/convert-fixedwidth.sh b/tools/convert-fixedwidth.sh new file mode 100755 index 0000000..bb6011e --- /dev/null +++ b/tools/convert-fixedwidth.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# This script converts nonstandard fixed-width integer types found in FRR to +# C99 standard types. +USAGE="./$(basename "$0")" +USAGE+=$' <src-path> -- convert nonstandard fixed-width integer types found in FRR to C99 standard types\n' +USAGE+=$'<src-path> - a directory containing C source, or a C source file\n' +if [ $# -eq 0 ]; then + printf "%s" "$USAGE" + exit 1 +fi + +FRRTREE=$1 + +if [[ -d $FRRTREE ]]; then + SOURCES=$(find $FRRTREE -type f -name '*.[ch]') +elif [[ -f $FRRTREE ]]; then + SOURCES="$FRRTREE" + SOURCES+=$'\n' +else + printf "%s" "$USAGE" + exit 1 +fi + +printf "%s" "$SOURCES" | while read line ; do + printf "Processing $line " + sed -i -e 's/u_int\([0-9]\{1,3\}\)_t/uint\1_t/g' $line + printf "." + sed -i -e 's/\([^a-z_]\)u_char\([^a-z_]\|$\)/\1uint8_t\2/g' $line + printf "." + sed -i -e 's/\([^a-z_]\)u_short\([^a-z_]\|$\)/\1unsigned short\2/g' $line + printf "." + sed -i -e 's/\([^a-z_]\)u_int\([^a-z_]\|$\)/\1unsigned int\2/g' $line + printf "." + sed -i -e 's/\([^a-z_]\)u_long\([^a-z_]\|$\)/\1unsigned long\2/g' $line + printf "." + sed -i -e 's/^u_char /uint8_t /g' $line + printf "." + sed -i -e 's/^u_short /unsigned short /g' $line + printf "." + sed -i -e 's/^u_int /unsigned int /g' $line + printf "." + sed -i -e 's/^u_long /unsigned long /g' $line + printf ".\n" +done |