5 * Created by Jason Allen on 6/26/06.
6 * Copyright 2006 Ohloh. All rights reserved.
13 * language_breakdown_initialize
15 * sets up the blank buffers...
18 void language_breakdown_initialize(LanguageBreakdown *lb, char *name, int buffer_size) {
19 strcpy(lb->name, name);
20 lb->code = lb->code_cur = malloc(buffer_size);
22 lb->comment = lb->comment_cur = malloc(buffer_size);
28 * language_breakdown_free
30 * frees the buffers allocated by a language_breakdown
33 void language_breakdown_free(LanguageBreakdown *lb) {
35 if (lb->code == NULL || lb->comment == NULL) {
36 log0("freeing language_breakdown twice!");
46 char * first_non_blank(char *from, char *to) {
47 while (from < to && (*from == ' ' || *from == '\t')) {
54 * language_breakdown_copy_code
56 * copies the passed in string (via delimiters) to the code buffer
59 void language_breakdown_copy_code(LanguageBreakdown *lb, char *from, char *to) {
60 from = first_non_blank(from, to);
61 strncpy(lb->code_cur, from, to - from);
62 lb->code_cur += to - from;
67 * language_breakdown_copy_comment
69 * copies the passed in string (via delimiters) to the comment buffer
72 void language_breakdown_copy_comment(LanguageBreakdown *lb, char *from, char *to) {
73 from = first_non_blank(from, to);
74 strncpy(lb->comment_cur, from, to - from);
75 lb->comment_cur += to - from;