| 84 | } |
| 85 | |
| 86 | static const char* classend( MatchState* ms, const char* p ) { |
| 87 | switch ( *p++ ) { |
| 88 | case L_ESC: { |
| 89 | if ( p == ms->p_end ) |
| 90 | throw_error( "malformed pattern (ends with '%')" ); |
| 91 | return p + 1; |
| 92 | } |
| 93 | case '[': { |
| 94 | if ( *p == '^' ) |
| 95 | p++; |
| 96 | do { /* look for a `]' */ |
| 97 | if ( p == ms->p_end ) |
| 98 | throw_error( "malformed pattern (missing ']')" ); |
| 99 | if ( *( p++ ) == L_ESC && p < ms->p_end ) |
| 100 | p++; /* skip escapes (e.g. `%]') */ |
| 101 | } while ( *p != ']' ); |
| 102 | return p + 1; |
| 103 | } |
| 104 | default: { |
| 105 | return p; |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | static int match_class( int c, int cl ) { |
| 111 | int res; |