Skip to content

Commit d758037

Browse files
committed
Terminal: improve performance of xfce4-terminal version
1 parent d25ac86 commit d758037

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/detection/terminalshell/terminalshell.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionTermux(FFstrbuf* version)
287287
return version->length > 0;
288288
}
289289

290-
static bool extractGnomeTerminalVersion(const char *str, FF_MAYBE_UNUSED uint32_t len, void *userdata)
290+
static bool extractGeneralVersion(const char *str, FF_MAYBE_UNUSED uint32_t len, void *userdata)
291291
{
292292
if (!ffCharIsDigit(str[0])) return true;
293293
int count = 0;
@@ -301,7 +301,7 @@ FF_MAYBE_UNUSED static bool getTerminalVersionGnome(FFstrbuf* exe, FFstrbuf* ver
301301
{
302302
if (exe->chars[0] == '/')
303303
{
304-
ffBinaryExtractStrings(exe->chars, extractGnomeTerminalVersion, version, (uint32_t) strlen("0.0.0"));
304+
ffBinaryExtractStrings(exe->chars, extractGeneralVersion, version, (uint32_t) strlen("0.0.0"));
305305
if (version->length) return true;
306306
}
307307

@@ -317,6 +317,17 @@ FF_MAYBE_UNUSED static bool getTerminalVersionGnome(FFstrbuf* exe, FFstrbuf* ver
317317
return true;
318318
}
319319

320+
FF_MAYBE_UNUSED static bool getTerminalVersionXfce4Terminal(FFstrbuf* exe, FFstrbuf* version)
321+
{
322+
if (exe->chars[0] == '/')
323+
{
324+
ffBinaryExtractStrings(exe->chars, extractGeneralVersion, version, (uint32_t) strlen("0.0.0"));
325+
if (version->length) return true;
326+
}
327+
328+
return getExeVersionGeneral(exe, version);//xfce4-terminal 1.0.4 (Xfce 4.18)...
329+
}
330+
320331
FF_MAYBE_UNUSED static bool getTerminalVersionKgx(FFstrbuf* version)
321332
{
322333
if(ffProcessAppendStdOut(version, (char* const[]){
@@ -652,7 +663,7 @@ bool fftsGetTerminalVersion(FFstrbuf* processName, FF_MAYBE_UNUSED FFstrbuf* exe
652663
return getExeVersionGeneral(exe, version);//yakuake 22.12.3
653664

654665
if(ffStrbufIgnCaseEqualS(processName, "xfce4-terminal"))
655-
return getExeVersionGeneral(exe, version);//xfce4-terminal 1.0.4 (Xfce 4.18)...
666+
return getTerminalVersionXfce4Terminal(exe, version);
656667

657668
if(ffStrbufIgnCaseEqualS(processName, "terminator"))
658669
return getExeVersionGeneral(exe, version);//terminator 2.1.3

0 commit comments

Comments
 (0)