COIN-OR::LEMON - Graph Library

Ticket #165: f8832dc16d45.patch

File f8832dc16d45.patch, 2.1 KB (added by Peter Kovacs, 12 years ago)
  • scripts/unify-sources.sh

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1225204666 -3600
    # Node ID f8832dc16d459684b1740edb6b2b1840edaf4a7a
    # Parent  2593e163e407403990ba8f4323f684190a625a62
    Use standard error/warning message format in the unifier script
    
    diff --git a/scripts/unify-sources.sh b/scripts/unify-sources.sh
    a b  
    8686}
    8787
    8888function check_action() {
     89    if [ "$3" == 'tabs' ]
     90    then
     91        PATTERN=$(echo -e '\t')
     92    elif [ "$3" == 'trailing spaces' ]
     93    then
     94        PATTERN='\ +$'
     95    else
     96        PATTERN='*'
     97    fi
     98
    8999    if ! diff -q $1 $2 >/dev/null
    90100    then
    91         echo
    92         echo -n "      $3 failed at line(s): "
    93         echo -n $(diff $1 $2 | grep '^[0-9]' | sed "s/^\(.*\)c.*$/ \1/g" |
    94                   sed "s/,/-/g" | paste -s -d',')
    95         FAILED=YES
     101        if [ "$PATTERN" == '*' ]
     102        then
     103            diff $1 $2 | grep '^[0-9]' | sed "s|^\(.*\)c.*$|$2:\1: check failed: $3|g" |
     104              sed "s/:\([0-9]*\),\([0-9]*\):\(.*\)$/:\1:\3 (until line \2)/g"
     105        else
     106            grep -n -E "$PATTERN" $2 | sed "s|^\([0-9]*\):.*$|$2:\1: check failed: $3|g"
     107        fi
     108        FAILED=YES
    96109    fi
    97110}
    98111
    99112function check_warning() {
    100     echo
    101113    if [ "$2" == 'long lines' ]
    102114    then
    103         echo -n "      $2 warning at line(s): "
    104         echo -n $(grep -n -E '.{81,}' $1 | sed "s/^\([0-9]*\)/ \1\t/g" |
    105                   cut -f 1 | paste -s -d',')
     115        grep -n -E '.{81,}' $1 | sed "s|^\([0-9]*\):.*$|$1:\1: warning: $2|g"
    106116    else
    107         echo -n "      $2 warning"
     117        echo "$1: warning: $2"
    108118    fi
    109119    WARNED=YES
    110120}
     
    236246# process the file
    237247
    238248function process_file() {
    239     echo -n "    $ACTION $1..."
     249    if [ "$ACTION" == 'update' ]
     250    then
     251        echo -n "    $ACTION $1..."
     252    else
     253        echo "    $ACTION $1..."
     254    fi
    240255
    241256    CHECKING="header tabs spaces long_lines"
    242257
     
    246261        "$check"_check $1
    247262    done
    248263    "$ACTION"_end $1
    249     echo
     264    if [ "$ACTION" == 'update' ]
     265    then
     266        echo
     267    fi
    250268}
    251269
    252270function process_all {