[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dfa.c:in_coll_range z/OS fixes
From: |
Jim Meyering |
Subject: |
Re: dfa.c:in_coll_range z/OS fixes |
Date: |
Tue, 06 Apr 2010 21:03:12 +0200 |
Aharon Robbins wrote:
> Hi. My z/OS maintainer indicates that in_coll_range() doesn't compile
> there. He suggests the following patch:
>
> *** dfa.c.orig Fri Apr 2 06:00:20 2010
> --- dfa.c Fri Apr 2 05:59:38 2010
> ***************
> *** 408,414 ****
> --- 408,419 ----
> static int
> in_coll_range (char ch, char from, char to)
> {
> + #ifdef ZOS_USS
> + char c[6] = { 0, 0, 0, 0, 0, 0 };
> + c[0] = from; c[2] = ch; c[4] = to;
> + #else
> char c[6] = { from, 0, ch, 0, to, 0 };
> + #endif
> return strcoll (&c[0], &c[2]) <= 0 && strcoll (&c[2], &c[4]) <= 0;
> }
>
> I rather prefer this one, since it's straightforward and clear:
And since it avoids not only in-function, but system-specific
(contrary to autoconf's feature-test philosophy) #if tests.
> Index: dfa.c
> ===================================================================
> RCS file: /d/mongo/cvsrep/gawk-stable/dfa.c,v
> retrieving revision 1.29
> diff -u -r1.29 dfa.c
> --- dfa.c 2 Apr 2010 09:33:41 -0000 1.29
> +++ dfa.c 4 Apr 2010 12:29:47 -0000
> @@ -408,7 +501,10 @@
> static int
> in_coll_range (char ch, char from, char to)
> {
> - char c[6] = { from, 0, ch, 0, to, 0 };
> + char c[6] = { 0, 0, 0, 0, 0, 0 };
> + c[0] = from;
> + c[2] = ch;
> + c[4] = to;
> return strcoll (&c[0], &c[2]) <= 0 && strcoll (&c[2], &c[4]) <= 0;
> }
>
> Please let me know if either of these is acceptable.
I prefer to avoid even the semblance of dead stores
for the odd-numbered elements. I've committed the following
change on a private-for-now "old-compilers" branch.
I'll see how much trouble it is to carry this one change
through the upcoming development. If the branch survives and
grows, I may eventually publish it.
>From 4aeebc7febb4ccd49ecffd0181159c0dd866642c Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 6 Apr 2010 20:59:10 +0200
Subject: [PATCH] avoid C99 auto initializer syntax
* src/dfa.c (in_coll_range): Initialize explicitly. For z/OS.
---
src/dfa.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/dfa.c b/src/dfa.c
index ca32b66..ef878f2 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -375,7 +375,13 @@ static unsigned char const *buf_end; /* reference to
end in dfaexec(). */
static int
in_coll_range (char ch, char from, char to)
{
- char c[6] = { from, 0, ch, 0, to, 0 };
+ char c[6];
+ c[0] = from;
+ c[1] = 0;
+ c[2] = ch;
+ c[3] = 0;
+ c[4] = to;
+ c[5] = 0;
return strcoll (&c[0], &c[2]) <= 0 && strcoll (&c[2], &c[4]) <= 0;
}
--
1.7.0.4.552.gc303