L:222 reduced home_dir's scope.

L:318 changed to appropiate format specifier
L:500 changed line's location.
This commit is contained in:
elegantShock2258 2021-10-14 16:53:54 +05:30
parent aa4a14998f
commit 8147b0a528
No known key found for this signature in database
GPG key ID: CABDDF7DC0C18BFA

View file

@ -207,7 +207,6 @@ int main(int argc, char *argv[])
void parse_config() void parse_config()
{ {
char line[256]; char line[256];
char homedir[512];
// opening and reading the config file // opening and reading the config file
FILE *config=NULL; FILE *config=NULL;
@ -215,6 +214,7 @@ void parse_config()
{ {
if (getenv("HOME") != NULL) if (getenv("HOME") != NULL)
{ {
char homedir[512];
sprintf(homedir, "%s/.config/uwufetch/config", getenv("HOME")); sprintf(homedir, "%s/.config/uwufetch/config", getenv("HOME"));
config = fopen(homedir, "r"); config = fopen(homedir, "r");
} }
@ -315,7 +315,7 @@ int pkgman()
comma_separator++; comma_separator++;
char spkg_count[16]; char spkg_count[16];
sprintf(spkg_count, "%d", pkg_count); sprintf(spkg_count, "%u", pkg_count);
strcat(pkgman_name, spkg_count); strcat(pkgman_name, spkg_count);
strcat(pkgman_name, " "); strcat(pkgman_name, " ");
strcat(pkgman_name, current->pkgman_name); // this is the line that breaks mac os, but something strange happens before strcat(pkgman_name, current->pkgman_name); // this is the line that breaks mac os, but something strange happens before
@ -497,7 +497,6 @@ int read_cache()
void print_cache() void print_cache()
{ {
char line[256];
// ram // ram
#ifndef __APPLE__ #ifndef __APPLE__
#ifndef __CYGWIN__ #ifndef __CYGWIN__
@ -508,6 +507,7 @@ void print_cache()
#else #else
meminfo = popen("LANG=EN_us free -m 2> /dev/null", "r"); meminfo = popen("LANG=EN_us free -m 2> /dev/null", "r");
#endif #endif
char line[256];
while (fgets(line, sizeof(line), meminfo)) while (fgets(line, sizeof(line), meminfo))
// free command prints like this: "Mem:" total used free shared buff/cache available // free command prints like this: "Mem:" total used free shared buff/cache available
sscanf(line, "Mem: %d %d", &ram_total, &ram_used); sscanf(line, "Mem: %d %d", &ram_total, &ram_used);