help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gmake UTF-8 Support?


From: Kaz Kylheku (gmake)
Subject: Re: Gmake UTF-8 Support?
Date: Wed, 29 Sep 2021 09:23:32 -0700
User-agent: Roundcube Webmail/0.9.2

On 2021-09-29 08:52, Jon Forrest wrote:
I'm curious whether gmake supports UTF-8 in Makefiles.
I did some googling and saw one report that it did but
I grepped the source code and only found a couple of
references to UTF-8. One was looking for the UTF-8
BOM at the beginning of input files, and the other
was in guile.c. I didn't see anything in read.c for
handling multi-byte characters but maybe I missed
something.

So, my question is does gmake support UTF-8 in Makefiles?

UTF-8 is supposed to just pass through programs and functions
that are 8-bit clean. That's a "feature". It was invented
by dyed-in-the-wool Unix hackers Ken Thompson and Rob Pike.

For instance strlen(x) will work if x is UTF-8; it just
won't give you the number of multibyte characters or code
points in the string, only the bytes.

If the program allows bytes in the range 0x80 to 0xFF
to be parts of identifiers then you can use Unicode
characters in identifiers.

The caveat is that there are no security checks in such
a program, like defenses against overlong forms or other
invalid UTF-8. You trust your own Makefile, though.

What have you tried? What would you like to do; where
would you like to use Unicode characters?

The following Makefile, which uses kanji in variable names,
works for me.

$ cat Makefile.u8
対象 := foo

部分 := foo.o bar.o


$(対象): $(部分)
        $(CC) -o $@ $<

$ make -f Makefile.u8
cc    -c -o foo.o foo.c
make: *** No rule to make target 'bar.o', needed by 'foo'.  Stop

$ touch foo.o bar.o

$ make -f Makefile.u8
cc -o foo foo.o

I did some experimenting with these characters in file names;
that works too.

None of this implies "support" for UTF-8, other than not
screwing up the handling of bytes in the 0x80-0xFF range,
and allowing them to be constituents of identifiers and other
data.

You just can't have ASCII whitespace. :)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]