コード例 #1
0
ファイル: message.c プロジェクト: Flowdeeps/tidy-html5
void tidy_out( TidyDocImpl* doc, ctmbstr msg, ... )
{
    if ( !cfgBool(doc, TidyQuiet) )
    {
        TidyOutputSink *outp = &doc->errout->sink;
        ctmbstr cp;
        enum { sizeBuf=2048 };
        char *buf = (char *)TidyDocAlloc(doc,sizeBuf);
        byte b;

        va_list args;
        va_start( args, msg );
        TY_(tmbvsnprintf)(buf, sizeBuf, msg, args);
        va_end( args );

        for ( cp=buf; *cp; ++cp )
        {
            b = (*cp & 0xff);
            if (b == (byte)'\n')
                TY_(WriteChar)( b, doc->errout ); /* for EOL translation */
            else
                outp->putByte( outp->sinkData, b ); /* #383 - no encoding */
        }

        TidyDocFree(doc, buf);
    }
}
コード例 #2
0
void Win32MLangPutChar(tchar c, StreamOut * out, uint * bytesWritten)
{
    IMLangConvertCharset * p;
    TidyOutputSink * sink;
    CHAR outbuf[TC_OUTBUFSIZE] = { 0 };
    UINT outbufsize = TC_OUTBUFSIZE;
    HRESULT hr = S_OK;
    WCHAR inbuf[2] = { 0 };
    UINT inbufsize = 0;
    uint i;

    assert( c != 0 );
    assert( c <= 0x10FFFF );
    assert( bytesWritten != NULL );
    assert( out != NULL );
    assert( &out->sink != NULL );
    assert( out->mlang != 0 );

    p = (IMLangConvertCharset *)out->mlang;
    sink = &out->sink;

    if (c > 0xFFFF)
    {
        tchar high = 0;
        tchar low = 0;

        SplitSurrogatePair(c, &low, &high);

        inbuf[inbufsize++] = (WCHAR)low;
        inbuf[inbufsize++] = (WCHAR)high;
    }
    else
        inbuf[inbufsize++] = (WCHAR)c;

    hr = IMLangConvertCharset_DoConversionFromUnicode(p, inbuf, &inbufsize, outbuf, &outbufsize);
    
    assert( hr == S_OK );
    assert( outbufsize > 0 );
    assert( inbufsize == 1 || inbufsize == 2 );

    for (i = 0; i < outbufsize; ++i)
        sink->putByte(sink->sinkData, (byte)(outbuf[i]));

    *bytesWritten = outbufsize;

    return;
}
コード例 #3
0
ファイル: message.c プロジェクト: Flowdeeps/tidy-html5
static void messagePos( TidyDocImpl* doc, TidyReportLevel level, uint code,
                        int line, int col, ctmbstr msg, va_list args )
{
    enum { sizeMessageBuf=2048 };
    char *messageBuf = TidyDocAlloc(doc,sizeMessageBuf);
    Bool go = UpdateCount( doc, level );

    if ( go )
    {
        va_list args_copy;
        va_copy(args_copy, args);
        TY_(tmbvsnprintf)(messageBuf, sizeMessageBuf, msg, args);
        if ( doc->mssgFilt )
        {
            TidyDoc tdoc = tidyImplToDoc( doc );
            go = doc->mssgFilt( tdoc, level, line, col, messageBuf );
        }
        if ( doc->mssgFilt2 )
        {
            /* mssgFilt2 is intended to allow LibTidy users to localize
               messages via their own means by providing a key string and
               the parameters to fill it. For the key string to remain
               consistent, we have to ensure that we only ever return the
               built-in English version of this string. */
            TidyDoc tdoc = tidyImplToDoc( doc );
            go = go | doc->mssgFilt2( tdoc, level, line, col, tidyDefaultString(code), args_copy );
        }
        if ( doc->mssgFilt3 )
        {
            /* mssgFilt3 is intended to allow LibTidy users to localize
               messages via their own means by providing a key string and
               the parameters to fill it. */
            TidyDoc tdoc = tidyImplToDoc( doc );
            go = go | doc->mssgFilt3( tdoc, level, line, col, tidyErrorCodeAsString(code), args_copy );
        }
    }

    if ( go )
    {
        enum { sizeBuf=1024 };
        TidyOutputSink *outp = &doc->errout->sink;
        char *buf = (char *)TidyDocAlloc(doc,sizeBuf);
        const char *cp;
        byte b;
        if ( line > 0 && col > 0 )
        {
            ReportPosition(doc, line, col, buf, sizeBuf);
            for ( cp = buf; *cp; ++cp )
            {
                b = (*cp & 0xff);
                outp->putByte( outp->sinkData, b );
            }
        }

        LevelPrefix( level, buf, sizeBuf );
        for ( cp = buf; *cp; ++cp )
        {
            b = (*cp & 0xff);
            outp->putByte( outp->sinkData, b );
        }
        for ( cp = messageBuf; *cp; ++cp )
        {
            b = (*cp & 0xff);
            outp->putByte( outp->sinkData, b );
        }
        TY_(WriteChar)( '\n', doc->errout );
        TidyDocFree(doc, buf);
    }
    TidyDocFree(doc, messageBuf);
}