delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2017/07/23/07:01:59

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Message-ID: <597482DE.2010800@gmx.de>
Date: Sun, 23 Jul 2017 13:05:02 +0200
From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: DJGPP doesn't support std::wstring?
References: <CANbeq3zwqk7eSiR1f+2tgdiztpC_B=HQN42WPwt+sgtbQUcz2g AT mail DOT gmail DOT com> <59728009 DOT 7010801 AT gmx DOT de> <5ba63d08-999c-db29-3e59-5feca8f71c38 AT iki DOT fi>
In-Reply-To: <5ba63d08-999c-db29-3e59-5feca8f71c38@iki.fi>
X-Provags-ID: V03:K0:ISG8VYWNLbPIhG13W0Kb1VGd6/vPnKWA7VI6QIGieNg0dmvx4KA
pAn7OFTDBWePU/j7A6zZuTRaQeKon1unio3Fb7OnVGm41b+6NipHBq9VxbzxCrz0axfO7gV
cKZjsGsARpHTYpONPi2wulyXBS2uHUyHI3pi9XoId+iv4NLAhe4s9dw0WPWcj+NGzDY2Qes
Md6PKi/7sOOR8NMG2BMeQ==
X-UI-Out-Filterresults: notjunk:1;V01:K0:ZrQJyBQT6Zg=:J1dZsA4APmY4NdvYm3rsRx
xOAwwCIJsP0Vv3QiwN7AYLbCulPmPPcsNR87nNuFmN7+ky2fGTh+9hxc7PThcC9pzo5qu8LJr
SyGoF4GiOyBNyWr8btvgTLYwFa++t1cdesljI8DWvfP0XfrrNhDm2wIrbH2H3EPMSyGyZHqgn
zMK8z4KV1mk4i1px8Rh0LUFtvo9Y5Cqxr92emdSN0v7jxcF1ij7HuWv9JXBiSlgLkHWDJR8o3
5tlnAqBzte9KmQgr7Tf3+/TsIKHIBx+DTaQ2N5QE5PZJBxCD2TF4vSgUprGUagS3zES75iq47
y4zorbbLss5pg8PuGgwhMtJqhRgQX0r03d5vljF0rebzAxZznJzBSHcxYHcfIQ0130Dby8bqn
5YixTf4L3BuWjomd5tFiSmCOkfY6olEdG4MWisf70cKAB0ism3SkKFJ59qQRpsKNu0txRDCBX
mIfXqNHJLPfRSglEM3y6prw1ba7MUkeV7Jas6p3dNCr+NyxqB3yA9pprAqxnZSRi8DDYA3Hwj
eN9tI5XOfMMfRE9FBWsI7qxSHcXCCLw2uIZ1I1zWj9gotRpbMpOKWXvE17mXlYVQtCVcl1NJd
pSP7PQhBQzzfgkvUEZqfBxD86cppMlqhfB83eMvAW3vRitX0gp9Xx31claoAA2BIEPT34AA5/
ftO0HbGFCsDelYhLrIf8fUVE21fTmockgRnWKyf3IKElUjZKt5oEJ7rE6MlGg4KguKn4EJS48
vR57LZ7cGlRjz1ym9s8QnDH+pYSxkcnB2KvZBYvlcTTJl2tin1GrH2dMd+0LR7MC9owwN32SM
rjqV/+Mp522CtOHyNd+q7Yk34MO7ue0Nfd5bSd+dmUK/5vMaZ4=
Reply-To: djgpp AT delorie DOT com

Am 22.07.2017 18:16, schrieb Andris Pavenis (andris DOT pavenis AT iki DOT fi) [via djgpp AT delorie DOT com]:
> On 07/22/2017 01:28 AM, Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com] wrote:
>> Am 21.07.2017 14:56, schrieb Andrew Wu (andrewwu DOT tw AT gmail DOT com) [via djgpp AT delorie DOT com]:
>> [snip]
>>>
>>> Any method to support wstring in DJGPP?
>> [snip]
>>
>> No, if no one implements this stuff from scratch.
>> DJGPP 2.05 with gcc 7.1.0 has never supported neither wide characters nor multi byte strings.
>> This is also true for any previous version of DJGPP no matter what gcc version has been used.
>> It is very unlikely that some developer will volunteer to implement this stuff for DJGPP.
>> In the very best case you will have to find some auxiliar library that provides the missing
>> functionality. But I doubt that that will solve all issues.
>>
>> Regards,
>> Juan M. Guerrero
>>
> There was actually implementation of wide character support almost 20 years ago. Some of mails at DJGPP workers (not all of them) are
>
> http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp-workers/1998/09/10/18:45:06
>
> http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp-workers/1998/09/15/09:53:11
>
> http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp-workers/1998/09/11/13:02:03
>
> Original URL from last of these mails do not respond now and it did no more contain the files when I looked last time long ago as far as I remember.
>
> The problem is that that nobody took the work of actually integrating these additions in DJGPP libc then. Good news is that I still have these files laying around
>
> http://ap1.pp.fi/djgpp/misc/
>
> I raised this topic before releasing DJGPP v2.05. It was then decided to postpone it.
>
> Andris
>


Some remarks about the code:

1) All file names shall be renamed to lower case before they are added
    to the repository.
2) All files shall have unix EOL before they are added to the repository.
    Currently they have DOS EOL.
3) The stuff of ./DJTYPES.H has already been added /djgpp/include/sys/djtypes.h
    and ./LIMITS.H is superfluous.  It has nothing at all that needs to be
    added to /djgpp/include/limits.h from at all ./LIMITS.H.
4) The typedef of wctrans_t differ.  According to the glibc header it must be
    an int pointer but ./INCLUDE/WCTYPE.H typdefs it as int.
    The typedef of wctype_t differ.  The one from ./INCLUDE/WCTYPE.H seems to
    be the right one.  For some reason I have not figured out /djgpp/include/wtype.h
    typedefs it as unsigned short.
5) The second argument of wcsrchr must be wchar_t and not int as it is.
    This function has been fixed.  See patch and
    http://pubs.opengroup.org/onlinepubs/009695399/functions/wcsrchr.html
6) The third and last argument of wcstok is missing.  I assume that the
    definition of this function has changed since it has been implemented
    by the author.  This function has been fixed.  See patch and
    http://pubs.opengroup.org/onlinepubs/009695399/functions/wcstok.html
7) At least a minimal testsuite must be implemented for this set of functions.
8) I have inspected the files and compiled them with gcc346, gcc494, gcc540,
    gcc640 and gcc710.  The patch below shows the adjustments that were
    necessary to get this 20 year old code compiled.  The code itself seems ok
    to me because all wide char functions are identical to their char counterparts.
    Only the character type has been replaced by wide character thus if the char
    versions were ok then the wide char versions should also be ok.  Also the
    txh files are 20 years old and need to be fixed due to errors and adjusted
    accordingly.  The patch is based on wchar.zip and not on the repository code.
9) It shall be noted that the implemented functions are only a very small part
    of all functions defined in wchar.h  Here a lot of more work needs to be
    done before it can be claimed that DJGPP supports wide char/multi-byte strings.

Regards,
Juan M. Guerrero





diff -aprNU5 wchar.orig/include/wchar.h wchar/include/wchar.h
--- wchar.orig/include/wchar.h	1998-09-10 16:52:28 +0000
+++ wchar/include/wchar.h	2017-07-23 03:34:10 +0000
@@ -36,14 +36,14 @@ size_t	wcscspn(const wchar_t *_s1, const
  size_t	wcslen(const wchar_t *_s);
  wchar_t * wcsncat(wchar_t *_s1, const wchar_t *_s2, size_t _n);
  int wcsncmp(const wchar_t *_s1, const wchar_t *_s2, size_t _n);
  wchar_t *  wcsncpy(wchar_t *_s1, const wchar_t *_s2, size_t _n);
  wchar_t *  wcspbrk(const wchar_t *_s1, const wchar_t *_s2);
-wchar_t *  wcsrchr(const wchar_t *_s, int _c);
+wchar_t *  wcsrchr(const wchar_t *_s, wchar_t _c);
  size_t	wcsspn(const wchar_t *_s1, const wchar_t *_s2);
  wchar_t * wcsstr(const wchar_t *_s1, const wchar_t *_s2);
-wchar_t * wcstok(wchar_t *_s1, const wchar_t *_s2);
+wchar_t * wcstok(wchar_t *_s1, const wchar_t *_s2, wchar_t **last);
  size_t wcsxfrm(wchar_t *_s1, const wchar_t *_s2, size_t _n);

  #ifdef __cplusplus
  }
  #endif
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/makefile wchar/src/libc/ansi/wchar/makefile
--- wchar.orig/src/libc/ansi/wchar/makefile	1970-01-01 00:00:00 +0000
+++ wchar/src/libc/ansi/wchar/makefile	2017-07-23 02:33:22 +0000
@@ -0,0 +1,47 @@
+# Copyright (C) 2017 DJ Delorie, see COPYING.DJ for details
+TOP=../..
+
+SRC += wcscat.c
+SRC += wcscat.txh
+SRC += wcschr.c
+SRC += wcschr.txh
+SRC += wcscmp.c
+SRC += wcscmp.txh
+SRC += wcscoll.c
+SRC += wcscoll.txh
+SRC += wcscpy.c
+SRC += wcscpy.txh
+SRC += wcscspn.c
+SRC += wcscspn.txh
+SRC += wcslen.c
+SRC += wcslen.txh
+SRC += wcsncat.c
+SRC += wcsncat.txh
+SRC += wcsncmp.c
+SRC += wcsncmp.txh
+SRC += wcsncpy.c
+SRC += wcsncpy.txh
+SRC += wcspbrk.c
+SRC += wcspbrk.txh
+SRC += wcsrchr.c
+SRC += wcsrchr.txh
+SRC += wcsspn.c
+SRC += wcsspn.txh
+SRC += wcsstr.c
+SRC += wcsstr.txh
+SRC += wcstok.c
+SRC += wcstok.txh
+SRC += wcsxfrm.c
+SRC += wcsxfrm.txh
+SRC += wmemchr.c
+SRC += wmemchr.txh
+SRC += wmemcmp.c
+SRC += wmemcmp.txh
+SRC += wmemcpy.c
+SRC += wmemcpy.txh
+SRC += wmemmove.c
+SRC += wmemmove.txh
+SRC += wmemset.c
+SRC += wmemset.txh
+
+include $(TOP)/../makefile.inc
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcscat.txh wchar/src/libc/ansi/wchar/wcscat.txh
--- wchar.orig/src/libc/ansi/wchar/wcscat.txh	1998-09-11 08:54:34 +0000
+++ wchar/src/libc/ansi/wchar/wcscat.txh	2017-07-23 04:38:12 +0000
@@ -2,21 +2,25 @@
  @subheading Syntax

  @example
  #include <wchar.h>

-wchar_t *strcat(wchar_t *s1, const wchar_t *s2);
+wchar_t *wcscat(wchar_t *s1, const wchar_t *s2);
  @end example

  @subheading Description

  This function concatenates @var{s2} to the end of @var{s1}.

  @subheading Return Value

  @var{s1}

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  wchar_t buf[100] = L"hello";
  wcscat(buf, L" there");
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcschr.txh wchar/src/libc/ansi/wchar/wcschr.txh
--- wchar.orig/src/libc/ansi/wchar/wcschr.txh	1998-09-11 08:59:18 +0000
+++ wchar/src/libc/ansi/wchar/wcschr.txh	2017-07-23 04:38:08 +0000
@@ -15,10 +15,14 @@ pointer to the end of the wide string.

  @subheading Return Value

  A pointer to the wide character, or @code{NULL} if it wasn't found.

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  wchar_t *tag_start = wcschr(document, L'<');
  @end example
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcscmp.txh wchar/src/libc/ansi/wchar/wcscmp.txh
--- wchar.orig/src/libc/ansi/wchar/wcscmp.txh	1998-09-11 09:02:46 +0000
+++ wchar/src/libc/ansi/wchar/wcscmp.txh	2017-07-23 04:38:04 +0000
@@ -14,10 +14,14 @@ This function compares @var{s1} and @var
  @subheading Return Value

  Zero if the wide strings are equal, a positive number if @var{s1} comes after
  @var{s2} in the collating sequense, else a negative number.

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  if (wcscmp(arg, L"-i") == 0)
    do_include();
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcscoll.txh wchar/src/libc/ansi/wchar/wcscoll.txh
--- wchar.orig/src/libc/ansi/wchar/wcscoll.txh	1998-09-11 09:02:32 +0000
+++ wchar/src/libc/ansi/wchar/wcscoll.txh	2017-07-23 04:38:02 +0000
@@ -15,10 +15,14 @@ sequences from the current locale.
  @subheading Return Value

  Zero if the wide strings are equal, a positive number if @var{s1} comes after
  @var{s2} in the collating sequense, else a negative number.

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  while (wcscoll(var, list[i]) < 0)
    i++;
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcscpy.txh wchar/src/libc/ansi/wchar/wcscpy.txh
--- wchar.orig/src/libc/ansi/wchar/wcscpy.txh	1998-09-11 09:03:42 +0000
+++ wchar/src/libc/ansi/wchar/wcscpy.txh	2017-07-23 04:37:58 +0000
@@ -2,21 +2,25 @@
  @subheading Syntax

  @example
  #include <wchar.h>

-wchar_t *strcpy(wchar_t *s1, const wchar_t *s2);
+wchar_t *wcscpy(wchar_t *s1, const wchar_t *s2);
  @end example

  @subheading Description

  This function copies @var{s2} into @var{s1}.

  @subheading Return Value

  @var{s1}

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  wchar_t buf[100];
  wcscpy(buf, arg);
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcscspn.txh wchar/src/libc/ansi/wchar/wcscspn.txh
--- wchar.orig/src/libc/ansi/wchar/wcscspn.txh	1998-09-11 09:04:58 +0000
+++ wchar/src/libc/ansi/wchar/wcscspn.txh	2017-07-23 04:50:28 +0000
@@ -18,10 +18,14 @@ wide string if nothing else.

  The index of the found character.

  @subheading Example

+@subheading Portability
+
+@portability ansi, posix
+
  @example
  int i = wcscspn(command, "<>|");
  if (command[i])
    do_redirection();
  @end example
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcslen.txh wchar/src/libc/ansi/wchar/wcslen.txh
--- wchar.orig/src/libc/ansi/wchar/wcslen.txh	1998-09-11 00:10:30 +0000
+++ wchar/src/libc/ansi/wchar/wcslen.txh	2017-07-23 04:50:32 +0000
@@ -13,10 +13,14 @@ This function returns the number of wide

  @subheading Return Value

  The length of the wide string.

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  if (wcslen(buffer) <= BUFFER_MAX)
    copy_buffer(buffer);
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcsncat.txh wchar/src/libc/ansi/wchar/wcsncat.txh
--- wchar.orig/src/libc/ansi/wchar/wcsncat.txh	1998-09-11 00:08:02 +0000
+++ wchar/src/libc/ansi/wchar/wcsncat.txh	2017-07-23 04:50:34 +0000
@@ -14,10 +14,14 @@ end of @var{s1}.

  @subheading Return Value

  @var{s1}

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  wcsncat(fname, extension, 4);
  @end example
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcsncmp.txh wchar/src/libc/ansi/wchar/wcsncmp.txh
--- wchar.orig/src/libc/ansi/wchar/wcsncmp.txh	1998-09-11 00:06:54 +0000
+++ wchar/src/libc/ansi/wchar/wcsncmp.txh	2017-07-23 04:50:38 +0000
@@ -14,10 +14,14 @@ This function compares up to @var{max} w
  @subheading Return Value

  Zero if the wide strings are equal, a positive number if @var{s1} comes after
  @var{s2} in the ASCII collating sequense, else a negative number.

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  if (wcsncmp(arg, "-i", 2) == 0)
    do_include();
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcsncpy.txh wchar/src/libc/ansi/wchar/wcsncpy.txh
--- wchar.orig/src/libc/ansi/wchar/wcsncpy.txh	1998-09-11 00:05:22 +0000
+++ wchar/src/libc/ansi/wchar/wcsncpy.txh	2017-07-23 04:51:08 +0000
@@ -13,10 +13,14 @@ This function copies up to @var{max} cha

  @subheading Return Value

  @var{s1}

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  wchar_t buf[100];
  wcsncpy(buf, arg, 99);
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcspbrk.txh wchar/src/libc/ansi/wchar/wcspbrk.txh
--- wchar.orig/src/libc/ansi/wchar/wcspbrk.txh	1998-09-11 00:04:12 +0000
+++ wchar/src/libc/ansi/wchar/wcspbrk.txh	2017-07-23 12:37:24 +0000
@@ -14,10 +14,14 @@ wide character in @var{set}.

  @subheading Return Value

  A pointer to the first match, or @code{NULL} if none are found.

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  if (wcspbrk(command, L"<>|"))
    do_redirection();
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcsrchr.c wchar/src/libc/ansi/wchar/wcsrchr.c
--- wchar.orig/src/libc/ansi/wchar/wcsrchr.c	1998-09-09 20:36:34 +0000
+++ wchar/src/libc/ansi/wchar/wcsrchr.c	2017-07-23 02:24:42 +0000
@@ -2,20 +2,19 @@

  #include <wchar.h>
  #include <libc/unconst.h>

  wchar_t *
-wcsrchr(const wchar_t *s, int c)
+wcsrchr(const wchar_t *s, wchar_t c)
  {
-  wchar_t cc = c;
-  const wchar_t *sp=(wchar_t *)0;
+  const wchar_t *sp = (wchar_t *)0;
    while (*s)
    {
-    if (*s == cc)
+    if (*s == c)
        sp = s;
      s++;
    }
-  if (cc == 0)
+  if (c == 0)
      sp = s;
    return unconst(sp, wchar_t *);
  }

diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcsrchr.txh wchar/src/libc/ansi/wchar/wcsrchr.txh
--- wchar.orig/src/libc/ansi/wchar/wcsrchr.txh	1998-09-13 11:10:24 +0000
+++ wchar/src/libc/ansi/wchar/wcsrchr.txh	2017-07-23 12:37:36 +0000
@@ -14,10 +14,14 @@ This function finds the last occurrence
  @subheading Return Value

  A pointer to the last match, or @code{NULL} if the wide character isn't in
  the wide string.

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  wchar_t *last_slash = wcschr(filename, L'/');
  @end example
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcsspn.txh wchar/src/libc/ansi/wchar/wcsspn.txh
--- wchar.orig/src/libc/ansi/wchar/wcsspn.txh	1998-09-11 00:01:36 +0000
+++ wchar/src/libc/ansi/wchar/wcsspn.txh	2017-07-23 12:38:18 +0000
@@ -16,10 +16,14 @@ wide string if nothing else.

  @subheading Return Value

  The index of the found character.

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  int i = wcsspn(entry, L" \t\b");
  if (entry[i])
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcsstr.txh wchar/src/libc/ansi/wchar/wcsstr.txh
--- wchar.orig/src/libc/ansi/wchar/wcsstr.txh	1998-09-10 23:59:56 +0000
+++ wchar/src/libc/ansi/wchar/wcsstr.txh	2017-07-23 12:38:38 +0000
@@ -13,10 +13,14 @@ This function finds the first occurrence

  @subheading Return Value

  A pointer within @var{s1}, or @code{NULL} if @var{s2} wasn't found.

+@subheading Portability
+
+@portability ansi, posix
+
  @subheading Example

  @example
  if (wcsstr(command, L".exe"))
    do_exe();
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcstok.c wchar/src/libc/ansi/wchar/wcstok.c
--- wchar.orig/src/libc/ansi/wchar/wcstok.c	1998-09-09 20:37:38 +0000
+++ wchar/src/libc/ansi/wchar/wcstok.c	2017-07-23 03:56:54 +0000
@@ -1,18 +1,16 @@
  /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
  #include <wchar.h>

  wchar_t *
-wcstok(wchar_t *s, const wchar_t *delim)
+wcstok(wchar_t *s, const wchar_t *delim, wchar_t **last)
  {
    const wchar_t *spanp;
    int c, sc;
    wchar_t *tok;
-  static wchar_t *last;

-
-  if (s == NULL && (s = last) == NULL)
+  if (s == NULL && (s = *last) == NULL)
      return (NULL);

    /*
     * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
     */
@@ -40,11 +38,11 @@ wcstok(wchar_t *s, const wchar_t *delim)
        if ((sc = *spanp++) == c) {
  	if (c == 0)
  	  s = NULL;
  	else
  	  s[-1] = 0;
-	last = s;
+	*last = s;
  	return (tok);
        }
      } while (sc != 0);
    }
    /* NOTREACHED */
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcstok.txh wchar/src/libc/ansi/wchar/wcstok.txh
--- wchar.orig/src/libc/ansi/wchar/wcstok.txh	1998-09-11 00:18:48 +0000
+++ wchar/src/libc/ansi/wchar/wcstok.txh	2017-07-23 03:39:56 +0000
@@ -2,39 +2,49 @@
  @subheading Syntax

  @example
  #include <wchar.h>

-char *wcstok(wchar_t *s1, const wchar_t *s2);
+char *wcstok(wchar_t *s1, const wchar_t *s2, char **s3);
  @end example

  @subheading Description

  This function retrieves tokens from @var{s1} which are delimited by
-wide characters from @var{s2}.
+characters from @var{s2}.  It uses @var{s3} to track how far in
+@var{s1} the search has progressed.

  To initiate the search, pass the string to be searched as @var{s1}.  For
-the remaining tokens, pass @code{NULL} instead.
+the remaining tokens, pass @code{NULL} instead.

  @subheading Return Value

  A pointer to the token, or @code{NULL} if no more are found.

+@subheading Portability
+
+@portability posix
+
  @subheading Example

  @example
+#include <stdio.h>
+#include <wchar.h>
+
  main()
  @{
    wchar_t *buf = L"Hello there, stranger";
-  wchar_t *tok;
+  wchar_t *tok, *where;
    size_t word_count = 0;
-  for (tok = wcstok(buf, L" ");
+  for (tok = wcstok(buf, L" ,", &where);
         tok;
-       tok=wcstok(0, L" "))
-    ++word_count;
+       tok=wcstok(NULL, L" ,", &where))
+    printf("tok = `%s'\n", tok);

-  ++word_count;
+  return 0;
  @}

-word_count = 3
+tok = `Hello'
+tok = `there'
+tok = `stranger'
  @end example

diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wcsxfrm.txh wchar/src/libc/ansi/wchar/wcsxfrm.txh
--- wchar.orig/src/libc/ansi/wchar/wcsxfrm.txh	1998-09-10 23:55:38 +0000
+++ wchar/src/libc/ansi/wchar/wcsxfrm.txh	2017-07-23 12:38:50 +0000
@@ -16,6 +16,11 @@ the locale such that @code{wcscmp(s1b, s
  transforms of @code{s1} and @code{s2}.

  @subheading Return Value

  The actual number of bytes required to transform @var{s2}, including the
-@code{NULL}.
+@code{NULL}.
+
+@subheading Portability
+
+@portability ansi, posix
+
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wmemcmp.c wchar/src/libc/ansi/wchar/wmemcmp.c
--- wchar.orig/src/libc/ansi/wchar/wmemcmp.c	1998-09-09 20:51:50 +0000
+++ wchar/src/libc/ansi/wchar/wmemcmp.c	2017-07-23 02:33:22 +0000
@@ -1,7 +1,9 @@
+/* Copyright (C) 2017 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
  #include <wchar.h>
+#include <string.h>

  int
  wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n)
  {
    return memcmp(s1, s2, n * sizeof(wchar_t));
diff -aprNU5 wchar.orig/src/libc/ansi/wchar/wmemset.c wchar/src/libc/ansi/wchar/wmemset.c
--- wchar.orig/src/libc/ansi/wchar/wmemset.c	1998-09-11 10:01:16 +0000
+++ wchar/src/libc/ansi/wchar/wmemset.c	2017-07-23 02:29:42 +0000
@@ -5,11 +5,11 @@
  wchar_t *
  wmemset(wchar_t *_str, wchar_t c, size_t n)
  {
  /* Since wchar_t is a long, there isn't much to be gained with assembly */
  /* like this function's parallel memset, except with some loop unrolling */
-  int i;
-  for (i=0; i<n; ++_str, ++i)
+  size_t i;
+  for (i = 0; i < n; ++_str, ++i)
        *_str = c;

    return _str;
  }

- Raw text -


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