Skip to content

Commit

Permalink
Hiệu chỉnh công cụ merge: Sử dụng gvec_create_full
Browse files Browse the repository at this point in the history
  • Loading branch information
bangoc committed Sep 24, 2022
1 parent 638a5b2 commit 8e93c1c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mega-unit/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct gvector *read_lines(const char *fname) {
if (!fp) {
return NULL;
}
struct gvector *lines = gvec_create(100, gtype_free_s);
struct gvector *lines = gvec_create_full(0, 100, gtype_zero, gtype_free_s);
char *tmp = NULL;
while (cgetline(&tmp, NULL, fp)) {
remove_tail_lf(tmp);
Expand Down Expand Up @@ -78,7 +78,7 @@ void process(const char *root, const char *list_name, const char *out_name) {
}

struct rbstree *headers = rbs_create(gtype_cmp_s, gtype_free_s);
struct gvector *contents = gvec_create(1000, gtype_free_s);
struct gvector *contents = gvec_create_full(0, 1000, gtype_zero, gtype_free_s);
char tmp[1024];
gvec_traverse(cur, v) {
if (!is_include(cur->s)) {
Expand Down Expand Up @@ -160,7 +160,12 @@ void process(const char *root, const char *list_name, const char *out_name) {
int main(int argc, char *argv[]) {
if (argc != 5) {
printf("Usage: merge root-dir header-list source-list out-name\n"
"Example: merge ~/git/cgen all.h all.c cgen\n");
"Example: merge ~/git/cgen all.h all.c cgen\n"
"Trong đó:\n"
"\t~/git/cgen: Thư mục gốc\n"
"\tall.h: Tên tệp chưa danh sách tệp tiêu đề, đường dẫn tương đối\n"
"\tall.c: Tên tệp chứa danh sách tệp mã nguồn, đường dẫn tương đối\n"
"\tcgen: Tiền tố của các tệp đầu ra (.c và .h)\n");
return 1;
}
const char *root = argv[1],
Expand Down

0 comments on commit 8e93c1c

Please sign in to comment.