@@ -95,7 +95,7 @@ Editorconfig::MatchFilename(const char* filename, const BMessage* allProperties,
9595 int32 slashIndex = regexStr.FindFirst (" /" );
9696 if (slashIndex != B_ERROR && slashIndex > 0 && regexStr[slashIndex - 1 ] != ' \\ ' )
9797 dirSpecific = true ;
98- bool inBrace = false ;
98+ int32 inBraceCount = 0 ;
9999 int32 c = 0 ;
100100 while (c < regexStr.Length ()) {
101101 if (regexStr[c] == ' *' ) {
@@ -127,30 +127,31 @@ Editorconfig::MatchFilename(const char* filename, const BMessage* allProperties,
127127 c += 2 ;
128128 continue ;
129129 }
130- if (!inBrace) {
131- if (regexStr[c] == ' {' ) {
132- if (c > 0 && regexStr[c - 1 ] == ' \\ ' ) {
133- c++;
134- continue ;
135- }
136- inBrace = true ;
137- regexStr.Replace (" {" , " (" , 1 , c);
130+ if (regexStr[c] == ' {' ) {
131+ if (c > 0 && regexStr[c - 1 ] == ' \\ ' ) {
132+ c++;
133+ continue ;
138134 }
139- } else {
135+ inBraceCount++;
136+ regexStr.Replace (" {" , " (" , 1 , c);
137+ }
138+ if (inBraceCount > 0 ) {
140139 if (c > 0 && regexStr[c - 1 ] == ' \\ ' ) {
141140 c++;
142141 continue ;
143142 }
144143 if (regexStr[c] == ' ,' )
145144 regexStr.Replace (" ," , " |" , 1 , c);
146145 if (regexStr[c] == ' }' ) {
147- inBrace = false ;
146+ inBraceCount-- ;
148147 regexStr.Replace (" }" , " )" , 1 , c);
149148 }
150149 }
151150 c++;
152151 }
153152
153+ if (inBraceCount != 0 ) return ;
154+
154155 std::regex expr (regexStr.String ());
155156 if (properties != nullptr && std::regex_match (filename, expr)) {
156157 BMessage globProperties;
0 commit comments