This commit is contained in:
Jim Derry 2017-03-09 16:04:03 -05:00
parent b0bd27e9c1
commit f88328b893
2 changed files with 19 additions and 15 deletions

View file

@ -693,6 +693,10 @@ void GetOption( TidyDoc tdoc, TidyOption topt, OptionDesc *d )
** Array holding all options. Contains a trailing sentinel.
*/
typedef struct {
/* Some options aren't exposed in the API although they're available
in the enum. This struct is guaranteed to hold *all* Tidy options,
but be sure to use the public API iterators to access them!
*/
TidyOption topt[N_TIDY_OPTIONS];
} AllOption_t;
@ -723,8 +727,7 @@ static void getSortedOption( TidyDoc tdoc, AllOption_t *tOption )
tOption->topt[i] = NULL; /* sentinel */
qsort(tOption->topt,
/* Do not sort the sentinel: hence `-1' */
sizeof(tOption->topt)/sizeof(tOption->topt[0])-1,
i, /* there are i items, not including the sentinal */
sizeof(tOption->topt[0]),
cmpOpt);
}

View file

@ -1601,10 +1601,11 @@ const TidyOptionImpl* TY_(getNextOption)( TidyDocImpl* ARG_UNUSED(doc),
optId = (size_t) *iter;
if ( optId > TidyUnknownOption && optId < N_TIDY_OPTIONS )
{
option = &option_defs[ optId ];
optId++;
/* Hide these internal options from the API entirely. */
if ( optId == TidyEmacsFile || optId == TidyDoctypeMode )
while ( optId == TidyEmacsFile || optId == TidyDoctypeMode )
optId++;
option = &option_defs[ optId ];
optId++;
}
*iter = (TidyIterator) ( optId < N_TIDY_OPTIONS ? optId : (size_t)0 );