diff options
| author | Thorsten Töpper <atsutane@freethoughts.de> | 2025-07-26 03:07:34 +0200 |
|---|---|---|
| committer | Thorsten Töpper <atsutane@freethoughts.de> | 2025-07-26 03:07:34 +0200 |
| commit | ff1bd6be03e2a0b12309b074dd0c13c6cc6c0ca6 (patch) | |
| tree | 6a9e139654c787d8708d281fdab161dea3fef219 | |
| parent | cbcb331be25157151d5c64b399dbe9e046561307 (diff) | |
| download | dir_monitor-ff1bd6be03e2a0b12309b074dd0c13c6cc6c0ca6.tar.gz dir_monitor-ff1bd6be03e2a0b12309b074dd0c13c6cc6c0ca6.tar.bz2 | |
output: minor improvements/corrections
| -rw-r--r-- | src/output.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/output.c b/src/output.c index daf16d3..644a6a6 100644 --- a/src/output.c +++ b/src/output.c @@ -120,7 +120,8 @@ inline size_t get_longest_filename(struct list_head *list) { inline void out_print_group_name(struct list_node *ptr) { struct group *group = NULL; static gid_t prev_gid = UINT32_MAX; - static char prev_group_name[64] = ""; + /* TODO: move to heap with sapconf(_SC_LOGIN_NAME_MAX) length */ + static char prev_group_name[256] = ""; size_t group_name_length = 0; /* For the unlikely case of multi threading this program: lock required here... */ @@ -158,7 +159,8 @@ inline void out_print_group_name(struct list_node *ptr) { inline void out_print_user_name(struct list_node *ptr) { struct passwd *pwd = NULL; static uid_t prev_uid = UINT32_MAX; - static char prev_user_name[64] = ""; + /* TODO: move to heap with sapconf(_SC_LOGIN_NAME_MAX) length */ + static char prev_user_name[256] = ""; size_t user_name_length = 0; /* For the unlikely case of multi threading this program: lock required here... */ @@ -388,9 +390,11 @@ inline void out_print_format_string_header(const char *format, size_t longest_fn switch (format[i]) { case 'n': sprintf(pos, " FILE "); - tmp = strlen(pos); - for (k=0; k<longest_fname-4; k++) { - pos[tmp+k] = ' '; + if (option_print_boxed_table) { + tmp = strlen(pos); + for (k=0; k<longest_fname-4; k++) { + pos[tmp+k] = ' '; + } } LOCAL_EXTEND_SEP_LINE(); break; @@ -472,15 +476,16 @@ inline void out_print_format_string_header(const char *format, size_t longest_fn if (option_print_boxed_table) { tmp = strlen(sep_line); fputs(sep_line, stdout); + free(header); /* Reuse the memory */ if ((global_sep_line = calloc(tmp+1, sizeof(char))) != NULL) { memcpy(global_sep_line, sep_line, tmp); - free(sep_line); } + free(sep_line); } else { fputc_width_x('-', strlen(header), stdout); + free(header); } out_print_newline(); - free(header); #undef LOCAL_EXTEND_SEP_LINE } /* === END OF FORMATTING FUNCTIONS === */ |
