fix icons not showing and segfault when size not properly formatted
This commit is contained in:
parent
652473a0ec
commit
1f0f19174a
3 changed files with 38 additions and 33 deletions
7
ccc.c
7
ccc.c
|
@ -630,7 +630,12 @@ void add_file_stat(char *filepath, int ftype)
|
|||
unit++;
|
||||
}
|
||||
/* display sizes */
|
||||
sprintf(size, "%.3g%s", bytes, units[unit]);
|
||||
/* Check if there are decimal places */
|
||||
if (bytes == (unsigned int) bytes) {
|
||||
sprintf(size, "%d%s", (unsigned int) bytes, units[unit]);
|
||||
} else {
|
||||
sprintf(size, "%.2f%s", bytes, units[unit]);
|
||||
}
|
||||
|
||||
/* get file mode string */
|
||||
char *mode_str = get_file_mode(file_stat.st_mode);
|
||||
|
|
62
icons.c
62
icons.c
|
@ -20,7 +20,6 @@ unsigned int hash(char *name)
|
|||
hash_value = (hash_value * name[i]) % TABLE_SIZE;
|
||||
}
|
||||
|
||||
printf("Name: %s | Hash Value: %d\n", name, hash_value);
|
||||
return hash_value;
|
||||
}
|
||||
|
||||
|
@ -50,69 +49,70 @@ void hashtable_init()
|
|||
md->icon = L"";
|
||||
|
||||
icon *py = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "py");
|
||||
md->icon = L"";
|
||||
strcpy(py->name, "py");
|
||||
py->icon = L"";
|
||||
|
||||
icon *java = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "java");
|
||||
md->icon = L"";
|
||||
strcpy(java->name, "java");
|
||||
java->icon = L"";
|
||||
|
||||
icon *json = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "json");
|
||||
md->icon = L"";
|
||||
strcpy(json->name, "json");
|
||||
json->icon = L"";
|
||||
|
||||
icon *js = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "js");
|
||||
md->icon = L"";
|
||||
strcpy(js->name, "js");
|
||||
js->icon = L"";
|
||||
|
||||
icon *html = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "html");
|
||||
md->icon = L"";
|
||||
strcpy(html->name, "html");
|
||||
html->icon = L"";
|
||||
|
||||
icon *rs = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "rs");
|
||||
md->icon = L"";
|
||||
strcpy(rs->name, "rs");
|
||||
rs->icon = L"";
|
||||
|
||||
icon *sh = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "sh");
|
||||
md->icon = L"";
|
||||
strcpy(sh->name, "sh");
|
||||
sh->icon = L"";
|
||||
|
||||
icon *go = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "go");
|
||||
md->icon = L"";
|
||||
strcpy(go->name, "go");
|
||||
go->icon = L"";
|
||||
|
||||
icon *r = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "r");
|
||||
md->icon = L"";
|
||||
strcpy(r->name, "r");
|
||||
r->icon = L"";
|
||||
|
||||
icon *diff = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "diff");
|
||||
md->icon = L"";
|
||||
strcpy(diff->name, "diff");
|
||||
diff->icon = L"";
|
||||
|
||||
icon *hs = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "hs");
|
||||
md->icon = L"";
|
||||
strcpy(hs->name, "hs");
|
||||
hs->icon = L"";
|
||||
|
||||
icon *log = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "log");
|
||||
md->icon = L"";
|
||||
strcpy(log->name, "log");
|
||||
log->icon = L"";
|
||||
|
||||
icon *rb = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "rb");
|
||||
md->icon = L"";
|
||||
strcpy(rb->name, "rb");
|
||||
rb->icon = L"";
|
||||
|
||||
icon *iso = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "iso");
|
||||
md->icon = L"";
|
||||
strcpy(iso->name, "iso");
|
||||
iso->icon = L"";
|
||||
|
||||
icon *lua = memalloc(sizeof(icon));
|
||||
strcpy(md->name, "lua");
|
||||
md->icon = L"";
|
||||
strcpy(lua->name, "lua");
|
||||
lua->icon = L"";
|
||||
|
||||
hashtable_add(c);
|
||||
hashtable_add(h);
|
||||
hashtable_add(cpp);
|
||||
hashtable_add(hpp);
|
||||
hashtable_add(md);
|
||||
hashtable_add(py);
|
||||
hashtable_add(java);
|
||||
hashtable_add(json);
|
||||
|
|
2
icons.h
2
icons.h
|
@ -5,7 +5,7 @@
|
|||
#include <wchar.h>
|
||||
|
||||
#define MAX_NAME 30
|
||||
#define TABLE_SIZE 50
|
||||
#define TABLE_SIZE 100
|
||||
|
||||
typedef struct {
|
||||
char name[MAX_NAME];
|
||||
|
|
Loading…
Reference in a new issue