File: remove_comma_abs.sh

package info (click to toggle)
libflame 5.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 162,052 kB
  • sloc: ansic: 750,080; fortran: 404,344; makefile: 8,133; sh: 5,458; python: 937; pascal: 144; perl: 66
file content (32 lines) | stat: -rwxr-xr-x 837 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash

main() 
{
    script_name=${0##*/}
    echo " "
    echo " "
    echo " "${script_name}
    echo " "
    echo " Objective:"
    echo "   The script removes comma expressions, which are automatically generated by abs macro."
    echo " "

    files="$(find . -maxdepth 1 -name "*.c")"
    for file in ${files}; do
        echo -ne "   Removing comma expressions from ... ${file}                  "\\r

        tmp_file=$(echo "${file}.back")
        ( mv -f ${file} ${tmp_file} ;
            cat ${tmp_file} \
                | sed  's/\([ a-z0-9_]*\) = \([][ &a-z0-9_/<>.,+*()-]*\), abs([ a-z0-9_]*)/(abs(\2))/g' \
                > ${file} ;
            rm -f ${tmp_file} )
    done

    return 0
}

main "$@"


# | sed  's/\([ a-z0-9_]*\) = \([a-z0-9_]*\)(\([][ &a-z0-9_.+*()-]*\)), \(abs\)([ a-z0-9_]*)/(kdd(\2(\3)))/g'