Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

onig_set_default_syntax

May
12,845
164
Apparently, TCC does not call onig_set_default_syntax() when it sets the regular expression syntax. It would be nice if it did. Then plugins could specify ONIG_SYNTAX_DEFAULT and not have to worry about getting it right (or whether the user has used OPTION to change the syntax). As it is I QueryOptionValue() and set it myself in every function that uses Onig.

Could you add that call to the startup and OPTION routines?

I do it like this.
Code:
VOID GetRegexSyntax ( VOID ) {
    WCHAR szResponse[16];
    OnigSyntaxType *psyntax = ONIG_SYNTAX_PERL;
    if ( QueryOptionValue( L"RegularExpressions", szResponse ) )
        psyntax = ONIG_SYNTAX_PERL;
    else {
        if ( !lstrcmpi(szResponse, L"PERL" )    )    psyntax = ONIG_SYNTAX_PERL;
        if ( !lstrcmpi(szResponse, L"RUBY" )    )    psyntax = ONIG_SYNTAX_RUBY;
        if ( !lstrcmpi(szResponse, L"JAVA" )    )    psyntax = ONIG_SYNTAX_JAVA;
        if ( !lstrcmpi(szResponse, L"GREP" )    )    psyntax = ONIG_SYNTAX_GREP;
        if ( !lstrcmpi(szResponse, L"POSIX")    )    psyntax = ONIG_SYNTAX_POSIX_EXTENDED;
        if ( !lstrcmpi(szResponse, L"GNU"  )    )    psyntax = ONIG_SYNTAX_GNU_REGEX;
    }

    onig_set_default_syntax(psyntax);
}
 
| Apparently, TCC does not call onig_set_default_syntax() when it sets
| the regular expression syntax. It would be nice if it did. Then
| plugins could specify ONIG_SYNTAX_DEFAULT and not have to worry
| about getting it right (or whether the user has used OPTION to
| change the syntax). As it is I QueryOptionValue() and set it myself
| in every function that uses Onig.

Do you also restore the user's choice?
--
Steve
 
On Sat, 25 Sep 2010 08:28:15 -0400, you wrote:

|| Apparently, TCC does not call onig_set_default_syntax() when it sets
|| the regular expression syntax. It would be nice if it did. Then
|| plugins could specify ONIG_SYNTAX_DEFAULT and not have to worry
|| about getting it right (or whether the user has used OPTION to
|| change the syntax). As it is I QueryOptionValue() and set it myself
|| in every function that uses Onig.
|
|Do you also restore the user's choice?

QueryOptionValue() gets the current value of the user's choice (that's my
point), so there's no reason to restore it. I wouldn't have to do that (I
believe) if TCC called onig_set_default_syntax() whenever it set/changed the
syntax; I could use ONIG_SYNTAX_DEFAULT and be confident that it was current.
 
Back
Top