Skip to content

Commit 736d531

Browse files
authored
Merge pull request #705 from fastfetch-cli/dev
Release v2.7.1
2 parents 1206f6d + efe42a2 commit 736d531

File tree

7 files changed

+78
-72
lines changed

7 files changed

+78
-72
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 2.7.1
2+
3+
Features:
4+
* Config presets in app folder now work with symlinks
5+
6+
Bugfixes:
7+
* Fix a possible segfault when detecting terminal (Terminal, Linux)
8+
19
# 2.7.0
210

311
Features:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
22

33
project(fastfetch
4-
VERSION 2.7.0
4+
VERSION 2.7.1
55
LANGUAGES C
66
DESCRIPTION "Fast neofetch-like system information tool"
77
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"

src/detection/gpu/gpu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const char* FF_GPU_VENDOR_NAME_APPLE = "Apple";
66
const char* FF_GPU_VENDOR_NAME_AMD = "AMD";
77
const char* FF_GPU_VENDOR_NAME_INTEL = "Intel";
88
const char* FF_GPU_VENDOR_NAME_NVIDIA = "NVIDIA";
9+
const char* FF_GPU_VENDOR_NAME_QUALCOMM = "Qualcomm";
10+
const char* FF_GPU_VENDOR_NAME_MTK = "MTK";
911
const char* FF_GPU_VENDOR_NAME_VMWARE = "VMware";
1012
const char* FF_GPU_VENDOR_NAME_PARALLEL = "Parallel";
1113
const char* FF_GPU_VENDOR_NAME_MICROSOFT = "Microsoft";
@@ -33,6 +35,10 @@ const char* ffGetGPUVendorString(unsigned vendorId)
3335
return FF_GPU_VENDOR_NAME_INTEL;
3436
else if(arrayContains((const unsigned[]) {0x0955, 0x10de, 0x12d2}, vendorId, 3))
3537
return FF_GPU_VENDOR_NAME_NVIDIA;
38+
else if(arrayContains((const unsigned[]) {0x5143}, vendorId, 1))
39+
return FF_GPU_VENDOR_NAME_QUALCOMM;
40+
else if(arrayContains((const unsigned[]) {0x14c3}, vendorId, 1))
41+
return FF_GPU_VENDOR_NAME_MTK;
3642
else if(arrayContains((const unsigned[]) {0x15ad}, vendorId, 1))
3743
return FF_GPU_VENDOR_NAME_VMWARE;
3844
else if(arrayContains((const unsigned[]) {0x1af4}, vendorId, 1))

src/detection/terminalshell/terminalshell_linux.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
312312

313313
static bool getTerminalInfoByPidEnv(FFTerminalResult* result, const char* pidEnv)
314314
{
315-
pid_t pid = (pid_t) strtol(getenv(pidEnv), NULL, 10);
315+
const char* envStr = getenv(pidEnv);
316+
if (envStr == NULL)
317+
return false;
318+
319+
pid_t pid = (pid_t) strtol(envStr, NULL, 10);
316320
result->pid = (uint32_t) pid;
317321
char name[256];
318322
if (getProcessNameAndPpid(pid, name, (pid_t*) &result->ppid, NULL) == NULL)

src/modules/datetime/datetime.c

Lines changed: 37 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,33 @@
99
#pragma GCC diagnostic ignored "-Wformat" // warning: unknown conversion type character 'F' in format
1010

1111
#define FF_DATETIME_DISPLAY_NAME "Date & Time"
12-
#define FF_DATETIME_NUM_FORMAT_ARGS 20
12+
#define FF_DATETIME_NUM_FORMAT_ARGS 22
1313

1414
typedef struct FFDateTimeResult
1515
{
1616
//Examples for 21.02.2022 - 15:18:37
1717
uint16_t year; //2022
1818
uint8_t yearShort; //22
1919
uint8_t month; //2
20-
FFstrbuf monthPretty; //02
21-
FFstrbuf monthName; //February
22-
FFstrbuf monthNameShort; //Feb
20+
char monthPretty[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //02
21+
char monthName[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //February
22+
char monthNameShort[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //Feb
2323
uint8_t week; //8
24-
FFstrbuf weekday; //Monday
25-
FFstrbuf weekdayShort; //Mon
24+
char weekday[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //Monday
25+
char weekdayShort[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //Mon
2626
uint16_t dayInYear; //52
2727
uint8_t dayInMonth; //21
2828
uint8_t dayInWeek; //1
2929
uint8_t hour; //15
30-
FFstrbuf hourPretty; //15
30+
char hourPretty[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //15
3131
uint8_t hour12; //3
32-
FFstrbuf hour12Pretty; //03
32+
char hour12Pretty[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //03
3333
uint8_t minute; //18
34-
FFstrbuf minutePretty; //18
34+
char minutePretty[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //18
3535
uint8_t second; //37
36-
FFstrbuf secondPretty; //37
36+
char secondPretty[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //37
37+
char offsetFromUtc[FASTFETCH_STRBUF_DEFAULT_ALLOC];
38+
char timezoneName[FASTFETCH_STRBUF_DEFAULT_ALLOC];
3739
} FFDateTimeResult;
3840

3941
void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs)
@@ -43,80 +45,50 @@ void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs)
4345
result.year = (uint16_t) (tm->tm_year + 1900);
4446
result.yearShort = (uint8_t) (result.year % 100);
4547
result.month = (uint8_t) (tm->tm_mon + 1);
46-
47-
ffStrbufInitA(&result.monthPretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
48-
result.monthPretty.length = (uint32_t) strftime(result.monthPretty.chars, ffStrbufGetFree(&result.monthPretty), "%m", tm);
49-
50-
ffStrbufInitA(&result.monthName, FASTFETCH_STRBUF_DEFAULT_ALLOC);
51-
result.monthName.length = (uint32_t) strftime(result.monthName.chars, ffStrbufGetFree(&result.monthName), "%B", tm);
52-
53-
ffStrbufInitA(&result.monthNameShort, FASTFETCH_STRBUF_DEFAULT_ALLOC);
54-
result.monthNameShort.length = (uint32_t) strftime(result.monthNameShort.chars, ffStrbufGetFree(&result.monthNameShort), "%b", tm);
55-
48+
strftime(result.monthPretty, sizeof(result.monthPretty), "%m", tm);
49+
strftime(result.monthName, sizeof(result.monthName), "%B", tm);
50+
strftime(result.monthNameShort, sizeof(result.monthNameShort), "%b", tm);
5651
result.week = (uint8_t) (tm->tm_yday / 7 + 1);
57-
58-
ffStrbufInitA(&result.weekday, FASTFETCH_STRBUF_DEFAULT_ALLOC);
59-
result.weekday.length = (uint32_t) strftime(result.weekday.chars, ffStrbufGetFree(&result.weekday), "%A", tm);
60-
61-
ffStrbufInitA(&result.weekdayShort, FASTFETCH_STRBUF_DEFAULT_ALLOC);
62-
result.weekdayShort.length = (uint32_t) strftime(result.weekdayShort.chars, ffStrbufGetFree(&result.weekdayShort), "%a", tm);
63-
52+
strftime(result.weekday, sizeof(result.weekday), "%A", tm);
53+
strftime(result.weekdayShort, sizeof(result.weekdayShort), "%a", tm);
6454
result.dayInYear = (uint8_t) (tm->tm_yday + 1);
6555
result.dayInMonth = (uint8_t) tm->tm_mday;
6656
result.dayInWeek = tm->tm_wday == 0 ? 7 : (uint8_t) tm->tm_wday;
67-
6857
result.hour = (uint8_t) tm->tm_hour;
69-
70-
ffStrbufInitA(&result.hourPretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
71-
result.hourPretty.length = (uint32_t) strftime(result.hourPretty.chars, ffStrbufGetFree(&result.hourPretty), "%H", tm);
72-
58+
strftime(result.hourPretty, sizeof(result.hourPretty), "%H", tm);
7359
result.hour12 = (uint8_t) (result.hour % 12);
74-
75-
ffStrbufInitA(&result.hour12Pretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
76-
result.hour12Pretty.length = (uint32_t) strftime(result.hour12Pretty.chars, ffStrbufGetFree(&result.hour12Pretty), "%I", tm);
77-
60+
strftime(result.hour12Pretty, sizeof(result.hour12Pretty), "%I", tm);
7861
result.minute = (uint8_t) tm->tm_min;
79-
80-
ffStrbufInitA(&result.minutePretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
81-
result.minutePretty.length = (uint32_t) strftime(result.minutePretty.chars, ffStrbufGetFree(&result.minutePretty), "%M", tm);
82-
62+
strftime(result.minutePretty, sizeof(result.minutePretty), "%M", tm);
8363
result.second = (uint8_t) tm->tm_sec;
84-
85-
ffStrbufInitA(&result.secondPretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
86-
result.secondPretty.length = (uint32_t) strftime(result.secondPretty.chars, ffStrbufGetFree(&result.secondPretty), "%S", tm);
64+
strftime(result.secondPretty, sizeof(result.secondPretty), "%S", tm);
65+
strftime(result.offsetFromUtc, sizeof(result.offsetFromUtc), "%z", tm);
66+
strftime(result.timezoneName, sizeof(result.timezoneName), "%Z", tm);
8767

8868
ffPrintFormat(FF_DATETIME_DISPLAY_NAME, 0, moduleArgs, FF_DATETIME_NUM_FORMAT_ARGS, (FFformatarg[]) {
8969
{FF_FORMAT_ARG_TYPE_UINT16, &result.year}, // 1
9070
{FF_FORMAT_ARG_TYPE_UINT8, &result.yearShort}, // 2
9171
{FF_FORMAT_ARG_TYPE_UINT8, &result.month}, // 3
92-
{FF_FORMAT_ARG_TYPE_STRBUF, &result.monthPretty}, // 4
93-
{FF_FORMAT_ARG_TYPE_STRBUF, &result.monthName}, // 5
94-
{FF_FORMAT_ARG_TYPE_STRBUF, &result.monthNameShort}, // 6
72+
{FF_FORMAT_ARG_TYPE_STRING, result.monthPretty}, // 4
73+
{FF_FORMAT_ARG_TYPE_STRING, result.monthName}, // 5
74+
{FF_FORMAT_ARG_TYPE_STRING, result.monthNameShort}, // 6
9575
{FF_FORMAT_ARG_TYPE_UINT8, &result.week}, // 7
96-
{FF_FORMAT_ARG_TYPE_STRBUF, &result.weekday}, // 8
97-
{FF_FORMAT_ARG_TYPE_STRBUF, &result.weekdayShort}, // 9
76+
{FF_FORMAT_ARG_TYPE_STRING, result.weekday}, // 8
77+
{FF_FORMAT_ARG_TYPE_STRING, result.weekdayShort}, // 9
9878
{FF_FORMAT_ARG_TYPE_UINT16, &result.dayInYear}, // 10
9979
{FF_FORMAT_ARG_TYPE_UINT8, &result.dayInMonth}, // 11
10080
{FF_FORMAT_ARG_TYPE_UINT8, &result.dayInWeek}, // 12
10181
{FF_FORMAT_ARG_TYPE_UINT8, &result.hour}, // 13
102-
{FF_FORMAT_ARG_TYPE_STRBUF, &result.hourPretty}, // 14
82+
{FF_FORMAT_ARG_TYPE_STRING, result.hourPretty}, // 14
10383
{FF_FORMAT_ARG_TYPE_UINT8, &result.hour12}, // 15
104-
{FF_FORMAT_ARG_TYPE_STRBUF, &result.hour12Pretty}, // 16
84+
{FF_FORMAT_ARG_TYPE_STRING, result.hour12Pretty}, // 16
10585
{FF_FORMAT_ARG_TYPE_UINT8, &result.minute}, // 17
106-
{FF_FORMAT_ARG_TYPE_STRBUF, &result.minutePretty}, // 18
86+
{FF_FORMAT_ARG_TYPE_STRING, result.minutePretty}, // 18
10787
{FF_FORMAT_ARG_TYPE_UINT8, &result.second}, // 19
108-
{FF_FORMAT_ARG_TYPE_STRBUF, &result.secondPretty} // 20
88+
{FF_FORMAT_ARG_TYPE_STRING, result.secondPretty}, // 20
89+
{FF_FORMAT_ARG_TYPE_STRING, result.offsetFromUtc}, // 21
90+
{FF_FORMAT_ARG_TYPE_STRING, result.timezoneName}, // 22
10991
});
110-
111-
ffStrbufDestroy(&result.hour12Pretty);
112-
ffStrbufDestroy(&result.hourPretty);
113-
ffStrbufDestroy(&result.minutePretty);
114-
ffStrbufDestroy(&result.monthName);
115-
ffStrbufDestroy(&result.monthNameShort);
116-
ffStrbufDestroy(&result.monthPretty);
117-
ffStrbufDestroy(&result.secondPretty);
118-
ffStrbufDestroy(&result.weekday);
119-
ffStrbufDestroy(&result.weekdayShort);
12092
}
12193

12294
void ffPrintDateTime(FFDateTimeOptions* options)
@@ -205,7 +177,9 @@ void ffPrintDateTimeHelpFormat(void)
205177
"minute",
206178
"minute with leading zero",
207179
"second",
208-
"second with leading zero"
180+
"second with leading zero",
181+
"offset from UTC in the ISO 8601 format",
182+
"locale-dependent timezone name or abbreviation",
209183
});
210184
}
211185

src/util/platform/FFPlatform_unix.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,31 @@
1717

1818
static void getExePath(FFPlatform* platform)
1919
{
20-
FFstrbuf* const exePath = &platform->exePath;
21-
ffStrbufEnsureFree(exePath, PATH_MAX);
20+
char exePath[PATH_MAX + 1];
2221
#ifdef __linux__
23-
ssize_t exePathLen = readlink("/proc/self/exe", exePath->chars, exePath->allocated - 1);
22+
ssize_t exePathLen = readlink("/proc/self/exe", exePath, sizeof(exePath) - 1);
23+
exePath[exePathLen] = '\0';
2424
#elif defined(__APPLE__)
25-
int exePathLen = proc_pidpath((int) getpid(), exePath->chars, exePath->allocated);
25+
int exePathLen = proc_pidpath((int) getpid(), exePath, sizeof(exePath));
2626
#elif defined(__FreeBSD__)
27-
size_t exePathLen = exePath->allocated;
27+
size_t exePathLen = sizeof(exePath);
2828
if(sysctl(
2929
(int[]){CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, (int) getpid()}, 4,
30-
exePath->chars, &exePathLen,
30+
exePath, &exePathLen,
3131
NULL, 0
3232
) < 0)
3333
exePathLen = 0;
3434
else
3535
exePathLen--; // remove terminating NUL
3636
#endif
3737
if (exePathLen > 0)
38-
exePath->length = (uint32_t) exePathLen;
38+
{
39+
ffStrbufEnsureFree(&platform->exePath, PATH_MAX);
40+
if (realpath(platform->exePath.chars, exePath))
41+
ffStrbufRecalculateLength(&platform->exePath);
42+
else
43+
ffStrbufSetNS(&platform->exePath, (uint32_t) exePathLen, exePath);
44+
}
3945
}
4046

4147
static void platformPathAddEnv(FFlist* dirs, const char* env)

src/util/platform/FFPlatform_windows.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ static void getExePath(FFPlatform* platform)
1818
DWORD exePathWLen = GetModuleFileNameW(NULL, exePathW, MAX_PATH);
1919
if (exePathWLen == 0 && exePathWLen >= MAX_PATH) return;
2020

21+
FF_AUTO_CLOSE_FD HANDLE hPath = CreateFileW(exePathW, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
22+
if (hPath != INVALID_HANDLE_VALUE)
23+
{
24+
DWORD len = GetFinalPathNameByHandleW(hPath, exePathW, MAX_PATH, FILE_NAME_OPENED);
25+
if (len > 0 && len < MAX_PATH)
26+
exePathWLen = len;
27+
}
28+
2129
ffStrbufSetNWS(&platform->exePath, exePathWLen, exePathW);
2230
if (ffStrbufStartsWithS(&platform->exePath, "\\\\?\\"))
2331
ffStrbufSubstrAfter(&platform->exePath, 3);

0 commit comments

Comments
 (0)