Skip to content

Commit

Permalink
Renamed ParsedLanguage->language to ParsedLanguage->name.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchell committed May 23, 2009
1 parent 86d0fab commit 9db411d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/parsed_language.c
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/sourcefile.c
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -244,17 +244,17 @@ 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);
iter = iter->next;
}
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);
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/structs.h
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions test/unit/parser_test.h
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/sourcefile_test.h
Expand Up @@ -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);
}
Expand Down

0 comments on commit 9db411d

Please sign in to comment.