Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / bin / ACE-casts-convert
blob1c8527cfaf598c54d54e812c3c5f6c47c899fd79
1 #! /bin/sh
3 # =============================================================================
5 # @file ACE-casts-convert
7 # Script to convert all ACE cast macro calls (e.g.
8 # ACE_static_cast (foo, bar)) to their standard C++ counterparts (e.g.
9 # static_cast<foo> (bar)).
11 # Use this script at your own risk. It appears to work correctly for
12 # most cases, but verify the results "just in case".
14 # @note Wildcards may be supplied as the "FILE" arguments to this
15 # script since the shell should expand the wildcards before
16 # executing the script.
18 # @bug The sed program used in this script may loop indefinitely on
19 # ACE casts with arguments split across multiple lines
20 # containing patterns it doesn't recognize.
22 # @author Ossama Othman
24 # =============================================================================
27 if test "$#" -eq 0; then
28 echo "Usage: $0 FILE [FILE2] ..."
29 echo ""
30 exit 1
33 echo ""
34 echo "Converting ACE cast macro calls to standard C++ syntax in:"
36 while test "$#" -gt 0
38 arg="$1"
39 shift
41 if grep "ACE_\(static\|dynamic\|const\|reinterpret\)_cast" $arg > /dev/null 2>&1; then
42 echo " $arg"
43 sed -e :a -e 's/ACE_\(const\|static\|reinterpret\|dynamic\)_cast[ \t]*([ \t]*\([^,]*\)[ \t]*,[ \t]*\([^ \t].*\)/\1_cast<\2> (\3/g; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast[ \t]*([ \t]*\([^,]*\)[ \t]*,[ \t]*$/{N;s/\n//;ba;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast[ \t]*([ \t]*$/{N;s/\n//;ba;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast[ \t]*$/{N;s/\n//;ba;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast[ \t]*(/ba' \
44 -e :aa -e 's/ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ref[ \t]*([ \t]*\([^,]*\)[ \t]*,\(.*\),[ \t]*\([^,]*\)/\1_cast<\2<\3> \&> (\4/g; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ref[ \t]*([ \t]*\([^,]*\)[ \t]*,[ \t]*$/{N;s/\n//;baa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ref[ \t]*([ \t]*$/{N;s/\n//;baa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ref[ \t]*$/{N;s/\n//;baa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ref[ \t]*(/baa' \
45 -e :aaa -e 's/ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ptr[ \t]*([ \t]*\([^,]*\)[ \t]*,\(.*\),[ \t]*\([^,]*\)/\1_cast<\2<\3> \*> (\4/g; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ptr[ \t]*([ \t]*\([^,]*\)[ \t]*,[ \t]*$/{N;s/\n//;baaa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ptr[ \t]*([ \t]*$/{N;s/\n//;baaa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ptr[ \t]*$/{N;s/\n//;baaa;}; /ACE_\(const\|static\|reinterpret\|dynamic\)_cast_[1-5]_ptr[ \t]*(/baaa' $arg > ${arg}.new
46 mv ${arg}.new $arg
48 done