File tree Expand file tree Collapse file tree 1 file changed +8
-18
lines changed
Expand file tree Collapse file tree 1 file changed +8
-18
lines changed Original file line number Diff line number Diff line change @@ -134,24 +134,14 @@ const char* ffDetectEditor(FFEditorResult* result)
134134 return NULL ;
135135
136136 ffStrbufSubstrBeforeFirstC (& result -> version , '\n' );
137- for (uint32_t iStart = 0 ; iStart < result -> version .length ; ++ iStart )
138- {
139- char c = result -> version .chars [iStart ];
140- if (ffCharIsDigit (c ))
141- {
142- for (uint32_t iEnd = iStart + 1 ; iEnd < result -> version .length ; ++ iEnd )
143- {
144- char c = result -> version .chars [iEnd ];
145- if (isspace (c ))
146- {
147- ffStrbufSubstrBefore (& result -> version , iEnd );
148- break ;
149- }
150- }
151- if (iStart > 0 )
152- ffStrbufSubstrAfter (& result -> version , iStart - 1 );
153- break ;
154- }
137+ const char * versionStart = strpbrk (result -> version .chars , "0123456789" );
138+ if (versionStart != NULL ) {
139+ const char * versionEnd = strpbrk (versionStart , " \t\v\f" );
140+ if (versionEnd != NULL )
141+ ffStrbufSubstrBefore (& result -> version , (uint32_t )(versionEnd - result -> version .chars ));
142+
143+ if (versionStart != result -> version .chars )
144+ ffStrbufSubstrAfter (& result -> version , (uint32_t )(versionStart - result -> version .chars - 1 ));
155145 }
156146
157147 return NULL ;
You can’t perform that action at this time.
0 commit comments