Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Greg Chicares <chicares-j9pdmedNgrk <at> public.gmane.org>
Subject: Re: vsnprintf, strange behavior (new mingw runtime?)
Newsgroups: gmane.comp.gnu.mingw.user
Date: Wednesday 5th September 2007 11:12:22 UTC (over 10 years ago)
I confirm that "%ld" isn't behaving as I'd expect....

On 2007-09-05 02:36Z, David Daeschler wrote:
> 
> Again, the file (this time with line information)

The line numbers seem slightly different in HEAD:

http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/winsup/mingw/mingwex/gdtoa/mingw_snprintf.c?annotate=1.2&cvsroot=src

> mingwex/gdtoa/mingw_snprintf.c: 
> function: x_sprintf
> line: 453
> 
>                         case 'l':
>                                 if (fmt[0] == 'l')
>                                   {
>                                     fmt++;
>                                     len = LEN_LL;
>                                   }
>                                 else
>                                   len = LEN_LL;

Your suggestion to change the last line this way

-                                   len = LEN_LL;
+                                   len = LEN_L;

looks correct to me.

Since we're inspecting the "l" versus "ll" code, I thought I'd
take a look at "h" versus "hh" as well, and I think there's a
problem there:

/tmp[0]$cat mingw-snprintf-test-hhn.cpp
#include 
#include 
#include  // snprintf()

int main()
{
    char buf[1000];

    signed char sc0 = 55;
    signed char sc1 = 66;
    signed char sc2 = 77;

    // This should modify only the second of the three variables.
    int len = snprintf(buf, 20, "%d%hhn", 11, &sc1);

    std::cout << "%d output:  '" << buf      <<  "' ('11' is expected)\n";
    std::cout << "%hhn output: " << (int)sc1 << "   (2 is expected)\n";
    std::cout << "guard 0:     " << (int)sc0 <<  "  (55 is expected)\n";
    std::cout << "guard 2:     " << (int)sc2 <<  "  (77 is expected)\n";
    std::cout << "len:         " << len      << "   (2 is expected)\n";

    std::cout << std::endl;
}

/tmp[0]$g++ -mno-cygwin -ggdb mingw-snprintf-test-hhn.cpp
/tmp[0]$./a
%d output:  '11' ('11' is expected)
%hhn output: 2   (2 is expected)
guard 0:     0  (55 is expected)
guard 2:     77  (77 is expected)
len:         2   (2 is expected)

As I interpret 7.19.6.1/8, that's writing a byte that it
shouldn't be touching.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
MinGW-users mailing list
[email protected]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
 
CD: 3ms