void mail_header_append (mbox_t *mbox, mbox_mail_t *mail, char *row, size_t rowlen) { char *key, *value; if (isspace(row[0]) && mbox->aux.status != STATUS_NODATA) { /* Part of a previous header */ dstrbuf_insert(mbox->aux.multiline, row, rowlen); } else { mail_header_end(mbox, mail); // store any previous open header. if (parse_trace(&mbox->parse, row, &value)) { /* A new trace field */ mbox->aux.status = STATUS_TRACE; } else if (parse_field(&mbox->parse, row, &key, &value)) { /* A new generic field */ mbox->aux.key = key; mbox->aux.status = STATUS_FIELD; } dstrbuf_insert(mbox->aux.multiline, value, 0); } /* Any other line is considered garbage. */ }
int main(int argc, char* argv[]) { stringtab_init(); pass_opt_t opt; pass_opt_init(&opt); opt.release = true; opt.output = "."; ast_setwidth(get_width()); bool print_program_ast = false; bool print_package_ast = false; opt_state_t s; ponyint_opt_init(args, &s, &argc, argv); bool ok = true; bool print_usage = false; int id; while((id = ponyint_opt_next(&s)) != -1) { switch(id) { case OPT_VERSION: printf("%s [%s] (llvm %s)\n", PONY_VERSION, PONY_BUILD_CONFIG, LLVM_VERSION); return 0; case OPT_DEBUG: opt.release = false; break; case OPT_BUILDFLAG: define_build_flag(s.arg_val); break; case OPT_STRIP: opt.strip_debug = true; break; case OPT_PATHS: package_add_paths(s.arg_val, &opt); break; case OPT_OUTPUT: opt.output = s.arg_val; break; case OPT_LIBRARY: opt.library = true; break; case OPT_RUNTIMEBC: opt.runtimebc = true; break; case OPT_PIC: opt.pic = true; break; case OPT_DOCS: opt.docs = true; break; case OPT_SAFE: if(!package_add_safe(s.arg_val, &opt)) ok = false; break; case OPT_IEEEMATH: opt.ieee_math = true; break; case OPT_CPU: opt.cpu = s.arg_val; break; case OPT_FEATURES: opt.features = s.arg_val; break; case OPT_TRIPLE: opt.triple = s.arg_val; break; case OPT_STATS: opt.print_stats = true; break; case OPT_LINK_ARCH: opt.link_arch = s.arg_val; break; case OPT_LINKER: opt.linker = s.arg_val; break; case OPT_AST: print_program_ast = true; break; case OPT_ASTPACKAGE: print_package_ast = true; break; case OPT_TRACE: parse_trace(true); break; case OPT_WIDTH: ast_setwidth(atoi(s.arg_val)); break; case OPT_IMMERR: errors_set_immediate(opt.check.errors, true); break; case OPT_VERIFY: opt.verify = true; break; case OPT_EXTFUN: opt.extfun = true; break; case OPT_FILENAMES: opt.print_filenames = true; break; case OPT_CHECKTREE: opt.check_tree = true; break; case OPT_BNF: print_grammar(false, true); return 0; case OPT_ANTLR: print_grammar(true, true); return 0; case OPT_ANTLRRAW: print_grammar(true, false); return 0; case OPT_VERBOSE: { int v = atoi(s.arg_val); if (v >= 0 && v <= 4) { opt.verbosity = (verbosity_level)v; } else { ok = false; } } break; case OPT_PASSES: if(!limit_passes(&opt, s.arg_val)) { ok = false; print_usage = true; } break; default: usage(); return -1; } } for(int i = 1; i < argc; i++) { if(argv[i][0] == '-') { printf("Unrecognised option: %s\n", argv[i]); ok = false; print_usage = true; } } #if defined(PLATFORM_IS_WINDOWS) opt.strip_debug = true; #endif if(!ok) { errors_print(opt.check.errors); if(print_usage) usage(); return -1; } if(ponyc_init(&opt)) { if(argc == 1) { ok &= compile_package(".", &opt, print_program_ast, print_package_ast); } else { for(int i = 1; i < argc; i++) ok &= compile_package(argv[i], &opt, print_program_ast, print_package_ast); } } if(!ok && errors_get_count(opt.check.errors) == 0) printf("Error: internal failure not reported\n"); ponyc_shutdown(&opt); pass_opt_done(&opt); return ok ? 0 : -1; }
int main(int argc, char* argv[]) { stringtab_init(); pass_opt_t opt; pass_opt_init(&opt); opt.release = true; opt.output = "."; ast_setwidth(get_width()); bool print_program_ast = false; bool print_package_ast = false; opt_state_t s; opt_init(args, &s, &argc, argv); bool ok = true; bool print_usage = false; int id; while((id = opt_next(&s)) != -1) { switch(id) { case OPT_VERSION: printf("%s\n", PONY_VERSION); return 0; case OPT_DEBUG: opt.release = false; break; case OPT_BUILDFLAG: define_build_flag(s.arg_val); break; case OPT_STRIP: opt.strip_debug = true; break; case OPT_PATHS: package_add_paths(s.arg_val); break; case OPT_OUTPUT: opt.output = s.arg_val; break; case OPT_LIBRARY: opt.library = true; break; case OPT_DOCS: opt.docs = true; break; case OPT_SAFE: if(!package_add_safe(s.arg_val)) ok = false; break; case OPT_IEEEMATH: opt.ieee_math = true; break; case OPT_CPU: opt.cpu = s.arg_val; break; case OPT_FEATURES: opt.features = s.arg_val; break; case OPT_TRIPLE: opt.triple = s.arg_val; break; case OPT_STATS: opt.print_stats = true; break; case OPT_AST: print_program_ast = true; break; case OPT_ASTPACKAGE: print_package_ast = true; break; case OPT_TRACE: parse_trace(true); break; case OPT_WIDTH: ast_setwidth(atoi(s.arg_val)); break; case OPT_IMMERR: error_set_immediate(true); break; case OPT_VERIFY: opt.verify = true; break; case OPT_FILENAMES: opt.print_filenames = true; break; case OPT_CHECKTREE: enable_check_tree(true); break; case OPT_BNF: print_grammar(false, true); return 0; case OPT_ANTLR: print_grammar(true, true); return 0; case OPT_ANTLRRAW: print_grammar(true, false); return 0; case OPT_PASSES: if(!limit_passes(&opt, s.arg_val)) { ok = false; print_usage = true; } break; default: usage(); return -1; } } for(int i = 1; i < argc; i++) { if(argv[i][0] == '-') { printf("Unrecognised option: %s\n", argv[i]); ok = false; print_usage = true; } } #ifdef PLATFORM_IS_WINDOWS opt.strip_debug = true; #endif if(!ok) { print_errors(); if(print_usage) usage(); return -1; } if(package_init(&opt)) { if(argc == 1) { ok &= compile_package(".", &opt, print_program_ast, print_package_ast); } else { for(int i = 1; i < argc; i++) ok &= compile_package(argv[i], &opt, print_program_ast, print_package_ast); } } if(!ok && get_error_count() == 0) printf("Error: internal failure not reported\n"); package_done(&opt); pass_opt_done(&opt); stringtab_done(); return ok ? 0 : -1; }