onig_set_default_syntax

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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);
}
 
#2
| 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
 
#3
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.