Bug 165642 - FileHandle::printf doesn't build on Windows
Summary: FileHandle::printf doesn't build on Windows
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Keith Rollin
Depends on:
Reported: 2016-12-08 18:34 PST by Keith Rollin
Modified: 2016-12-10 18:16 PST (History)
2 users (show)

See Also:

Patch (1.59 KB, patch)
2016-12-08 18:36 PST, Keith Rollin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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]
Comment 2 WebKit Commit Bot 2016-12-08 19:10:30 PST
Comment on attachment 296609 [details]

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]

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) };

    std::vsnprintf(buffer.data(), buffer.size(), format, 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.