1*1f5207b7SJohn Levon#!/bin/bash
2*1f5207b7SJohn Levon
3*1f5207b7SJohn Levoncontext=6
4*1f5207b7SJohn Levonwhile true ; do
5*1f5207b7SJohn Levon    if [ "$1" = "-C" ] ; then
6*1f5207b7SJohn Levon	shift
7*1f5207b7SJohn Levon	context=$1
8*1f5207b7SJohn Levon	shift
9*1f5207b7SJohn Levon	continue
10*1f5207b7SJohn Levon    fi
11*1f5207b7SJohn Levon    break
12*1f5207b7SJohn Levondone
13*1f5207b7SJohn Levon
14*1f5207b7SJohn Levon
15*1f5207b7SJohn Levonfile=$1
16*1f5207b7SJohn Levon[ "$file" = "" ] && [ -e err-list ] && file=err-list
17*1f5207b7SJohn Levonif [[ "$file" = "" ]] ; then
18*1f5207b7SJohn Levon    echo "Usage:  $0 [-C <lines>] [-b] [-k] <file with smatch messages>"
19*1f5207b7SJohn Levon    echo "  -C <lines>:  Print <lines> of context"
20*1f5207b7SJohn Levon    exit 1
21*1f5207b7SJohn Levonfi
22*1f5207b7SJohn Levon
23*1f5207b7SJohn Levoncat $file | while read line ; do
24*1f5207b7SJohn Levon    code_file=$(echo "$line" | cut -d ':' -f 1)
25*1f5207b7SJohn Levon    lineno=$(echo "$line" | cut -d ' ' -f 1 | cut -d ':' -f 2)
26*1f5207b7SJohn Levon    echo "========================================================="
27*1f5207b7SJohn Levon    echo "$line"
28*1f5207b7SJohn Levon    echo "---"
29*1f5207b7SJohn Levon    tail -n +$(($lineno - ($context - 1))) $code_file | head -n $(($context - 1))
30*1f5207b7SJohn Levon    echo "---------------------------------------------------------"
31*1f5207b7SJohn Levon    tail -n +${lineno} $code_file | head -n $context
32*1f5207b7SJohn Levondone
33*1f5207b7SJohn Levon
34