Bug 165642

Summary: FileHandle::printf doesn't build on Windows
Product: WebKit Reporter: Keith Rollin <krollin>
Component: WebCore Misc.Assignee: Keith Rollin <krollin>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, darin
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Keith Rollin 2016-12-08 18:34:33 PST
vasprintf doesn't exist on Windows.
Comment 1 Keith Rollin 2016-12-08 18:36:30 PST
Created attachment 296609 [details]
Patch
Comment 2 WebKit Commit Bot 2016-12-08 19:10:30 PST
Comment on attachment 296609 [details]
Patch

Clearing flags on attachment: 296609

Committed r209593: <http://trac.webkit.org/changeset/209593>
Comment 3 WebKit Commit Bot 2016-12-08 19:10:34 PST
All reviewed patches have been landed.  Closing bug.
Comment 4 Darin Adler 2016-12-09 21:38:10 PST
Comment on attachment 296609 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=296609&action=review

> Source/WebCore/platform/FileHandle.cpp:105
> +    // TODO: implement this without relying on vasprintf.
> +    return false;

Looked up how to do it here <http://en.cppreference.com/w/cpp/io/c/vfprintf>:

    va_list args;
    va_start(args, format);

    va_list preflightArgs;
    va_copy(preflightArgs, args);
    Vector<char, 1024> buffer { 1 + std::vsnprintf(nullptr, 0, format, preflightArgs) };
    va_end(preflightArgs);

    std::vsnprintf(buffer.data(), buffer.size(), format, args);

    va_end(args);

    return write(buffer.data(), strlen(buffer.data()));
Comment 5 Darin Adler 2016-12-09 21:38:31 PST
That version should work fine on other platforms too.
Comment 6 Darin Adler 2016-12-10 18:16:18 PST
I put up a patch with the above code in bug 165740.