use b_plain use cz/vars use cz/parse use cz/brace use cz/number_lines use cz/rm_comments_blank use cz/contlines use cz/split_semicolons use cz/split_use use cz/split_vars use cz/includes use cz/expand_macros use cz/pc use cz/meta use cz/protos use cz/typedefs use cz/header use cz/process use cz/strip char use_b[] = "use b" char add_main[] = "Main:" boolean cz_translate_compile() boolean ok = 1 if !opt("clean") clean() FILE *log = Fopen(log_file, "w+") stdio_redirect(stderr, log) try(x) translate() if !opt("translate") compile() except(x) warn_errors() ok = 0 Fflush(stderr) if file_size(log_file) rewind(log) fcp(log, stderr) Fclose(log) return ok translate() boolean ok = 1 tofree_block() try(x) vecclr(lines) ; vecclr(work) if opt("useb") vec_push_cstr(lines, use_b) if opt("addmain") vec_push_cstr(lines, add_main) src_file_data = read_lines(lines, src_file) if opt("addmain") for_vec(i, lines, cstr) cstr l = *i if l == use_b || l == add_main: continue cstr t = Malloc(strlen(l)+1) *t = '\t' strcpy(t+1, l) *i = t if cz_line_numbers number_lines(src_file) b2b1() if opt("b1file") write_lines(lines, b1_file) F_out(c_file) brace(lines) except(x) ok = 0 Free(src_file_data) if !ok Throw() b2b1() b2b0() b02b1() b2b0() rm_comments_blank() contlines() split_semicolons() cz_parse() split_use() split_vars() b02b1() cz_includes() # cz_meta is disabled for now, as it can't work yet # cz_meta() cz_expand_macros() cz_processes() cz_wrappers() if cz_standalone cz_strip() cz_pc() cz_protos() cz_typedefs() cz_uniq() cz_shuffle() # ok = !Systemlu("<", q(src_file), "brace_number_lines", "|", "b2b1", ">", q(b1_file)) boolean cz_create_header() boolean ok = 1 tofree_block() try(x) vecclr(lines) ; vecclr(work) if opt("useb") vec_push_cstr(lines, use_b) if opt("addmain") vec_push_cstr(lines, add_main) src_file_data = read_lines(lines, src_file) if opt("addmain") for_vec(i, lines, cstr) cstr l = *i if l == use_b || l == add_main: continue cstr t = Malloc(strlen(l)+1) *t = '\t' strcpy(t+1, l) *i = t if cz_line_numbers number_lines(src_file) b2bh() write_lines(lines, bh_file) except(x) warn_errors() ok = 0 Free(src_file_data) return ok b2bh() b2b0() b02bh() b02bh() # is this right? several things would be done twice when it's included? if cz_bh_no_macros vecclr(defines) # cz_processes() # cz_wrappers() cz_protos() cz_header() cz_uniq() cz_shuffle() compile() int rv cstr cc = cz_lang == LANG_CXX ? cz_cxx : cz_cc new(cc_args, vec, cstr, 16) vec_append(cc_args, cz_lang == LANG_CXX ? cxxflags : cflags) vec_append(cc_args, ldflags) cstr o_exe = Format("-o%s", exe_file) vec_push_cstr(cc_args, o_exe) vec_push_cstr(cc_args, c_file) vec_push_cstr(cc_args, cz_L_so) vec_append(cc_args, ldlibs) rv = !Systema(cc, vec_to_array(cc_args)) vec_free(cc_args) Free(o_exe) if !rv error("compile failed") clean() each(x, c_file, b1_file, exe_file, log_file) remove(x) if opt("nobackup") each(x, xbak_file, bbak_file, bbak2_file) remove(x)