On Sat, Mar 29, 2025 at 03:18:20PM +0000, Iain Sandoe wrote:
> Hi Jakub
>
> Thanks for doing this...
>
> > On 28 Mar 2025, at 14:39, Jakub Jelinek <[email protected]> wrote:
> >
> > +cobol/charmaps.cc cobol/valconv.cc: cobol/%.cc: $(LIB_SOURCE)/%.cc
> > + -l='ec\|common-defs\|io\|gcobolio\|libgcobol\|gfileio\|charmaps'; \
> > + l=$$l'\|valconv\|exceptl'; \
> > + sed -e '/^#include/s,"\('$$l'\)\.h","../../libgcobol/\1.h",' $^ > $@
>
> .. however, this does not work with the BSD sed on Darwin (although it does
> with GNU sed on Darwin).
>
> The issue appears to be that alternation is an ERE addition from my reading
> of
> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03
> (the Darwin BRE sed works fine when there is only one match in the
> sub-expression,
> but fails as soon as any alternate is added).
>
> Darwin’s sed (and at least x86_64 / aarch64 Linux sed) work fine with the
> updated patch
> to use an ERE instead. Do you think this is an acceptable update? (it is
> still POSIX sed).
I'm not sure if sed -E is portable enough (sure, I know it is in POSIX, but
that is not enough).
How about just
sed -e '/^#include/s,"\([^"]*.h\)","../../libgcobol/\1",' $& > $@
?
I mean, both charmaps.cc and valconv.cc use #include <> for system headers
and #include "" for local headers and we want to adjust all of the latter
and none of the former?
> diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in
> index 990d51a8578..bbf1c9ef30e 100644
> --- a/gcc/cobol/Make-lang.in
> +++ b/gcc/cobol/Make-lang.in
> @@ -88,9 +88,8 @@ cobol1_OBJS = \
> # so that the .h files can be found.
>
> cobol/charmaps.cc cobol/valconv.cc: cobol/%.cc: $(LIB_SOURCE)/%.cc
> - -l='ec\|common-defs\|io\|gcobolio\|gfileio\|charmaps'; \
> - l=$$l'\|valconv\|exceptl'; \
> - sed -e '/^#include/s,"\('$$l'\)\.h","../../libgcobol/\1.h",' $^ > $@
> + -l='ec|common-defs|io|gcobolio|gfileio|charmaps|valconv|exceptl'; \
> + sed -E -e '/^#include/s,"('$$l')\.h","../../libgcobol/\1.h",' $^ > $@
>
> LIB_SOURCE_H=$(wildcard $(LIB_SOURCE)/*.h)
>
Jakub