idx
int64
func
string
target
int64
450,833
int st21nfca_hci_se_io(struct nfc_hci_dev *hdev, u32 se_idx, u8 *apdu, size_t apdu_length, se_io_cb_t cb, void *cb_context) { struct st21nfca_hci_info *info = nfc_hci_get_clientdata(hdev); pr_debug("se_io %x\n", se_idx); switch (se_idx) { case ST21NFCA_ESE_HOST_ID: info->se_info.cb = cb; info->se_info.cb_context = cb_context; mod_timer(&info->se_info.bwi_timer, jiffies + msecs_to_jiffies(info->se_info.wt_timeout)); info->se_info.bwi_active = true; return nfc_hci_send_event(hdev, ST21NFCA_APDU_READER_GATE, ST21NFCA_EVT_TRANSMIT_DATA, apdu, apdu_length); default: return -ENODEV; } }
0
226,399
void fiin_box_del(GF_Box *s) { FDItemInformationBox *ptr = (FDItemInformationBox *)s; if (ptr == NULL) return; if (ptr->partition_entries) gf_list_del(ptr->partition_entries); gf_free(ptr);
0
312,459
qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title) { dictitem_T *di; int retval = FAIL; int qf_idx; int newlist = FALSE; qf_list_T *qfl; if (action == ' ' || qf_stack_empty(qi)) newlist = TRUE; qf_idx = qf_setprop_get_qfidx(qi, what, action, &newlist); if (qf_idx == INVALID_QFIDX) // List not found return FAIL; if (newlist) { qi->qf_curlist = qf_idx; qf_new_list(qi, title); qf_idx = qi->qf_curlist; } qfl = qf_get_list(qi, qf_idx); if ((di = dict_find(what, (char_u *)"title", -1)) != NULL) retval = qf_setprop_title(qi, qf_idx, what, di); if ((di = dict_find(what, (char_u *)"items", -1)) != NULL) retval = qf_setprop_items(qi, qf_idx, di, action); if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL) retval = qf_setprop_items_from_lines(qi, qf_idx, what, di, action); if ((di = dict_find(what, (char_u *)"context", -1)) != NULL) retval = qf_setprop_context(qfl, di); if ((di = dict_find(what, (char_u *)"idx", -1)) != NULL) retval = qf_setprop_curidx(qi, qfl, di); if ((di = dict_find(what, (char_u *)"quickfixtextfunc", -1)) != NULL) retval = qf_setprop_qftf(qi, qfl, di); if (newlist || retval == OK) qf_list_changed(qfl); if (newlist) qf_update_buffer(qi, NULL); return retval; }
0
359,636
DEFUN (show_ip_community_list, show_ip_community_list_cmd, "show ip community-list", SHOW_STR IP_STR "List community-list\n") { struct community_list *list; struct community_list_master *cm; cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); if (! cm) return CMD_SUCCESS; for (list = cm->num.head; list; list = list->next) community_list_show (vty, list); for (list = cm->str.head; list; list = list->next) community_list_show (vty, list); return CMD_SUCCESS; }
0
252,297
mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip) { return pZip ? pZip->m_total_files : 0; }
0
214,339
int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu) { struct rtas_token_definition *d; struct rtas_args args; rtas_arg_t *orig_rets; gpa_t args_phys; int rc; /* * r4 contains the guest physical address of the RTAS args * Mask off the top 4 bits since this is a guest real address */ args_phys = kvmppc_get_gpr(vcpu, 4) & KVM_PAM; vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); rc = kvm_read_guest(vcpu->kvm, args_phys, &args, sizeof(args)); srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); if (rc) goto fail; /* * args->rets is a pointer into args->args. Now that we've * copied args we need to fix it up to point into our copy, * not the guest args. We also need to save the original * value so we can restore it on the way out. */ orig_rets = args.rets; args.rets = &args.args[be32_to_cpu(args.nargs)]; mutex_lock(&vcpu->kvm->arch.rtas_token_lock); rc = -ENOENT; list_for_each_entry(d, &vcpu->kvm->arch.rtas_tokens, list) { if (d->token == be32_to_cpu(args.token)) { d->handler->handler(vcpu, &args); rc = 0; break; } } mutex_unlock(&vcpu->kvm->arch.rtas_token_lock); if (rc == 0) { args.rets = orig_rets; rc = kvm_write_guest(vcpu->kvm, args_phys, &args, sizeof(args)); if (rc) goto fail; } return rc; fail: /* * We only get here if the guest has called RTAS with a bogus * args pointer. That means we can't get to the args, and so we * can't fail the RTAS call. So fail right out to userspace, * which should kill the guest. */ return rc; }
1
254,879
Value DocumentSourceGroup::expandId(const Value& val) { // _id doesn't get wrapped in a document if (_idFieldNames.empty()) return val; // _id is a single-field document containing val if (_idFieldNames.size() == 1) return Value(DOC(_idFieldNames[0] << val)); // _id is a multi-field document containing the elements of val const vector<Value>& vals = val.getArray(); invariant(_idFieldNames.size() == vals.size()); MutableDocument md(vals.size()); for (size_t i = 0; i < vals.size(); i++) { md[_idFieldNames[i]] = vals[i]; } return md.freezeToValue(); }
0
338,102
void WasmBinaryBuilder::visitThrow(Throw* curr) { BYN_TRACE("zz node: Throw\n"); auto index = getU32LEB(); if (index >= wasm.tags.size()) { throwError("bad tag index"); } auto* tag = wasm.tags[index].get(); curr->tag = tag->name; size_t num = tag->sig.params.size(); curr->operands.resize(num); for (size_t i = 0; i < num; i++) { curr->operands[num - i - 1] = popNonVoidExpression(); } curr->finalize(); }
0
275,995
void uECC_point_mult(uECC_word_t *result, const uECC_word_t *point, const uECC_word_t *scalar, uECC_Curve curve) { uECC_word_t tmp1[uECC_MAX_WORDS]; uECC_word_t tmp2[uECC_MAX_WORDS]; uECC_word_t *p2[2] = {tmp1, tmp2}; uECC_word_t carry = regularize_k(scalar, tmp1, tmp2, curve); EccPoint_mult(result, point, p2[!carry], 0, curve->num_n_bits + 1, curve); }
0
294,608
d_lite_yday(VALUE self) { get_d1(self); return INT2FIX(m_yday(dat)); }
0
441,827
SProcXkbGetKbdByName(ClientPtr client) { REQUEST(xkbGetKbdByNameReq); swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq); swaps(&stuff->deviceSpec); swaps(&stuff->want); swaps(&stuff->need); return ProcXkbGetKbdByName(client); }
0
253,630
smb2_dump_detail(void *buf, struct TCP_Server_Info *server) { #ifdef CONFIG_CIFS_DEBUG2 struct smb2_hdr *shdr = (struct smb2_hdr *)buf; cifs_server_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n", shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId, shdr->Id.SyncId.ProcessId); cifs_server_dbg(VFS, "smb buf %p len %u\n", buf, server->ops->calc_smb_size(buf, server)); #endif }
0
225,596
GF_Box *leva_box_new() { ISOM_DECL_BOX_ALLOC(GF_LevelAssignmentBox, GF_ISOM_BOX_TYPE_LEVA); return (GF_Box *)tmp;
0
226,076
GF_Err fdpa_box_read(GF_Box *s, GF_BitStream *bs) { u32 i; GF_FDpacketBox *ptr = (GF_FDpacketBox *)s; ISOM_DECREASE_SIZE(ptr, 3); ptr->info.sender_current_time_present = gf_bs_read_int(bs, 1); ptr->info.expected_residual_time_present = gf_bs_read_int(bs, 1); ptr->info.session_close_bit = gf_bs_read_int(bs, 1); ptr->info.object_close_bit = gf_bs_read_int(bs, 1); gf_bs_read_int(bs, 4); ptr->info.transport_object_identifier = gf_bs_read_u16(bs); ISOM_DECREASE_SIZE(ptr, 2); ptr->header_ext_count = gf_bs_read_u16(bs); if (ptr->size / 2 < ptr->header_ext_count) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Invalid number of entries %d in fdpa\n", ptr->header_ext_count)); return GF_ISOM_INVALID_FILE; } GF_SAFE_ALLOC_N(ptr->headers, ptr->header_ext_count, GF_LCTheaderExtension); if (!ptr->headers) return GF_OUT_OF_MEM; for (i=0; i<ptr->header_ext_count; i++) { ptr->headers[i].header_extension_type = gf_bs_read_u8(bs); ISOM_DECREASE_SIZE(ptr, 1); if (ptr->headers[i].header_extension_type > 127) { ISOM_DECREASE_SIZE(ptr, 3); gf_bs_read_data(bs, (char *) ptr->headers[i].content, 3); } else { ISOM_DECREASE_SIZE(ptr, 1); ptr->headers[i].data_length = gf_bs_read_u8(bs); if (ptr->headers[i].data_length) { ptr->headers[i].data_length = 4*ptr->headers[i].data_length - 2; if (ptr->size < sizeof(char) * ptr->headers[i].data_length) return GF_ISOM_INVALID_FILE; ptr->headers[i].data = gf_malloc(sizeof(char) * ptr->headers[i].data_length); if (!ptr->headers[i].data) return GF_OUT_OF_MEM; ISOM_DECREASE_SIZE(ptr, ptr->headers[i].data_length); gf_bs_read_data(bs, ptr->headers[i].data, ptr->headers[i].data_length); } } } return GF_OK;
0
242,986
int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) { int ret, done = 0; size_t len = ssl->out_msglen; uint8_t flush = force_flush; MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write record" ) ); #if defined(MBEDTLS_ZLIB_SUPPORT) if( ssl->transform_out != NULL && ssl->session_out->compression == MBEDTLS_SSL_COMPRESS_DEFLATE ) { if( ( ret = ssl_compress_buf( ssl ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "ssl_compress_buf", ret ); return( ret ); } len = ssl->out_msglen; } #endif /*MBEDTLS_ZLIB_SUPPORT */ #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) if( mbedtls_ssl_hw_record_write != NULL ) { MBEDTLS_SSL_DEBUG_MSG( 2, ( "going for mbedtls_ssl_hw_record_write()" ) ); ret = mbedtls_ssl_hw_record_write( ssl ); if( ret != 0 && ret != MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_hw_record_write", ret ); return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED ); } if( ret == 0 ) done = 1; } #endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */ if( !done ) { unsigned i; size_t protected_record_size; #if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH) size_t out_buf_len = ssl->out_buf_len; #else size_t out_buf_len = MBEDTLS_SSL_OUT_BUFFER_LEN; #endif /* Skip writing the record content type to after the encryption, * as it may change when using the CID extension. */ mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, ssl->conf->transport, ssl->out_hdr + 1 ); memcpy( ssl->out_ctr, ssl->cur_out_ctr, 8 ); MBEDTLS_PUT_UINT16_BE( len, ssl->out_len, 0); if( ssl->transform_out != NULL ) { mbedtls_record rec; rec.buf = ssl->out_iv; rec.buf_len = out_buf_len - ( ssl->out_iv - ssl->out_buf ); rec.data_len = ssl->out_msglen; rec.data_offset = ssl->out_msg - rec.buf; memcpy( &rec.ctr[0], ssl->out_ctr, 8 ); mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, ssl->conf->transport, rec.ver ); rec.type = ssl->out_msgtype; #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) /* The CID is set by mbedtls_ssl_encrypt_buf(). */ rec.cid_len = 0; #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ if( ( ret = mbedtls_ssl_encrypt_buf( ssl, ssl->transform_out, &rec, ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "ssl_encrypt_buf", ret ); return( ret ); } if( rec.data_offset != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } /* Update the record content type and CID. */ ssl->out_msgtype = rec.type; #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID ) memcpy( ssl->out_cid, rec.cid, rec.cid_len ); #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ ssl->out_msglen = len = rec.data_len; MBEDTLS_PUT_UINT16_BE( rec.data_len, ssl->out_len, 0 ); } protected_record_size = len + mbedtls_ssl_out_hdr_len( ssl ); #if defined(MBEDTLS_SSL_PROTO_DTLS) /* In case of DTLS, double-check that we don't exceed * the remaining space in the datagram. */ if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) { ret = ssl_get_remaining_space_in_datagram( ssl ); if( ret < 0 ) return( ret ); if( protected_record_size > (size_t) ret ) { /* Should never happen */ return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } } #endif /* MBEDTLS_SSL_PROTO_DTLS */ /* Now write the potentially updated record content type. */ ssl->out_hdr[0] = (unsigned char) ssl->out_msgtype; MBEDTLS_SSL_DEBUG_MSG( 3, ( "output record: msgtype = %u, " "version = [%u:%u], msglen = %" MBEDTLS_PRINTF_SIZET, ssl->out_hdr[0], ssl->out_hdr[1], ssl->out_hdr[2], len ) ); MBEDTLS_SSL_DEBUG_BUF( 4, "output record sent to network", ssl->out_hdr, protected_record_size ); ssl->out_left += protected_record_size; ssl->out_hdr += protected_record_size; mbedtls_ssl_update_out_pointers( ssl, ssl->transform_out ); for( i = 8; i > mbedtls_ssl_ep_len( ssl ); i-- ) if( ++ssl->cur_out_ctr[i - 1] != 0 ) break; /* The loop goes to its end iff the counter is wrapping */ if( i == mbedtls_ssl_ep_len( ssl ) ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "outgoing message counter would wrap" ) ); return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING ); } } #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && flush == SSL_DONT_FORCE_FLUSH ) { size_t remaining; ret = ssl_get_remaining_payload_in_datagram( ssl ); if( ret < 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "ssl_get_remaining_payload_in_datagram", ret ); return( ret ); } remaining = (size_t) ret; if( remaining == 0 ) { flush = SSL_FORCE_FLUSH; } else { MBEDTLS_SSL_DEBUG_MSG( 2, ( "Still %u bytes available in current datagram", (unsigned) remaining ) ); } } #endif /* MBEDTLS_SSL_PROTO_DTLS */ if( ( flush == SSL_FORCE_FLUSH ) && ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_flush_output", ret ); return( ret ); } MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write record" ) ); return( 0 ); }
0
512,325
Item *get_copy(THD *thd) { return get_item_copy<Item_cache_datetime>(thd, this); }
0
225,444
static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *b) { enum v4l2_buf_type type; int index; struct v4l2_loopback_device *dev; struct v4l2_loopback_opener *opener; MARK(); type = b->type; index = b->index; dev = v4l2loopback_getdevice(file); opener = fh_to_opener(fh); if ((b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && (b->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)) { return -EINVAL; } if (b->index > max_buffers) return -EINVAL; if (opener->timeout_image_io) *b = dev->timeout_image_buffer.buffer; else *b = dev->buffers[b->index % dev->used_buffers].buffer; b->type = type; b->index = index; dprintkrw("buffer type: %d (of %d with size=%ld)\n", b->memory, dev->buffers_number, dev->buffer_size); /* Hopefully fix 'DQBUF return bad index if queue bigger then 2 for capture' https://github.com/umlaeute/v4l2loopback/issues/60 */ b->flags &= ~V4L2_BUF_FLAG_DONE; b->flags |= V4L2_BUF_FLAG_QUEUED; return 0; }
0
294,572
jd_to_nth_kday(VALUE jd, double sg, VALUE *nth, int *rjd, int *ry, int *rm, int *rn, int *rk) { decode_jd(jd, nth, rjd); c_jd_to_nth_kday(*rjd, sg, ry, rm, rn, rk); }
0
512,949
Item_type_holder(THD *thd, Item *item) :Item(thd, item), Type_handler_hybrid_field_type(item->real_type_handler()), enum_set_typelib(0) { DBUG_ASSERT(item->is_fixed()); maybe_null= item->maybe_null; }
0
281,056
void xfrm_policy_hash_rebuild(struct net *net) { schedule_work(&net->xfrm.policy_hthresh.work); }
0
405,327
decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse) { const struct iphdr *iph = ip_hdr(skb); int ihl = iph->ihl; u8 *xprth = skb_network_header(skb) + ihl * 4; struct flowi4 *fl4 = &fl->u.ip4; int oif = 0; if (skb_dst(skb) && skb_dst(skb)->dev) oif = skb_dst(skb)->dev->ifindex; memset(fl4, 0, sizeof(struct flowi4)); fl4->flowi4_mark = skb->mark; fl4->flowi4_oif = reverse ? skb->skb_iif : oif; fl4->flowi4_proto = iph->protocol; fl4->daddr = reverse ? iph->saddr : iph->daddr; fl4->saddr = reverse ? iph->daddr : iph->saddr; fl4->flowi4_tos = iph->tos & ~INET_ECN_MASK; if (!ip_is_fragment(iph)) { switch (iph->protocol) { case IPPROTO_UDP: case IPPROTO_UDPLITE: case IPPROTO_TCP: case IPPROTO_SCTP: case IPPROTO_DCCP: if (xprth + 4 < skb->data || pskb_may_pull(skb, xprth + 4 - skb->data)) { __be16 *ports; xprth = skb_network_header(skb) + ihl * 4; ports = (__be16 *)xprth; fl4->fl4_sport = ports[!!reverse]; fl4->fl4_dport = ports[!reverse]; } break; case IPPROTO_ICMP: if (xprth + 2 < skb->data || pskb_may_pull(skb, xprth + 2 - skb->data)) { u8 *icmp; xprth = skb_network_header(skb) + ihl * 4; icmp = xprth; fl4->fl4_icmp_type = icmp[0]; fl4->fl4_icmp_code = icmp[1]; } break; case IPPROTO_GRE: if (xprth + 12 < skb->data || pskb_may_pull(skb, xprth + 12 - skb->data)) { __be16 *greflags; __be32 *gre_hdr; xprth = skb_network_header(skb) + ihl * 4; greflags = (__be16 *)xprth; gre_hdr = (__be32 *)xprth; if (greflags[0] & GRE_KEY) { if (greflags[0] & GRE_CSUM) gre_hdr++; fl4->fl4_gre_key = gre_hdr[1]; } } break; default: break; } } }
0
512,392
bool Item_func_interval::fix_length_and_dec() { uint rows= row->cols(); use_decimal_comparison= ((row->element_index(0)->result_type() == DECIMAL_RESULT) || (row->element_index(0)->result_type() == INT_RESULT)); if (rows > 8) { bool not_null_consts= TRUE; for (uint i= 1; not_null_consts && i < rows; i++) { Item *el= row->element_index(i); not_null_consts&= el->const_item() && !el->is_null(); } if (not_null_consts) { intervals= (interval_range*) current_thd->alloc(sizeof(interval_range) * (rows - 1)); if (!intervals) return TRUE; if (use_decimal_comparison) { for (uint i= 1; i < rows; i++) { Item *el= row->element_index(i); interval_range *range= intervals + (i-1); if ((el->result_type() == DECIMAL_RESULT) || (el->result_type() == INT_RESULT)) { range->type= DECIMAL_RESULT; range->dec.init(); my_decimal *dec= el->val_decimal(&range->dec); if (dec != &range->dec) { range->dec= *dec; } } else { range->type= REAL_RESULT; range->dbl= el->val_real(); } } } else { for (uint i= 1; i < rows; i++) { intervals[i-1].dbl= row->element_index(i)->val_real(); } } } } maybe_null= 0; max_length= 2; used_tables_and_const_cache_join(row); not_null_tables_cache= row->not_null_tables(); join_with_sum_func(row); with_param= with_param || row->with_param; with_field= with_field || row->with_field; return FALSE; }
0
313,784
nv_put_opt(cmdarg_T *cap, int fix_indent) { int regname = 0; void *reg1 = NULL, *reg2 = NULL; int empty = FALSE; int was_visual = FALSE; int dir; int flags = 0; int keep_registers = FALSE; if (cap->oap->op_type != OP_NOP) { #ifdef FEAT_DIFF // "dp" is ":diffput" if (cap->oap->op_type == OP_DELETE && cap->cmdchar == 'p') { clearop(cap->oap); nv_diffgetput(TRUE, cap->opcount); } else #endif clearopbeep(cap->oap); } #ifdef FEAT_JOB_CHANNEL else if (bt_prompt(curbuf) && !prompt_curpos_editable()) { clearopbeep(cap->oap); } #endif else { if (fix_indent) { dir = (cap->cmdchar == ']' && cap->nchar == 'p') ? FORWARD : BACKWARD; flags |= PUT_FIXINDENT; } else dir = (cap->cmdchar == 'P' || ((cap->cmdchar == 'g' || cap->cmdchar == 'z') && cap->nchar == 'P')) ? BACKWARD : FORWARD; prep_redo_cmd(cap); if (cap->cmdchar == 'g') flags |= PUT_CURSEND; else if (cap->cmdchar == 'z') flags |= PUT_BLOCK_INNER; if (VIsual_active) { // Putting in Visual mode: The put text replaces the selected // text. First delete the selected text, then put the new text. // Need to save and restore the registers that the delete // overwrites if the old contents is being put. was_visual = TRUE; regname = cap->oap->regname; keep_registers = cap->cmdchar == 'P'; #ifdef FEAT_CLIPBOARD adjust_clip_reg(&regname); #endif if (regname == 0 || regname == '"' || VIM_ISDIGIT(regname) || regname == '-' #ifdef FEAT_CLIPBOARD || (clip_unnamed && (regname == '*' || regname == '+')) #endif ) { // The delete is going to overwrite the register we want to // put, save it first. reg1 = get_register(regname, TRUE); } // Now delete the selected text. Avoid messages here. cap->cmdchar = 'd'; cap->nchar = NUL; cap->oap->regname = keep_registers ? '_' : NUL; ++msg_silent; nv_operator(cap); do_pending_operator(cap, 0, FALSE); empty = (curbuf->b_ml.ml_flags & ML_EMPTY); --msg_silent; // delete PUT_LINE_BACKWARD; cap->oap->regname = regname; if (reg1 != NULL) { // Delete probably changed the register we want to put, save // it first. Then put back what was there before the delete. reg2 = get_register(regname, FALSE); put_register(regname, reg1); } // When deleted a linewise Visual area, put the register as // lines to avoid it joined with the next line. When deletion was // characterwise, split a line when putting lines. if (VIsual_mode == 'V') flags |= PUT_LINE; else if (VIsual_mode == 'v') flags |= PUT_LINE_SPLIT; if (VIsual_mode == Ctrl_V && dir == FORWARD) flags |= PUT_LINE_FORWARD; dir = BACKWARD; if ((VIsual_mode != 'V' && curwin->w_cursor.col < curbuf->b_op_start.col) || (VIsual_mode == 'V' && curwin->w_cursor.lnum < curbuf->b_op_start.lnum)) // cursor is at the end of the line or end of file, put // forward. dir = FORWARD; // May have been reset in do_put(). VIsual_active = TRUE; } do_put(cap->oap->regname, NULL, dir, cap->count1, flags); // If a register was saved, put it back now. if (reg2 != NULL) put_register(regname, reg2); // What to reselect with "gv"? Selecting the just put text seems to // be the most useful, since the original text was removed. if (was_visual) { curbuf->b_visual.vi_start = curbuf->b_op_start; curbuf->b_visual.vi_end = curbuf->b_op_end; // need to adjust cursor position if (*p_sel == 'e') inc(&curbuf->b_visual.vi_end); } // When all lines were selected and deleted do_put() leaves an empty // line that needs to be deleted now. if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) { ml_delete_flags(curbuf->b_ml.ml_line_count, ML_DEL_MESSAGE); deleted_lines(curbuf->b_ml.ml_line_count + 1, 1); // If the cursor was in that line, move it to the end of the last // line. if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) { curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; coladvance((colnr_T)MAXCOL); } } auto_format(FALSE, TRUE); } }
0
229,175
static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq, VirtIODevice *vdev) { VirtIOSerialPortClass *vsc; assert(port); assert(virtio_queue_ready(vq)); vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port); while (!port->throttled) { unsigned int i; /* Pop an elem only if we haven't left off a previous one mid-way */ if (!port->elem.out_num) { if (!virtqueue_pop(vq, &port->elem)) { break; } port->iov_idx = 0; port->iov_offset = 0; } for (i = port->iov_idx; i < port->elem.out_num; i++) { size_t buf_size; ssize_t ret; buf_size = port->elem.out_sg[i].iov_len - port->iov_offset; ret = vsc->have_data(port, port->elem.out_sg[i].iov_base + port->iov_offset, buf_size); if (port->throttled) { port->iov_idx = i; if (ret > 0) { port->iov_offset += ret; } break; } port->iov_offset = 0; } if (port->throttled) { break; } virtqueue_push(vq, &port->elem, 0); port->elem.out_num = 0; } virtio_notify(vdev, vq); }
0
267,972
static void get_strings_range(RBinFile *bf, RList *list, int min, int raw, ut64 from, ut64 to, RBinSection *section) { r_return_if_fail (bf && bf->buf); RBinPlugin *plugin = r_bin_file_cur_plugin (bf); if (!raw && (!plugin || !plugin->info)) { return; } if (!min) { min = plugin? plugin->minstrlen: 4; } /* Some plugins return zero, fix it up */ if (min < 0) { return; } if (!min) { min = 4; } { RIO *io = bf->rbin->iob.io; RCoreBind *cb = &io->coreb; if (cb && cb->cfgGet) { const bool cfg_debug = cb->cfgGet (cb->core, "cfg.debug"); if (!cfg_debug) { if (!to || to > r_buf_size (bf->buf)) { to = r_buf_size (bf->buf); } if (!to) { return; } } } } if (raw != 2) { ut64 size = to - from; // in case of dump ignore here if (bf->rbin->maxstrbuf && size && size > bf->rbin->maxstrbuf) { if (bf->rbin->verbose) { R_LOG_WARN ("bin_strings buffer is too big (0x%08" PFMT64x "). Use -zzz or set bin.maxstrbuf (RABIN2_MAXSTRBUF) in r2 (rabin2)", size); } return; } } int type; const char *enc = bf->rbin->strenc; if (!enc) { type = R_STRING_TYPE_DETECT; } else if (!strcmp (enc, "latin1")) { type = R_STRING_TYPE_ASCII; } else if (!strcmp (enc, "utf8")) { type = R_STRING_TYPE_UTF8; } else if (!strcmp (enc, "utf16le")) { type = R_STRING_TYPE_WIDE; } else if (!strcmp (enc, "utf32le")) { type = R_STRING_TYPE_WIDE32; } else { // TODO utf16be, utf32be eprintf ("ERROR: encoding %s not supported\n", enc); return; } string_scan_range (list, bf, min, from, to, type, raw, section); }
0
262,016
ProtoRequestTypeText(ProtoRequestType t) { switch (t) { case PROTO_REQUEST_UNKNOWN: return "UNKNOWN"; case PROTO_REQUEST_SESSION_REQ: return "SESSION"; case PROTO_REQUEST_CONN: return "CONNECT"; case PROTO_REQUEST_ADDALIAS: return "ADDALIAS"; case PROTO_REQUEST_REMOVEALIAS: return "REMOVEALIAS"; case PROTO_REQUEST_QUERYALIASES: return "QUERYALIASES"; case PROTO_REQUEST_QUERYMAPPEDALIASES: return "QUERYMAPPEDALIASES"; case PROTO_REQUEST_CREATETICKET: return "CREATETICKET"; case PROTO_REQUEST_VALIDATETICKET: return "VALIDATETICKET"; case PROTO_REQUEST_REVOKETICKET: return "REVOKETICKET"; case PROTO_REQUEST_VALIDATE_SAML_BEARER_TOKEN: return "VALIDATE_SAML_BEARER_TOKEN"; default: return "INVALID"; } }
0
300,746
static int tipc_set_sk_state(struct sock *sk, int state) { int oldsk_state = sk->sk_state; int res = -EINVAL; switch (state) { case TIPC_OPEN: res = 0; break; case TIPC_LISTEN: case TIPC_CONNECTING: if (oldsk_state == TIPC_OPEN) res = 0; break; case TIPC_ESTABLISHED: if (oldsk_state == TIPC_CONNECTING || oldsk_state == TIPC_OPEN) res = 0; break; case TIPC_DISCONNECTING: if (oldsk_state == TIPC_CONNECTING || oldsk_state == TIPC_ESTABLISHED) res = 0; break; } if (!res) sk->sk_state = state; return res; }
0
463,075
static uint64_t sungem_mmio_rxdma_read(void *opaque, hwaddr addr, unsigned size) { SunGEMState *s = opaque; uint32_t val; if (!(addr <= 0x28) && !(addr >= 0x100 && addr <= 0x120)) { qemu_log_mask(LOG_GUEST_ERROR, "Read from unknown RXDMA register 0x%"HWADDR_PRIx"\n", addr); return 0; } val = s->rxdmaregs[addr >> 2]; trace_sungem_mmio_rxdma_read(addr, val); return val; }
0
299,898
readconf_handle_option(uschar *buffer, optionlist *oltop, int last, void *data_block, uschar *unknown_txt) { int ptr = 0; int offset = 0; int n, count, type, value; int issecure = 0; uid_t uid; gid_t gid; BOOL boolvalue = TRUE; BOOL freesptr = TRUE; BOOL extra_condition = FALSE; optionlist *ol, *ol2; struct passwd *pw; void *reset_point; int intbase = 0; uschar *inttype = US""; uschar *sptr; uschar *s = buffer; uschar *saved_condition, *strtemp; uschar **str_target; uschar name[64]; uschar name2[64]; /* There may be leading spaces; thereafter, we expect an option name starting with a letter. */ while (isspace(*s)) s++; if (!isalpha(*s)) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "option setting expected: %s", s); /* Read the name of the option, and skip any subsequent white space. If it turns out that what we read was "hide", set the flag indicating that this is a secure option, and loop to read the next word. */ for (n = 0; n < 2; n++) { while (isalnum(*s) || *s == '_') { if (ptr < sizeof(name)-1) name[ptr++] = *s; s++; } name[ptr] = 0; while (isspace(*s)) s++; if (Ustrcmp(name, "hide") != 0) break; issecure = opt_secure; ptr = 0; } /* Deal with "no_" or "not_" here for booleans */ if (Ustrncmp(name, "no_", 3) == 0) { boolvalue = FALSE; offset = 3; } if (Ustrncmp(name, "not_", 4) == 0) { boolvalue = FALSE; offset = 4; } /* Search the list for the given name. A non-existent name, or an option that is set twice, is a disaster. */ ol = find_option(name + offset, oltop, last); if (ol == NULL) { if (unknown_txt == NULL) return FALSE; log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, CS unknown_txt, name); } if ((ol->type & opt_set) != 0) { uschar *mname = name; if (Ustrncmp(mname, "no_", 3) == 0) mname += 3; if (Ustrcmp(mname, "condition") == 0) extra_condition = TRUE; else log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "\"%s\" option set for the second time", mname); } ol->type |= opt_set | issecure; type = ol->type & opt_mask; /* Types with data values must be followed by '='; the "no[t]_" prefix applies only to boolean values. */ if (type < opt_bool || type > opt_bool_last) { if (offset != 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "negation prefix applied to a non-boolean option"); if (*s == 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "unexpected end of line (data missing) after %s", name); if (*s != '=') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "missing \"=\" after %s", name); } /* If a boolean wasn't preceded by "no[t]_" it can be followed by = and true/false/yes/no, or, in the case of opt_expanded_bool, a general string that ultimately expands to one of those values. */ else if (*s != 0 && (offset != 0 || *s != '=')) extra_chars_error(s, US"boolean option ", name, US""); /* Skip white space after = */ if (*s == '=') while (isspace((*(++s)))); /* If there is a data block and the opt_public flag is not set, change the data block pointer to the private options block. */ if (data_block != NULL && (ol->type & opt_public) == 0) data_block = (void *)(((driver_instance *)data_block)->options_block); /* Now get the data according to the type. */ switch (type) { /* If a string value is not enclosed in quotes, it consists of the rest of the current line, verbatim. Otherwise, string escapes are processed. A transport is specified as a string, which is then looked up in the list of transports. A search type is specified as one of a number of known strings. A set or rewrite rules for a driver is specified as a string, which is then parsed into a suitable chain of control blocks. Uids and gids are specified as strings which are then looked up in the passwd file. Lists of uids and gids are similarly specified as colon- separated strings. */ case opt_stringptr: case opt_uid: case opt_gid: case opt_expand_uid: case opt_expand_gid: case opt_uidlist: case opt_gidlist: case opt_rewrite: reset_point = sptr = read_string(s, name); /* Having read a string, we now have several different ways of using it, depending on the data type, so do another switch. If keeping the actual string is not required (because it is interpreted), freesptr is set TRUE, and at the end we reset the pool. */ switch (type) { /* If this was a string, set the variable to point to the new string, and set the flag so its store isn't reclaimed. If it was a list of rewrite rules, we still keep the string (for printing), and parse the rules into a control block and flags word. */ case opt_stringptr: if (data_block == NULL) str_target = (uschar **)(ol->value); else str_target = (uschar **)((uschar *)data_block + (long int)(ol->value)); if (extra_condition) { /* We already have a condition, we're conducting a crude hack to let multiple condition rules be chained together, despite storing them in text form. */ saved_condition = *str_target; strtemp = string_sprintf("${if and{{bool_lax{%s}}{bool_lax{%s}}}}", saved_condition, sptr); *str_target = string_copy_malloc(strtemp); /* TODO(pdp): there is a memory leak here when we set 3 or more conditions; I still don't understand the store mechanism enough to know what's the safe way to free content from an earlier store. AFAICT, stores stack, so freeing an early stored item also stores all data alloc'd after it. If we knew conditions were adjacent, we could survive that, but we don't. So I *think* we need to take another bit from opt_type to indicate "malloced"; this seems like quite a hack, especially for this one case. It also means that we can't ever reclaim the store from the *first* condition. Because we only do this once, near process start-up, I'm prepared to let this slide for the time being, even though it rankles. */ } else { *str_target = sptr; freesptr = FALSE; } break; case opt_rewrite: if (data_block == NULL) *((uschar **)(ol->value)) = sptr; else *((uschar **)((uschar *)data_block + (long int)(ol->value))) = sptr; freesptr = FALSE; if (type == opt_rewrite) { int sep = 0; int *flagptr; uschar *p = sptr; rewrite_rule **chain; optionlist *ol3; sprintf(CS name2, "*%.50s_rules", name); ol2 = find_option(name2, oltop, last); sprintf(CS name2, "*%.50s_flags", name); ol3 = find_option(name2, oltop, last); if (ol2 == NULL || ol3 == NULL) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "rewrite rules not available for driver"); if (data_block == NULL) { chain = (rewrite_rule **)(ol2->value); flagptr = (int *)(ol3->value); } else { chain = (rewrite_rule **)((uschar *)data_block + (long int)(ol2->value)); flagptr = (int *)((uschar *)data_block + (long int)(ol3->value)); } while ((p = string_nextinlist(&sptr, &sep, big_buffer, BIG_BUFFER_SIZE)) != NULL) { rewrite_rule *next = readconf_one_rewrite(p, flagptr, FALSE); *chain = next; chain = &(next->next); } if ((*flagptr & (rewrite_all_envelope | rewrite_smtp)) != 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "rewrite rule specifies a " "non-header rewrite - not allowed at transport time -"); } break; /* If it was an expanded uid, see if there is any expansion to be done by checking for the presence of a $ character. If there is, save it in the corresponding *expand_user option field. Otherwise, fall through to treat it as a fixed uid. Ensure mutual exclusivity of the two kinds of data. */ case opt_expand_uid: sprintf(CS name2, "*expand_%.50s", name); ol2 = find_option(name2, oltop, last); if (ol2 != NULL) { uschar *ss = (Ustrchr(sptr, '$') != NULL)? sptr : NULL; if (data_block == NULL) *((uschar **)(ol2->value)) = ss; else *((uschar **)((uschar *)data_block + (long int)(ol2->value))) = ss; if (ss != NULL) { *(get_set_flag(name, oltop, last, data_block)) = FALSE; freesptr = FALSE; break; } } /* Look up a fixed uid, and also make use of the corresponding gid if a passwd entry is returned and the gid has not been set. */ case opt_uid: if (!route_finduser(sptr, &pw, &uid)) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "user %s was not found", sptr); if (data_block == NULL) *((uid_t *)(ol->value)) = uid; else *((uid_t *)((uschar *)data_block + (long int)(ol->value))) = uid; /* Set the flag indicating a fixed value is set */ *(get_set_flag(name, oltop, last, data_block)) = TRUE; /* Handle matching gid if we have a passwd entry: done by finding the same name with terminating "user" changed to "group"; if not found, ignore. Also ignore if the value is already set. */ if (pw == NULL) break; Ustrcpy(name+Ustrlen(name)-4, "group"); ol2 = find_option(name, oltop, last); if (ol2 != NULL && ((ol2->type & opt_mask) == opt_gid || (ol2->type & opt_mask) == opt_expand_gid)) { BOOL *set_flag = get_set_flag(name, oltop, last, data_block); if (! *set_flag) { if (data_block == NULL) *((gid_t *)(ol2->value)) = pw->pw_gid; else *((gid_t *)((uschar *)data_block + (long int)(ol2->value))) = pw->pw_gid; *set_flag = TRUE; } } break; /* If it was an expanded gid, see if there is any expansion to be done by checking for the presence of a $ character. If there is, save it in the corresponding *expand_user option field. Otherwise, fall through to treat it as a fixed gid. Ensure mutual exclusivity of the two kinds of data. */ case opt_expand_gid: sprintf(CS name2, "*expand_%.50s", name); ol2 = find_option(name2, oltop, last); if (ol2 != NULL) { uschar *ss = (Ustrchr(sptr, '$') != NULL)? sptr : NULL; if (data_block == NULL) *((uschar **)(ol2->value)) = ss; else *((uschar **)((uschar *)data_block + (long int)(ol2->value))) = ss; if (ss != NULL) { *(get_set_flag(name, oltop, last, data_block)) = FALSE; freesptr = FALSE; break; } } /* Handle freestanding gid */ case opt_gid: if (!route_findgroup(sptr, &gid)) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "group %s was not found", sptr); if (data_block == NULL) *((gid_t *)(ol->value)) = gid; else *((gid_t *)((uschar *)data_block + (long int)(ol->value))) = gid; *(get_set_flag(name, oltop, last, data_block)) = TRUE; break; /* If it was a uid list, look up each individual entry, and build a vector of uids, with a count in the first element. Put the vector in malloc store so we can free the string. (We are reading into permanent store already.) */ case opt_uidlist: { int count = 1; uid_t *list; int ptr = 0; uschar *p; uschar *op = expand_string (sptr); if (op == NULL) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "failed to expand %s: %s", name, expand_string_message); p = op; if (*p != 0) count++; while (*p != 0) if (*p++ == ':' && *p != 0) count++; list = store_malloc(count*sizeof(uid_t)); list[ptr++] = (uid_t)(count - 1); if (data_block == NULL) *((uid_t **)(ol->value)) = list; else *((uid_t **)((uschar *)data_block + (long int)(ol->value))) = list; p = op; while (count-- > 1) { int sep = 0; (void)string_nextinlist(&p, &sep, big_buffer, BIG_BUFFER_SIZE); if (!route_finduser(big_buffer, NULL, &uid)) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "user %s was not found", big_buffer); list[ptr++] = uid; } } break; /* If it was a gid list, look up each individual entry, and build a vector of gids, with a count in the first element. Put the vector in malloc store so we can free the string. (We are reading into permanent store already.) */ case opt_gidlist: { int count = 1; gid_t *list; int ptr = 0; uschar *p; uschar *op = expand_string (sptr); if (op == NULL) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "failed to expand %s: %s", name, expand_string_message); p = op; if (*p != 0) count++; while (*p != 0) if (*p++ == ':' && *p != 0) count++; list = store_malloc(count*sizeof(gid_t)); list[ptr++] = (gid_t)(count - 1); if (data_block == NULL) *((gid_t **)(ol->value)) = list; else *((gid_t **)((uschar *)data_block + (long int)(ol->value))) = list; p = op; while (count-- > 1) { int sep = 0; (void)string_nextinlist(&p, &sep, big_buffer, BIG_BUFFER_SIZE); if (!route_findgroup(big_buffer, &gid)) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "group %s was not found", big_buffer); list[ptr++] = gid; } } break; } /* Release store if the value of the string doesn't need to be kept. */ if (freesptr) store_reset(reset_point); break; /* Expanded boolean: if no characters follow, or if there are no dollar characters, this is a fixed-valued boolean, and we fall through. Otherwise, save the string for later expansion in the alternate place. */ case opt_expand_bool: if (*s != 0 && Ustrchr(s, '$') != 0) { sprintf(CS name2, "*expand_%.50s", name); ol2 = find_option(name2, oltop, last); if (ol2 != NULL) { reset_point = sptr = read_string(s, name); if (data_block == NULL) *((uschar **)(ol2->value)) = sptr; else *((uschar **)((uschar *)data_block + (long int)(ol2->value))) = sptr; freesptr = FALSE; break; } } /* Fall through */ /* Boolean: if no characters follow, the value is boolvalue. Otherwise look for yes/not/true/false. Some booleans are stored in a single bit in a single int. There's a special fudge for verify settings; without a suffix they set both xx_sender and xx_recipient. The table points to the sender value; search subsequently for the recipient. There's another special case: opt_bool_set also notes when a boolean has been set. */ case opt_bool: case opt_bit: case opt_bool_verify: case opt_bool_set: if (*s != 0) { s = readconf_readname(name2, 64, s); if (strcmpic(name2, US"true") == 0 || strcmpic(name2, US"yes") == 0) boolvalue = TRUE; else if (strcmpic(name2, US"false") == 0 || strcmpic(name2, US"no") == 0) boolvalue = FALSE; else log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "\"%s\" is not a valid value for the \"%s\" option", name2, name); if (*s != 0) extra_chars_error(s, string_sprintf("\"%s\" ", name2), US"for boolean option ", name); } /* Handle single-bit type. */ if (type == opt_bit) { int bit = 1 << ((ol->type >> 16) & 31); int *ptr = (data_block == NULL)? (int *)(ol->value) : (int *)((uschar *)data_block + (long int)ol->value); if (boolvalue) *ptr |= bit; else *ptr &= ~bit; break; } /* Handle full BOOL types */ if (data_block == NULL) *((BOOL *)(ol->value)) = boolvalue; else *((BOOL *)((uschar *)data_block + (long int)(ol->value))) = boolvalue; /* Verify fudge */ if (type == opt_bool_verify) { sprintf(CS name2, "%.50s_recipient", name + offset); ol2 = find_option(name2, oltop, last); if (ol2 != NULL) { if (data_block == NULL) *((BOOL *)(ol2->value)) = boolvalue; else *((BOOL *)((uschar *)data_block + (long int)(ol2->value))) = boolvalue; } } /* Note that opt_bool_set type is set, if there is somewhere to do so */ else if (type == opt_bool_set) { sprintf(CS name2, "*set_%.50s", name + offset); ol2 = find_option(name2, oltop, last); if (ol2 != NULL) { if (data_block == NULL) *((BOOL *)(ol2->value)) = TRUE; else *((BOOL *)((uschar *)data_block + (long int)(ol2->value))) = TRUE; } } break; /* Octal integer */ case opt_octint: intbase = 8; inttype = US"octal "; /* Integer: a simple(ish) case; allow octal and hex formats, and suffixes K and M. The different types affect output, not input. */ case opt_mkint: case opt_int: { uschar *endptr; long int lvalue; errno = 0; lvalue = strtol(CS s, CSS &endptr, intbase); if (endptr == s) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "%sinteger expected for %s", inttype, name); if (errno != ERANGE) { if (tolower(*endptr) == 'k') { if (lvalue > INT_MAX/1024 || lvalue < INT_MIN/1024) errno = ERANGE; else lvalue *= 1024; endptr++; } else if (tolower(*endptr) == 'm') { if (lvalue > INT_MAX/(1024*1024) || lvalue < INT_MIN/(1024*1024)) errno = ERANGE; else lvalue *= 1024*1024; endptr++; } } if (errno == ERANGE || lvalue > INT_MAX || lvalue < INT_MIN) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "absolute value of integer \"%s\" is too large (overflow)", s); while (isspace(*endptr)) endptr++; if (*endptr != 0) extra_chars_error(endptr, inttype, US"integer value for ", name); value = (int)lvalue; } if (data_block == NULL) *((int *)(ol->value)) = value; else *((int *)((uschar *)data_block + (long int)(ol->value))) = value; break; /* Integer held in K: again, allow octal and hex formats, and suffixes K and M. */ case opt_Kint: { uschar *endptr; errno = 0; value = strtol(CS s, CSS &endptr, intbase); if (endptr == s) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "%sinteger expected for %s", inttype, name); if (errno != ERANGE) { if (tolower(*endptr) == 'm') { if (value > INT_MAX/1024 || value < INT_MIN/1024) errno = ERANGE; else value *= 1024; endptr++; } else if (tolower(*endptr) == 'k') { endptr++; } else { value = (value + 512)/1024; } } if (errno == ERANGE) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "absolute value of integer \"%s\" is too large (overflow)", s); while (isspace(*endptr)) endptr++; if (*endptr != 0) extra_chars_error(endptr, inttype, US"integer value for ", name); } if (data_block == NULL) *((int *)(ol->value)) = value; else *((int *)((uschar *)data_block + (long int)(ol->value))) = value; break; /* Fixed-point number: held to 3 decimal places. */ case opt_fixed: if (sscanf(CS s, "%d%n", &value, &count) != 1) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "fixed-point number expected for %s", name); if (value < 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "integer \"%s\" is too large (overflow)", s); value *= 1000; if (value < 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "integer \"%s\" is too large (overflow)", s); if (s[count] == '.') { int d = 100; while (isdigit(s[++count])) { value += (s[count] - '0') * d; d /= 10; } } while (isspace(s[count])) count++; if (s[count] != 0) extra_chars_error(s+count, US"fixed-point value for ", name, US""); if (data_block == NULL) *((int *)(ol->value)) = value; else *((int *)((uschar *)data_block + (long int)(ol->value))) = value; break; /* There's a special routine to read time values. */ case opt_time: value = readconf_readtime(s, 0, FALSE); if (value < 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "invalid time value for %s", name); if (data_block == NULL) *((int *)(ol->value)) = value; else *((int *)((uschar *)data_block + (long int)(ol->value))) = value; break; /* A time list is a list of colon-separated times, with the first element holding the size of the list and the second the number of entries used. */ case opt_timelist: { int count = 0; int *list = (data_block == NULL)? (int *)(ol->value) : (int *)((uschar *)data_block + (long int)(ol->value)); if (*s != 0) for (count = 1; count <= list[0] - 2; count++) { int terminator = 0; uschar *snext = Ustrchr(s, ':'); if (snext != NULL) { uschar *ss = snext; while (ss > s && isspace(ss[-1])) ss--; terminator = *ss; } value = readconf_readtime(s, terminator, FALSE); if (value < 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "invalid time value for %s", name); if (count > 1 && value <= list[count]) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "time value out of order for %s", name); list[count+1] = value; if (snext == NULL) break; s = snext + 1; while (isspace(*s)) s++; } if (count > list[0] - 2) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "too many time values for %s", name); if (count > 0 && list[2] == 0) count = 0; list[1] = count; } break; } return TRUE; }
0
452,253
static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStylesheetPtr style, zval *docp TSRMLS_DC) /* {{{ */ { xmlDocPtr newdocp = NULL; xmlDocPtr doc = NULL; xmlNodePtr node = NULL; xsltTransformContextPtr ctxt; php_libxml_node_object *object; char **params = NULL; int clone; zval *doXInclude, *member; zend_object_handlers *std_hnd; FILE *f; int secPrefsError = 0; int secPrefsValue, secPrefsIni; xsltSecurityPrefsPtr secPrefs = NULL; node = php_libxml_import_node(docp TSRMLS_CC); if (node) { doc = node->doc; } if (doc == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Document"); return NULL; } if (style == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "No stylesheet associated to this object"); return NULL; } if (intern->profiling) { if (php_check_open_basedir(intern->profiling TSRMLS_CC)) { f = NULL; } else { f = VCWD_FOPEN(intern->profiling, "w"); } } else { f = NULL; } if (intern->parameter) { params = php_xsl_xslt_make_params(intern->parameter, 0 TSRMLS_CC); } intern->doc = emalloc(sizeof(php_libxml_node_object)); memset(intern->doc, 0, sizeof(php_libxml_node_object)); if (intern->hasKeys == 1) { doc = xmlCopyDoc(doc, 1); } else { object = (php_libxml_node_object *)zend_object_store_get_object(docp TSRMLS_CC); intern->doc->document = object->document; } php_libxml_increment_doc_ref(intern->doc, doc TSRMLS_CC); ctxt = xsltNewTransformContext(style, doc); ctxt->_private = (void *) intern; std_hnd = zend_get_std_object_handlers(); MAKE_STD_ZVAL(member); ZVAL_STRING(member, "doXInclude", 0); doXInclude = std_hnd->read_property(id, member, BP_VAR_IS, NULL TSRMLS_CC); if (Z_TYPE_P(doXInclude) != IS_NULL) { convert_to_long(doXInclude); ctxt->xinclude = Z_LVAL_P(doXInclude); } efree(member); secPrefsValue = intern->securityPrefs; /* This whole if block can be removed, when we remove the xsl.security_prefs php.ini option in PHP 6+ */ secPrefsIni= INI_INT("xsl.security_prefs"); /* if secPrefsIni has the same value as secPrefsValue, all is fine */ if (secPrefsIni != secPrefsValue) { if (secPrefsIni != XSL_SECPREF_DEFAULT) { /* if the ini value is not set to the default, throw an E_DEPRECATED warning */ php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The xsl.security_prefs php.ini option is deprecated; use XsltProcessor->setSecurityPrefs() instead"); if (intern->securityPrefsSet == 0) { /* if securityPrefs were not set through the setSecurityPrefs method, take the ini setting */ secPrefsValue = secPrefsIni; } else { /* else throw a notice, that the ini setting was not used */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "The xsl.security_prefs php.ini was not used, since the XsltProcessor->setSecurityPrefs() method was used"); } } } /* if securityPrefs is set to NONE, we don't have to do any checks, but otherwise... */ if (secPrefsValue != XSL_SECPREF_NONE) { secPrefs = xsltNewSecurityPrefs(); if (secPrefsValue & XSL_SECPREF_READ_FILE ) { if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_FILE, xsltSecurityForbid)) { secPrefsError = 1; } } if (secPrefsValue & XSL_SECPREF_WRITE_FILE ) { if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_FILE, xsltSecurityForbid)) { secPrefsError = 1; } } if (secPrefsValue & XSL_SECPREF_CREATE_DIRECTORY ) { if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_CREATE_DIRECTORY, xsltSecurityForbid)) { secPrefsError = 1; } } if (secPrefsValue & XSL_SECPREF_READ_NETWORK) { if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_READ_NETWORK, xsltSecurityForbid)) { secPrefsError = 1; } } if (secPrefsValue & XSL_SECPREF_WRITE_NETWORK) { if (0 != xsltSetSecurityPrefs(secPrefs, XSLT_SECPREF_WRITE_NETWORK, xsltSecurityForbid)) { secPrefsError = 1; } } if (0 != xsltSetCtxtSecurityPrefs(secPrefs, ctxt)) { secPrefsError = 1; } } if (secPrefsError == 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't set libxslt security properties, not doing transformation for security reasons"); } else { newdocp = xsltApplyStylesheetUser(style, doc, (const char**) params, NULL, f, ctxt); } if (f) { fclose(f); } xsltFreeTransformContext(ctxt); if (secPrefs) { xsltFreeSecurityPrefs(secPrefs); } if (intern->node_list != NULL) { zend_hash_destroy(intern->node_list); FREE_HASHTABLE(intern->node_list); intern->node_list = NULL; } php_libxml_decrement_doc_ref(intern->doc TSRMLS_CC); efree(intern->doc); intern->doc = NULL; if (params) { clone = 0; while(params[clone]) { efree(params[clone++]); } efree(params); } return newdocp; }
0
248,321
static cfg_value_t *cfg_opt_getval(cfg_opt_t *opt, unsigned int index) { cfg_value_t *val = NULL; if (index != 0 && !is_set(CFGF_LIST, opt->flags) && !is_set(CFGF_MULTI, opt->flags)) { errno = EINVAL; return NULL; } if (opt->simple_value.ptr) val = (cfg_value_t *)opt->simple_value.ptr; else { if (is_set(CFGF_RESET, opt->flags)) { cfg_free_value(opt); opt->flags &= ~CFGF_RESET; } if (index >= opt->nvalues) val = cfg_addval(opt); else val = opt->values[index]; } return val; }
0
445,879
save_as_archive_dialog_response_cb (GtkDialog *dialog, int response, gpointer user_data) { FrWindow *window = user_data; GFile *file; const char *mime_type; const char *password; gboolean encrypt_header; int volume_size; GSettings *settings; if ((response == GTK_RESPONSE_CANCEL) || (response == GTK_RESPONSE_DELETE_EVENT)) { gtk_widget_destroy (GTK_WIDGET (dialog)); _archive_operation_cancelled (window, FR_ACTION_CREATING_ARCHIVE); return; } if (response != GTK_RESPONSE_OK) return; file = fr_new_archive_dialog_get_file (FR_NEW_ARCHIVE_DIALOG (dialog), &mime_type); if (file == NULL) return; password = fr_new_archive_dialog_get_password (FR_NEW_ARCHIVE_DIALOG (dialog)); encrypt_header = fr_new_archive_dialog_get_encrypt_header (FR_NEW_ARCHIVE_DIALOG (dialog)); volume_size = fr_new_archive_dialog_get_volume_size (FR_NEW_ARCHIVE_DIALOG (dialog)); settings = g_settings_new (FILE_ROLLER_SCHEMA_NEW); g_settings_set_int (settings, PREF_NEW_VOLUME_SIZE, volume_size); g_object_unref (settings); fr_window_archive_save_as (window, file, mime_type, password, encrypt_header, volume_size); gtk_widget_destroy (GTK_WIDGET (dialog)); g_object_unref (file); }
0
450,369
static void zrle_write_u16(VncState *vs, uint16_t value) { vnc_write(vs, (uint8_t *)&value, 2); }
0
473,948
cp949_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end, OnigEncoding enc) { return onigenc_mbn_is_mbc_ambiguous(enc, flag, pp, end); }
0
254,034
static ssize_t attr_show_buffers(struct device *cd, struct device_attribute *attr, char *buf) { struct v4l2_loopback_device *dev = v4l2loopback_cd2dev(cd); return sprintf(buf, "%d\n", dev->used_buffers); }
0
312,429
ex_make(exarg_T *eap) { char_u *fname; char_u *cmd; char_u *enc = NULL; win_T *wp = NULL; qf_info_T *qi = &ql_info; int res; char_u *au_name = NULL; int_u save_qfid; char_u *errorformat = p_efm; int newlist = TRUE; // Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". if (grep_internal(eap->cmdidx)) { ex_vimgrep(eap); return; } au_name = make_get_auname(eap->cmdidx); if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, curbuf->b_fname, TRUE, curbuf)) { #ifdef FEAT_EVAL if (aborting()) return; #endif } enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; if (is_loclist_cmd(eap->cmdidx)) wp = curwin; autowrite_all(); fname = get_mef_name(); if (fname == NULL) return; mch_remove(fname); // in case it's not unique cmd = make_get_fullcmd(eap->arg, fname); if (cmd == NULL) { vim_free(fname); return; } // let the shell know if we are redirecting output or not do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0); #ifdef AMIGA out_flush(); // read window status report and redraw before message (void)char_avail(); #endif incr_quickfix_busy(); if (eap->cmdidx != CMD_make && eap->cmdidx != CMD_lmake) errorformat = p_gefm; if (eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd) newlist = FALSE; res = qf_init(wp, fname, errorformat, newlist, qf_cmdtitle(*eap->cmdlinep), enc); if (wp != NULL) { qi = GET_LOC_LIST(wp); if (qi == NULL) goto cleanup; } if (res >= 0) qf_list_changed(qf_get_curlist(qi)); // Remember the current quickfix list identifier, so that we can // check for autocommands changing the current quickfix list. save_qfid = qf_get_curlist(qi)->qf_id; if (au_name != NULL) apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, TRUE, curbuf); if (res > 0 && !eap->forceit && qflist_valid(wp, save_qfid)) // display the first error qf_jump_first(qi, save_qfid, FALSE); cleanup: decr_quickfix_busy(); mch_remove(fname); vim_free(fname); vim_free(cmd); }
0
369,296
static inline void io_req_complete_state(struct io_kiocb *req, s32 res, u32 cflags) { req->result = res; req->cflags = cflags; req->flags |= REQ_F_COMPLETE_INLINE; }
0
412,137
dnsc_parse_certs(struct dnsc_env *env, struct config_file *cfg) { struct config_strlist *head, *head2; size_t signed_cert_id; size_t rotated_cert_id; char *nm; env->signed_certs_count = 0U; env->rotated_certs_count = 0U; for (head = cfg->dnscrypt_provider_cert; head; head = head->next) { env->signed_certs_count++; } for (head = cfg->dnscrypt_provider_cert_rotated; head; head = head->next) { env->rotated_certs_count++; } env->signed_certs = sodium_allocarray(env->signed_certs_count, sizeof *env->signed_certs); env->rotated_certs = sodium_allocarray(env->rotated_certs_count, sizeof env->signed_certs); signed_cert_id = 0U; rotated_cert_id = 0U; for(head = cfg->dnscrypt_provider_cert; head; head = head->next, signed_cert_id++) { nm = dnsc_chroot_path(cfg, head->str); if(dnsc_read_from_file( nm, (char *)(env->signed_certs + signed_cert_id), sizeof(struct SignedCert)) != 0) { fatal_exit("dnsc_parse_certs: failed to load %s: %s", head->str, strerror(errno)); } for(head2 = cfg->dnscrypt_provider_cert_rotated; head2; head2 = head2->next) { if(strcmp(head->str, head2->str) == 0) { *(env->rotated_certs + rotated_cert_id) = env->signed_certs + signed_cert_id; rotated_cert_id++; verbose(VERB_OPS, "Cert %s is rotated and will not be distributed via DNS", head->str); break; } } verbose(VERB_OPS, "Loaded cert %s", head->str); } return signed_cert_id; }
0
247,516
int read_image_tga( gdIOCtx *ctx, oTga *tga ) { int pixel_block_size = (tga->bits / 8); int image_block_size; int* decompression_buffer = NULL; unsigned char* conversion_buffer = NULL; int buffer_caret = 0; int bitmap_caret = 0; int i = 0; int encoded_pixels; int rle_size; if(overflow2(tga->width, tga->height)) { return -1; } if(overflow2(tga->width * tga->height, pixel_block_size)) { return -1; } image_block_size = (tga->width * tga->height) * pixel_block_size; if(overflow2(image_block_size, sizeof(int))) { return -1; } /*! \todo Add more image type support. */ if (tga->imagetype != TGA_TYPE_RGB && tga->imagetype != TGA_TYPE_RGB_RLE) return -1; /*! \brief Allocate memmory for image block * Allocate a chunk of memory for the image block to be passed into. */ tga->bitmap = (int *) gdMalloc(image_block_size * sizeof(int)); if (tga->bitmap == NULL) return -1; switch (tga->imagetype) { case TGA_TYPE_RGB: /*! \brief Read in uncompressed RGB TGA * Chunk load the pixel data from an uncompressed RGB type TGA. */ conversion_buffer = (unsigned char *) gdMalloc(image_block_size * sizeof(unsigned char)); if (conversion_buffer == NULL) { return -1; } if (gdGetBuf(conversion_buffer, image_block_size, ctx) != image_block_size) { gd_error("gd-tga: premature end of image data\n"); gdFree(conversion_buffer); return -1; } while (buffer_caret < image_block_size) { tga->bitmap[buffer_caret] = (int) conversion_buffer[buffer_caret]; buffer_caret++; } gdFree(conversion_buffer); break; case TGA_TYPE_RGB_RLE: /*! \brief Read in RLE compressed RGB TGA * Chunk load the pixel data from an RLE compressed RGB type TGA. */ decompression_buffer = (int*) gdMalloc(image_block_size * sizeof(int)); if (decompression_buffer == NULL) { return -1; } conversion_buffer = (unsigned char *) gdMalloc(image_block_size * sizeof(unsigned char)); if (conversion_buffer == NULL) { gd_error("gd-tga: premature end of image data\n"); gdFree( decompression_buffer ); return -1; } rle_size = gdGetBuf(conversion_buffer, image_block_size, ctx); if (rle_size <= 0) { gdFree(conversion_buffer); gdFree(decompression_buffer); return -1; } buffer_caret = 0; while( buffer_caret < rle_size) { decompression_buffer[buffer_caret] = (int)conversion_buffer[buffer_caret]; buffer_caret++; } buffer_caret = 0; while( bitmap_caret < image_block_size ) { if (buffer_caret + pixel_block_size > rle_size) { gdFree( decompression_buffer ); gdFree( conversion_buffer ); return -1; } if ((decompression_buffer[buffer_caret] & TGA_RLE_FLAG) == TGA_RLE_FLAG) { encoded_pixels = ( ( decompression_buffer[ buffer_caret ] & ~TGA_RLE_FLAG ) + 1 ); buffer_caret++; if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size || buffer_caret + pixel_block_size > rle_size) { gdFree( decompression_buffer ); gdFree( conversion_buffer ); return -1; } for (i = 0; i < encoded_pixels; i++) { memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, pixel_block_size * sizeof(int)); bitmap_caret += pixel_block_size; } buffer_caret += pixel_block_size; } else { encoded_pixels = decompression_buffer[ buffer_caret ] + 1; buffer_caret++; if ((bitmap_caret + (encoded_pixels * pixel_block_size)) > image_block_size || buffer_caret + (encoded_pixels * pixel_block_size) > rle_size) { gdFree( decompression_buffer ); gdFree( conversion_buffer ); return -1; } memcpy(tga->bitmap + bitmap_caret, decompression_buffer + buffer_caret, encoded_pixels * pixel_block_size * sizeof(int)); bitmap_caret += (encoded_pixels * pixel_block_size); buffer_caret += (encoded_pixels * pixel_block_size); } } gdFree( decompression_buffer ); gdFree( conversion_buffer ); break; } return 1; }
0
390,612
ProcXkbGetDeviceInfo(ClientPtr client) { DeviceIntPtr dev; xkbGetDeviceInfoReply rep; int status,nDeviceLedFBs; unsigned length,nameLen; CARD16 ledClass,ledID; unsigned wanted,supported; char * str; REQUEST(xkbGetDeviceInfoReq); REQUEST_SIZE_MATCH(xkbGetDeviceInfoReq); if (!(client->xkbClientFlags&_XkbClientInitialized)) return BadAccess; wanted= stuff->wanted; CHK_ANY_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess); CHK_MASK_LEGAL(0x01,wanted,XkbXI_AllDeviceFeaturesMask); if ((!dev->button)||((stuff->nBtns<1)&&(!stuff->allBtns))) wanted&= ~XkbXI_ButtonActionsMask; if ((!dev->kbdfeed)&&(!dev->leds)) wanted&= ~XkbXI_IndicatorsMask; nameLen= XkbSizeCountedString(dev->name); bzero((char *)&rep,SIZEOF(xkbGetDeviceInfoReply)); rep.type = X_Reply; rep.deviceID= dev->id; rep.sequenceNumber = client->sequence; rep.length = nameLen/4; rep.present = wanted; rep.supported = XkbXI_AllDeviceFeaturesMask; rep.unsupported = 0; rep.firstBtnWanted = rep.nBtnsWanted = 0; rep.firstBtnRtrn = rep.nBtnsRtrn = 0; if (dev->button) rep.totalBtns= dev->button->numButtons; else rep.totalBtns= 0; rep.devType= dev->type; rep.hasOwnState= (dev->key && dev->key->xkbInfo); rep.nDeviceLedFBs = 0; if (dev->kbdfeed) rep.dfltKbdFB= dev->kbdfeed->ctrl.id; else rep.dfltKbdFB= XkbXINone; if (dev->leds) rep.dfltLedFB= dev->leds->ctrl.id; else rep.dfltLedFB= XkbXINone; ledClass= stuff->ledClass; ledID= stuff->ledID; rep.firstBtnWanted= rep.nBtnsWanted= 0; rep.firstBtnRtrn= rep.nBtnsRtrn= 0; if (wanted&XkbXI_ButtonActionsMask) { if (stuff->allBtns) { stuff->firstBtn= 0; stuff->nBtns= dev->button->numButtons; } if ((stuff->firstBtn+stuff->nBtns)>dev->button->numButtons) { client->errorValue = _XkbErrCode4(0x02,dev->button->numButtons, stuff->firstBtn, stuff->nBtns); return BadValue; } else { rep.firstBtnWanted= stuff->firstBtn; rep.nBtnsWanted= stuff->nBtns; if (dev->button->xkb_acts!=NULL) { XkbAction *act; register int i; rep.firstBtnRtrn= stuff->firstBtn; rep.nBtnsRtrn= stuff->nBtns; act= &dev->button->xkb_acts[rep.firstBtnWanted]; for (i=0;i<rep.nBtnsRtrn;i++,act++) { if (act->type!=XkbSA_NoAction) break; } rep.firstBtnRtrn+= i; rep.nBtnsRtrn-= i; act= &dev->button->xkb_acts[rep.firstBtnRtrn+rep.nBtnsRtrn-1]; for (i=0;i<rep.nBtnsRtrn;i++,act--) { if (act->type!=XkbSA_NoAction) break; } rep.nBtnsRtrn-= i; } rep.length+= (rep.nBtnsRtrn*SIZEOF(xkbActionWireDesc))/4; } } if (wanted&XkbXI_IndicatorsMask) { status= CheckDeviceLedFBs(dev,ledClass,ledID,&rep,client); if (status!=Success) return status; } length= rep.length*4; supported= rep.supported; nDeviceLedFBs = rep.nDeviceLedFBs; if (client->swapped) { register int n; swaps(&rep.sequenceNumber,n); swapl(&rep.length,n); swaps(&rep.present,n); swaps(&rep.supported,n); swaps(&rep.unsupported,n); swaps(&rep.nDeviceLedFBs,n); swapl(&rep.type,n); } WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), (char *)&rep); str= (char*) xalloc(nameLen); if (!str) return BadAlloc; XkbWriteCountedString(str,dev->name,client->swapped); WriteToClient(client,nameLen,str); xfree(str); length-= nameLen; if (rep.nBtnsRtrn>0) { int sz; xkbActionWireDesc * awire; sz= rep.nBtnsRtrn*SIZEOF(xkbActionWireDesc); awire= (xkbActionWireDesc *)&dev->button->xkb_acts[rep.firstBtnRtrn]; WriteToClient(client,sz,(char *)awire); length-= sz; } if (nDeviceLedFBs>0) { status= SendDeviceLedFBs(dev,ledClass,ledID,length,client); if (status!=Success) return status; } else if (length!=0) { ErrorF("[xkb] Internal Error! BadLength in ProcXkbGetDeviceInfo\n"); ErrorF("[xkb] Wrote %d fewer bytes than expected\n",length); return BadLength; } if (stuff->wanted&(~supported)) { xkbExtensionDeviceNotify ed; bzero((char *)&ed,SIZEOF(xkbExtensionDeviceNotify)); ed.ledClass= ledClass; ed.ledID= ledID; ed.ledsDefined= 0; ed.ledState= 0; ed.firstBtn= ed.nBtns= 0; ed.reason= XkbXI_UnsupportedFeatureMask; ed.supported= supported; ed.unsupported= stuff->wanted&(~supported); XkbSendExtensionDeviceNotify(dev,client,&ed); } return client->noClientException; }
0
336,615
SPICE_GNUC_VISIBLE void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16]) { memcpy(s->config->spice_uuid, uuid, sizeof(s->config->spice_uuid)); s->config->spice_uuid_is_set = TRUE; }
0
225,079
PQprotocolVersion(const PGconn *conn) { if (!conn) return 0; if (conn->status == CONNECTION_BAD) return 0; return PG_PROTOCOL_MAJOR(conn->pversion); }
0
413,656
static void core_anal_color_curr_node(RCore *core, RAnalBlock *bbi) { bool color_current = r_config_get_i (core->config, "graph.gv.current"); char *pal_curr = palColorFor ("graph.current"); bool current = r_anal_block_contains (bbi, core->offset); if (current && color_current) { r_cons_printf ("\t\"0x%08"PFMT64x"\" ", bbi->addr); r_cons_printf ("\t[fillcolor=%s style=filled shape=box];\n", pal_curr); } free (pal_curr); }
0
252,314
bool operator()(long long *a, long long *b) { return *a > *b; }
0
455,279
posix_readline_initialize (on_or_off) int on_or_off; { static char kseq[2] = { CTRL ('I'), 0 }; /* TAB */ if (on_or_off) rl_variable_bind ("comment-begin", "#"); #if defined (VI_MODE) if (on_or_off) { vi_tab_binding = rl_function_of_keyseq (kseq, vi_insertion_keymap, (int *)NULL); rl_bind_key_in_map (CTRL ('I'), rl_insert, vi_insertion_keymap); } else { if (rl_function_of_keyseq (kseq, vi_insertion_keymap, (int *)NULL) == rl_insert) rl_bind_key_in_map (CTRL ('I'), vi_tab_binding, vi_insertion_keymap); } #endif }
0
445,983
fr_window_get_password_for_second_archive (FrWindow *window) { g_return_val_if_fail (window != NULL, NULL); return window->priv->second_password; }
0
459,134
struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, struct sk_buff *skb, struct sk_buff **to_free, int *ret) { struct tcf_result cl_res; struct tcf_proto *fl; if (!qe->info.block_index) return skb; fl = rcu_dereference_bh(qe->filter_chain); switch (tcf_classify(skb, NULL, fl, &cl_res, false)) { case TC_ACT_SHOT: qdisc_qstats_drop(sch); __qdisc_drop(skb, to_free); *ret = __NET_XMIT_BYPASS; return NULL; case TC_ACT_STOLEN: case TC_ACT_QUEUED: case TC_ACT_TRAP: __qdisc_drop(skb, to_free); *ret = __NET_XMIT_STOLEN; return NULL; case TC_ACT_REDIRECT: skb_do_redirect(skb); *ret = __NET_XMIT_STOLEN; return NULL; } return skb; }
0
197,593
njs_function_frame_save(njs_vm_t *vm, njs_frame_t *frame, u_char *pc) { size_t value_count, n; njs_value_t *start, *end, *p, **new, *value, **local; njs_function_t *function; njs_native_frame_t *active, *native; *frame = *vm->active_frame; frame->previous_active_frame = NULL; native = &frame->native; active = &vm->active_frame->native; value_count = njs_function_frame_value_count(active); function = active->function; new = (njs_value_t **) ((u_char *) native + NJS_FRAME_SIZE); value = (njs_value_t *) (new + value_count + function->u.lambda->temp); native->arguments = value; native->arguments_offset = value + (function->args_offset - 1); native->local = new + njs_function_frame_args_count(active); native->temp = new + value_count; native->pc = pc; start = njs_function_frame_values(active, &end); p = native->arguments; while (start < end) { *p = *start++; *new++ = p++; } /* Move all arguments. */ p = native->arguments; local = native->local + function->args_offset; for (n = 0; n < function->args_count; n++) { if (!njs_is_valid(p)) { njs_set_undefined(p); } *local++ = p++; } return NJS_OK; }
1
259,605
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 (m_pLargestScale) { class Frame *frame = m_pLargestScale->FrameOf(); while(frame) { if (frame->ComponentOf(i)->SubXOf() != sx || frame->ComponentOf(i)->SubYOf() != sy) JPG_THROW(MALFORMED_STREAM,"HierarchicalBitmapRequester::PrepareForDecoding", "component subsampling is inconsistent across hierarchical levels"); frame = frame->NextOf(); } } 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 }
0
366,326
struct vfsmount *lookup_mnt(const struct path *path) { struct mount *child_mnt; struct vfsmount *m; unsigned seq; rcu_read_lock(); do { seq = read_seqbegin(&mount_lock); child_mnt = __lookup_mnt(path->mnt, path->dentry); m = child_mnt ? &child_mnt->mnt : NULL; } while (!legitimize_mnt(m, seq)); rcu_read_unlock(); return m; }
0
238,382
njs_function_property_prototype_set(njs_vm_t *vm, njs_lvlhsh_t *hash, njs_value_t *prototype) { njs_int_t ret; njs_object_prop_t *prop; njs_lvlhsh_query_t lhq; const njs_value_t proto_string = njs_string("prototype"); prop = njs_object_prop_alloc(vm, &proto_string, prototype, 0); if (njs_slow_path(prop == NULL)) { return NULL; } prop->writable = 1; lhq.value = prop; lhq.key_hash = NJS_PROTOTYPE_HASH; lhq.key = njs_str_value("prototype"); lhq.replace = 1; lhq.pool = vm->mem_pool; lhq.proto = &njs_object_hash_proto; ret = njs_lvlhsh_insert(hash, &lhq); if (njs_fast_path(ret == NJS_OK)) { return &prop->value; } njs_internal_error(vm, "lvlhsh insert failed"); return NULL; }
0
255,935
Status ShapeRefiner::InferShapesForFunction( const FunctionDef* function_def, AttrSlice attributes, ExtendedInferenceContext* outer_context) { const Graph* graph; auto it = functions_.find(function_def); if (it != functions_.end()) { graph = it->second.get(); } else { InstantiationResult result; TF_RETURN_IF_ERROR(InstantiateFunction( *function_def, attributes, [this](const string& op, const OpDef** sig) { return this->function_library_->LookUpOpDef(op, sig); }, &result)); Graph* new_graph = new Graph(function_library_); GraphConstructorOptions options; options.allow_internal_ops = true; TF_RETURN_IF_ERROR( ConvertNodeDefsToGraph(options, result.nodes, new_graph)); functions_[function_def].reset(new_graph); graph = new_graph; } std::unordered_set<const Node*> function_nodes; Status inference_status = Status::OK(); { auto node_shape_inference_lambda = [this, &outer_context, &function_nodes, &inference_status](const Node* node) { if (!inference_status.ok()) return; inference_status = InferShapesForFunctionSubNode(node, outer_context->get_context()); function_nodes.insert(node); }; // Calls inference lambda for each node after visiting all predecessors. // Ensures that we are adding nodes to ShapeRefiner in the topological // order. ReverseDFS(*graph, {}, node_shape_inference_lambda); } // Delete the contexts created for the functions nodes to save memory. for (const Node* node : function_nodes) { node_to_context_.erase(node); } return inference_status; }
0
233,940
bool DocumentSourceUnionWith::usedDisk() { if (_pipeline) { _stats.planSummaryStats.usedDisk = _stats.planSummaryStats.usedDisk || _pipeline->usedDisk(); } return _stats.planSummaryStats.usedDisk; }
0
364,780
set_buflocal_tfu_callback(buf_T *buf UNUSED) { free_callback(&buf->b_tfu_cb); if (tfu_cb.cb_name != NULL && *tfu_cb.cb_name != NUL) copy_callback(&buf->b_tfu_cb, &tfu_cb); }
0
217,567
static char *TracePSClippath(const unsigned char *blob,size_t length, const size_t magick_unused(columns),const size_t magick_unused(rows)) { char *path, *message; MagickBooleanType in_subpath; PointInfo first[3], last[3], point[3]; ssize_t i, x; ssize_t knot_count, selector, y; magick_unreferenced(columns); magick_unreferenced(rows); path=AcquireString((char *) NULL); if (path == (char *) NULL) return((char *) NULL); message=AcquireString((char *) NULL); (void) FormatLocaleString(message,MaxTextExtent,"/ClipImage\n"); (void) ConcatenateString(&path,message); (void) FormatLocaleString(message,MaxTextExtent,"{\n"); (void) ConcatenateString(&path,message); (void) FormatLocaleString(message,MaxTextExtent," /c {curveto} bind def\n"); (void) ConcatenateString(&path,message); (void) FormatLocaleString(message,MaxTextExtent," /l {lineto} bind def\n"); (void) ConcatenateString(&path,message); (void) FormatLocaleString(message,MaxTextExtent," /m {moveto} bind def\n"); (void) ConcatenateString(&path,message); (void) FormatLocaleString(message,MaxTextExtent, " /v {currentpoint 6 2 roll curveto} bind def\n"); (void) ConcatenateString(&path,message); (void) FormatLocaleString(message,MaxTextExtent, " /y {2 copy curveto} bind def\n"); (void) ConcatenateString(&path,message); (void) FormatLocaleString(message,MaxTextExtent, " /z {closepath} bind def\n"); (void) ConcatenateString(&path,message); (void) FormatLocaleString(message,MaxTextExtent," newpath\n"); (void) ConcatenateString(&path,message); /* The clipping path format is defined in "Adobe Photoshop File Formats Specification" version 6.0 downloadable from adobe.com. */ (void) memset(point,0,sizeof(point)); (void) memset(first,0,sizeof(first)); (void) memset(last,0,sizeof(last)); knot_count=0; in_subpath=MagickFalse; while (length > 0) { selector=(ssize_t) ReadPropertyMSBShort(&blob,&length); switch (selector) { case 0: case 3: { if (knot_count != 0) { blob+=24; length-=MagickMin(24,(ssize_t) length); break; } /* Expected subpath length record. */ knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length); blob+=22; length-=MagickMin(22,(ssize_t) length); break; } case 1: case 2: case 4: case 5: { if (knot_count == 0) { /* Unexpected subpath knot */ blob+=24; length-=MagickMin(24,(ssize_t) length); break; } /* Add sub-path knot */ for (i=0; i < 3; i++) { y=(size_t) ReadPropertyMSBLong(&blob,&length); x=(size_t) ReadPropertyMSBLong(&blob,&length); point[i].x=(double) x/4096.0/4096.0; point[i].y=1.0-(double) y/4096.0/4096.0; } if (in_subpath == MagickFalse) { (void) FormatLocaleString(message,MaxTextExtent," %g %g m\n", point[1].x,point[1].y); for (i=0; i < 3; i++) { first[i]=point[i]; last[i]=point[i]; } } else { /* Handle special cases when Bezier curves are used to describe corners and straight lines. */ if ((last[1].x == last[2].x) && (last[1].y == last[2].y) && (point[0].x == point[1].x) && (point[0].y == point[1].y)) (void) FormatLocaleString(message,MaxTextExtent, " %g %g l\n",point[1].x,point[1].y); else if ((last[1].x == last[2].x) && (last[1].y == last[2].y)) (void) FormatLocaleString(message,MaxTextExtent, " %g %g %g %g v\n",point[0].x,point[0].y, point[1].x,point[1].y); else if ((point[0].x == point[1].x) && (point[0].y == point[1].y)) (void) FormatLocaleString(message,MaxTextExtent, " %g %g %g %g y\n",last[2].x,last[2].y, point[1].x,point[1].y); else (void) FormatLocaleString(message,MaxTextExtent, " %g %g %g %g %g %g c\n",last[2].x, last[2].y,point[0].x,point[0].y,point[1].x,point[1].y); for (i=0; i < 3; i++) last[i]=point[i]; } (void) ConcatenateString(&path,message); in_subpath=MagickTrue; knot_count--; /* Close the subpath if there are no more knots. */ if (knot_count == 0) { /* Same special handling as above except we compare to the first point in the path and close the path. */ if ((last[1].x == last[2].x) && (last[1].y == last[2].y) && (first[0].x == first[1].x) && (first[0].y == first[1].y)) (void) FormatLocaleString(message,MaxTextExtent, " %g %g l z\n",first[1].x,first[1].y); else if ((last[1].x == last[2].x) && (last[1].y == last[2].y)) (void) FormatLocaleString(message,MaxTextExtent, " %g %g %g %g v z\n",first[0].x,first[0].y, first[1].x,first[1].y); else if ((first[0].x == first[1].x) && (first[0].y == first[1].y)) (void) FormatLocaleString(message,MaxTextExtent, " %g %g %g %g y z\n",last[2].x,last[2].y, first[1].x,first[1].y); else (void) FormatLocaleString(message,MaxTextExtent, " %g %g %g %g %g %g c z\n",last[2].x, last[2].y,first[0].x,first[0].y,first[1].x,first[1].y); (void) ConcatenateString(&path,message); in_subpath=MagickFalse; } break; } case 6: case 7: case 8: default: { blob+=24; length-=MagickMin(24,(ssize_t) length); break; } } } /* Returns an empty PS path if the path has no knots. */ (void) FormatLocaleString(message,MaxTextExtent," eoclip\n"); (void) ConcatenateString(&path,message); (void) FormatLocaleString(message,MaxTextExtent,"} bind def"); (void) ConcatenateString(&path,message); message=DestroyString(message); return(path); }
0
424,944
static int iwl_trans_pcie_rxq_dma_data(struct iwl_trans *trans, int queue, struct iwl_trans_rxq_dma_data *data) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); if (queue >= trans->num_rx_queues || !trans_pcie->rxq) return -EINVAL; data->fr_bd_cb = trans_pcie->rxq[queue].bd_dma; data->urbd_stts_wrptr = trans_pcie->rxq[queue].rb_stts_dma; data->ur_bd_cb = trans_pcie->rxq[queue].used_bd_dma; data->fr_bd_wid = 0; return 0; }
0
259,281
static int mov_parse_auxiliary_info(MOVContext *c, MOVStreamContext *sc, AVIOContext *pb, MOVEncryptionIndex *encryption_index) { AVEncryptionInfo **sample, **encrypted_samples; int64_t prev_pos; size_t sample_count, sample_info_size, i; int ret = 0; unsigned int alloc_size = 0; if (encryption_index->nb_encrypted_samples) return 0; sample_count = encryption_index->auxiliary_info_sample_count; if (encryption_index->auxiliary_offsets_count != 1) { av_log(c->fc, AV_LOG_ERROR, "Multiple auxiliary info chunks are not supported\n"); return AVERROR_PATCHWELCOME; } if (sample_count >= INT_MAX / sizeof(*encrypted_samples)) return AVERROR(ENOMEM); prev_pos = avio_tell(pb); if (!(pb->seekable & AVIO_SEEKABLE_NORMAL) || avio_seek(pb, encryption_index->auxiliary_offsets[0], SEEK_SET) != encryption_index->auxiliary_offsets[0]) { av_log(c->fc, AV_LOG_INFO, "Failed to seek for auxiliary info, will only parse senc atoms for encryption info\n"); goto finish; } for (i = 0; i < sample_count && !pb->eof_reached; i++) { unsigned int min_samples = FFMIN(FFMAX(i + 1, 1024 * 1024), sample_count); encrypted_samples = av_fast_realloc(encryption_index->encrypted_samples, &alloc_size, min_samples * sizeof(*encrypted_samples)); if (!encrypted_samples) { ret = AVERROR(ENOMEM); goto finish; } encryption_index->encrypted_samples = encrypted_samples; sample = &encryption_index->encrypted_samples[i]; sample_info_size = encryption_index->auxiliary_info_default_size ? encryption_index->auxiliary_info_default_size : encryption_index->auxiliary_info_sizes[i]; ret = mov_read_sample_encryption_info(c, pb, sc, sample, sample_info_size > sc->cenc.per_sample_iv_size); if (ret < 0) goto finish; } if (pb->eof_reached) { av_log(c->fc, AV_LOG_ERROR, "Hit EOF while reading auxiliary info\n"); ret = AVERROR_INVALIDDATA; } else { encryption_index->nb_encrypted_samples = sample_count; } finish: avio_seek(pb, prev_pos, SEEK_SET); if (ret < 0) { for (; i > 0; i--) { av_encryption_info_free(encryption_index->encrypted_samples[i - 1]); } av_freep(&encryption_index->encrypted_samples); } return ret; }
0
220,027
explicit SparseTensorsMap(const string& name) : name_(name), counter_(0) {}
0
224,568
Status UnknownShape(shape_inference::InferenceContext* c) { for (int i = 0; i < c->num_outputs(); ++i) { c->set_output(i, c->UnknownShape()); } return Status::OK(); }
0
413,602
static int core_anal_graph_construct_edges(RCore *core, RAnalFunction *fcn, int opts, PJ *pj, Sdb *DB) { RAnalBlock *bbi; RListIter *iter; int is_keva = opts & R_CORE_ANAL_KEYVALUE; int is_star = opts & R_CORE_ANAL_STAR; int is_json = opts & R_CORE_ANAL_JSON; int is_html = r_cons_context ()->is_html; char *pal_jump = palColorFor ("graph.true"); char *pal_fail = palColorFor ("graph.false"); char *pal_trfa = palColorFor ("graph.trufae"); int nodes = 0; r_list_foreach (fcn->bbs, iter, bbi) { if (bbi->jump != UT64_MAX) { nodes++; if (is_keva) { char key[128]; char val[128]; snprintf (key, sizeof (key), "bb.0x%08"PFMT64x".to", bbi->addr); if (bbi->fail != UT64_MAX) { snprintf (val, sizeof (val), "0x%08"PFMT64x, bbi->jump); } else { snprintf (val, sizeof (val), "0x%08"PFMT64x ",0x%08"PFMT64x, bbi->jump, bbi->fail); } // bb.<addr>.to=<jump>,<fail> sdb_set (DB, key, val, 0); } else if (is_html) { r_cons_printf ("<div class=\"connector _0x%08"PFMT64x" _0x%08"PFMT64x"\">\n" " <img class=\"connector-end\" src=\"img/arrow.gif\" /></div>\n", bbi->addr, bbi->jump); } else if (!is_json && !is_keva) { if (is_star) { char *from = get_title (bbi->addr); char *to = get_title (bbi->jump); r_cons_printf ("age %s %s\n", from, to); free (from); free (to); } else { r_strf_buffer (128); const char* edge_color = bbi->fail != -1 ? pal_jump : pal_trfa; if (sdb_const_get (core->sdb, r_strf ("agraph.edge.0x%"PFMT64x"_0x%"PFMT64x".highlight", bbi->addr, bbi->jump), 0)) { edge_color = "cyan"; } r_cons_printf (" \"0x%08"PFMT64x"\" -> \"0x%08"PFMT64x"\" " "[color=\"%s\"];\n", bbi->addr, bbi->jump, edge_color); core_anal_color_curr_node (core, bbi); } } } if (bbi->fail != -1) { nodes++; if (is_html) { r_cons_printf ("<div class=\"connector _0x%08"PFMT64x" _0x%08"PFMT64x"\">\n" " <img class=\"connector-end\" src=\"img/arrow.gif\"/></div>\n", bbi->addr, bbi->fail); } else if (!is_keva && !is_json) { if (is_star) { char *from = get_title (bbi->addr); char *to = get_title (bbi->fail); r_cons_printf ("age %s %s\n", from, to); free(from); free(to); } else { r_cons_printf (" \"0x%08"PFMT64x"\" -> \"0x%08"PFMT64x"\" " "[color=\"%s\"];\n", bbi->addr, bbi->fail, pal_fail); core_anal_color_curr_node (core, bbi); } } } if (bbi->switch_op) { RAnalCaseOp *caseop; RListIter *iter; if (bbi->fail != UT64_MAX) { if (is_html) { r_cons_printf ("<div class=\"connector _0x%08"PFMT64x" _0x%08"PFMT64x"\">\n" " <img class=\"connector-end\" src=\"img/arrow.gif\"/></div>\n", bbi->addr, bbi->fail); } else if (!is_keva && !is_json) { if (is_star) { char *from = get_title (bbi->addr); char *to = get_title (bbi->fail); r_cons_printf ("age %s %s\n", from, to); free(from); free(to); } else { r_cons_printf (" \"0x%08"PFMT64x"\" -> \"0x%08"PFMT64x"\" " "[color=\"%s\"];\n", bbi->addr, bbi->fail, pal_fail); core_anal_color_curr_node (core, bbi); } } } r_list_foreach (bbi->switch_op->cases, iter, caseop) { nodes++; if (is_keva) { char key[128]; snprintf (key, sizeof (key), "bb.0x%08"PFMT64x".switch.%"PFMT64d, bbi->addr, caseop->value); sdb_num_set (DB, key, caseop->jump, 0); snprintf (key, sizeof (key), "bb.0x%08"PFMT64x".switch", bbi->addr); sdb_array_add_num (DB, key, caseop->value, 0); } else if (is_html) { r_cons_printf ("<div class=\"connector _0x%08" PFMT64x " _0x%08" PFMT64x "\">\n" " <img class=\"connector-end\" src=\"img/arrow.gif\"/></div>\n", bbi->addr, caseop->addr); } else if (!is_json && !is_keva) { if (is_star) { char *from = get_title (bbi->addr); char *to = get_title (caseop->addr); r_cons_printf ("age %s %s\n", from ,to); free (from); free (to); } else { r_cons_printf (" \"0x%08" PFMT64x "\" -> \"0x%08" PFMT64x "\" " "[color=\"%s\"];\n", bbi->addr, caseop->addr, pal_trfa); core_anal_color_curr_node (core, bbi); } } } } } free(pal_jump); free(pal_fail); free(pal_trfa); return nodes; }
0
236,205
GF_Err diST_box_size(GF_Box *s) { GF_DIMSScriptTypesBox *p = (GF_DIMSScriptTypesBox *)s; s->size += p->content_script_types ? (strlen(p->content_script_types)+1) : 1; return GF_OK; }
0
225,772
GF_Err leva_box_read(GF_Box *s, GF_BitStream *bs) { u32 i; GF_LevelAssignmentBox *ptr = (GF_LevelAssignmentBox*)s; ISOM_DECREASE_SIZE(ptr, 1) ptr->level_count = gf_bs_read_u8(bs); //each level is at least 5 bytes if (ptr->size / 5 < ptr->level_count) return GF_ISOM_INVALID_FILE; GF_SAFE_ALLOC_N(ptr->levels, ptr->level_count, GF_LevelAssignment); if (!ptr->levels) return GF_OUT_OF_MEM; for (i = 0; i < ptr->level_count; i++) { GF_LevelAssignment *level = &ptr->levels[i]; u8 tmp; if (!level || ptr->size < 5) return GF_BAD_PARAM; ISOM_DECREASE_SIZE(ptr, 5) level->track_id = gf_bs_read_u32(bs); tmp = gf_bs_read_u8(bs); level->padding_flag = tmp >> 7; level->type = tmp & 0x7F; if (level->type == 0) { ISOM_DECREASE_SIZE(ptr, 4) level->grouping_type = gf_bs_read_u32(bs); } else if (level->type == 1) { ISOM_DECREASE_SIZE(ptr, 8) level->grouping_type = gf_bs_read_u32(bs); level->grouping_type_parameter = gf_bs_read_u32(bs); } else if (level->type == 4) { ISOM_DECREASE_SIZE(ptr, 4) level->sub_track_id = gf_bs_read_u32(bs); } } return GF_OK;
0
432,188
void *address_space_map(AddressSpace *as, hwaddr addr, hwaddr *plen, bool is_write, MemTxAttrs attrs) { hwaddr len = *plen; hwaddr l, xlat; MemoryRegion *mr; void *ptr; FlatView *fv; struct uc_struct *uc = as->uc; if (len == 0) { return NULL; } l = len; fv = address_space_to_flatview(as); mr = flatview_translate(uc, fv, addr, &xlat, &l, is_write, attrs); if (!memory_access_is_direct(mr, is_write)) { /* Avoid unbounded allocations */ l = MIN(l, TARGET_PAGE_SIZE); mr->uc->bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, l); mr->uc->bounce.addr = addr; mr->uc->bounce.len = l; mr->uc->bounce.mr = mr; if (!is_write) { flatview_read(as->uc, fv, addr, MEMTXATTRS_UNSPECIFIED, mr->uc->bounce.buffer, l); } *plen = l; return mr->uc->bounce.buffer; } *plen = flatview_extend_translation(as->uc, fv, addr, len, mr, xlat, l, is_write, attrs); ptr = qemu_ram_ptr_length(as->uc, mr->ram_block, xlat, plen, true); return ptr; }
0
222,554
string Canonicalize(const string& funcname, AttrSlice attrs, const FunctionLibraryRuntime::InstantiateOptions& options) { absl::InlinedVector<AttrKeyAndValue, 8> entries; entries.reserve(attrs.size() + static_cast<int>(!options.target.empty()) + options.input_devices.size()); for (const auto& p : attrs) { if (p.first != kExecutorAttr) { entries.push_back(AttrKeyAndValue( p.first, -1, Print(p.second, /*hash_string_attrs=*/true))); } } if (!options.target.empty()) { entries.push_back(AttrKeyAndValue("_target", -1, options.target, AttrKeyAndValue::kCEscape)); } for (int i = 0; i < options.input_devices.size(); ++i) { entries.push_back(AttrKeyAndValue("_input_dev", i, options.input_devices[i], AttrKeyAndValue::kCEscape)); } for (int i = 0; i < options.output_devices.size(); ++i) { entries.push_back(AttrKeyAndValue("_output_dev", i, options.output_devices[i], AttrKeyAndValue::kCEscape)); } for (const auto& iter : options.input_resource_dtypes_and_shapes) { entries.push_back(AttrKeyAndValue("_input_resource_dtype", iter.first, DataTypeString(iter.second.dtype))); entries.push_back(AttrKeyAndValue("_input_resource_shape", iter.first, iter.second.shape.DebugString(), AttrKeyAndValue::kCEscape)); } if (options.lib_def) { entries.push_back(AttrKeyAndValue( "_lib_def", -1, absl::StrCat("", reinterpret_cast<uintptr_t>(options.lib_def)))); } if (!options.state_handle.empty()) { entries.push_back( AttrKeyAndValue("_state_handle", -1, options.state_handle)); } string executor_type = FunctionLibraryRuntime::ExecutorType(options, attrs); if (!executor_type.empty()) { entries.push_back(AttrKeyAndValue(kExecutorAttr, -1, executor_type)); } if (options.config_proto.ByteSize() > 0) { string config_proto_serialized; SerializeToStringDeterministic(options.config_proto, &config_proto_serialized); entries.push_back(AttrKeyAndValue("_config_proto", -1, config_proto_serialized, AttrKeyAndValue::kCEscape)); } std::sort(entries.begin(), entries.end()); string result = strings::StrCat(funcname, "["); bool first = true; for (const auto& entry : entries) { entry.AppendTo(first, &result); first = false; } result += "]"; return result; }
0
353,149
static void clipColor(int rIn, int gIn, int bIn, unsigned char *rOut, unsigned char *gOut, unsigned char *bOut) { int lum, rgbMin, rgbMax; lum = getLum(rIn, gIn, bIn); rgbMin = rgbMax = rIn; if (gIn < rgbMin) { rgbMin = gIn; } else if (gIn > rgbMax) { rgbMax = gIn; } if (bIn < rgbMin) { rgbMin = bIn; } else if (bIn > rgbMax) { rgbMax = bIn; } if (rgbMin < 0) { *rOut = (unsigned char)(lum + ((rIn - lum) * lum) / (lum - rgbMin)); *gOut = (unsigned char)(lum + ((gIn - lum) * lum) / (lum - rgbMin)); *bOut = (unsigned char)(lum + ((bIn - lum) * lum) / (lum - rgbMin)); } else if (rgbMax > 255) { *rOut = (unsigned char)(lum + ((rIn - lum) * (255 - lum)) / (rgbMax - lum)); *gOut = (unsigned char)(lum + ((gIn - lum) * (255 - lum)) / (rgbMax - lum)); *bOut = (unsigned char)(lum + ((bIn - lum) * (255 - lum)) / (rgbMax - lum)); } else { *rOut = rIn; *gOut = gIn; *bOut = bIn; } }
0
331,757
QPainterState *QPaintEngineEx::createState(QPainterState *orig) const { if (!orig) return new QPainterState; return new QPainterState(orig); }
0
246,448
static void wasm_custom_name_free(RBinWasmCustomNameEntry *cust) { if (cust) { switch (cust->type) { case R_BIN_WASM_NAMETYPE_Module: R_FREE (cust->mod_name); break; case R_BIN_WASM_NAMETYPE_Function: if (cust->func) { r_id_storage_free (cust->func->names); R_FREE (cust->func); } break; case R_BIN_WASM_NAMETYPE_Local: wasm_custom_local_names_free (cust->local); break; case R_BIN_WASM_NAMETYPE_None: break; default: eprintf ("Unkown type: 0x%x\n", cust->type); r_warn_if_reached (); } R_FREE (cust); } }
0
225,446
static inline void set_queued(struct v4l2l_buffer *buffer) { buffer->buffer.flags &= ~V4L2_BUF_FLAG_DONE; buffer->buffer.flags |= V4L2_BUF_FLAG_QUEUED; }
0
409,410
parse_builtin_tcap(char_u *term) { struct builtin_term *p; char_u name[2]; int term_8bit; p = find_builtin_term(term); term_8bit = term_is_8bit(term); // Do not parse if builtin term not found if (p->bt_string == NULL) return; for (++p; p->bt_entry != (int)KS_NAME && p->bt_entry != BT_EXTRA_KEYS; ++p) { if ((int)p->bt_entry >= 0) // KS_xx entry { // Only set the value if it wasn't set yet. if (term_strings[p->bt_entry] == NULL || term_strings[p->bt_entry] == empty_option) { #ifdef FEAT_EVAL int opt_idx = -1; #endif // 8bit terminal: use CSI instead of <Esc>[ if (term_8bit && term_7to8bit((char_u *)p->bt_string) != 0) { char_u *s, *t; s = vim_strsave((char_u *)p->bt_string); if (s != NULL) { for (t = s; *t; ++t) if (term_7to8bit(t)) { *t = term_7to8bit(t); STRMOVE(t + 1, t + 2); } term_strings[p->bt_entry] = s; #ifdef FEAT_EVAL opt_idx = #endif set_term_option_alloced( &term_strings[p->bt_entry]); } } else { term_strings[p->bt_entry] = (char_u *)p->bt_string; #ifdef FEAT_EVAL opt_idx = get_term_opt_idx(&term_strings[p->bt_entry]); #endif } #ifdef FEAT_EVAL set_term_option_sctx_idx(NULL, opt_idx); #endif } } else { name[0] = KEY2TERMCAP0((int)p->bt_entry); name[1] = KEY2TERMCAP1((int)p->bt_entry); if (find_termcode(name) == NULL) add_termcode(name, (char_u *)p->bt_string, term_8bit); } } }
0
452,251
static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params TSRMLS_DC) { int parsize; zval **value; char *xpath_expr, *string_key = NULL; ulong num_key; char **params = NULL; int i = 0; parsize = (2 * zend_hash_num_elements(parht) + 1) * sizeof(char *); params = (char **)safe_emalloc((2 * zend_hash_num_elements(parht) + 1), sizeof(char *), 0); memset((char *)params, 0, parsize); for (zend_hash_internal_pointer_reset(parht); zend_hash_get_current_data(parht, (void **)&value) == SUCCESS; zend_hash_move_forward(parht)) { if (zend_hash_get_current_key(parht, &string_key, &num_key, 1) != HASH_KEY_IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid argument or parameter array"); efree(params); return NULL; } else { if (Z_TYPE_PP(value) != IS_STRING) { SEPARATE_ZVAL(value); convert_to_string(*value); } if (!xpath_params) { xpath_expr = php_xsl_xslt_string_to_xpathexpr(Z_STRVAL_PP(value) TSRMLS_CC); } else { xpath_expr = estrndup(Z_STRVAL_PP(value), Z_STRLEN_PP(value)); } if (xpath_expr) { params[i++] = string_key; params[i++] = xpath_expr; } else { efree(string_key); } } } params[i++] = NULL; return params; }
0
455,354
wdequote_pathname (pathname) char *pathname; { mbstate_t ps; size_t len, n; wchar_t *wpathname; int i, j; wchar_t *orig_wpathname; if (mbsmbchar (pathname) == 0) { udequote_pathname (pathname); return; } len = strlen (pathname); /* Convert the strings into wide characters. */ n = xdupmbstowcs (&wpathname, NULL, pathname); if (n == (size_t) -1) { /* Something wrong. Fall back to single-byte */ udequote_pathname (pathname); return; } orig_wpathname = wpathname; for (i = j = 0; wpathname && wpathname[i]; ) { if (wpathname[i] == L'\\') i++; wpathname[j++] = wpathname[i++]; if (wpathname[i - 1] == L'\0') break; } if (wpathname) wpathname[j] = L'\0'; /* Convert the wide character string into unibyte character set. */ memset (&ps, '\0', sizeof(mbstate_t)); n = wcsrtombs(pathname, (const wchar_t **)&wpathname, len, &ps); pathname[len] = '\0'; /* Can't just free wpathname here; wcsrtombs changes it in many cases. */ free (orig_wpathname); }
0
452,992
static bool nft_dup_netdev_offload_action(const struct nft_expr *expr) { return true; }
0
90,889
void DidGetUsage(int64 usage) { DCHECK(original_message_loop()->BelongsToCurrentThread()); DCHECK(!pending_origins_.empty()); DCHECK(client_tracker_); DCHECK_GE(usage, 0); if (usage < 0) usage = 0; const GURL& origin = pending_origins_.front(); std::string host = net::GetHostOrSpecFromURL(origin); client_tracker_->AddCachedOrigin(origin, usage); pending_origins_.pop_front(); if (pending_origins_.empty() || host != net::GetHostOrSpecFromURL(pending_origins_.front())) { client_tracker_->AddCachedHost(host); } if (pending_origins_.empty()) { CallCompleted(); DeleteSoon(); } }
0
359,570
DEFUN (no_neighbor_disable_connected_check, no_neighbor_disable_connected_check_cmd, NO_NEIGHBOR_CMD2 "disable-connected-check", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "one-hop away EBGP peer using loopback address\n") { return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DISABLE_CONNECTED_CHECK); }
0
512,610
longlong val_int() { return longlong_from_string_with_check(&str_value); }
0
332,393
do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) { oparg_T *oap = cap->oap; pos_T old_cursor; int empty_region_error; int restart_edit_save; #ifdef FEAT_LINEBREAK int lbr_saved = curwin->w_p_lbr; #endif // The visual area is remembered for redo static redo_VIsual_T redo_VIsual = {NUL, 0, 0, 0,0}; int include_line_break = FALSE; #if defined(FEAT_CLIPBOARD) // Yank the visual area into the GUI selection register before we operate // on it and lose it forever. // Don't do it if a specific register was specified, so that ""x"*P works. // This could call do_pending_operator() recursively, but that's OK // because gui_yank will be TRUE for the nested call. if ((clip_star.available || clip_plus.available) && oap->op_type != OP_NOP && !gui_yank && VIsual_active && !redo_VIsual_busy && oap->regname == 0) clip_auto_select(); #endif old_cursor = curwin->w_cursor; // If an operation is pending, handle it... if ((finish_op || VIsual_active) && oap->op_type != OP_NOP) { // Yank can be redone when 'y' is in 'cpoptions', but not when yanking // for the clipboard. int redo_yank = vim_strchr(p_cpo, CPO_YANK) != NULL && !gui_yank; #ifdef FEAT_LINEBREAK // Avoid a problem with unwanted linebreaks in block mode. if (curwin->w_p_lbr) curwin->w_valid &= ~VALID_VIRTCOL; curwin->w_p_lbr = FALSE; #endif oap->is_VIsual = VIsual_active; if (oap->motion_force == 'V') oap->motion_type = MLINE; else if (oap->motion_force == 'v') { // If the motion was linewise, "inclusive" will not have been set. // Use "exclusive" to be consistent. Makes "dvj" work nice. if (oap->motion_type == MLINE) oap->inclusive = FALSE; // If the motion already was characterwise, toggle "inclusive" else if (oap->motion_type == MCHAR) oap->inclusive = !oap->inclusive; oap->motion_type = MCHAR; } else if (oap->motion_force == Ctrl_V) { // Change line- or characterwise motion into Visual block mode. if (!VIsual_active) { VIsual_active = TRUE; VIsual = oap->start; } VIsual_mode = Ctrl_V; VIsual_select = FALSE; VIsual_reselect = FALSE; } // Only redo yank when 'y' flag is in 'cpoptions'. // Never redo "zf" (define fold). if ((redo_yank || oap->op_type != OP_YANK) && ((!VIsual_active || oap->motion_force) // Also redo Operator-pending Visual mode mappings || (VIsual_active && is_ex_cmdchar(cap) && oap->op_type != OP_COLON)) && cap->cmdchar != 'D' #ifdef FEAT_FOLDING && oap->op_type != OP_FOLD && oap->op_type != OP_FOLDOPEN && oap->op_type != OP_FOLDOPENREC && oap->op_type != OP_FOLDCLOSE && oap->op_type != OP_FOLDCLOSEREC && oap->op_type != OP_FOLDDEL && oap->op_type != OP_FOLDDELREC #endif ) { prep_redo(oap->regname, cap->count0, get_op_char(oap->op_type), get_extra_op_char(oap->op_type), oap->motion_force, cap->cmdchar, cap->nchar); if (cap->cmdchar == '/' || cap->cmdchar == '?') // was a search { // If 'cpoptions' does not contain 'r', insert the search // pattern to really repeat the same command. if (vim_strchr(p_cpo, CPO_REDO) == NULL) AppendToRedobuffLit(cap->searchbuf, -1); AppendToRedobuff(NL_STR); } else if (is_ex_cmdchar(cap)) { // do_cmdline() has stored the first typed line in // "repeat_cmdline". When several lines are typed repeating // won't be possible. if (repeat_cmdline == NULL) ResetRedobuff(); else { AppendToRedobuffLit(repeat_cmdline, -1); AppendToRedobuff(NL_STR); VIM_CLEAR(repeat_cmdline); } } } if (redo_VIsual_busy) { // Redo of an operation on a Visual area. Use the same size from // redo_VIsual.rv_line_count and redo_VIsual.rv_vcol. oap->start = curwin->w_cursor; curwin->w_cursor.lnum += redo_VIsual.rv_line_count - 1; if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; VIsual_mode = redo_VIsual.rv_mode; if (redo_VIsual.rv_vcol == MAXCOL || VIsual_mode == 'v') { if (VIsual_mode == 'v') { if (redo_VIsual.rv_line_count <= 1) { validate_virtcol(); curwin->w_curswant = curwin->w_virtcol + redo_VIsual.rv_vcol - 1; } else curwin->w_curswant = redo_VIsual.rv_vcol; } else { curwin->w_curswant = MAXCOL; } coladvance(curwin->w_curswant); } cap->count0 = redo_VIsual.rv_count; if (redo_VIsual.rv_count != 0) cap->count1 = redo_VIsual.rv_count; else cap->count1 = 1; } else if (VIsual_active) { if (!gui_yank) { // Save the current VIsual area for '< and '> marks, and "gv" curbuf->b_visual.vi_start = VIsual; curbuf->b_visual.vi_end = curwin->w_cursor; curbuf->b_visual.vi_mode = VIsual_mode; restore_visual_mode(); curbuf->b_visual.vi_curswant = curwin->w_curswant; # ifdef FEAT_EVAL curbuf->b_visual_mode_eval = VIsual_mode; # endif } // In Select mode, a linewise selection is operated upon like a // characterwise selection. // Special case: gH<Del> deletes the last line. if (VIsual_select && VIsual_mode == 'V' && cap->oap->op_type != OP_DELETE) { if (LT_POS(VIsual, curwin->w_cursor)) { VIsual.col = 0; curwin->w_cursor.col = (colnr_T)STRLEN(ml_get(curwin->w_cursor.lnum)); } else { curwin->w_cursor.col = 0; VIsual.col = (colnr_T)STRLEN(ml_get(VIsual.lnum)); } VIsual_mode = 'v'; } // If 'selection' is "exclusive", backup one character for // charwise selections. else if (VIsual_mode == 'v') include_line_break = unadjust_for_sel(); oap->start = VIsual; if (VIsual_mode == 'V') { oap->start.col = 0; oap->start.coladd = 0; } } // Set oap->start to the first position of the operated text, oap->end // to the end of the operated text. w_cursor is equal to oap->start. if (LT_POS(oap->start, curwin->w_cursor)) { #ifdef FEAT_FOLDING // Include folded lines completely. if (!VIsual_active) { if (hasFolding(oap->start.lnum, &oap->start.lnum, NULL)) oap->start.col = 0; if ((curwin->w_cursor.col > 0 || oap->inclusive || oap->motion_type == MLINE) && hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum)) curwin->w_cursor.col = (colnr_T)STRLEN(ml_get_curline()); } #endif oap->end = curwin->w_cursor; curwin->w_cursor = oap->start; // w_virtcol may have been updated; if the cursor goes back to its // previous position w_virtcol becomes invalid and isn't updated // automatically. curwin->w_valid &= ~VALID_VIRTCOL; } else { #ifdef FEAT_FOLDING // Include folded lines completely. if (!VIsual_active && oap->motion_type == MLINE) { if (hasFolding(curwin->w_cursor.lnum, &curwin->w_cursor.lnum, NULL)) curwin->w_cursor.col = 0; if (hasFolding(oap->start.lnum, NULL, &oap->start.lnum)) oap->start.col = (colnr_T)STRLEN(ml_get(oap->start.lnum)); } #endif oap->end = oap->start; oap->start = curwin->w_cursor; } // Just in case lines were deleted that make the position invalid. check_pos(curwin->w_buffer, &oap->end); oap->line_count = oap->end.lnum - oap->start.lnum + 1; // Set "virtual_op" before resetting VIsual_active. virtual_op = virtual_active(); if (VIsual_active || redo_VIsual_busy) { get_op_vcol(oap, redo_VIsual.rv_vcol, TRUE); if (!redo_VIsual_busy && !gui_yank) { // Prepare to reselect and redo Visual: this is based on the // size of the Visual text resel_VIsual_mode = VIsual_mode; if (curwin->w_curswant == MAXCOL) resel_VIsual_vcol = MAXCOL; else { if (VIsual_mode != Ctrl_V) getvvcol(curwin, &(oap->end), NULL, NULL, &oap->end_vcol); if (VIsual_mode == Ctrl_V || oap->line_count <= 1) { if (VIsual_mode != Ctrl_V) getvvcol(curwin, &(oap->start), &oap->start_vcol, NULL, NULL); resel_VIsual_vcol = oap->end_vcol - oap->start_vcol + 1; } else resel_VIsual_vcol = oap->end_vcol; } resel_VIsual_line_count = oap->line_count; } // can't redo yank (unless 'y' is in 'cpoptions') and ":" if ((redo_yank || oap->op_type != OP_YANK) && oap->op_type != OP_COLON #ifdef FEAT_FOLDING && oap->op_type != OP_FOLD && oap->op_type != OP_FOLDOPEN && oap->op_type != OP_FOLDOPENREC && oap->op_type != OP_FOLDCLOSE && oap->op_type != OP_FOLDCLOSEREC && oap->op_type != OP_FOLDDEL && oap->op_type != OP_FOLDDELREC #endif && oap->motion_force == NUL ) { // Prepare for redoing. Only use the nchar field for "r", // otherwise it might be the second char of the operator. if (cap->cmdchar == 'g' && (cap->nchar == 'n' || cap->nchar == 'N')) prep_redo(oap->regname, cap->count0, get_op_char(oap->op_type), get_extra_op_char(oap->op_type), oap->motion_force, cap->cmdchar, cap->nchar); else if (!is_ex_cmdchar(cap)) { int opchar = get_op_char(oap->op_type); int extra_opchar = get_extra_op_char(oap->op_type); int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL; // reverse what nv_replace() did if (nchar == REPLACE_CR_NCHAR) nchar = CAR; else if (nchar == REPLACE_NL_NCHAR) nchar = NL; if (opchar == 'g' && extra_opchar == '@') // also repeat the count for 'operatorfunc' prep_redo_num2(oap->regname, 0L, NUL, 'v', cap->count0, opchar, extra_opchar, nchar); else prep_redo(oap->regname, 0L, NUL, 'v', opchar, extra_opchar, nchar); } if (!redo_VIsual_busy) { redo_VIsual.rv_mode = resel_VIsual_mode; redo_VIsual.rv_vcol = resel_VIsual_vcol; redo_VIsual.rv_line_count = resel_VIsual_line_count; redo_VIsual.rv_count = cap->count0; redo_VIsual.rv_arg = cap->arg; } } // oap->inclusive defaults to TRUE. // If oap->end is on a NUL (empty line) oap->inclusive becomes // FALSE. This makes "d}P" and "v}dP" work the same. if (oap->motion_force == NUL || oap->motion_type == MLINE) oap->inclusive = TRUE; if (VIsual_mode == 'V') oap->motion_type = MLINE; else { oap->motion_type = MCHAR; if (VIsual_mode != Ctrl_V && *ml_get_pos(&(oap->end)) == NUL && (include_line_break || !virtual_op)) { oap->inclusive = FALSE; // Try to include the newline, unless it's an operator // that works on lines only. if (*p_sel != 'o' && !op_on_lines(oap->op_type) && oap->end.lnum < curbuf->b_ml.ml_line_count) { ++oap->end.lnum; oap->end.col = 0; oap->end.coladd = 0; ++oap->line_count; } } } redo_VIsual_busy = FALSE; // Switch Visual off now, so screen updating does // not show inverted text when the screen is redrawn. // With OP_YANK and sometimes with OP_COLON and OP_FILTER there is // no screen redraw, so it is done here to remove the inverted // part. if (!gui_yank) { VIsual_active = FALSE; setmouse(); mouse_dragging = 0; may_clear_cmdline(); if ((oap->op_type == OP_YANK || oap->op_type == OP_COLON || oap->op_type == OP_FUNCTION || oap->op_type == OP_FILTER) && oap->motion_force == NUL) { #ifdef FEAT_LINEBREAK // make sure redrawing is correct curwin->w_p_lbr = lbr_saved; #endif redraw_curbuf_later(INVERTED); } } } // Include the trailing byte of a multi-byte char. if (has_mbyte && oap->inclusive) { int l; l = (*mb_ptr2len)(ml_get_pos(&oap->end)); if (l > 1) oap->end.col += l - 1; } curwin->w_set_curswant = TRUE; // oap->empty is set when start and end are the same. The inclusive // flag affects this too, unless yanking and the end is on a NUL. oap->empty = (oap->motion_type == MCHAR && (!oap->inclusive || (oap->op_type == OP_YANK && gchar_pos(&oap->end) == NUL)) && EQUAL_POS(oap->start, oap->end) && !(virtual_op && oap->start.coladd != oap->end.coladd)); // For delete, change and yank, it's an error to operate on an // empty region, when 'E' included in 'cpoptions' (Vi compatible). empty_region_error = (oap->empty && vim_strchr(p_cpo, CPO_EMPTYREGION) != NULL); // Force a redraw when operating on an empty Visual region, when // 'modifiable is off or creating a fold. if (oap->is_VIsual && (oap->empty || !curbuf->b_p_ma #ifdef FEAT_FOLDING || oap->op_type == OP_FOLD #endif )) { #ifdef FEAT_LINEBREAK curwin->w_p_lbr = lbr_saved; #endif redraw_curbuf_later(INVERTED); } // If the end of an operator is in column one while oap->motion_type // is MCHAR and oap->inclusive is FALSE, we put op_end after the last // character in the previous line. If op_start is on or before the // first non-blank in the line, the operator becomes linewise // (strange, but that's the way vi does it). if ( oap->motion_type == MCHAR && oap->inclusive == FALSE && !(cap->retval & CA_NO_ADJ_OP_END) && oap->end.col == 0 && (!oap->is_VIsual || *p_sel == 'o') && !oap->block_mode && oap->line_count > 1) { oap->end_adjusted = TRUE; // remember that we did this --oap->line_count; --oap->end.lnum; if (inindent(0)) oap->motion_type = MLINE; else { oap->end.col = (colnr_T)STRLEN(ml_get(oap->end.lnum)); if (oap->end.col) { --oap->end.col; oap->inclusive = TRUE; } } } else oap->end_adjusted = FALSE; switch (oap->op_type) { case OP_LSHIFT: case OP_RSHIFT: op_shift(oap, TRUE, oap->is_VIsual ? (int)cap->count1 : 1); auto_format(FALSE, TRUE); break; case OP_JOIN_NS: case OP_JOIN: if (oap->line_count < 2) oap->line_count = 2; if (curwin->w_cursor.lnum + oap->line_count - 1 > curbuf->b_ml.ml_line_count) beep_flush(); else { (void)do_join(oap->line_count, oap->op_type == OP_JOIN, TRUE, TRUE, TRUE); auto_format(FALSE, TRUE); } break; case OP_DELETE: VIsual_reselect = FALSE; // don't reselect now if (empty_region_error) { vim_beep(BO_OPER); CancelRedo(); } else { (void)op_delete(oap); // save cursor line for undo if it wasn't saved yet if (oap->motion_type == MLINE && has_format_option(FO_AUTO) && u_save_cursor() == OK) auto_format(FALSE, TRUE); } break; case OP_YANK: if (empty_region_error) { if (!gui_yank) { vim_beep(BO_OPER); CancelRedo(); } } else { #ifdef FEAT_LINEBREAK curwin->w_p_lbr = lbr_saved; #endif oap->excl_tr_ws = cap->cmdchar == 'z'; (void)op_yank(oap, FALSE, !gui_yank); } check_cursor_col(); break; case OP_CHANGE: VIsual_reselect = FALSE; // don't reselect now if (empty_region_error) { vim_beep(BO_OPER); CancelRedo(); } else { // This is a new edit command, not a restart. Need to // remember it to make 'insertmode' work with mappings for // Visual mode. But do this only once and not when typed and // 'insertmode' isn't set. if (p_im || !KeyTyped) restart_edit_save = restart_edit; else restart_edit_save = 0; restart_edit = 0; #ifdef FEAT_LINEBREAK // Restore linebreak, so that when the user edits it looks as // before. curwin->w_p_lbr = lbr_saved; #endif // Reset finish_op now, don't want it set inside edit(). finish_op = FALSE; if (op_change(oap)) // will call edit() cap->retval |= CA_COMMAND_BUSY; if (restart_edit == 0) restart_edit = restart_edit_save; } break; case OP_FILTER: if (vim_strchr(p_cpo, CPO_FILTER) != NULL) AppendToRedobuff((char_u *)"!\r"); // use any last used !cmd else bangredo = TRUE; // do_bang() will put cmd in redo buffer // FALLTHROUGH case OP_INDENT: case OP_COLON: #if defined(FEAT_LISP) || defined(FEAT_CINDENT) // If 'equalprg' is empty, do the indenting internally. if (oap->op_type == OP_INDENT && *get_equalprg() == NUL) { # ifdef FEAT_LISP if (curbuf->b_p_lisp) { op_reindent(oap, get_lisp_indent); break; } # endif # ifdef FEAT_CINDENT op_reindent(oap, # ifdef FEAT_EVAL *curbuf->b_p_inde != NUL ? get_expr_indent : # endif get_c_indent); break; # endif } #endif op_colon(oap); break; case OP_TILDE: case OP_UPPER: case OP_LOWER: case OP_ROT13: if (empty_region_error) { vim_beep(BO_OPER); CancelRedo(); } else op_tilde(oap); check_cursor_col(); break; case OP_FORMAT: #if defined(FEAT_EVAL) if (*curbuf->b_p_fex != NUL) op_formatexpr(oap); // use expression else #endif { if (*p_fp != NUL || *curbuf->b_p_fp != NUL) op_colon(oap); // use external command else op_format(oap, FALSE); // use internal function } break; case OP_FORMAT2: op_format(oap, TRUE); // use internal function break; case OP_FUNCTION: { redo_VIsual_T save_redo_VIsual = redo_VIsual; #ifdef FEAT_LINEBREAK // Restore linebreak, so that when the user edits it looks as // before. curwin->w_p_lbr = lbr_saved; #endif // call 'operatorfunc' op_function(oap); // Restore the info for redoing Visual mode, the function may // invoke another operator and unintentionally change it. redo_VIsual = save_redo_VIsual; break; } case OP_INSERT: case OP_APPEND: VIsual_reselect = FALSE; // don't reselect now if (empty_region_error) { vim_beep(BO_OPER); CancelRedo(); } else { // This is a new edit command, not a restart. Need to // remember it to make 'insertmode' work with mappings for // Visual mode. But do this only once. restart_edit_save = restart_edit; restart_edit = 0; #ifdef FEAT_LINEBREAK // Restore linebreak, so that when the user edits it looks as // before. curwin->w_p_lbr = lbr_saved; #endif op_insert(oap, cap->count1); #ifdef FEAT_LINEBREAK // Reset linebreak, so that formatting works correctly. curwin->w_p_lbr = FALSE; #endif // TODO: when inserting in several lines, should format all // the lines. auto_format(FALSE, TRUE); if (restart_edit == 0) restart_edit = restart_edit_save; else cap->retval |= CA_COMMAND_BUSY; } break; case OP_REPLACE: VIsual_reselect = FALSE; // don't reselect now if (empty_region_error) { vim_beep(BO_OPER); CancelRedo(); } else { #ifdef FEAT_LINEBREAK // Restore linebreak, so that when the user edits it looks as // before. curwin->w_p_lbr = lbr_saved; #endif op_replace(oap, cap->nchar); } break; #ifdef FEAT_FOLDING case OP_FOLD: VIsual_reselect = FALSE; // don't reselect now foldCreate(oap->start.lnum, oap->end.lnum); break; case OP_FOLDOPEN: case OP_FOLDOPENREC: case OP_FOLDCLOSE: case OP_FOLDCLOSEREC: VIsual_reselect = FALSE; // don't reselect now opFoldRange(oap->start.lnum, oap->end.lnum, oap->op_type == OP_FOLDOPEN || oap->op_type == OP_FOLDOPENREC, oap->op_type == OP_FOLDOPENREC || oap->op_type == OP_FOLDCLOSEREC, oap->is_VIsual); break; case OP_FOLDDEL: case OP_FOLDDELREC: VIsual_reselect = FALSE; // don't reselect now deleteFold(oap->start.lnum, oap->end.lnum, oap->op_type == OP_FOLDDELREC, oap->is_VIsual); break; #endif case OP_NR_ADD: case OP_NR_SUB: if (empty_region_error) { vim_beep(BO_OPER); CancelRedo(); } else { VIsual_active = TRUE; #ifdef FEAT_LINEBREAK curwin->w_p_lbr = lbr_saved; #endif op_addsub(oap, cap->count1, redo_VIsual.rv_arg); VIsual_active = FALSE; } check_cursor_col(); break; default: clearopbeep(oap); } virtual_op = MAYBE; if (!gui_yank) { // if 'sol' not set, go back to old column for some commands if (!p_sol && oap->motion_type == MLINE && !oap->end_adjusted && (oap->op_type == OP_LSHIFT || oap->op_type == OP_RSHIFT || oap->op_type == OP_DELETE)) { #ifdef FEAT_LINEBREAK curwin->w_p_lbr = FALSE; #endif coladvance(curwin->w_curswant = old_col); } } else { curwin->w_cursor = old_cursor; } oap->block_mode = FALSE; clearop(oap); motion_force = NUL; } #ifdef FEAT_LINEBREAK curwin->w_p_lbr = lbr_saved; #endif }
0
522,344
int GmfCloseMesh(int64_t MshIdx) { int i, res = 1; GmfMshSct *msh = (GmfMshSct *)MshIdx; RecBlk(msh, msh->buf, 0); // In write down the "End" kw in write mode if(msh->mod == GmfWrite) { if(msh->typ & Asc) fprintf(msh->hdl, "\n%s\n", GmfKwdFmt[ GmfEnd ][0]); else GmfSetKwd(MshIdx, GmfEnd, 0); } // Close the file and free the mesh structure if(msh->typ & Bin) #ifdef WITH_GMF_AIO close(msh->FilDes); #else fclose(msh->hdl); #endif else if(fclose(msh->hdl)) res = 0; // Free optional H.O. renumbering tables for(i=0;i<GmfLastKeyword;i++) if(msh->KwdTab[i].OrdTab) free(msh->KwdTab[i].OrdTab); free(msh); return(res); }
0
309,867
skip_delay(const char *s) { if (s[0] == '$' && s[1] == '<') { s += 2; while (isdigit(UChar(*s)) || *s == '/') ++s; if (*s == '>') ++s; } return s; }
0
309,904
termattrs(void) { return NCURSES_SP_NAME(termattrs) (CURRENT_SCREEN); }
0
225,664
GF_Box *edts_box_new() { ISOM_DECL_BOX_ALLOC(GF_EditBox, GF_ISOM_BOX_TYPE_EDTS); return (GF_Box *) tmp; }
0
195,056
inline void BiasAndClamp(float clamp_min, float clamp_max, int bias_size, const float* bias_data, int array_size, float* array_data) { // Note: see b/132215220: in May 2019 we thought it would be OK to replace // this with the Eigen one-liner: // return (array.colwise() + bias).cwiseMin(clamp_max).cwiseMin(clamp_max). // This turned out to severely regress performance: +4ms (i.e. 8%) on // MobileNet v2 / 1.0 / 224. So we keep custom NEON code for now. TFLITE_DCHECK_EQ((array_size % bias_size), 0); #ifdef USE_NEON float* array_ptr = array_data; float* array_end_ptr = array_ptr + array_size; const auto clamp_min_vec = vdupq_n_f32(clamp_min); const auto clamp_max_vec = vdupq_n_f32(clamp_max); for (; array_ptr != array_end_ptr; array_ptr += bias_size) { int i = 0; for (; i <= bias_size - 16; i += 16) { auto b0 = vld1q_f32(bias_data + i); auto b1 = vld1q_f32(bias_data + i + 4); auto b2 = vld1q_f32(bias_data + i + 8); auto b3 = vld1q_f32(bias_data + i + 12); auto a0 = vld1q_f32(array_ptr + i); auto a1 = vld1q_f32(array_ptr + i + 4); auto a2 = vld1q_f32(array_ptr + i + 8); auto a3 = vld1q_f32(array_ptr + i + 12); auto x0 = vaddq_f32(a0, b0); auto x1 = vaddq_f32(a1, b1); auto x2 = vaddq_f32(a2, b2); auto x3 = vaddq_f32(a3, b3); x0 = vmaxq_f32(clamp_min_vec, x0); x1 = vmaxq_f32(clamp_min_vec, x1); x2 = vmaxq_f32(clamp_min_vec, x2); x3 = vmaxq_f32(clamp_min_vec, x3); x0 = vminq_f32(clamp_max_vec, x0); x1 = vminq_f32(clamp_max_vec, x1); x2 = vminq_f32(clamp_max_vec, x2); x3 = vminq_f32(clamp_max_vec, x3); vst1q_f32(array_ptr + i, x0); vst1q_f32(array_ptr + i + 4, x1); vst1q_f32(array_ptr + i + 8, x2); vst1q_f32(array_ptr + i + 12, x3); } for (; i <= bias_size - 4; i += 4) { auto b = vld1q_f32(bias_data + i); auto a = vld1q_f32(array_ptr + i); auto x = vaddq_f32(a, b); x = vmaxq_f32(clamp_min_vec, x); x = vminq_f32(clamp_max_vec, x); vst1q_f32(array_ptr + i, x); } for (; i < bias_size; i++) { array_ptr[i] = ActivationFunctionWithMinMax(array_ptr[i] + bias_data[i], clamp_min, clamp_max); } } #else // not NEON for (int array_offset = 0; array_offset < array_size; array_offset += bias_size) { for (int i = 0; i < bias_size; i++) { array_data[array_offset + i] = ActivationFunctionWithMinMax( array_data[array_offset + i] + bias_data[i], clamp_min, clamp_max); } } #endif }
1
398,542
static void free_loc_table_list(RzBinDwarfLocList *loc_list) { RzListIter *iter; RzBinDwarfLocRange *range; rz_list_foreach (loc_list->list, iter, range) { free(range->expression->data); free(range->expression); free(range); } rz_list_free(loc_list->list); free(loc_list); }
0
244,294
GF_Err strk_box_write(GF_Box *s, GF_BitStream *bs) { return gf_isom_box_write_header(s, bs); }
0
101,688
static WebProcessProxy::WebPageProxyMap& globalPageMap() { ASSERT(isMainThread()); DEFINE_STATIC_LOCAL(WebProcessProxy::WebPageProxyMap, pageMap, ()); return pageMap; }
0
254,898
shared_ptr<Sorter<Value, Value>::Iterator> DocumentSourceGroup::spill() { _usedDisk = true; vector<const GroupsMap::value_type*> ptrs; // using pointers to speed sorting ptrs.reserve(_groups->size()); for (GroupsMap::const_iterator it = _groups->begin(), end = _groups->end(); it != end; ++it) { ptrs.push_back(&*it); } stable_sort(ptrs.begin(), ptrs.end(), SpillSTLComparator(pExpCtx->getValueComparator())); SortedFileWriter<Value, Value> writer(SortOptions().TempDir(pExpCtx->tempDir), _file); switch (_accumulatedFields.size()) { // same as ptrs[i]->second.size() for all i. case 0: // no values, essentially a distinct for (size_t i = 0; i < ptrs.size(); i++) { writer.addAlreadySorted(ptrs[i]->first, Value()); } break; case 1: // just one value, use optimized serialization as single Value for (size_t i = 0; i < ptrs.size(); i++) { writer.addAlreadySorted(ptrs[i]->first, ptrs[i]->second[0]->getValue(/*toBeMerged=*/true)); } break; default: // multiple values, serialize as array-typed Value for (size_t i = 0; i < ptrs.size(); i++) { vector<Value> accums; for (size_t j = 0; j < ptrs[i]->second.size(); j++) { accums.push_back(ptrs[i]->second[j]->getValue(/*toBeMerged=*/true)); } writer.addAlreadySorted(ptrs[i]->first, Value(std::move(accums))); } break; } _groups->clear(); Sorter<Value, Value>::Iterator* iteratorPtr = writer.done(); return shared_ptr<Sorter<Value, Value>::Iterator>(iteratorPtr); }
0
424,908
static int iwl_pcie_load_section(struct iwl_trans *trans, u8 section_num, const struct fw_desc *section) { u8 *v_addr; dma_addr_t p_addr; u32 offset, chunk_sz = min_t(u32, FH_MEM_TB_MAX_LENGTH, section->len); int ret = 0; IWL_DEBUG_FW(trans, "[%d] uCode section being loaded...\n", section_num); v_addr = dma_alloc_coherent(trans->dev, chunk_sz, &p_addr, GFP_KERNEL | __GFP_NOWARN); if (!v_addr) { IWL_DEBUG_INFO(trans, "Falling back to small chunks of DMA\n"); chunk_sz = PAGE_SIZE; v_addr = dma_alloc_coherent(trans->dev, chunk_sz, &p_addr, GFP_KERNEL); if (!v_addr) return -ENOMEM; } for (offset = 0; offset < section->len; offset += chunk_sz) { u32 copy_size, dst_addr; bool extended_addr = false; copy_size = min_t(u32, chunk_sz, section->len - offset); dst_addr = section->offset + offset; if (dst_addr >= IWL_FW_MEM_EXTENDED_START && dst_addr <= IWL_FW_MEM_EXTENDED_END) extended_addr = true; if (extended_addr) iwl_set_bits_prph(trans, LMPM_CHICK, LMPM_CHICK_EXTENDED_ADDR_SPACE); memcpy(v_addr, (u8 *)section->data + offset, copy_size); ret = iwl_pcie_load_firmware_chunk(trans, dst_addr, p_addr, copy_size); if (extended_addr) iwl_clear_bits_prph(trans, LMPM_CHICK, LMPM_CHICK_EXTENDED_ADDR_SPACE); if (ret) { IWL_ERR(trans, "Could not load the [%d] uCode section\n", section_num); break; } } dma_free_coherent(trans->dev, chunk_sz, v_addr, p_addr); return ret; }
0
343,232
void dorest(const char *name) { char *endptr; restartat = (off_t) strtoull(name, &endptr, 10); if (*endptr != 0 || restartat < (off_t) 0) { restartat = 0; addreply(554, MSG_REST_NOT_NUMERIC "\n" MSG_REST_RESET); } else { if (type == 1 && restartat != 0) { #ifdef STRICT_REST addreply_noformat(504, MSG_REST_ASCII_STRICT); #else addreply(350, MSG_REST_ASCII_WORKAROUND, (long long) restartat); #endif } else { if (restartat != 0) { logfile(LOG_NOTICE, MSG_REST_SUCCESS, (long long) restartat); } addreply(350, MSG_REST_SUCCESS, (long long) restartat); } } }
0
421,388
static void in(int d) { if (minify < 1) while (d-- > 0) putchar('\t'); }
0
424,926
void iwl_pcie_synchronize_irqs(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); if (trans_pcie->msix_enabled) { int i; for (i = 0; i < trans_pcie->alloc_vecs; i++) synchronize_irq(trans_pcie->msix_entries[i].vector); } else { synchronize_irq(trans_pcie->pci_dev->irq); } }
0
216,861
EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params) { int ok = 0, tmp; EC_GROUP *ret = NULL, *dup = NULL; BIGNUM *p = NULL, *a = NULL, *b = NULL; EC_POINT *point = NULL; long field_bits; int curve_name = NID_undef; BN_CTX *ctx = NULL; if (!params->fieldID || !params->fieldID->fieldType || !params->fieldID->p.ptr) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } /* * Now extract the curve parameters a and b. Note that, although SEC 1 * specifies the length of their encodings, historical versions of OpenSSL * encoded them incorrectly, so we must accept any length for backwards * compatibility. */ if (!params->curve || !params->curve->a || !params->curve->a->data || !params->curve->b || !params->curve->b->data) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } a = BN_bin2bn(params->curve->a->data, params->curve->a->length, NULL); if (a == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_BN_LIB); goto err; } b = BN_bin2bn(params->curve->b->data, params->curve->b->length, NULL); if (b == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_BN_LIB); goto err; } /* get the field parameters */ tmp = OBJ_obj2nid(params->fieldID->fieldType); if (tmp == NID_X9_62_characteristic_two_field) #ifdef OPENSSL_NO_EC2M { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_GF2M_NOT_SUPPORTED); goto err; } #else { X9_62_CHARACTERISTIC_TWO *char_two; char_two = params->fieldID->p.char_two; field_bits = char_two->m; if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_FIELD_TOO_LARGE); goto err; } if ((p = BN_new()) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_MALLOC_FAILURE); goto err; } /* get the base type */ tmp = OBJ_obj2nid(char_two->type); if (tmp == NID_X9_62_tpBasis) { long tmp_long; if (!char_two->p.tpBasis) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } tmp_long = ASN1_INTEGER_get(char_two->p.tpBasis); if (!(char_two->m > tmp_long && tmp_long > 0)) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_TRINOMIAL_BASIS); goto err; } /* create the polynomial */ if (!BN_set_bit(p, (int)char_two->m)) goto err; if (!BN_set_bit(p, (int)tmp_long)) goto err; if (!BN_set_bit(p, 0)) goto err; } else if (tmp == NID_X9_62_ppBasis) { X9_62_PENTANOMIAL *penta; penta = char_two->p.ppBasis; if (!penta) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } if (! (char_two->m > penta->k3 && penta->k3 > penta->k2 && penta->k2 > penta->k1 && penta->k1 > 0)) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_PENTANOMIAL_BASIS); goto err; } /* create the polynomial */ if (!BN_set_bit(p, (int)char_two->m)) goto err; if (!BN_set_bit(p, (int)penta->k1)) goto err; if (!BN_set_bit(p, (int)penta->k2)) goto err; if (!BN_set_bit(p, (int)penta->k3)) goto err; if (!BN_set_bit(p, 0)) goto err; } else if (tmp == NID_X9_62_onBasis) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_NOT_IMPLEMENTED); goto err; } else { /* error */ ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } /* create the EC_GROUP structure */ ret = EC_GROUP_new_curve_GF2m(p, a, b, NULL); } #endif else if (tmp == NID_X9_62_prime_field) { /* we have a curve over a prime field */ /* extract the prime number */ if (!params->fieldID->p.prime) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } p = ASN1_INTEGER_to_BN(params->fieldID->p.prime, NULL); if (p == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB); goto err; } if (BN_is_negative(p) || BN_is_zero(p)) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_FIELD); goto err; } field_bits = BN_num_bits(p); if (field_bits > OPENSSL_ECC_MAX_FIELD_BITS) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_FIELD_TOO_LARGE); goto err; } /* create the EC_GROUP structure */ ret = EC_GROUP_new_curve_GFp(p, a, b, NULL); } else { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_FIELD); goto err; } if (ret == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB); goto err; } /* extract seed (optional) */ if (params->curve->seed != NULL) { OPENSSL_free(ret->seed); if ((ret->seed = OPENSSL_malloc(params->curve->seed->length)) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_MALLOC_FAILURE); goto err; } memcpy(ret->seed, params->curve->seed->data, params->curve->seed->length); ret->seed_len = params->curve->seed->length; } if (!params->order || !params->base || !params->base->data) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR); goto err; } if ((point = EC_POINT_new(ret)) == NULL) goto err; /* set the point conversion form */ EC_GROUP_set_point_conversion_form(ret, (point_conversion_form_t) (params->base->data[0] & ~0x01)); /* extract the ec point */ if (!EC_POINT_oct2point(ret, point, params->base->data, params->base->length, NULL)) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB); goto err; } /* extract the order */ if ((a = ASN1_INTEGER_to_BN(params->order, a)) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB); goto err; } if (BN_is_negative(a) || BN_is_zero(a)) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_GROUP_ORDER); goto err; } if (BN_num_bits(a) > (int)field_bits + 1) { /* Hasse bound */ ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_INVALID_GROUP_ORDER); goto err; } /* extract the cofactor (optional) */ if (params->cofactor == NULL) { BN_free(b); b = NULL; } else if ((b = ASN1_INTEGER_to_BN(params->cofactor, b)) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_ASN1_LIB); goto err; } /* set the generator, order and cofactor (if present) */ if (!EC_GROUP_set_generator(ret, point, a, b)) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB); goto err; } /* * Check if the explicit parameters group just created matches one of the * built-in curves. * * We create a copy of the group just built, so that we can remove optional * fields for the lookup: we do this to avoid the possibility that one of * the optional parameters is used to force the library into using a less * performant and less secure EC_METHOD instead of the specialized one. * In any case, `seed` is not really used in any computation, while a * cofactor different from the one in the built-in table is just * mathematically wrong anyway and should not be used. */ if ((ctx = BN_CTX_new()) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_BN_LIB); goto err; } if ((dup = EC_GROUP_dup(ret)) == NULL || EC_GROUP_set_seed(dup, NULL, 0) != 1 || !EC_GROUP_set_generator(dup, point, a, NULL)) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB); goto err; } if ((curve_name = ec_curve_nid_from_params(dup, ctx)) != NID_undef) { /* * The input explicit parameters successfully matched one of the * built-in curves: often for built-in curves we have specialized * methods with better performance and hardening. * * In this case we replace the `EC_GROUP` created through explicit * parameters with one created from a named group. */ EC_GROUP *named_group = NULL; #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 /* * NID_wap_wsg_idm_ecid_wtls12 and NID_secp224r1 are both aliases for * the same curve, we prefer the SECP nid when matching explicit * parameters as that is associated with a specialized EC_METHOD. */ if (curve_name == NID_wap_wsg_idm_ecid_wtls12) curve_name = NID_secp224r1; #endif /* !def(OPENSSL_NO_EC_NISTP_64_GCC_128) */ if ((named_group = EC_GROUP_new_by_curve_name(curve_name)) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, ERR_R_EC_LIB); goto err; } EC_GROUP_free(ret); ret = named_group; /* * Set the flag so that EC_GROUPs created from explicit parameters are * serialized using explicit parameters by default. */ EC_GROUP_set_asn1_flag(ret, OPENSSL_EC_EXPLICIT_CURVE); /* * If the input params do not contain the optional seed field we make * sure it is not added to the returned group. * * The seed field is not really used inside libcrypto anyway, and * adding it to parsed explicit parameter keys would alter their DER * encoding output (because of the extra field) which could impact * applications fingerprinting keys by their DER encoding. */ if (params->curve->seed == NULL) { if (EC_GROUP_set_seed(ret, NULL, 0) != 1) goto err; } } ok = 1; err: if (!ok) { EC_GROUP_free(ret); ret = NULL; } EC_GROUP_free(dup); BN_free(p); BN_free(a); BN_free(b); EC_POINT_free(point); BN_CTX_free(ctx); return ret; }
1
197,185
static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const uint8_t *buf, int size) { GetBitContext gb; PutBitContext pb; MPEG4AudioConfig m4ac; int off; init_get_bits(&gb, buf, size * 8); off = avpriv_mpeg4audio_get_config2(&m4ac, buf, size, 1, s); if (off < 0) return off; skip_bits_long(&gb, off); adts->objecttype = m4ac.object_type - 1; adts->sample_rate_index = m4ac.sampling_index; adts->channel_conf = m4ac.chan_config; if (adts->objecttype > 3U) { av_log(s, AV_LOG_ERROR, "MPEG-4 AOT %d is not allowed in ADTS\n", adts->objecttype+1); return AVERROR_INVALIDDATA; } if (adts->sample_rate_index == 15) { av_log(s, AV_LOG_ERROR, "Escape sample rate index illegal in ADTS\n"); return AVERROR_INVALIDDATA; } if (get_bits(&gb, 1)) { av_log(s, AV_LOG_ERROR, "960/120 MDCT window is not allowed in ADTS\n"); return AVERROR_INVALIDDATA; } if (get_bits(&gb, 1)) { av_log(s, AV_LOG_ERROR, "Scalable configurations are not allowed in ADTS\n"); return AVERROR_INVALIDDATA; } if (get_bits(&gb, 1)) { av_log(s, AV_LOG_ERROR, "Extension flag is not allowed in ADTS\n"); return AVERROR_INVALIDDATA; } if (!adts->channel_conf) { init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE); put_bits(&pb, 3, 5); //ID_PCE adts->pce_size = (ff_copy_pce_data(&pb, &gb) + 3) / 8; flush_put_bits(&pb); } adts->write_adts = 1; return 0; }
1
301,424
static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd) { NTSTATUS result; START_PROFILE(fset_nt_acl); result = set_nt_acl(fsp, security_info_sent, psd); END_PROFILE(fset_nt_acl); return result; }
0
374,043
static RBinInfo *info(RBinFile *bf) { SymbolsMetadata sm = parseMetadata (bf->buf, 0x40); RBinInfo *ret = R_NEW0 (RBinInfo); if (!ret) { return NULL; } ret->file = strdup (bf->file); ret->bclass = strdup ("symbols"); ret->os = strdup ("unknown"); ret->arch = sm.arch ? strdup (sm.arch) : NULL; ret->bits = sm.bits; ret->type = strdup ("Symbols file"); ret->subsystem = strdup ("llvm"); ret->has_va = true; return ret; }
0
400,405
edit( int cmdchar, int startln, // if set, insert at start of line long count) { int c = 0; char_u *ptr; int lastc = 0; int mincol; static linenr_T o_lnum = 0; int i; int did_backspace = TRUE; // previous char was backspace int line_is_white = FALSE; // line is empty before insert linenr_T old_topline = 0; // topline before insertion #ifdef FEAT_DIFF int old_topfill = -1; #endif int inserted_space = FALSE; // just inserted a space int replaceState = MODE_REPLACE; int nomove = FALSE; // don't move cursor on return #ifdef FEAT_JOB_CHANNEL int cmdchar_todo = cmdchar; #endif #ifdef FEAT_CONCEAL int cursor_line_was_concealed; #endif // Remember whether editing was restarted after CTRL-O. did_restart_edit = restart_edit; // sleep before redrawing, needed for "CTRL-O :" that results in an // error message check_for_delay(TRUE); // set Insstart_orig to Insstart update_Insstart_orig = TRUE; #ifdef HAVE_SANDBOX // Don't allow inserting in the sandbox. if (sandbox != 0) { emsg(_(e_not_allowed_in_sandbox)); return FALSE; } #endif // Don't allow changes in the buffer while editing the cmdline. The // caller of getcmdline() may get confused. // Don't allow recursive insert mode when busy with completion. if (textlock != 0 || ins_compl_active() || compl_busy || pum_visible()) { emsg(_(e_not_allowed_to_change_text_or_change_window)); return FALSE; } ins_compl_clear(); // clear stuff for CTRL-X mode /* * Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx". */ if (cmdchar != 'r' && cmdchar != 'v') { pos_T save_cursor = curwin->w_cursor; #ifdef FEAT_EVAL if (cmdchar == 'R') ptr = (char_u *)"r"; else if (cmdchar == 'V') ptr = (char_u *)"v"; else ptr = (char_u *)"i"; set_vim_var_string(VV_INSERTMODE, ptr, 1); set_vim_var_string(VV_CHAR, NULL, -1); // clear v:char #endif ins_apply_autocmds(EVENT_INSERTENTER); // Check for changed highlighting, e.g. for ModeMsg. if (need_highlight_changed) highlight_changed(); // Make sure the cursor didn't move. Do call check_cursor_col() in // case the text was modified. Since Insert mode was not started yet // a call to check_cursor_col() may move the cursor, especially with // the "A" command, thus set State to avoid that. Also check that the // line number is still valid (lines may have been deleted). // Do not restore if v:char was set to a non-empty string. if (!EQUAL_POS(curwin->w_cursor, save_cursor) #ifdef FEAT_EVAL && *get_vim_var_str(VV_CHAR) == NUL #endif && save_cursor.lnum <= curbuf->b_ml.ml_line_count) { int save_state = State; curwin->w_cursor = save_cursor; State = MODE_INSERT; check_cursor_col(); State = save_state; } } #ifdef FEAT_CONCEAL // Check if the cursor line was concealed before changing State. cursor_line_was_concealed = curwin->w_p_cole > 0 && conceal_cursor_line(curwin); #endif /* * When doing a paste with the middle mouse button, Insstart is set to * where the paste started. */ if (where_paste_started.lnum != 0) Insstart = where_paste_started; else { Insstart = curwin->w_cursor; if (startln) Insstart.col = 0; } Insstart_textlen = (colnr_T)linetabsize(ml_get_curline()); Insstart_blank_vcol = MAXCOL; if (!did_ai) ai_col = 0; if (cmdchar != NUL && restart_edit == 0) { ResetRedobuff(); AppendNumberToRedobuff(count); if (cmdchar == 'V' || cmdchar == 'v') { // "gR" or "gr" command AppendCharToRedobuff('g'); AppendCharToRedobuff((cmdchar == 'v') ? 'r' : 'R'); } else { if (cmdchar == K_PS) AppendCharToRedobuff('a'); else AppendCharToRedobuff(cmdchar); if (cmdchar == 'g') // "gI" command AppendCharToRedobuff('I'); else if (cmdchar == 'r') // "r<CR>" command count = 1; // insert only one <CR> } } if (cmdchar == 'R') { State = MODE_REPLACE; } else if (cmdchar == 'V' || cmdchar == 'v') { State = MODE_VREPLACE; replaceState = MODE_VREPLACE; orig_line_count = curbuf->b_ml.ml_line_count; vr_lines_changed = 1; } else State = MODE_INSERT; may_trigger_modechanged(); stop_insert_mode = FALSE; #ifdef FEAT_CONCEAL // Check if the cursor line needs redrawing after changing State. If // 'concealcursor' is "n" it needs to be redrawn without concealing. conceal_check_cursor_line(cursor_line_was_concealed); #endif // Need to position cursor again when on a TAB and when on a char with // virtual text. if (gchar_cursor() == TAB #ifdef FEAT_PROP_POPUP || curbuf->b_has_textprop #endif ) curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL); /* * Enable langmap or IME, indicated by 'iminsert'. * Note that IME may enabled/disabled without us noticing here, thus the * 'iminsert' value may not reflect what is actually used. It is updated * when hitting <Esc>. */ if (curbuf->b_p_iminsert == B_IMODE_LMAP) State |= MODE_LANGMAP; #ifdef HAVE_INPUT_METHOD im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); #endif setmouse(); #ifdef FEAT_CMDL_INFO clear_showcmd(); #endif #ifdef FEAT_RIGHTLEFT // there is no reverse replace mode revins_on = (State == MODE_INSERT && p_ri); if (revins_on) undisplay_dollar(); revins_chars = 0; revins_legal = 0; revins_scol = -1; #endif if (!p_ek) { MAY_WANT_TO_LOG_THIS; // Disable bracketed paste mode, we won't recognize the escape // sequences. out_str(T_BD); // Disable modifyOtherKeys, keys with modifiers would cause exiting // Insert mode. out_str(T_CTE); } /* * Handle restarting Insert mode. * Don't do this for "CTRL-O ." (repeat an insert): In that case we get * here with something in the stuff buffer. */ if (restart_edit != 0 && stuff_empty()) { /* * After a paste we consider text typed to be part of the insert for * the pasted text. You can backspace over the pasted text too. */ if (where_paste_started.lnum) arrow_used = FALSE; else arrow_used = TRUE; restart_edit = 0; /* * If the cursor was after the end-of-line before the CTRL-O and it is * now at the end-of-line, put it after the end-of-line (this is not * correct in very rare cases). * Also do this if curswant is greater than the current virtual * column. Eg after "^O$" or "^O80|". */ validate_virtcol(); update_curswant(); if (((ins_at_eol && curwin->w_cursor.lnum == o_lnum) || curwin->w_curswant > curwin->w_virtcol) && *(ptr = ml_get_curline() + curwin->w_cursor.col) != NUL) { if (ptr[1] == NUL) ++curwin->w_cursor.col; else if (has_mbyte) { i = (*mb_ptr2len)(ptr); if (ptr[i] == NUL) curwin->w_cursor.col += i; } } ins_at_eol = FALSE; } else arrow_used = FALSE; // we are in insert mode now, don't need to start it anymore need_start_insertmode = FALSE; // Need to save the line for undo before inserting the first char. ins_need_undo = TRUE; where_paste_started.lnum = 0; can_cindent = TRUE; #ifdef FEAT_FOLDING // The cursor line is not in a closed fold, unless 'insertmode' is set or // restarting. if (!p_im && did_restart_edit == 0) foldOpenCursor(); #endif /* * If 'showmode' is set, show the current (insert/replace/..) mode. * A warning message for changing a readonly file is given here, before * actually changing anything. It's put after the mode, if any. */ i = 0; if (p_smd && msg_silent == 0) i = showmode(); if (!p_im && did_restart_edit == 0) change_warning(i == 0 ? 0 : i + 1); #ifdef CURSOR_SHAPE ui_cursor_shape(); // may show different cursor shape #endif #ifdef FEAT_DIGRAPHS do_digraph(-1); // clear digraphs #endif /* * Get the current length of the redo buffer, those characters have to be * skipped if we want to get to the inserted characters. */ ptr = get_inserted(); if (ptr == NULL) new_insert_skip = 0; else { new_insert_skip = (int)STRLEN(ptr); vim_free(ptr); } old_indent = 0; /* * Main loop in Insert mode: repeat until Insert mode is left. */ for (;;) { #ifdef FEAT_RIGHTLEFT if (!revins_legal) revins_scol = -1; // reset on illegal motions else revins_legal = 0; #endif if (arrow_used) // don't repeat insert when arrow key used count = 0; if (update_Insstart_orig) Insstart_orig = Insstart; if (stop_insert_mode && !ins_compl_active()) { // ":stopinsert" used or 'insertmode' reset count = 0; goto doESCkey; } // set curwin->w_curswant for next K_DOWN or K_UP if (!arrow_used) curwin->w_set_curswant = TRUE; // If there is no typeahead may check for timestamps (e.g., for when a // menu invoked a shell command). if (stuff_empty()) { did_check_timestamps = FALSE; if (need_check_timestamps) check_timestamps(FALSE); } /* * When emsg() was called msg_scroll will have been set. */ msg_scroll = FALSE; #ifdef FEAT_GUI // When 'mousefocus' is set a mouse movement may have taken us to // another window. "need_mouse_correct" may then be set because of an // autocommand. if (need_mouse_correct) gui_mouse_correct(); #endif #ifdef FEAT_FOLDING // Open fold at the cursor line, according to 'foldopen'. if (fdo_flags & FDO_INSERT) foldOpenCursor(); // Close folds where the cursor isn't, according to 'foldclose' if (!char_avail()) foldCheckClose(); #endif #ifdef FEAT_JOB_CHANNEL if (bt_prompt(curbuf)) { init_prompt(cmdchar_todo); cmdchar_todo = NUL; } #endif /* * If we inserted a character at the last position of the last line in * the window, scroll the window one line up. This avoids an extra * redraw. * This is detected when the cursor column is smaller after inserting * something. * Don't do this when the topline changed already, it has * already been adjusted (by insertchar() calling open_line())). */ if (curbuf->b_mod_set && curwin->w_p_wrap && !did_backspace && curwin->w_topline == old_topline #ifdef FEAT_DIFF && curwin->w_topfill == old_topfill #endif ) { mincol = curwin->w_wcol; validate_cursor_col(); if ( #ifdef FEAT_VARTABS curwin->w_wcol < mincol - tabstop_at( get_nolist_virtcol(), curbuf->b_p_ts, curbuf->b_p_vts_array) #else (int)curwin->w_wcol < mincol - curbuf->b_p_ts #endif && curwin->w_wrow == W_WINROW(curwin) + curwin->w_height - 1 - get_scrolloff_value() && (curwin->w_cursor.lnum != curwin->w_topline #ifdef FEAT_DIFF || curwin->w_topfill > 0 #endif )) { #ifdef FEAT_DIFF if (curwin->w_topfill > 0) --curwin->w_topfill; else #endif #ifdef FEAT_FOLDING if (hasFolding(curwin->w_topline, NULL, &old_topline)) set_topline(curwin, old_topline + 1); else #endif set_topline(curwin, curwin->w_topline + 1); } } // May need to adjust w_topline to show the cursor. update_topline(); did_backspace = FALSE; validate_cursor(); // may set must_redraw /* * Redraw the display when no characters are waiting. * Also shows mode, ruler and positions cursor. */ ins_redraw(TRUE); if (curwin->w_p_scb) do_check_scrollbind(TRUE); if (curwin->w_p_crb) do_check_cursorbind(); update_curswant(); old_topline = curwin->w_topline; #ifdef FEAT_DIFF old_topfill = curwin->w_topfill; #endif #ifdef USE_ON_FLY_SCROLL dont_scroll = FALSE; // allow scrolling here #endif /* * Get a character for Insert mode. Ignore K_IGNORE and K_NOP. */ if (c != K_CURSORHOLD) lastc = c; // remember the previous char for CTRL-D // After using CTRL-G U the next cursor key will not break undo. if (dont_sync_undo == MAYBE) dont_sync_undo = TRUE; else dont_sync_undo = FALSE; if (cmdchar == K_PS) // Got here from normal mode when bracketed paste started. c = K_PS; else do { c = safe_vgetc(); if (stop_insert_mode #ifdef FEAT_TERMINAL || (c == K_IGNORE && term_use_loop()) #endif ) { // Insert mode ended, possibly from a callback, or a timer // must have opened a terminal window. if (c != K_IGNORE && c != K_NOP) vungetc(c); count = 0; nomove = TRUE; ins_compl_prep(ESC); goto doESCkey; } } while (c == K_IGNORE || c == K_NOP); // Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. did_cursorhold = TRUE; #ifdef FEAT_RIGHTLEFT if (p_hkmap && KeyTyped) c = hkmap(c); // Hebrew mode mapping #endif // If the window was made so small that nothing shows, make it at least // one line and one column when typing. if (KeyTyped && !KeyStuffed) win_ensure_size(); /* * Special handling of keys while the popup menu is visible or wanted * and the cursor is still in the completed word. Only when there is * a match, skip this when no matches were found. */ if (ins_compl_active() && pum_wanted() && curwin->w_cursor.col >= ins_compl_col() && ins_compl_has_shown_match()) { // BS: Delete one character from "compl_leader". if ((c == K_BS || c == Ctrl_H) && curwin->w_cursor.col > ins_compl_col() && (c = ins_compl_bs()) == NUL) continue; // When no match was selected or it was edited. if (!ins_compl_used_match()) { // CTRL-L: Add one character from the current match to // "compl_leader". Except when at the original match and // there is nothing to add, CTRL-L works like CTRL-P then. if (c == Ctrl_L && (!ctrl_x_mode_line_or_eval() || ins_compl_long_shown_match())) { ins_compl_addfrommatch(); continue; } // A non-white character that fits in with the current // completion: Add to "compl_leader". if (ins_compl_accept_char(c)) { #if defined(FEAT_EVAL) // Trigger InsertCharPre. char_u *str = do_insert_char_pre(c); char_u *p; if (str != NULL) { for (p = str; *p != NUL; MB_PTR_ADV(p)) ins_compl_addleader(PTR2CHAR(p)); vim_free(str); } else #endif ins_compl_addleader(c); continue; } // Pressing CTRL-Y selects the current match. When // ins_compl_enter_selects() is set the Enter key does the // same. if ((c == Ctrl_Y || (ins_compl_enter_selects() && (c == CAR || c == K_KENTER || c == NL))) && stop_arrow() == OK) { ins_compl_delete(); ins_compl_insert(FALSE); } } } // Prepare for or stop CTRL-X mode. This doesn't do completion, but // it does fix up the text when finishing completion. ins_compl_init_get_longest(); if (ins_compl_prep(c)) continue; // CTRL-\ CTRL-N goes to Normal mode, // CTRL-\ CTRL-G goes to mode selected with 'insertmode', // CTRL-\ CTRL-O is like CTRL-O but without moving the cursor. if (c == Ctrl_BSL) { // may need to redraw when no more chars available now ins_redraw(FALSE); ++no_mapping; ++allow_keys; c = plain_vgetc(); --no_mapping; --allow_keys; if (c != Ctrl_N && c != Ctrl_G && c != Ctrl_O) { // it's something else vungetc(c); c = Ctrl_BSL; } else if (c == Ctrl_G && p_im) continue; else { if (c == Ctrl_O) { ins_ctrl_o(); ins_at_eol = FALSE; // cursor keeps its column nomove = TRUE; } count = 0; goto doESCkey; } } #ifdef FEAT_DIGRAPHS c = do_digraph(c); #endif if ((c == Ctrl_V || c == Ctrl_Q) && ctrl_x_mode_cmdline()) goto docomplete; if (c == Ctrl_V || c == Ctrl_Q) { ins_ctrl_v(); c = Ctrl_V; // pretend CTRL-V is last typed character continue; } if (cindent_on() && ctrl_x_mode_none()) { // A key name preceded by a bang means this key is not to be // inserted. Skip ahead to the re-indenting below. // A key name preceded by a star means that indenting has to be // done before inserting the key. line_is_white = inindent(0); if (in_cinkeys(c, '!', line_is_white)) goto force_cindent; if (can_cindent && in_cinkeys(c, '*', line_is_white) && stop_arrow() == OK) do_c_expr_indent(); } #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) switch (c) { case K_LEFT: c = K_RIGHT; break; case K_S_LEFT: c = K_S_RIGHT; break; case K_C_LEFT: c = K_C_RIGHT; break; case K_RIGHT: c = K_LEFT; break; case K_S_RIGHT: c = K_S_LEFT; break; case K_C_RIGHT: c = K_C_LEFT; break; } #endif /* * If 'keymodel' contains "startsel", may start selection. If it * does, a CTRL-O and c will be stuffed, we need to get these * characters. */ if (ins_start_select(c)) continue; /* * The big switch to handle a character in insert mode. */ switch (c) { case ESC: // End input mode if (echeck_abbr(ESC + ABBR_OFF)) break; // FALLTHROUGH case Ctrl_C: // End input mode #ifdef FEAT_CMDWIN if (c == Ctrl_C && cmdwin_type != 0) { // Close the cmdline window. cmdwin_result = K_IGNORE; got_int = FALSE; // don't stop executing autocommands et al. nomove = TRUE; goto doESCkey; } #endif #ifdef FEAT_JOB_CHANNEL if (c == Ctrl_C && bt_prompt(curbuf)) { if (invoke_prompt_interrupt()) { if (!bt_prompt(curbuf)) // buffer changed to a non-prompt buffer, get out of // Insert mode goto doESCkey; break; } } #endif #ifdef UNIX do_intr: #endif // when 'insertmode' set, and not halfway a mapping, don't leave // Insert mode if (goto_im()) { if (got_int) { (void)vgetc(); // flush all buffers got_int = FALSE; } else vim_beep(BO_IM); break; } doESCkey: /* * This is the ONLY return from edit()! */ // Always update o_lnum, so that a "CTRL-O ." that adds a line // still puts the cursor back after the inserted text. if (ins_at_eol && gchar_cursor() == NUL) o_lnum = curwin->w_cursor.lnum; if (ins_esc(&count, cmdchar, nomove)) { // When CTRL-C was typed got_int will be set, with the result // that the autocommands won't be executed. When mapped got_int // is not set, but let's keep the behavior the same. if (cmdchar != 'r' && cmdchar != 'v' && c != Ctrl_C) ins_apply_autocmds(EVENT_INSERTLEAVE); did_cursorhold = FALSE; return (c == Ctrl_O); } continue; case Ctrl_Z: // suspend when 'insertmode' set if (!p_im) goto normalchar; // insert CTRL-Z as normal char do_cmdline_cmd((char_u *)"stop"); #ifdef CURSOR_SHAPE ui_cursor_shape(); // may need to update cursor shape #endif continue; case Ctrl_O: // execute one command #ifdef FEAT_COMPL_FUNC if (ctrl_x_mode_omni()) goto docomplete; #endif if (echeck_abbr(Ctrl_O + ABBR_OFF)) break; ins_ctrl_o(); // don't move the cursor left when 'virtualedit' has "onemore". if (get_ve_flags() & VE_ONEMORE) { ins_at_eol = FALSE; nomove = TRUE; } count = 0; goto doESCkey; case K_INS: // toggle insert/replace mode case K_KINS: ins_insert(replaceState); break; case K_SELECT: // end of Select mode mapping - ignore break; case K_HELP: // Help key works like <ESC> <Help> case K_F1: case K_XF1: stuffcharReadbuff(K_HELP); if (p_im) need_start_insertmode = TRUE; goto doESCkey; #ifdef FEAT_NETBEANS_INTG case K_F21: // NetBeans command ++no_mapping; // don't map the next key hits i = plain_vgetc(); --no_mapping; netbeans_keycommand(i); break; #endif case K_ZERO: // Insert the previously inserted text. case NUL: case Ctrl_A: // For ^@ the trailing ESC will end the insert, unless there is an // error. if (stuff_inserted(NUL, 1L, (c == Ctrl_A)) == FAIL && c != Ctrl_A && !p_im) goto doESCkey; // quit insert mode inserted_space = FALSE; break; case Ctrl_R: // insert the contents of a register ins_reg(); auto_format(FALSE, TRUE); inserted_space = FALSE; break; case Ctrl_G: // commands starting with CTRL-G ins_ctrl_g(); break; case Ctrl_HAT: // switch input mode and/or langmap ins_ctrl_hat(); break; #ifdef FEAT_RIGHTLEFT case Ctrl__: // switch between languages if (!p_ari) goto normalchar; ins_ctrl_(); break; #endif case Ctrl_D: // Make indent one shiftwidth smaller. #if defined(FEAT_FIND_ID) if (ctrl_x_mode_path_defines()) goto docomplete; #endif // FALLTHROUGH case Ctrl_T: // Make indent one shiftwidth greater. if (c == Ctrl_T && ctrl_x_mode_thesaurus()) { if (has_compl_option(FALSE)) goto docomplete; break; } ins_shift(c, lastc); auto_format(FALSE, TRUE); inserted_space = FALSE; break; case K_DEL: // delete character under the cursor case K_KDEL: ins_del(); auto_format(FALSE, TRUE); break; case K_BS: // delete character before the cursor case K_S_BS: case Ctrl_H: did_backspace = ins_bs(c, BACKSPACE_CHAR, &inserted_space); auto_format(FALSE, TRUE); break; case Ctrl_W: // delete word before the cursor #ifdef FEAT_JOB_CHANNEL if (bt_prompt(curbuf) && (mod_mask & MOD_MASK_SHIFT) == 0) { // In a prompt window CTRL-W is used for window commands. // Use Shift-CTRL-W to delete a word. stuffcharReadbuff(Ctrl_W); restart_edit = 'A'; nomove = TRUE; count = 0; goto doESCkey; } #endif did_backspace = ins_bs(c, BACKSPACE_WORD, &inserted_space); auto_format(FALSE, TRUE); break; case Ctrl_U: // delete all inserted text in current line # ifdef FEAT_COMPL_FUNC // CTRL-X CTRL-U completes with 'completefunc'. if (ctrl_x_mode_function()) goto docomplete; # endif did_backspace = ins_bs(c, BACKSPACE_LINE, &inserted_space); auto_format(FALSE, TRUE); inserted_space = FALSE; break; case K_LEFTMOUSE: // mouse keys case K_LEFTMOUSE_NM: case K_LEFTDRAG: case K_LEFTRELEASE: case K_LEFTRELEASE_NM: case K_MOUSEMOVE: case K_MIDDLEMOUSE: case K_MIDDLEDRAG: case K_MIDDLERELEASE: case K_RIGHTMOUSE: case K_RIGHTDRAG: case K_RIGHTRELEASE: case K_X1MOUSE: case K_X1DRAG: case K_X1RELEASE: case K_X2MOUSE: case K_X2DRAG: case K_X2RELEASE: ins_mouse(c); break; case K_MOUSEDOWN: // Default action for scroll wheel up: scroll up ins_mousescroll(MSCR_DOWN); break; case K_MOUSEUP: // Default action for scroll wheel down: scroll down ins_mousescroll(MSCR_UP); break; case K_MOUSELEFT: // Scroll wheel left ins_mousescroll(MSCR_LEFT); break; case K_MOUSERIGHT: // Scroll wheel right ins_mousescroll(MSCR_RIGHT); break; case K_PS: bracketed_paste(PASTE_INSERT, FALSE, NULL); if (cmdchar == K_PS) // invoked from normal mode, bail out goto doESCkey; break; case K_PE: // Got K_PE without K_PS, ignore. break; #ifdef FEAT_GUI_TABLINE case K_TABLINE: case K_TABMENU: ins_tabline(c); break; #endif case K_IGNORE: // Something mapped to nothing break; case K_COMMAND: // <Cmd>command<CR> case K_SCRIPT_COMMAND: // <ScriptCmd>command<CR> do_cmdkey_command(c, 0); #ifdef FEAT_TERMINAL if (term_use_loop()) // Started a terminal that gets the input, exit Insert mode. goto doESCkey; #endif break; case K_CURSORHOLD: // Didn't type something for a while. ins_apply_autocmds(EVENT_CURSORHOLDI); did_cursorhold = TRUE; // If CTRL-G U was used apply it to the next typed key. if (dont_sync_undo == TRUE) dont_sync_undo = MAYBE; break; #ifdef FEAT_GUI_MSWIN // On MS-Windows ignore <M-F4>, we get it when closing the window // was cancelled. case K_F4: if (mod_mask != MOD_MASK_ALT) goto normalchar; break; #endif #ifdef FEAT_GUI case K_VER_SCROLLBAR: ins_scroll(); break; case K_HOR_SCROLLBAR: ins_horscroll(); break; #endif case K_HOME: // <Home> case K_KHOME: case K_S_HOME: case K_C_HOME: ins_home(c); break; case K_END: // <End> case K_KEND: case K_S_END: case K_C_END: ins_end(c); break; case K_LEFT: // <Left> if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) ins_s_left(); else ins_left(); break; case K_S_LEFT: // <S-Left> case K_C_LEFT: ins_s_left(); break; case K_RIGHT: // <Right> if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) ins_s_right(); else ins_right(); break; case K_S_RIGHT: // <S-Right> case K_C_RIGHT: ins_s_right(); break; case K_UP: // <Up> if (pum_visible()) goto docomplete; if (mod_mask & MOD_MASK_SHIFT) ins_pageup(); else ins_up(FALSE); break; case K_S_UP: // <S-Up> case K_PAGEUP: case K_KPAGEUP: if (pum_visible()) goto docomplete; ins_pageup(); break; case K_DOWN: // <Down> if (pum_visible()) goto docomplete; if (mod_mask & MOD_MASK_SHIFT) ins_pagedown(); else ins_down(FALSE); break; case K_S_DOWN: // <S-Down> case K_PAGEDOWN: case K_KPAGEDOWN: if (pum_visible()) goto docomplete; ins_pagedown(); break; #ifdef FEAT_DND case K_DROP: // drag-n-drop event ins_drop(); break; #endif case K_S_TAB: // When not mapped, use like a normal TAB c = TAB; // FALLTHROUGH case TAB: // TAB or Complete patterns along path #if defined(FEAT_FIND_ID) if (ctrl_x_mode_path_patterns()) goto docomplete; #endif inserted_space = FALSE; if (ins_tab()) goto normalchar; // insert TAB as a normal char auto_format(FALSE, TRUE); break; case K_KENTER: // <Enter> c = CAR; // FALLTHROUGH case CAR: case NL: #if defined(FEAT_QUICKFIX) // In a quickfix window a <CR> jumps to the error under the // cursor. if (bt_quickfix(curbuf) && c == CAR) { if (curwin->w_llist_ref == NULL) // quickfix window do_cmdline_cmd((char_u *)".cc"); else // location list window do_cmdline_cmd((char_u *)".ll"); break; } #endif #ifdef FEAT_CMDWIN if (cmdwin_type != 0) { // Execute the command in the cmdline window. cmdwin_result = CAR; goto doESCkey; } #endif #ifdef FEAT_JOB_CHANNEL if (bt_prompt(curbuf)) { invoke_prompt_callback(); if (!bt_prompt(curbuf)) // buffer changed to a non-prompt buffer, get out of // Insert mode goto doESCkey; break; } #endif if (ins_eol(c) == FAIL && !p_im) goto doESCkey; // out of memory auto_format(FALSE, FALSE); inserted_space = FALSE; break; case Ctrl_K: // digraph or keyword completion if (ctrl_x_mode_dictionary()) { if (has_compl_option(TRUE)) goto docomplete; break; } #ifdef FEAT_DIGRAPHS c = ins_digraph(); if (c == NUL) break; #endif goto normalchar; case Ctrl_X: // Enter CTRL-X mode ins_ctrl_x(); break; case Ctrl_RSB: // Tag name completion after ^X if (!ctrl_x_mode_tags()) goto normalchar; goto docomplete; case Ctrl_F: // File name completion after ^X if (!ctrl_x_mode_files()) goto normalchar; goto docomplete; case 's': // Spelling completion after ^X case Ctrl_S: if (!ctrl_x_mode_spell()) goto normalchar; goto docomplete; case Ctrl_L: // Whole line completion after ^X if (!ctrl_x_mode_whole_line()) { // CTRL-L with 'insertmode' set: Leave Insert mode if (p_im) { if (echeck_abbr(Ctrl_L + ABBR_OFF)) break; goto doESCkey; } goto normalchar; } // FALLTHROUGH case Ctrl_P: // Do previous/next pattern completion case Ctrl_N: // if 'complete' is empty then plain ^P is no longer special, // but it is under other ^X modes if (*curbuf->b_p_cpt == NUL && (ctrl_x_mode_normal() || ctrl_x_mode_whole_line()) && !compl_status_local()) goto normalchar; docomplete: compl_busy = TRUE; #ifdef FEAT_FOLDING disable_fold_update++; // don't redraw folds here #endif if (ins_complete(c, TRUE) == FAIL) compl_status_clear(); #ifdef FEAT_FOLDING disable_fold_update--; #endif compl_busy = FALSE; can_si = may_do_si(); // allow smartindenting break; case Ctrl_Y: // copy from previous line or scroll down case Ctrl_E: // copy from next line or scroll up c = ins_ctrl_ey(c); break; default: #ifdef UNIX if (c == intr_char) // special interrupt char goto do_intr; #endif normalchar: /* * Insert a normal character. */ #if defined(FEAT_EVAL) if (!p_paste) { // Trigger InsertCharPre. char_u *str = do_insert_char_pre(c); char_u *p; if (str != NULL) { if (*str != NUL && stop_arrow() != FAIL) { // Insert the new value of v:char literally. for (p = str; *p != NUL; MB_PTR_ADV(p)) { c = PTR2CHAR(p); if (c == CAR || c == K_KENTER || c == NL) ins_eol(c); else ins_char(c); } AppendToRedobuffLit(str, -1); } vim_free(str); c = NUL; } // If the new value is already inserted or an empty string // then don't insert any character. if (c == NUL) break; } #endif // Try to perform smart-indenting. ins_try_si(c); if (c == ' ') { inserted_space = TRUE; if (inindent(0)) can_cindent = FALSE; if (Insstart_blank_vcol == MAXCOL && curwin->w_cursor.lnum == Insstart.lnum) Insstart_blank_vcol = get_nolist_virtcol(); } // Insert a normal character and check for abbreviations on a // special character. Let CTRL-] expand abbreviations without // inserting it. if (vim_iswordc(c) || (!echeck_abbr( // Add ABBR_OFF for characters above 0x100, this is // what check_abbr() expects. (has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : c) && c != Ctrl_RSB)) { insert_special(c, FALSE, FALSE); #ifdef FEAT_RIGHTLEFT revins_legal++; revins_chars++; #endif } auto_format(FALSE, TRUE); #ifdef FEAT_FOLDING // When inserting a character the cursor line must never be in a // closed fold. foldOpenCursor(); #endif break; } // end of switch (c) // If typed something may trigger CursorHoldI again. if (c != K_CURSORHOLD #ifdef FEAT_COMPL_FUNC // but not in CTRL-X mode, a script can't restore the state && ctrl_x_mode_normal() #endif ) did_cursorhold = FALSE; // If the cursor was moved we didn't just insert a space if (arrow_used) inserted_space = FALSE; if (can_cindent && cindent_on() && ctrl_x_mode_normal()) { force_cindent: /* * Indent now if a key was typed that is in 'cinkeys'. */ if (in_cinkeys(c, ' ', line_is_white)) { if (stop_arrow() == OK) // re-indent the current line do_c_expr_indent(); } } } // for (;;) // NOTREACHED }
0
411,790
on_name_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { g_bus_watch_name (G_BUS_TYPE_SESSION, "org.gnome.SessionManager", G_BUS_NAME_WATCHER_FLAGS_NONE, name_appeared_handler, NULL, user_data, NULL); }
0
336,511
void reds_unregister_channel(RedsState *reds, RedChannel *channel) { reds->channels.remove(red::shared_ptr<RedChannel>(channel)); }
0
226,304
GF_Err gitn_box_read(GF_Box *s, GF_BitStream *bs) { u32 i; GF_Err e; GroupIdToNameBox *ptr = (GroupIdToNameBox *)s; ISOM_DECREASE_SIZE(ptr, 2); ptr->nb_entries = gf_bs_read_u16(bs); if (ptr->size / 4 < ptr->nb_entries) return GF_ISOM_INVALID_FILE; GF_SAFE_ALLOC_N(ptr->entries, ptr->nb_entries, GroupIdNameEntry); if (!ptr->entries) return GF_OUT_OF_MEM; for (i=0; i<ptr->nb_entries; i++) { ISOM_DECREASE_SIZE(ptr, 4); ptr->entries[i].group_id = gf_bs_read_u32(bs); e = gf_isom_read_null_terminated_string(s, bs, ptr->size, &ptr->entries[i].name); if (e) return e; } return GF_OK;
0
404,736
static inline unsigned last_fd(struct fdtable *fdt) { return fdt->max_fds - 1; }
0
310,199
reset_scroll_region(NCURSES_SP_DCL0) /* Set the scroll-region to a known state (the default) */ { if (change_scroll_region) { NCURSES_PUTP2("change_scroll_region", TIPARM_2(change_scroll_region, 0, screen_lines(SP_PARM) - 1)); } }
0
234,212
init_dwarf_regnames_iamcu (void) { dwarf_regnames = dwarf_regnames_iamcu; dwarf_regnames_count = ARRAY_SIZE (dwarf_regnames_iamcu); dwarf_regnames_lookup_func = regname_internal_by_table_only; }
0