public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [libgo PATCH 0/1] mksyscalls.awk: make split ERE more portable
@ 2013-08-01 12:50 Bernhard Reutner-Fischer
  2013-08-01 12:50 ` [libgo PATCH 1/1] " Bernhard Reutner-Fischer
  2013-08-02 22:33 ` [libgo PATCH 0/1] " Ian Lance Taylor
  0 siblings, 2 replies; 3+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-08-01 12:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bernhard Reutner-Fischer, Ian Lance Taylor, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 413 bytes --]

Hi,

When using busybox' awk to bootstrap, libgo's syscalls are generated
incorrectly.

I'm attaching the split() used by busybox' awk including output before
and after the patch for reference.

Please install / ok to install?

Bernhard Reutner-Fischer (1):
  mksyscalls.awk: make split ERE more portable

 libgo/go/syscall/mksyscall.awk |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
1.7.10.4

[-- Attachment #2: regexec.c --]
[-- Type: text/x-csrc, Size: 1318 bytes --]

#include <regex.h>
#include <string.h>
#include <stdio.h>
int main(void) {
	int l, n = 0;
	char *inp = "//sysnb	pipe(p *[2]_C_int) (err error)";
	char *out = __builtin_alloca(strlen(inp)*2+3);
	regex_t re;
	regmatch_t m[1];
	strcpy(out, inp);
#ifndef ERE
# define ERE "[	 (]*"
#endif
	if (regcomp(&re, ERE, REG_EXTENDED) != 0)
		__builtin_abort();
	do {
		l = strcspn(inp, "\n\0");
		if (regexec(&re, inp, 1, m, 0) == 0 && m[0].rm_so <= l) {
			l = m[0].rm_so;
			if (m[0].rm_eo == 0)
				m[0].rm_eo++, l++;
			n++;
		} else {
			m[0].rm_eo = l;
			if (inp[l])
				m[0].rm_eo++;
		}
		memcpy(out, inp, l);
		do {
			out[l] = '\0';
		} while (++l < m[0].rm_eo);
		printf("[%2d] '%s'\n", n, out);
		while (*(out++) != '\0')
			continue;
		inp += m[0].rm_eo;
	} while (*inp);
	regfree(&re);
	return 0;
}

#if 0
+ gcc '-DERE="[ 	(]*"' -o x regexec.c
+ ./x
[ 1] '/'
[ 2] '/'
[ 3] 's'
[ 4] 'y'
[ 5] 's'
[ 6] 'n'
[ 7] 'b'
[ 8] ''
[ 9] 'p'
[10] 'i'
[11] 'p'
[12] 'e'
[13] ''
[14] 'p'
[15] ''
[16] '*'
[17] '['
[18] '2'
[19] ']'
[20] '_'
[21] 'C'
[22] '_'
[23] 'i'
[24] 'n'
[25] 't'
[26] ')'
[27] ''
[28] 'e'
[29] 'r'
[30] 'r'
[31] ''
[32] 'e'
[33] 'r'
[34] 'r'
[35] 'o'
[36] 'r'
[37] ')'
+ gcc '-DERE="[ 	(]"' -o x regexec.c
+ ./x
[ 1] '//sysnb'
[ 2] 'pipe'
[ 3] 'p'
[ 4] '*[2]_C_int)'
[ 5] ''
[ 6] 'err'
[ 6] 'error)'
#endif

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

* [libgo PATCH 1/1] mksyscalls.awk: make split ERE more portable
  2013-08-01 12:50 [libgo PATCH 0/1] mksyscalls.awk: make split ERE more portable Bernhard Reutner-Fischer
@ 2013-08-01 12:50 ` Bernhard Reutner-Fischer
  2013-08-02 22:33 ` [libgo PATCH 0/1] " Ian Lance Taylor
  1 sibling, 0 replies; 3+ messages in thread
From: Bernhard Reutner-Fischer @ 2013-08-01 12:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bernhard Reutner-Fischer, Ian Lance Taylor, gofrontend-dev

awk's split() ERE was splitting on (essentially) .
Double checked with mawk 1.3.3, GNU Awk 4.0.1, busybox awk
that they still produce identical output.

libgo/ChangeLog (???)

2013-08-01  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

	* go/syscall/mksyscall.awk (split): Fix ere argument.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 libgo/go/syscall/mksyscall.awk |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libgo/go/syscall/mksyscall.awk b/libgo/go/syscall/mksyscall.awk
index 74f0e28..829b6fe 100644
--- a/libgo/go/syscall/mksyscall.awk
+++ b/libgo/go/syscall/mksyscall.awk
@@ -53,7 +53,7 @@ BEGIN {
     }
 
     # Sets a[1] = //sysnb, a[2] == function name.
-    split(line, a, "[ 	(]*")
+    split(line, a, "[ 	(]")
     gofnname = a[2]
 
     off = match(line, "\\([^()]*\\)")
@@ -78,7 +78,7 @@ BEGIN {
 	next
     }
 
-    split(line, a, "[ 	(]*")
+    split(line, a, "[ 	(]")
     cfnname = substr(a[1], 3, length(a[1]) - 2)
 
     off = match(line, "\\([^()]*\\)")
-- 
1.7.10.4

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

* Re: [libgo PATCH 0/1] mksyscalls.awk: make split ERE more portable
  2013-08-01 12:50 [libgo PATCH 0/1] mksyscalls.awk: make split ERE more portable Bernhard Reutner-Fischer
  2013-08-01 12:50 ` [libgo PATCH 1/1] " Bernhard Reutner-Fischer
@ 2013-08-02 22:33 ` Ian Lance Taylor
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2013-08-02 22:33 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer; +Cc: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 593 bytes --]

On Thu, Aug 1, 2013 at 5:36 AM, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
>
> When using busybox' awk to bootstrap, libgo's syscalls are generated
> incorrectly.
>
> I'm attaching the split() used by busybox' awk including output before
> and after the patch for reference.
>
> Please install / ok to install?

I installed a slightly different version, that retains the desired
semantics (skip arbitrary amounts of whitespace).  This should avoid
confusing the busybox awk by matching the null string.  Committed to
mainline and 4.8 branch.

Thanks for reporting the issue.

Ian

[-- Attachment #2: foo.patch --]
[-- Type: application/octet-stream, Size: 572 bytes --]

diff -r 76558b3ff8f3 libgo/go/syscall/mksyscall.awk
--- a/libgo/go/syscall/mksyscall.awk	Fri Aug 02 09:59:39 2013 -0700
+++ b/libgo/go/syscall/mksyscall.awk	Fri Aug 02 15:28:21 2013 -0700
@@ -53,7 +53,7 @@
     }
 
     # Sets a[1] = //sysnb, a[2] == function name.
-    split(line, a, "[ 	(]*")
+    split(line, a, "[ 	(]+")
     gofnname = a[2]
 
     off = match(line, "\\([^()]*\\)")
@@ -78,7 +78,7 @@
 	next
     }
 
-    split(line, a, "[ 	(]*")
+    split(line, a, "[ 	(]+")
     cfnname = substr(a[1], 3, length(a[1]) - 2)
 
     off = match(line, "\\([^()]*\\)")

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

end of thread, other threads:[~2013-08-02 22:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-01 12:50 [libgo PATCH 0/1] mksyscalls.awk: make split ERE more portable Bernhard Reutner-Fischer
2013-08-01 12:50 ` [libgo PATCH 1/1] " Bernhard Reutner-Fischer
2013-08-02 22:33 ` [libgo PATCH 0/1] " Ian Lance Taylor

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 read-only IMAP folder(s) and NNTP newsgroup(s).