#!/bin/rc # From sl and the folks at 9front. if(~ $#* 0){ echo usage: $0 file ... >[1=2] exit usage } awk 'BEGIN{ n=0 } function hex(h){ v=0 h=tolower(h) if(!sub(/^0x/, "", h)) return h for(i=1; i<=length(h); ++i){ x=index("0123456789abcdef", substr(h, i, 1)) if(!x) return -1 v=(16*v)+x-1 } return v } { if(FNR == 1){ if(NR == 1){ hx=$1 hy=$2 } next } if(length($3) == 0) next f=$3 d=FILENAME if(sub(/\/[^\/]+$/, "", d)) f=sprintf("%s/%s", d, f) if(system(sprintf("test -e %s", f))){ printf("%s:%d missing %s\n", FILENAME, FNR, f) >"/fd/2" next } s = hex($1) e = hex($2) if(e < s) next for(i=0; i= as[i] && s <= ae[i]) s = ae[i]+1 if(e >= as[i] && e <= ae[i]) e = as[i]-1 if(s > e) next } as[n] = hex($1) ae[n] = hex($2) ax[n] = f n++; } END{ printf("%d %d\n", hx, hy) for(i=0; i