Thu, 02 Jul 2026 12:44:29 +0200
remove POSIX reserved type suffix from code
relates to #917
| src/arguments.c | file | annotate | diff | comparison | revisions | |
| src/arguments.h | file | annotate | diff | comparison | revisions | |
| src/bfile_heuristics.c | file | annotate | diff | comparison | revisions | |
| src/bfile_heuristics.h | file | annotate | diff | comparison | revisions | |
| src/cline.c | file | annotate | diff | comparison | revisions | |
| src/regex_parser.c | file | annotate | diff | comparison | revisions | |
| src/regex_parser.h | file | annotate | diff | comparison | revisions | |
| src/scanner.c | file | annotate | diff | comparison | revisions | |
| src/scanner.h | file | annotate | diff | comparison | revisions | |
| src/settings.c | file | annotate | diff | comparison | revisions | |
| src/settings.h | file | annotate | diff | comparison | revisions | |
| src/string_list.c | file | annotate | diff | comparison | revisions | |
| src/string_list.h | file | annotate | diff | comparison | revisions |
--- a/src/arguments.c Thu Jul 02 10:22:33 2026 +0200 +++ b/src/arguments.c Thu Jul 02 12:44:29 2026 +0200 @@ -53,7 +53,7 @@ return ret; } -void parseCSL(char* csl, string_list_t* list) { +void parseCSL(char* csl, string_list* list) { if (csl != NULL) { char* finder = strtok(csl, ","); while (finder != NULL) {
--- a/src/arguments.h Thu Jul 02 10:22:33 2026 +0200 +++ b/src/arguments.h Thu Jul 02 12:44:29 2026 +0200 @@ -37,7 +37,7 @@ int checkArgument(const char*, const char*); bool checkParamOpt(int*); bool registerArgument(int*, int); -void parseCSL(char*, string_list_t*); +void parseCSL(char*, string_list*); #ifdef _cplusplus }
--- a/src/bfile_heuristics.c Thu Jul 02 10:22:33 2026 +0200 +++ b/src/bfile_heuristics.c Thu Jul 02 12:44:29 2026 +0200 @@ -25,25 +25,26 @@ */ #include "bfile_heuristics.h" +#include "stdinc.h" #include <ctype.h> -bfile_heuristics_t *new_bfile_heuristics_t() { - bfile_heuristics_t *ret = malloc(sizeof(bfile_heuristics_t)); +bfile_heuristics *new_bfile_heuristics() { + bfile_heuristics *ret = malloc(sizeof(bfile_heuristics)); ret->level = BFILE_MEDIUM_ACCURACY; bfile_reset(ret); return ret; } -void destroy_bfile_heuristics_t(bfile_heuristics_t *def) { +void destroy_bfile_heuristics(bfile_heuristics *def) { free(def); } -void bfile_reset(bfile_heuristics_t *def) { +void bfile_reset(bfile_heuristics *def) { def->bcount = 0; def->tcount = 0; } -bool bfile_check(bfile_heuristics_t *def, int next_char) { +bool bfile_check(bfile_heuristics *def, int next_char) { bool ret = false; if (def->level != BFILE_IGNORE) { def->tcount++;
--- a/src/bfile_heuristics.h Thu Jul 02 10:22:33 2026 +0200 +++ b/src/bfile_heuristics.h Thu Jul 02 12:44:29 2026 +0200 @@ -27,8 +27,6 @@ #ifndef BFILE_HEURISTICS_H_ #define BFILE_HEURISTICS_H_ -#include "stdinc.h" - #define BFILE_IGNORE 0x00 #define BFILE_LOW_ACCURACY 0x01 #define BFILE_MEDIUM_ACCURACY 0x02 @@ -38,16 +36,16 @@ unsigned int level; unsigned int bcount; /* 'binary' character count */ unsigned int tcount; /* total count */ -} bfile_heuristics_t; +} bfile_heuristics; #ifdef _cplusplus extern "C" { #endif -bfile_heuristics_t *new_bfile_heuristics_t(); -void destroy_bfile_heuristics_t(bfile_heuristics_t *def); -void bfile_reset(bfile_heuristics_t *def); -bool bfile_check(bfile_heuristics_t *def, int next_char); +bfile_heuristics *new_bfile_heuristics(); +void destroy_bfile_heuristics(bfile_heuristics *def); +void bfile_reset(bfile_heuristics *def); +bool bfile_check(bfile_heuristics *def, int next_char); #ifdef _cplusplus }
--- a/src/cline.c Thu Jul 02 10:22:33 2026 +0200 +++ b/src/cline.c Thu Jul 02 12:44:29 2026 +0200 @@ -81,20 +81,20 @@ "\n"); } -static int exit_with_version(settings_t* settings) { +static int exit_with_version(settings* settings) { printf("cline - Version: " VERSION "\n"); - destroy_settings_t(settings); + destroy_settings(settings); return 0; } -static int exit_with_help(settings_t* settings, int code) { +static int exit_with_help(settings* settings, int code) { printf("cline - Version: " VERSION "\n"); printHelpText(); - destroy_settings_t(settings); + destroy_settings(settings); return code; } -static void normalize_excluded_dirs(settings_t *settings) { +static void normalize_excluded_dirs(settings *settings) { /* normalize all paths */ for (int i = 0 ; i < settings->excludeDirs->count ; i++) { char *arg = strdup(settings->excludeDirs->items[i]); @@ -127,14 +127,14 @@ int main(int argc, char** argv) { /* Settings */ - settings_t *settings = new_settings_t(); + settings *settings = new_settings(); if (settings == NULL) { fprintf(stderr, "Memory allocation failed.\n"); return 1; } /* Get arguments */ - string_list_t *directories = new_string_list_t(); + string_list *directories = new_string_list(); if (directories == NULL) { fprintf(stderr, "Memory allocation failed.\n"); return 1; @@ -300,8 +300,8 @@ /* Compiler regular expressions, if any specified */ if (!regex_compile_all(settings->regex)) { - destroy_string_list_t(directories); - destroy_settings_t(settings); + destroy_string_list(directories); + destroy_settings(settings); return 1; } @@ -309,7 +309,7 @@ normalize_excluded_dirs(settings); /* Scan directories */ - scanresult_t* result = new_scanresult_t(settings); + scanresult* result = new_scanresult(settings); const char* result_type = settings->count_chars ? "chars" : "lines"; bool has_output = false; unsigned total = 0; @@ -318,19 +318,19 @@ } for (unsigned t = 0 ; t < directories->count ; t++) { /* Don't waste memory when only the total sum is needed */ - string_list_t *output = NULL; + string_list *output = NULL; if (settings->verbose) { - output = new_string_list_t(); + output = new_string_list(); output->free_item = free; } - scanDirectory((scanner_t){directories->items[t], 0}, settings, output, result); + scanDirectory((scanner){directories->items[t], 0}, settings, output, result); total += result->result; if (settings->verbose) { has_output |= output->count > 0; for (int i = 0 ; i < output->count ; i++) { printf("%s", output->items[i]); } - destroy_string_list_t(output); + destroy_string_list(output); if (directories->count > 1) { has_output = true; fputs(sepline_single, stdout); @@ -340,7 +340,7 @@ } } } - destroy_string_list_t(directories); + destroy_string_list(directories); /* Print result */ if (settings->verbose) { @@ -376,8 +376,8 @@ } else { printf("%u", total); } - destroy_scanresult_t(result); - destroy_settings_t(settings); + destroy_scanresult(result); + destroy_settings(settings); return 0; }
--- a/src/regex_parser.c Thu Jul 02 10:22:33 2026 +0200 +++ b/src/regex_parser.c Thu Jul 02 12:44:29 2026 +0200 @@ -27,10 +27,10 @@ #include "regex_parser.h" #include <ctype.h> -regex_parser_t* new_regex_parser_t() { - regex_parser_t* ret = malloc(sizeof(regex_parser_t)); +regex_parser* new_regex_parser() { + regex_parser* ret = malloc(sizeof(regex_parser)); if (ret != NULL) { - ret->pattern_list = new_string_list_t(); + ret->pattern_list = new_string_list(); ret->matched_counted = 0; ret->pattern_match = 0; ret->compiled_patterns = NULL; @@ -40,11 +40,11 @@ return ret; } -void regex_parser_reset(regex_parser_t* parser) { +void regex_parser_reset(regex_parser* parser) { parser->pattern_match = parser->matched_counted = 0; } -void regex_destcomppats(regex_parser_t* parser) { +void regex_destcomppats(regex_parser* parser) { if (parser->compiled_patterns != NULL) { for (unsigned i = 0 ; i < parser->compiled_pattern_count ; i++) { regfree(parser->compiled_patterns + i); @@ -55,13 +55,13 @@ } } -void destroy_regex_parser_t(regex_parser_t* parser) { +void destroy_regex_parser(regex_parser* parser) { regex_destcomppats(parser); - destroy_string_list_t(parser->pattern_list); + destroy_string_list(parser->pattern_list); free(parser); } -bool regex_parser_matching(regex_parser_t* parser) { +bool regex_parser_matching(regex_parser* parser) { return parser->pattern_match > 0; } @@ -74,7 +74,7 @@ return ret; } -int regex_parser_do(regex_parser_t* parser, char* input) { +int regex_parser_do(regex_parser* parser, char* input) { int err = REG_NOMATCH; if (parser->compiled_pattern_count > 0) { regmatch_t match; @@ -139,7 +139,7 @@ return err; } -bool regex_compile_all(regex_parser_t* parser) { +bool regex_compile_all(regex_parser* parser) { size_t pcount = parser->pattern_list->count; if (pcount > 0) { regex_destcomppats(parser);
--- a/src/regex_parser.h Thu Jul 02 10:22:33 2026 +0200 +++ b/src/regex_parser.h Thu Jul 02 12:44:29 2026 +0200 @@ -40,26 +40,26 @@ #endif typedef struct { - string_list_t* pattern_list; /* even entries: start ; odd entries: end */ + string_list* pattern_list; /* even entries: start ; odd entries: end */ regex_t* compiled_patterns; size_t compiled_pattern_count; unsigned int pattern_match; /* save position of end pattern to match - NULL when a start pattern shall match first */ unsigned int matched_counted; bool count_chars; -} regex_parser_t; +} regex_parser; #ifdef _cplusplus extern "C" { #endif -regex_parser_t* new_regex_parser_t(); -void destroy_regex_parser_t(regex_parser_t*); -void regex_parser_reset(regex_parser_t* parser); +regex_parser* new_regex_parser(); +void destroy_regex_parser(regex_parser*); +void regex_parser_reset(regex_parser* parser); -bool regex_parser_matching(regex_parser_t*); -bool regex_compile_all(regex_parser_t*); -int regex_parser_do(regex_parser_t*, char*); +bool regex_parser_matching(regex_parser*); +bool regex_compile_all(regex_parser*); +int regex_parser_do(regex_parser*, char*); #ifdef _cplusplus }
--- a/src/scanner.c Thu Jul 02 10:22:33 2026 +0200 +++ b/src/scanner.c Thu Jul 02 12:44:29 2026 +0200 @@ -79,18 +79,16 @@ } #endif -typedef struct filelist filelist_t; - struct filelist { char *displayname; unsigned displayname_len; char *filename; char *ext; unsigned st_mode; - filelist_t *next; + struct filelist *next; }; -static bool testSuffix(char* filename, string_list_t* list) { +static bool testSuffix(char* filename, string_list* list) { bool ret = false; size_t tokenlen, fnamelen = strlen(filename); for (size_t t = 0 ; t < list->count ; t++) { @@ -106,7 +104,7 @@ return ret; } -static void addResultPerExtension(scanresult_ext_t* result, +static void addResultPerExtension(scanresult_ext* result, char* ext, unsigned value) { if (!result) return; @@ -137,15 +135,15 @@ result->count++; } -scanresult_t* new_scanresult_t(settings_t* settings) { - scanresult_t* result = calloc(1, sizeof(scanresult_t)); +scanresult* new_scanresult(settings* settings) { + scanresult* result = calloc(1, sizeof(scanresult)); if (settings->individual_sums) { - result->ext = calloc(1, sizeof(scanresult_ext_t)); + result->ext = calloc(1, sizeof(scanresult_ext)); } return result; } -void destroy_scanresult_t(scanresult_t* result) { +void destroy_scanresult(scanresult* result) { if (result->ext) { if (result->ext->count > 0) { for (unsigned i = 0 ; i < result->ext->count ; i++) { @@ -159,9 +157,9 @@ free(result); } -static filelist_t *buildFileList(scanner_t scanner, settings_t* settings) { +static struct filelist *buildFileList(scanner scanner, settings* settings) { - filelist_t* list = NULL; + struct filelist* list = NULL; DIR *dirf; struct dirent *entry; struct stat statbuf; @@ -176,7 +174,7 @@ if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { /* Create new filelist entry */ - filelist_t *newentry = (filelist_t*) malloc(sizeof(filelist_t)); + struct filelist *newentry = malloc(sizeof(struct filelist)); newentry->next = NULL; newentry->displayname_len = strlen(entry->d_name); @@ -210,9 +208,9 @@ if (list) { /* create fake root to have a pointer on the true root */ - filelist_t root; + struct filelist root; root.next = list; - filelist_t *parent = &root; + struct filelist *parent = &root; while (parent->next && (strcasecmp(parent->next->displayname, newentry->displayname) < 0 || (!S_ISDIR(newentry->st_mode) && S_ISDIR(parent->next->st_mode)) @@ -235,8 +233,8 @@ return list; } -static bool is_dir_excluded(settings_t* settings, const char* dir) { - const string_list_t * const list = settings->excludeDirs; +static bool is_dir_excluded(settings* settings, const char* dir) { + const string_list * const list = settings->excludeDirs; for (size_t i = 0 ; i < list->count ; i++) { /* determine if the list item is a path or a name */ @@ -264,15 +262,15 @@ return false; } -void scanDirectory(scanner_t scanner, settings_t* settings, - string_list_t* output, scanresult_t* result) { +void scanDirectory(scanner scnr, settings* settings, + string_list* output, scanresult* result) { result->result = 0; bool bfile; char *outbuf; const char *result_type = settings->count_chars ? "chars" : "lines"; - filelist_t *filelist = buildFileList(scanner, settings); + struct filelist *filelist = buildFileList(scnr, settings); while (filelist != NULL) { @@ -285,38 +283,38 @@ /* Print hint */ outbuf = malloc(81); snprintf(outbuf, 81, "%*s%*s%19s\n", - filelist->displayname_len + scanner.spaces, + filelist->displayname_len + scnr.spaces, filelist->displayname, - 60 - filelist->displayname_len - scanner.spaces, + 60 - filelist->displayname_len - scnr.spaces, "", "no match"); add_string(output, outbuf); } } else { - string_list_t *recoutput = settings->verbose ? new_string_list_t() : NULL; - scanresult_t recresult; + string_list *recoutput = settings->verbose ? new_string_list() : NULL; + scanresult recresult; recresult.ext = result->ext; scanDirectory( - (scanner_t) {filelist->filename, scanner.spaces+1}, + (scanner) {filelist->filename, scnr.spaces+1}, settings, recoutput, &recresult); result->result += recresult.result; if (settings->verbose && (!settings->matchesOnly || recresult.result > 0)) { outbuf = (char*) malloc(81); snprintf(outbuf, 81, "%*s/%*s%13u %s\n", - filelist->displayname_len+scanner.spaces, filelist->displayname, - 60-filelist->displayname_len-scanner.spaces-1, "", + filelist->displayname_len+scnr.spaces, filelist->displayname, + 60-filelist->displayname_len-scnr.spaces-1, "", recresult.result, result_type); add_string(output, outbuf); for (unsigned i = 0 ; i < recoutput->count ; i++) { add_string(output, recoutput->items[i]); } } - destroy_string_list_t(recoutput); + destroy_string_list(recoutput); } } } else if (!settings->matchesOnly && settings->verbose) { outbuf = (char*) malloc(81); snprintf(outbuf, 81, "%*s\n", - filelist->displayname_len+scanner.spaces, + filelist->displayname_len+scnr.spaces, filelist->displayname); add_string(output, outbuf); } @@ -381,9 +379,9 @@ if (!settings->matchesOnly && !settings->dirsOnly && settings->verbose) { outbuf = (char*) malloc(81); snprintf(outbuf, 81, - "%*s%*s%19s\n", filelist->displayname_len+scanner.spaces, + "%*s%*s%19s\n", filelist->displayname_len+scnr.spaces, filelist->displayname, - 60-filelist->displayname_len-scanner.spaces, "", "binary"); + 60-filelist->displayname_len-scnr.spaces, "", "binary"); add_string(output, outbuf); } } else { @@ -392,9 +390,9 @@ if (!settings->dirsOnly && settings->verbose) { outbuf = (char*) malloc(81); snprintf(outbuf, 81, "%*s%*s%13u %s\n", - filelist->displayname_len+scanner.spaces, + filelist->displayname_len+scnr.spaces, filelist->displayname, - 60-filelist->displayname_len-scanner.spaces, + 60-filelist->displayname_len-scnr.spaces, "", res_value, result_type @@ -408,8 +406,8 @@ /* Print hint */ outbuf = (char*) malloc(81); snprintf(outbuf, 81, "%*s%*s%19s\n", - filelist->displayname_len+scanner.spaces, filelist->displayname, - 60-filelist->displayname_len-scanner.spaces, "", "no match"); + filelist->displayname_len+scnr.spaces, filelist->displayname, + 60-filelist->displayname_len-scnr.spaces, "", "no match"); add_string(output, outbuf); } } @@ -417,7 +415,7 @@ free(filelist->filename); free(filelist->displayname); - filelist_t *freethis = filelist; + struct filelist *freethis = filelist; filelist = filelist->next; free(freethis); }
--- a/src/scanner.h Thu Jul 02 10:22:33 2026 +0200 +++ b/src/scanner.h Thu Jul 02 12:44:29 2026 +0200 @@ -33,29 +33,29 @@ typedef struct { char *dir; unsigned spaces; -} scanner_t; +} scanner; typedef struct { unsigned count; unsigned capacity; char** extensions; unsigned* result; -} scanresult_ext_t; +} scanresult_ext; typedef struct { unsigned result; - scanresult_ext_t* ext; -} scanresult_t; + scanresult_ext* ext; +} scanresult; #ifdef _cplusplus extern "C" { #endif -void scanDirectory(scanner_t scanner, settings_t* settings, - string_list_t* output, scanresult_t* result); +void scanDirectory(scanner scanner, settings* settings, + string_list* output, scanresult* result); -scanresult_t* new_scanresult_t(settings_t* settings); -void destroy_scanresult_t(scanresult_t*); +scanresult* new_scanresult(settings* settings); +void destroy_scanresult(scanresult*); char *make_path_absolute(const char *path);
--- a/src/settings.c Thu Jul 02 10:22:33 2026 +0200 +++ b/src/settings.c Thu Jul 02 12:44:29 2026 +0200 @@ -26,36 +26,36 @@ #include "settings.h" -settings_t* new_settings_t() { - settings_t *settings = malloc(sizeof(settings_t)); - if (settings != NULL) { +settings* new_settings() { + settings *s = malloc(sizeof(settings)); + if (s != NULL) { #ifdef _WIN32 - settings->fileSeparator = '\\'; + s->fileSeparator = '\\'; #else - settings->fileSeparator = '/'; + s->fileSeparator = '/'; #endif /* _WIN32 */ - settings->recursive = false; - settings->matchesOnly = false; - settings->includeSuffixes = new_string_list_t(); - settings->excludeSuffixes = new_string_list_t(); - settings->excludeDirs = new_string_list_t(); - settings->verbose = true; - settings->bfileHeuristics = new_bfile_heuristics_t(); - settings->confusing_lnlen = false; - settings->regex = new_regex_parser_t(); - settings->individual_sums = false; - settings->count_chars = false; - settings->dirsOnly = false; + s->recursive = false; + s->matchesOnly = false; + s->includeSuffixes = new_string_list(); + s->excludeSuffixes = new_string_list(); + s->excludeDirs = new_string_list(); + s->verbose = true; + s->bfileHeuristics = new_bfile_heuristics(); + s->confusing_lnlen = false; + s->regex = new_regex_parser(); + s->individual_sums = false; + s->count_chars = false; + s->dirsOnly = false; } - return settings; + return s; } -void destroy_settings_t(settings_t* settings) { - destroy_regex_parser_t(settings->regex); - destroy_string_list_t(settings->includeSuffixes); - destroy_string_list_t(settings->excludeSuffixes); - destroy_string_list_t(settings->excludeDirs); - destroy_bfile_heuristics_t(settings->bfileHeuristics); +void destroy_settings(settings* settings) { + destroy_regex_parser(settings->regex); + destroy_string_list(settings->includeSuffixes); + destroy_string_list(settings->excludeSuffixes); + destroy_string_list(settings->excludeDirs); + destroy_bfile_heuristics(settings->bfileHeuristics); free(settings); }
--- a/src/settings.h Thu Jul 02 10:22:33 2026 +0200 +++ b/src/settings.h Thu Jul 02 12:44:29 2026 +0200 @@ -32,12 +32,12 @@ #include "bfile_heuristics.h" #include "regex_parser.h" -typedef struct settings_s { - string_list_t* includeSuffixes; - string_list_t* excludeSuffixes; - string_list_t* excludeDirs; - regex_parser_t* regex; - bfile_heuristics_t* bfileHeuristics; +typedef struct { + string_list* includeSuffixes; + string_list* excludeSuffixes; + string_list* excludeDirs; + regex_parser* regex; + bfile_heuristics* bfileHeuristics; char fileSeparator; bool recursive; bool matchesOnly; @@ -46,14 +46,14 @@ bool individual_sums; bool count_chars; bool dirsOnly; -} settings_t; +} settings; #ifdef _cplusplus extern "C" { #endif -settings_t* new_settings_t(); -void destroy_settings_t(settings_t*); +settings* new_settings(); +void destroy_settings(settings*); #ifdef _cplusplus }
--- a/src/string_list.c Thu Jul 02 10:22:33 2026 +0200 +++ b/src/string_list.c Thu Jul 02 12:44:29 2026 +0200 @@ -31,8 +31,8 @@ static void do_not_free(void* item) { } -string_list_t* new_string_list_t() { - string_list_t* stringList = malloc(sizeof(string_list_t)); +string_list* new_string_list() { + string_list* stringList = malloc(sizeof(string_list)); stringList->count = 0; stringList->capacity = 32; stringList->items = calloc(sizeof(char*), stringList->capacity); @@ -41,7 +41,7 @@ return stringList; } -void destroy_string_list_t(string_list_t* list) { +void destroy_string_list(string_list* list) { if (list) { if (list->items) { for (size_t i = 0 ; i < list->count ; i++) { @@ -53,7 +53,7 @@ } } -void add_string(string_list_t* list, char* item) { +void add_string(string_list* list, char* item) { assert(list != NULL); if (list->count < list->capacity) { list->items[list->count++] = item;
--- a/src/string_list.h Thu Jul 02 10:22:33 2026 +0200 +++ b/src/string_list.h Thu Jul 02 12:44:29 2026 +0200 @@ -29,20 +29,20 @@ #include "stdinc.h" -typedef struct string_list_s { +typedef struct { size_t count; size_t capacity; char** items; void (*free_item)(void*); -} string_list_t; +} string_list; #ifdef _cplusplus extern "C" { #endif -string_list_t* new_string_list_t(); -void destroy_string_list_t(string_list_t*); -void add_string(string_list_t*, char*); +string_list* new_string_list(); +void destroy_string_list(string_list*); +void add_string(string_list*, char*); #ifdef _cplusplus }