make = command's output plumbable
This patch makes sam's = cmd output what seems to me a more useful (plumbable) format: /full/path/to/file:addr , where addr is line(s) under = and rune(s) under =#.
This commit is contained in:
parent
c7e0f3b65f
commit
6730cc562d
2 changed files with 20 additions and 8 deletions
|
@ -403,10 +403,10 @@ Print the text in the range.
|
||||||
Set dot.
|
Set dot.
|
||||||
.TP
|
.TP
|
||||||
.B =
|
.B =
|
||||||
Print the line address and character address of the range.
|
Print the file name and line address of the range.
|
||||||
.TP
|
.TP
|
||||||
.B =#
|
.B =#
|
||||||
Print just the character address of the range.
|
Print the file name and character address of the range.
|
||||||
.PD
|
.PD
|
||||||
.SS File commands
|
.SS File commands
|
||||||
.PD 0
|
.PD 0
|
||||||
|
|
|
@ -688,11 +688,27 @@ nlcount(File *f, Posn p0, Posn p1)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printposn(File *f, int charsonly)
|
printposn(File *f, int chars)
|
||||||
{
|
{
|
||||||
Posn l1, l2;
|
Posn l1, l2;
|
||||||
|
char *s;
|
||||||
|
|
||||||
if(!charsonly){
|
if(f->name.s[0]){
|
||||||
|
if(f->name.s[0]!='/'){
|
||||||
|
getcurwd();
|
||||||
|
s = Strtoc(&curwd);
|
||||||
|
dprint("%s", s);
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
|
s = Strtoc(&f->name);
|
||||||
|
dprint("%s:", s);
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
|
if(chars){
|
||||||
|
dprint("#%lud", addr.r.p1);
|
||||||
|
if(addr.r.p2 != addr.r.p1)
|
||||||
|
dprint(",#%lud", addr.r.p2);
|
||||||
|
}else{
|
||||||
l1 = 1+nlcount(f, (Posn)0, addr.r.p1);
|
l1 = 1+nlcount(f, (Posn)0, addr.r.p1);
|
||||||
l2 = l1+nlcount(f, addr.r.p1, addr.r.p2);
|
l2 = l1+nlcount(f, addr.r.p1, addr.r.p2);
|
||||||
/* check if addr ends with '\n' */
|
/* check if addr ends with '\n' */
|
||||||
|
@ -701,11 +717,7 @@ printposn(File *f, int charsonly)
|
||||||
dprint("%lud", l1);
|
dprint("%lud", l1);
|
||||||
if(l2 != l1)
|
if(l2 != l1)
|
||||||
dprint(",%lud", l2);
|
dprint(",%lud", l2);
|
||||||
dprint("; ");
|
|
||||||
}
|
}
|
||||||
dprint("#%lud", addr.r.p1);
|
|
||||||
if(addr.r.p2 != addr.r.p1)
|
|
||||||
dprint(",#%lud", addr.r.p2);
|
|
||||||
dprint("\n");
|
dprint("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue