diff --git a/src/parsed_language.c b/src/parsed_language.c index 70092cf7..5cf6fdb8 100644 --- a/src/parsed_language.c +++ b/src/parsed_language.c @@ -6,10 +6,10 @@ #include "parsed_language.h" -ParsedLanguage *ohcount_parsed_language_new(const char *language, +ParsedLanguage *ohcount_parsed_language_new(const char *name, int buffer_size) { ParsedLanguage *pl = malloc(sizeof(ParsedLanguage)); - pl->language = language; + pl->name = name; pl->buffer_size = buffer_size; pl->code = malloc(buffer_size + 5); pl->code_p = pl->code; diff --git a/src/sourcefile.c b/src/sourcefile.c index 6834d24c..18f40eb8 100644 --- a/src/sourcefile.c +++ b/src/sourcefile.c @@ -148,7 +148,7 @@ void parser_callback(const char *language, const char *entity, int start, // Has this language been detected before? ParsedLanguageList *iter = list->head; while (iter) { - if (strcmp(iter->pl->language, language) == 0) + if (strcmp(iter->pl->name, language) == 0) break; // yes it has iter = iter->next; } @@ -225,7 +225,7 @@ LocList *ohcount_sourcefile_get_loc_list(SourceFile *sourcefile) { ParsedLanguageList *iter; iter = ohcount_sourcefile_get_parsed_language_list(sourcefile)->head; while (iter) { - Loc *loc = ohcount_loc_new(iter->pl->language, iter->pl->code_count, + Loc *loc = ohcount_loc_new(iter->pl->name, iter->pl->code_count, iter->pl->comments_count, iter->pl->blanks_count, 1); ohcount_loc_list_add_loc(list, loc); @@ -244,7 +244,7 @@ LocDeltaList *ohcount_sourcefile_diff(SourceFile *from, SourceFile *to) { iter = ohcount_sourcefile_get_parsed_language_list(from)->head; while (iter) { LocDelta *delta = ohcount_sourcefile_calc_loc_delta(from, - iter->pl->language, + iter->pl->name, to); ohcount_loc_delta_list_add_loc_delta(list, delta); ohcount_loc_delta_free(delta); @@ -252,9 +252,9 @@ LocDeltaList *ohcount_sourcefile_diff(SourceFile *from, SourceFile *to) { } iter = ohcount_sourcefile_get_parsed_language_list(to)->head; while (iter) { - if (!ohcount_loc_delta_list_get_loc_delta(list, iter->pl->language)) { + if (!ohcount_loc_delta_list_get_loc_delta(list, iter->pl->name)) { LocDelta *delta = ohcount_sourcefile_calc_loc_delta(from, - iter->pl->language, + iter->pl->name, to); ohcount_loc_delta_list_add_loc_delta(list, delta); ohcount_loc_delta_free(delta); @@ -277,7 +277,7 @@ LocDelta *ohcount_sourcefile_calc_loc_delta(SourceFile *from, ParsedLanguageList *iter; iter = ohcount_sourcefile_get_parsed_language_list(from)->head; while (iter) { - if (strcmp(language, iter->pl->language) == 0) { + if (strcmp(language, iter->pl->name) == 0) { from_code = iter->pl->code; from_comments = iter->pl->comments; from_blanks_count = iter->pl->blanks_count; @@ -287,7 +287,7 @@ LocDelta *ohcount_sourcefile_calc_loc_delta(SourceFile *from, } iter = ohcount_sourcefile_get_parsed_language_list(to)->head; while (iter) { - if (strcmp(language, iter->pl->language) == 0) { + if (strcmp(language, iter->pl->name) == 0) { to_code = iter->pl->code; to_comments = iter->pl->comments; to_blanks_count = iter->pl->blanks_count; diff --git a/src/structs.h b/src/structs.h index 98e14fb0..3bd9b67c 100644 --- a/src/structs.h +++ b/src/structs.h @@ -178,7 +178,7 @@ typedef struct LocDeltaListItem { */ typedef struct { /** The parsed language. */ - const char *language; + const char *name; /** The size of the code and comments buffers. */ int buffer_size; diff --git a/test/unit/parser_test.h b/test/unit/parser_test.h index bf69ba61..d4a11f76 100644 --- a/test/unit/parser_test.h +++ b/test/unit/parser_test.h @@ -21,7 +21,7 @@ void test_parser_verify_parse(SourceFile *sf, const char *language, int blanks) { ohcount_sourcefile_parse(sf); ParsedLanguageList *list = ohcount_sourcefile_get_parsed_language_list(sf); - assert(strcmp(list->head->pl->language, language) == 0); + assert(strcmp(list->head->pl->name, language) == 0); assert(strcmp(list->head->pl->code, code) == 0); assert(strcmp(list->head->pl->comments, comments) == 0); assert(list->head->pl->blanks_count == blanks); @@ -35,11 +35,11 @@ void test_parser_verify_parse2(SourceFile *sf, const char *language, int blanks2) { ohcount_sourcefile_parse(sf); ParsedLanguageList *list = ohcount_sourcefile_get_parsed_language_list(sf); - assert(strcmp(list->head->pl->language, language) == 0); + assert(strcmp(list->head->pl->name, language) == 0); assert(strcmp(list->head->pl->code, code) == 0); assert(strcmp(list->head->pl->comments, comments) == 0); assert(list->head->pl->blanks_count == blanks); - assert(strcmp(list->head->next->pl->language, language2) == 0); + assert(strcmp(list->head->next->pl->name, language2) == 0); assert(strcmp(list->head->next->pl->code, code2) == 0); assert(strcmp(list->head->next->pl->comments, comments2) == 0); assert(list->head->next->pl->blanks_count == blanks2); diff --git a/test/unit/sourcefile_test.h b/test/unit/sourcefile_test.h index fee7b4a7..e93eeb64 100644 --- a/test/unit/sourcefile_test.h +++ b/test/unit/sourcefile_test.h @@ -30,7 +30,7 @@ void test_sourcefile_language_breakdowns() { SourceFile *sf = ohcount_sourcefile_new("foo.rb"); ohcount_sourcefile_set_contents(sf, "x = 5"); ParsedLanguageList *list = ohcount_sourcefile_get_parsed_language_list(sf); - assert(strcmp("ruby", list->head->pl->language) == 0); + assert(strcmp("ruby", list->head->pl->name) == 0); assert(strcmp("x = 5", list->head->pl->code) == 0); ohcount_sourcefile_free(sf); }