devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] srcpos: correct column numbers
@ 2018-01-15 18:33 Julia Lawall
  2018-01-16  0:20 ` Frank Rowand
  0 siblings, 1 reply; 9+ messages in thread
From: Julia Lawall @ 2018-01-15 18:33 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

The start of a line is column 0, at least according to emacs.

Every character counts, so need to increment by 1 before adjusting for tab.

Signed-off-by: Julia Lawall <Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
---
 srcpos.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpos.c b/srcpos.c
index 9d38459..e8fced9 100644
--- a/srcpos.c
+++ b/srcpos.c
@@ -154,7 +154,7 @@ void srcfile_push(const char *fname)
 	srcfile->prev = current_srcfile;

 	srcfile->lineno = 1;
-	srcfile->colno = 1;
+	srcfile->colno = 0;

 	current_srcfile = srcfile;
 }
@@ -223,8 +223,9 @@ void srcpos_update(struct srcpos *pos, const char *text, int len)
 	for (i = 0; i < len; i++)
 		if (text[i] == '\n') {
 			current_srcfile->lineno++;
-			current_srcfile->colno = 1;
+			current_srcfile->colno = 0;
 		} else if (text[i] == '\t') {
+			current_srcfile->colno++;
 			current_srcfile->colno =
 				ALIGN(current_srcfile->colno, TAB_SIZE);
 		} else {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-01-19  5:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-15 18:33 [PATCH] srcpos: correct column numbers Julia Lawall
2018-01-16  0:20 ` Frank Rowand
     [not found]   ` <4eec9dbb-c047-86ae-e4b2-08de9f0499fe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-16  6:10     ` Julia Lawall
2018-01-18  4:22       ` David Gibson
     [not found]         ` <20180118042202.GI30352-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2018-01-18  5:15           ` Julia Lawall
2018-01-18  7:01             ` David Gibson
     [not found]               ` <20180118070123.GV30352-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2018-01-18 10:12                 ` Julia Lawall
2018-01-19  5:44                   ` David Gibson
     [not found]                     ` <20180119054454.GA28299-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2018-01-19  5:59                       ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).