Send MinGW-Notify mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.osdn.me/mailman/listinfo/mingw-notify
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of MinGW-Notify digest..."


Please do not reply to this notification; the sender address is unable to 
accept incoming e-mail.  If you wish to unsubscribe you can do so at 
https://lists.osdn.me/mailman/listinfo/mingw-notify.



Today's Topics:

   1. [mingw] #39687: wcsrtombs with NULL dest pointer doesn't
      ignore len parameter (MinGW Notification List)


----------------------------------------------------------------------

Message: 1
Date: Mon, 04 Nov 2019 22:34:50 +0000
From: MinGW Notification List <[email protected]>
To: OSDN Ticket System <[email protected]>
Subject: [MinGW-Notify] [mingw] #39687: wcsrtombs with NULL dest
        pointer doesn't ignore len parameter
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8

#39687: wcsrtombs with NULL dest pointer doesn't ignore len parameter



  Open Date: 2019-10-19 17:38
Last Update: 2019-11-04 22:34

URL for this Ticket:
    https://osdn.net//projects/mingw/ticket/39687
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=39687

---------------------------------------------------------------------

Last Changes/Comment on this Ticket:
2019-11-04 22:34 Updated by: keith

Comment:

Unfortunately, converting a wchar_t representation of an SBCS string (such as
L"Hello") doesn't really exercise the code effectively. Thus, I modified your
original test case, to:

 1.  #include <iostream>
 2.  #include <vector>
 3.  #include <string>
 4.  #include <cstring>
 5.  #include <cwchar>
 6.  #include <clocale>
 7.  #include <cerrno>
 8.  
 9.  void print_wide(const wchar_t* wstr)
10.  { std::mbstate_t state = std::mbstate_t();
11.    std::size_t len = 1 + std::wcsrtombs(nullptr, &wstr, 0, &state);
12.    if( len > 0 )
13.    { std::vector<char> mbstr(len);
14.      std::wcsrtombs(&mbstr[0], &wstr, mbstr.size(), &state);
15.      std::cout << "Multibyte string: " << &mbstr[0] << '\n'
16.        << "Length, including '\\0': " << mbstr.size() << '\n';
17.    }
18.    else
19.    { std::cerr << "Verified input length: " << len << "; "
20.        << std::strerror(errno) << '\n';
21.    }
22.  }
23.   
24.  int main()
25.  { const char *lang = std::getenv("LC_CTYPE");
26.    std::setlocale(LC_CTYPE, (lang == nullptr) ? "" : lang );
27.    std::cerr << "Locale: " << std::setlocale(LC_CTYPE, NULL) << '\n';
28.    const wchar_t* wstr = L"A wstring-\u00df\u6c34\U0001d10b"; // or L"A 
wstring-ß水𝄋"
29.    print_wide(wstr);
30.  }

When I compile this, and run it on my GNU/Linux host, I see:

$ g++ tc39687.cc
]$ ./a.out
Locale: en_GB.utf8
Multibyte string: A wstring-ß水𝄋
Length, including '\0': 20

I shall attempt to reproduce this, with a modified MinGW implementation of
wcsrtombs() and related functions.



---------------------------------------------------------------------
Ticket Status:

      Reporter: gallickgunner
         Owner: keith
          Type: Issues
        Status: Open [Owner assigned]
      Priority: 5 - Medium
     MileStone: (None)
     Component: WSL
      Severity: 5 - Medium
    Resolution: None
---------------------------------------------------------------------

Ticket details:

I'm using MinGW-gcc-6.3.0. The wcsrtombs() function as mentioned in the docs on
cppreference should return the number of bytes that would have been written to
src. However it doesn't do so on my end. It seems the implementation doesn't
ignore the length parameter when dest is passed as NULL? A similar issue was
reported and presumably fixed for the Mingw-w64 on the sourceforge site
Currently working around by passing INT_MAX as the length parameter, so it
finishes within the limit and returns the size.

I apologize in advance if this is just an issue from my end or if any other
info is missing. First time submitting a ticket :)



-- 
Ticket information of MinGW - Minimalist GNU for Windows project
MinGW - Minimalist GNU for Windows Project is hosted on OSDN

Project URL: https://osdn.net/projects/mingw/
OSDN: https://osdn.net

URL for this Ticket:
    https://osdn.net/projects/mingw/ticket/39687
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=39687


------------------------------

Subject: Digest Footer

_______________________________________________
MinGW-Notify mailing list
[email protected]
https://lists.osdn.me/mailman/listinfo/mingw-notify


------------------------------

End of MinGW-Notify Digest, Vol 26, Issue 2
*******************************************

Reply via email to