static int should_extract (struct archive_entry *entry) { const char *path = archive_entry_pathname (entry); if (has_prefix (path, "./")) path += 2; /* Skip these as we're using GLVND on majod > 367*/ if (nvidia_major_version > 367 && (has_prefix (path, "libGL.so") || has_prefix (path, "libEGL.so"))) return 0; if ((has_prefix (path, "lib") || has_prefix (path, "tls/lib"))&& has_suffix (path, ".so." NVIDIA_VERSION)) return 1; if (strcmp (path, "nvidia_icd.json") == 0) { archive_entry_set_pathname (entry, "./vulkan/icd.d/nvidia_icd.json"); return 1; } if (strcmp (path, "10_nvidia.json") == 0) { archive_entry_set_pathname (entry, "./glvnd/egl_vendor.d/10_nvidia.json"); return 1; } return 0; }
decision_proceduret::resultt cvc_dect::read_cvcl_result() { std::ifstream in(temp_result_filename.c_str()); std::string line; while(std::getline(in, line)) { if(has_prefix(line, "Invalid.")) { boolean_assignment.clear(); boolean_assignment.resize(no_boolean_variables); while(std::getline(in, line)) { if(has_prefix(line, "ASSERT ")) read_assert(in, line); } return D_SATISFIABLE; } else if(has_prefix(line, "Valid.")) return D_UNSATISFIABLE; } error() << "Unexpected result from CVC-Lite" << eom; return D_ERROR; }
decision_proceduret::resultt dplib_dect::read_dplib_result() { std::ifstream in(temp_result_filename.c_str()); std::string line; while(std::getline(in, line)) { if(has_prefix(line, "Invalid.")) { dplib_prop.reset_assignment(); while(std::getline(in, line)) { if(has_prefix(line, "ASSERT ")) read_assert(in, line); } return D_SATISFIABLE; } else if(has_prefix(line, "Valid.")) return D_UNSATISFIABLE; } error("Unexpected result from CVC-Lite"); return D_ERROR; }
std::string java_class_loadert::file_to_class_name(const std::string &file) { std::string result=file; // Strip .class. Note that the Java class loader would // not do that. if(has_suffix(result, ".class")) result.resize(result.size()-6); // Strip a "./" prefix. Note that the Java class loader // would not do that. #ifdef _WIN32 while(has_prefix(result, ".\\")) result=std::string(result, 2, std::string::npos); #else while(has_prefix(result, "./")) result=std::string(result, 2, std::string::npos); #endif // slash to dot for(std::string::iterator it=result.begin(); it!=result.end(); it++) if(*it=='/') *it='.'; return result; }
int main(int argc, char* argv[]) { if (argc > 1) { fprintf(stderr, "%s: usage: summarize\n", argv[0]); exit(1); } /* FILE* f = fopen(argv[1], "w"); if (f == NULL) { perror(argv[1]); exit(1); } */ FILE* f = stdout; fprintf(f, "\n==================================================\n"); fprintf(f, "[SUMMARY] Test Summary\n"); fprintf(f, "==================================================\n\n"); size_t len; char* ln; long total = 0; long pass = 0; long fail = 0; long total_total = 0; long total_pass = 0; long total_fail = 0; for(;;) { ln = fgetln(stdin, &len); //if (ln) fprintf(stdout, "%.*s", (int)len, ln); if (ln == NULL || has_prefix(ln, "[TEST]")) { if (total) { print_summary(f, total, pass, fail); } total_total += total; total_pass += pass; total_fail += fail; total = 0; pass = 0; fail = 0; if (ln) { fprintf(f, "%.*s", (int)len, ln); } else { fprintf(f, "[TOTAL]\n"); print_summary(f, total_total, total_pass, total_fail); break; } } else if (has_prefix(ln, "[PASS]")) { ++total; ++pass; } else if (has_prefix(ln, "[FAIL]")) { ++total; ++fail; } } return (total_fail ? EXIT_FAILURE : EXIT_SUCCESS); }
void file_view(const datat &data) { std::ofstream out("file_view.html"); out << "<html>\n<head>\n"; out << "<title>" << html_escape(data.description) << "</title>\n"; out << "<style type=\"text/css\">\n"; out << "/* Source-code listing */\n"; out << "div.file { float: left; padding-right: 20px; }\n"; out << "div.listing { font-size: 3px; width: 150px; height: 400px; overflow-y: scroll; overflow-x: scroll; white-space: pre; }\n"; out << "div.filename { text-align: center; font-size: 14px; width: 150px; }\n"; out << "strong.alarm { font-style: normal; background-color: #ff6633; font-weight: normal; }\n"; out << "/* Description of sw under test */\n"; out << "div.description { float: center; font: 14px \"Trebuchet MS\", Verdana, Arial, Helvetica, sans-serif; width=100%; text-align: center; }\n"; out << "</style>\n"; out << "</head>\n"; out << "<body>\n"; out << "<center><img src=\"http://www.deltacheck.org/deltacheck_logo_small.png\"></center>\n"; out << "<div class=\"description\">\n"; out << html_escape(data.description) << "\n"; out << "</div>\n"; std::set<irep_idt> files; for(datat::propertiest::const_iterator e_it=data.properties.begin(); e_it!=data.properties.end(); e_it++) files.insert(e_it->file); for(std::set<irep_idt>::const_iterator f_it=files.begin(); f_it!=files.end(); f_it++) { if(has_prefix(id2string(*f_it), "/usr/include/")) continue; if(has_prefix(id2string(*f_it), "<builtin-library>")) continue; print_file(data, *f_it, out); } out << "</body>\n</html>\n"; }
void Server::event_handler(struct mg_connection *conn, int ev, void *p) { struct http_message *hm = (struct http_message *) p; if (ev == MG_EV_SSI_CALL) { mbuf_resize(&conn->send_mbuf, conn->send_mbuf.size * 2); std::string resp(conn->send_mbuf.buf, conn->send_mbuf.len); boost::replace_all(resp, "href=\"/", std::string("href=\"") + CONFIG_STRING(m_config, "service.base_location")); boost::replace_all(resp, "src=\"/", std::string("src=\"") + CONFIG_STRING(m_config, "service.base_location")); boost::replace_all(resp, "action=\"/", std::string("action=\"") + CONFIG_STRING(m_config, "service.base_location")); strcpy(conn->send_mbuf.buf, resp.c_str()); mbuf_trim(&conn->send_mbuf); return; } if (ev != MG_EV_HTTP_REQUEST) { return; } hm->uri.p += CONFIG_STRING(m_config, "service.base_location").size() - 1; hm->uri.len -= CONFIG_STRING(m_config, "service.base_location").size() - 1; if (!is_authorized(conn, hm)) { redirect_to(conn, hm, "/login"); } else if (mg_vcmp(&hm->uri, "/authorize") == 0) { authorize(conn, hm); } else if (mg_vcmp(&hm->uri, "/logout") == 0) { serve_logout(conn, hm); // } else if (mg_vcmp(&hm->uri, "/users") == 0) { // serve_users(conn, hm); // } else if (mg_vcmp(&hm->uri, "/users/add") == 0) { // serve_users_add(conn, hm); // } else if (mg_vcmp(&hm->uri, "/users/remove") == 0) { // serve_users_remove(conn, hm); } else if (has_prefix(&hm->uri, "/oauth2")) { serve_oauth2(conn, hm); } else if (has_prefix(&hm->uri, "/api/v1/")) { m_apiServer->handleRequest(this, get_session(hm), conn, hm); } else { if (hm->uri.p[hm->uri.len - 1] != '/') { std::string url(hm->uri.p, hm->uri.len); if (url.find(".") == std::string::npos) { url += "/"; redirect_to(conn, hm, url.c_str()); conn->flags |= MG_F_SEND_AND_CLOSE; return; } } mg_serve_http(conn, hm, s_http_server_opts); } conn->flags |= MG_F_SEND_AND_CLOSE; }
int goto_cc_cmdlinet::get_optnr(const std::string &opt_string) { int optnr; cmdlinet::optiont option; if(has_prefix(opt_string, "--")) // starts with -- ? { if(opt_string.size()==3) // still "short" { option.islong=false; option.optchar=opt_string[2]; optnr=getoptnr(option.optchar); } else { option.islong=true; option.optstring=std::string(opt_string, 2, std::string::npos); option.optchar=0; optnr=getoptnr(option.optstring); } } else if(has_prefix(opt_string, "-")) // starts with - ? { if(opt_string.size()==2) { option.islong=false; option.optchar=opt_string[1]; optnr=getoptnr(option.optchar); } else { option.islong=true; option.optstring=std::string(opt_string, 1, std::string::npos); option.optchar=0; optnr=getoptnr(option.optstring); } } else { assert(false); return -1; } if(optnr==-1) { // new options.push_back(option); return options.size()-1; } return optnr; }
void nondet_static( const namespacet &ns, goto_functionst &goto_functions, const irep_idt &fct_name) { goto_functionst::function_mapt::iterator i_it=goto_functions.function_map.find(fct_name); assert(i_it!=goto_functions.function_map.end()); goto_programt &init=i_it->second.body; Forall_goto_program_instructions(i_it, init) { const goto_programt::instructiont &instruction=*i_it; if(instruction.is_assign()) { const symbol_exprt &sym=to_symbol_expr( to_code_assign(instruction.code).lhs()); // is it a __CPROVER_* variable? if(has_prefix(id2string(sym.get_identifier()), CPROVER_PREFIX)) continue; // static lifetime? if(!ns.lookup(sym.get_identifier()).is_static_lifetime) continue; // constant? if(sym.type().get_bool(ID_C_constant)) continue; i_it=init.insert_before(++i_it); i_it->make_assignment(); i_it->code=code_assignt(sym, side_effect_expr_nondett(sym.type())); i_it->location=instruction.location; i_it->function=instruction.function; } else if(instruction.is_function_call()) { const code_function_callt &fct=to_code_function_call(instruction.code); const symbol_exprt &fsym=to_symbol_expr(fct.function()); if(has_prefix(id2string(fsym.get_identifier()), "c::#ini#")) nondet_static(ns, goto_functions, fsym.get_identifier()); } } }
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { static const struct mg_str api_prefix = MG_MK_STR("/api/v1"); struct http_message *hm = (struct http_message *) ev_data; struct mg_str key; switch (ev) { case MG_EV_HTTP_REQUEST: if (has_prefix(&hm->uri, &api_prefix)) { key.p = hm->uri.p + api_prefix.len; key.len = hm->uri.len - api_prefix.len; if (is_equal(&hm->method, &s_get_method)) { db_op(nc, hm, &key, s_db_handle, API_OP_GET); } else if (is_equal(&hm->method, &s_put_method)) { db_op(nc, hm, &key, s_db_handle, API_OP_SET); } else if (is_equal(&hm->method, &s_delele_method)) { db_op(nc, hm, &key, s_db_handle, API_OP_DEL); } else { mg_printf(nc, "%s", "HTTP/1.0 501 Not Implemented\r\n" "Content-Length: 0\r\n\r\n"); } } else { mg_serve_http(nc, hm, s_http_server_opts); /* Serve static content */ } break; default: break; } }
static struct http_backend *choose_backend_from_list( struct http_message *hm, struct http_backend *backends, int num_backends) { int i; struct ns_str vhost = {"", 0}; const struct ns_str *host = ns_get_http_header(hm, "host"); if (host != NULL) vhost = *host; const char *vhost_end = vhost.p; while (vhost_end < vhost.p + vhost.len && *vhost_end != ':') { vhost_end++; } vhost.len = vhost_end - vhost.p; struct http_backend *chosen = NULL; for (i = 0; i < num_backends; i++) { struct http_backend *be = &backends[i]; if (has_prefix(&hm->uri, be->uri_prefix) && matches_vhost(&vhost, be->vhost) && (chosen == NULL || /* Prefer most specific URI prefixes */ strlen(be->uri_prefix) > strlen(chosen->uri_prefix) || /* Among prefixes of the same length chose the least used. */ (strlen(be->uri_prefix) == strlen(chosen->uri_prefix) && be->usage_counter < chosen->usage_counter))) { chosen = be; } } return chosen; }
void java_bytecode_parsert::get_class_refs_rec(const typet &src) { if(src.id()==ID_code) { const code_typet &ct=to_code_type(src); const typet &rt=ct.return_type(); get_class_refs_rec(rt); for(const auto &p : ct.parameters()) get_class_refs_rec(p.type()); } else if(src.id()==ID_symbol) { irep_idt name=src.get(ID_C_base_name); if(has_prefix(id2string(name), "array[")) { const typet &element_type= static_cast<const typet &>(src.find(ID_C_element_type)); get_class_refs_rec(element_type); } else parse_tree.class_refs.insert(name); } else if(src.id()==ID_struct) { const struct_typet &struct_type=to_struct_type(src); for(const auto &c : struct_type.components()) get_class_refs_rec(c.type()); } else if(src.id()==ID_pointer) get_class_refs_rec(src.subtype()); }
void cvc_dect::read_assert(std::istream &in, std::string &line) { // strip ASSERT line=std::string(line, strlen("ASSERT "), std::string::npos); if(line=="") return; // bit-vector if(line[0]=='(') { // get identifier std::string::size_type pos= line.find(' '); std::string identifier=std::string(line, 1, pos-1); // get value if(!std::getline(in, line)) return; // skip spaces pos=0; while(pos<line.size() && line[pos]==' ') pos++; // get final ")" std::string::size_type pos2=line.rfind(')'); if(pos2==std::string::npos) return; std::string value=std::string(line, pos, pos2-pos); #if 0 std::cout << ">" << identifier << "< = >" << value << "<"; std::cout << std::endl; #endif } else { // boolean bool value=true; if(has_prefix(line, "NOT ")) { line=std::string(line, strlen("NOT "), std::string::npos); value=false; } if(line=="") return; if(line[0]=='l') { unsigned number=unsafe_string2unsigned(line.substr(1)); assert(number<no_boolean_variables); assert(no_boolean_variables==boolean_assignment.size()); boolean_assignment[number]=value; } } }
static void choose_backend(struct ns_connection *nc) { struct http_message hm; struct iobuf *io = &nc->recv_iobuf; int req_len = ns_parse_http(io->buf, io->len, &hm); if (req_len < 0 || (req_len == 0 && io->len >= NS_MAX_HTTP_REQUEST_SIZE)) { /* Invalid, or too large request */ nc->flags |= NSF_CLOSE_IMMEDIATELY; } else if (req_len == 0) { /* Do nothing, request is not yet fully buffered */ } else { /* * Got HTTP request, look which backend to use. Round-robin over the * backends with the same uri_prefix and vhost. */ struct ns_str vhost = *ns_get_http_header(&hm, "host"); const char *vhost_end = vhost.p; while(vhost_end < vhost.p + vhost.len && *vhost_end != ':') { vhost_end++; } vhost.len = vhost_end - vhost.p; int i, chosen = -1; for (i = 0; i < s_num_http_backends; i++) { if (has_prefix(&hm.uri, s_http_backends[i].uri_prefix) && matches_vhost(&vhost, s_http_backends[i].vhost) && (chosen == -1 || s_http_backends[i].usage_counter < s_http_backends[chosen].usage_counter)) { chosen = i; } } if (chosen == -1) { /* No backend with given uri_prefix found, bail out */ ns_printf(nc, "%s%s\r\n", s_error_404, s_content_len_0); } else if (s_http_backends[chosen].redirect != 0) { ns_printf(nc, "HTTP/1.1 302 Found\r\nLocation: %s\r\n\r\n", s_http_backends[chosen].host_port); nc->flags |= NSF_SEND_AND_CLOSE; } else if ((nc->proto_data = ns_connect(nc->mgr, s_http_backends[chosen].host_port, ev_handler)) == NULL) { /* Connection to backend failed */ ns_printf(nc, "%s%s\r\n", s_error_500, s_content_len_0); } else { /* * Forward request to the backend. Note that we can insert extra headers * to pass information to the backend. * Store backend index as user_data for the backend connection. */ ((struct ns_connection *) nc->proto_data)->proto_data = nc; ((struct ns_connection *) nc->proto_data)->user_data = (void *) (long) chosen; s_http_backends[chosen].usage_counter++; ns_send(nc->proto_data, io->buf, io->len); iobuf_remove(io, io->len); } } }
bool has_complete_prefix(bitmask const& m, int num_bits) { for (int i = 0; i < (1 << num_bits); ++i) { if (!has_prefix(m, i, num_bits)) return false; } return true; }
void c_typecheck_baset::do_initializer(symbolt &symbol) { // this one doesn't need initialization if(has_prefix(id2string(symbol.name), CPROVER_PREFIX "constant_infinity")) return; if(symbol.static_lifetime) { if(symbol.value.is_nil()) { const typet &final_type=follow(symbol.type); if(final_type.id()!=ID_incomplete_struct && final_type.id()!=ID_incomplete_array && final_type.id()!=ID_empty) { // zero initializer symbol.value=zero_initializer(symbol.type, symbol.location); symbol.value.set("#zero_initializer", true); } } else { typecheck_expr(symbol.value); do_initializer(symbol.value, symbol.type, true); if(follow(symbol.type).id()==ID_incomplete_array) symbol.type=symbol.value.type(); } } else if(!symbol.is_type) { const typet &final_type=follow(symbol.type); if(final_type.id()==ID_incomplete_c_enum || final_type.id()==ID_c_enum) { if(symbol.is_macro) { // these must have a constant value assert(symbol.value.is_not_nil()); typecheck_expr(symbol.value); locationt location=symbol.value.location(); do_initializer(symbol.value, symbol.type, true); make_constant(symbol.value); } } else if(symbol.value.is_not_nil()) { typecheck_expr(symbol.value); do_initializer(symbol.value, symbol.type, true); if(follow(symbol.type).id()==ID_incomplete_array) symbol.type=symbol.value.type(); } } }
bool pointer_logict::is_dynamic_object(const exprt &expr) const { if(expr.type().get_bool("#dynamic")) return true; if(expr.id()==ID_symbol) if(has_prefix(id2string(to_symbol_expr(expr).get_identifier()), "symex_dynamic::")) return true; return false; }
static bool should_init_symbol(const symbolt &sym) { if(sym.type.id()!=ID_code && sym.is_lvalue && sym.is_state_var && sym.is_static_lifetime && sym.mode==ID_java) return true; return has_prefix(id2string(sym.name), "java::java.lang.String.Literal"); }
void dplib_dect::read_assert(std::istream &in, std::string &line) { // strip ASSERT line=std::string(line, strlen("ASSERT "), std::string::npos); if(line=="") return; // bit-vector if(line[0]=='(') { // get identifier std::string::size_type pos= line.find(' '); std::string identifier=std::string(line, 1, pos-1); // get value if(!str_getline(in, line)) return; // skip spaces pos=0; while(pos<line.size() && line[pos]==' ') pos++; // get final ")" std::string::size_type pos2=line.rfind(')'); if(pos2==std::string::npos) return; std::string value=std::string(line, pos, pos2-pos); std::cout << ">" << identifier << "< = >" << value << "<"; std::cout << std::endl; } else { // boolean tvt value=tvt(true); if(has_prefix(line, "NOT ")) { line=std::string(line, strlen("NOT "), std::string::npos); value=tvt(false); } if(line=="") return; if(line[0]=='l') { unsigned number=atoi(line.c_str()+1); assert(number<dplib_prop.no_variables()); dplib_prop.assignment[number]=value; } } }
void generic_read(struct FI *f, char *filename) { if (filename_corresponds_to_tiffo(filename)) { #ifdef FANCY_TIFF f->tiffo = true; tiff_octaves_init0(f->t, filename, f->megabytes,f->max_octaves); if (f->option_write) f->t->option_write = true; f->w = f->t->i->w; f->h = f->t->i->h; f->pd = f->t->i->spp; f->no = f->t->noctaves; #else assert(false); #endif } else if (!f->option_write && FORCE_GDAL()) { #ifdef FANCY_GDAL f->gdal = true; GDALAllRegister(); char buf[2*FILENAME_MAX]; snprintf(buf, 2*FILENAME_MAX, has_prefix(filename, "http://") || has_prefix(filename, "https://") ? "/vsicurl/%s" : "%s", filename); f->gdal_img = GDALOpen(buf, GA_ReadOnly); fprintf(stderr, "gdal_dataset = %p\n", f->gdal_img); f->pd = GDALGetRasterCount(f->gdal_img); f->w = GDALGetRasterXSize(f->gdal_img); f->h = GDALGetRasterYSize(f->gdal_img); f->no = 1; for (int i = 0; i < f->pd; i++) f->gdal_band[i] = GDALGetRasterBand(f->gdal_img, i+1); #else assert(false); #endif } else { f->x = iio_read_image_float_vec(filename, &f->w, &f->h, &f->pd); f->no = build_pyramid(f, f->max_octaves); snprintf(f->x_filename, FILENAME_MAX, "%s", filename); f->x_changed = false; } }
void load(const gcstring& table) { thedb_create = true; if (table != "") // load a single table { load_table(table); } else // load entire database { const size_t bufsize = 8000; char buf[bufsize]; IstreamFile fin("database.su", "rb"); if (! fin) except("can't open database.su"); fin.getline(buf, bufsize); if (! has_prefix(buf, "Suneido dump 1")) except("invalid file"); if (_access("suneido.db", 0) == 0) { remove("suneido.bak"); verify(0 == rename("suneido.db", "suneido.bak")); } Loading loading; while (fin.getline(buf, bufsize)) { if (has_prefix(buf, "======")) { memcpy(buf, "create", 6); load1(fin, buf); } else except("bad file format"); } verify(!alerts); } }
bool value_sett::field_sensitive( const irep_idt &id, const typet &type, const namespacet &ns) { // we always track fields on these if(has_prefix(id2string(id), "value_set::dynamic_object") || id=="value_set::return_value" || id=="value_set::memory") return true; // otherwise it has to be a struct return ns.follow(type).id()==ID_struct; }
unsigned get_max( const std::string &prefix, const symbol_tablet::symbolst &symbols) { unsigned max_nr=0; forall_symbols(it, symbols) if(has_prefix(id2string(it->first), prefix)) max_nr= std::max(unsafe_c_str2unsigned(it->first.c_str()+prefix.size()), max_nr); return max_nr; }
const ArchiveLoader* ArchiveManager::find_loader_by_magic(const std::string& filename) const { std::string start_of_file = Filesystem::get_magic(filename); // search for a loader that can handle the magic for(const auto& it: m_loader_by_magic) { if (has_prefix(start_of_file, it.first)) { return it.second; } } return nullptr; }
static int find_skip_lines (int fd) { char buffer[1024]; ssize_t size; char *line_start, *line_end, *buffer_end; char *skip_str = NULL; int skip_lines; size = pread (fd, buffer, sizeof buffer - 1, 0); if (size == -1) die_with_error ("read extra data"); buffer[size] = 0; /* Ensure zero termination */ buffer_end = buffer + size; line_start = buffer; while (line_start < buffer_end) { line_end = strchr (line_start, '\n'); if (line_end != NULL) { *line_end = 0; line_end += 1; } else line_end = buffer_end; if (has_prefix (line_start, "skip=")) { skip_str = line_start + 5; break; } line_start = line_end; } if (skip_str == NULL) die ("Can't find skip size"); skip_lines = atoi (skip_str); if (skip_lines == 0) die ("Can't parse skip=%s", skip_str); return skip_lines; }
void c_typecheck_baset::do_initializer(symbolt &symbol) { // this one doesn't need initialization if(has_prefix(id2string(symbol.name), CPROVER_PREFIX "constant_infinity")) return; if(symbol.is_static_lifetime) { if(symbol.value.is_not_nil()) { typecheck_expr(symbol.value); do_initializer(symbol.value, symbol.type, true); // need to adjust size? if(follow(symbol.type).id()==ID_array && to_array_type(follow(symbol.type)).size().is_nil()) symbol.type=symbol.value.type(); } } else if(!symbol.is_type) { if(symbol.is_macro) { // these must have a constant value assert(symbol.value.is_not_nil()); typecheck_expr(symbol.value); source_locationt location=symbol.value.source_location(); do_initializer(symbol.value, symbol.type, true); make_constant(symbol.value); } else if(symbol.value.is_not_nil()) { typecheck_expr(symbol.value); do_initializer(symbol.value, symbol.type, true); // need to adjust size? if(follow(symbol.type).id()==ID_array && to_array_type(follow(symbol.type)).size().is_nil()) symbol.type=symbol.value.type(); } } }
Forall_goto_functions(f_it, goto_functions) { // don't instrument our internal functions if(has_prefix(id2string(f_it->first), CPROVER_PREFIX)) continue; // don't instrument the function to be called, // or otherwise this will be recursive if(f_it->first==id) continue; // patch in a call to `id' at the entry point goto_programt &body=f_it->second.body; goto_programt::targett t= body.insert_before(body.instructions.begin()); t->make_function_call( function_to_call(symbol_table, id, f_it->first)); t->function=f_it->first; }
int load_table(const gcstring& table) { const size_t bufsize = 8000; char buf[bufsize]; IstreamFile fin((table + ".su").str(), "rb"); if (!fin) except("can't open " << table << ".su"); fin.getline(buf, bufsize); if (!has_prefix(buf, "Suneido dump 1")) except("invalid file"); char* buf2 = buf + table.size() + 1; fin.getline(buf2, bufsize); verify(0 == memcmp(buf2, "======", 6)); memcpy(buf, "create ", 7); memcpy(buf + 7, table.ptr(), table.size()); Loading loading; int n = load1(fin, buf); verify(!alerts); return n; }
void var_mapt::init(var_infot &var_info) { if(has_prefix(id2string(var_info.symbol), "symex_dynamic::")) { var_info.kind=var_infot::SHARED; } else { // Check for the presence of va_args std::size_t found=id2string(var_info.symbol).find("::va_arg"); if(found != std::string::npos) { var_info.kind=var_infot::PROCEDURE_LOCAL; } else { const symbolt *symbol=0; if(ns.lookup(var_info.symbol, symbol)) throw "var_mapt::init identifier \"" +id2string(var_info.full_identifier) +"\" lookup in ns failed"; if(symbol->is_static_lifetime) { if(symbol->is_thread_local) var_info.kind=var_infot::THREAD_LOCAL; else var_info.kind=var_infot::SHARED; } else var_info.kind=var_infot::PROCEDURE_LOCAL; } } if(var_info.is_shared()) var_info.number=shared_count++; else var_info.number=local_count++; }
void ConsoleImpl::tab_complete() { const std::vector<std::string>& roottable = get_roottable(); std::vector<std::string> completions; for(std::vector<std::string>::const_iterator i = roottable.begin(); i != roottable.end(); ++i) { if (has_prefix(*i, command_line)) { completions.push_back(*i); } } if (completions.empty()) { // console << "No completions" << std::endl; } else if (completions.size() == 1) { command_line = completions.front(); cursor_pos = command_line.size(); } else { console << "> " << command_line << std::endl; for(std::vector<std::string>::iterator i = completions.begin(); i != completions.end(); ++i) { console << *i << " "; } console << std::endl; command_line = find_longest_prefix(completions); cursor_pos = command_line.size(); } }