1*1f5207b7SJohn Levon#!/bin/bash
2*1f5207b7SJohn Levon
3*1f5207b7SJohn Levonnew=$1
4*1f5207b7SJohn Levonold=$2
5*1f5207b7SJohn Levon
6*1f5207b7SJohn Levonif [ "$old" = "" ] ; then
7*1f5207b7SJohn Levon    echo "usage:  $0 <new file> <old file>"
8*1f5207b7SJohn Levon    exit 1
9*1f5207b7SJohn Levonfi
10*1f5207b7SJohn Levon
11*1f5207b7SJohn Levon#
12*1f5207b7SJohn Levon# If the $old and $new are very similar then we can
13*1f5207b7SJohn Levon# filter out a lot of bug just by doing a diff.
14*1f5207b7SJohn Levon#
15*1f5207b7SJohn Levon# But the line numbers change quite frequently so
16*1f5207b7SJohn Levon# really we only want to see if the line numbers
17*1f5207b7SJohn Levon# have changed inside the function.
18*1f5207b7SJohn Levon# The 42 in this message:
19*1f5207b7SJohn Levon# file.c +123 some_func(42) warn: blah blah blah
20*1f5207b7SJohn Levon#
21*1f5207b7SJohn Levon
22*1f5207b7SJohn LevonIFS="
23*1f5207b7SJohn Levon"
24*1f5207b7SJohn Levonfor err in $(diff -u $old $new | cut -b 2- | egrep '(warn|error|warning):') ; do
25*1f5207b7SJohn Levon
26*1f5207b7SJohn Levon    # we are only interested in the last chunk.
27*1f5207b7SJohn Levon    # "some_func(42) warn: blah blah blah"
28*1f5207b7SJohn Levon    last=$(echo $err | cut -d ' ' -f 2-)
29*1f5207b7SJohn Levon
30*1f5207b7SJohn Levon    # There are some error message which include a second
31*1f5207b7SJohn Levon    # line number so we crudely chop that off.
32*1f5207b7SJohn Levon    last=$(echo $last | sed -e 's/line .*//')
33*1f5207b7SJohn Levon
34*1f5207b7SJohn Levon    if ! grep -Fq "$last" $old ; then
35*1f5207b7SJohn Levon	echo $err
36*1f5207b7SJohn Levon    fi
37*1f5207b7SJohn Levondone
38