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; 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: default:
break; 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. /** 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 ); TidyOptionId optId = tidyOptGetId( topt );
TidyBuffer buf1, buf2;
if ( tidyOptGetCategory(topt) == TidyInternalCategory ) if ( tidyOptGetCategory(topt) == TidyInternalCategory )
return; return;
@ -1505,18 +1551,56 @@ static void printOptionExportValues(TidyDoc ARG_UNUSED(tdoc), /**< The Tidy doc
case TidyPreTags: case TidyPreTags:
{ {
TidyIterator pos = tidyOptGetDeclTagList( tdoc ); TidyIterator pos = tidyOptGetDeclTagList( tdoc );
while ( pos ) if ( pos ) /* Is #697 - one or more values */
{ {
d->def = tidyOptGetNextDeclTag(tdoc, optId, &pos); tidyBufInit(&buf1);
if ( pos ) tidyBufInit(&buf2);
while (pos)
{ {
printf( "%s: %s\n", d->name, d->def ); d->def = tidyOptGetNextDeclTag(tdoc, optId, &pos);
d->name = ""; if (d->def)
d->type = ""; {
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; 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: default:
break; break;
} }

View file

@ -1476,9 +1476,12 @@ Bool ParseCSS1Selector( TidyDocImpl* doc, const TidyOptionImpl* option )
return no; 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++] = '-'; /* Make sure any escaped Unicode is terminated */
buf[i] = 0; /* so valid class names are generated after */ buf[i] = 0; /* so valid class names are generated after */
/* Tidy appends last digits. */ /* Tidy appends last digits. */
#endif /* Is #697 - Is this still required? */
SetOptionValue( doc, option->id, buf ); SetOptionValue( doc, option->id, buf );
return yes; return yes;