Merge pull request #695 from htacg/issue-679

Issue 679
This commit is contained in:
Geoff McLane 2018-04-13 15:25:32 +02:00 committed by GitHub
commit e10c29bde8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 93 additions and 6 deletions

View file

@ -1445,6 +1445,24 @@ static void printOptionValues(TidyDoc ARG_UNUSED(tdoc), /**< The Tidy document.
}
}
break;
case TidyPriorityAttributes: /* Is #697 - This case seems missing */
{
TidyIterator itAttr = tidyOptGetPriorityAttrList(tdoc);
if (itAttr && (itAttr != (TidyIterator)-1))
{
while (itAttr)
{
d->def = tidyOptGetNextPriorityAttr(tdoc, &itAttr);
if (itAttr)
{
printf(fmt, d->name, d->type, d->def);
d->name = "";
d->type = "";
}
}
}
}
break;
default:
break;
}
@ -1484,6 +1502,33 @@ static void optionvalues( TidyDoc tdoc )
** @{
*/
/* Is #697 - specialised service to 'invert' a buffers content
split on a space character */
static void invertBuffer(TidyBuffer *src, TidyBuffer *dst)
{
uint len = src->size;
char *in = (char *)src->bp;
char *cp;
if (!in)
return;
while (len)
{
unsigned char uc;
len--;
uc = in[len];
if (uc == ' ')
{
in[len] = 0;
cp = &in[len + 1];
if (dst->size)
tidyBufAppend(dst, " ", 1);
tidyBufAppend(dst, cp, strlen(cp));
}
}
if (dst->size)
tidyBufAppend(dst, " ", 1);
tidyBufAppend(dst, in, strlen(in));
}
/** Prints the option value for a given option.
*/
@ -1493,6 +1538,7 @@ static void printOptionExportValues(TidyDoc ARG_UNUSED(tdoc), /**< The Tidy doc
)
{
TidyOptionId optId = tidyOptGetId( topt );
TidyBuffer buf1, buf2;
if ( tidyOptGetCategory(topt) == TidyInternalCategory )
return;
@ -1505,16 +1551,54 @@ static void printOptionExportValues(TidyDoc ARG_UNUSED(tdoc), /**< The Tidy doc
case TidyPreTags:
{
TidyIterator pos = tidyOptGetDeclTagList( tdoc );
while ( pos )
if ( pos ) /* Is #697 - one or more values */
{
tidyBufInit(&buf1);
tidyBufInit(&buf2);
while (pos)
{
d->def = tidyOptGetNextDeclTag(tdoc, optId, &pos);
if ( pos )
if (d->def)
{
printf( "%s: %s\n", d->name, d->def );
if (buf1.size)
tidyBufAppend(&buf1, " ", 1);
tidyBufAppend(&buf1, d->def, strlen(d->def));
}
}
invertBuffer(&buf1, &buf2); /* Is #697 - specialised service to invert words */
tidyBufAppend(&buf2, (void *)"\0", 1); /* is this really required? */
printf("%s: %s\n", d->name, buf2.bp);
d->name = "";
d->type = "";
d->def = 0;
tidyBufFree(&buf1);
tidyBufFree(&buf2);
}
}
break;
case TidyPriorityAttributes: /* Is #697 - This case seems missing */
{
TidyIterator itAttr = tidyOptGetPriorityAttrList(tdoc);
if (itAttr && (itAttr != (TidyIterator)-1))
{
tidyBufInit(&buf1);
while (itAttr)
{
d->def = tidyOptGetNextPriorityAttr(tdoc, &itAttr);
if (d->def)
{
if (buf1.size)
tidyBufAppend(&buf1, " ", 1);
tidyBufAppend(&buf1, d->def, strlen(d->def));
}
}
tidyBufAppend(&buf1, (void *)"\0", 1); /* is this really required? */
printf("%s: %s\n", d->name, buf1.bp);
d->name = "";
d->type = "";
d->def = 0;
tidyBufFree(&buf1);
}
}
break;
default:

View file

@ -1476,9 +1476,12 @@ Bool ParseCSS1Selector( TidyDocImpl* doc, const TidyOptionImpl* option )
return no;
}
buf[i] = 0; /* Is #697 - Do *not* add '-' */
#if 0 /* Is #697 - Is this still required? KEEP HISTORY - DO NOT DELETE */
buf[i++] = '-'; /* Make sure any escaped Unicode is terminated */
buf[i] = 0; /* so valid class names are generated after */
/* Tidy appends last digits. */
#endif /* Is #697 - Is this still required? */
SetOptionValue( doc, option->id, buf );
return yes;