delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/10/08/03:54:46

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
In-Reply-To: <342661340910072002w47aeec8av63f87fe9202cb90b@mail.gmail.com>
To: Hirofumi Katayama <katayama DOT hirofumi DOT mz AT gmail DOT com>
Cc: cygwin AT cygwin DOT com
Subject: Re: -municode support
MIME-Version: 1.0
Message-ID: <OF56FF46D0.ED6B61C8-ONC1257649.002AD792-C1257649.002B6918@onevision.de>
From: Kai Tietz <Kai DOT Tietz AT onevision DOT com>
Date: Thu, 8 Oct 2009 09:54:39 +0200
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

cygwin-owner AT cygwin DOT com wrote on 08.10.2009 05:02:21:

> I think Cygwin should support -municode option.
> The following patches I made might be incorrect and/or incomplete.
>=20
> diff -u -N -r cygwin-1.7.0-62-old/winsup/mingw/conuni.c
> cygwin-1.7.0-62/winsup/mingw/conuni.c
> --- cygwin-1.7.0-62-old/winsup/mingw/conuni.c   Thu Jan  1 00:00:00 1970
> +++ cygwin-1.7.0-62/winsup/mingw/conuni.c   Tue Oct  6 12:48:04 2009
> @@ -0,0 +1,15 @@
> +/*
> + * conuni.c
> + * This file has no copyright assigned and is placed in the Public=20
Domain.
> + * This file is a part of the mingw-runtime package.
> + * No warranty is given; refer to the file DISCLAIMER within the=20
package.
> + */
> +
> +#include <stdlib.h>
> +#include <wchar.h>
> +
> +int wmain(int, wchar_t **);
> +int main(int argc, char *argv[])
> +{
> +    return wmain(argc, __wargv);
> +}
> diff -u -N -r cygwin-1.7.0-62-old/winsup/mingw/Makefile.in
> cygwin-1.7.0-62/winsup/mingw/Makefile.in
> --- cygwin-1.7.0-62-old/winsup/mingw/Makefile.in   Thu Jul 30 23:38:40=20
2009
> +++ cygwin-1.7.0-62/winsup/mingw/Makefile.in   Tue Oct  6 12:45:12 2009
> @@ -221,7 +221,7 @@
>     TARFLAGS=3D"$(TARFLAGS)" \
>     TARFILEEXT=3D"$(TARFILEEXT)"
>=20
> -CRT0S =3D crt1.o dllcrt1.o crt2.o dllcrt2.o CRT_noglob.o crtmt.o crtst.o=
=20
\
> +CRT0S =3D crt1.o dllcrt1.o crt2.o dllcrt2.o conuni.o winuni.o
> CRT_noglob.o crtmt.o crtst.o \
>     CRT_fp8.o CRT_fp10.o txtmode.o binmode.o
>  MINGW_OBJS =3D CRTglob.o CRTfmode.o CRTinit.o  dllmain.o gccmain.o \
>          main.o crtst.o mthr_stub.o CRT_fp10.o txtmode.o \
> @@ -364,6 +364,12 @@
>  crt2.o dllcrt2.o:
>     $(CC) -c -D__MSVCRT__ -U__CRTDLL__ $(ALL_CFLAGS) $< -o $@
>=20
> +conuni.o:
> +   $(CC) -c -D__MSVCRT__ -U__CRTDLL__ $(ALL_CFLAGS) $< -o $@
> +
> +winuni.o:
> +   $(CC) -c -D__MSVCRT__ -U__CRTDLL__ $(ALL_CFLAGS) $< -o $@
> +
>  check: check-headers
>=20
>  TEST_H_OPTIONS =3D $(ALL_CFLAGS) -Wall -W -Wsystem-headers -c \
> @@ -550,6 +556,8 @@
>  CRTinit.o: CRTinit.c
>  crt1.o: crt1.c init.c
>  crt2.o: crt1.c init.c
> +conuni.o: conuni.c
> +winuni.o: winuni.c
>  crtmt.o: crtmt.c
>  crtst.o: crtst.c
>  ctype_old.o: ctype_old.c
> diff -u -N -r cygwin-1.7.0-62-old/winsup/mingw/winuni.c
> cygwin-1.7.0-62/winsup/mingw/winuni.c
> --- cygwin-1.7.0-62-old/winsup/mingw/winuni.c   Thu Jan  1 00:00:00 1970
> +++ cygwin-1.7.0-62/winsup/mingw/winuni.c   Tue Oct  6 12:48:38 2009
> @@ -0,0 +1,36 @@
> +/*
> + * winuni.c
> + * This file has no copyright assigned and is placed in the Public=20
Domain.
> + * This file is a part of the mingw-runtime package.
> + * No warranty is given; refer to the file DISCLAIMER within the=20
package.
> + */
> +
> +#define WIN32_LEAN_AND_MEAN
> +#include <windows.h>
> +#include <wchar.h>
> +
> +INT WINAPI wWinMain(
> +    HINSTANCE   hInstance,
> +    HINSTANCE   hPrevInstance,
> +    LPWSTR      pszCmdLine,
> +    INT         nCmdShow);
> +
> +INT WINAPI WinMain(
> +    HINSTANCE   hInstance,
> +    HINSTANCE   hPrevInstance,
> +    LPSTR       pszCmdLine,
> +    INT         nCmdShow)
> +{
> +    static const WCHAR blank[] =3D {' ', '\t', 0};
> +    WCHAR *pch =3D GetCommandLineW();
> +    if (*pch =3D=3D '\"')
> +    {
> +        pch =3D wcschr(pch + 1, '\"') + 1;
> +    }
> +    else
> +    {
> +        pch =3D pch + wcscspn(pch, blank);
> +    }
> +    pch =3D pch + wcsspn(pch, blank);
> +    return wWinMain(hInstance, hPrevInstance, pch, nCmdShow);
> +}
> diff -u -N -r gcc-core-4.4.1-old/gcc/config/i386/cygming.opt
> gcc-core-4.4.1/gcc/config/i386/cygming.opt
> --- gcc-core-4.4.1-old/gcc/config/i386/cygming.opt   Thu Aug  2 19:49:32=
=20
2007
> +++ gcc-core-4.4.1/gcc/config/i386/cygming.opt   Tue Oct  6 13:24:54=20
2009
> @@ -45,3 +45,6 @@
>  mwindows
>  Target
>  Create GUI application
> +
> +municode
> +Create Unicode application
> diff -u -N -r gcc-core-4.4.1-old/gcc/config/i386/cygwin.h
> gcc-core-4.4.1/gcc/config/i386/cygwin.h
> --- gcc-core-4.4.1-old/gcc/config/i386/cygwin.h   Sat Feb 21 00:20:38=20
2009
> +++ gcc-core-4.4.1/gcc/config/i386/cygwin.h   Tue Oct  6 13:15:16 2009
> @@ -30,13 +30,14 @@
>    %{!mno-cygwin:-D__CYGWIN32__ -D__CYGWIN__ %{!ansi:-Dunix}
> -D__unix__ -D__unix }\
>    %{mwin32|mno-cygwin:-DWIN32 -D_WIN32 -D__WIN32 -D__WIN32__ %{!
> ansi:-DWINNT}}\
>    %{!nostdinc:%{!mno-win32|mno-cygwin:-idirafter ../include/w32api%s
> -idirafter ../../include/w32api%s}}\
> +  %{municode: -DUNICODE -D_UNICODE}\
>  "
>=20
>  #undef STARTFILE_SPEC
>  #define STARTFILE_SPEC "\
>    %{shared|mdll: %{mno-cygwin:dllcrt2%O%s}}\
>    %{!shared: %{!mdll: %{!mno-cygwin:crt0%O%s} %{mno-cygwin:crt2%O%s}\
> -  %{pg:gcrt0%O%s}}}\
> +  %{pg:gcrt0%O%s} %{municode: %{mconsole:conuni%O%s} %{mwindows:
> winuni%O%s}}}}\
>    crtbegin.o%s"
>=20
>  #undef ENDFILE_SPEC
> diff -u -N -r gcc-core-4.4.1-old/gcc/config/i386/mingw32.h
> gcc-core-4.4.1/gcc/config/i386/mingw32.h
> --- gcc-core-4.4.1-old/gcc/config/i386/mingw32.h   Sat Feb 21 00:20:38=20
2009
> +++ gcc-core-4.4.1/gcc/config/i386/mingw32.h   Tue Oct  6 13:18:10 2009
> @@ -59,7 +59,7 @@
>  #define STANDARD_INCLUDE_COMPONENT "MINGW"
>=20
>  #undef CPP_SPEC
> -#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT}"
> +#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT}
> %{municode:-DUNICODE -D_UNICODE}"
>=20
>  /* For Windows applications, include more libraries, but always include
>     kernel32.  */
> @@ -103,7 +103,9 @@
>=20
>  #undef STARTFILE_SPEC
>  #define STARTFILE_SPEC "%{shared|mdll:dllcrt2%O%s} \
> -  %{!shared:%{!mdll:crt2%O%s}} %{pg:gcrt2%O%s} \
> +  %{!shared:%{!mdll:crt2%O%s \
> +  %{municode: %{mconsole:conuni%O%s} %{mwindows:winuni%O%s}}}} \
> +  %{pg:gcrt2%O%s} \
>    crtbegin.o%s"
>=20
>  #undef ENDFILE_SPEC
> diff -u -N -r gcc-core-4.4.1-old/gcc/doc/g++.1=20
gcc-core-4.4.1/gcc/doc/g++.1
> --- gcc-core-4.4.1-old/gcc/doc/g++.1   Wed Jul 22 17:23:38 2009
> +++ gcc-core-4.4.1/gcc/doc/g++.1   Tue Oct  6 13:32:56 2009
> @@ -838,7 +838,7 @@
>  See i386 and x86\-64 Options.
>  .Sp
>  \&\fIi386 and x86\-64 Windows Options\fR
> -\&\fB\-mconsole \-mcygwin \-mno\-cygwin \-mdll
> +\&\fB\-mconsole \-mcygwin \-mno\-cygwin \-mdll \-municode
>  \&\-mnop\-fun\-dllimport \-mthread \-mwin32 \-mwindows\fR
>  .Sp
>  \&\fIXstormy16 Options\fR
> @@ -14500,6 +14500,12 @@
>  specifies that a \s-1GUI\s0 application is to be generated by
>  instructing the linker to set the \s-1PE\s0 header subsystem type
>  appropriately.
> +.IP "\fB\-municode\fR" 4
> +.IX Item "-municode"
> +This option is available for Cygwin and MinGW targets.  It
> +specifies that a \s-1Unicode\s0 application is to be generated by
> +instructing the linker to set the \s-1PE\s0 header subsystem type
> +appropriately.
>  .PP
>  See also under \fBi386 and x86\-64 Options\fR for standard options.
>  .PP
> diff -u -N -r gcc-core-4.4.1-old/gcc/doc/gcc.1=20
gcc-core-4.4.1/gcc/doc/gcc.1
> --- gcc-core-4.4.1-old/gcc/doc/gcc.1   Wed Jul 22 16:53:10 2009
> +++ gcc-core-4.4.1/gcc/doc/gcc.1   Tue Oct  6 13:31:20 2009
> @@ -838,7 +838,7 @@
>  See i386 and x86\-64 Options.
>  .Sp
>  \&\fIi386 and x86\-64 Windows Options\fR
> -\&\fB\-mconsole \-mcygwin \-mno\-cygwin \-mdll
> +\&\fB\-mconsole \-mcygwin \-mno\-cygwin \-mdll \-municode
>  \&\-mnop\-fun\-dllimport \-mthread \-mwin32 \-mwindows\fR
>  .Sp
>  \&\fIXstormy16 Options\fR
> @@ -14500,6 +14500,12 @@
>  specifies that a \s-1GUI\s0 application is to be generated by
>  instructing the linker to set the \s-1PE\s0 header subsystem type
>  appropriately.
> +.IP "\fB\-municode\fR" 4
> +.IX Item "-municode"
> +This option is available for Cygwin and MinGW targets.  It
> +specifies that a \s-1Unicode\s0 application is to be generated by
> +instructing the linker to set the \s-1PE\s0 header subsystem type
> +appropriately.
>  .PP
>  See also under \fBi386 and x86\-64 Options\fR for standard options.
>  .PP
> diff -u -N -r gcc-core-4.4.1-old/gcc/doc/gcc.info
> gcc-core-4.4.1/gcc/doc/gcc.info
> --- gcc-core-4.4.1-old/gcc/doc/gcc.info   Wed Jul 22 17:33:04 2009
> +++ gcc-core-4.4.1/gcc/doc/gcc.info   Tue Oct  6 13:30:34 2009
> @@ -1056,7 +1056,7 @@
>       _x86-64 Options_ See i386 and x86-64 Options.
>=20
>       _i386 and x86-64 Windows Options_
> -          -mconsole -mcygwin -mno-cygwin -mdll
> +          -mconsole -mcygwin -mno-cygwin -mdll -municode
>            -mnop-fun-dllimport -mthread -mwin32 -mwindows
>=20
>       _Xstormy16 Options_
> @@ -14565,6 +14565,11 @@
>       specifies that a GUI application is to be generated by instructing
>       the linker to set the PE header subsystem type appropriately.
>=20
> +`-municode'
> +     This option is available for Cygwin and MinGW targets.  It
> +     specifies that a Unicode application is to be generated by=20
instructing
> +     the linker to set the PE header subsystem type appropriately.
> +
>   See also under *note i386 and x86-64 Options:: for standard options.
>=20
>  =1F
> diff -u -N -r gcc-core-4.4.1-old/gcc/doc/invoke.texi
> gcc-core-4.4.1/gcc/doc/invoke.texi
> --- gcc-core-4.4.1-old/gcc/doc/invoke.texi   Wed Apr  1 16:18:48 2009
> +++ gcc-core-4.4.1/gcc/doc/invoke.texi   Tue Oct  6 13:32:02 2009
> @@ -826,7 +826,7 @@
>  See i386 and x86-64 Options.
>=20
>  @emph{i386 and x86-64 Windows Options}
> -@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll
> +@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll -municode
>  -mnop-fun-dllimport -mthread -mwin32 -mwindows}
>=20
>  @emph{Xstormy16 Options}
> @@ -15533,6 +15533,13 @@
>  specifies that a GUI application is to be generated by
>  instructing the linker to set the PE header subsystem type
>  appropriately.
> +
> +@item -municode
> +@opindex municode
> +This option is available for Cygwin and MinGW targets.  It
> +specifies that a Unicode application is to be generated by
> +instructing the linker to set the PE header subsystem type
> +appropriately.
>  @end table
>=20
>  See also under @ref{i386 and x86-64 Options} for standard options.
>=20
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>=20

This feature would be nice for mingw.org and cygwin, but it is already=20
present on gcc. To reinvent the wheel makes less sense here IMHO. The=20
mingw-w64 supports -municode for gcc 4.5 for the triplet <cpu>-w64-mingw*=
=20
at the moment, as cygwin/mingw don't have unicode startup facility at the=
=20
moment.
And btw the patch here (especially the parts related to gcc) is here on=20
the wrong list. And also I would prefer for the gcc patch, that it uses=20
current implementation and names, instead of choosing here some new one.

Regards,
Kai Tietz


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019