idx
int64
func
string
target
int64
314,494
PJ_DEF(pj_status_t) pjmedia_sdp_attr_get_rtcp(const pjmedia_sdp_attr *attr, pjmedia_sdp_rtcp_attr *rtcp) { pj_scanner scanner; pj_str_t token; pj_status_t status = -1; PJ_USE_EXCEPTION; PJ_ASSERT_RETURN(pj_strcmp2(&attr->name, "rtcp")==0, PJ_EINVALIDOP); if (attr->value.slen == 0) return PJMEDIA_SDP_EINATTR; init_sdp_parser(); /* fmtp BNF: * a=rtcp:<port> [nettype addrtype address] */ /* The buffer passed to the scanner is not guaranteed to be NULL * terminated, but should be safe. See ticket #2063. */ pj_scan_init(&scanner, (char*)attr->value.ptr, attr->value.slen, PJ_SCAN_AUTOSKIP_WS, &on_scanner_error); /* Init */ rtcp->net_type.slen = rtcp->addr_type.slen = rtcp->addr.slen = 0; /* Parse */ PJ_TRY { /* Get the port */ pj_scan_get(&scanner, &cs_token, &token); rtcp->port = pj_strtoul(&token); /* Have address? */ if (!pj_scan_is_eof(&scanner)) { /* Get network type */ pj_scan_get(&scanner, &cs_token, &rtcp->net_type); /* Get address type */ pj_scan_get(&scanner, &cs_token, &rtcp->addr_type); /* Get the address */ //pj_scan_get(&scanner, &cs_token, &rtcp->addr); pj_scan_get_until_chr(&scanner, "/ \t\r\n", &rtcp->addr); } status = PJ_SUCCESS; } PJ_CATCH_ANY { status = PJMEDIA_SDP_EINRTCP; } PJ_END; pj_scan_fini(&scanner); return status; }
0
234,143
reset_state_machine (int is_stmt) { state_machine_regs.address = 0; state_machine_regs.view = 0; state_machine_regs.op_index = 0; state_machine_regs.file = 1; state_machine_regs.line = 1; state_machine_regs.column = 0; state_machine_regs.is_stmt = is_stmt; state_machine_regs.basic_block = 0; state_machine_regs.end_sequence = 0; state_machine_regs.last_file_entry = 0; }
0
359,434
community_show_all_iterator (struct hash_backet *backet, struct vty *vty) { struct community *com; com = (struct community *) backet->data; vty_out (vty, "[%p] (%ld) %s%s", backet, com->refcnt, community_str (com), VTY_NEWLINE); }
0
462,544
std::shared_ptr<rss_feed> controller::get_feed_by_url(const std::string& feedurl) { for (auto feed : feeds) { if (feedurl == feed->rssurl()) return feed; } LOG(level::ERROR, "controller:get_feed_by_url failed for %s", feedurl); return std::shared_ptr<rss_feed>(); }
0
336,135
static void ip6gre_tnl_parm_from_user(struct __ip6_tnl_parm *p, const struct ip6_tnl_parm2 *u) { p->laddr = u->laddr; p->raddr = u->raddr; p->flags = u->flags; p->hop_limit = u->hop_limit; p->encap_limit = u->encap_limit; p->flowinfo = u->flowinfo; p->link = u->link; p->i_key = u->i_key; p->o_key = u->o_key; p->i_flags = gre_flags_to_tnl_flags(u->i_flags); p->o_flags = gre_flags_to_tnl_flags(u->o_flags); memcpy(p->name, u->name, sizeof(u->name)); }
0
417,071
mp_uint32 PlayerGeneric::getSyncSampleCounter() const { if (player) return player->getSyncSampleCounter(); return 0; }
0
513,032
TYPELIB *get_typelib() const { return ref ? (*ref)->get_typelib() : NULL; }
0
223,462
static void check_str_end(compiler_common *common, jump_list **end_reached) { /* Does not affect registers. Usually used in a tight spot. */ DEFINE_COMPILER; struct sljit_jump *jump; if (common->mode == PCRE2_JIT_COMPLETE) { add_jump(compiler, end_reached, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0)); return; } jump = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0); if (common->mode == PCRE2_JIT_PARTIAL_SOFT) { add_jump(compiler, end_reached, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0)); OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, 0); add_jump(compiler, end_reached, JUMP(SLJIT_JUMP)); } else { add_jump(compiler, end_reached, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0)); if (common->partialmatchlabel != NULL) JUMPTO(SLJIT_JUMP, common->partialmatchlabel); else add_jump(compiler, &common->partialmatch, JUMP(SLJIT_JUMP)); } JUMPHERE(jump); }
0
234,832
static int balance_kthread(void *data) { struct btrfs_fs_info *fs_info = data; int ret = 0; mutex_lock(&fs_info->balance_mutex); if (fs_info->balance_ctl) ret = btrfs_balance(fs_info, fs_info->balance_ctl, NULL); mutex_unlock(&fs_info->balance_mutex); return ret; }
0
459,169
static void tc_block_indr_cleanup(struct flow_block_cb *block_cb) { struct tcf_block *block = block_cb->indr.data; struct net_device *dev = block_cb->indr.dev; struct Qdisc *sch = block_cb->indr.sch; struct netlink_ext_ack extack = {}; struct flow_block_offload bo = {}; tcf_block_offload_init(&bo, dev, sch, FLOW_BLOCK_UNBIND, block_cb->indr.binder_type, &block->flow_block, tcf_block_shared(block), &extack); rtnl_lock(); down_write(&block->cb_lock); list_del(&block_cb->driver_list); list_move(&block_cb->list, &bo.cb_list); tcf_block_unbind(block, &bo); up_write(&block->cb_lock); rtnl_unlock(); }
0
509,574
void maria_end_backup() { translog_enable_purge(); }
0
252,349
mz_ulong mz_compressBound(mz_ulong source_len) { return mz_deflateBound(NULL, source_len); }
0
300,835
static int __tipc_nl_add_sk_publ(struct sk_buff *skb, struct netlink_callback *cb, struct publication *publ) { void *hdr; struct nlattr *attrs; hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, &tipc_genl_family, NLM_F_MULTI, TIPC_NL_PUBL_GET); if (!hdr) goto msg_cancel; attrs = nla_nest_start_noflag(skb, TIPC_NLA_PUBL); if (!attrs) goto genlmsg_cancel; if (nla_put_u32(skb, TIPC_NLA_PUBL_KEY, publ->key)) goto attr_msg_cancel; if (nla_put_u32(skb, TIPC_NLA_PUBL_TYPE, publ->sr.type)) goto attr_msg_cancel; if (nla_put_u32(skb, TIPC_NLA_PUBL_LOWER, publ->sr.lower)) goto attr_msg_cancel; if (nla_put_u32(skb, TIPC_NLA_PUBL_UPPER, publ->sr.upper)) goto attr_msg_cancel; nla_nest_end(skb, attrs); genlmsg_end(skb, hdr); return 0; attr_msg_cancel: nla_nest_cancel(skb, attrs); genlmsg_cancel: genlmsg_cancel(skb, hdr); msg_cancel: return -EMSGSIZE; }
0
231,659
explicit FakeServerHandshake( QuicServerConnectionState& conn, std::shared_ptr<FizzServerQuicHandshakeContext> fizzContext, bool chloSync = false, bool cfinSync = false, folly::Optional<uint64_t> clientActiveConnectionIdLimit = folly::none) : FizzServerHandshake(&conn, std::move(fizzContext)), conn_(conn), chloSync_(chloSync), cfinSync_(cfinSync), clientActiveConnectionIdLimit_(clientActiveConnectionIdLimit) {}
0
254,883
void DocumentSourceGroup::addAccumulator(AccumulationStatement accumulationStatement) { _accumulatedFields.push_back(accumulationStatement); }
0
393,467
static SQInteger closure_setroot(HSQUIRRELVM v) { if(SQ_FAILED(sq_setclosureroot(v,-2))) return SQ_ERROR; return 1; }
0
512,643
Item_cache_year(THD *thd, const Type_handler *handler) :Item_cache_int(thd, handler) { }
0
317,236
static int selinux_perf_event_open(struct perf_event_attr *attr, int type) { u32 requested, sid = current_sid(); if (type == PERF_SECURITY_OPEN) requested = PERF_EVENT__OPEN; else if (type == PERF_SECURITY_CPU) requested = PERF_EVENT__CPU; else if (type == PERF_SECURITY_KERNEL) requested = PERF_EVENT__KERNEL; else if (type == PERF_SECURITY_TRACEPOINT) requested = PERF_EVENT__TRACEPOINT; else return -EINVAL; return avc_has_perm(&selinux_state, sid, sid, SECCLASS_PERF_EVENT, requested, NULL); }
0
234,830
int btrfs_forget_devices(const char *path) { int ret; mutex_lock(&uuid_mutex); ret = btrfs_free_stale_devices(strlen(path) ? path : NULL, NULL); mutex_unlock(&uuid_mutex); return ret; }
0
512,836
Item_cache(THD *thd): Item(thd), Type_handler_hybrid_field_type(&type_handler_string), example(0), cached_field(0), value_cached(0), used_table_map(0) { maybe_null= 1; null_value= 1; null_value_inside= true; }
0
336,625
RedCharDeviceVDIPort::read_one_msg_from_device() { RedsState *reds; int n; reds = get_server(); while (reds->vdagent) { switch (priv->read_state) { case VDI_PORT_READ_STATE_READ_HEADER: n = read(priv->receive_pos, priv->receive_len); if (!n) { return RedPipeItemPtr(); } if ((priv->receive_len -= n)) { priv->receive_pos += n; return RedPipeItemPtr(); } priv->message_receive_len = priv->vdi_chunk_header.size; priv->read_state = VDI_PORT_READ_STATE_GET_BUFF; /* fall through */ case VDI_PORT_READ_STATE_GET_BUFF: { if (!(priv->current_read_buf = vdi_port_get_read_buf(this))) { return RedPipeItemPtr(); } priv->receive_pos = priv->current_read_buf->data; priv->receive_len = MIN(priv->message_receive_len, sizeof(priv->current_read_buf->data)); priv->current_read_buf->len = priv->receive_len; priv->message_receive_len -= priv->receive_len; priv->read_state = VDI_PORT_READ_STATE_READ_DATA; } /* fall through */ case VDI_PORT_READ_STATE_READ_DATA: { n = read(priv->receive_pos, priv->receive_len); if (!n) { return RedPipeItemPtr(); } if ((priv->receive_len -= n)) { priv->receive_pos += n; break; } auto dispatch_buf = std::move(priv->current_read_buf); priv->receive_pos = NULL; if (priv->message_receive_len == 0) { priv->read_state = VDI_PORT_READ_STATE_READ_HEADER; priv->receive_pos = (uint8_t *)&priv->vdi_chunk_header; priv->receive_len = sizeof(priv->vdi_chunk_header); } else { priv->read_state = VDI_PORT_READ_STATE_GET_BUFF; } switch (vdi_port_read_buf_process(this, *dispatch_buf)) { case AGENT_MSG_FILTER_OK: reds_adjust_agent_capabilities(reds, (VDAgentMessage *) dispatch_buf->data); return dispatch_buf; case AGENT_MSG_FILTER_PROTO_ERROR: reds_agent_remove(reds); /* fall through */ case AGENT_MSG_FILTER_MONITORS_CONFIG: /* fall through */ case AGENT_MSG_FILTER_DISCARD: dispatch_buf.reset(); } } } /* END switch */ } /* END while */ return RedPipeItemPtr(); }
0
405,374
static u32 xfrm_pol_bin_key(const void *data, u32 len, u32 seed) { const struct xfrm_pol_inexact_key *k = data; u32 a = k->type << 24 | k->dir << 16 | k->family; return jhash_3words(a, k->if_id, net_hash_mix(read_pnet(&k->net)), seed); }
0
220,235
Graph::Graph(const FunctionLibraryDefinition& flib_def) : Graph(flib_def.default_registry()) { // Need a new-enough consumer to support the functions we add to the graph. if (flib_def.num_functions() > 0 && versions_->min_consumer() < 12) { versions_->set_min_consumer(12); } Status s = ops_.AddLibrary(flib_def); CHECK(s.ok()) << s.error_message(); }
0
270,393
void ok_inflater_set_input(ok_inflater *inflater, const uint8_t *buffer, size_t buffer_length) { if (inflater) { if (inflater->input == inflater->input_end) { inflater->input = buffer; inflater->input_end = inflater->input + buffer_length; } else { ok_inflater_error(inflater, "ok_inflater_set_input was called with unread input data."); } } }
0
244,355
GF_Box *extr_box_new() { ISOM_DECL_BOX_ALLOC(GF_ExtraDataBox, GF_ISOM_BOX_TYPE_EXTR); return (GF_Box *)tmp; }
0
512,303
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) { bool res= m_value.to_TIME(thd, ltime, fuzzydate); DBUG_ASSERT(!res); return res; }
0
405,393
xfrm_policy_eval_candidates(struct xfrm_pol_inexact_candidates *cand, struct xfrm_policy *prefer, const struct flowi *fl, u8 type, u16 family, int dir, u32 if_id) { struct xfrm_policy *tmp; int i; for (i = 0; i < ARRAY_SIZE(cand->res); i++) { tmp = __xfrm_policy_eval_candidates(cand->res[i], prefer, fl, type, family, dir, if_id); if (!tmp) continue; if (IS_ERR(tmp)) return tmp; prefer = tmp; } return prefer; }
0
197,511
void HierarchicalBitmapRequester::PrepareForDecoding(void) { #if ACCUSOFT_CODE UBYTE i; BuildCommon(); if (m_ppDecodingMCU == NULL) { m_ppDecodingMCU = (struct Line **)m_pEnviron->AllocMem(sizeof(struct Line *) * m_ucCount*8); memset(m_ppDecodingMCU,0,sizeof(struct Line *) * m_ucCount * 8); } if (m_ppUpsampler == NULL) { m_ppUpsampler = (class UpsamplerBase **)m_pEnviron->AllocMem(sizeof(class UpsamplerBase *) * m_ucCount); memset(m_ppUpsampler,0,sizeof(class Upsampler *) * m_ucCount); for(i = 0;i < m_ucCount;i++) { class Component *comp = m_pFrame->ComponentOf(i); UBYTE sx = comp->SubXOf(); UBYTE sy = comp->SubYOf(); if (sx > 1 || sy > 1) { m_ppUpsampler[i] = UpsamplerBase::CreateUpsampler(m_pEnviron,sx,sy, m_ulPixelWidth,m_ulPixelHeight, m_pFrame->TablesOf()->isChromaCentered()); m_bSubsampling = true; } } } if (m_pLargestScale) m_pLargestScale->PrepareForDecoding(); #endif }
1
437,685
static inline u16 freq_to_clock_divider(unsigned int freq, unsigned int rollovers) { return count_to_clock_divider( DIV_ROUND_CLOSEST(CX23888_IR_REFCLK_FREQ, freq * rollovers)); }
0
273,103
murmur_hash64(const void *key, int len, uint32_t seed) { const int r = 24; const uint32_t m = 0x5bd1e995; const uint32_t *data; const unsigned char *data_tail; uint32_t k1; uint32_t h1; uint32_t k2; uint32_t h2; uint64_t h; h1 = seed ^ len; h2 = 0; data = (const uint32_t *)key; while (len >= 8) { k1 = *data++; k1 *= m; k1 ^= k1 >> r; k1 *= m; h1 *= m; h1 ^= k1; k2 = *data++; k2 *= m; k2 ^= k2 >> r; k2 *= m; h2 *= m; h2 ^= k2; len -= 8; } if (len >= 4) { k1 = *data++; k1 *= m; k1 ^= k1 >> r; k1 *= m; h1 *= m; h1 ^= k1; len -= 4; } data_tail = (const unsigned char *)data; switch(len) { case 3: h2 ^= (uint32_t)(data_tail[2]) << 16; case 2: h2 ^= (uint32_t)(data_tail[1]) << 8; case 1: h2 ^= (uint32_t)(data_tail[0]); h2 *= m; }; h1 ^= h2 >> 18; h1 *= m; h2 ^= h1 >> 22; h2 *= m; h1 ^= h2 >> 17; h1 *= m; h2 ^= h1 >> 19; h2 *= m; h = h1; h = (h << 32) | h2; return h; }
0
424,915
void iwl_trans_pcie_free(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); int i; iwl_pcie_synchronize_irqs(trans); if (trans->trans_cfg->gen2) iwl_pcie_gen2_tx_free(trans); else iwl_pcie_tx_free(trans); iwl_pcie_rx_free(trans); if (trans_pcie->rba.alloc_wq) { destroy_workqueue(trans_pcie->rba.alloc_wq); trans_pcie->rba.alloc_wq = NULL; } if (trans_pcie->msix_enabled) { for (i = 0; i < trans_pcie->alloc_vecs; i++) { irq_set_affinity_hint( trans_pcie->msix_entries[i].vector, NULL); } trans_pcie->msix_enabled = false; } else { iwl_pcie_free_ict(trans); } iwl_pcie_free_fw_monitor(trans); for_each_possible_cpu(i) { struct iwl_tso_hdr_page *p = per_cpu_ptr(trans_pcie->tso_hdr_page, i); if (p->page) __free_page(p->page); } free_percpu(trans_pcie->tso_hdr_page); mutex_destroy(&trans_pcie->mutex); iwl_trans_free(trans); }
0
246,687
static GF_Err do_export_tracks() { GF_Err e; u32 i; char szFile[GF_MAX_PATH+24]; GF_MediaExporter mdump; for (i=0; i<nb_track_act; i++) { u32 j; TrackAction *tka = &tracks[i]; if (tka->act_type != TRAC_ACTION_RAW_EXTRACT) continue; memset(&mdump, 0, sizeof(mdump)); mdump.file = file; mdump.flags = tka->dump_type; mdump.trackID = tka->trackID; mdump.sample_num = tka->sample_num; if (tka->out_name) { mdump.out_name = tka->out_name; } else if (outName) { mdump.out_name = outName; mdump.flags |= GF_EXPORT_MERGE; /*don't infer extension on user-given filename*/ mdump.flags |= GF_EXPORT_NO_FILE_EXT; } else if (mdump.trackID) { sprintf(szFile, "%s_track%d", outfile, mdump.trackID); mdump.out_name = szFile; } else { sprintf(szFile, "%s_export", outfile); mdump.out_name = szFile; } if (tka->trackID==(u32) -1) { for (j=0; j<gf_isom_get_track_count(file); j++) { mdump.trackID = gf_isom_get_track_id(file, j+1); sprintf(szFile, "%s_track%d", outfile, mdump.trackID); mdump.out_name = szFile; mdump.print_stats_graph = fs_dump_flags; e = gf_media_export(&mdump); if (e) return e; } } else { mdump.print_stats_graph = fs_dump_flags; e = gf_media_export(&mdump); if (e) return e; } } return GF_OK; }
0
343,265
static void clearargs(int argc, char **argv) { #ifndef NO_PROCNAME_CHANGE # if defined(__linux__) && !defined(HAVE_SETPROCTITLE) int i; char *first = NULL; char *next = NULL; for (i = 0; i < argc; i++) { if (first == NULL) { first = argv[i]; } if (next == NULL || argv[i] == next + 1) { next = argv[i] + strlen(argv[i]); } } for (i = 0; environ[i] != NULL; i++) { if (first == NULL) { first = argv[i]; } if (next == NULL) { next = argv[i] + strlen(argv[i]); } } if (first == NULL || next == NULL) { return; } argv_lth = next - first; argv0 = argv; if (environ != NULL) { char **new_environ; unsigned int env_nb = 0U; while (environ[env_nb] != NULL) { env_nb++; } if ((new_environ = malloc((1U + env_nb) * sizeof (char *))) == NULL) { abort(); } new_environ[env_nb] = NULL; while (env_nb > 0U) { env_nb--; new_environ[env_nb] = strdup(environ[env_nb]); } environ = new_environ; } # else (void) argc; (void) argv; # endif #endif }
0
328,969
R_API RBinJavaAttrInfo *r_bin_java_constant_value_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) { ut64 offset = 6; RBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset); if (attr) { attr->type = R_BIN_JAVA_ATTR_TYPE_CONST_VALUE_ATTR; if (offset + 4 < sz) { attr->info.constant_value_attr.constantvalue_idx = R_BIN_JAVA_USHORT (buffer, offset); } offset += 2; attr->size = offset; } // IFDBG r_bin_java_print_constant_value_attr_summary(attr); return attr; }
0
463,151
static void annotation_get_usercounters(annotate_state_t *state, struct annotate_entry_list *entry) { struct buf value = BUF_INITIALIZER; struct mboxname_counters counters; char *mboxname = NULL; assert(state); assert(state->userid); mboxname = mboxname_user_mbox(state->userid, NULL); int r = mboxname_read_counters(mboxname, &counters); if (!r) buf_printf(&value, "%u %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %u", counters.version, counters.highestmodseq, counters.mailmodseq, counters.caldavmodseq, counters.carddavmodseq, counters.notesmodseq, counters.mailfoldersmodseq, counters.caldavfoldersmodseq, counters.carddavfoldersmodseq, counters.notesfoldersmodseq, counters.quotamodseq, counters.raclmodseq, counters.uidvalidity); output_entryatt(state, entry->name, state->userid, &value); free(mboxname); buf_free(&value); }
0
231,711
void setOneRttKeys() { // Mimic ServerHandshake behavior. // oneRttWriteCipher would already be set during ReportEarlyHandshakeSuccess if (!allowZeroRttKeys_) { oneRttWriteCipher_ = createNoOpAead(); oneRttWriteHeaderCipher_ = createNoOpHeaderCipher(); } oneRttReadCipher_ = createNoOpAead(); oneRttReadHeaderCipher_ = createNoOpHeaderCipher(); }
0
328,872
R_API char *r_bin_java_print_string_cp_stringify(RBinJavaCPTypeObj *obj) { ut32 size = 255, consumed = 0; char *value = malloc (size); if (value) { memset (value, 0, size); consumed = snprintf (value, size, "%d.0x%04"PFMT64x ".%s.%d", obj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name, obj->info.cp_string.string_idx); if (consumed >= size - 1) { free (value); size += size >> 1; value = malloc (size); if (value) { memset (value, 0, size); (void)snprintf (value, size, "%d.0x%04"PFMT64x ".%s.%d", obj->metas->ord, obj->file_offset, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name, obj->info.cp_string.string_idx); } } } return value; }
0
231,747
TEST_P( QuicServerTransportHandshakeTest, TestConnectionSetupWithoutSourceTokenInPsk) { serverCtx->setSendNewSessionTicket(false); expectedSourceToken_ = {clientAddr.getIPAddress()}; testSetupConnection(); }
0
333,083
nfa_dump(nfa_regprog_T *prog) { FILE *debugf = fopen(NFA_REGEXP_DUMP_LOG, "a"); if (debugf != NULL) { nfa_print_state(debugf, prog->start); if (prog->reganch) fprintf(debugf, "reganch: %d\n", prog->reganch); if (prog->regstart != NUL) fprintf(debugf, "regstart: %c (decimal: %d)\n", prog->regstart, prog->regstart); if (prog->match_text != NULL) fprintf(debugf, "match_text: \"%s\"\n", prog->match_text); fclose(debugf); } }
0
139,246
void OverlayWindowViews::TogglePlayPause() { bool is_active = controller_->TogglePlayPause(); play_pause_controls_view_->SetToggled(is_active); }
0
231,055
UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) { UBaseType_t uxReturn; configASSERT( xQueue ); taskENTER_CRITICAL(); { uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting; } taskEXIT_CRITICAL(); return uxReturn; } /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */
0
247,565
TEST_P(SslSocketTest, RsaPrivateKeyProviderAsyncSignFailure) { const std::string server_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_cert.pem" private_key_provider: provider_name: test typed_config: "@type": type.googleapis.com/google.protobuf.Struct value: private_key_file: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_key.pem" expected_operation: sign sync_mode: false crypto_error: true mode: rsa validation_context: trusted_ca: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.pem" crl: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.crl" )EOF"; const std::string failing_client_ctx_yaml = R"EOF( common_tls_context: tls_params: cipher_suites: - ECDHE-RSA-AES128-GCM-SHA256 )EOF"; TestUtilOptions failing_test_options(failing_client_ctx_yaml, server_ctx_yaml, false, GetParam()); testUtil(failing_test_options.setPrivateKeyMethodExpected(true).setExpectedServerStats( "ssl.connection_error")); }
0
204,036
int hw_atl_utils_fw_rpc_wait(struct aq_hw_s *self, struct hw_atl_utils_fw_rpc **rpc) { struct aq_hw_atl_utils_fw_rpc_tid_s sw; struct aq_hw_atl_utils_fw_rpc_tid_s fw; int err = 0; do { sw.val = aq_hw_read_reg(self, HW_ATL_RPC_CONTROL_ADR); self->rpc_tid = sw.tid; err = readx_poll_timeout_atomic(hw_atl_utils_rpc_state_get, self, fw.val, sw.tid == fw.tid, 1000U, 100000U); if (err < 0) goto err_exit; err = aq_hw_err_from_flags(self); if (err < 0) goto err_exit; if (fw.len == 0xFFFFU) { err = hw_atl_utils_fw_rpc_call(self, sw.len); if (err < 0) goto err_exit; } } while (sw.tid != fw.tid || 0xFFFFU == fw.len); if (rpc) { if (fw.len) { err = hw_atl_utils_fw_downld_dwords(self, self->rpc_addr, (u32 *)(void *) &self->rpc, (fw.len + sizeof(u32) - sizeof(u8)) / sizeof(u32)); if (err < 0) goto err_exit; } *rpc = &self->rpc; } err_exit: return err; }
1
248,328
DLLIMPORT int cfg_opt_nprint_var(cfg_opt_t *opt, unsigned int index, FILE *fp) { const char *str; if (!opt || !fp) { errno = EINVAL; return CFG_FAIL; } switch (opt->type) { case CFGT_INT: fprintf(fp, "%ld", cfg_opt_getnint(opt, index)); break; case CFGT_FLOAT: fprintf(fp, "%f", cfg_opt_getnfloat(opt, index)); break; case CFGT_STR: str = cfg_opt_getnstr(opt, index); fprintf(fp, "\""); while (str && *str) { if (*str == '"') fprintf(fp, "\\\""); else if (*str == '\\') fprintf(fp, "\\\\"); else fprintf(fp, "%c", *str); str++; } fprintf(fp, "\""); break; case CFGT_BOOL: fprintf(fp, "%s", cfg_opt_getnbool(opt, index) ? "true" : "false"); break; case CFGT_NONE: case CFGT_SEC: case CFGT_FUNC: case CFGT_PTR: case CFGT_COMMENT: break; } return CFG_SUCCESS; }
0
225,409
int v4l2_ctrl_handler_init(struct v4l2_ctrl_handler *hdl, unsigned nr_of_controls_hint) { hdl->error = 0; return 0; }
0
231,050
QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t * pxStaticQueue ) { QueueHandle_t xNewQueue; const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0; /* Prevent compiler warnings about unused parameters if * configUSE_TRACE_FACILITY does not equal 1. */ ( void ) ucQueueType; xNewQueue = xQueueGenericCreateStatic( uxMutexLength, uxMutexSize, NULL, pxStaticQueue, ucQueueType ); prvInitialiseMutex( ( Queue_t * ) xNewQueue ); return xNewQueue; }
0
225,605
GF_Box *tfdt_box_new() { ISOM_DECL_BOX_ALLOC(GF_TFBaseMediaDecodeTimeBox, GF_ISOM_BOX_TYPE_TFDT); return (GF_Box *)tmp;
0
424,957
static int iwl_dbgfs_monitor_data_open(struct inode *inode, struct file *file) { struct iwl_trans *trans = inode->i_private; struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); if (!trans->dbg.dest_tlv || trans->dbg.dest_tlv->monitor_mode != EXTERNAL_MODE) { IWL_ERR(trans, "Debug destination is not set to DRAM\n"); return -ENOENT; } if (trans_pcie->fw_mon_data.state != IWL_FW_MON_DBGFS_STATE_CLOSED) return -EBUSY; trans_pcie->fw_mon_data.state = IWL_FW_MON_DBGFS_STATE_OPEN; return simple_open(inode, file); }
0
217,547
int64_t GmfOpenMesh(const char *FilNam, int mod, ...) { int KwdCod, res, *PtrVer, *PtrDim, err; int64_t MshIdx; char str[ GmfStrSiz ]; va_list VarArg; GmfMshSct *msh; /*---------------------*/ /* MESH STRUCTURE INIT */ /*---------------------*/ if(!(msh = calloc(1, sizeof(GmfMshSct)))) return(0); MshIdx = (int64_t)msh; // Save the current stack environment for longjmp if( (err = setjmp(msh->err)) != 0) { #ifdef GMFDEBUG printf("libMeshb : mesh %p : error %d\n", msh, err); #endif if(msh->hdl != NULL) fclose(msh->hdl); if(msh->FilDes != 0) #ifdef GMF_WINDOWS _close(msh->FilDes); #else close(msh->FilDes); #endif free(msh); return(0); } // Copy the FilNam into the structure if(strlen(FilNam) + 7 >= GmfStrSiz) longjmp(msh->err, -4); strcpy(msh->FilNam, FilNam); // Store the opening mod (read or write) and guess // the filetype (binary or ascii) depending on the extension msh->mod = mod; msh->buf = (void *)msh->DblBuf; msh->FltBuf = (void *)msh->DblBuf; msh->IntBuf = (void *)msh->DblBuf; if(strstr(msh->FilNam, ".meshb")) msh->typ |= (Bin | MshFil); else if(strstr(msh->FilNam, ".mesh")) msh->typ |= (Asc | MshFil); else if(strstr(msh->FilNam, ".solb")) msh->typ |= (Bin | SolFil); else if(strstr(msh->FilNam, ".sol")) msh->typ |= (Asc | SolFil); else longjmp(msh->err, -5); // Open the file in the required mod and initialize the mesh structure if(msh->mod == GmfRead) { /*-----------------------*/ /* OPEN FILE FOR READING */ /*-----------------------*/ va_start(VarArg, mod); PtrVer = va_arg(VarArg, int *); PtrDim = va_arg(VarArg, int *); va_end(VarArg); // Read the endian coding tag, the mesh version // and the mesh dimension (mandatory kwd) if(msh->typ & Bin) { // Create the name string and open the file #ifdef WITH_GMF_AIO // [Bruno] added binary flag (necessary under Windows) msh->FilDes = open(msh->FilNam, OPEN_READ_FLAGS, OPEN_READ_MODE); if(msh->FilDes <= 0) longjmp(msh->err, -6); // Read the endian coding tag if(read(msh->FilDes, &msh->cod, WrdSiz) != WrdSiz) longjmp(msh->err, -7); #else // [Bruno] added binary flag (necessary under Windows) if(!(msh->hdl = fopen(msh->FilNam, "rb"))) longjmp(msh->err, -8); // Read the endian coding tag safe_fread(&msh->cod, WrdSiz, 1, msh->hdl, msh->err); #endif // Read the mesh version and the mesh dimension (mandatory kwd) if( (msh->cod != 1) && (msh->cod != 16777216) ) longjmp(msh->err, -9); ScaWrd(msh, (unsigned char *)&msh->ver); if( (msh->ver < 1) || (msh->ver > 4) ) longjmp(msh->err, -10); if( (msh->ver >= 3) && (sizeof(int64_t) != 8) ) longjmp(msh->err, -11); ScaWrd(msh, (unsigned char *)&KwdCod); if(KwdCod != GmfDimension) longjmp(msh->err, -12); GetPos(msh); ScaWrd(msh, (unsigned char *)&msh->dim); } else { // Create the name string and open the file if(!(msh->hdl = fopen(msh->FilNam, "rb"))) longjmp(msh->err, -13); do { res = fscanf(msh->hdl, "%s", str); }while( (res != EOF) && strcmp(str, "MeshVersionFormatted") ); if(res == EOF) longjmp(msh->err, -14); safe_fscanf(msh->hdl, "%d", &msh->ver, msh->err); if( (msh->ver < 1) || (msh->ver > 4) ) longjmp(msh->err, -15); do { res = fscanf(msh->hdl, "%s", str); }while( (res != EOF) && strcmp(str, "Dimension") ); if(res == EOF) longjmp(msh->err, -16); safe_fscanf(msh->hdl, "%d", &msh->dim, msh->err); } if( (msh->dim != 2) && (msh->dim != 3) ) longjmp(msh->err, -17); (*PtrVer) = msh->ver; (*PtrDim) = msh->dim; // Set default real numbers size if(msh->ver == 1) msh->FltSiz = 32; else msh->FltSiz = 64; /*------------*/ /* KW READING */ /*------------*/ // Read the list of kw present in the file if(!ScaKwdTab(msh)) return(0); return(MshIdx); } else if(msh->mod == GmfWrite) { /*-----------------------*/ /* OPEN FILE FOR WRITING */ /*-----------------------*/ msh->cod = 1; // Check if the user provided a valid version number and dimension va_start(VarArg, mod); msh->ver = va_arg(VarArg, int); msh->dim = va_arg(VarArg, int); va_end(VarArg); if( (msh->ver < 1) || (msh->ver > 4) ) longjmp(msh->err, -18); if( (msh->ver >= 3) && (sizeof(int64_t) != 8) ) longjmp(msh->err, -19); if( (msh->dim != 2) && (msh->dim != 3) ) longjmp(msh->err, -20); // Set default real numbers size if(msh->ver == 1) msh->FltSiz = 32; else msh->FltSiz = 64; // Create the mesh file if(msh->typ & Bin) { /* * [Bruno] replaced previous call to creat(): * with a call to open(), because Windows needs the * binary flag to be specified. */ #ifdef WITH_GMF_AIO msh->FilDes = open(msh->FilNam, OPEN_WRITE_FLAGS, OPEN_WRITE_MODE); if(msh->FilDes <= 0) longjmp(msh->err, -21); #else if(!(msh->hdl = fopen(msh->FilNam, "wb"))) longjmp(msh->err, -22); #endif } else if(!(msh->hdl = fopen(msh->FilNam, "wb"))) longjmp(msh->err, -23); /*------------*/ /* KW WRITING */ /*------------*/ // Write the mesh version and dimension if(msh->typ & Asc) { fprintf(msh->hdl, "%s %d\n\n", GmfKwdFmt[ GmfVersionFormatted ][0], msh->ver); fprintf(msh->hdl, "%s %d\n", GmfKwdFmt[ GmfDimension ][0], msh->dim); } else { RecWrd(msh, (unsigned char *)&msh->cod); RecWrd(msh, (unsigned char *)&msh->ver); GmfSetKwd(MshIdx, GmfDimension, 0); RecWrd(msh, (unsigned char *)&msh->dim); } return(MshIdx); } else { free(msh); return(0); } }
1
477,374
R_API char *r_bin_java_print_utf8_cp_stringify(RBinJavaCPTypeObj *obj) { ut32 size = 255, consumed = 0; char *utf8_str = r_hex_bin2strdup (obj->info.cp_utf8.bytes, obj->info.cp_utf8.length); char *value = malloc (size + strlen (utf8_str)); if (value) { memset (value, 0, size); consumed = snprintf (value, size, "%d.0x%04"PFMT64x ".%s.%d.%s", obj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name, obj->info.cp_utf8.length, utf8_str); if (consumed >= size - 1) { free (value); size += size >> 1; value = malloc (size + strlen (utf8_str)); if (value) { memset (value, 0, size); (void)snprintf (value, size, "%d.0x%04"PFMT64x ".%s.%d.%s", obj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name, obj->info.cp_utf8.length, utf8_str); } } } free (utf8_str); return value; }
0
452,259
PHP_FALIAS(getSecurityPrefs, xsl_xsltprocessor_get_security_prefs, arginfo_xsl_xsltprocessor_get_security_prefs) {NULL, NULL, NULL}
0
508,905
bool LEX::need_correct_ident() { switch(sql_command) { case SQLCOM_SHOW_CREATE: case SQLCOM_SHOW_TABLES: case SQLCOM_CREATE_VIEW: return TRUE; default: return FALSE; } }
0
336,527
static void reds_mig_remove_wait_disconnect_client(RedsState *reds, RedClient *client) { auto &clients(reds->mig_wait_disconnect_clients); g_warn_if_fail(std::find(clients.begin(), clients.end(), client) != clients.end()); clients.remove(client); if (clients.empty()) { reds_mig_cleanup(reds); } }
0
312,400
existing_swapfile(buf_T *buf) { if (buf->b_ml.ml_mfp != NULL && buf->b_ml.ml_mfp->mf_fname != NULL) { char_u *fname = buf->b_ml.ml_mfp->mf_fname; size_t len = STRLEN(fname); return fname[len - 1] != 'p' || fname[len - 2] != 'w'; } return FALSE; }
0
328,972
R_API void r_bin_java_get_interface_json_definitions(RBinJavaObj *bin, PJ *pj) { RList *the_list; RListIter *iter = NULL; char *new_str; pj_ka (pj, "interfaces"); if (!bin || !(the_list = r_bin_java_get_interface_names (bin))) { pj_end (pj); return; } r_list_foreach (the_list, iter, new_str) { char *tmp = new_str; // eprintf ("Processing string: %s\n", new_str); while (*tmp) { if (*tmp == '/') { *tmp = '.'; } tmp++; } pj_s (pj, new_str); } r_list_free (the_list); pj_end (pj); }
0
393,527
static SQInteger array_reverse(HSQUIRRELVM v) { return SQ_SUCCEEDED(sq_arrayreverse(v,-1)) ? 1 : SQ_ERROR; }
0
369,182
static void io_poll_cancel_req(struct io_kiocb *req) { io_poll_mark_cancelled(req); /* kick tw, which should complete the request */ io_poll_execute(req, 0, 0);
0
352,995
csnValidate( Syntax *syntax, struct berval *in ) { struct berval bv; char *ptr; int rc; assert( in != NULL ); if ( BER_BVISNULL( in ) || BER_BVISEMPTY( in ) ) { return LDAP_INVALID_SYNTAX; } bv = *in; ptr = ber_bvchr( &bv, '#' ); if ( ptr == NULL || ptr == &bv.bv_val[bv.bv_len] ) { return LDAP_INVALID_SYNTAX; } bv.bv_len = ptr - bv.bv_val; if ( bv.bv_len != STRLENOF( "YYYYmmddHHMMSS.uuuuuuZ" ) && bv.bv_len != STRLENOF( "YYYYmmddHHMMSSZ" ) ) { return LDAP_INVALID_SYNTAX; } rc = generalizedTimeValidate( NULL, &bv ); if ( rc != LDAP_SUCCESS ) { return rc; } bv.bv_val = ptr + 1; bv.bv_len = in->bv_len - ( bv.bv_val - in->bv_val ); ptr = ber_bvchr( &bv, '#' ); if ( ptr == NULL || ptr == &in->bv_val[in->bv_len] ) { return LDAP_INVALID_SYNTAX; } bv.bv_len = ptr - bv.bv_val; if ( bv.bv_len != 6 ) { return LDAP_INVALID_SYNTAX; } rc = hexValidate( NULL, &bv ); if ( rc != LDAP_SUCCESS ) { return rc; } bv.bv_val = ptr + 1; bv.bv_len = in->bv_len - ( bv.bv_val - in->bv_val ); ptr = ber_bvchr( &bv, '#' ); if ( ptr == NULL || ptr == &in->bv_val[in->bv_len] ) { return LDAP_INVALID_SYNTAX; } bv.bv_len = ptr - bv.bv_val; if ( bv.bv_len == 2 ) { /* tolerate old 2-digit replica-id */ rc = hexValidate( NULL, &bv ); } else { rc = sidValidate( NULL, &bv ); } if ( rc != LDAP_SUCCESS ) { return rc; } bv.bv_val = ptr + 1; bv.bv_len = in->bv_len - ( bv.bv_val - in->bv_val ); if ( bv.bv_len != 6 ) { return LDAP_INVALID_SYNTAX; } return hexValidate( NULL, &bv ); }
0
225,456
Status MutationError(absl::string_view function_name, absl::string_view params, absl::string_view msg) { return errors::InvalidArgument(absl::Substitute( "MutableGraphView::$0($1) error: $2.", function_name, params, msg)); }
0
220,109
static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t len) { struct inode *inode = file_inode(filep); long ret; if (!S_ISREG(inode->i_mode)) return -EOPNOTSUPP; if ((mode != 0) && (mode != (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE))) return -EOPNOTSUPP; ret = inode_newsize_ok(inode, offset + len); if (ret < 0) return ret; if (mode & FALLOC_FL_PUNCH_HOLE) return nfs42_proc_deallocate(filep, offset, len); return nfs42_proc_allocate(filep, offset, len); }
0
269,509
static int TIFFReadPixels(TIFF *tiff,const tsample_t sample, const ssize_t row,tdata_t scanline) { int status; status=TIFFReadScanline(tiff,scanline,(uint32) row,sample); return(status); }
0
197,135
ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) { struct ccp_aes_engine *aes = &cmd->u.aes; struct ccp_dm_workarea key, ctx, final_wa, tag; struct ccp_data src, dst; struct ccp_data aad; struct ccp_op op; unsigned int dm_offset; unsigned int authsize; unsigned int jobid; unsigned int ilen; bool in_place = true; /* Default value */ __be64 *final; int ret; struct scatterlist *p_inp, sg_inp[2]; struct scatterlist *p_tag, sg_tag[2]; struct scatterlist *p_outp, sg_outp[2]; struct scatterlist *p_aad; if (!aes->iv) return -EINVAL; if (!((aes->key_len == AES_KEYSIZE_128) || (aes->key_len == AES_KEYSIZE_192) || (aes->key_len == AES_KEYSIZE_256))) return -EINVAL; if (!aes->key) /* Gotta have a key SGL */ return -EINVAL; /* Zero defaults to 16 bytes, the maximum size */ authsize = aes->authsize ? aes->authsize : AES_BLOCK_SIZE; switch (authsize) { case 16: case 15: case 14: case 13: case 12: case 8: case 4: break; default: return -EINVAL; } /* First, decompose the source buffer into AAD & PT, * and the destination buffer into AAD, CT & tag, or * the input into CT & tag. * It is expected that the input and output SGs will * be valid, even if the AAD and input lengths are 0. */ p_aad = aes->src; p_inp = scatterwalk_ffwd(sg_inp, aes->src, aes->aad_len); p_outp = scatterwalk_ffwd(sg_outp, aes->dst, aes->aad_len); if (aes->action == CCP_AES_ACTION_ENCRYPT) { ilen = aes->src_len; p_tag = scatterwalk_ffwd(sg_tag, p_outp, ilen); } else { /* Input length for decryption includes tag */ ilen = aes->src_len - authsize; p_tag = scatterwalk_ffwd(sg_tag, p_inp, ilen); } jobid = CCP_NEW_JOBID(cmd_q->ccp); memset(&op, 0, sizeof(op)); op.cmd_q = cmd_q; op.jobid = jobid; op.sb_key = cmd_q->sb_key; /* Pre-allocated */ op.sb_ctx = cmd_q->sb_ctx; /* Pre-allocated */ op.init = 1; op.u.aes.type = aes->type; /* Copy the key to the LSB */ ret = ccp_init_dm_workarea(&key, cmd_q, CCP_AES_CTX_SB_COUNT * CCP_SB_BYTES, DMA_TO_DEVICE); if (ret) return ret; dm_offset = CCP_SB_BYTES - aes->key_len; ret = ccp_set_dm_area(&key, dm_offset, aes->key, 0, aes->key_len); if (ret) goto e_key; ret = ccp_copy_to_sb(cmd_q, &key, op.jobid, op.sb_key, CCP_PASSTHRU_BYTESWAP_256BIT); if (ret) { cmd->engine_error = cmd_q->cmd_error; goto e_key; } /* Copy the context (IV) to the LSB. * There is an assumption here that the IV is 96 bits in length, plus * a nonce of 32 bits. If no IV is present, use a zeroed buffer. */ ret = ccp_init_dm_workarea(&ctx, cmd_q, CCP_AES_CTX_SB_COUNT * CCP_SB_BYTES, DMA_BIDIRECTIONAL); if (ret) goto e_key; dm_offset = CCP_AES_CTX_SB_COUNT * CCP_SB_BYTES - aes->iv_len; ret = ccp_set_dm_area(&ctx, dm_offset, aes->iv, 0, aes->iv_len); if (ret) goto e_ctx; ret = ccp_copy_to_sb(cmd_q, &ctx, op.jobid, op.sb_ctx, CCP_PASSTHRU_BYTESWAP_256BIT); if (ret) { cmd->engine_error = cmd_q->cmd_error; goto e_ctx; } op.init = 1; if (aes->aad_len > 0) { /* Step 1: Run a GHASH over the Additional Authenticated Data */ ret = ccp_init_data(&aad, cmd_q, p_aad, aes->aad_len, AES_BLOCK_SIZE, DMA_TO_DEVICE); if (ret) goto e_ctx; op.u.aes.mode = CCP_AES_MODE_GHASH; op.u.aes.action = CCP_AES_GHASHAAD; while (aad.sg_wa.bytes_left) { ccp_prepare_data(&aad, NULL, &op, AES_BLOCK_SIZE, true); ret = cmd_q->ccp->vdata->perform->aes(&op); if (ret) { cmd->engine_error = cmd_q->cmd_error; goto e_aad; } ccp_process_data(&aad, NULL, &op); op.init = 0; } } op.u.aes.mode = CCP_AES_MODE_GCTR; op.u.aes.action = aes->action; if (ilen > 0) { /* Step 2: Run a GCTR over the plaintext */ in_place = (sg_virt(p_inp) == sg_virt(p_outp)) ? true : false; ret = ccp_init_data(&src, cmd_q, p_inp, ilen, AES_BLOCK_SIZE, in_place ? DMA_BIDIRECTIONAL : DMA_TO_DEVICE); if (ret) goto e_ctx; if (in_place) { dst = src; } else { ret = ccp_init_data(&dst, cmd_q, p_outp, ilen, AES_BLOCK_SIZE, DMA_FROM_DEVICE); if (ret) goto e_src; } op.soc = 0; op.eom = 0; op.init = 1; while (src.sg_wa.bytes_left) { ccp_prepare_data(&src, &dst, &op, AES_BLOCK_SIZE, true); if (!src.sg_wa.bytes_left) { unsigned int nbytes = ilen % AES_BLOCK_SIZE; if (nbytes) { op.eom = 1; op.u.aes.size = (nbytes * 8) - 1; } } ret = cmd_q->ccp->vdata->perform->aes(&op); if (ret) { cmd->engine_error = cmd_q->cmd_error; goto e_dst; } ccp_process_data(&src, &dst, &op); op.init = 0; } } /* Step 3: Update the IV portion of the context with the original IV */ ret = ccp_copy_from_sb(cmd_q, &ctx, op.jobid, op.sb_ctx, CCP_PASSTHRU_BYTESWAP_256BIT); if (ret) { cmd->engine_error = cmd_q->cmd_error; goto e_dst; } ret = ccp_set_dm_area(&ctx, dm_offset, aes->iv, 0, aes->iv_len); if (ret) goto e_dst; ret = ccp_copy_to_sb(cmd_q, &ctx, op.jobid, op.sb_ctx, CCP_PASSTHRU_BYTESWAP_256BIT); if (ret) { cmd->engine_error = cmd_q->cmd_error; goto e_dst; } /* Step 4: Concatenate the lengths of the AAD and source, and * hash that 16 byte buffer. */ ret = ccp_init_dm_workarea(&final_wa, cmd_q, AES_BLOCK_SIZE, DMA_BIDIRECTIONAL); if (ret) goto e_dst; final = (__be64 *)final_wa.address; final[0] = cpu_to_be64(aes->aad_len * 8); final[1] = cpu_to_be64(ilen * 8); memset(&op, 0, sizeof(op)); op.cmd_q = cmd_q; op.jobid = jobid; op.sb_key = cmd_q->sb_key; /* Pre-allocated */ op.sb_ctx = cmd_q->sb_ctx; /* Pre-allocated */ op.init = 1; op.u.aes.type = aes->type; op.u.aes.mode = CCP_AES_MODE_GHASH; op.u.aes.action = CCP_AES_GHASHFINAL; op.src.type = CCP_MEMTYPE_SYSTEM; op.src.u.dma.address = final_wa.dma.address; op.src.u.dma.length = AES_BLOCK_SIZE; op.dst.type = CCP_MEMTYPE_SYSTEM; op.dst.u.dma.address = final_wa.dma.address; op.dst.u.dma.length = AES_BLOCK_SIZE; op.eom = 1; op.u.aes.size = 0; ret = cmd_q->ccp->vdata->perform->aes(&op); if (ret) goto e_dst; if (aes->action == CCP_AES_ACTION_ENCRYPT) { /* Put the ciphered tag after the ciphertext. */ ccp_get_dm_area(&final_wa, 0, p_tag, 0, authsize); } else { /* Does this ciphered tag match the input? */ ret = ccp_init_dm_workarea(&tag, cmd_q, authsize, DMA_BIDIRECTIONAL); if (ret) goto e_tag; ret = ccp_set_dm_area(&tag, 0, p_tag, 0, authsize); if (ret) goto e_tag; ret = crypto_memneq(tag.address, final_wa.address, authsize) ? -EBADMSG : 0; ccp_dm_free(&tag); } e_tag: ccp_dm_free(&final_wa); e_dst: if (ilen > 0 && !in_place) ccp_free_data(&dst, cmd_q); e_src: if (ilen > 0) ccp_free_data(&src, cmd_q); e_aad: if (aes->aad_len) ccp_free_data(&aad, cmd_q); e_ctx: ccp_dm_free(&ctx); e_key: ccp_dm_free(&key); return ret; }
1
463,174
static void annotation_get_uniqueid(annotate_state_t *state, struct annotate_entry_list *entry) { struct buf value = BUF_INITIALIZER; assert(state->mailbox); if (state->mailbox->uniqueid) buf_appendcstr(&value, state->mailbox->uniqueid); output_entryatt(state, entry->name, "", &value); buf_free(&value); }
0
482,533
compileRule(FileInfo *file, TranslationTableHeader **table, DisplayTableHeader **displayTable, const MacroList **inScopeMacros) { CharsString token; TranslationTableOpcode opcode; CharsString ruleChars; CharsString ruleDots; CharsString cells; CharsString scratchPad; CharsString emphClass; TranslationTableCharacterAttributes after = 0; TranslationTableCharacterAttributes before = 0; int noback, nofor, nocross; noback = nofor = nocross = 0; doOpcode: if (!getToken(file, &token, NULL)) return 1; /* blank line */ if (token.chars[0] == '#' || token.chars[0] == '<') return 1; /* comment */ if (file->lineNumber == 1 && (eqasc2uni((unsigned char *)"ISO", token.chars, 3) || eqasc2uni((unsigned char *)"UTF-8", token.chars, 5))) { if (table) compileHyphenation(file, &token, table); else /* ignore the whole file */ while (_lou_getALine(file)) ; return 1; } opcode = getOpcode(file, &token); switch (opcode) { case CTO_Macro: { const Macro *macro; #ifdef ENABLE_MACROS if (!inScopeMacros) { compileError(file, "Defining macros only allowed in table files."); return 0; } if (compileMacro(file, &macro)) { *inScopeMacros = cons_macro(macro, *inScopeMacros); return 1; } return 0; #else compileError(file, "Macro feature is disabled."); return 0; #endif } case CTO_IncludeFile: { CharsString includedFile; if (!getToken(file, &token, "include file name")) return 0; if (!parseChars(file, &includedFile, &token)) return 0; return includeFile(file, &includedFile, table, displayTable); } case CTO_NoBack: if (nofor) { compileError(file, "%s already specified.", _lou_findOpcodeName(CTO_NoFor)); return 0; } noback = 1; goto doOpcode; case CTO_NoFor: if (noback) { compileError(file, "%s already specified.", _lou_findOpcodeName(CTO_NoBack)); return 0; } nofor = 1; goto doOpcode; case CTO_Space: return compileCharDef( file, opcode, CTC_Space, noback, nofor, table, displayTable); case CTO_Digit: return compileCharDef( file, opcode, CTC_Digit, noback, nofor, table, displayTable); case CTO_LitDigit: return compileCharDef( file, opcode, CTC_LitDigit, noback, nofor, table, displayTable); case CTO_Punctuation: return compileCharDef( file, opcode, CTC_Punctuation, noback, nofor, table, displayTable); case CTO_Math: return compileCharDef(file, opcode, CTC_Math, noback, nofor, table, displayTable); case CTO_Sign: return compileCharDef(file, opcode, CTC_Sign, noback, nofor, table, displayTable); case CTO_Letter: return compileCharDef( file, opcode, CTC_Letter, noback, nofor, table, displayTable); case CTO_UpperCase: return compileCharDef( file, opcode, CTC_UpperCase, noback, nofor, table, displayTable); case CTO_LowerCase: return compileCharDef( file, opcode, CTC_LowerCase, noback, nofor, table, displayTable); case CTO_Grouping: return compileGrouping(file, noback, nofor, table, displayTable); case CTO_Display: if (!displayTable) return 1; // ignore if (!getRuleCharsText(file, &ruleChars)) return 0; if (!getRuleDotsPattern(file, &ruleDots)) return 0; if (ruleChars.length != 1 || ruleDots.length != 1) { compileError(file, "Exactly one character and one cell are required."); return 0; } return putCharDotsMapping( file, ruleChars.chars[0], ruleDots.chars[0], displayTable); case CTO_UpLow: case CTO_None: { // check if token is a macro name if (inScopeMacros) { const MacroList *macros = *inScopeMacros; while (macros) { const Macro *m = macros->head; if (token.length == strlen(m->name) && eqasc2uni((unsigned char *)m->name, token.chars, token.length)) { if (!inScopeMacros) { compileError(file, "Calling macros only allowed in table files."); return 0; } FileInfo tmpFile; memset(&tmpFile, 0, sizeof(tmpFile)); tmpFile.fileName = file->fileName; tmpFile.sourceFile = file->sourceFile; tmpFile.lineNumber = file->lineNumber; tmpFile.encoding = noEncoding; tmpFile.status = 0; tmpFile.linepos = 0; tmpFile.linelen = 0; int argument_count = 0; CharsString *arguments = malloc(m->argument_count * sizeof(CharsString)); while (argument_count < m->argument_count) { if (getToken(file, &token, "macro argument")) arguments[argument_count++] = token; else break; } if (argument_count < m->argument_count) { compileError(file, "Expected %d arguments", m->argument_count); return 0; } int i = 0; int subst = 0; int next = subst < m->substitution_count ? m->substitutions[2 * subst] : m->definition_length; for (;;) { while (i < next) { widechar c = m->definition[i++]; if (c == '\n') { if (!compileRule(&tmpFile, table, displayTable, inScopeMacros)) { _lou_logMessage(LOU_LOG_ERROR, "result of macro expansion was: %s", _lou_showString( tmpFile.line, tmpFile.linelen, 0)); return 0; } tmpFile.linepos = 0; tmpFile.linelen = 0; } else if (tmpFile.linelen >= MAXSTRING) { compileError(file, "Line exceeds %d characters (post macro " "expansion)", MAXSTRING); return 0; } else tmpFile.line[tmpFile.linelen++] = c; } if (subst < m->substitution_count) { CharsString arg = arguments[m->substitutions[2 * subst + 1] - 1]; for (int j = 0; j < arg.length; j++) tmpFile.line[tmpFile.linelen++] = arg.chars[j]; subst++; next = subst < m->substitution_count ? m->substitutions[2 * subst] : m->definition_length; } else { if (!compileRule( &tmpFile, table, displayTable, inScopeMacros)) { _lou_logMessage(LOU_LOG_ERROR, "result of macro expansion was: %s", _lou_showString( tmpFile.line, tmpFile.linelen, 0)); return 0; } break; } } return 1; } macros = macros->tail; } } if (opcode == CTO_UpLow) { compileError(file, "The uplow opcode is deprecated."); return 0; } compileError(file, "opcode %s not defined.", _lou_showString(token.chars, token.length, 0)); return 0; } /* now only opcodes follow that don't modify the display table */ default: if (!table) return 1; switch (opcode) { case CTO_Locale: compileWarning(file, "The locale opcode is not implemented. Use the locale meta data " "instead."); return 1; case CTO_Undefined: { // not passing pointer because compileBrailleIndicator may reallocate table TranslationTableOffset ruleOffset = (*table)->undefined; if (!compileBrailleIndicator(file, "undefined character opcode", CTO_Undefined, &ruleOffset, noback, nofor, table)) return 0; (*table)->undefined = ruleOffset; return 1; } case CTO_Match: { int ok = 0; widechar *patterns = NULL; TranslationTableRule *rule; TranslationTableOffset ruleOffset; CharsString ptn_before, ptn_after; TranslationTableOffset patternsOffset; int len, mrk; size_t patternsByteSize = sizeof(*patterns) * 27720; patterns = (widechar *)malloc(patternsByteSize); if (!patterns) _lou_outOfMemory(); memset(patterns, 0xffff, patternsByteSize); noback = 1; getCharacters(file, &ptn_before); getRuleCharsText(file, &ruleChars); getCharacters(file, &ptn_after); getRuleDotsPattern(file, &ruleDots); if (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, &ruleOffset, &rule, noback, nofor, table)) goto CTO_Match_cleanup; if (ptn_before.chars[0] == '-' && ptn_before.length == 1) len = _lou_pattern_compile( &ptn_before.chars[0], 0, &patterns[1], 13841, *table, file); else len = _lou_pattern_compile(&ptn_before.chars[0], ptn_before.length, &patterns[1], 13841, *table, file); if (!len) goto CTO_Match_cleanup; mrk = patterns[0] = len + 1; _lou_pattern_reverse(&patterns[1]); if (ptn_after.chars[0] == '-' && ptn_after.length == 1) len = _lou_pattern_compile( &ptn_after.chars[0], 0, &patterns[mrk], 13841, *table, file); else len = _lou_pattern_compile(&ptn_after.chars[0], ptn_after.length, &patterns[mrk], 13841, *table, file); if (!len) goto CTO_Match_cleanup; len += mrk; if (!allocateSpaceInTranslationTable( file, &patternsOffset, len * sizeof(widechar), table)) goto CTO_Match_cleanup; // allocateSpaceInTranslationTable may have moved table, so make sure rule is // still valid rule = (TranslationTableRule *)&(*table)->ruleArea[ruleOffset]; memcpy(&(*table)->ruleArea[patternsOffset], patterns, len * sizeof(widechar)); rule->patterns = patternsOffset; ok = 1; CTO_Match_cleanup: free(patterns); return ok; } case CTO_BackMatch: { int ok = 0; widechar *patterns = NULL; TranslationTableRule *rule; TranslationTableOffset ruleOffset; CharsString ptn_before, ptn_after; TranslationTableOffset patternOffset; int len, mrk; size_t patternsByteSize = sizeof(*patterns) * 27720; patterns = (widechar *)malloc(patternsByteSize); if (!patterns) _lou_outOfMemory(); memset(patterns, 0xffff, patternsByteSize); nofor = 1; getCharacters(file, &ptn_before); getRuleCharsText(file, &ruleChars); getCharacters(file, &ptn_after); getRuleDotsPattern(file, &ruleDots); if (!addRule(file, opcode, &ruleChars, &ruleDots, 0, 0, &ruleOffset, &rule, noback, nofor, table)) goto CTO_BackMatch_cleanup; if (ptn_before.chars[0] == '-' && ptn_before.length == 1) len = _lou_pattern_compile( &ptn_before.chars[0], 0, &patterns[1], 13841, *table, file); else len = _lou_pattern_compile(&ptn_before.chars[0], ptn_before.length, &patterns[1], 13841, *table, file); if (!len) goto CTO_BackMatch_cleanup; mrk = patterns[0] = len + 1; _lou_pattern_reverse(&patterns[1]); if (ptn_after.chars[0] == '-' && ptn_after.length == 1) len = _lou_pattern_compile( &ptn_after.chars[0], 0, &patterns[mrk], 13841, *table, file); else len = _lou_pattern_compile(&ptn_after.chars[0], ptn_after.length, &patterns[mrk], 13841, *table, file); if (!len) goto CTO_BackMatch_cleanup; len += mrk; if (!allocateSpaceInTranslationTable( file, &patternOffset, len * sizeof(widechar), table)) goto CTO_BackMatch_cleanup; // allocateSpaceInTranslationTable may have moved table, so make sure rule is // still valid rule = (TranslationTableRule *)&(*table)->ruleArea[ruleOffset]; memcpy(&(*table)->ruleArea[patternOffset], patterns, len * sizeof(widechar)); rule->patterns = patternOffset; ok = 1; CTO_BackMatch_cleanup: free(patterns); return ok; } case CTO_CapsLetter: case CTO_BegCapsWord: case CTO_EndCapsWord: case CTO_BegCaps: case CTO_EndCaps: case CTO_BegCapsPhrase: case CTO_EndCapsPhrase: case CTO_LenCapsPhrase: /* these 8 general purpose opcodes are compiled further down to more specific * internal opcodes: * - modeletter * - begmodeword * - endmodeword * - begmode * - endmode * - begmodephrase * - endmodephrase * - lenmodephrase */ case CTO_ModeLetter: case CTO_BegModeWord: case CTO_EndModeWord: case CTO_BegMode: case CTO_EndMode: case CTO_BegModePhrase: case CTO_EndModePhrase: case CTO_LenModePhrase: { TranslationTableCharacterAttributes mode; int i; switch (opcode) { case CTO_CapsLetter: case CTO_BegCapsWord: case CTO_EndCapsWord: case CTO_BegCaps: case CTO_EndCaps: case CTO_BegCapsPhrase: case CTO_EndCapsPhrase: case CTO_LenCapsPhrase: mode = CTC_UpperCase; i = 0; opcode += (CTO_ModeLetter - CTO_CapsLetter); break; default: if (!getToken(file, &token, "attribute name")) return 0; if (!(*table)->characterClasses && !allocateCharacterClasses(*table)) { return 0; } const CharacterClass *characterClass = findCharacterClass(&token, *table); if (!characterClass) { characterClass = addCharacterClass(file, token.chars, token.length, *table, 1); if (!characterClass) return 0; } mode = characterClass->attribute; if (!(mode == CTC_UpperCase || mode == CTC_Digit) && mode >= CTC_Space && mode <= CTC_LitDigit) { compileError(file, "mode must be \"uppercase\", \"digit\", or a custom " "attribute name."); return 0; } /* check if this mode is already defined and if the number of modes does * not exceed the maximal number */ if (mode == CTC_UpperCase) i = 0; else { for (i = 1; i < MAX_MODES && (*table)->modes[i].value; i++) { if ((*table)->modes[i].mode == mode) { break; } } if (i == MAX_MODES) { compileError(file, "Max number of modes (%i) reached", MAX_MODES); return 0; } } } if (!(*table)->modes[i].value) (*table)->modes[i] = (EmphasisClass){ plain_text, mode, 0x1 << (MAX_EMPH_CLASSES + i), MAX_EMPH_CLASSES + i }; switch (opcode) { case CTO_BegModePhrase: { // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i][begPhraseOffset]; if (!compileBrailleIndicator(file, "first word capital sign", CTO_BegCapsPhraseRule + (8 * i), &ruleOffset, noback, nofor, table)) return 0; (*table)->emphRules[MAX_EMPH_CLASSES + i][begPhraseOffset] = ruleOffset; return 1; } case CTO_EndModePhrase: { TranslationTableOffset ruleOffset; switch (compileBeforeAfter(file)) { case 1: // before if ((*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseAfterOffset]) { compileError( file, "Capital sign after last word already defined."); return 0; } // not passing pointer because compileBrailleIndicator may reallocate // table ruleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i] [endPhraseBeforeOffset]; if (!compileBrailleIndicator(file, "capital sign before last word", CTO_EndCapsPhraseBeforeRule + (8 * i), &ruleOffset, noback, nofor, table)) return 0; (*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseBeforeOffset] = ruleOffset; return 1; case 2: // after if ((*table)->emphRules[MAX_EMPH_CLASSES + i] [endPhraseBeforeOffset]) { compileError( file, "Capital sign before last word already defined."); return 0; } // not passing pointer because compileBrailleIndicator may reallocate // table ruleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i] [endPhraseAfterOffset]; if (!compileBrailleIndicator(file, "capital sign after last word", CTO_EndCapsPhraseAfterRule + (8 * i), &ruleOffset, noback, nofor, table)) return 0; (*table)->emphRules[MAX_EMPH_CLASSES + i][endPhraseAfterOffset] = ruleOffset; return 1; default: // error compileError(file, "Invalid lastword indicator location."); return 0; } return 0; } case CTO_BegMode: { // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i][begOffset]; if (!compileBrailleIndicator(file, "first letter capital sign", CTO_BegCapsRule + (8 * i), &ruleOffset, noback, nofor, table)) return 0; (*table)->emphRules[MAX_EMPH_CLASSES + i][begOffset] = ruleOffset; return 1; } case CTO_EndMode: { // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i][endOffset]; if (!compileBrailleIndicator(file, "last letter capital sign", CTO_EndCapsRule + (8 * i), &ruleOffset, noback, nofor, table)) return 0; (*table)->emphRules[MAX_EMPH_CLASSES + i][endOffset] = ruleOffset; return 1; } case CTO_ModeLetter: { // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i][letterOffset]; if (!compileBrailleIndicator(file, "single letter capital sign", CTO_CapsLetterRule + (8 * i), &ruleOffset, noback, nofor, table)) return 0; (*table)->emphRules[MAX_EMPH_CLASSES + i][letterOffset] = ruleOffset; return 1; } case CTO_BegModeWord: { // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i][begWordOffset]; if (!compileBrailleIndicator(file, "capital word", CTO_BegCapsWordRule + (8 * i), &ruleOffset, noback, nofor, table)) return 0; (*table)->emphRules[MAX_EMPH_CLASSES + i][begWordOffset] = ruleOffset; return 1; } case CTO_EndModeWord: { // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[MAX_EMPH_CLASSES + i][endWordOffset]; if (!compileBrailleIndicator(file, "capital word stop", CTO_EndCapsWordRule + (8 * i), &ruleOffset, noback, nofor, table)) return 0; (*table)->emphRules[MAX_EMPH_CLASSES + i][endWordOffset] = ruleOffset; return 1; } case CTO_LenModePhrase: return (*table)->emphRules[MAX_EMPH_CLASSES + i][lenPhraseOffset] = compileNumber(file); default: break; } break; } /* these 8 general purpose emphasis opcodes are compiled further down to more * specific internal opcodes: * - emphletter * - begemphword * - endemphword * - begemph * - endemph * - begemphphrase * - endemphphrase * - lenemphphrase */ case CTO_EmphClass: if (!getToken(file, &emphClass, "emphasis class")) { compileError(file, "emphclass must be followed by a valid class name."); return 0; } int k, i; char *s = malloc(sizeof(char) * (emphClass.length + 1)); for (k = 0; k < emphClass.length; k++) s[k] = (char)emphClass.chars[k]; s[k++] = '\0'; for (i = 0; i < MAX_EMPH_CLASSES && (*table)->emphClassNames[i]; i++) if (strcmp(s, (*table)->emphClassNames[i]) == 0) { _lou_logMessage(LOU_LOG_WARN, "Duplicate emphasis class: %s", s); warningCount++; free(s); return 1; } if (i == MAX_EMPH_CLASSES) { _lou_logMessage(LOU_LOG_ERROR, "Max number of emphasis classes (%i) reached", MAX_EMPH_CLASSES); errorCount++; free(s); return 0; } switch (i) { /* For backwards compatibility (i.e. because programs will assume * the first 3 typeform bits are `italic', `underline' and `bold') * we require that the first 3 emphclass definitions are (in that * order): * * emphclass italic * emphclass underline * emphclass bold * * While it would be possible to use the emphclass opcode only for * defining _additional_ classes (not allowing for them to be called * italic, underline or bold), thereby reducing the amount of * boilerplate, we deliberately choose not to do that in order to * not give italic, underline and bold any special status. The * hope is that eventually all programs will use liblouis for * emphasis the recommended way (i.e. by looking up the supported * typeforms in the documentation or API) so that we can drop this * restriction. */ case 0: if (strcmp(s, "italic") != 0) { _lou_logMessage(LOU_LOG_ERROR, "First emphasis class must be \"italic\" but got " "%s", s); errorCount++; free(s); return 0; } break; case 1: if (strcmp(s, "underline") != 0) { _lou_logMessage(LOU_LOG_ERROR, "Second emphasis class must be \"underline\" but " "got " "%s", s); errorCount++; free(s); return 0; } break; case 2: if (strcmp(s, "bold") != 0) { _lou_logMessage(LOU_LOG_ERROR, "Third emphasis class must be \"bold\" but got " "%s", s); errorCount++; free(s); return 0; } break; } (*table)->emphClassNames[i] = s; (*table)->emphClasses[i] = (EmphasisClass){ emph_1 << i, /* relies on the order of typeforms emph_1..emph_10 */ 0, 0x1 << i, i }; return 1; case CTO_EmphLetter: case CTO_BegEmphWord: case CTO_EndEmphWord: case CTO_BegEmph: case CTO_EndEmph: case CTO_BegEmphPhrase: case CTO_EndEmphPhrase: case CTO_LenEmphPhrase: case CTO_EmphModeChars: case CTO_NoEmphChars: { if (!getToken(file, &token, "emphasis class")) return 0; if (!parseChars(file, &emphClass, &token)) return 0; char *s = malloc(sizeof(char) * (emphClass.length + 1)); int k, i; for (k = 0; k < emphClass.length; k++) s[k] = (char)emphClass.chars[k]; s[k++] = '\0'; for (i = 0; i < MAX_EMPH_CLASSES && (*table)->emphClassNames[i]; i++) if (strcmp(s, (*table)->emphClassNames[i]) == 0) break; if (i == MAX_EMPH_CLASSES || !(*table)->emphClassNames[i]) { _lou_logMessage(LOU_LOG_ERROR, "Emphasis class %s not declared", s); errorCount++; free(s); return 0; } int ok = 0; switch (opcode) { case CTO_EmphLetter: { // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[i][letterOffset]; if (!compileBrailleIndicator(file, "single letter", CTO_Emph1LetterRule + letterOffset + (8 * i), &ruleOffset, noback, nofor, table)) break; (*table)->emphRules[i][letterOffset] = ruleOffset; ok = 1; break; } case CTO_BegEmphWord: { // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[i][begWordOffset]; if (!compileBrailleIndicator(file, "word", CTO_Emph1LetterRule + begWordOffset + (8 * i), &ruleOffset, noback, nofor, table)) break; (*table)->emphRules[i][begWordOffset] = ruleOffset; ok = 1; break; } case CTO_EndEmphWord: { // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[i][endWordOffset]; if (!compileBrailleIndicator(file, "word stop", CTO_Emph1LetterRule + endWordOffset + (8 * i), &ruleOffset, noback, nofor, table)) break; (*table)->emphRules[i][endWordOffset] = ruleOffset; ok = 1; break; } case CTO_BegEmph: { /* fail if both begemph and any of begemphphrase or begemphword are * defined */ if ((*table)->emphRules[i][begWordOffset] || (*table)->emphRules[i][begPhraseOffset]) { compileError(file, "Cannot define emphasis for both no context and word or " "phrase context, i.e. cannot have both begemph and " "begemphword or begemphphrase."); break; } // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[i][begOffset]; if (!compileBrailleIndicator(file, "first letter", CTO_Emph1LetterRule + begOffset + (8 * i), &ruleOffset, noback, nofor, table)) break; (*table)->emphRules[i][begOffset] = ruleOffset; ok = 1; break; } case CTO_EndEmph: { if ((*table)->emphRules[i][endWordOffset] || (*table)->emphRules[i][endPhraseBeforeOffset] || (*table)->emphRules[i][endPhraseAfterOffset]) { compileError(file, "Cannot define emphasis for both no context and word or " "phrase context, i.e. cannot have both endemph and " "endemphword or endemphphrase."); break; } // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[i][endOffset]; if (!compileBrailleIndicator(file, "last letter", CTO_Emph1LetterRule + endOffset + (8 * i), &ruleOffset, noback, nofor, table)) break; (*table)->emphRules[i][endOffset] = ruleOffset; ok = 1; break; } case CTO_BegEmphPhrase: { // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[i][begPhraseOffset]; if (!compileBrailleIndicator(file, "first word", CTO_Emph1LetterRule + begPhraseOffset + (8 * i), &ruleOffset, noback, nofor, table)) break; (*table)->emphRules[i][begPhraseOffset] = ruleOffset; ok = 1; break; } case CTO_EndEmphPhrase: switch (compileBeforeAfter(file)) { case 1: { // before if ((*table)->emphRules[i][endPhraseAfterOffset]) { compileError(file, "last word after already defined."); break; } // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[i][endPhraseBeforeOffset]; if (!compileBrailleIndicator(file, "last word before", CTO_Emph1LetterRule + endPhraseBeforeOffset + (8 * i), &ruleOffset, noback, nofor, table)) break; (*table)->emphRules[i][endPhraseBeforeOffset] = ruleOffset; ok = 1; break; } case 2: { // after if ((*table)->emphRules[i][endPhraseBeforeOffset]) { compileError(file, "last word before already defined."); break; } // not passing pointer because compileBrailleIndicator may reallocate // table TranslationTableOffset ruleOffset = (*table)->emphRules[i][endPhraseAfterOffset]; if (!compileBrailleIndicator(file, "last word after", CTO_Emph1LetterRule + endPhraseAfterOffset + (8 * i), &ruleOffset, noback, nofor, table)) break; (*table)->emphRules[i][endPhraseAfterOffset] = ruleOffset; ok = 1; break; } default: // error compileError(file, "Invalid lastword indicator location."); break; } break; case CTO_LenEmphPhrase: if (((*table)->emphRules[i][lenPhraseOffset] = compileNumber(file))) ok = 1; break; case CTO_EmphModeChars: { if (!getRuleCharsText(file, &ruleChars)) break; widechar *emphmodechars = (*table)->emphModeChars[i]; int len; for (len = 0; len < EMPHMODECHARSSIZE && emphmodechars[len]; len++) ; if (len + ruleChars.length > EMPHMODECHARSSIZE) { compileError(file, "More than %d characters", EMPHMODECHARSSIZE); break; } ok = 1; for (int k = 0; k < ruleChars.length; k++) { if (!getChar(ruleChars.chars[k], *table, NULL)) { compileError(file, "Emphasis mode character undefined"); ok = 0; break; } emphmodechars[len++] = ruleChars.chars[k]; } break; } case CTO_NoEmphChars: { if (!getRuleCharsText(file, &ruleChars)) break; widechar *noemphchars = (*table)->noEmphChars[i]; int len; for (len = 0; len < NOEMPHCHARSSIZE && noemphchars[len]; len++) ; if (len + ruleChars.length > NOEMPHCHARSSIZE) { compileError(file, "More than %d characters", NOEMPHCHARSSIZE); break; } ok = 1; for (int k = 0; k < ruleChars.length; k++) { if (!getChar(ruleChars.chars[k], *table, NULL)) { compileError(file, "Character undefined"); ok = 0; break; } noemphchars[len++] = ruleChars.chars[k]; } break; } default: break; } free(s); return ok; } case CTO_LetterSign: { // not passing pointer because compileBrailleIndicator may reallocate table TranslationTableOffset ruleOffset = (*table)->letterSign; if (!compileBrailleIndicator(file, "letter sign", CTO_LetterRule, &ruleOffset, noback, nofor, table)) return 0; (*table)->letterSign = ruleOffset; return 1; } case CTO_NoLetsignBefore: if (!getRuleCharsText(file, &ruleChars)) return 0; if (((*table)->noLetsignBeforeCount + ruleChars.length) > LETSIGNBEFORESIZE) { compileError(file, "More than %d characters", LETSIGNBEFORESIZE); return 0; } for (int k = 0; k < ruleChars.length; k++) (*table)->noLetsignBefore[(*table)->noLetsignBeforeCount++] = ruleChars.chars[k]; return 1; case CTO_NoLetsign: if (!getRuleCharsText(file, &ruleChars)) return 0; if (((*table)->noLetsignCount + ruleChars.length) > LETSIGNSIZE) { compileError(file, "More than %d characters", LETSIGNSIZE); return 0; } for (int k = 0; k < ruleChars.length; k++) (*table)->noLetsign[(*table)->noLetsignCount++] = ruleChars.chars[k]; return 1; case CTO_NoLetsignAfter: if (!getRuleCharsText(file, &ruleChars)) return 0; if (((*table)->noLetsignAfterCount + ruleChars.length) > LETSIGNAFTERSIZE) { compileError(file, "More than %d characters", LETSIGNAFTERSIZE); return 0; } for (int k = 0; k < ruleChars.length; k++) (*table)->noLetsignAfter[(*table)->noLetsignAfterCount++] = ruleChars.chars[k]; return 1; case CTO_NumberSign: { // not passing pointer because compileBrailleIndicator may reallocate table TranslationTableOffset ruleOffset = (*table)->numberSign; if (!compileBrailleIndicator(file, "number sign", CTO_NumberRule, &ruleOffset, noback, nofor, table)) return 0; (*table)->numberSign = ruleOffset; return 1; } case CTO_NumericModeChars: if (!getRuleCharsText(file, &ruleChars)) return 0; for (int k = 0; k < ruleChars.length; k++) { TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL); if (!c) { compileError(file, "Numeric mode character undefined: %s", _lou_showString(&ruleChars.chars[k], 1, 0)); return 0; } c->attributes |= CTC_NumericMode; (*table)->usesNumericMode = 1; } return 1; case CTO_MidEndNumericModeChars: if (!getRuleCharsText(file, &ruleChars)) return 0; for (int k = 0; k < ruleChars.length; k++) { TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL); if (!c) { compileError(file, "Midendnumeric mode character undefined"); return 0; } c->attributes |= CTC_MidEndNumericMode; (*table)->usesNumericMode = 1; } return 1; case CTO_NumericNoContractChars: if (!getRuleCharsText(file, &ruleChars)) return 0; for (int k = 0; k < ruleChars.length; k++) { TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL); if (!c) { compileError(file, "Numeric no contraction character undefined"); return 0; } c->attributes |= CTC_NumericNoContract; (*table)->usesNumericMode = 1; } return 1; case CTO_NoContractSign: { // not passing pointer because compileBrailleIndicator may reallocate table TranslationTableOffset ruleOffset = (*table)->noContractSign; if (!compileBrailleIndicator(file, "no contractions sign", CTO_NoContractRule, &ruleOffset, noback, nofor, table)) return 0; (*table)->noContractSign = ruleOffset; return 1; } case CTO_SeqDelimiter: if (!getRuleCharsText(file, &ruleChars)) return 0; for (int k = 0; k < ruleChars.length; k++) { TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL); if (!c) { compileError(file, "Sequence delimiter character undefined"); return 0; } c->attributes |= CTC_SeqDelimiter; (*table)->usesSequences = 1; } return 1; case CTO_SeqBeforeChars: if (!getRuleCharsText(file, &ruleChars)) return 0; for (int k = 0; k < ruleChars.length; k++) { TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL); if (!c) { compileError(file, "Sequence before character undefined"); return 0; } c->attributes |= CTC_SeqBefore; } return 1; case CTO_SeqAfterChars: if (!getRuleCharsText(file, &ruleChars)) return 0; for (int k = 0; k < ruleChars.length; k++) { TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL); if (!c) { compileError(file, "Sequence after character undefined"); return 0; } c->attributes |= CTC_SeqAfter; } return 1; case CTO_SeqAfterPattern: if (!getRuleCharsText(file, &ruleChars)) return 0; if (((*table)->seqPatternsCount + ruleChars.length + 1) > SEQPATTERNSIZE) { compileError(file, "More than %d characters", SEQPATTERNSIZE); return 0; } for (int k = 0; k < ruleChars.length; k++) (*table)->seqPatterns[(*table)->seqPatternsCount++] = ruleChars.chars[k]; (*table)->seqPatterns[(*table)->seqPatternsCount++] = 0; return 1; case CTO_SeqAfterExpression: if (!getRuleCharsText(file, &ruleChars)) return 0; if ((ruleChars.length + 1) > SEQPATTERNSIZE) { compileError(file, "More than %d characters", SEQPATTERNSIZE); return 0; } for (int k = 0; k < ruleChars.length; k++) (*table)->seqAfterExpression[k] = ruleChars.chars[k]; (*table)->seqAfterExpression[ruleChars.length] = 0; (*table)->seqAfterExpressionLength = ruleChars.length; return 1; case CTO_CapsModeChars: if (!getRuleCharsText(file, &ruleChars)) return 0; for (int k = 0; k < ruleChars.length; k++) { TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL); if (!c) { compileError(file, "Capital mode character undefined"); return 0; } c->attributes |= CTC_CapsMode; (*table)->hasCapsModeChars = 1; } return 1; case CTO_BegComp: { // not passing pointer because compileBrailleIndicator may reallocate table TranslationTableOffset ruleOffset = (*table)->begComp; if (!compileBrailleIndicator(file, "begin computer braille", CTO_BegCompRule, &ruleOffset, noback, nofor, table)) return 0; (*table)->begComp = ruleOffset; return 1; } case CTO_EndComp: { // not passing pointer because compileBrailleIndicator may reallocate table TranslationTableOffset ruleOffset = (*table)->endComp; if (!compileBrailleIndicator(file, "end computer braslle", CTO_EndCompRule, &ruleOffset, noback, nofor, table)) return 0; (*table)->endComp = ruleOffset; return 1; } case CTO_NoCross: if (nocross) { compileError( file, "%s already specified.", _lou_findOpcodeName(CTO_NoCross)); return 0; } nocross = 1; goto doOpcode; case CTO_Syllable: (*table)->syllables = 1; case CTO_Always: case CTO_LargeSign: case CTO_WholeWord: case CTO_PartWord: case CTO_JoinNum: case CTO_JoinableWord: case CTO_LowWord: case CTO_SuffixableWord: case CTO_PrefixableWord: case CTO_BegWord: case CTO_BegMidWord: case CTO_MidWord: case CTO_MidEndWord: case CTO_EndWord: case CTO_PrePunc: case CTO_PostPunc: case CTO_BegNum: case CTO_MidNum: case CTO_EndNum: case CTO_Repeated: case CTO_RepWord: if (!getRuleCharsText(file, &ruleChars)) return 0; if (!getRuleDotsPattern(file, &ruleDots)) return 0; if (ruleDots.length == 0) // check that all characters in a rule with `=` as second operand are // defined (or based on another character) for (int k = 0; k < ruleChars.length; k++) { TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL); if (!(c && (c->definitionRule || c->basechar))) { compileError(file, "Character %s is not defined", _lou_showString(&ruleChars.chars[k], 1, 0)); return 0; } } TranslationTableRule *r; if (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, &r, noback, nofor, table)) return 0; if (nocross) r->nocross = 1; return 1; // if (opcode == CTO_MidNum) // { // TranslationTableCharacter *c = getChar(ruleChars.chars[0]); // if(c) // c->attributes |= CTC_NumericMode; // } case CTO_RepEndWord: if (!getRuleCharsText(file, &ruleChars)) return 0; CharsString dots; if (!getToken(file, &dots, "dots,dots operand")) return 0; int len = dots.length; for (int k = 0; k < len - 1; k++) { if (dots.chars[k] == ',') { dots.length = k; if (!parseDots(file, &ruleDots, &dots)) return 0; ruleDots.chars[ruleDots.length++] = ','; k++; if (k == len - 1 && dots.chars[k] == '=') { // check that all characters are defined (or based on another // character) for (int l = 0; l < ruleChars.length; l++) { TranslationTableCharacter *c = getChar(ruleChars.chars[l], *table, NULL); if (!(c && (c->definitionRule || c->basechar))) { compileError(file, "Character %s is not defined", _lou_showString(&ruleChars.chars[l], 1, 0)); return 0; } } } else { CharsString x, y; x.length = 0; while (k < len) x.chars[x.length++] = dots.chars[k++]; if (parseDots(file, &y, &x)) for (int l = 0; l < y.length; l++) ruleDots.chars[ruleDots.length++] = y.chars[l]; } return addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, NULL, noback, nofor, table); } } return 0; case CTO_CompDots: case CTO_Comp6: { TranslationTableOffset ruleOffset; if (!getRuleCharsText(file, &ruleChars)) return 0; if (ruleChars.length != 1) { compileError(file, "first operand must be 1 character"); return 0; } if (nofor || noback) { compileWarning(file, "nofor and noback not allowed on comp6 rules"); } if (!getRuleDotsPattern(file, &ruleDots)) return 0; if (!addRule(file, opcode, &ruleChars, &ruleDots, after, before, &ruleOffset, NULL, noback, nofor, table)) return 0; return 1; } case CTO_ExactDots: if (!getRuleCharsText(file, &ruleChars)) return 0; if (ruleChars.chars[0] != '@') { compileError(file, "The operand must begin with an at sign (@)"); return 0; } for (int k = 1; k < ruleChars.length; k++) scratchPad.chars[k - 1] = ruleChars.chars[k]; scratchPad.length = ruleChars.length - 1; if (!parseDots(file, &ruleDots, &scratchPad)) return 0; return addRule(file, opcode, &ruleChars, &ruleDots, before, after, NULL, NULL, noback, nofor, table); case CTO_CapsNoCont: { TranslationTableOffset ruleOffset; ruleChars.length = 1; ruleChars.chars[0] = 'a'; if (!addRule(file, CTO_CapsNoContRule, &ruleChars, NULL, after, before, &ruleOffset, NULL, noback, nofor, table)) return 0; (*table)->capsNoCont = ruleOffset; return 1; } case CTO_Replace: if (getRuleCharsText(file, &ruleChars)) { if (atEndOfLine(file)) ruleDots.length = ruleDots.chars[0] = 0; else { getRuleDotsText(file, &ruleDots); if (ruleDots.chars[0] == '#') ruleDots.length = ruleDots.chars[0] = 0; else if (ruleDots.chars[0] == '\\' && ruleDots.chars[1] == '#') memmove(&ruleDots.chars[0], &ruleDots.chars[1], ruleDots.length-- * CHARSIZE); } } for (int k = 0; k < ruleChars.length; k++) putChar(file, ruleChars.chars[k], table, NULL); for (int k = 0; k < ruleDots.length; k++) putChar(file, ruleDots.chars[k], table, NULL); return addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, NULL, noback, nofor, table); case CTO_Correct: (*table)->corrections = 1; goto doPass; case CTO_Pass2: if ((*table)->numPasses < 2) (*table)->numPasses = 2; goto doPass; case CTO_Pass3: if ((*table)->numPasses < 3) (*table)->numPasses = 3; goto doPass; case CTO_Pass4: if ((*table)->numPasses < 4) (*table)->numPasses = 4; doPass: case CTO_Context: if (!(nofor || noback)) { compileError(file, "%s or %s must be specified.", _lou_findOpcodeName(CTO_NoFor), _lou_findOpcodeName(CTO_NoBack)); return 0; } return compilePassOpcode(file, opcode, noback, nofor, table); case CTO_Contraction: case CTO_NoCont: case CTO_CompBrl: case CTO_Literal: if (!getRuleCharsText(file, &ruleChars)) return 0; // check that all characters in a compbrl, contraction, // nocont or literal rule are defined (or based on another // character) for (int k = 0; k < ruleChars.length; k++) { TranslationTableCharacter *c = getChar(ruleChars.chars[k], *table, NULL); if (!(c && (c->definitionRule || c->basechar))) { compileError(file, "Character %s is not defined", _lou_showString(&ruleChars.chars[k], 1, 0)); return 0; } } return addRule(file, opcode, &ruleChars, NULL, after, before, NULL, NULL, noback, nofor, table); case CTO_MultInd: { ruleChars.length = 0; if (!getToken(file, &token, "multiple braille indicators") || !parseDots(file, &cells, &token)) return 0; while (getToken(file, &token, "multind opcodes")) { opcode = getOpcode(file, &token); if (opcode == CTO_None) { compileError(file, "opcode %s not defined.", _lou_showString(token.chars, token.length, 0)); return 0; } if (!(opcode >= CTO_CapsLetter && opcode < CTO_MultInd)) { compileError(file, "Not a braille indicator opcode."); return 0; } ruleChars.chars[ruleChars.length++] = (widechar)opcode; if (atEndOfLine(file)) break; } return addRule(file, CTO_MultInd, &ruleChars, &cells, after, before, NULL, NULL, noback, nofor, table); } case CTO_Class: compileWarning(file, "class is deprecated, use attribute instead"); case CTO_Attribute: { if (nofor || noback) { compileWarning( file, "nofor and noback not allowed before class/attribute"); } if ((opcode == CTO_Class && (*table)->usesAttributeOrClass == 1) || (opcode == CTO_Attribute && (*table)->usesAttributeOrClass == 2)) { compileError(file, "attribute and class rules must not be both present in a table"); return 0; } if (opcode == CTO_Class) (*table)->usesAttributeOrClass = 2; else (*table)->usesAttributeOrClass = 1; if (!getToken(file, &token, "attribute name")) { compileError(file, "Expected %s", "attribute name"); return 0; } if (!(*table)->characterClasses && !allocateCharacterClasses(*table)) { return 0; } TranslationTableCharacterAttributes attribute = 0; { int attrNumber = -1; switch (token.chars[0]) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': attrNumber = token.chars[0] - '0'; break; } if (attrNumber >= 0) { if (opcode == CTO_Class) { compileError(file, "Invalid class name: may not contain digits, use " "attribute instead of class"); return 0; } if (token.length > 1 || attrNumber > 7) { compileError(file, "Invalid attribute name: must be a digit between 0 and 7 " "or a word containing only letters"); return 0; } if (!(*table)->numberedAttributes[attrNumber]) // attribute not used before yet: assign it a value (*table)->numberedAttributes[attrNumber] = getNextNumberedAttribute(*table); attribute = (*table)->numberedAttributes[attrNumber]; } else { const CharacterClass *namedAttr = findCharacterClass(&token, *table); if (!namedAttr) { // no class with that name: create one namedAttr = addCharacterClass( file, &token.chars[0], token.length, *table, 1); if (!namedAttr) return 0; } // there is a class with that name or a new class was successfully // created attribute = namedAttr->attribute; if (attribute == CTC_UpperCase || attribute == CTC_LowerCase) attribute |= CTC_Letter; } } CharsString characters; if (!getCharacters(file, &characters)) return 0; for (int i = 0; i < characters.length; i++) { // get the character from the table, or if it is not defined yet, // define it TranslationTableCharacter *character = putChar(file, characters.chars[i], table, NULL); // set the attribute character->attributes |= attribute; // also set the attribute on the associated dots (if any) if (character->basechar) character = (TranslationTableCharacter *)&(*table) ->ruleArea[character->basechar]; if (character->definitionRule) { TranslationTableRule *defRule = (TranslationTableRule *)&(*table) ->ruleArea[character->definitionRule]; if (defRule->dotslen == 1) { TranslationTableCharacter *dots = getDots(defRule->charsdots[defRule->charslen], *table); if (dots) dots->attributes |= attribute; } } } return 1; } { TranslationTableCharacterAttributes *attributes; const CharacterClass *class; case CTO_After: attributes = &after; goto doBeforeAfter; case CTO_Before: attributes = &before; doBeforeAfter: if (!(*table)->characterClasses) { if (!allocateCharacterClasses(*table)) return 0; } if (!getToken(file, &token, "attribute name")) return 0; if (!(class = findCharacterClass(&token, *table))) { compileError(file, "attribute not defined"); return 0; } *attributes |= class->attribute; goto doOpcode; } case CTO_Base: if (nofor || noback) { compileWarning(file, "nofor and noback not allowed before base"); } if (!getToken(file, &token, "attribute name")) { compileError( file, "base opcode must be followed by a valid attribute name."); return 0; } if (!(*table)->characterClasses && !allocateCharacterClasses(*table)) { return 0; } const CharacterClass *mode = findCharacterClass(&token, *table); if (!mode) { mode = addCharacterClass(file, token.chars, token.length, *table, 1); if (!mode) return 0; } if (!(mode->attribute == CTC_UpperCase || mode->attribute == CTC_Digit) && mode->attribute >= CTC_Space && mode->attribute <= CTC_LitDigit) { compileError(file, "base opcode must be followed by \"uppercase\", \"digit\", or a " "custom attribute name."); return 0; } if (!getRuleCharsText(file, &token)) return 0; if (token.length != 1) { compileError(file, "Exactly one character followed by one base character is " "required."); return 0; } TranslationTableOffset characterOffset; TranslationTableCharacter *character = putChar(file, token.chars[0], table, &characterOffset); if (!getRuleCharsText(file, &token)) return 0; if (token.length != 1) { compileError(file, "Exactly one base character is required."); return 0; } if (character->definitionRule) { TranslationTableRule *prevRule = (TranslationTableRule *)&(*table) ->ruleArea[character->definitionRule]; _lou_logMessage(LOU_LOG_DEBUG, "%s:%d: Character already defined (%s). The base rule will take " "precedence.", file->fileName, file->lineNumber, printSource(file, prevRule->sourceFile, prevRule->sourceLine)); character->definitionRule = 0; } TranslationTableOffset basechar; putChar(file, token.chars[0], table, &basechar); // putChar may have moved table, so make sure character is still valid character = (TranslationTableCharacter *)&(*table)->ruleArea[characterOffset]; if (character->basechar) { if (character->basechar == basechar && character->mode == mode->attribute) { _lou_logMessage(LOU_LOG_DEBUG, "%s:%d: Duplicate base rule.", file->fileName, file->lineNumber); } else { _lou_logMessage(LOU_LOG_DEBUG, "%s:%d: A different base rule already exists for this " "character (%s). The new rule will take precedence.", file->fileName, file->lineNumber, printSource( file, character->sourceFile, character->sourceLine)); } } character->basechar = basechar; character->mode = mode->attribute; character->sourceFile = file->sourceFile; character->sourceLine = file->lineNumber; /* some other processing is done at the end of the compilation, in * finalizeTable() */ return 1; case CTO_EmpMatchBefore: before |= CTC_EmpMatch; goto doOpcode; case CTO_EmpMatchAfter: after |= CTC_EmpMatch; goto doOpcode; case CTO_SwapCc: case CTO_SwapCd: case CTO_SwapDd: return compileSwap(file, opcode, noback, nofor, table); case CTO_Hyphen: case CTO_DecPoint: // case CTO_Apostrophe: // case CTO_Initial: if (!getRuleCharsText(file, &ruleChars)) return 0; if (!getRuleDotsPattern(file, &ruleDots)) return 0; if (ruleChars.length != 1 || ruleDots.length < 1) { compileError(file, "One Unicode character and at least one cell are " "required."); return 0; } return addRule(file, opcode, &ruleChars, &ruleDots, after, before, NULL, NULL, noback, nofor, table); // if (opcode == CTO_DecPoint) // { // TranslationTableCharacter *c = // getChar(ruleChars.chars[0]); // if(c) // c->attributes |= CTC_NumericMode; // } default: compileError(file, "unimplemented opcode."); return 0; } } return 0; }
0
336,147
static void ip6gre_netlink_parms(struct nlattr *data[], struct __ip6_tnl_parm *parms) { memset(parms, 0, sizeof(*parms)); if (!data) return; if (data[IFLA_GRE_LINK]) parms->link = nla_get_u32(data[IFLA_GRE_LINK]); if (data[IFLA_GRE_IFLAGS]) parms->i_flags = gre_flags_to_tnl_flags( nla_get_be16(data[IFLA_GRE_IFLAGS])); if (data[IFLA_GRE_OFLAGS]) parms->o_flags = gre_flags_to_tnl_flags( nla_get_be16(data[IFLA_GRE_OFLAGS])); if (data[IFLA_GRE_IKEY]) parms->i_key = nla_get_be32(data[IFLA_GRE_IKEY]); if (data[IFLA_GRE_OKEY]) parms->o_key = nla_get_be32(data[IFLA_GRE_OKEY]); if (data[IFLA_GRE_LOCAL]) parms->laddr = nla_get_in6_addr(data[IFLA_GRE_LOCAL]); if (data[IFLA_GRE_REMOTE]) parms->raddr = nla_get_in6_addr(data[IFLA_GRE_REMOTE]); if (data[IFLA_GRE_TTL]) parms->hop_limit = nla_get_u8(data[IFLA_GRE_TTL]); if (data[IFLA_GRE_ENCAP_LIMIT]) parms->encap_limit = nla_get_u8(data[IFLA_GRE_ENCAP_LIMIT]); if (data[IFLA_GRE_FLOWINFO]) parms->flowinfo = nla_get_be32(data[IFLA_GRE_FLOWINFO]); if (data[IFLA_GRE_FLAGS]) parms->flags = nla_get_u32(data[IFLA_GRE_FLAGS]); }
0
289,309
static void snd_pcm_oss_release_substream(struct snd_pcm_substream *substream) { snd_pcm_oss_release_buffers(substream); substream->oss.oss = 0; }
0
387,608
static void fill_remaining_elem_value(struct snd_ctl_elem_value *control, struct snd_ctl_elem_info *info, u32 pattern) { size_t offset = value_sizes[info->type] * info->count; offset = DIV_ROUND_UP(offset, sizeof(u32)); memset32((u32 *)control->value.bytes.data + offset, pattern, sizeof(control->value) / sizeof(u32) - offset); }
0
310,103
free_namelist(char **src) { if (src != 0) { int n; for (n = 0; src[n] != 0; ++n) free(src[n]); free(src); } }
0
500,695
static inline uint32_t sftp_get_new_id(sftp_session session) { return ++session->id_counter; }
0
308,190
static void *fastrpc_vmap(struct dma_buf *dmabuf) { struct fastrpc_buf *buf = dmabuf->priv; return buf->virt; }
0
231,012
mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc) { /* mrb_assert(MRB_PROC_CFUNC_P(proc)) */ const mrb_irep *irep = proc->body.irep; const mrb_pool_value *pool = irep->pool; const mrb_sym *syms = irep->syms; mrb_code insn; int ai = mrb_gc_arena_save(mrb); struct mrb_jmpbuf *prev_jmp = mrb->jmp; struct mrb_jmpbuf c_jmp; uint32_t a; uint16_t b; uint16_t c; mrb_sym mid; const struct mrb_irep_catch_handler *ch; #ifdef DIRECT_THREADED static const void * const optable[] = { #define OPCODE(x,_) &&L_OP_ ## x, #include "mruby/ops.h" #undef OPCODE }; #endif mrb_bool exc_catched = FALSE; RETRY_TRY_BLOCK: MRB_TRY(&c_jmp) { if (exc_catched) { exc_catched = FALSE; mrb_gc_arena_restore(mrb, ai); if (mrb->exc && mrb->exc->tt == MRB_TT_BREAK) goto L_BREAK; goto L_RAISE; } mrb->jmp = &c_jmp; mrb_vm_ci_proc_set(mrb->c->ci, proc); #define regs (mrb->c->ci->stack) INIT_DISPATCH { CASE(OP_NOP, Z) { /* do nothing */ NEXT; } CASE(OP_MOVE, BB) { regs[a] = regs[b]; NEXT; } CASE(OP_LOADL, BB) { switch (pool[b].tt) { /* number */ case IREP_TT_INT32: regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i32); break; case IREP_TT_INT64: #if defined(MRB_INT64) regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64); break; #else #if defined(MRB_64BIT) if (INT32_MIN <= pool[b].u.i64 && pool[b].u.i64 <= INT32_MAX) { regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64); break; } #endif goto L_INT_OVERFLOW; #endif case IREP_TT_BIGINT: #ifdef MRB_USE_BIGINT { const char *s = pool[b].u.str; regs[a] = mrb_bint_new_str(mrb, s+2, (mrb_int)s[0], (mrb_int)s[1]); } break; #else goto L_INT_OVERFLOW; #endif #ifndef MRB_NO_FLOAT case IREP_TT_FLOAT: regs[a] = mrb_float_value(mrb, pool[b].u.f); break; #endif default: /* should not happen (tt:string) */ regs[a] = mrb_nil_value(); break; } NEXT; } CASE(OP_LOADI, BB) { SET_FIXNUM_VALUE(regs[a], b); NEXT; } CASE(OP_LOADINEG, BB) { SET_FIXNUM_VALUE(regs[a], -b); NEXT; } CASE(OP_LOADI__1,B) goto L_LOADI; CASE(OP_LOADI_0,B) goto L_LOADI; CASE(OP_LOADI_1,B) goto L_LOADI; CASE(OP_LOADI_2,B) goto L_LOADI; CASE(OP_LOADI_3,B) goto L_LOADI; CASE(OP_LOADI_4,B) goto L_LOADI; CASE(OP_LOADI_5,B) goto L_LOADI; CASE(OP_LOADI_6,B) goto L_LOADI; CASE(OP_LOADI_7, B) { L_LOADI: SET_FIXNUM_VALUE(regs[a], (mrb_int)insn - (mrb_int)OP_LOADI_0); NEXT; } CASE(OP_LOADI16, BS) { SET_FIXNUM_VALUE(regs[a], (mrb_int)(int16_t)b); NEXT; } CASE(OP_LOADI32, BSS) { SET_INT_VALUE(mrb, regs[a], (int32_t)(((uint32_t)b<<16)+c)); NEXT; } CASE(OP_LOADSYM, BB) { SET_SYM_VALUE(regs[a], syms[b]); NEXT; } CASE(OP_LOADNIL, B) { SET_NIL_VALUE(regs[a]); NEXT; } CASE(OP_LOADSELF, B) { regs[a] = regs[0]; NEXT; } CASE(OP_LOADT, B) { SET_TRUE_VALUE(regs[a]); NEXT; } CASE(OP_LOADF, B) { SET_FALSE_VALUE(regs[a]); NEXT; } CASE(OP_GETGV, BB) { mrb_value val = mrb_gv_get(mrb, syms[b]); regs[a] = val; NEXT; } CASE(OP_SETGV, BB) { mrb_gv_set(mrb, syms[b], regs[a]); NEXT; } CASE(OP_GETSV, BB) { mrb_value val = mrb_vm_special_get(mrb, syms[b]); regs[a] = val; NEXT; } CASE(OP_SETSV, BB) { mrb_vm_special_set(mrb, syms[b], regs[a]); NEXT; } CASE(OP_GETIV, BB) { regs[a] = mrb_iv_get(mrb, regs[0], syms[b]); NEXT; } CASE(OP_SETIV, BB) { mrb_iv_set(mrb, regs[0], syms[b], regs[a]); NEXT; } CASE(OP_GETCV, BB) { mrb_value val; val = mrb_vm_cv_get(mrb, syms[b]); regs[a] = val; NEXT; } CASE(OP_SETCV, BB) { mrb_vm_cv_set(mrb, syms[b], regs[a]); NEXT; } CASE(OP_GETIDX, B) { mrb_value va = regs[a], vb = regs[a+1]; switch (mrb_type(va)) { case MRB_TT_ARRAY: if (!mrb_integer_p(vb)) goto getidx_fallback; regs[a] = mrb_ary_entry(va, mrb_integer(vb)); break; case MRB_TT_HASH: va = mrb_hash_get(mrb, va, vb); regs[a] = va; break; case MRB_TT_STRING: switch (mrb_type(vb)) { case MRB_TT_INTEGER: case MRB_TT_STRING: case MRB_TT_RANGE: va = mrb_str_aref(mrb, va, vb, mrb_undef_value()); regs[a] = va; break; default: goto getidx_fallback; } break; default: getidx_fallback: mid = MRB_OPSYM(aref); goto L_SEND_SYM; } NEXT; } CASE(OP_SETIDX, B) { c = 2; mid = MRB_OPSYM(aset); SET_NIL_VALUE(regs[a+3]); goto L_SENDB_SYM; } CASE(OP_GETCONST, BB) { mrb_value v = mrb_vm_const_get(mrb, syms[b]); regs[a] = v; NEXT; } CASE(OP_SETCONST, BB) { mrb_vm_const_set(mrb, syms[b], regs[a]); NEXT; } CASE(OP_GETMCNST, BB) { mrb_value v = mrb_const_get(mrb, regs[a], syms[b]); regs[a] = v; NEXT; } CASE(OP_SETMCNST, BB) { mrb_const_set(mrb, regs[a+1], syms[b], regs[a]); NEXT; } CASE(OP_GETUPVAR, BBB) { mrb_value *regs_a = regs + a; struct REnv *e = uvenv(mrb, c); if (e && b < MRB_ENV_LEN(e)) { *regs_a = e->stack[b]; } else { *regs_a = mrb_nil_value(); } NEXT; } CASE(OP_SETUPVAR, BBB) { struct REnv *e = uvenv(mrb, c); if (e) { mrb_value *regs_a = regs + a; if (b < MRB_ENV_LEN(e)) { e->stack[b] = *regs_a; mrb_write_barrier(mrb, (struct RBasic*)e); } } NEXT; } CASE(OP_JMP, S) { pc += (int16_t)a; JUMP; } CASE(OP_JMPIF, BS) { if (mrb_test(regs[a])) { pc += (int16_t)b; JUMP; } NEXT; } CASE(OP_JMPNOT, BS) { if (!mrb_test(regs[a])) { pc += (int16_t)b; JUMP; } NEXT; } CASE(OP_JMPNIL, BS) { if (mrb_nil_p(regs[a])) { pc += (int16_t)b; JUMP; } NEXT; } CASE(OP_JMPUW, S) { a = (uint32_t)((pc - irep->iseq) + (int16_t)a); CHECKPOINT_RESTORE(RBREAK_TAG_JUMP) { struct RBreak *brk = (struct RBreak*)mrb->exc; mrb_value target = mrb_break_value_get(brk); mrb_assert(mrb_integer_p(target)); a = (uint32_t)mrb_integer(target); mrb_assert(a >= 0 && a < irep->ilen); } CHECKPOINT_MAIN(RBREAK_TAG_JUMP) { ch = catch_handler_find(mrb, mrb->c->ci, pc, MRB_CATCH_FILTER_ENSURE); if (ch) { /* avoiding a jump from a catch handler into the same handler */ if (a < mrb_irep_catch_handler_unpack(ch->begin) || a >= mrb_irep_catch_handler_unpack(ch->end)) { THROW_TAGGED_BREAK(mrb, RBREAK_TAG_JUMP, proc, mrb_fixnum_value(a)); } } } CHECKPOINT_END(RBREAK_TAG_JUMP); mrb->exc = NULL; /* clear break object */ pc = irep->iseq + a; JUMP; } CASE(OP_EXCEPT, B) { mrb_value exc; if (mrb->exc == NULL) { exc = mrb_nil_value(); } else { switch (mrb->exc->tt) { case MRB_TT_BREAK: case MRB_TT_EXCEPTION: exc = mrb_obj_value(mrb->exc); break; default: mrb_assert(!"bad mrb_type"); exc = mrb_nil_value(); break; } mrb->exc = NULL; } regs[a] = exc; NEXT; } CASE(OP_RESCUE, BB) { mrb_value exc = regs[a]; /* exc on stack */ mrb_value e = regs[b]; struct RClass *ec; switch (mrb_type(e)) { case MRB_TT_CLASS: case MRB_TT_MODULE: break; default: { mrb_value exc; exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR, "class or module required for rescue clause"); mrb_exc_set(mrb, exc); goto L_RAISE; } } ec = mrb_class_ptr(e); regs[b] = mrb_bool_value(mrb_obj_is_kind_of(mrb, exc, ec)); NEXT; } CASE(OP_RAISEIF, B) { mrb_value exc = regs[a]; if (mrb_break_p(exc)) { mrb->exc = mrb_obj_ptr(exc); goto L_BREAK; } mrb_exc_set(mrb, exc); if (mrb->exc) { goto L_RAISE; } NEXT; } CASE(OP_SSEND, BBB) { regs[a] = regs[0]; insn = OP_SEND; } goto L_SENDB; CASE(OP_SSENDB, BBB) { regs[a] = regs[0]; } goto L_SENDB; CASE(OP_SEND, BBB) goto L_SENDB; L_SEND_SYM: c = 1; /* push nil after arguments */ SET_NIL_VALUE(regs[a+2]); goto L_SENDB_SYM; CASE(OP_SENDB, BBB) L_SENDB: mid = syms[b]; L_SENDB_SYM: { mrb_callinfo *ci = mrb->c->ci; mrb_method_t m; struct RClass *cls; mrb_value recv, blk; ARGUMENT_NORMALIZE(a, &c, insn); recv = regs[a]; cls = mrb_class(mrb, recv); m = mrb_method_search_vm(mrb, &cls, mid); if (MRB_METHOD_UNDEF_P(m)) { m = prepare_missing(mrb, recv, mid, &cls, a, &c, blk, 0); mid = MRB_SYM(method_missing); } /* push callinfo */ ci = cipush(mrb, a, 0, cls, NULL, mid, c); if (MRB_METHOD_CFUNC_P(m)) { if (MRB_METHOD_PROC_P(m)) { struct RProc *p = MRB_METHOD_PROC(m); mrb_vm_ci_proc_set(ci, p); recv = p->body.func(mrb, recv); } else { if (MRB_METHOD_NOARG_P(m)) { check_method_noarg(mrb, ci); } recv = MRB_METHOD_FUNC(m)(mrb, recv); } mrb_gc_arena_shrink(mrb, ai); if (mrb->exc) goto L_RAISE; ci = mrb->c->ci; if (mrb_proc_p(blk)) { struct RProc *p = mrb_proc_ptr(blk); if (p && !MRB_PROC_STRICT_P(p) && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) { p->flags |= MRB_PROC_ORPHAN; } } if (!ci->u.target_class) { /* return from context modifying method (resume/yield) */ if (ci->cci == CINFO_RESUMED) { mrb->jmp = prev_jmp; return recv; } else { mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc)); proc = ci[-1].proc; irep = proc->body.irep; pool = irep->pool; syms = irep->syms; } } ci->stack[0] = recv; /* pop stackpos */ ci = cipop(mrb); pc = ci->pc; } else { /* setup environment for calling method */ mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m))); irep = proc->body.irep; pool = irep->pool; syms = irep->syms; mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs); pc = irep->iseq; } } JUMP; CASE(OP_CALL, Z) { mrb_callinfo *ci = mrb->c->ci; mrb_value recv = ci->stack[0]; struct RProc *m = mrb_proc_ptr(recv); /* replace callinfo */ ci->u.target_class = MRB_PROC_TARGET_CLASS(m); mrb_vm_ci_proc_set(ci, m); if (MRB_PROC_ENV_P(m)) { ci->mid = MRB_PROC_ENV(m)->mid; } /* prepare stack */ if (MRB_PROC_CFUNC_P(m)) { recv = MRB_PROC_CFUNC(m)(mrb, recv); mrb_gc_arena_shrink(mrb, ai); if (mrb->exc) goto L_RAISE; /* pop stackpos */ ci = cipop(mrb); pc = ci->pc; ci[1].stack[0] = recv; irep = mrb->c->ci->proc->body.irep; } else { /* setup environment for calling method */ proc = m; irep = m->body.irep; if (!irep) { mrb->c->ci->stack[0] = mrb_nil_value(); a = 0; c = OP_R_NORMAL; goto L_OP_RETURN_BODY; } mrb_int nargs = mrb_ci_bidx(ci)+1; if (nargs < irep->nregs) { mrb_stack_extend(mrb, irep->nregs); stack_clear(regs+nargs, irep->nregs-nargs); } if (MRB_PROC_ENV_P(m)) { regs[0] = MRB_PROC_ENV(m)->stack[0]; } pc = irep->iseq; } pool = irep->pool; syms = irep->syms; JUMP; } CASE(OP_SUPER, BB) { mrb_method_t m; struct RClass *cls; mrb_callinfo *ci = mrb->c->ci; mrb_value recv, blk; const struct RProc *p = ci->proc; mrb_sym mid = ci->mid; struct RClass* target_class = MRB_PROC_TARGET_CLASS(p); if (MRB_PROC_ENV_P(p) && p->e.env->mid && p->e.env->mid != mid) { /* alias support */ mid = p->e.env->mid; /* restore old mid */ } if (mid == 0 || !target_class) { mrb_value exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method"); mrb_exc_set(mrb, exc); goto L_RAISE; } if ((target_class->flags & MRB_FL_CLASS_IS_PREPENDED) || target_class->tt == MRB_TT_MODULE) { target_class = mrb_vm_ci_target_class(ci); if (!target_class || target_class->tt != MRB_TT_ICLASS) { goto super_typeerror; } } recv = regs[0]; if (!mrb_obj_is_kind_of(mrb, recv, target_class)) { super_typeerror: ; mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR, "self has wrong type to call super in this context"); mrb_exc_set(mrb, exc); goto L_RAISE; } ARGUMENT_NORMALIZE(a, &b, OP_SUPER); cls = target_class->super; m = mrb_method_search_vm(mrb, &cls, mid); if (MRB_METHOD_UNDEF_P(m)) { m = prepare_missing(mrb, recv, mid, &cls, a, &b, blk, 1); mid = MRB_SYM(method_missing); } /* push callinfo */ ci = cipush(mrb, a, 0, cls, NULL, mid, b); /* prepare stack */ ci->stack[0] = recv; if (MRB_METHOD_CFUNC_P(m)) { mrb_value v; if (MRB_METHOD_PROC_P(m)) { mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m)); } v = MRB_METHOD_CFUNC(m)(mrb, recv); mrb_gc_arena_restore(mrb, ai); if (mrb->exc) goto L_RAISE; ci = mrb->c->ci; mrb_assert(!mrb_break_p(v)); if (!mrb_vm_ci_target_class(ci)) { /* return from context modifying method (resume/yield) */ if (ci->cci == CINFO_RESUMED) { mrb->jmp = prev_jmp; return v; } else { mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc)); proc = ci[-1].proc; irep = proc->body.irep; pool = irep->pool; syms = irep->syms; } } mrb->c->ci->stack[0] = v; ci = cipop(mrb); pc = ci->pc; } else { /* setup environment for calling method */ mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m))); irep = proc->body.irep; pool = irep->pool; syms = irep->syms; mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs); pc = irep->iseq; } JUMP; } CASE(OP_ARGARY, BS) { mrb_int m1 = (b>>11)&0x3f; mrb_int r = (b>>10)&0x1; mrb_int m2 = (b>>5)&0x1f; mrb_int kd = (b>>4)&0x1; mrb_int lv = (b>>0)&0xf; mrb_value *stack; if (mrb->c->ci->mid == 0 || mrb_vm_ci_target_class(mrb->c->ci) == NULL) { mrb_value exc; L_NOSUPER: exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method"); mrb_exc_set(mrb, exc); goto L_RAISE; } if (lv == 0) stack = regs + 1; else { struct REnv *e = uvenv(mrb, lv-1); if (!e) goto L_NOSUPER; if (MRB_ENV_LEN(e) <= m1+r+m2+1) goto L_NOSUPER; stack = e->stack + 1; } if (r == 0) { regs[a] = mrb_ary_new_from_values(mrb, m1+m2, stack); } else { mrb_value *pp = NULL; struct RArray *rest; mrb_int len = 0; if (mrb_array_p(stack[m1])) { struct RArray *ary = mrb_ary_ptr(stack[m1]); pp = ARY_PTR(ary); len = ARY_LEN(ary); } regs[a] = mrb_ary_new_capa(mrb, m1+len+m2); rest = mrb_ary_ptr(regs[a]); if (m1 > 0) { stack_copy(ARY_PTR(rest), stack, m1); } if (len > 0) { stack_copy(ARY_PTR(rest)+m1, pp, len); } if (m2 > 0) { stack_copy(ARY_PTR(rest)+m1+len, stack+m1+1, m2); } ARY_SET_LEN(rest, m1+len+m2); } if (kd) { regs[a+1] = stack[m1+r+m2]; regs[a+2] = stack[m1+r+m2+1]; } else { regs[a+1] = stack[m1+r+m2]; } mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_ENTER, W) { mrb_int m1 = MRB_ASPEC_REQ(a); mrb_int o = MRB_ASPEC_OPT(a); mrb_int r = MRB_ASPEC_REST(a); mrb_int m2 = MRB_ASPEC_POST(a); mrb_int kd = (MRB_ASPEC_KEY(a) > 0 || MRB_ASPEC_KDICT(a))? 1 : 0; /* unused int b = MRB_ASPEC_BLOCK(a); */ mrb_int const len = m1 + o + r + m2; mrb_callinfo *ci = mrb->c->ci; mrb_int argc = ci->n; mrb_value *argv = regs+1; mrb_value * const argv0 = argv; mrb_int const kw_pos = len + kd; /* where kwhash should be */ mrb_int const blk_pos = kw_pos + 1; /* where block should be */ mrb_value blk = regs[mrb_ci_bidx(ci)]; mrb_value kdict = mrb_nil_value(); /* keyword arguments */ if (ci->nk > 0) { mrb_int kidx = mrb_ci_kidx(ci); kdict = regs[kidx]; if (!mrb_hash_p(kdict) || mrb_hash_size(mrb, kdict) == 0) { kdict = mrb_nil_value(); ci->nk = 0; } } if (!kd && !mrb_nil_p(kdict)) { if (argc < 14) { ci->n++; argc++; /* include kdict in normal arguments */ } else if (argc == 14) { /* pack arguments and kdict */ regs[1] = mrb_ary_new_from_values(mrb, argc+1, &regs[1]); argc = ci->n = 15; } else {/* argc == 15 */ /* push kdict to packed arguments */ mrb_ary_push(mrb, regs[1], regs[2]); } ci->nk = 0; } if (kd && MRB_ASPEC_KEY(a) > 0 && mrb_hash_p(kdict)) { kdict = mrb_hash_dup(mrb, kdict); } /* arguments is passed with Array */ if (argc == 15) { struct RArray *ary = mrb_ary_ptr(regs[1]); argv = ARY_PTR(ary); argc = (int)ARY_LEN(ary); mrb_gc_protect(mrb, regs[1]); } /* strict argument check */ if (ci->proc && MRB_PROC_STRICT_P(ci->proc)) { if (argc < m1 + m2 || (r == 0 && argc > len)) { argnum_error(mrb, m1+m2); goto L_RAISE; } } /* extract first argument array to arguments */ else if (len > 1 && argc == 1 && mrb_array_p(argv[0])) { mrb_gc_protect(mrb, argv[0]); argc = (int)RARRAY_LEN(argv[0]); argv = RARRAY_PTR(argv[0]); } /* rest arguments */ mrb_value rest = mrb_nil_value(); if (argc < len) { mrb_int mlen = m2; if (argc < m1+m2) { mlen = m1 < argc ? argc - m1 : 0; } /* copy mandatory and optional arguments */ if (argv0 != argv && argv) { value_move(&regs[1], argv, argc-mlen); /* m1 + o */ } if (argc < m1) { stack_clear(&regs[argc+1], m1-argc); } /* copy post mandatory arguments */ if (mlen) { value_move(&regs[len-m2+1], &argv[argc-mlen], mlen); } if (mlen < m2) { stack_clear(&regs[len-m2+mlen+1], m2-mlen); } /* initialize rest arguments with empty Array */ if (r) { rest = mrb_ary_new_capa(mrb, 0); regs[m1+o+1] = rest; } /* skip initializer of passed arguments */ if (o > 0 && argc > m1+m2) pc += (argc - m1 - m2)*3; } else { mrb_int rnum = 0; if (argv0 != argv) { value_move(&regs[1], argv, m1+o); } if (r) { rnum = argc-m1-o-m2; rest = mrb_ary_new_from_values(mrb, rnum, argv+m1+o); regs[m1+o+1] = rest; } if (m2 > 0 && argc-m2 > m1) { value_move(&regs[m1+o+r+1], &argv[m1+o+rnum], m2); } pc += o*3; } /* need to be update blk first to protect blk from GC */ regs[blk_pos] = blk; /* move block */ if (kd) { if (mrb_nil_p(kdict)) kdict = mrb_hash_new_capa(mrb, 0); regs[kw_pos] = kdict; /* set kwhash */ } /* format arguments for generated code */ mrb->c->ci->n = (uint8_t)len; /* clear local (but non-argument) variables */ if (irep->nlocals-blk_pos-1 > 0) { stack_clear(&regs[blk_pos+1], irep->nlocals-blk_pos-1); } JUMP; } CASE(OP_KARG, BB) { mrb_value k = mrb_symbol_value(syms[b]); mrb_int kidx = mrb_ci_kidx(mrb->c->ci); mrb_value kdict, v; if (kidx < 0 || !mrb_hash_p(kdict=regs[kidx]) || !mrb_hash_key_p(mrb, kdict, k)) { mrb_value str = mrb_format(mrb, "missing keyword: %v", k); mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str)); goto L_RAISE; } v = mrb_hash_get(mrb, kdict, k); regs[a] = v; mrb_hash_delete_key(mrb, kdict, k); NEXT; } CASE(OP_KEY_P, BB) { mrb_value k = mrb_symbol_value(syms[b]); mrb_int kidx = mrb_ci_kidx(mrb->c->ci); mrb_value kdict; mrb_bool key_p = FALSE; if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx])) { key_p = mrb_hash_key_p(mrb, kdict, k); } regs[a] = mrb_bool_value(key_p); NEXT; } CASE(OP_KEYEND, Z) { mrb_int kidx = mrb_ci_kidx(mrb->c->ci); mrb_value kdict; if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx]) && !mrb_hash_empty_p(mrb, kdict)) { mrb_value keys = mrb_hash_keys(mrb, kdict); mrb_value key1 = RARRAY_PTR(keys)[0]; mrb_value str = mrb_format(mrb, "unknown keyword: %v", key1); mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str)); goto L_RAISE; } NEXT; } CASE(OP_BREAK, B) { c = OP_R_BREAK; goto L_RETURN; } CASE(OP_RETURN_BLK, B) { c = OP_R_RETURN; goto L_RETURN; } CASE(OP_RETURN, B) c = OP_R_NORMAL; L_RETURN: { mrb_callinfo *ci; ci = mrb->c->ci; if (ci->mid) { mrb_value blk = regs[mrb_ci_bidx(ci)]; if (mrb_proc_p(blk)) { struct RProc *p = mrb_proc_ptr(blk); if (!MRB_PROC_STRICT_P(p) && ci > mrb->c->cibase && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) { p->flags |= MRB_PROC_ORPHAN; } } } if (mrb->exc) { L_RAISE: ci = mrb->c->ci; if (ci == mrb->c->cibase) { ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL); if (ch == NULL) goto L_FTOP; goto L_CATCH; } while ((ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL)) == NULL) { ci = cipop(mrb); if (ci[1].cci == CINFO_SKIP && prev_jmp) { mrb->jmp = prev_jmp; MRB_THROW(prev_jmp); } pc = ci[0].pc; if (ci == mrb->c->cibase) { ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL); if (ch == NULL) { L_FTOP: /* fiber top */ if (mrb->c == mrb->root_c) { mrb->c->ci->stack = mrb->c->stbase; goto L_STOP; } else { struct mrb_context *c = mrb->c; c->status = MRB_FIBER_TERMINATED; mrb->c = c->prev; c->prev = NULL; goto L_RAISE; } } break; } } L_CATCH: if (ch == NULL) goto L_STOP; if (FALSE) { L_CATCH_TAGGED_BREAK: /* from THROW_TAGGED_BREAK() or UNWIND_ENSURE() */ ci = mrb->c->ci; } proc = ci->proc; irep = proc->body.irep; pool = irep->pool; syms = irep->syms; mrb_stack_extend(mrb, irep->nregs); pc = irep->iseq + mrb_irep_catch_handler_unpack(ch->target); } else { mrb_int acc; mrb_value v; ci = mrb->c->ci; v = regs[a]; mrb_gc_protect(mrb, v); switch (c) { case OP_R_RETURN: /* Fall through to OP_R_NORMAL otherwise */ if (ci->cci == CINFO_NONE && MRB_PROC_ENV_P(proc) && !MRB_PROC_STRICT_P(proc)) { const struct RProc *dst; mrb_callinfo *cibase; cibase = mrb->c->cibase; dst = top_proc(mrb, proc); if (MRB_PROC_ENV_P(dst)) { struct REnv *e = MRB_PROC_ENV(dst); if (!MRB_ENV_ONSTACK_P(e) || (e->cxt && e->cxt != mrb->c)) { localjump_error(mrb, LOCALJUMP_ERROR_RETURN); goto L_RAISE; } } /* check jump destination */ while (cibase <= ci && ci->proc != dst) { if (ci->cci > CINFO_NONE) { /* jump cross C boundary */ localjump_error(mrb, LOCALJUMP_ERROR_RETURN); goto L_RAISE; } ci--; } if (ci <= cibase) { /* no jump destination */ localjump_error(mrb, LOCALJUMP_ERROR_RETURN); goto L_RAISE; } ci = mrb->c->ci; while (cibase <= ci && ci->proc != dst) { CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_BLOCK) { cibase = mrb->c->cibase; dst = top_proc(mrb, proc); } CHECKPOINT_MAIN(RBREAK_TAG_RETURN_BLOCK) { UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_BLOCK, proc, v); } CHECKPOINT_END(RBREAK_TAG_RETURN_BLOCK); ci = cipop(mrb); pc = ci->pc; } proc = ci->proc; mrb->exc = NULL; /* clear break object */ break; } /* fallthrough */ case OP_R_NORMAL: NORMAL_RETURN: if (ci == mrb->c->cibase) { struct mrb_context *c; c = mrb->c; if (!c->prev) { /* toplevel return */ regs[irep->nlocals] = v; goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP); } if (!c->vmexec && c->prev->ci == c->prev->cibase) { mrb_value exc = mrb_exc_new_lit(mrb, E_FIBER_ERROR, "double resume"); mrb_exc_set(mrb, exc); goto L_RAISE; } CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_TOPLEVEL) { c = mrb->c; } CHECKPOINT_MAIN(RBREAK_TAG_RETURN_TOPLEVEL) { UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_TOPLEVEL, proc, v); } CHECKPOINT_END(RBREAK_TAG_RETURN_TOPLEVEL); /* automatic yield at the end */ c->status = MRB_FIBER_TERMINATED; mrb->c = c->prev; mrb->c->status = MRB_FIBER_RUNNING; c->prev = NULL; if (c->vmexec) { mrb_gc_arena_restore(mrb, ai); c->vmexec = FALSE; mrb->jmp = prev_jmp; return v; } ci = mrb->c->ci; } CHECKPOINT_RESTORE(RBREAK_TAG_RETURN) { /* do nothing */ } CHECKPOINT_MAIN(RBREAK_TAG_RETURN) { UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN, proc, v); } CHECKPOINT_END(RBREAK_TAG_RETURN); mrb->exc = NULL; /* clear break object */ break; case OP_R_BREAK: if (MRB_PROC_STRICT_P(proc)) goto NORMAL_RETURN; if (MRB_PROC_ORPHAN_P(proc)) { mrb_value exc; L_BREAK_ERROR: exc = mrb_exc_new_lit(mrb, E_LOCALJUMP_ERROR, "break from proc-closure"); mrb_exc_set(mrb, exc); goto L_RAISE; } if (!MRB_PROC_ENV_P(proc) || !MRB_ENV_ONSTACK_P(MRB_PROC_ENV(proc))) { goto L_BREAK_ERROR; } else { struct REnv *e = MRB_PROC_ENV(proc); if (e->cxt != mrb->c) { goto L_BREAK_ERROR; } } CHECKPOINT_RESTORE(RBREAK_TAG_BREAK) { /* do nothing */ } CHECKPOINT_MAIN(RBREAK_TAG_BREAK) { UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK, proc, v); } CHECKPOINT_END(RBREAK_TAG_BREAK); /* break from fiber block */ if (ci == mrb->c->cibase && ci->pc) { struct mrb_context *c = mrb->c; mrb->c = c->prev; c->prev = NULL; ci = mrb->c->ci; } if (ci->cci > CINFO_NONE) { ci = cipop(mrb); mrb->exc = (struct RObject*)break_new(mrb, RBREAK_TAG_BREAK, proc, v); mrb_gc_arena_restore(mrb, ai); mrb->c->vmexec = FALSE; mrb->jmp = prev_jmp; MRB_THROW(prev_jmp); } if (FALSE) { struct RBreak *brk; L_BREAK: brk = (struct RBreak*)mrb->exc; proc = mrb_break_proc_get(brk); v = mrb_break_value_get(brk); ci = mrb->c->ci; switch (mrb_break_tag_get(brk)) { #define DISPATCH_CHECKPOINTS(n, i) case n: goto CHECKPOINT_LABEL_MAKE(n); RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS) #undef DISPATCH_CHECKPOINTS default: mrb_assert(!"wrong break tag"); } } while (mrb->c->cibase < ci && ci[-1].proc != proc->upper) { if (ci[-1].cci == CINFO_SKIP) { goto L_BREAK_ERROR; } CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_UPPER) { /* do nothing */ } CHECKPOINT_MAIN(RBREAK_TAG_BREAK_UPPER) { UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_UPPER, proc, v); } CHECKPOINT_END(RBREAK_TAG_BREAK_UPPER); ci = cipop(mrb); pc = ci->pc; } CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_INTARGET) { /* do nothing */ } CHECKPOINT_MAIN(RBREAK_TAG_BREAK_INTARGET) { UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_INTARGET, proc, v); } CHECKPOINT_END(RBREAK_TAG_BREAK_INTARGET); if (ci == mrb->c->cibase) { goto L_BREAK_ERROR; } mrb->exc = NULL; /* clear break object */ break; default: /* cannot happen */ break; } mrb_assert(ci == mrb->c->ci); mrb_assert(mrb->exc == NULL); if (mrb->c->vmexec && !mrb_vm_ci_target_class(ci)) { mrb_gc_arena_restore(mrb, ai); mrb->c->vmexec = FALSE; mrb->jmp = prev_jmp; return v; } acc = ci->cci; ci = cipop(mrb); if (acc == CINFO_SKIP || acc == CINFO_DIRECT) { mrb_gc_arena_restore(mrb, ai); mrb->jmp = prev_jmp; return v; } pc = ci->pc; DEBUG(fprintf(stderr, "from :%s\n", mrb_sym_name(mrb, ci->mid))); proc = ci->proc; irep = proc->body.irep; pool = irep->pool; syms = irep->syms; ci[1].stack[0] = v; mrb_gc_arena_restore(mrb, ai); } JUMP; } CASE(OP_BLKPUSH, BS) { int m1 = (b>>11)&0x3f; int r = (b>>10)&0x1; int m2 = (b>>5)&0x1f; int kd = (b>>4)&0x1; int lv = (b>>0)&0xf; mrb_value *stack; if (lv == 0) stack = regs + 1; else { struct REnv *e = uvenv(mrb, lv-1); if (!e || (!MRB_ENV_ONSTACK_P(e) && e->mid == 0) || MRB_ENV_LEN(e) <= m1+r+m2+1) { localjump_error(mrb, LOCALJUMP_ERROR_YIELD); goto L_RAISE; } stack = e->stack + 1; } if (mrb_nil_p(stack[m1+r+m2+kd])) { localjump_error(mrb, LOCALJUMP_ERROR_YIELD); goto L_RAISE; } regs[a] = stack[m1+r+m2+kd]; NEXT; } #if !defined(MRB_USE_BIGINT) || defined(MRB_INT32) L_INT_OVERFLOW: { mrb_value exc = mrb_exc_new_lit(mrb, E_RANGE_ERROR, "integer overflow"); mrb_exc_set(mrb, exc); } goto L_RAISE; #endif #define TYPES2(a,b) ((((uint16_t)(a))<<8)|(((uint16_t)(b))&0xff)) #define OP_MATH(op_name) \ /* need to check if op is overridden */ \ switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) { \ OP_MATH_CASE_INTEGER(op_name); \ OP_MATH_CASE_FLOAT(op_name, integer, float); \ OP_MATH_CASE_FLOAT(op_name, float, integer); \ OP_MATH_CASE_FLOAT(op_name, float, float); \ OP_MATH_CASE_STRING_##op_name(); \ default: \ mid = MRB_OPSYM(op_name); \ goto L_SEND_SYM; \ } \ NEXT; #define OP_MATH_CASE_INTEGER(op_name) \ case TYPES2(MRB_TT_INTEGER, MRB_TT_INTEGER): \ { \ mrb_int x = mrb_integer(regs[a]), y = mrb_integer(regs[a+1]), z; \ if (mrb_int_##op_name##_overflow(x, y, &z)) { \ OP_MATH_OVERFLOW_INT(op_name,x,y); \ } \ else \ SET_INT_VALUE(mrb,regs[a], z); \ } \ break #ifdef MRB_NO_FLOAT #define OP_MATH_CASE_FLOAT(op_name, t1, t2) (void)0 #else #define OP_MATH_CASE_FLOAT(op_name, t1, t2) \ case TYPES2(OP_MATH_TT_##t1, OP_MATH_TT_##t2): \ { \ mrb_float z = mrb_##t1(regs[a]) OP_MATH_OP_##op_name mrb_##t2(regs[a+1]); \ SET_FLOAT_VALUE(mrb, regs[a], z); \ } \ break #endif #ifdef MRB_USE_BIGINT #define OP_MATH_OVERFLOW_INT(op,x,y) regs[a] = mrb_bint_##op##_ii(mrb,x,y) #else #define OP_MATH_OVERFLOW_INT(op,x,y) goto L_INT_OVERFLOW #endif #define OP_MATH_CASE_STRING_add() \ case TYPES2(MRB_TT_STRING, MRB_TT_STRING): \ regs[a] = mrb_str_plus(mrb, regs[a], regs[a+1]); \ mrb_gc_arena_restore(mrb, ai); \ break #define OP_MATH_CASE_STRING_sub() (void)0 #define OP_MATH_CASE_STRING_mul() (void)0 #define OP_MATH_OP_add + #define OP_MATH_OP_sub - #define OP_MATH_OP_mul * #define OP_MATH_TT_integer MRB_TT_INTEGER #define OP_MATH_TT_float MRB_TT_FLOAT CASE(OP_ADD, B) { OP_MATH(add); } CASE(OP_SUB, B) { OP_MATH(sub); } CASE(OP_MUL, B) { OP_MATH(mul); } CASE(OP_DIV, B) { #ifndef MRB_NO_FLOAT mrb_float x, y, f; #endif /* need to check if op is overridden */ switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) { case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER): { mrb_int x = mrb_integer(regs[a]); mrb_int y = mrb_integer(regs[a+1]); mrb_int div = mrb_div_int(mrb, x, y); SET_INT_VALUE(mrb, regs[a], div); } NEXT; #ifndef MRB_NO_FLOAT case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT): x = (mrb_float)mrb_integer(regs[a]); y = mrb_float(regs[a+1]); break; case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER): x = mrb_float(regs[a]); y = (mrb_float)mrb_integer(regs[a+1]); break; case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT): x = mrb_float(regs[a]); y = mrb_float(regs[a+1]); break; #endif default: mid = MRB_OPSYM(div); goto L_SEND_SYM; } #ifndef MRB_NO_FLOAT f = mrb_div_float(x, y); SET_FLOAT_VALUE(mrb, regs[a], f); #endif NEXT; } #define OP_MATHI(op_name) \ /* need to check if op is overridden */ \ switch (mrb_type(regs[a])) { \ OP_MATHI_CASE_INTEGER(op_name); \ OP_MATHI_CASE_FLOAT(op_name); \ default: \ SET_INT_VALUE(mrb,regs[a+1], b); \ mid = MRB_OPSYM(op_name); \ goto L_SEND_SYM; \ } \ NEXT; #define OP_MATHI_CASE_INTEGER(op_name) \ case MRB_TT_INTEGER: \ { \ mrb_int x = mrb_integer(regs[a]), y = (mrb_int)b, z; \ if (mrb_int_##op_name##_overflow(x, y, &z)) { \ OP_MATH_OVERFLOW_INT(op_name,x,y); \ } \ else \ SET_INT_VALUE(mrb,regs[a], z); \ } \ break #ifdef MRB_NO_FLOAT #define OP_MATHI_CASE_FLOAT(op_name) (void)0 #else #define OP_MATHI_CASE_FLOAT(op_name) \ case MRB_TT_FLOAT: \ { \ mrb_float z = mrb_float(regs[a]) OP_MATH_OP_##op_name b; \ SET_FLOAT_VALUE(mrb, regs[a], z); \ } \ break #endif CASE(OP_ADDI, BB) { OP_MATHI(add); } CASE(OP_SUBI, BB) { OP_MATHI(sub); } #define OP_CMP_BODY(op,v1,v2) (v1(regs[a]) op v2(regs[a+1])) #ifdef MRB_NO_FLOAT #define OP_CMP(op,sym) do {\ int result;\ /* need to check if - is overridden */\ switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\ case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\ result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\ break;\ default:\ mid = MRB_OPSYM(sym);\ goto L_SEND_SYM;\ }\ if (result) {\ SET_TRUE_VALUE(regs[a]);\ }\ else {\ SET_FALSE_VALUE(regs[a]);\ }\ } while(0) #else #define OP_CMP(op, sym) do {\ int result;\ /* need to check if - is overridden */\ switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\ case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\ result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\ break;\ case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\ result = OP_CMP_BODY(op,mrb_fixnum,mrb_float);\ break;\ case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\ result = OP_CMP_BODY(op,mrb_float,mrb_fixnum);\ break;\ case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\ result = OP_CMP_BODY(op,mrb_float,mrb_float);\ break;\ default:\ mid = MRB_OPSYM(sym);\ goto L_SEND_SYM;\ }\ if (result) {\ SET_TRUE_VALUE(regs[a]);\ }\ else {\ SET_FALSE_VALUE(regs[a]);\ }\ } while(0) #endif CASE(OP_EQ, B) { if (mrb_obj_eq(mrb, regs[a], regs[a+1])) { SET_TRUE_VALUE(regs[a]); } else { OP_CMP(==,eq); } NEXT; } CASE(OP_LT, B) { OP_CMP(<,lt); NEXT; } CASE(OP_LE, B) { OP_CMP(<=,le); NEXT; } CASE(OP_GT, B) { OP_CMP(>,gt); NEXT; } CASE(OP_GE, B) { OP_CMP(>=,ge); NEXT; } CASE(OP_ARRAY, BB) { regs[a] = mrb_ary_new_from_values(mrb, b, &regs[a]); mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_ARRAY2, BBB) { regs[a] = mrb_ary_new_from_values(mrb, c, &regs[b]); mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_ARYCAT, B) { mrb_value splat = mrb_ary_splat(mrb, regs[a+1]); if (mrb_nil_p(regs[a])) { regs[a] = splat; } else { mrb_assert(mrb_array_p(regs[a])); mrb_ary_concat(mrb, regs[a], splat); } mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_ARYPUSH, BB) { mrb_assert(mrb_array_p(regs[a])); for (mrb_int i=0; i<b; i++) { mrb_ary_push(mrb, regs[a], regs[a+i+1]); } NEXT; } CASE(OP_ARYDUP, B) { mrb_value ary = regs[a]; if (mrb_array_p(ary)) { ary = mrb_ary_new_from_values(mrb, RARRAY_LEN(ary), RARRAY_PTR(ary)); } else { ary = mrb_ary_new_from_values(mrb, 1, &ary); } regs[a] = ary; NEXT; } CASE(OP_AREF, BBB) { mrb_value v = regs[b]; if (!mrb_array_p(v)) { if (c == 0) { regs[a] = v; } else { SET_NIL_VALUE(regs[a]); } } else { v = mrb_ary_ref(mrb, v, c); regs[a] = v; } NEXT; } CASE(OP_ASET, BBB) { mrb_assert(mrb_array_p(regs[a])); mrb_ary_set(mrb, regs[b], c, regs[a]); NEXT; } CASE(OP_APOST, BBB) { mrb_value v = regs[a]; int pre = b; int post = c; struct RArray *ary; int len, idx; if (!mrb_array_p(v)) { v = mrb_ary_new_from_values(mrb, 1, &regs[a]); } ary = mrb_ary_ptr(v); len = (int)ARY_LEN(ary); if (len > pre + post) { v = mrb_ary_new_from_values(mrb, len - pre - post, ARY_PTR(ary)+pre); regs[a++] = v; while (post--) { regs[a++] = ARY_PTR(ary)[len-post-1]; } } else { v = mrb_ary_new_capa(mrb, 0); regs[a++] = v; for (idx=0; idx+pre<len; idx++) { regs[a+idx] = ARY_PTR(ary)[pre+idx]; } while (idx < post) { SET_NIL_VALUE(regs[a+idx]); idx++; } } mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_INTERN, B) { mrb_assert(mrb_string_p(regs[a])); mrb_sym sym = mrb_intern_str(mrb, regs[a]); regs[a] = mrb_symbol_value(sym); NEXT; } CASE(OP_SYMBOL, BB) { size_t len; mrb_sym sym; mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0); len = pool[b].tt >> 2; if (pool[b].tt & IREP_TT_SFLAG) { sym = mrb_intern_static(mrb, pool[b].u.str, len); } else { sym = mrb_intern(mrb, pool[b].u.str, len); } regs[a] = mrb_symbol_value(sym); NEXT; } CASE(OP_STRING, BB) { mrb_int len; mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0); len = pool[b].tt >> 2; if (pool[b].tt & IREP_TT_SFLAG) { regs[a] = mrb_str_new_static(mrb, pool[b].u.str, len); } else { regs[a] = mrb_str_new(mrb, pool[b].u.str, len); } mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_STRCAT, B) { mrb_assert(mrb_string_p(regs[a])); mrb_str_concat(mrb, regs[a], regs[a+1]); NEXT; } CASE(OP_HASH, BB) { mrb_value hash = mrb_hash_new_capa(mrb, b); int i; int lim = a+b*2; for (i=a; i<lim; i+=2) { mrb_hash_set(mrb, hash, regs[i], regs[i+1]); } regs[a] = hash; mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_HASHADD, BB) { mrb_value hash; int i; int lim = a+b*2+1; hash = regs[a]; mrb_ensure_hash_type(mrb, hash); for (i=a+1; i<lim; i+=2) { mrb_hash_set(mrb, hash, regs[i], regs[i+1]); } mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_HASHCAT, B) { mrb_value hash = regs[a]; mrb_assert(mrb_hash_p(hash)); mrb_hash_merge(mrb, hash, regs[a+1]); mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_LAMBDA, BB) c = OP_L_LAMBDA; L_MAKE_LAMBDA: { struct RProc *p; const mrb_irep *nirep = irep->reps[b]; if (c & OP_L_CAPTURE) { p = mrb_closure_new(mrb, nirep); } else { p = mrb_proc_new(mrb, nirep); p->flags |= MRB_PROC_SCOPE; } if (c & OP_L_STRICT) p->flags |= MRB_PROC_STRICT; regs[a] = mrb_obj_value(p); mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_BLOCK, BB) { c = OP_L_BLOCK; goto L_MAKE_LAMBDA; } CASE(OP_METHOD, BB) { c = OP_L_METHOD; goto L_MAKE_LAMBDA; } CASE(OP_RANGE_INC, B) { mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], FALSE); regs[a] = v; mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_RANGE_EXC, B) { mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], TRUE); regs[a] = v; mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_OCLASS, B) { regs[a] = mrb_obj_value(mrb->object_class); NEXT; } CASE(OP_CLASS, BB) { struct RClass *c = 0, *baseclass; mrb_value base, super; mrb_sym id = syms[b]; base = regs[a]; super = regs[a+1]; if (mrb_nil_p(base)) { baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc); if (!baseclass) baseclass = mrb->object_class; base = mrb_obj_value(baseclass); } c = mrb_vm_define_class(mrb, base, super, id); regs[a] = mrb_obj_value(c); mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_MODULE, BB) { struct RClass *cls = 0, *baseclass; mrb_value base; mrb_sym id = syms[b]; base = regs[a]; if (mrb_nil_p(base)) { baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc); if (!baseclass) baseclass = mrb->object_class; base = mrb_obj_value(baseclass); } cls = mrb_vm_define_module(mrb, base, id); regs[a] = mrb_obj_value(cls); mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_EXEC, BB) { mrb_value recv = regs[a]; struct RProc *p; const mrb_irep *nirep = irep->reps[b]; /* prepare closure */ p = mrb_proc_new(mrb, nirep); p->c = NULL; mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)proc); MRB_PROC_SET_TARGET_CLASS(p, mrb_class_ptr(recv)); p->flags |= MRB_PROC_SCOPE; /* prepare call stack */ cipush(mrb, a, 0, mrb_class_ptr(recv), p, 0, 0); irep = p->body.irep; pool = irep->pool; syms = irep->syms; mrb_stack_extend(mrb, irep->nregs); stack_clear(regs+1, irep->nregs-1); pc = irep->iseq; JUMP; } CASE(OP_DEF, BB) { struct RClass *target = mrb_class_ptr(regs[a]); struct RProc *p = mrb_proc_ptr(regs[a+1]); mrb_method_t m; mrb_sym mid = syms[b]; MRB_METHOD_FROM_PROC(m, p); mrb_define_method_raw(mrb, target, mid, m); mrb_method_added(mrb, target, mid); mrb_gc_arena_restore(mrb, ai); regs[a] = mrb_symbol_value(mid); NEXT; } CASE(OP_SCLASS, B) { regs[a] = mrb_singleton_class(mrb, regs[a]); mrb_gc_arena_restore(mrb, ai); NEXT; } CASE(OP_TCLASS, B) { struct RClass *target = check_target_class(mrb); if (!target) goto L_RAISE; regs[a] = mrb_obj_value(target); NEXT; } CASE(OP_ALIAS, BB) { struct RClass *target = check_target_class(mrb); if (!target) goto L_RAISE; mrb_alias_method(mrb, target, syms[a], syms[b]); mrb_method_added(mrb, target, syms[a]); NEXT; } CASE(OP_UNDEF, B) { struct RClass *target = check_target_class(mrb); if (!target) goto L_RAISE; mrb_undef_method_id(mrb, target, syms[a]); NEXT; } CASE(OP_DEBUG, Z) { FETCH_BBB(); #ifdef MRB_USE_DEBUG_HOOK mrb->debug_op_hook(mrb, irep, pc, regs); #else #ifndef MRB_NO_STDIO printf("OP_DEBUG %d %d %d\n", a, b, c); #else abort(); #endif #endif NEXT; } CASE(OP_ERR, B) { size_t len = pool[a].tt >> 2; mrb_value exc; mrb_assert((pool[a].tt&IREP_TT_NFLAG)==0); exc = mrb_exc_new(mrb, E_LOCALJUMP_ERROR, pool[a].u.str, len); mrb_exc_set(mrb, exc); goto L_RAISE; } CASE(OP_EXT1, Z) { insn = READ_B(); switch (insn) { #define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _1(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY; #include "mruby/ops.h" #undef OPCODE } pc--; NEXT; } CASE(OP_EXT2, Z) { insn = READ_B(); switch (insn) { #define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _2(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY; #include "mruby/ops.h" #undef OPCODE } pc--; NEXT; } CASE(OP_EXT3, Z) { uint8_t insn = READ_B(); switch (insn) { #define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _3(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY; #include "mruby/ops.h" #undef OPCODE } pc--; NEXT; } CASE(OP_STOP, Z) { /* stop VM */ CHECKPOINT_RESTORE(RBREAK_TAG_STOP) { /* do nothing */ } CHECKPOINT_MAIN(RBREAK_TAG_STOP) { UNWIND_ENSURE(mrb, mrb->c->ci, pc, RBREAK_TAG_STOP, proc, mrb_nil_value()); } CHECKPOINT_END(RBREAK_TAG_STOP); L_STOP: mrb->jmp = prev_jmp; if (mrb->exc) { mrb_assert(mrb->exc->tt == MRB_TT_EXCEPTION); return mrb_obj_value(mrb->exc); } return regs[irep->nlocals]; } } END_DISPATCH; #undef regs } MRB_CATCH(&c_jmp) { mrb_callinfo *ci = mrb->c->ci; while (ci > mrb->c->cibase && ci->cci == CINFO_DIRECT) { ci = cipop(mrb); } exc_catched = TRUE; pc = ci->pc; goto RETRY_TRY_BLOCK; } MRB_END_EXC(&c_jmp); }
0
427,707
cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, uint32_t offs, cdf_property_info_t **info, size_t *count, size_t *maxcount) { const cdf_section_header_t *shp; cdf_section_header_t sh; const uint8_t *p, *q, *e; size_t i, o4, nelements, j, slen, left; cdf_property_info_t *inp; if (offs > UINT32_MAX / 4) { errno = EFTYPE; goto out; } shp = CAST(const cdf_section_header_t *, cdf_offset(sst->sst_tab, offs)); if (cdf_check_stream_offset(sst, h, shp, sizeof(*shp), __LINE__) == -1) goto out; sh.sh_len = CDF_TOLE4(shp->sh_len); if (sh.sh_len > CDF_SHLEN_LIMIT) { errno = EFTYPE; goto out; } if (cdf_check_stream_offset(sst, h, shp, sh.sh_len, __LINE__) == -1) goto out; sh.sh_properties = CDF_TOLE4(shp->sh_properties); DPRINTF(("section len: %u properties %u\n", sh.sh_len, sh.sh_properties)); if (sh.sh_properties > CDF_PROP_LIMIT) goto out; inp = cdf_grow_info(info, maxcount, sh.sh_properties); if (inp == NULL) goto out; inp += *count; *count += sh.sh_properties; p = CAST(const uint8_t *, cdf_offset(sst->sst_tab, offs + sizeof(sh))); e = CAST(const uint8_t *, cdf_offset(shp, sh.sh_len)); if (p >= e || cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1) goto out; for (i = 0; i < sh.sh_properties; i++) { if ((q = cdf_get_property_info_pos(sst, h, p, e, i)) == NULL) goto out; inp[i].pi_id = CDF_GETUINT32(p, i << 1); left = CAST(size_t, e - q); if (left < sizeof(uint32_t)) { DPRINTF(("short info (no type)_\n")); goto out; } inp[i].pi_type = CDF_GETUINT32(q, 0); DPRINTF(("%" SIZE_T_FORMAT "u) id=%#x type=%#x offs=%#tx,%#x\n", i, inp[i].pi_id, inp[i].pi_type, q - p, offs)); if (inp[i].pi_type & CDF_VECTOR) { if (left < sizeof(uint32_t) * 2) { DPRINTF(("missing CDF_VECTOR length\n")); goto out; } nelements = CDF_GETUINT32(q, 1); if (nelements > CDF_ELEMENT_LIMIT || nelements == 0) { DPRINTF(("CDF_VECTOR with nelements == %" SIZE_T_FORMAT "u\n", nelements)); goto out; } slen = 2; } else { nelements = 1; slen = 1; } o4 = slen * sizeof(uint32_t); if (inp[i].pi_type & (CDF_ARRAY|CDF_BYREF|CDF_RESERVED)) goto unknown; switch (inp[i].pi_type & CDF_TYPEMASK) { case CDF_NULL: case CDF_EMPTY: break; case CDF_SIGNED16: if (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int16_t))) goto unknown; break; case CDF_SIGNED32: case CDF_BOOL: case CDF_UNSIGNED32: case CDF_FLOAT: if (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int32_t))) goto unknown; break; case CDF_SIGNED64: case CDF_UNSIGNED64: case CDF_DOUBLE: case CDF_FILETIME: if (!cdf_copy_info(&inp[i], &q[o4], e, sizeof(int64_t))) goto unknown; break; case CDF_LENGTH32_STRING: case CDF_LENGTH32_WSTRING: if (nelements > 1) { size_t nelem = inp - *info; inp = cdf_grow_info(info, maxcount, nelements); if (inp == NULL) goto out; inp += nelem; } for (j = 0; j < nelements && i < sh.sh_properties; j++, i++) { uint32_t l; if (o4 + sizeof(uint32_t) > left) goto out; l = CDF_GETUINT32(q, slen); o4 += sizeof(uint32_t); if (o4 + l > left) goto out; inp[i].pi_str.s_len = l; inp[i].pi_str.s_buf = CAST(const char *, CAST(const void *, &q[o4])); DPRINTF(("o=%" SIZE_T_FORMAT "u l=%d(%" SIZE_T_FORMAT "u), t=%" SIZE_T_FORMAT "u s=%s\n", o4, l, CDF_ROUND(l, sizeof(l)), left, inp[i].pi_str.s_buf)); if (l & 1) l++; slen += l >> 1; o4 = slen * sizeof(uint32_t); } i--; break; case CDF_CLIPBOARD: if (inp[i].pi_type & CDF_VECTOR) goto unknown; break; default: unknown: memset(&inp[i].pi_val, 0, sizeof(inp[i].pi_val)); DPRINTF(("Don't know how to deal with %#x\n", inp[i].pi_type)); break; } } return 0; out: free(*info); *info = NULL; *count = 0; *maxcount = 0; errno = EFTYPE; return -1; }
0
500,699
int sftp_extension_supported(sftp_session sftp, const char *name, const char *data) { int i, n; n = sftp_extensions_get_count(sftp); for (i = 0; i < n; i++) { if (strcmp(sftp_extensions_get_name(sftp, i), name) == 0 && strcmp(sftp_extensions_get_data(sftp, i), data) == 0) { return 1; } } return 0; }
0
373,521
ipf_print_reass_packet(const char *es, const void *pkt) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 10); if (!VLOG_DROP_WARN(&rl)) { struct ds ds = DS_EMPTY_INITIALIZER; ds_put_hex_dump(&ds, pkt, 128, 0, false); VLOG_WARN("%s\n%s", es, ds_cstr(&ds)); ds_destroy(&ds); } }
0
364,747
get_tag_details(taggy_T *tag, dict_T *retdict) { list_T *pos; fmark_T *fmark; dict_add_string(retdict, "tagname", tag->tagname); dict_add_number(retdict, "matchnr", tag->cur_match + 1); dict_add_number(retdict, "bufnr", tag->cur_fnum); if (tag->user_data) dict_add_string(retdict, "user_data", tag->user_data); if ((pos = list_alloc_id(aid_tagstack_from)) == NULL) return; dict_add_list(retdict, "from", pos); fmark = &tag->fmark; list_append_number(pos, (varnumber_T)(fmark->fnum != -1 ? fmark->fnum : 0)); list_append_number(pos, (varnumber_T)fmark->mark.lnum); list_append_number(pos, (varnumber_T)(fmark->mark.col == MAXCOL ? MAXCOL : fmark->mark.col + 1)); list_append_number(pos, (varnumber_T)fmark->mark.coladd); }
0
252,467
static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n) { char buf[4096]; memset(buf, 0, MZ_MIN(sizeof(buf), n)); while (n) { mz_uint32 s = MZ_MIN(sizeof(buf), n); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s) return MZ_FALSE; cur_file_ofs += s; n -= s; } return MZ_TRUE; }
0
313,752
nv_csearch(cmdarg_T *cap) { int t_cmd; if (cap->cmdchar == 't' || cap->cmdchar == 'T') t_cmd = TRUE; else t_cmd = FALSE; cap->oap->motion_type = MCHAR; if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL) clearopbeep(cap->oap); else { curwin->w_set_curswant = TRUE; // Include a Tab for "tx" and for "dfx". if (gchar_cursor() == TAB && virtual_active() && cap->arg == FORWARD && (t_cmd || cap->oap->op_type != OP_NOP)) { colnr_T scol, ecol; getvcol(curwin, &curwin->w_cursor, &scol, NULL, &ecol); curwin->w_cursor.coladd = ecol - scol; } else curwin->w_cursor.coladd = 0; adjust_for_sel(cap); #ifdef FEAT_FOLDING if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP) foldOpenCursor(); #endif } }
0
267,833
vm_execute (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ { while (true) { ecma_value_t completion_value = vm_loop (frame_ctx_p); switch (frame_ctx_p->call_operation) { case VM_EXEC_CALL: { opfunc_call (frame_ctx_p); break; } #if JERRY_ESNEXT case VM_EXEC_SUPER_CALL: { vm_super_call (frame_ctx_p); break; } case VM_EXEC_SPREAD_OP: { vm_spread_operation (frame_ctx_p); break; } case VM_EXEC_RETURN: { return completion_value; } #endif /* JERRY_ESNEXT */ case VM_EXEC_CONSTRUCT: { opfunc_construct (frame_ctx_p); break; } default: { JERRY_ASSERT (frame_ctx_p->call_operation == VM_NO_EXEC_OP); const ecma_compiled_code_t *bytecode_header_p = frame_ctx_p->shared_p->bytecode_header_p; uint32_t register_end; if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS) { register_end = ((cbc_uint16_arguments_t *) bytecode_header_p)->register_end; } else { register_end = ((cbc_uint8_arguments_t *) bytecode_header_p)->register_end; } /* Free arguments and registers */ ecma_value_t *registers_p = VM_GET_REGISTERS (frame_ctx_p); for (uint32_t i = 0; i < register_end; i++) { ecma_fast_free_value (registers_p[i]); } #if JERRY_DEBUGGER if (JERRY_CONTEXT (debugger_stop_context) == JERRY_CONTEXT (vm_top_context_p)) { /* The engine will stop when the next breakpoint is reached. */ JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_STOP); JERRY_CONTEXT (debugger_stop_context) = NULL; } #endif /* JERRY_DEBUGGER */ JERRY_CONTEXT (vm_top_context_p) = frame_ctx_p->prev_context_p; return completion_value; } } } } /* vm_execute */
0
231,034
QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) { QueueHandle_t xNewQueue; const UBaseType_t uxMutexLength = ( UBaseType_t ) 1, uxMutexSize = ( UBaseType_t ) 0; xNewQueue = xQueueGenericCreate( uxMutexLength, uxMutexSize, ucQueueType ); prvInitialiseMutex( ( Queue_t * ) xNewQueue ); return xNewQueue; }
0
317,308
static void selinux_perf_event_free(struct perf_event *event) { struct perf_event_security_struct *perfsec = event->security; event->security = NULL; kfree(perfsec); }
0
279,947
free_old_sub(void) { vim_free(old_sub); }
0
508,413
open_and_process_routine(THD *thd, Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt, Prelocking_strategy *prelocking_strategy, bool has_prelocking_list, Open_table_context *ot_ctx, bool *need_prelocking, bool *routine_modifies_data) { MDL_key::enum_mdl_namespace mdl_type= rt->mdl_request.key.mdl_namespace(); DBUG_ENTER("open_and_process_routine"); *routine_modifies_data= false; switch (mdl_type) { case MDL_key::FUNCTION: case MDL_key::PROCEDURE: { sp_head *sp; /* Try to get MDL lock on the routine. Note that we do not take locks on top-level CALLs as this can lead to a deadlock. Not locking top-level CALLs does not break the binlog as only the statements in the called procedure show up there, not the CALL itself. */ if (rt != (Sroutine_hash_entry*)prelocking_ctx->sroutines_list.first || mdl_type != MDL_key::PROCEDURE) { /* Since we acquire only shared lock on routines we don't need to care about global intention exclusive locks. */ DBUG_ASSERT(rt->mdl_request.type == MDL_SHARED); /* Waiting for a conflicting metadata lock to go away may lead to a deadlock, detected by MDL subsystem. If possible, we try to resolve such deadlocks by releasing all metadata locks and restarting the pre-locking process. To prevent the error from polluting the diagnostics area in case of successful resolution, install a special error handler for ER_LOCK_DEADLOCK error. */ MDL_deadlock_handler mdl_deadlock_handler(ot_ctx); thd->push_internal_handler(&mdl_deadlock_handler); bool result= thd->mdl_context.acquire_lock(&rt->mdl_request, ot_ctx->get_timeout()); thd->pop_internal_handler(); if (result) DBUG_RETURN(TRUE); DEBUG_SYNC(thd, "after_shared_lock_pname"); /* Ensures the routine is up-to-date and cached, if exists. */ if (sp_cache_routine(thd, rt, has_prelocking_list, &sp)) DBUG_RETURN(TRUE); /* Remember the version of the routine in the parse tree. */ if (check_and_update_routine_version(thd, rt, sp)) DBUG_RETURN(TRUE); /* 'sp' is NULL when there is no such routine. */ if (sp) { *routine_modifies_data= sp->modifies_data(); if (!has_prelocking_list) prelocking_strategy->handle_routine(thd, prelocking_ctx, rt, sp, need_prelocking); } } else { /* If it's a top level call, just make sure we have a recent version of the routine, if it exists. Validating routine version is unnecessary, since CALL does not affect the prepared statement prelocked list. */ if (sp_cache_routine(thd, rt, FALSE, &sp)) DBUG_RETURN(TRUE); } } break; case MDL_key::TRIGGER: /** We add trigger entries to lex->sroutines_list, but we don't load them here. The trigger entry is only used when building a transitive closure of objects used in a statement, to avoid adding to this closure objects that are used in the trigger more than once. E.g. if a trigger trg refers to table t2, and the trigger table t1 is used multiple times in the statement (say, because it's used in function f1() twice), we will only add t2 once to the list of tables to prelock. We don't take metadata locks on triggers either: they are protected by a respective lock on the table, on which the trigger is defined. The only two cases which give "trouble" are SHOW CREATE TRIGGER and DROP TRIGGER statements. For these, statement syntax doesn't specify the table on which this trigger is defined, so we have to make a "dirty" read in the data dictionary to find out the table name. Once we discover the table name, we take a metadata lock on it, and this protects all trigger operations. Of course the table, in theory, may disappear between the dirty read and metadata lock acquisition, but in that case we just return a run-time error. Grammar of other trigger DDL statements (CREATE, DROP) requires the table to be specified explicitly, so we use the table metadata lock to protect trigger metadata in these statements. Similarly, in DML we always use triggers together with their tables, and thus don't need to take separate metadata locks on them. */ break; default: /* Impossible type value. */ DBUG_ASSERT(0); } DBUG_RETURN(FALSE); }
0
445,884
fr_window_archive_extract (FrWindow *window, GList *file_list, GFile *destination, const char *base_dir, gboolean skip_older, FrOverwrite overwrite, gboolean junk_paths, gboolean ask_to_open_destination) { ExtractData *edata; gboolean do_not_extract = FALSE; GError *error = NULL; edata = extract_data_new (window, file_list, destination, base_dir, skip_older, overwrite, junk_paths, FALSE, ask_to_open_destination); fr_window_set_current_batch_action (window, FR_BATCH_ACTION_EXTRACT, edata, (GFreeFunc) extract_data_free); if (archive_is_encrypted (window, edata->file_list) && (window->priv->password == NULL)) { dlg_ask_password (window); return; } if (! _g_file_query_is_dir (edata->destination)) { /* There is nothing to ask if the destination doesn't exist. */ if (edata->overwrite == FR_OVERWRITE_ASK) edata->overwrite = FR_OVERWRITE_YES; if (! ForceDirectoryCreation) { GtkWidget *d; int r; char *folder_name; char *msg; folder_name = _g_file_get_display_basename (edata->destination); msg = g_strdup_printf (_("Destination folder \"%s\" does not exist.\n\nDo you want to create it?"), folder_name); g_free (folder_name); d = _gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_QUESTION, msg, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("Create _Folder"), GTK_RESPONSE_YES, NULL); gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_YES); r = gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_free (msg); if (r != GTK_RESPONSE_YES) do_not_extract = TRUE; } if (! do_not_extract && ! _g_file_make_directory_tree (edata->destination, 0755, &error)) { GtkWidget *d; char *details; details = g_strdup_printf (_("Could not create the destination folder: %s."), error->message); d = _gtk_error_dialog_new (GTK_WINDOW (window), 0, NULL, _("Extraction not performed"), "%s", details); g_clear_error (&error); fr_window_show_error_dialog (window, d, GTK_WINDOW (window), details); fr_window_stop_batch (window); g_free (details); return; } } if (do_not_extract) { GtkWidget *d; d = _gtk_message_dialog_new (GTK_WINDOW (window), 0, GTK_STOCK_DIALOG_WARNING, _("Extraction not performed"), NULL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_OK); fr_window_show_error_dialog (window, d, GTK_WINDOW (window), _("Extraction not performed")); fr_window_stop_batch (window); return; } if (edata->overwrite == FR_OVERWRITE_ASK) { OverwriteData *odata; odata = g_new0 (OverwriteData, 1); odata->window = window; odata->edata = edata; odata->extract_all = (edata->file_list == NULL) || (g_list_length (edata->file_list) == window->archive->files->len); if (edata->file_list == NULL) edata->file_list = fr_window_get_file_list (window); odata->current_file = odata->edata->file_list; _fr_window_ask_overwrite_dialog (odata); } else _fr_window_archive_extract_from_edata (window, edata); }
0
210,282
static int i2c_ddc_rx(I2CSlave *i2c) { I2CDDCState *s = I2CDDC(i2c); int value; value = s->edid_blob[s->reg]; s->reg++; return value; }
1
500,660
void sftp_file_set_nonblocking(sftp_file handle){ handle->nonblocking=1; }
0
247,612
const std::string& clientCtxYaml() const { return client_ctx_yaml_; }
0
224,571
Status Conv2DBackpropInputShape(shape_inference::InferenceContext* c) { string data_format_str; if (!c->GetAttr("data_format", &data_format_str).ok()) { data_format_str = "NHWC"; } TensorFormat data_format; if (!FormatFromString(data_format_str, &data_format)) { return errors::InvalidArgument("Invalid data format string: ", data_format_str); } // For the rest of this function, output_grad_* describes out_backprop and // input_grad_* describes in_backprop. ShapeHandle output_grad_shape = c->input(2); TF_RETURN_IF_ERROR(c->WithRank(output_grad_shape, 4, &output_grad_shape)); ShapeHandle filter_shape = c->input(1); TF_RETURN_IF_ERROR(c->WithRank(filter_shape, 4, &filter_shape)); DimensionHandle batch_size_dim; DimensionHandle output_grad_depth_dim; gtl::InlinedVector<DimensionHandle, 2> output_grad_spatial_dims(2); TF_RETURN_IF_ERROR(DimensionsFromShape( output_grad_shape, data_format, &batch_size_dim, absl::MakeSpan(output_grad_spatial_dims), &output_grad_depth_dim, c)); DimensionHandle unused; TF_RETURN_IF_ERROR( c->Merge(output_grad_depth_dim, c->Dim(filter_shape, 3), &unused)); ShapeHandle specified_input_grad_shape; TF_RETURN_IF_ERROR( c->MakeShapeFromShapeTensor(0, &specified_input_grad_shape)); if (c->Rank(specified_input_grad_shape) == InferenceContext::kUnknownRank) { TF_RETURN_IF_ERROR(c->WithRank(specified_input_grad_shape, 4, &specified_input_grad_shape)); } // input_grad_depth_dim doesn't equal c->Dim(filter_shape,2) when the number // of groups is larger than 1. If input_sizes is a 4D shape, we collect // input_grad_depth_dim from input_sizes; otherwise we compute it as // c->Dim(filter_shape,2). DimensionHandle input_grad_depth_dim; gtl::InlinedVector<DimensionHandle, 2> specified_input_grad_spatial_dims(2); int specified_input_grad_rank = c->Rank(specified_input_grad_shape); if (specified_input_grad_rank == 4) { DimensionHandle specified_batch_size_dim; TF_RETURN_IF_ERROR(DimensionsFromShape( specified_input_grad_shape, data_format, &specified_batch_size_dim, absl::MakeSpan(specified_input_grad_spatial_dims), &input_grad_depth_dim, c)); TF_RETURN_IF_ERROR( c->Merge(specified_batch_size_dim, batch_size_dim, &unused)); } else if (specified_input_grad_rank == 2) { specified_input_grad_spatial_dims[0] = c->Dim(specified_input_grad_shape, 0); specified_input_grad_spatial_dims[1] = c->Dim(specified_input_grad_shape, 1); input_grad_depth_dim = c->Dim(filter_shape, 2); } else { return errors::InvalidArgument( "Conv2DBackpropInput requires input_sizes to contain 4 values or 2 " "values, but got: ", specified_input_grad_rank); } ShapeHandle input_grad_shape; TF_RETURN_IF_ERROR(ShapeFromDimensions( batch_size_dim, specified_input_grad_spatial_dims, input_grad_depth_dim, data_format, /*vect_size=*/absl::nullopt, c, &input_grad_shape)); c->set_output(0, input_grad_shape); return Status::OK(); }
0
301,395
static struct dirent *vfswrap_readdir(vfs_handle_struct *handle, DIR *dirp, SMB_STRUCT_STAT *sbuf) { struct dirent *result; START_PROFILE(syscall_readdir); result = readdir(dirp); END_PROFILE(syscall_readdir); if (sbuf) { /* Default Posix readdir() does not give us stat info. * Set to invalid to indicate we didn't return this info. */ SET_STAT_INVALID(*sbuf); #if defined(HAVE_DIRFD) && defined(HAVE_FSTATAT) if (result != NULL) { /* See if we can efficiently return this. */ struct stat st; int flags = (lp_posix_pathnames() ? AT_SYMLINK_NOFOLLOW : 0); int ret = fstatat(dirfd(dirp), result->d_name, &st, flags); if (ret == 0) { init_stat_ex_from_stat(sbuf, &st, lp_fake_dir_create_times( SNUM(handle->conn))); } } #endif } return result; }
0
491,910
static ssize_t fuse_perform_write(struct file *file, struct address_space *mapping, struct iov_iter *ii, loff_t pos) { struct inode *inode = mapping->host; struct fuse_conn *fc = get_fuse_conn(inode); int err = 0; ssize_t res = 0; if (is_bad_inode(inode)) return -EIO; do { struct fuse_req *req; ssize_t count; req = fuse_get_req(fc); if (IS_ERR(req)) { err = PTR_ERR(req); break; } count = fuse_fill_write_pages(req, mapping, ii, pos); if (count <= 0) { err = count; } else { size_t num_written; num_written = fuse_send_write_pages(req, file, inode, pos, count); err = req->out.h.error; if (!err) { res += num_written; pos += num_written; /* break out of the loop on short write */ if (num_written != count) err = -EIO; } } fuse_put_request(fc, req); } while (!err && iov_iter_count(ii)); if (res > 0) fuse_write_update_size(inode, pos); fuse_invalidate_attr(inode); return res > 0 ? res : err; }
0
336,544
SPICE_GNUC_VISIBLE int spice_server_set_tls(SpiceServer *s, int port, const char *ca_cert_file, const char *certs_file, const char *private_key_file, const char *key_passwd, const char *dh_key_file, const char *ciphersuite) { if (port == 0 || ca_cert_file == NULL || certs_file == NULL || private_key_file == NULL) { return -1; } if (port < 0 || port > 0xffff) { return -1; } memset(&s->config->ssl_parameters, 0, sizeof(s->config->ssl_parameters)); s->config->spice_secure_port = port; g_strlcpy(s->config->ssl_parameters.ca_certificate_file, ca_cert_file, sizeof(s->config->ssl_parameters.ca_certificate_file)); g_strlcpy(s->config->ssl_parameters.certs_file, certs_file, sizeof(s->config->ssl_parameters.certs_file)); g_strlcpy(s->config->ssl_parameters.private_key_file, private_key_file, sizeof(s->config->ssl_parameters.private_key_file)); if (key_passwd) { g_strlcpy(s->config->ssl_parameters.keyfile_password, key_passwd, sizeof(s->config->ssl_parameters.keyfile_password)); } if (ciphersuite) { g_strlcpy(s->config->ssl_parameters.ciphersuite, ciphersuite, sizeof(s->config->ssl_parameters.ciphersuite)); } if (dh_key_file) { g_strlcpy(s->config->ssl_parameters.dh_key_file, dh_key_file, sizeof(s->config->ssl_parameters.dh_key_file)); } return 0; }
0
244,091
GF_Err lsr1_box_read(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_LASeRSampleEntryBox *ptr = (GF_LASeRSampleEntryBox*)s; e = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)ptr, bs); if (e) return e; ISOM_DECREASE_SIZE(ptr, 8); return gf_isom_box_array_read(s, bs); }
0
231,666
TEST_F(QuicServerTransportTest, SetCongestionControl) { // Default: Cubic auto cc = server->getConn().congestionController.get(); EXPECT_EQ(CongestionControlType::Cubic, cc->type()); // Change to Reno server->setCongestionControl(CongestionControlType::NewReno); cc = server->getConn().congestionController.get(); EXPECT_EQ(CongestionControlType::NewReno, cc->type()); // Change back to Cubic: server->setCongestionControl(CongestionControlType::Cubic); cc = server->getConn().congestionController.get(); EXPECT_EQ(CongestionControlType::Cubic, cc->type()); }
0
386,563
void DL_Dxf::addDimDiametric(DL_CreationInterface* creationInterface) { DL_DimensionData d = getDimData(); // diametric dimension: DL_DimDiametricData dr( // definition point getRealValue(15, 0.0), getRealValue(25, 0.0), getRealValue(35, 0.0), // leader length: getRealValue(40, 0.0)); creationInterface->addDimDiametric(d, dr); }
0
274,732
callbacks_new_project_activate (GtkMenuItem *menuitem, gpointer user_data) { if (mainProject->last_loaded >= 0) { if (!interface_get_alert_dialog_response ( _("Do you want to close any open layers " "and start a new project?"), _("Starting a new project will cause all currently " "open layers to be closed. Any unsaved changes " "will be lost."), FALSE, NULL, GTK_STOCK_CLOSE, GTK_STOCK_CANCEL)) return; } /* Unload all layers and then clear layer window */ gerbv_unload_all_layers (mainProject); callbacks_update_layer_tree (); selection_clear (&screen.selectionInfo); update_selected_object_message (FALSE); /* Destroy project info */ if (mainProject->project) { g_free(mainProject->project); mainProject->project = NULL; } render_refresh_rendered_image_on_screen(); }
0
385,859
SYSCALL_DEFINE0(vhangup) { if (capable(CAP_SYS_TTY_CONFIG)) { tty_vhangup_self(); return 0; } return -EPERM; }
0
226,248
GF_Err clap_box_write(GF_Box *s, GF_BitStream *bs) { GF_CleanApertureBox *ptr = (GF_CleanApertureBox *)s; GF_Err e = gf_isom_box_write_header(s, bs); if (e) return e; gf_bs_write_u32(bs, ptr->cleanApertureWidthN); gf_bs_write_u32(bs, ptr->cleanApertureWidthD); gf_bs_write_u32(bs, ptr->cleanApertureHeightN); gf_bs_write_u32(bs, ptr->cleanApertureHeightD); gf_bs_write_u32(bs, (u32) ptr->horizOffN); gf_bs_write_u32(bs, ptr->horizOffD); gf_bs_write_u32(bs, (u32) ptr->vertOffN); gf_bs_write_u32(bs, ptr->vertOffD); return GF_OK;
0
316,953
static int selinux_kernel_create_files_as(struct cred *new, struct inode *inode) { struct inode_security_struct *isec = inode_security(inode); struct task_security_struct *tsec = selinux_cred(new); u32 sid = current_sid(); int ret; ret = avc_has_perm(&selinux_state, sid, isec->sid, SECCLASS_KERNEL_SERVICE, KERNEL_SERVICE__CREATE_FILES_AS, NULL); if (ret == 0) tsec->create_sid = isec->sid; return ret; }
0
512,693
int Arg_comparator::compare_e_real() { double val1= (*a)->val_real(); double val2= (*b)->val_real(); if ((*a)->null_value || (*b)->null_value) return MY_TEST((*a)->null_value && (*b)->null_value); return MY_TEST(val1 == val2); }
0
409,523
check_shellsize(void) { if (Rows < min_rows()) // need room for one window and command line Rows = min_rows(); limit_screen_size(); // make sure these values are not invalid if (cmdline_row >= Rows) cmdline_row = Rows - 1; if (msg_row >= Rows) msg_row = Rows - 1; }
0
317,037
static int selinux_kernel_act_as(struct cred *new, u32 secid) { struct task_security_struct *tsec = selinux_cred(new); u32 sid = current_sid(); int ret; ret = avc_has_perm(&selinux_state, sid, secid, SECCLASS_KERNEL_SERVICE, KERNEL_SERVICE__USE_AS_OVERRIDE, NULL); if (ret == 0) { tsec->sid = secid; tsec->create_sid = 0; tsec->keycreate_sid = 0; tsec->sockcreate_sid = 0; } return ret; }
0