Skip to contentSkip to conversation

srcpos: correct column numbers

PATCH In review Julia Lawall 3 participants 9 messages Jan 15, 2018 – Jan 19, 2018 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 srcpos: correct column numbers

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.

---
 srcpos.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
srcpos.c +3 -2
index 9d38459..e8fced9 100644
@@ -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 {
Signature · 1 line
2.7.4
#1 lore raw
Quoted 1 line · Julia Lawall

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

According to vim, the first character of a line is column 1. I don't know if it has a concept of column 0, to the left of that character.

$ vim --version
VIM - Vi IMproved 7.4

Let the editor wars begin.... :-)

Personally, I use vim, but if the dtc column numbers match emac's world view instead of vim's, that is fine with me.

-Frank

Quoted 33 lines

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

---
 srcpos.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
srcpos.c +3 -2
index 9d38459..e8fced9 100644
@@ -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 {

A message that is not in the archive (sent off-list or not yet received): 4eec9dbb-c047-86ae-e4b2-08de9f0499fe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#3 lore raw
Quoted 6 lines · Frank Rowand
Quoted 1 line · Julia Lawall

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

According to vim, the first character of a line is column 1. I don't know if it has a concept of column 0, to the left of that character.

Quoted 7 lines
$ vim --version
VIM - Vi IMproved 7.4

Let the editor wars begin.... :-)

Personally, I use vim, but if the dtc column numbers match emac's world view instead of vim's, that is fine with me.

At the start of a line, ie just after a \n, there has been no character. This change made the column numbers work for me in the annotations.

There is also the issue of tabs. David wanted tabs to count as 8 characters, but actually cpp converts tabs to spaces. So if a dts file has been through cpp, the numbers will be smaller. So it could be better to consider tabs to be 1 character, to not have to think about what kind of include was used.

julia

Quoted 42 lines

-Frank

Quoted 23 lines

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

---
 srcpos.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
srcpos.c +1 -1
index 9d38459..e8fced9 100644
@@ -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;
 }

srcpos.c void srcpos_update(struct srcpos *pos, const char *text, int len) · line 231

Quoted 10 lines
srcpos.c +2 -1
@@ -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 {

--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 18 lines · Julia Lawall
Quoted 6 lines · Frank Rowand
Quoted 1 line · Julia Lawall

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

According to vim, the first character of a line is column 1. I don't know if it has a concept of column 0, to the left of that character.

Quoted 7 lines
$ vim --version
VIM - Vi IMproved 7.4

Let the editor wars begin.... :-)

Personally, I use vim, but if the dtc column numbers match emac's world view instead of vim's, that is fine with me.

Quoted 8 lines

At the start of a line, ie just after a \n, there has been no character. This change made the column numbers work for me in the annotations.

There is also the issue of tabs. David wanted tabs to count as 8 characters, but actually cpp converts tabs to spaces. So if a dts file has been through cpp, the numbers will be smaller. So it could be better to consider tabs to be 1 character, to not have to think about what kind of include was used.

Urgh.. debating which editor to match sounds like it's going to be a rathole.

Let's try a different approach: does gcc ever report column numbers? If so, what's its interpretation?

Quoted 41 lines

julia

Quoted 38 lines

-Frank

Quoted 33 lines

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

---
 srcpos.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
srcpos.c +3 -2
index 9d38459..e8fced9 100644
@@ -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 {
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 28 lines · David Gibson
Quoted 18 lines · Julia Lawall
Quoted 6 lines · Frank Rowand
Quoted 1 line · Julia Lawall

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

According to vim, the first character of a line is column 1. I don't know if it has a concept of column 0, to the left of that character.

Quoted 7 lines
$ vim --version
VIM - Vi IMproved 7.4

Let the editor wars begin.... :-)

Personally, I use vim, but if the dtc column numbers match emac's world view instead of vim's, that is fine with me.

Quoted 8 lines

At the start of a line, ie just after a \n, there has been no character. This change made the column numbers work for me in the annotations.

There is also the issue of tabs. David wanted tabs to count as 8 characters, but actually cpp converts tabs to spaces. So if a dts file has been through cpp, the numbers will be smaller. So it could be better to consider tabs to be 1 character, to not have to think about what kind of include was used.

Quoted 5 lines

Urgh.. debating which editor to match sounds like it's going to be a rathole.

Let's try a different approach: does gcc ever report column numbers? If so, what's its interpretation?

Chosen at random, I have the following error:

drivers/thermal/kirkwood_thermal.c:88:15: warning: assignment makes pointer from
integer without a cast [enabled by default]
priv->sensor = devm_request_and_ioremap(&pdev->dev, res);

and the following code:

	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);

In emacs, the go to the line and type control f 15 times solution puts the cursor right afher after the =. The column numbers of emacs report 22 for that position. I guess in vim, putting the cursor right on the = would report 15.

When I run the dts compiler on tests/test_tree1.dts, for line 39:

                        compatible = "subsubnode2", "subsubnode";

I get the start and end as 24 and 65. 24 is what emacs shows as the column number when I put the cursor right on the c. 65 is what the column number shows when I put the cursor right past the semicolon.

I tried to move around in vim, but I don't know how it works. It seems to report the position of the c as 4 or 25. It seems to report the position of the final semicolon as 44 or 65. I am not sure how it work though, because it gives the impression that there is a single blank character before c, which is not the case.

julia

#7 lore raw
Quoted 63 lines · Julia Lawall
Quoted 28 lines · David Gibson
Quoted 18 lines · Julia Lawall
Quoted 6 lines · Frank Rowand
Quoted 1 line · Julia Lawall

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

According to vim, the first character of a line is column 1. I don't know if it has a concept of column 0, to the left of that character.

Quoted 7 lines
$ vim --version
VIM - Vi IMproved 7.4

Let the editor wars begin.... :-)

Personally, I use vim, but if the dtc column numbers match emac's world view instead of vim's, that is fine with me.

Quoted 8 lines

At the start of a line, ie just after a \n, there has been no character. This change made the column numbers work for me in the annotations.

There is also the issue of tabs. David wanted tabs to count as 8 characters, but actually cpp converts tabs to spaces. So if a dts file has been through cpp, the numbers will be smaller. So it could be better to consider tabs to be 1 character, to not have to think about what kind of include was used.

Quoted 5 lines

Urgh.. debating which editor to match sounds like it's going to be a rathole.

Let's try a different approach: does gcc ever report column numbers? If so, what's its interpretation?

Chosen at random, I have the following error:

drivers/thermal/kirkwood_thermal.c:88:15: warning: assignment makes pointer from
integer without a cast [enabled by default]
priv->sensor = devm_request_and_ioremap(&pdev->dev, res);

and the following code:

	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);

In emacs, the go to the line and type control f 15 times solution puts the cursor right afher after the =. The column numbers of emacs report 22 for that position. I guess in vim, putting the cursor right on the = would report 15.

When I run the dts compiler on tests/test_tree1.dts, for line 39:

                        compatible = "subsubnode2", "subsubnode";

I get the start and end as 24 and 65. 24 is what emacs shows as the column number when I put the cursor right on the c. 65 is what the column number shows when I put the cursor right past the semicolon.

Quoted 5 lines

I tried to move around in vim, but I don't know how it works. It seems to report the position of the c as 4 or 25. It seems to report the position of the final semicolon as 44 or 65. I am not sure how it work though, because it gives the impression that there is a single blank character before c, which is not the case.

Ok, let's go with the gcc definition, which appears to be "# of bytes past the last \n".

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 64 lines · David Gibson
Quoted 63 lines · Julia Lawall
Quoted 28 lines · David Gibson
Quoted 18 lines · Julia Lawall
Quoted 6 lines · Frank Rowand
Quoted 1 line · Julia Lawall

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

According to vim, the first character of a line is column 1. I don't know if it has a concept of column 0, to the left of that character.

Quoted 7 lines
$ vim --version
VIM - Vi IMproved 7.4

Let the editor wars begin.... :-)

Personally, I use vim, but if the dtc column numbers match emac's world view instead of vim's, that is fine with me.

Quoted 8 lines

At the start of a line, ie just after a \n, there has been no character. This change made the column numbers work for me in the annotations.

There is also the issue of tabs. David wanted tabs to count as 8 characters, but actually cpp converts tabs to spaces. So if a dts file has been through cpp, the numbers will be smaller. So it could be better to consider tabs to be 1 character, to not have to think about what kind of include was used.

Quoted 5 lines

Urgh.. debating which editor to match sounds like it's going to be a rathole.

Let's try a different approach: does gcc ever report column numbers? If so, what's its interpretation?

Chosen at random, I have the following error:

drivers/thermal/kirkwood_thermal.c:88:15: warning: assignment makes pointer from
integer without a cast [enabled by default]
priv->sensor = devm_request_and_ioremap(&pdev->dev, res);

and the following code:

	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);

In emacs, the go to the line and type control f 15 times solution puts the cursor right afher after the =. The column numbers of emacs report 22 for that position. I guess in vim, putting the cursor right on the = would report 15.

When I run the dts compiler on tests/test_tree1.dts, for line 39:

                        compatible = "subsubnode2", "subsubnode";

I get the start and end as 24 and 65. 24 is what emacs shows as the column number when I put the cursor right on the c. 65 is what the column number shows when I put the cursor right past the semicolon.

Quoted 8 lines
Quoted 5 lines

I tried to move around in vim, but I don't know how it works. It seems to report the position of the c as 4 or 25. It seems to report the position of the final semicolon as 44 or 65. I am not sure how it work though, because it gives the impression that there is a single blank character before c, which is not the case.

Ok, let's go with the gcc definition, which appears to be "# of bytes past the last \n".

So that would be the strategy of the patch, where seeing a newline sets the counter to 0.

julia

Quoted 7 lines

--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_

				| _way_ _around_!

http://www.ozlabs.org/~dgibson

#10 lore raw
Quoted 74 lines · Julia Lawall
Quoted 70 lines · David Gibson
Quoted 68 lines · Julia Lawall
Quoted 28 lines · David Gibson
Quoted 18 lines · Julia Lawall
Quoted 6 lines · Frank Rowand
Quoted 1 line · Julia Lawall

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

According to vim, the first character of a line is column 1. I don't know if it has a concept of column 0, to the left of that character.

Quoted 7 lines
$ vim --version
VIM - Vi IMproved 7.4

Let the editor wars begin.... :-)

Personally, I use vim, but if the dtc column numbers match emac's world view instead of vim's, that is fine with me.

Quoted 8 lines

At the start of a line, ie just after a \n, there has been no character. This change made the column numbers work for me in the annotations.

There is also the issue of tabs. David wanted tabs to count as 8 characters, but actually cpp converts tabs to spaces. So if a dts file has been through cpp, the numbers will be smaller. So it could be better to consider tabs to be 1 character, to not have to think about what kind of include was used.

Quoted 5 lines

Urgh.. debating which editor to match sounds like it's going to be a rathole.

Let's try a different approach: does gcc ever report column numbers? If so, what's its interpretation?

Chosen at random, I have the following error:

drivers/thermal/kirkwood_thermal.c:88:15: warning: assignment makes pointer from
integer without a cast [enabled by default]
priv->sensor = devm_request_and_ioremap(&pdev->dev, res);

and the following code:

	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);

In emacs, the go to the line and type control f 15 times solution puts the cursor right afher after the =. The column numbers of emacs report 22 for that position. I guess in vim, putting the cursor right on the = would report 15.

When I run the dts compiler on tests/test_tree1.dts, for line 39:

                        compatible = "subsubnode2", "subsubnode";

I get the start and end as 24 and 65. 24 is what emacs shows as the column number when I put the cursor right on the c. 65 is what the column number shows when I put the cursor right past the semicolon.

I tried to move around in vim, but I don't know how it works. It seems to report the position of the c as 4 or 25. It seems to report the position of the final semicolon as 44 or 65. I am not sure how it work though, because it gives the impression that there is a single blank character before c, which is not the case.

Quoted 5 lines
Quoted 2 lines

Ok, let's go with the gcc definition, which appears to be "# of bytes past the last \n".

So that would be the strategy of the patch, where seeing a newline sets the counter to 0.

Right, but we should kill the tab expansion stuff at the same time.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw
Quoted 75 lines · David Gibson
Quoted 74 lines · Julia Lawall
Quoted 70 lines · David Gibson
Quoted 68 lines · Julia Lawall
Quoted 28 lines · David Gibson
Quoted 18 lines · Julia Lawall
Quoted 6 lines · Frank Rowand
Quoted 1 line · Julia Lawall

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

According to vim, the first character of a line is column 1. I don't know if it has a concept of column 0, to the left of that character.

Quoted 7 lines
$ vim --version
VIM - Vi IMproved 7.4

Let the editor wars begin.... :-)

Personally, I use vim, but if the dtc column numbers match emac's world view instead of vim's, that is fine with me.

Quoted 8 lines

At the start of a line, ie just after a \n, there has been no character. This change made the column numbers work for me in the annotations.

There is also the issue of tabs. David wanted tabs to count as 8 characters, but actually cpp converts tabs to spaces. So if a dts file has been through cpp, the numbers will be smaller. So it could be better to consider tabs to be 1 character, to not have to think about what kind of include was used.

Quoted 5 lines

Urgh.. debating which editor to match sounds like it's going to be a rathole.

Let's try a different approach: does gcc ever report column numbers? If so, what's its interpretation?

Chosen at random, I have the following error:

drivers/thermal/kirkwood_thermal.c:88:15: warning: assignment makes pointer from
integer without a cast [enabled by default]
priv->sensor = devm_request_and_ioremap(&pdev->dev, res);

and the following code:

	priv->sensor = devm_request_and_ioremap(&pdev->dev, res);

In emacs, the go to the line and type control f 15 times solution puts the cursor right afher after the =. The column numbers of emacs report 22 for that position. I guess in vim, putting the cursor right on the = would report 15.

When I run the dts compiler on tests/test_tree1.dts, for line 39:

                        compatible = "subsubnode2", "subsubnode";

I get the start and end as 24 and 65. 24 is what emacs shows as the column number when I put the cursor right on the c. 65 is what the column number shows when I put the cursor right past the semicolon.

I tried to move around in vim, but I don't know how it works. It seems to report the position of the c as 4 or 25. It seems to report the position of the final semicolon as 44 or 65. I am not sure how it work though, because it gives the impression that there is a single blank character before c, which is not the case.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Ok, let's go with the gcc definition, which appears to be "# of bytes past the last \n".

So that would be the strategy of the patch, where seeing a newline sets the counter to 0.

Right, but we should kill the tab expansion stuff at the same time.

OK, I'll do that.

julia