Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dripping #963

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions console/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1836,13 +1836,13 @@ static void xml_strings( void )
*/
static Bool TIDY_CALL reportCallback(TidyMessage tmessage)
{
#if 0
#if 1
TidyIterator pos;
TidyMessageArgument arg;
TidyFormatParameterType messageType;
ctmbstr messageFormat;

printf("FILTER: %s, %s\n", tidyGetMessageKey( tmessage ), tidyGetMessageOutput( tmessage ));
printf("FILTER: %s:\n%s\n", tidyGetMessageKey( tmessage ), tidyGetMessageOutput( tmessage ));

/* loop through the arguments, if any, and print their details */
pos = tidyGetMessageArguments( tmessage );
Expand Down
71 changes: 68 additions & 3 deletions src/messageobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ struct printfArg {
static struct printfArg *BuildArgArray( TidyDocImpl *doc, ctmbstr fmt, va_list ap, int *rv );


/*********************************************************************
* Other Static functions
*********************************************************************/
static Bool paragraphizeText( tmbstr dest, size_t size, ctmbstr text );



/*********************************************************************
* Tidy Message Object Support
*********************************************************************/
Expand Down Expand Up @@ -106,9 +113,12 @@ static TidyMessageImpl *tidyMessageCreateInitV( TidyDocImpl *doc,

result->messageKey = TY_(tidyErrorCodeAsKey)(code);

result->messageFormatDefault = tidyDefaultString(code);
result->messageFormat = tidyLocalizedString(code);

result->messageFormatDefault = TidyDocAlloc(doc, sizeMessageBuf);
paragraphizeText( result->messageFormatDefault, sizeMessageBuf, tidyDefaultString(code));

result->messageFormat = TidyDocAlloc(doc, sizeMessageBuf);
paragraphizeText( result->messageFormat, sizeMessageBuf, tidyLocalizedString(code));

result->messageDefault = TidyDocAlloc(doc, sizeMessageBuf);
va_copy(args_copy, args);
TY_(tmbvsnprintf)(result->messageDefault, sizeMessageBuf, result->messageFormatDefault, args_copy);
Expand Down Expand Up @@ -250,6 +260,8 @@ void TY_(tidyMessageRelease)( TidyMessageImpl *message )
if ( !message )
return;
TidyDocFree( tidyDocToImpl(message->tidyDoc), message->arguments );
TidyDocFree( tidyDocToImpl(message->tidyDoc), message->messageFormatDefault );
TidyDocFree( tidyDocToImpl(message->tidyDoc), message->messageFormat );
TidyDocFree( tidyDocToImpl(message->tidyDoc), message->messageDefault );
TidyDocFree( tidyDocToImpl(message->tidyDoc), message->message );
TidyDocFree( tidyDocToImpl(message->tidyDoc), message->messagePosDefault );
Expand Down Expand Up @@ -628,3 +640,56 @@ static struct printfArg* BuildArgArray( TidyDocImpl *doc, ctmbstr fmt, va_list a
return nas;
}


/*********************************************************************
* Other Static functions
*********************************************************************/

/** Filles a provided buffer with with proper paragraph text from the source text.
** For some reason Tidy refuses to work with paragraphs and instead believes that
** 80 characters is good enough for everyone in the world regardless of modern
** monitor sizes, *and* it implements a private API for formatting. This function
** will respect Tidy's private API and turn dialogue output text back into
** paragraphs.
**
** The internal, private API seems to be such:
*/
static Bool paragraphizeText( tmbstr dest, size_t size, ctmbstr text )
{
const char* p = text;
char c;
uint ix = 0;

while( ( c = *p++ ) != 0 )
{
if ( c == '\n' && ( c = *p++ ) == '\n' )
{
dest[ix] = '\n';
ix++;
continue;
}

dest[ix] = c;
ix++;
}

dest[ix] = '\0';

return yes;


// {
// if( c != '%' )
// continue;
//
// if( ( c = *p++ ) == '%' ) /* skip %% case */
// continue;
// else
// number++;
// }

}




4 changes: 2 additions & 2 deletions src/tidy-int.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ struct _TidyMessageImpl

ctmbstr messageKey; /* the message code as a key string */

ctmbstr messageFormatDefault; /* the built-in format string */
ctmbstr messageFormat; /* the localized format string */
tmbstr messageFormatDefault; /* the built-in format string */
tmbstr messageFormat; /* the localized format string */

tmbstr messageDefault; /* the message, formatted, default language */
tmbstr message; /* the message, formatted, localized */
Expand Down