idx
int64 | func
string | target
int64 |
|---|---|---|
413,680
|
static char *is_string_at(RCore *core, ut64 addr, int *olen) {
ut8 rstr[128] = {0};
int ret = 0, len = 0;
ut8 *str = calloc (256, 1);
if (!str) {
if (olen) {
*olen = 0;
}
return NULL;
}
r_io_read_at (core->io, addr, str, 255);
str[255] = 0;
if (is_string (str, 256, &len)) {
if (olen) {
*olen = len;
}
return (char*) str;
}
ut64 *cstr = (ut64*)str;
ut64 lowptr = cstr[0];
if (lowptr >> 32) { // must be pa mode only
lowptr &= UT32_MAX;
}
// cstring
if (cstr[0] == 0 && cstr[1] < 0x1000) {
ut64 ptr = cstr[2];
if (ptr >> 32) { // must be pa mode only
ptr &= UT32_MAX;
}
if (ptr) {
r_io_read_at (core->io, ptr, rstr, sizeof (rstr));
rstr[127] = 0;
ret = is_string (rstr, 128, &len);
if (ret) {
strcpy ((char*) str, (char*) rstr);
if (olen) {
*olen = len;
}
return (char*) str;
}
}
} else {
// pstring
r_io_read_at (core->io, lowptr, rstr, sizeof (rstr));
rstr[127] = 0;
ret = is_string (rstr, sizeof (rstr), &len);
if (ret) {
strcpy ((char*) str, (char*) rstr);
if (olen) {
*olen = len;
}
return (char*) str;
}
}
// check if current section have no exec bit
if (len < 1) {
ret = 0;
free (str);
len = -1;
} else if (olen) {
*olen = len;
}
// NOTE: coverity says that ret is always 0 here, so str is dead code
return ret? (char *)str: NULL;
}
| 0
|
483,513
|
static __init int match_config_table(efi_guid_t *guid,
unsigned long table,
efi_config_table_type_t *table_types)
{
int i;
if (table_types) {
for (i = 0; efi_guidcmp(table_types[i].guid, NULL_GUID); i++) {
if (!efi_guidcmp(*guid, table_types[i].guid)) {
*(table_types[i].ptr) = table;
if (table_types[i].name)
pr_cont(" %s=0x%lx ",
table_types[i].name, table);
return 1;
}
}
}
return 0;
}
| 0
|
238,420
|
static bool is_cmpxchg_insn(const struct bpf_insn *insn)
{
return BPF_CLASS(insn->code) == BPF_STX &&
BPF_MODE(insn->code) == BPF_ATOMIC &&
insn->imm == BPF_CMPXCHG;
}
| 0
|
512,386
|
bool Item_func_case_simple::prepare_predicant_and_values(THD *thd,
uint *found_types,
bool nulls_equal)
{
bool have_null= false;
uint type_cnt;
Type_handler_hybrid_field_type tmp;
uint ncases= when_count();
add_predicant(this, 0);
for (uint i= 0 ; i < ncases; i++)
{
if (nulls_equal ?
add_value("case..when", this, i + 1) :
add_value_skip_null("case..when", this, i + 1, &have_null))
return true;
}
all_values_added(&tmp, &type_cnt, &m_found_types);
#ifndef DBUG_OFF
Predicant_to_list_comparator::debug_print(thd);
#endif
return false;
}
| 0
|
264,282
|
static void vnc_colordepth(VncState *vs)
{
if (vnc_has_feature(vs, VNC_FEATURE_WMVI)) {
/* Sending a WMVi message to notify the client*/
vnc_lock_output(vs);
vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE);
vnc_write_u8(vs, 0);
vnc_write_u16(vs, 1); /* number of rects */
vnc_framebuffer_update(vs, 0, 0,
surface_width(vs->vd->ds),
surface_height(vs->vd->ds),
VNC_ENCODING_WMVi);
pixel_format_message(vs);
vnc_unlock_output(vs);
vnc_flush(vs);
} else {
set_pixel_conversion(vs);
}
}
| 0
|
436,128
|
static int io_sq_thread(void *data)
{
struct io_sq_data *sqd = data;
struct io_ring_ctx *ctx;
unsigned long timeout = 0;
char buf[TASK_COMM_LEN];
DEFINE_WAIT(wait);
snprintf(buf, sizeof(buf), "iou-sqp-%d", sqd->task_pid);
set_task_comm(current, buf);
if (sqd->sq_cpu != -1)
set_cpus_allowed_ptr(current, cpumask_of(sqd->sq_cpu));
else
set_cpus_allowed_ptr(current, cpu_online_mask);
current->flags |= PF_NO_SETAFFINITY;
mutex_lock(&sqd->lock);
while (1) {
bool cap_entries, sqt_spin = false;
if (io_sqd_events_pending(sqd) || signal_pending(current)) {
if (io_sqd_handle_event(sqd))
break;
timeout = jiffies + sqd->sq_thread_idle;
}
cap_entries = !list_is_singular(&sqd->ctx_list);
list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {
int ret = __io_sq_thread(ctx, cap_entries);
if (!sqt_spin && (ret > 0 || !list_empty(&ctx->iopoll_list)))
sqt_spin = true;
}
if (io_run_task_work())
sqt_spin = true;
if (sqt_spin || !time_after(jiffies, timeout)) {
cond_resched();
if (sqt_spin)
timeout = jiffies + sqd->sq_thread_idle;
continue;
}
prepare_to_wait(&sqd->wait, &wait, TASK_INTERRUPTIBLE);
if (!io_sqd_events_pending(sqd) && !current->task_works) {
bool needs_sched = true;
list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {
io_ring_set_wakeup_flag(ctx);
if ((ctx->flags & IORING_SETUP_IOPOLL) &&
!list_empty_careful(&ctx->iopoll_list)) {
needs_sched = false;
break;
}
if (io_sqring_entries(ctx)) {
needs_sched = false;
break;
}
}
if (needs_sched) {
mutex_unlock(&sqd->lock);
schedule();
mutex_lock(&sqd->lock);
}
list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
io_ring_clear_wakeup_flag(ctx);
}
finish_wait(&sqd->wait, &wait);
timeout = jiffies + sqd->sq_thread_idle;
}
io_uring_cancel_generic(true, sqd);
sqd->thread = NULL;
list_for_each_entry(ctx, &sqd->ctx_list, sqd_list)
io_ring_set_wakeup_flag(ctx);
io_run_task_work();
mutex_unlock(&sqd->lock);
complete(&sqd->exited);
do_exit(0);
| 0
|
264,696
|
lexer_construct_literal_object (parser_context_t *context_p, /**< context */
const lexer_lit_location_t *lit_location_p, /**< literal location */
uint8_t literal_type) /**< final literal type */
{
uint8_t local_byte_array[LEXER_MAX_LITERAL_LOCAL_BUFFER_SIZE];
const uint8_t *char_p =
lexer_convert_literal_to_chars (context_p, lit_location_p, local_byte_array, LEXER_STRING_NO_OPTS);
size_t length = lit_location_p->length;
parser_list_iterator_t literal_iterator;
lexer_literal_t *literal_p;
uint32_t literal_index = 0;
bool search_scope_stack = (literal_type == LEXER_IDENT_LITERAL);
if (JERRY_UNLIKELY (literal_type == LEXER_NEW_IDENT_LITERAL))
{
literal_type = LEXER_IDENT_LITERAL;
}
JERRY_ASSERT (literal_type == LEXER_IDENT_LITERAL || literal_type == LEXER_STRING_LITERAL);
JERRY_ASSERT (literal_type != LEXER_IDENT_LITERAL || length <= PARSER_MAXIMUM_IDENT_LENGTH);
JERRY_ASSERT (literal_type != LEXER_STRING_LITERAL || length <= PARSER_MAXIMUM_STRING_LENGTH);
parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
while ((literal_p = (lexer_literal_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
{
if (literal_p->type == literal_type && literal_p->prop.length == length
&& memcmp (literal_p->u.char_p, char_p, length) == 0)
{
context_p->lit_object.literal_p = literal_p;
context_p->lit_object.index = (uint16_t) literal_index;
parser_free_allocated_buffer (context_p);
if (search_scope_stack)
{
parser_scope_stack_t *scope_stack_start_p = context_p->scope_stack_p;
parser_scope_stack_t *scope_stack_p = scope_stack_start_p + context_p->scope_stack_top;
while (scope_stack_p > scope_stack_start_p)
{
scope_stack_p--;
if (scope_stack_p->map_from == literal_index)
{
JERRY_ASSERT (scanner_decode_map_to (scope_stack_p) >= PARSER_REGISTER_START
|| (literal_p->status_flags & LEXER_FLAG_USED));
context_p->lit_object.index = scanner_decode_map_to (scope_stack_p);
return;
}
}
literal_p->status_flags |= LEXER_FLAG_USED;
}
return;
}
literal_index++;
}
JERRY_ASSERT (literal_index == context_p->literal_count);
if (literal_index >= PARSER_MAXIMUM_NUMBER_OF_LITERALS)
{
parser_raise_error (context_p, PARSER_ERR_LITERAL_LIMIT_REACHED);
}
literal_p = (lexer_literal_t *) parser_list_append (context_p, &context_p->literal_pool);
literal_p->prop.length = (prop_length_t) length;
literal_p->type = literal_type;
uint8_t status_flags = LEXER_FLAG_SOURCE_PTR;
if (length > 0 && char_p == local_byte_array)
{
literal_p->u.char_p = (uint8_t *) jmem_heap_alloc_block (length);
memcpy ((uint8_t *) literal_p->u.char_p, char_p, length);
status_flags = 0;
}
else
{
literal_p->u.char_p = char_p;
/* Buffer is taken over when a new literal is constructed. */
if (context_p->u.allocated_buffer_p != NULL)
{
JERRY_ASSERT (char_p == context_p->u.allocated_buffer_p);
context_p->u.allocated_buffer_p = NULL;
status_flags = 0;
}
}
if (search_scope_stack)
{
status_flags |= LEXER_FLAG_USED;
}
if (lit_location_p->status_flags & LEXER_LIT_LOCATION_IS_ASCII)
{
literal_p->status_flags |= LEXER_FLAG_ASCII;
}
literal_p->status_flags = status_flags;
context_p->lit_object.literal_p = literal_p;
context_p->lit_object.index = (uint16_t) literal_index;
context_p->literal_count++;
JERRY_ASSERT (context_p->u.allocated_buffer_p == NULL);
} /* lexer_construct_literal_object */
| 0
|
301,475
|
soundfold_find(slang_T *slang, char_u *word)
{
idx_T arridx = 0;
int len;
int wlen = 0;
int c;
char_u *ptr = word;
char_u *byts;
idx_T *idxs;
int wordnr = 0;
byts = slang->sl_sbyts;
idxs = slang->sl_sidxs;
for (;;)
{
// First byte is the number of possible bytes.
len = byts[arridx++];
// If the first possible byte is a zero the word could end here.
// If the word ends we found the word. If not skip the NUL bytes.
c = ptr[wlen];
if (byts[arridx] == NUL)
{
if (c == NUL)
break;
// Skip over the zeros, there can be several.
while (len > 0 && byts[arridx] == NUL)
{
++arridx;
--len;
}
if (len == 0)
return -1; // no children, word should have ended here
++wordnr;
}
// If the word ends we didn't find it.
if (c == NUL)
return -1;
// Perform a binary search in the list of accepted bytes.
if (c == TAB) // <Tab> is handled like <Space>
c = ' ';
while (byts[arridx] < c)
{
// The word count is in the first idxs[] entry of the child.
wordnr += idxs[idxs[arridx]];
++arridx;
if (--len == 0) // end of the bytes, didn't find it
return -1;
}
if (byts[arridx] != c) // didn't find the byte
return -1;
// Continue at the child (if there is one).
arridx = idxs[arridx];
++wlen;
// One space in the good word may stand for several spaces in the
// checked word.
if (c == ' ')
while (ptr[wlen] == ' ' || ptr[wlen] == TAB)
++wlen;
}
return wordnr;
}
| 0
|
219,931
|
Status ConstantFolding::EvaluateOneFoldable(const NodeDef& node,
std::vector<NodeDef>* outputs,
bool* result_too_large) {
TensorVector inputs;
TensorVector output_tensors;
auto inputs_cleanup = gtl::MakeCleanup([&inputs, &output_tensors] {
for (const auto& input : inputs) {
delete input.tensor;
}
for (const auto& output : output_tensors) {
if (output.tensor) {
delete output.tensor;
}
}
});
size_t total_inputs_size = 0;
for (const auto& input : node.input()) {
const TensorId input_tensor = ParseTensorName(input);
if (input_tensor.index() < 0) {
// Control dependency
break;
}
const NodeDef* input_node = node_map_->GetNode(input);
if (!IsReallyConstant(*input_node)) {
return Status(error::INVALID_ARGUMENT,
strings::StrCat("Can't fold ", node.name(), ", its ", input,
" isn't constant"));
}
TF_RETURN_IF_ERROR(CheckAttrExists(*input_node, "value"));
const TensorProto& raw_val = input_node->attr().at("value").tensor();
if (raw_val.dtype() == DT_INVALID) {
return Status(
error::INVALID_ARGUMENT,
strings::StrCat("A tensor in the input node, with TensorId of ",
input_tensor.ToString(),
" has a dtype of DT_INVALID."));
}
if (IsRefType(raw_val.dtype())) {
return errors::InvalidArgument(
"Not allowed to construct a tensor with reference dtype, got ",
DataTypeString(raw_val.dtype()));
}
Tensor* value = new Tensor(raw_val.dtype(), raw_val.tensor_shape());
if (!value->FromProto(raw_val)) {
delete (value);
return errors::InvalidArgument("Unable to make Tensor from proto for ",
node.name(), " with shape ",
raw_val.tensor_shape().DebugString());
}
inputs.emplace_back(value);
total_inputs_size += value->TotalBytes();
}
TF_RETURN_IF_ERROR(EvaluateNode(node, inputs, &output_tensors));
if (output_tensors.empty()) {
return Status(error::INVALID_ARGUMENT, "Expected at least one output.");
}
outputs->resize(output_tensors.size());
for (size_t i = 0; i < output_tensors.size(); i++) {
string node_name = OptimizedNodeName(node, "-folded");
if (output_tensors.size() > 1) {
node_name = strings::StrCat(node_name, "-", i);
}
if (output_tensors[i].tensor) {
Status s = CreateNodeDef(node_name, output_tensors[i], &outputs->at(i),
total_inputs_size);
if (!s.ok()) {
*result_too_large = true;
return s;
}
} else {
// Create an empty NodeDef to identify dead outputs (e.g. the output of a
// switch that's not selected by the switch predicate).
outputs->at(i) = NodeDef();
}
}
return Status::OK();
}
| 0
|
369,112
|
static void io_req_task_queue_fail(struct io_kiocb *req, int ret)
{
req->result = ret;
req->io_task_work.func = io_req_task_cancel;
io_req_task_work_add(req, false);
}
| 0
|
450,816
|
convert_dirent (const struct dirent *source)
{
if (source == NULL)
{
struct readdir_result result = { NULL, };
return result;
}
struct readdir_result result = READDIR_RESULT_INITIALIZER (source);
return result;
}
| 0
|
371,181
|
static pyc_object *get_dict_object(RzBinPycObj *pyc, RzBuffer *buffer) {
pyc_object *ret = NULL,
*key = NULL,
*val = NULL;
ret = RZ_NEW0(pyc_object);
if (!ret) {
return NULL;
}
ret->data = rz_list_newf((RzListFree)free_object);
if (!ret->data) {
RZ_FREE(ret);
return NULL;
}
for (;;) {
key = get_object(pyc, buffer);
if (!key) {
break;
}
if (!rz_list_append(ret->data, key)) {
rz_list_free(ret->data);
RZ_FREE(ret);
free_object(key);
return NULL;
}
val = get_object(pyc, buffer);
if (!val) {
break;
}
if (!rz_list_append(ret->data, val)) {
rz_list_free(ret->data);
RZ_FREE(ret);
free_object(val);
return NULL;
}
}
ret->type = TYPE_DICT;
return ret;
}
| 0
|
230,614
|
void decode_prediction_unit(base_context* ctx,
const slice_segment_header* shdr,
de265_image* img,
const PBMotionCoding& motion,
int xC,int yC, int xB,int yB, int nCS, int nPbW,int nPbH, int partIdx)
{
logtrace(LogMotion,"decode_prediction_unit POC=%d %d;%d %dx%d\n",
img->PicOrderCntVal, xC+xB,yC+yB, nPbW,nPbH);
//slice_segment_header* shdr = tctx->shdr;
// 1.
PBMotion vi;
motion_vectors_and_ref_indices(ctx, shdr, img, motion,
xC,yC, xB,yB, nCS, nPbW,nPbH, partIdx, &vi);
// 2.
generate_inter_prediction_samples(ctx,shdr, img, xC,yC, xB,yB, nCS, nPbW,nPbH, &vi);
img->set_mv_info(xC+xB,yC+yB,nPbW,nPbH, vi);
}
| 0
|
90,894
|
void UsageTracker::GetCachedOrigins(std::set<GURL>* origins) const {
DCHECK(origins);
origins->clear();
for (ClientTrackerMap::const_iterator iter = client_tracker_map_.begin();
iter != client_tracker_map_.end(); ++iter) {
iter->second->GetCachedOrigins(origins);
}
}
| 0
|
230,456
|
uip_nd6_ra_output(uip_ipaddr_t * dest)
{
UIP_IP_BUF->vtc = 0x60;
UIP_IP_BUF->tcflow = 0;
UIP_IP_BUF->flow = 0;
UIP_IP_BUF->proto = UIP_PROTO_ICMP6;
UIP_IP_BUF->ttl = UIP_ND6_HOP_LIMIT;
if(dest == NULL) {
uip_create_linklocal_allnodes_mcast(&UIP_IP_BUF->destipaddr);
} else {
/* For sollicited RA */
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, dest);
}
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
UIP_ICMP_BUF->type = ICMP6_RA;
UIP_ICMP_BUF->icode = 0;
UIP_ND6_RA_BUF->cur_ttl = uip_ds6_if.cur_hop_limit;
UIP_ND6_RA_BUF->flags_reserved =
(UIP_ND6_M_FLAG << 7) | (UIP_ND6_O_FLAG << 6);
UIP_ND6_RA_BUF->router_lifetime = uip_htons(UIP_ND6_ROUTER_LIFETIME);
//UIP_ND6_RA_BUF->reachable_time = uip_htonl(uip_ds6_if.reachable_time);
//UIP_ND6_RA_BUF->retrans_timer = uip_htonl(uip_ds6_if.retrans_timer);
UIP_ND6_RA_BUF->reachable_time = 0;
UIP_ND6_RA_BUF->retrans_timer = 0;
uip_len = UIP_IPH_LEN + UIP_ICMPH_LEN + UIP_ND6_RA_LEN;
nd6_opt_offset = UIP_ND6_RA_LEN;
/* Prefix list */
for(prefix = uip_ds6_prefix_list;
prefix < uip_ds6_prefix_list + UIP_DS6_PREFIX_NB; prefix++) {
if((prefix->isused) && (prefix->advertise)) {
ND6_OPT_PREFIX_BUF(nd6_opt_offset)->type = UIP_ND6_OPT_PREFIX_INFO;
ND6_OPT_PREFIX_BUF(nd6_opt_offset)->len = UIP_ND6_OPT_PREFIX_INFO_LEN / 8;
ND6_OPT_PREFIX_BUF(nd6_opt_offset)->preflen = prefix->length;
ND6_OPT_PREFIX_BUF(nd6_opt_offset)->flagsreserved1 = prefix->l_a_reserved;
ND6_OPT_PREFIX_BUF(nd6_opt_offset)->validlt = uip_htonl(prefix->vlifetime);
ND6_OPT_PREFIX_BUF(nd6_opt_offset)->preferredlt = uip_htonl(prefix->plifetime);
ND6_OPT_PREFIX_BUF(nd6_opt_offset)->reserved2 = 0;
uip_ipaddr_copy(&(ND6_OPT_PREFIX_BUF(nd6_opt_offset)->prefix), &(prefix->ipaddr));
nd6_opt_offset += UIP_ND6_OPT_PREFIX_INFO_LEN;
uip_len += UIP_ND6_OPT_PREFIX_INFO_LEN;
}
}
/* Source link-layer option */
create_llao((uint8_t *)ND6_OPT_HDR_BUF(nd6_opt_offset), UIP_ND6_OPT_SLLAO);
uip_len += UIP_ND6_OPT_LLAO_LEN;
nd6_opt_offset += UIP_ND6_OPT_LLAO_LEN;
/* MTU */
ND6_OPT_MTU_BUF(nd6_opt_offset)->type = UIP_ND6_OPT_MTU;
ND6_OPT_MTU_BUF(nd6_opt_offset)->len = UIP_ND6_OPT_MTU_LEN >> 3;
ND6_OPT_MTU_BUF(nd6_opt_offset)->reserved = 0;
//ND6_OPT_MTU_BUF(nd6_opt_offset)->mtu = uip_htonl(uip_ds6_if.link_mtu);
ND6_OPT_MTU_BUF(nd6_opt_offset)->mtu = uip_htonl(1500);
uip_len += UIP_ND6_OPT_MTU_LEN;
nd6_opt_offset += UIP_ND6_OPT_MTU_LEN;
#if UIP_ND6_RA_RDNSS
if(uip_nameserver_count() > 0) {
uint8_t i = 0;
uip_ipaddr_t *ip = &ND6_OPT_RDNSS_BUF(nd6_opt_offset)->ip;
uip_ipaddr_t *dns = NULL;
ND6_OPT_RDNSS_BUF(nd6_opt_offset)->type = UIP_ND6_OPT_RDNSS;
ND6_OPT_RDNSS_BUF(nd6_opt_offset)->reserved = 0;
ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime = uip_nameserver_next_expiration();
if(ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime != UIP_NAMESERVER_INFINITE_LIFETIME) {
ND6_OPT_RDNSS_BUF(nd6_opt_offset)->lifetime -= clock_seconds();
}
while((dns = uip_nameserver_get(i)) != NULL) {
uip_ipaddr_copy(ip++, dns);
i++;
}
ND6_OPT_RDNSS_BUF(nd6_opt_offset)->len = UIP_ND6_OPT_RDNSS_LEN + (i << 1);
LOG_INFO("%d nameservers reported\n", i);
uip_len += ND6_OPT_RDNSS_BUF(nd6_opt_offset)->len << 3;
nd6_opt_offset += ND6_OPT_RDNSS_BUF(nd6_opt_offset)->len << 3;
}
#endif /* UIP_ND6_RA_RDNSS */
uipbuf_set_len_field(UIP_IP_BUF, uip_len - UIP_IPH_LEN);
/*ICMP checksum */
UIP_ICMP_BUF->icmpchksum = 0;
UIP_ICMP_BUF->icmpchksum = ~uip_icmp6chksum();
UIP_STAT(++uip_stat.nd6.sent);
LOG_INFO("Sending RA to ");
LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr);
LOG_INFO_(" from ");
LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr);
LOG_INFO_("\n");
return;
}
| 0
|
352,941
|
int octetStringFilter(
slap_mask_t use,
slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertedValue,
BerVarray *keysp,
void *ctx )
{
BerVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval *value = (struct berval *) assertedValue;
struct berval digest;
digest.bv_val = (char *)HASHdigest;
digest.bv_len = HASH_LEN;
keys = slap_sl_malloc( sizeof( struct berval ) * 2, ctx );
hashPreset( &HASHcontext, prefix, 0, syntax, mr );
hashIter( &HASHcontext, HASHdigest,
(unsigned char *)value->bv_val, value->bv_len );
ber_dupbv_x( keys, &digest, ctx );
BER_BVZERO( &keys[1] );
*keysp = keys;
return LDAP_SUCCESS;
}
| 0
|
385,820
|
SYSCALL_DEFINE2(ftruncate64, unsigned int, fd, loff_t, length)
{
return do_sys_ftruncate(fd, length, 0);
}
| 0
|
300,772
|
static int tipc_sk_anc_data_recv(struct msghdr *m, struct sk_buff *skb,
struct tipc_sock *tsk)
{
struct tipc_msg *hdr;
u32 data[3] = {0,};
bool has_addr;
int dlen, rc;
if (likely(m->msg_controllen == 0))
return 0;
hdr = buf_msg(skb);
dlen = msg_data_sz(hdr);
/* Capture errored message object, if any */
if (msg_errcode(hdr)) {
if (skb_linearize(skb))
return -ENOMEM;
hdr = buf_msg(skb);
data[0] = msg_errcode(hdr);
data[1] = dlen;
rc = put_cmsg(m, SOL_TIPC, TIPC_ERRINFO, 8, data);
if (rc || !dlen)
return rc;
rc = put_cmsg(m, SOL_TIPC, TIPC_RETDATA, dlen, msg_data(hdr));
if (rc)
return rc;
}
/* Capture TIPC_SERVICE_ADDR/RANGE destination address, if any */
switch (msg_type(hdr)) {
case TIPC_NAMED_MSG:
has_addr = true;
data[0] = msg_nametype(hdr);
data[1] = msg_namelower(hdr);
data[2] = data[1];
break;
case TIPC_MCAST_MSG:
has_addr = true;
data[0] = msg_nametype(hdr);
data[1] = msg_namelower(hdr);
data[2] = msg_nameupper(hdr);
break;
case TIPC_CONN_MSG:
has_addr = !!tsk->conn_addrtype;
data[0] = msg_nametype(&tsk->phdr);
data[1] = msg_nameinst(&tsk->phdr);
data[2] = data[1];
break;
default:
has_addr = false;
}
if (!has_addr)
return 0;
return put_cmsg(m, SOL_TIPC, TIPC_DESTNAME, 12, data);
}
| 0
|
369,398
|
static int io_tee(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_splice *sp = &req->splice;
struct file *out = sp->file_out;
unsigned int flags = sp->flags & ~SPLICE_F_FD_IN_FIXED;
struct file *in;
long ret = 0;
if (issue_flags & IO_URING_F_NONBLOCK)
return -EAGAIN;
if (sp->flags & SPLICE_F_FD_IN_FIXED)
in = io_file_get_fixed(req, sp->splice_fd_in, issue_flags);
else
in = io_file_get_normal(req, sp->splice_fd_in);
if (!in) {
ret = -EBADF;
goto done;
}
if (sp->len)
ret = do_tee(in, out, sp->len, flags);
if (!(sp->flags & SPLICE_F_FD_IN_FIXED))
io_put_file(in);
done:
if (ret != sp->len)
req_set_fail(req);
io_req_complete(req, ret);
return 0;
}
| 0
|
413,849
|
Method* LinkResolver::resolve_interface_call_or_null(
Klass* receiver_klass,
const LinkInfo& link_info) {
EXCEPTION_MARK;
CallInfo info;
resolve_interface_call(info, Handle(), receiver_klass, link_info, false, THREAD);
if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION;
return NULL;
}
return info.selected_method();
}
| 0
|
247,713
|
TEST_P(SslSocketTest, TestConnectionFailsOnStapleRequiredAndOcspExpired) {
const std::string server_ctx_yaml = R"EOF(
common_tls_context:
tls_certificates:
- certificate_chain:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/good_cert.pem"
private_key:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/good_key.pem"
ocsp_staple:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/unknown_ocsp_resp.der"
ocsp_staple_policy: must_staple
)EOF";
const std::string client_ctx_yaml = R"EOF(
common_tls_context:
tls_params:
cipher_suites:
- TLS_RSA_WITH_AES_128_GCM_SHA256
)EOF";
TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam());
testUtil(test_options.setExpectedServerStats("ssl.ocsp_staple_failed").enableOcspStapling());
}
| 0
|
262,795
|
static bool needs_escape(unsigned char c)
{
return c == BYTE_ESC || c == BYTE_FRAME;
}
| 0
|
400,739
|
size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *_csstate,
struct iov_iter *i)
{
struct csum_state *csstate = _csstate;
__wsum sum, next;
if (unlikely(iov_iter_is_discard(i))) {
WARN_ON(1); /* for now */
return 0;
}
sum = csum_shift(csstate->csum, csstate->off);
if (unlikely(iov_iter_is_pipe(i)))
bytes = csum_and_copy_to_pipe_iter(addr, bytes, i, &sum);
else iterate_and_advance(i, bytes, base, len, off, ({
next = csum_and_copy_to_user(addr + off, base, len);
sum = csum_block_add(sum, next, off);
next ? 0 : len;
}), ({
sum = csum_and_memcpy(base, addr + off, len, sum, off);
})
)
csstate->csum = csum_shift(sum, csstate->off);
csstate->off += bytes;
return bytes;
}
| 0
|
200,323
|
suggest_trie_walk(
suginfo_T *su,
langp_T *lp,
char_u *fword,
int soundfold)
{
char_u tword[MAXWLEN]; // good word collected so far
trystate_T stack[MAXWLEN];
char_u preword[MAXWLEN * 3]; // word found with proper case;
// concatenation of prefix compound
// words and split word. NUL terminated
// when going deeper but not when coming
// back.
char_u compflags[MAXWLEN]; // compound flags, one for each word
trystate_T *sp;
int newscore;
int score;
char_u *byts, *fbyts, *pbyts;
idx_T *idxs, *fidxs, *pidxs;
int depth;
int c, c2, c3;
int n = 0;
int flags;
garray_T *gap;
idx_T arridx;
int len;
char_u *p;
fromto_T *ftp;
int fl = 0, tl;
int repextra = 0; // extra bytes in fword[] from REP item
slang_T *slang = lp->lp_slang;
int fword_ends;
int goodword_ends;
#ifdef DEBUG_TRIEWALK
// Stores the name of the change made at each level.
char_u changename[MAXWLEN][80];
#endif
int breakcheckcount = 1000;
#ifdef FEAT_RELTIME
proftime_T time_limit;
#endif
int compound_ok;
// Go through the whole case-fold tree, try changes at each node.
// "tword[]" contains the word collected from nodes in the tree.
// "fword[]" the word we are trying to match with (initially the bad
// word).
depth = 0;
sp = &stack[0];
CLEAR_POINTER(sp);
sp->ts_curi = 1;
if (soundfold)
{
// Going through the soundfold tree.
byts = fbyts = slang->sl_sbyts;
idxs = fidxs = slang->sl_sidxs;
pbyts = NULL;
pidxs = NULL;
sp->ts_prefixdepth = PFD_NOPREFIX;
sp->ts_state = STATE_START;
}
else
{
// When there are postponed prefixes we need to use these first. At
// the end of the prefix we continue in the case-fold tree.
fbyts = slang->sl_fbyts;
fidxs = slang->sl_fidxs;
pbyts = slang->sl_pbyts;
pidxs = slang->sl_pidxs;
if (pbyts != NULL)
{
byts = pbyts;
idxs = pidxs;
sp->ts_prefixdepth = PFD_PREFIXTREE;
sp->ts_state = STATE_NOPREFIX; // try without prefix first
}
else
{
byts = fbyts;
idxs = fidxs;
sp->ts_prefixdepth = PFD_NOPREFIX;
sp->ts_state = STATE_START;
}
}
#ifdef FEAT_RELTIME
// The loop may take an indefinite amount of time. Break out after some
// time.
if (spell_suggest_timeout > 0)
profile_setlimit(spell_suggest_timeout, &time_limit);
#endif
// Loop to find all suggestions. At each round we either:
// - For the current state try one operation, advance "ts_curi",
// increase "depth".
// - When a state is done go to the next, set "ts_state".
// - When all states are tried decrease "depth".
while (depth >= 0 && !got_int)
{
sp = &stack[depth];
switch (sp->ts_state)
{
case STATE_START:
case STATE_NOPREFIX:
// Start of node: Deal with NUL bytes, which means
// tword[] may end here.
arridx = sp->ts_arridx; // current node in the tree
len = byts[arridx]; // bytes in this node
arridx += sp->ts_curi; // index of current byte
if (sp->ts_prefixdepth == PFD_PREFIXTREE)
{
// Skip over the NUL bytes, we use them later.
for (n = 0; n < len && byts[arridx + n] == 0; ++n)
;
sp->ts_curi += n;
// Always past NUL bytes now.
n = (int)sp->ts_state;
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_ENDNUL;
sp->ts_save_badflags = su->su_badflags;
// At end of a prefix or at start of prefixtree: check for
// following word.
if (depth < MAXWLEN - 1
&& (byts[arridx] == 0 || n == (int)STATE_NOPREFIX))
{
// Set su->su_badflags to the caps type at this position.
// Use the caps type until here for the prefix itself.
if (has_mbyte)
n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
else
n = sp->ts_fidx;
flags = badword_captype(su->su_badptr, su->su_badptr + n);
su->su_badflags = badword_captype(su->su_badptr + n,
su->su_badptr + su->su_badlen);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "prefix");
#endif
go_deeper(stack, depth, 0);
++depth;
sp = &stack[depth];
sp->ts_prefixdepth = depth - 1;
byts = fbyts;
idxs = fidxs;
sp->ts_arridx = 0;
// Move the prefix to preword[] with the right case
// and make find_keepcap_word() works.
tword[sp->ts_twordlen] = NUL;
make_case_word(tword + sp->ts_splitoff,
preword + sp->ts_prewordlen, flags);
sp->ts_prewordlen = (char_u)STRLEN(preword);
sp->ts_splitoff = sp->ts_twordlen;
}
break;
}
if (sp->ts_curi > len || byts[arridx] != 0)
{
// Past bytes in node and/or past NUL bytes.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_ENDNUL;
sp->ts_save_badflags = su->su_badflags;
break;
}
// End of word in tree.
++sp->ts_curi; // eat one NUL byte
flags = (int)idxs[arridx];
// Skip words with the NOSUGGEST flag.
if (flags & WF_NOSUGGEST)
break;
fword_ends = (fword[sp->ts_fidx] == NUL
|| (soundfold
? VIM_ISWHITE(fword[sp->ts_fidx])
: !spell_iswordp(fword + sp->ts_fidx, curwin)));
tword[sp->ts_twordlen] = NUL;
if (sp->ts_prefixdepth <= PFD_NOTSPECIAL
&& (sp->ts_flags & TSF_PREFIXOK) == 0
&& pbyts != NULL)
{
// There was a prefix before the word. Check that the prefix
// can be used with this word.
// Count the length of the NULs in the prefix. If there are
// none this must be the first try without a prefix.
n = stack[sp->ts_prefixdepth].ts_arridx;
len = pbyts[n++];
for (c = 0; c < len && pbyts[n + c] == 0; ++c)
;
if (c > 0)
{
c = valid_word_prefix(c, n, flags,
tword + sp->ts_splitoff, slang, FALSE);
if (c == 0)
break;
// Use the WF_RARE flag for a rare prefix.
if (c & WF_RAREPFX)
flags |= WF_RARE;
// Tricky: when checking for both prefix and compounding
// we run into the prefix flag first.
// Remember that it's OK, so that we accept the prefix
// when arriving at a compound flag.
sp->ts_flags |= TSF_PREFIXOK;
}
}
// Check NEEDCOMPOUND: can't use word without compounding. Do try
// appending another compound word below.
if (sp->ts_complen == sp->ts_compsplit && fword_ends
&& (flags & WF_NEEDCOMP))
goodword_ends = FALSE;
else
goodword_ends = TRUE;
p = NULL;
compound_ok = TRUE;
if (sp->ts_complen > sp->ts_compsplit)
{
if (slang->sl_nobreak)
{
// There was a word before this word. When there was no
// change in this word (it was correct) add the first word
// as a suggestion. If this word was corrected too, we
// need to check if a correct word follows.
if (sp->ts_fidx - sp->ts_splitfidx
== sp->ts_twordlen - sp->ts_splitoff
&& STRNCMP(fword + sp->ts_splitfidx,
tword + sp->ts_splitoff,
sp->ts_fidx - sp->ts_splitfidx) == 0)
{
preword[sp->ts_prewordlen] = NUL;
newscore = score_wordcount_adj(slang, sp->ts_score,
preword + sp->ts_prewordlen,
sp->ts_prewordlen > 0);
// Add the suggestion if the score isn't too bad.
if (newscore <= su->su_maxscore)
add_suggestion(su, &su->su_ga, preword,
sp->ts_splitfidx - repextra,
newscore, 0, FALSE,
lp->lp_sallang, FALSE);
break;
}
}
else
{
// There was a compound word before this word. If this
// word does not support compounding then give up
// (splitting is tried for the word without compound
// flag).
if (((unsigned)flags >> 24) == 0
|| sp->ts_twordlen - sp->ts_splitoff
< slang->sl_compminlen)
break;
// For multi-byte chars check character length against
// COMPOUNDMIN.
if (has_mbyte
&& slang->sl_compminlen > 0
&& mb_charlen(tword + sp->ts_splitoff)
< slang->sl_compminlen)
break;
compflags[sp->ts_complen] = ((unsigned)flags >> 24);
compflags[sp->ts_complen + 1] = NUL;
vim_strncpy(preword + sp->ts_prewordlen,
tword + sp->ts_splitoff,
sp->ts_twordlen - sp->ts_splitoff);
// Verify CHECKCOMPOUNDPATTERN rules.
if (match_checkcompoundpattern(preword, sp->ts_prewordlen,
&slang->sl_comppat))
compound_ok = FALSE;
if (compound_ok)
{
p = preword;
while (*skiptowhite(p) != NUL)
p = skipwhite(skiptowhite(p));
if (fword_ends && !can_compound(slang, p,
compflags + sp->ts_compsplit))
// Compound is not allowed. But it may still be
// possible if we add another (short) word.
compound_ok = FALSE;
}
// Get pointer to last char of previous word.
p = preword + sp->ts_prewordlen;
MB_PTR_BACK(preword, p);
}
}
// Form the word with proper case in preword.
// If there is a word from a previous split, append.
// For the soundfold tree don't change the case, simply append.
if (soundfold)
STRCPY(preword + sp->ts_prewordlen, tword + sp->ts_splitoff);
else if (flags & WF_KEEPCAP)
// Must find the word in the keep-case tree.
find_keepcap_word(slang, tword + sp->ts_splitoff,
preword + sp->ts_prewordlen);
else
{
// Include badflags: If the badword is onecap or allcap
// use that for the goodword too. But if the badword is
// allcap and it's only one char long use onecap.
c = su->su_badflags;
if ((c & WF_ALLCAP)
&& su->su_badlen == (*mb_ptr2len)(su->su_badptr))
c = WF_ONECAP;
c |= flags;
// When appending a compound word after a word character don't
// use Onecap.
if (p != NULL && spell_iswordp_nmw(p, curwin))
c &= ~WF_ONECAP;
make_case_word(tword + sp->ts_splitoff,
preword + sp->ts_prewordlen, c);
}
if (!soundfold)
{
// Don't use a banned word. It may appear again as a good
// word, thus remember it.
if (flags & WF_BANNED)
{
add_banned(su, preword + sp->ts_prewordlen);
break;
}
if ((sp->ts_complen == sp->ts_compsplit
&& WAS_BANNED(su, preword + sp->ts_prewordlen))
|| WAS_BANNED(su, preword))
{
if (slang->sl_compprog == NULL)
break;
// the word so far was banned but we may try compounding
goodword_ends = FALSE;
}
}
newscore = 0;
if (!soundfold) // soundfold words don't have flags
{
if ((flags & WF_REGION)
&& (((unsigned)flags >> 16) & lp->lp_region) == 0)
newscore += SCORE_REGION;
if (flags & WF_RARE)
newscore += SCORE_RARE;
if (!spell_valid_case(su->su_badflags,
captype(preword + sp->ts_prewordlen, NULL)))
newscore += SCORE_ICASE;
}
// TODO: how about splitting in the soundfold tree?
if (fword_ends
&& goodword_ends
&& sp->ts_fidx >= sp->ts_fidxtry
&& compound_ok)
{
// The badword also ends: add suggestions.
#ifdef DEBUG_TRIEWALK
if (soundfold && STRCMP(preword, "smwrd") == 0)
{
int j;
// print the stack of changes that brought us here
smsg("------ %s -------", fword);
for (j = 0; j < depth; ++j)
smsg("%s", changename[j]);
}
#endif
if (soundfold)
{
// For soundfolded words we need to find the original
// words, the edit distance and then add them.
add_sound_suggest(su, preword, sp->ts_score, lp);
}
else if (sp->ts_fidx > 0)
{
// Give a penalty when changing non-word char to word
// char, e.g., "thes," -> "these".
p = fword + sp->ts_fidx;
MB_PTR_BACK(fword, p);
if (!spell_iswordp(p, curwin) && *preword != NUL)
{
p = preword + STRLEN(preword);
MB_PTR_BACK(preword, p);
if (spell_iswordp(p, curwin))
newscore += SCORE_NONWORD;
}
// Give a bonus to words seen before.
score = score_wordcount_adj(slang,
sp->ts_score + newscore,
preword + sp->ts_prewordlen,
sp->ts_prewordlen > 0);
// Add the suggestion if the score isn't too bad.
if (score <= su->su_maxscore)
{
add_suggestion(su, &su->su_ga, preword,
sp->ts_fidx - repextra,
score, 0, FALSE, lp->lp_sallang, FALSE);
if (su->su_badflags & WF_MIXCAP)
{
// We really don't know if the word should be
// upper or lower case, add both.
c = captype(preword, NULL);
if (c == 0 || c == WF_ALLCAP)
{
make_case_word(tword + sp->ts_splitoff,
preword + sp->ts_prewordlen,
c == 0 ? WF_ALLCAP : 0);
add_suggestion(su, &su->su_ga, preword,
sp->ts_fidx - repextra,
score + SCORE_ICASE, 0, FALSE,
lp->lp_sallang, FALSE);
}
}
}
}
}
// Try word split and/or compounding.
if ((sp->ts_fidx >= sp->ts_fidxtry || fword_ends)
// Don't split halfway a character.
&& (!has_mbyte || sp->ts_tcharlen == 0))
{
int try_compound;
int try_split;
// If past the end of the bad word don't try a split.
// Otherwise try changing the next word. E.g., find
// suggestions for "the the" where the second "the" is
// different. It's done like a split.
// TODO: word split for soundfold words
try_split = (sp->ts_fidx - repextra < su->su_badlen)
&& !soundfold;
// Get here in several situations:
// 1. The word in the tree ends:
// If the word allows compounding try that. Otherwise try
// a split by inserting a space. For both check that a
// valid words starts at fword[sp->ts_fidx].
// For NOBREAK do like compounding to be able to check if
// the next word is valid.
// 2. The badword does end, but it was due to a change (e.g.,
// a swap). No need to split, but do check that the
// following word is valid.
// 3. The badword and the word in the tree end. It may still
// be possible to compound another (short) word.
try_compound = FALSE;
if (!soundfold
&& !slang->sl_nocompoundsugs
&& slang->sl_compprog != NULL
&& ((unsigned)flags >> 24) != 0
&& sp->ts_twordlen - sp->ts_splitoff
>= slang->sl_compminlen
&& (!has_mbyte
|| slang->sl_compminlen == 0
|| mb_charlen(tword + sp->ts_splitoff)
>= slang->sl_compminlen)
&& (slang->sl_compsylmax < MAXWLEN
|| sp->ts_complen + 1 - sp->ts_compsplit
< slang->sl_compmax)
&& (can_be_compound(sp, slang,
compflags, ((unsigned)flags >> 24))))
{
try_compound = TRUE;
compflags[sp->ts_complen] = ((unsigned)flags >> 24);
compflags[sp->ts_complen + 1] = NUL;
}
// For NOBREAK we never try splitting, it won't make any word
// valid.
if (slang->sl_nobreak && !slang->sl_nocompoundsugs)
try_compound = TRUE;
// If we could add a compound word, and it's also possible to
// split at this point, do the split first and set
// TSF_DIDSPLIT to avoid doing it again.
else if (!fword_ends
&& try_compound
&& (sp->ts_flags & TSF_DIDSPLIT) == 0)
{
try_compound = FALSE;
sp->ts_flags |= TSF_DIDSPLIT;
--sp->ts_curi; // do the same NUL again
compflags[sp->ts_complen] = NUL;
}
else
sp->ts_flags &= ~TSF_DIDSPLIT;
if (try_split || try_compound)
{
if (!try_compound && (!fword_ends || !goodword_ends))
{
// If we're going to split need to check that the
// words so far are valid for compounding. If there
// is only one word it must not have the NEEDCOMPOUND
// flag.
if (sp->ts_complen == sp->ts_compsplit
&& (flags & WF_NEEDCOMP))
break;
p = preword;
while (*skiptowhite(p) != NUL)
p = skipwhite(skiptowhite(p));
if (sp->ts_complen > sp->ts_compsplit
&& !can_compound(slang, p,
compflags + sp->ts_compsplit))
break;
if (slang->sl_nosplitsugs)
newscore += SCORE_SPLIT_NO;
else
newscore += SCORE_SPLIT;
// Give a bonus to words seen before.
newscore = score_wordcount_adj(slang, newscore,
preword + sp->ts_prewordlen, TRUE);
}
if (TRY_DEEPER(su, stack, depth, newscore))
{
go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK
if (!try_compound && !fword_ends)
sprintf(changename[depth], "%.*s-%s: split",
sp->ts_twordlen, tword, fword + sp->ts_fidx);
else
sprintf(changename[depth], "%.*s-%s: compound",
sp->ts_twordlen, tword, fword + sp->ts_fidx);
#endif
// Save things to be restored at STATE_SPLITUNDO.
sp->ts_save_badflags = su->su_badflags;
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SPLITUNDO;
++depth;
sp = &stack[depth];
// Append a space to preword when splitting.
if (!try_compound && !fword_ends)
STRCAT(preword, " ");
sp->ts_prewordlen = (char_u)STRLEN(preword);
sp->ts_splitoff = sp->ts_twordlen;
sp->ts_splitfidx = sp->ts_fidx;
// If the badword has a non-word character at this
// position skip it. That means replacing the
// non-word character with a space. Always skip a
// character when the word ends. But only when the
// good word can end.
if (((!try_compound && !spell_iswordp_nmw(fword
+ sp->ts_fidx,
curwin))
|| fword_ends)
&& fword[sp->ts_fidx] != NUL
&& goodword_ends)
{
int l;
l = mb_ptr2len(fword + sp->ts_fidx);
if (fword_ends)
{
// Copy the skipped character to preword.
mch_memmove(preword + sp->ts_prewordlen,
fword + sp->ts_fidx, l);
sp->ts_prewordlen += l;
preword[sp->ts_prewordlen] = NUL;
}
else
sp->ts_score -= SCORE_SPLIT - SCORE_SUBST;
sp->ts_fidx += l;
}
// When compounding include compound flag in
// compflags[] (already set above). When splitting we
// may start compounding over again.
if (try_compound)
++sp->ts_complen;
else
sp->ts_compsplit = sp->ts_complen;
sp->ts_prefixdepth = PFD_NOPREFIX;
// set su->su_badflags to the caps type at this
// position
if (has_mbyte)
n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
else
n = sp->ts_fidx;
su->su_badflags = badword_captype(su->su_badptr + n,
su->su_badptr + su->su_badlen);
// Restart at top of the tree.
sp->ts_arridx = 0;
// If there are postponed prefixes, try these too.
if (pbyts != NULL)
{
byts = pbyts;
idxs = pidxs;
sp->ts_prefixdepth = PFD_PREFIXTREE;
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_NOPREFIX;
}
}
}
}
break;
case STATE_SPLITUNDO:
// Undo the changes done for word split or compound word.
su->su_badflags = sp->ts_save_badflags;
// Continue looking for NUL bytes.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_START;
// In case we went into the prefix tree.
byts = fbyts;
idxs = fidxs;
break;
case STATE_ENDNUL:
// Past the NUL bytes in the node.
su->su_badflags = sp->ts_save_badflags;
if (fword[sp->ts_fidx] == NUL && sp->ts_tcharlen == 0)
{
// The badword ends, can't use STATE_PLAIN.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_DEL;
break;
}
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_PLAIN;
// FALLTHROUGH
case STATE_PLAIN:
// Go over all possible bytes at this node, add each to tword[]
// and use child node. "ts_curi" is the index.
arridx = sp->ts_arridx;
if (sp->ts_curi > byts[arridx])
{
// Done all bytes at this node, do next state. When still at
// already changed bytes skip the other tricks.
PROF_STORE(sp->ts_state)
if (sp->ts_fidx >= sp->ts_fidxtry)
sp->ts_state = STATE_DEL;
else
sp->ts_state = STATE_FINAL;
}
else
{
arridx += sp->ts_curi++;
c = byts[arridx];
// Normal byte, go one level deeper. If it's not equal to the
// byte in the bad word adjust the score. But don't even try
// when the byte was already changed. And don't try when we
// just deleted this byte, accepting it is always cheaper than
// delete + substitute.
if (c == fword[sp->ts_fidx]
|| (sp->ts_tcharlen > 0 && sp->ts_isdiff != DIFF_NONE))
newscore = 0;
else
newscore = SCORE_SUBST;
if ((newscore == 0
|| (sp->ts_fidx >= sp->ts_fidxtry
&& ((sp->ts_flags & TSF_DIDDEL) == 0
|| c != fword[sp->ts_delidx])))
&& TRY_DEEPER(su, stack, depth, newscore))
{
go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK
if (newscore > 0)
sprintf(changename[depth], "%.*s-%s: subst %c to %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
fword[sp->ts_fidx], c);
else
sprintf(changename[depth], "%.*s-%s: accept %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
fword[sp->ts_fidx]);
#endif
++depth;
sp = &stack[depth];
if (fword[sp->ts_fidx] != NUL)
++sp->ts_fidx;
tword[sp->ts_twordlen++] = c;
sp->ts_arridx = idxs[arridx];
if (newscore == SCORE_SUBST)
sp->ts_isdiff = DIFF_YES;
if (has_mbyte)
{
// Multi-byte characters are a bit complicated to
// handle: They differ when any of the bytes differ
// and then their length may also differ.
if (sp->ts_tcharlen == 0)
{
// First byte.
sp->ts_tcharidx = 0;
sp->ts_tcharlen = MB_BYTE2LEN(c);
sp->ts_fcharstart = sp->ts_fidx - 1;
sp->ts_isdiff = (newscore != 0)
? DIFF_YES : DIFF_NONE;
}
else if (sp->ts_isdiff == DIFF_INSERT)
// When inserting trail bytes don't advance in the
// bad word.
--sp->ts_fidx;
if (++sp->ts_tcharidx == sp->ts_tcharlen)
{
// Last byte of character.
if (sp->ts_isdiff == DIFF_YES)
{
// Correct ts_fidx for the byte length of the
// character (we didn't check that before).
sp->ts_fidx = sp->ts_fcharstart
+ mb_ptr2len(
fword + sp->ts_fcharstart);
// For changing a composing character adjust
// the score from SCORE_SUBST to
// SCORE_SUBCOMP.
if (enc_utf8
&& utf_iscomposing(
utf_ptr2char(tword
+ sp->ts_twordlen
- sp->ts_tcharlen))
&& utf_iscomposing(
utf_ptr2char(fword
+ sp->ts_fcharstart)))
sp->ts_score -=
SCORE_SUBST - SCORE_SUBCOMP;
// For a similar character adjust score from
// SCORE_SUBST to SCORE_SIMILAR.
else if (!soundfold
&& slang->sl_has_map
&& similar_chars(slang,
mb_ptr2char(tword
+ sp->ts_twordlen
- sp->ts_tcharlen),
mb_ptr2char(fword
+ sp->ts_fcharstart)))
sp->ts_score -=
SCORE_SUBST - SCORE_SIMILAR;
}
else if (sp->ts_isdiff == DIFF_INSERT
&& sp->ts_twordlen > sp->ts_tcharlen)
{
p = tword + sp->ts_twordlen - sp->ts_tcharlen;
c = mb_ptr2char(p);
if (enc_utf8 && utf_iscomposing(c))
{
// Inserting a composing char doesn't
// count that much.
sp->ts_score -= SCORE_INS - SCORE_INSCOMP;
}
else
{
// If the previous character was the same,
// thus doubling a character, give a bonus
// to the score. Also for the soundfold
// tree (might seem illogical but does
// give better scores).
MB_PTR_BACK(tword, p);
if (c == mb_ptr2char(p))
sp->ts_score -= SCORE_INS
- SCORE_INSDUP;
}
}
// Starting a new char, reset the length.
sp->ts_tcharlen = 0;
}
}
else
{
// If we found a similar char adjust the score.
// We do this after calling go_deeper() because
// it's slow.
if (newscore != 0
&& !soundfold
&& slang->sl_has_map
&& similar_chars(slang,
c, fword[sp->ts_fidx - 1]))
sp->ts_score -= SCORE_SUBST - SCORE_SIMILAR;
}
}
}
break;
case STATE_DEL:
// When past the first byte of a multi-byte char don't try
// delete/insert/swap a character.
if (has_mbyte && sp->ts_tcharlen > 0)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_FINAL;
break;
}
// Try skipping one character in the bad word (delete it).
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_INS_PREP;
sp->ts_curi = 1;
if (soundfold && sp->ts_fidx == 0 && fword[sp->ts_fidx] == '*')
// Deleting a vowel at the start of a word counts less, see
// soundalike_score().
newscore = 2 * SCORE_DEL / 3;
else
newscore = SCORE_DEL;
if (fword[sp->ts_fidx] != NUL
&& TRY_DEEPER(su, stack, depth, newscore))
{
go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: delete %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
fword[sp->ts_fidx]);
#endif
++depth;
// Remember what character we deleted, so that we can avoid
// inserting it again.
stack[depth].ts_flags |= TSF_DIDDEL;
stack[depth].ts_delidx = sp->ts_fidx;
// Advance over the character in fword[]. Give a bonus to the
// score if the same character is following "nn" -> "n". It's
// a bit illogical for soundfold tree but it does give better
// results.
if (has_mbyte)
{
c = mb_ptr2char(fword + sp->ts_fidx);
stack[depth].ts_fidx += mb_ptr2len(fword + sp->ts_fidx);
if (enc_utf8 && utf_iscomposing(c))
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;
else if (c == mb_ptr2char(fword + stack[depth].ts_fidx))
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
}
else
{
++stack[depth].ts_fidx;
if (fword[sp->ts_fidx] == fword[sp->ts_fidx + 1])
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
}
break;
}
// FALLTHROUGH
case STATE_INS_PREP:
if (sp->ts_flags & TSF_DIDDEL)
{
// If we just deleted a byte then inserting won't make sense,
// a substitute is always cheaper.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SWAP;
break;
}
// skip over NUL bytes
n = sp->ts_arridx;
for (;;)
{
if (sp->ts_curi > byts[n])
{
// Only NUL bytes at this node, go to next state.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SWAP;
break;
}
if (byts[n + sp->ts_curi] != NUL)
{
// Found a byte to insert.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_INS;
break;
}
++sp->ts_curi;
}
break;
// FALLTHROUGH
case STATE_INS:
// Insert one byte. Repeat this for each possible byte at this
// node.
n = sp->ts_arridx;
if (sp->ts_curi > byts[n])
{
// Done all bytes at this node, go to next state.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SWAP;
break;
}
// Do one more byte at this node, but:
// - Skip NUL bytes.
// - Skip the byte if it's equal to the byte in the word,
// accepting that byte is always better.
n += sp->ts_curi++;
c = byts[n];
if (soundfold && sp->ts_twordlen == 0 && c == '*')
// Inserting a vowel at the start of a word counts less,
// see soundalike_score().
newscore = 2 * SCORE_INS / 3;
else
newscore = SCORE_INS;
if (c != fword[sp->ts_fidx]
&& TRY_DEEPER(su, stack, depth, newscore))
{
go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: insert %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
c);
#endif
++depth;
sp = &stack[depth];
tword[sp->ts_twordlen++] = c;
sp->ts_arridx = idxs[n];
if (has_mbyte)
{
fl = MB_BYTE2LEN(c);
if (fl > 1)
{
// There are following bytes for the same character.
// We must find all bytes before trying
// delete/insert/swap/etc.
sp->ts_tcharlen = fl;
sp->ts_tcharidx = 1;
sp->ts_isdiff = DIFF_INSERT;
}
}
else
fl = 1;
if (fl == 1)
{
// If the previous character was the same, thus doubling a
// character, give a bonus to the score. Also for
// soundfold words (illogical but does give a better
// score).
if (sp->ts_twordlen >= 2
&& tword[sp->ts_twordlen - 2] == c)
sp->ts_score -= SCORE_INS - SCORE_INSDUP;
}
}
break;
case STATE_SWAP:
// Swap two bytes in the bad word: "12" -> "21".
// We change "fword" here, it's changed back afterwards at
// STATE_UNSWAP.
p = fword + sp->ts_fidx;
c = *p;
if (c == NUL)
{
// End of word, can't swap or replace.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_FINAL;
break;
}
// Don't swap if the first character is not a word character.
// SWAP3 etc. also don't make sense then.
if (!soundfold && !spell_iswordp(p, curwin))
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
break;
}
if (has_mbyte)
{
n = MB_CPTR2LEN(p);
c = mb_ptr2char(p);
if (p[n] == NUL)
c2 = NUL;
else if (!soundfold && !spell_iswordp(p + n, curwin))
c2 = c; // don't swap non-word char
else
c2 = mb_ptr2char(p + n);
}
else
{
if (p[1] == NUL)
c2 = NUL;
else if (!soundfold && !spell_iswordp(p + 1, curwin))
c2 = c; // don't swap non-word char
else
c2 = p[1];
}
// When the second character is NUL we can't swap.
if (c2 == NUL)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
break;
}
// When characters are identical, swap won't do anything.
// Also get here if the second char is not a word character.
if (c == c2)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SWAP3;
break;
}
if (c2 != NUL && TRY_DEEPER(su, stack, depth, SCORE_SWAP))
{
go_deeper(stack, depth, SCORE_SWAP);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: swap %c and %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
c, c2);
#endif
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNSWAP;
++depth;
if (has_mbyte)
{
fl = mb_char2len(c2);
mch_memmove(p, p + n, fl);
mb_char2bytes(c, p + fl);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
}
else
{
p[0] = c2;
p[1] = c;
stack[depth].ts_fidxtry = sp->ts_fidx + 2;
}
}
else
{
// If this swap doesn't work then SWAP3 won't either.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
}
break;
case STATE_UNSWAP:
// Undo the STATE_SWAP swap: "21" -> "12".
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = mb_ptr2len(p);
c = mb_ptr2char(p + n);
mch_memmove(p + mb_ptr2len(p + n), p, n);
mb_char2bytes(c, p);
}
else
{
c = *p;
*p = p[1];
p[1] = c;
}
// FALLTHROUGH
case STATE_SWAP3:
// Swap two bytes, skipping one: "123" -> "321". We change
// "fword" here, it's changed back afterwards at STATE_UNSWAP3.
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = MB_CPTR2LEN(p);
c = mb_ptr2char(p);
fl = MB_CPTR2LEN(p + n);
c2 = mb_ptr2char(p + n);
if (!soundfold && !spell_iswordp(p + n + fl, curwin))
c3 = c; // don't swap non-word char
else
c3 = mb_ptr2char(p + n + fl);
}
else
{
c = *p;
c2 = p[1];
if (!soundfold && !spell_iswordp(p + 2, curwin))
c3 = c; // don't swap non-word char
else
c3 = p[2];
}
// When characters are identical: "121" then SWAP3 result is
// identical, ROT3L result is same as SWAP: "211", ROT3L result is
// same as SWAP on next char: "112". Thus skip all swapping.
// Also skip when c3 is NUL.
// Also get here when the third character is not a word character.
// Second character may any char: "a.b" -> "b.a"
if (c == c3 || c3 == NUL)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
break;
}
if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))
{
go_deeper(stack, depth, SCORE_SWAP3);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: swap3 %c and %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
c, c3);
#endif
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNSWAP3;
++depth;
if (has_mbyte)
{
tl = mb_char2len(c3);
mch_memmove(p, p + n + fl, tl);
mb_char2bytes(c2, p + tl);
mb_char2bytes(c, p + fl + tl);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl + tl;
}
else
{
p[0] = p[2];
p[2] = c;
stack[depth].ts_fidxtry = sp->ts_fidx + 3;
}
}
else
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
}
break;
case STATE_UNSWAP3:
// Undo STATE_SWAP3: "321" -> "123"
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = mb_ptr2len(p);
c2 = mb_ptr2char(p + n);
fl = mb_ptr2len(p + n);
c = mb_ptr2char(p + n + fl);
tl = mb_ptr2len(p + n + fl);
mch_memmove(p + fl + tl, p, n);
mb_char2bytes(c, p);
mb_char2bytes(c2, p + tl);
p = p + tl;
}
else
{
c = *p;
*p = p[2];
p[2] = c;
++p;
}
if (!soundfold && !spell_iswordp(p, curwin))
{
// Middle char is not a word char, skip the rotate. First and
// third char were already checked at swap and swap3.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
break;
}
// Rotate three characters left: "123" -> "231". We change
// "fword" here, it's changed back afterwards at STATE_UNROT3L.
if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))
{
go_deeper(stack, depth, SCORE_SWAP3);
#ifdef DEBUG_TRIEWALK
p = fword + sp->ts_fidx;
sprintf(changename[depth], "%.*s-%s: rotate left %c%c%c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
p[0], p[1], p[2]);
#endif
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNROT3L;
++depth;
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = MB_CPTR2LEN(p);
c = mb_ptr2char(p);
fl = MB_CPTR2LEN(p + n);
fl += MB_CPTR2LEN(p + n + fl);
mch_memmove(p, p + n, fl);
mb_char2bytes(c, p + fl);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
}
else
{
c = *p;
*p = p[1];
p[1] = p[2];
p[2] = c;
stack[depth].ts_fidxtry = sp->ts_fidx + 3;
}
}
else
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
}
break;
case STATE_UNROT3L:
// Undo ROT3L: "231" -> "123"
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = mb_ptr2len(p);
n += mb_ptr2len(p + n);
c = mb_ptr2char(p + n);
tl = mb_ptr2len(p + n);
mch_memmove(p + tl, p, n);
mb_char2bytes(c, p);
}
else
{
c = p[2];
p[2] = p[1];
p[1] = *p;
*p = c;
}
// Rotate three bytes right: "123" -> "312". We change "fword"
// here, it's changed back afterwards at STATE_UNROT3R.
if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))
{
go_deeper(stack, depth, SCORE_SWAP3);
#ifdef DEBUG_TRIEWALK
p = fword + sp->ts_fidx;
sprintf(changename[depth], "%.*s-%s: rotate right %c%c%c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
p[0], p[1], p[2]);
#endif
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNROT3R;
++depth;
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = MB_CPTR2LEN(p);
n += MB_CPTR2LEN(p + n);
c = mb_ptr2char(p + n);
tl = MB_CPTR2LEN(p + n);
mch_memmove(p + tl, p, n);
mb_char2bytes(c, p);
stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;
}
else
{
c = p[2];
p[2] = p[1];
p[1] = *p;
*p = c;
stack[depth].ts_fidxtry = sp->ts_fidx + 3;
}
}
else
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
}
break;
case STATE_UNROT3R:
// Undo ROT3R: "312" -> "123"
p = fword + sp->ts_fidx;
if (has_mbyte)
{
c = mb_ptr2char(p);
tl = mb_ptr2len(p);
n = mb_ptr2len(p + tl);
n += mb_ptr2len(p + tl + n);
mch_memmove(p, p + tl, n);
mb_char2bytes(c, p + n);
}
else
{
c = *p;
*p = p[1];
p[1] = p[2];
p[2] = c;
}
// FALLTHROUGH
case STATE_REP_INI:
// Check if matching with REP items from the .aff file would work.
// Quickly skip if:
// - there are no REP items and we are not in the soundfold trie
// - the score is going to be too high anyway
// - already applied a REP item or swapped here
if ((lp->lp_replang == NULL && !soundfold)
|| sp->ts_score + SCORE_REP >= su->su_maxscore
|| sp->ts_fidx < sp->ts_fidxtry)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_FINAL;
break;
}
// Use the first byte to quickly find the first entry that may
// match. If the index is -1 there is none.
if (soundfold)
sp->ts_curi = slang->sl_repsal_first[fword[sp->ts_fidx]];
else
sp->ts_curi = lp->lp_replang->sl_rep_first[fword[sp->ts_fidx]];
if (sp->ts_curi < 0)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_FINAL;
break;
}
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP;
// FALLTHROUGH
case STATE_REP:
// Try matching with REP items from the .aff file. For each match
// replace the characters and check if the resulting word is
// valid.
p = fword + sp->ts_fidx;
if (soundfold)
gap = &slang->sl_repsal;
else
gap = &lp->lp_replang->sl_rep;
while (sp->ts_curi < gap->ga_len)
{
ftp = (fromto_T *)gap->ga_data + sp->ts_curi++;
if (*ftp->ft_from != *p)
{
// past possible matching entries
sp->ts_curi = gap->ga_len;
break;
}
if (STRNCMP(ftp->ft_from, p, STRLEN(ftp->ft_from)) == 0
&& TRY_DEEPER(su, stack, depth, SCORE_REP))
{
go_deeper(stack, depth, SCORE_REP);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: replace %s with %s",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
ftp->ft_from, ftp->ft_to);
#endif
// Need to undo this afterwards.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_UNDO;
// Change the "from" to the "to" string.
++depth;
fl = (int)STRLEN(ftp->ft_from);
tl = (int)STRLEN(ftp->ft_to);
if (fl != tl)
{
STRMOVE(p + tl, p + fl);
repextra += tl - fl;
}
mch_memmove(p, ftp->ft_to, tl);
stack[depth].ts_fidxtry = sp->ts_fidx + tl;
stack[depth].ts_tcharlen = 0;
break;
}
}
if (sp->ts_curi >= gap->ga_len && sp->ts_state == STATE_REP)
{
// No (more) matches.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_FINAL;
}
break;
case STATE_REP_UNDO:
// Undo a REP replacement and continue with the next one.
if (soundfold)
gap = &slang->sl_repsal;
else
gap = &lp->lp_replang->sl_rep;
ftp = (fromto_T *)gap->ga_data + sp->ts_curi - 1;
fl = (int)STRLEN(ftp->ft_from);
tl = (int)STRLEN(ftp->ft_to);
p = fword + sp->ts_fidx;
if (fl != tl)
{
STRMOVE(p + fl, p + tl);
repextra -= tl - fl;
}
mch_memmove(p, ftp->ft_from, fl);
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP;
break;
default:
// Did all possible states at this level, go up one level.
--depth;
if (depth >= 0 && stack[depth].ts_prefixdepth == PFD_PREFIXTREE)
{
// Continue in or go back to the prefix tree.
byts = pbyts;
idxs = pidxs;
}
// Don't check for CTRL-C too often, it takes time.
if (--breakcheckcount == 0)
{
ui_breakcheck();
breakcheckcount = 1000;
#ifdef FEAT_RELTIME
if (spell_suggest_timeout > 0
&& profile_passed_limit(&time_limit))
got_int = TRUE;
#endif
}
}
}
}
| 1
|
225,653
|
GF_Err kind_box_size(GF_Box *s)
{
GF_KindBox *ptr = (GF_KindBox *)s;
ptr->size += (ptr->schemeURI ? strlen(ptr->schemeURI) : 0) + 1;
if (ptr->value) {
ptr->size += strlen(ptr->value) + 1;
}
return GF_OK;
}
| 0
|
222,862
|
void CreateInputTensors(NodeContext* c,
std::vector<Tensor>* input_tensor_vector,
TensorVector* inputs) {
InferenceContext* ic = c->inference_context.get();
for (int i = 0; i < ic->num_inputs(); i++) {
if (ic->input_tensor(i)) {
input_tensor_vector->at(i) = *ic->input_tensor(i);
inputs->emplace_back(&input_tensor_vector->at(i));
// Note that we don't check c->input_tensor_protos[i], as UpdateNode()
// already converted it to ic->input_tensor(i);
} else {
// Create Tensor from input_tensors_as_shapes, and then emplace it
// back to inputs.
// Note that input_tensors_as_shapes is scalar or vector.
const ShapeHandle& shape_handle = ic->input_tensors_as_shapes()[i];
const DataType& data_type = c->input_types[i];
int32_t rank = ic->Rank(shape_handle);
if (rank < 1) {
input_tensor_vector->at(i) = Tensor(data_type, {});
} else {
input_tensor_vector->at(i) = Tensor(data_type, {rank});
}
auto* tensor = &input_tensor_vector->at(i);
if (data_type == DT_INT32) {
auto flat = tensor->flat<int32>();
for (int j = 0; j < rank; j++) {
int32_t dim = ic->Value(ic->Dim(shape_handle, j));
flat(j) = dim;
}
} else {
auto flat = tensor->flat<int64_t>();
for (int j = 0; j < rank; j++) {
int64_t dim = ic->Value(ic->Dim(shape_handle, j));
flat(j) = dim;
}
}
inputs->emplace_back(tensor);
}
}
}
| 0
|
246,700
|
static GF_Err do_dash()
{
GF_Err e;
u32 i;
Bool del_file = GF_FALSE;
char szMPD[GF_MAX_PATH], *sep;
char szStateFile[GF_MAX_PATH];
Bool dyn_state_file = GF_FALSE;
u32 do_abort = 0;
GF_DASHSegmenter *dasher=NULL;
if (crypt) {
M4_LOG(GF_LOG_ERROR, ("MP4Box cannot use -crypt and -dash in the same pass. Please encrypt your content first, or specify encryption filters on dash sources.\n"));
return GF_BAD_PARAM;
}
strcpy(outfile, outName ? outName : gf_url_get_resource_name(inName) );
sep = strrchr(outfile, '.');
if (sep) sep[0] = 0;
if (!outName) strcat(outfile, "_dash");
strcpy(szMPD, outfile);
if (outName && sep) {
sep[0] = '.';
strcat(szMPD, sep);
} else {
strcat(szMPD, ".mpd");
}
if ((dash_subduration>0) && (dash_duration > dash_subduration)) {
M4_LOG(GF_LOG_WARNING, ("Warning: -subdur parameter (%g s) should be greater than segment duration (%g s), using segment duration instead\n", dash_subduration, dash_duration));
dash_subduration = dash_duration;
}
if (dash_mode && dash_live)
M4_LOG(GF_LOG_INFO, ("Live DASH-ing - press 'q' to quit, 's' to save context and quit\n"));
if (!dash_ctx_file && dash_live) {
u32 r1;
u64 add = (u64) (intptr_t) &dasher;
add ^= gf_net_get_utc();
r1 = (u32) add ^ (u32) (add/0xFFFFFFFF);
r1 ^= gf_rand();
sprintf(szStateFile, "%s/dasher_%X.xml", gf_get_default_cache_directory(), r1 );
dash_ctx_file = szStateFile;
dyn_state_file = GF_TRUE;
} else if (dash_ctx_file) {
if (force_new)
gf_file_delete(dash_ctx_file);
}
if (dash_profile==GF_DASH_PROFILE_AUTO)
dash_profile = dash_mode ? GF_DASH_PROFILE_LIVE : GF_DASH_PROFILE_FULL;
if (!dash_mode) {
time_shift_depth = 0;
mpd_update_time = 0;
} else if ((dash_profile>=GF_DASH_PROFILE_MAIN) && !use_url_template && !mpd_update_time) {
/*use a default MPD update of dash_duration sec*/
mpd_update_time = (Double) (dash_subduration ? dash_subduration : dash_duration);
M4_LOG(GF_LOG_INFO, ("Using default MPD refresh of %g seconds\n", mpd_update_time));
}
if (file && do_save) {
gf_isom_close(file);
file = NULL;
del_file = GF_TRUE;
}
/*setup dash*/
dasher = gf_dasher_new(szMPD, dash_profile, NULL, dash_scale, dash_ctx_file);
if (!dasher) {
return mp4box_cleanup(1);
}
e = gf_dasher_set_info(dasher, dash_title, cprt, dash_more_info, dash_source, NULL);
if (e) {
M4_LOG(GF_LOG_ERROR, ("DASH Error: %s\n", gf_error_to_string(e)));
gf_dasher_del(dasher);
return e;
}
gf_dasher_set_start_date(dasher, dash_start_date);
gf_dasher_set_location(dasher, dash_source);
for (i=0; i < nb_mpd_base_urls; i++) {
e = gf_dasher_add_base_url(dasher, mpd_base_urls[i]);
if (e) {
M4_LOG(GF_LOG_ERROR, ("DASH Error: %s\n", gf_error_to_string(e)));
gf_dasher_del(dasher);
return e;
}
}
if (segment_timeline && !use_url_template) {
M4_LOG(GF_LOG_WARNING, ("DASH Warning: using -segment-timeline with no -url-template. Forcing URL template.\n"));
use_url_template = GF_TRUE;
}
e = gf_dasher_enable_url_template(dasher, (Bool) use_url_template, seg_name, seg_ext, init_seg_ext);
if (!e) e = gf_dasher_enable_segment_timeline(dasher, segment_timeline);
if (!e) e = gf_dasher_enable_single_segment(dasher, single_segment);
if (!e) e = gf_dasher_enable_single_file(dasher, single_file);
if (!e) e = gf_dasher_set_switch_mode(dasher, bitstream_switching_mode);
if (!e) e = gf_dasher_set_durations(dasher, dash_duration, interleaving_time, dash_subduration);
if (!e) e = gf_dasher_enable_rap_splitting(dasher, seg_at_rap, frag_at_rap);
if (!e) e = gf_dasher_set_segment_marker(dasher, segment_marker);
if (!e) e = gf_dasher_enable_sidx(dasher, (subsegs_per_sidx>=0) ? 1 : 0, (u32) subsegs_per_sidx, daisy_chain_sidx, use_ssix);
if (!e) e = gf_dasher_set_dynamic_mode(dasher, dash_mode, mpd_update_time, time_shift_depth, mpd_live_duration);
if (!e) e = gf_dasher_set_min_buffer(dasher, min_buffer);
if (!e) e = gf_dasher_set_ast_offset(dasher, ast_offset_ms);
if (!e) e = gf_dasher_enable_memory_fragmenting(dasher, memory_frags);
if (!e) e = gf_dasher_set_initial_isobmf(dasher, initial_moof_sn, initial_tfdt);
if (!e) e = gf_dasher_configure_isobmf_default(dasher, no_fragments_defaults, pssh_mode, samplegroups_in_traf, single_traf_per_moof, tfdt_per_traf, mvex_after_traks, sdtp_in_traf);
if (!e) e = gf_dasher_enable_utc_ref(dasher, insert_utc);
if (!e) e = gf_dasher_enable_real_time(dasher, frag_real_time);
if (!e) e = gf_dasher_set_content_protection_location_mode(dasher, cp_location_mode);
if (!e) e = gf_dasher_set_profile_extension(dasher, dash_profile_extension);
if (!e) e = gf_dasher_enable_cached_inputs(dasher, no_cache);
if (!e) e = gf_dasher_enable_loop_inputs(dasher, ! no_loop);
if (!e) e = gf_dasher_set_split_mode(dasher, dash_split_mode);
if (!e) e = gf_dasher_set_last_segment_merge(dasher, merge_last_seg);
if (!e) e = gf_dasher_set_hls_clock(dasher, hls_clock);
if (!e && dash_cues) e = gf_dasher_set_cues(dasher, dash_cues, strict_cues);
if (!e) e = gf_dasher_print_session_info(dasher, fs_dump_flags);
if (!e) e = gf_dasher_keep_source_utc(dasher, keep_utc);
for (i=0; i < nb_dash_inputs; i++) {
if (!e) e = gf_dasher_add_input(dasher, &dash_inputs[i]);
}
if (e) {
M4_LOG(GF_LOG_ERROR, ("DASH Setup Error: %s\n", gf_error_to_string(e)));
gf_dasher_del(dasher);
return e;
}
dash_cumulated_time=0;
while (1) {
if (run_for && (dash_cumulated_time >= run_for)) {
M4_LOG(GF_LOG_INFO, ("Done running, computing static MPD\n"));
do_abort = 3;
}
dash_prev_time=gf_sys_clock();
if (do_abort>=2) {
e = gf_dasher_set_dynamic_mode(dasher, GF_DASH_DYNAMIC_LAST, 0, time_shift_depth, mpd_live_duration);
}
if (!e) e = gf_dasher_process(dasher);
if (!dash_live && (e==GF_EOS) ) {
M4_LOG(GF_LOG_INFO, ("Nothing to dash, too early ...\n"));
e = GF_OK;
}
if (do_abort)
break;
//this happens when reading file while writing them (local playback of the live session ...)
if (dash_live && (e==GF_IO_ERR) ) {
M4_LOG(GF_LOG_WARNING, ("Error dashing file (%s) but continuing ...\n", gf_error_to_string(e) ));
e = GF_OK;
}
if (e) break;
if (dash_live) {
u64 ms_in_session=0;
u32 slept = gf_sys_clock();
u32 sleep_for = gf_dasher_next_update_time(dasher, &ms_in_session);
M4_LOG(GF_LOG_INFO, ("Next generation scheduled in %u ms (DASH time "LLU" ms)\r", sleep_for, ms_in_session));
if (run_for && (ms_in_session>=run_for)) {
dash_cumulated_time = 1+run_for;
continue;
}
while (1) {
if (gf_prompt_has_input()) {
char c = (char) gf_prompt_get_char();
if (c=='X') {
do_abort = 1;
break;
}
if (c=='q') {
do_abort = 2;
break;
}
if (c=='s') {
do_abort = 3;
break;
}
}
if (dash_mode == GF_DASH_DYNAMIC_DEBUG) {
break;
}
if (!sleep_for) break;
gf_sleep(sleep_for/10);
sleep_for = gf_dasher_next_update_time(dasher, NULL);
if (sleep_for<=1) {
dash_now_time=gf_sys_clock();
dash_cumulated_time+=(dash_now_time-dash_prev_time);
M4_LOG(GF_LOG_INFO, ("Slept for %d ms before generation, dash cumulated time %d\n", dash_now_time - slept, dash_cumulated_time));
break;
}
}
} else {
break;
}
}
gf_dasher_del(dasher);
if (!run_for && dash_ctx_file && (do_abort==3) && (dyn_state_file) && !gf_sys_is_test_mode() ) {
char szName[1024];
M4_LOG(GF_LOG_INFO, ("Enter file name to save dash context:\n"));
if (scanf("%1023s", szName) == 1) {
gf_file_move(dash_ctx_file, szName);
}
}
if (e) M4_LOG(GF_LOG_ERROR, ("Error DASHing file: %s\n", gf_error_to_string(e)));
if (file) gf_isom_delete(file);
if (del_file)
gf_file_delete(inName);
return e;
}
| 0
|
237,820
|
static int acurite_6045_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsigned row)
{
float tempf;
uint8_t humidity;
// uint8_t message_type, l_status;
char raw_str[31], *rawp;
uint16_t sensor_id;
uint8_t strike_count, strike_distance;
int battery_low, active, rfi_detect;
int exception = 0;
data_t *data;
int browlen = (bitbuffer->bits_per_row[row] + 7) / 8;
uint8_t *bb = bitbuffer->bb[row];
char const *channel_str = acurite_getChannel(bb[0]); // same as TXR
// Tower sensor ID is the last 14 bits of byte 0 and 1
// CCII IIII | IIII IIII
sensor_id = ((bb[0] & 0x3f) << 8) | bb[1]; // same as TXR
battery_low = (bb[2] & 0x40) == 0;
humidity = (bb[3] & 0x7f); // 1-99 %rH, same as TXR
active = (bb[4] & 0x40) == 0x40; // Sensor is actively listening for strikes
//message_type = bb[2] & 0x3f;
// 12 bits of temperature after removing parity and status bits.
// Message native format appears to be in 1/10 of a degree Fahrenheit
// Device Specification: -40 to 158 F / -40 to 70 C
// Available range given 12 bits with +1480 offset: -140.0 F to +261.5 F
int temp_raw = ((bb[4] & 0x1F) << 7) | (bb[5] & 0x7F);
tempf = (temp_raw - 1480) * 0.1f;
// Strike count is 8 bits, LSB in following byte
strike_count = ((bb[6] & 0x7f) << 1) | ((bb[7] & 0x40) >> 6);
strike_distance = bb[7] & 0x1f;
rfi_detect = (bb[7] & 0x20) == 0x20;
//l_status = (bb[7] & 0x60) >> 5;
/*
* 2018-04-21 rct - There are still a number of unknown bits in the
* message that need to be figured out. Add the raw message hex to
* to the structured data output to allow future analysis without
* having to enable debug for long running rtl_433 processes.
*/
rawp = (char *)raw_str;
for (int i=0; i < MIN(browlen, 15); i++) {
sprintf(rawp,"%02x",bb[i]);
rawp += 2;
}
*rawp = '\0';
// Flag whether this message might need further analysis
if (((bb[4] & 0x20) != 0) || // unknown status bits, always off
(humidity > 100) ||
(tempf > 158) ||
(tempf < -40)) {
exception++;
}
/* clang-format off */
data = data_make(
"model", "", DATA_STRING, "Acurite-6045M",
"id", NULL, DATA_INT, sensor_id,
"channel", NULL, DATA_STRING, channel_str,
"battery_ok", "Battery", DATA_INT, !battery_low,
"temperature_F", "temperature", DATA_FORMAT, "%.1f F", DATA_DOUBLE, tempf,
"humidity", "humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
"strike_count", "strike_count", DATA_INT, strike_count,
"storm_dist", "storm_distance", DATA_INT, strike_distance,
"active", "active_mode", DATA_INT, active, // @todo convert to bool
"rfi", "rfi_detect", DATA_INT, rfi_detect, // @todo convert to bool
"exception", "data_exception", DATA_INT, exception, // @todo convert to bool
"raw_msg", "raw_message", DATA_STRING, raw_str,
NULL);
/* clang-format on */
decoder_output_data(decoder, data);
return 1;
}
| 0
|
435,409
|
jetp3852_print_page(gx_device_printer *pdev, gp_file *prn_stream)
{
#define DATA_SIZE (LINE_SIZE * 8)
unsigned int cnt_2prn;
unsigned int count,tempcnt;
unsigned char vtp,cntc1,cntc2;
int line_size_color_plane;
byte data[DATA_SIZE];
byte plane_data[LINE_SIZE * 3];
/* Initialise data to zeros, otherwise later on, uninitialised bytes in
dp[] can be greater than 7, which breaks spr8[dp[]]. */
memset(data, 0x00, DATA_SIZE);
/* Set initial condition for printer */
gp_fputs("\033@",prn_stream);
/* Send each scan line in turn */
{
int lnum;
int line_size = gdev_mem_bytes_per_scan_line((gx_device *)pdev);
int num_blank_lines = 0;
if (line_size > DATA_SIZE) {
emprintf2(pdev->memory, "invalid resolution and/or width gives line_size = %d, max. is %d\n",
line_size, DATA_SIZE);
return_error(gs_error_rangecheck);
}
for ( lnum = 0; lnum < pdev->height; lnum++ ) {
byte *end_data = data + line_size;
gdev_prn_copy_scan_lines(pdev, lnum,
(byte *)data, line_size);
/* Remove trailing 0s. */
while ( end_data > data && end_data[-1] == 0 )
end_data--;
if ( end_data == data ) {
/* Blank line */
num_blank_lines++;
} else {
int i;
byte *odp;
byte *row;
/* Transpose the data to get pixel planes. */
for ( i = 0, odp = plane_data; i < DATA_SIZE;
i += 8, odp++
) { /* The following is for 16-bit machines */
#define spread3(c)\
{ 0, c, c*0x100, c*0x101, c*0x10000L, c*0x10001L, c*0x10100L, c*0x10101L }
static ulong spr40[8] = spread3(0x40);
static ulong spr8[8] = spread3(8);
static ulong spr2[8] = spread3(2);
register byte *dp = data + i;
register ulong pword =
(spr40[dp[0]] << 1) +
(spr40[dp[1]]) +
(spr40[dp[2]] >> 1) +
(spr8[dp[3]] << 1) +
(spr8[dp[4]]) +
(spr8[dp[5]] >> 1) +
(spr2[dp[6]]) +
(spr2[dp[7]] >> 1);
odp[0] = (byte)(pword >> 16);
odp[LINE_SIZE] = (byte)(pword >> 8);
odp[LINE_SIZE*2] = (byte)(pword);
}
/* Skip blank lines if any */
if ( num_blank_lines > 0 ) {
/* Do "dot skips" */
while(num_blank_lines > 255) {
gp_fputs("\033e\377",prn_stream);
num_blank_lines -= 255;
}
vtp = num_blank_lines;
gp_fprintf(prn_stream,"\033e%c",vtp);
num_blank_lines = 0;
}
/* Transfer raster graphics in the order R, G, B. */
/* Apparently it is stored in B, G, R */
/* Calculate the amount of data to send by what */
/* Ghostscript tells us the scan line_size in (bytes) */
count = line_size / 3;
line_size_color_plane = count / 3;
cnt_2prn = line_size_color_plane * 3 + 5;
tempcnt = cnt_2prn;
cntc1 = (tempcnt & 0xFF00) >> 8;
cntc2 = (tempcnt & 0x00FF);
gp_fprintf(prn_stream, "\033[O%c%c\200\037",cntc2,cntc1);
gp_fputc('\000',prn_stream);
gp_fputs("\124\124",prn_stream);
for ( row = plane_data + LINE_SIZE * 2, i = 0;
i < 3; row -= LINE_SIZE, i++ ) {
int jj;
byte ctemp;
odp = row;
/* Complement bytes */
for (jj=0; jj< line_size_color_plane; jj++) {
ctemp = *odp;
*odp++ = ~ctemp;
}
gp_fwrite(row, sizeof(byte),
line_size_color_plane, prn_stream);
}
}
}
}
/* eject page */
gp_fputs("\014", prn_stream);
return 0;
}
| 0
|
459,123
|
static void tcf_proto_put(struct tcf_proto *tp, bool rtnl_held,
struct netlink_ext_ack *extack)
{
if (refcount_dec_and_test(&tp->refcnt))
tcf_proto_destroy(tp, rtnl_held, true, extack);
}
| 0
|
316,984
|
static int selinux_tun_dev_attach(struct sock *sk, void *security)
{
struct tun_security_struct *tunsec = security;
struct sk_security_struct *sksec = sk->sk_security;
/* we don't currently perform any NetLabel based labeling here and it
* isn't clear that we would want to do so anyway; while we could apply
* labeling without the support of the TUN user the resulting labeled
* traffic from the other end of the connection would almost certainly
* cause confusion to the TUN user that had no idea network labeling
* protocols were being used */
sksec->sid = tunsec->sid;
sksec->sclass = SECCLASS_TUN_SOCKET;
return 0;
}
| 0
|
221,426
|
static void svm_inject_page_fault_nested(struct kvm_vcpu *vcpu, struct x86_exception *fault)
{
struct vcpu_svm *svm = to_svm(vcpu);
WARN_ON(!is_guest_mode(vcpu));
if (vmcb_is_intercept(&svm->nested.ctl, INTERCEPT_EXCEPTION_OFFSET + PF_VECTOR) &&
!svm->nested.nested_run_pending) {
svm->vmcb->control.exit_code = SVM_EXIT_EXCP_BASE + PF_VECTOR;
svm->vmcb->control.exit_code_hi = 0;
svm->vmcb->control.exit_info_1 = fault->error_code;
svm->vmcb->control.exit_info_2 = fault->address;
nested_svm_vmexit(svm);
} else {
kvm_inject_page_fault(vcpu, fault);
}
}
| 0
|
235,253
|
static bool test_write(struct torture_context *tctx,
struct smbcli_state *cli)
{
union smb_write io;
NTSTATUS status;
bool ret = true;
int fnum;
uint8_t *buf;
const int maxsize = 90000;
const char *fname = BASEDIR "\\test.txt";
unsigned int seed = time(NULL);
union smb_fileinfo finfo;
buf = talloc_zero_array(tctx, uint8_t, maxsize);
if (!torture_setup_dir(cli, BASEDIR)) {
torture_fail(tctx, "failed to setup basedir");
}
torture_comment(tctx, "Testing RAW_WRITE_WRITE\n");
io.generic.level = RAW_WRITE_WRITE;
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
ret = false;
torture_fail_goto(tctx, done,
talloc_asprintf(tctx, "Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)));
}
torture_comment(tctx, "Trying zero write\n");
io.write.in.file.fnum = fnum;
io.write.in.count = 0;
io.write.in.offset = 0;
io.write.in.remaining = 0;
io.write.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.write.out.nwritten, 0);
setup_buffer(buf, seed, maxsize);
torture_comment(tctx, "Trying small write\n");
io.write.in.count = 9;
io.write.in.offset = 4;
io.write.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.write.out.nwritten, io.write.in.count);
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) {
ret = false;
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
}
CHECK_BUFFER(buf+4, seed, 9);
CHECK_VALUE(IVAL(buf,0), 0);
setup_buffer(buf, seed, maxsize);
torture_comment(tctx, "Trying large write\n");
io.write.in.count = 4000;
io.write.in.offset = 0;
io.write.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.write.out.nwritten, 4000);
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) {
ret = false;
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
}
CHECK_BUFFER(buf, seed, 4000);
torture_comment(tctx, "Trying bad fnum\n");
io.write.in.file.fnum = fnum+1;
io.write.in.count = 4000;
io.write.in.offset = 0;
io.write.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
torture_comment(tctx, "Setting file as sparse\n");
status = torture_set_sparse(cli->tree, fnum);
CHECK_STATUS(status, NT_STATUS_OK);
if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
torture_comment(tctx, "skipping large file tests - CAP_LARGE_FILES not set\n");
goto done;
}
torture_comment(tctx, "Trying 2^32 offset\n");
setup_buffer(buf, seed, maxsize);
io.write.in.file.fnum = fnum;
io.write.in.count = 4000;
io.write.in.offset = 0xFFFFFFFF - 2000;
io.write.in.data = buf;
status = smb_raw_write(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.write.out.nwritten, 4000);
CHECK_ALL_INFO(io.write.in.count + (uint64_t)io.write.in.offset, size);
memset(buf, 0, maxsize);
if (smbcli_read(cli->tree, fnum, buf, io.write.in.offset, 4000) != 4000) {
ret = false;
torture_fail_goto(tctx, done, talloc_asprintf(tctx, "read failed at %s\n", __location__));
}
CHECK_BUFFER(buf, seed, 4000);
done:
smbcli_close(cli->tree, fnum);
smb_raw_exit(cli->session);
smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
| 0
|
450,377
|
static void vnc_dpy_switch(DisplayChangeListener *dcl,
DisplaySurface *surface)
{
static const char placeholder_msg[] =
"Display output is not active.";
static DisplaySurface *placeholder;
VncDisplay *vd = container_of(dcl, VncDisplay, dcl);
bool pageflip = vnc_check_pageflip(vd->ds, surface);
VncState *vs;
if (surface == NULL) {
if (placeholder == NULL) {
placeholder = qemu_create_message_surface(640, 480, placeholder_msg);
}
surface = placeholder;
}
vnc_abort_display_jobs(vd);
vd->ds = surface;
/* guest surface */
qemu_pixman_image_unref(vd->guest.fb);
vd->guest.fb = pixman_image_ref(surface->image);
vd->guest.format = surface->format;
if (pageflip) {
vnc_set_area_dirty(vd->guest.dirty, vd, 0, 0,
surface_width(surface),
surface_height(surface));
return;
}
/* server surface */
vnc_update_server_surface(vd);
QTAILQ_FOREACH(vs, &vd->clients, next) {
vnc_colordepth(vs);
vnc_desktop_resize(vs);
if (vs->vd->cursor) {
vnc_cursor_define(vs);
}
memset(vs->dirty, 0x00, sizeof(vs->dirty));
vnc_set_area_dirty(vs->dirty, vd, 0, 0,
vnc_width(vd),
vnc_height(vd));
vnc_update_throttle_offset(vs);
}
}
| 0
|
484,776
|
static struct sk_buff *xennet_get_rx_skb(struct netfront_queue *queue,
RING_IDX ri)
{
int i = xennet_rxidx(ri);
struct sk_buff *skb = queue->rx_skbs[i];
queue->rx_skbs[i] = NULL;
return skb;
}
| 0
|
208,421
|
ex_diffgetput(exarg_T *eap)
{
linenr_T lnum;
int count;
linenr_T off = 0;
diff_T *dp;
diff_T *dprev;
diff_T *dfree;
int idx_cur;
int idx_other;
int idx_from;
int idx_to;
int i;
int added;
char_u *p;
aco_save_T aco;
buf_T *buf;
int start_skip, end_skip;
int new_count;
int buf_empty;
int found_not_ma = FALSE;
// Find the current buffer in the list of diff buffers.
idx_cur = diff_buf_idx(curbuf);
if (idx_cur == DB_COUNT)
{
emsg(_(e_current_buffer_is_not_in_diff_mode));
return;
}
if (*eap->arg == NUL)
{
// No argument: Find the other buffer in the list of diff buffers.
for (idx_other = 0; idx_other < DB_COUNT; ++idx_other)
if (curtab->tp_diffbuf[idx_other] != curbuf
&& curtab->tp_diffbuf[idx_other] != NULL)
{
if (eap->cmdidx != CMD_diffput
|| curtab->tp_diffbuf[idx_other]->b_p_ma)
break;
found_not_ma = TRUE;
}
if (idx_other == DB_COUNT)
{
if (found_not_ma)
emsg(_(e_no_other_buffer_in_diff_mode_is_modifiable));
else
emsg(_(e_no_other_buffer_in_diff_mode));
return;
}
// Check that there isn't a third buffer in the list
for (i = idx_other + 1; i < DB_COUNT; ++i)
if (curtab->tp_diffbuf[i] != curbuf
&& curtab->tp_diffbuf[i] != NULL
&& (eap->cmdidx != CMD_diffput || curtab->tp_diffbuf[i]->b_p_ma))
{
emsg(_(e_more_than_two_buffers_in_diff_mode_dont_know_which_one_to_use));
return;
}
}
else
{
// Buffer number or pattern given. Ignore trailing white space.
p = eap->arg + STRLEN(eap->arg);
while (p > eap->arg && VIM_ISWHITE(p[-1]))
--p;
for (i = 0; vim_isdigit(eap->arg[i]) && eap->arg + i < p; ++i)
;
if (eap->arg + i == p) // digits only
i = atol((char *)eap->arg);
else
{
i = buflist_findpat(eap->arg, p, FALSE, TRUE, FALSE);
if (i < 0)
return; // error message already given
}
buf = buflist_findnr(i);
if (buf == NULL)
{
semsg(_(e_cant_find_buffer_str), eap->arg);
return;
}
if (buf == curbuf)
return; // nothing to do
idx_other = diff_buf_idx(buf);
if (idx_other == DB_COUNT)
{
semsg(_(e_buffer_str_is_not_in_diff_mode), eap->arg);
return;
}
}
diff_busy = TRUE;
// When no range given include the line above or below the cursor.
if (eap->addr_count == 0)
{
// Make it possible that ":diffget" on the last line gets line below
// the cursor line when there is no difference above the cursor.
if (eap->cmdidx == CMD_diffget
&& eap->line1 == curbuf->b_ml.ml_line_count
&& diff_check(curwin, eap->line1) == 0
&& (eap->line1 == 1 || diff_check(curwin, eap->line1 - 1) == 0))
++eap->line2;
else if (eap->line1 > 0)
--eap->line1;
}
if (eap->cmdidx == CMD_diffget)
{
idx_from = idx_other;
idx_to = idx_cur;
}
else
{
idx_from = idx_cur;
idx_to = idx_other;
// Need to make the other buffer the current buffer to be able to make
// changes in it.
// set curwin/curbuf to buf and save a few things
aucmd_prepbuf(&aco, curtab->tp_diffbuf[idx_other]);
}
// May give the warning for a changed buffer here, which can trigger the
// FileChangedRO autocommand, which may do nasty things and mess
// everything up.
if (!curbuf->b_changed)
{
change_warning(0);
if (diff_buf_idx(curbuf) != idx_to)
{
emsg(_(e_buffer_changed_unexpectedly));
goto theend;
}
}
dprev = NULL;
for (dp = curtab->tp_first_diff; dp != NULL; )
{
if (dp->df_lnum[idx_cur] > eap->line2 + off)
break; // past the range that was specified
dfree = NULL;
lnum = dp->df_lnum[idx_to];
count = dp->df_count[idx_to];
if (dp->df_lnum[idx_cur] + dp->df_count[idx_cur] > eap->line1 + off
&& u_save(lnum - 1, lnum + count) != FAIL)
{
// Inside the specified range and saving for undo worked.
start_skip = 0;
end_skip = 0;
if (eap->addr_count > 0)
{
// A range was specified: check if lines need to be skipped.
start_skip = eap->line1 + off - dp->df_lnum[idx_cur];
if (start_skip > 0)
{
// range starts below start of current diff block
if (start_skip > count)
{
lnum += count;
count = 0;
}
else
{
count -= start_skip;
lnum += start_skip;
}
}
else
start_skip = 0;
end_skip = dp->df_lnum[idx_cur] + dp->df_count[idx_cur] - 1
- (eap->line2 + off);
if (end_skip > 0)
{
// range ends above end of current/from diff block
if (idx_cur == idx_from) // :diffput
{
i = dp->df_count[idx_cur] - start_skip - end_skip;
if (count > i)
count = i;
}
else // :diffget
{
count -= end_skip;
end_skip = dp->df_count[idx_from] - start_skip - count;
if (end_skip < 0)
end_skip = 0;
}
}
else
end_skip = 0;
}
buf_empty = BUFEMPTY();
added = 0;
for (i = 0; i < count; ++i)
{
// remember deleting the last line of the buffer
buf_empty = curbuf->b_ml.ml_line_count == 1;
ml_delete(lnum);
--added;
}
for (i = 0; i < dp->df_count[idx_from] - start_skip - end_skip; ++i)
{
linenr_T nr;
nr = dp->df_lnum[idx_from] + start_skip + i;
if (nr > curtab->tp_diffbuf[idx_from]->b_ml.ml_line_count)
break;
p = vim_strsave(ml_get_buf(curtab->tp_diffbuf[idx_from],
nr, FALSE));
if (p != NULL)
{
ml_append(lnum + i - 1, p, 0, FALSE);
vim_free(p);
++added;
if (buf_empty && curbuf->b_ml.ml_line_count == 2)
{
// Added the first line into an empty buffer, need to
// delete the dummy empty line.
buf_empty = FALSE;
ml_delete((linenr_T)2);
}
}
}
new_count = dp->df_count[idx_to] + added;
dp->df_count[idx_to] = new_count;
if (start_skip == 0 && end_skip == 0)
{
// Check if there are any other buffers and if the diff is
// equal in them.
for (i = 0; i < DB_COUNT; ++i)
if (curtab->tp_diffbuf[i] != NULL && i != idx_from
&& i != idx_to
&& !diff_equal_entry(dp, idx_from, i))
break;
if (i == DB_COUNT)
{
// delete the diff entry, the buffers are now equal here
dfree = dp;
dp = dp->df_next;
if (dprev == NULL)
curtab->tp_first_diff = dp;
else
dprev->df_next = dp;
}
}
// Adjust marks. This will change the following entries!
if (added != 0)
{
mark_adjust(lnum, lnum + count - 1, (long)MAXLNUM, (long)added);
if (curwin->w_cursor.lnum >= lnum)
{
// Adjust the cursor position if it's in/after the changed
// lines.
if (curwin->w_cursor.lnum >= lnum + count)
curwin->w_cursor.lnum += added;
else if (added < 0)
curwin->w_cursor.lnum = lnum;
}
}
changed_lines(lnum, 0, lnum + count, (long)added);
if (dfree != NULL)
{
// Diff is deleted, update folds in other windows.
#ifdef FEAT_FOLDING
diff_fold_update(dfree, idx_to);
#endif
vim_free(dfree);
}
else
// mark_adjust() may have changed the count in a wrong way
dp->df_count[idx_to] = new_count;
// When changing the current buffer, keep track of line numbers
if (idx_cur == idx_to)
off += added;
}
// If before the range or not deleted, go to next diff.
if (dfree == NULL)
{
dprev = dp;
dp = dp->df_next;
}
}
// restore curwin/curbuf and a few other things
if (eap->cmdidx != CMD_diffget)
{
// Syncing undo only works for the current buffer, but we change
// another buffer. Sync undo if the command was typed. This isn't
// 100% right when ":diffput" is used in a function or mapping.
if (KeyTyped)
u_sync(FALSE);
aucmd_restbuf(&aco);
}
theend:
diff_busy = FALSE;
if (diff_need_update)
ex_diffupdate(NULL);
// Check that the cursor is on a valid character and update its
// position. When there were filler lines the topline has become
// invalid.
check_cursor();
changed_line_abv_curs();
if (diff_need_update)
// redraw already done by ex_diffupdate()
diff_need_update = FALSE;
else
{
// Also need to redraw the other buffers.
diff_redraw(FALSE);
apply_autocmds(EVENT_DIFFUPDATED, NULL, NULL, FALSE, curbuf);
}
}
| 1
|
369,194
|
static inline void __io_req_set_refcount(struct io_kiocb *req, int nr)
{
if (!(req->flags & REQ_F_REFCOUNT)) {
req->flags |= REQ_F_REFCOUNT;
atomic_set(&req->refs, nr);
}
}
| 0
|
328,941
|
R_API RBinJavaAttrInfo *r_bin_java_rtvp_annotations_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {
ut32 i = 0;
RBinJavaAttrInfo *attr = NULL;
ut64 offset = 0;
attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);
offset += 6;
RBinJavaAnnotationsArray *annotation_array;
if (attr) {
attr->type = R_BIN_JAVA_ATTR_TYPE_RUNTIME_VISIBLE_PARAMETER_ANNOTATION_ATTR;
attr->info.rtvp_annotations_attr.num_parameters = buffer[offset];
offset += 1;
attr->info.rtvp_annotations_attr.parameter_annotations = r_list_newf (r_bin_java_annotation_array_free);
for (i = 0; i < attr->info.rtvp_annotations_attr.num_parameters; i++) {
if (offset > sz) {
break;
}
annotation_array = r_bin_java_annotation_array_new (buffer + offset, sz - offset, buf_offset + offset);
if (annotation_array) {
offset += annotation_array->size;
}
r_list_append (attr->info.rtvp_annotations_attr.parameter_annotations, (void *) annotation_array);
}
attr->size = offset;
}
return attr;
}
| 0
|
294,525
|
date_s_ordinal(int argc, VALUE *argv, VALUE klass)
{
VALUE vy, vd, vsg, y, fr, fr2, ret;
int d;
double sg;
rb_scan_args(argc, argv, "03", &vy, &vd, &vsg);
y = INT2FIX(-4712);
d = 1;
fr2 = INT2FIX(0);
sg = DEFAULT_SG;
switch (argc) {
case 3:
val2sg(vsg, sg);
case 2:
check_numeric(vd, "yday");
num2int_with_frac(d, positive_inf);
case 1:
check_numeric(vy, "year");
y = vy;
}
{
VALUE nth;
int ry, rd, rjd, ns;
if (!valid_ordinal_p(y, d, sg,
&nth, &ry,
&rd, &rjd,
&ns))
rb_raise(eDateError, "invalid date");
ret = d_simple_new_internal(klass,
nth, rjd,
sg,
0, 0, 0,
HAVE_JD);
}
add_frac();
return ret;
}
| 0
|
245,196
|
is_update_query(const char *query)
{
const char *query_list[] = {"insert", "update", "delete", "replace",
"alter", "load", NULL};
return is_query_from_list(query, query_list);
}
| 0
|
201,885
|
regmatch(
char_u *scan, // Current node.
proftime_T *tm UNUSED, // timeout limit or NULL
int *timed_out UNUSED) // flag set on timeout or NULL
{
char_u *next; // Next node.
int op;
int c;
regitem_T *rp;
int no;
int status; // one of the RA_ values:
#ifdef FEAT_RELTIME
int tm_count = 0;
#endif
// Make "regstack" and "backpos" empty. They are allocated and freed in
// bt_regexec_both() to reduce malloc()/free() calls.
regstack.ga_len = 0;
backpos.ga_len = 0;
// Repeat until "regstack" is empty.
for (;;)
{
// Some patterns may take a long time to match, e.g., "\([a-z]\+\)\+Q".
// Allow interrupting them with CTRL-C.
fast_breakcheck();
#ifdef DEBUG
if (scan != NULL && regnarrate)
{
mch_errmsg((char *)regprop(scan));
mch_errmsg("(\n");
}
#endif
// Repeat for items that can be matched sequentially, without using the
// regstack.
for (;;)
{
if (got_int || scan == NULL)
{
status = RA_FAIL;
break;
}
#ifdef FEAT_RELTIME
// Check for timeout once in a 100 times to avoid overhead.
if (tm != NULL && ++tm_count == 100)
{
tm_count = 0;
if (profile_passed_limit(tm))
{
if (timed_out != NULL)
*timed_out = TRUE;
status = RA_FAIL;
break;
}
}
#endif
status = RA_CONT;
#ifdef DEBUG
if (regnarrate)
{
mch_errmsg((char *)regprop(scan));
mch_errmsg("...\n");
# ifdef FEAT_SYN_HL
if (re_extmatch_in != NULL)
{
int i;
mch_errmsg(_("External submatches:\n"));
for (i = 0; i < NSUBEXP; i++)
{
mch_errmsg(" \"");
if (re_extmatch_in->matches[i] != NULL)
mch_errmsg((char *)re_extmatch_in->matches[i]);
mch_errmsg("\"\n");
}
}
# endif
}
#endif
next = regnext(scan);
op = OP(scan);
// Check for character class with NL added.
if (!rex.reg_line_lbr && WITH_NL(op) && REG_MULTI
&& *rex.input == NUL && rex.lnum <= rex.reg_maxline)
{
reg_nextline();
}
else if (rex.reg_line_lbr && WITH_NL(op) && *rex.input == '\n')
{
ADVANCE_REGINPUT();
}
else
{
if (WITH_NL(op))
op -= ADD_NL;
if (has_mbyte)
c = (*mb_ptr2char)(rex.input);
else
c = *rex.input;
switch (op)
{
case BOL:
if (rex.input != rex.line)
status = RA_NOMATCH;
break;
case EOL:
if (c != NUL)
status = RA_NOMATCH;
break;
case RE_BOF:
// We're not at the beginning of the file when below the first
// line where we started, not at the start of the line or we
// didn't start at the first line of the buffer.
if (rex.lnum != 0 || rex.input != rex.line
|| (REG_MULTI && rex.reg_firstlnum > 1))
status = RA_NOMATCH;
break;
case RE_EOF:
if (rex.lnum != rex.reg_maxline || c != NUL)
status = RA_NOMATCH;
break;
case CURSOR:
// Check if the buffer is in a window and compare the
// rex.reg_win->w_cursor position to the match position.
if (rex.reg_win == NULL
|| (rex.lnum + rex.reg_firstlnum
!= rex.reg_win->w_cursor.lnum)
|| ((colnr_T)(rex.input - rex.line)
!= rex.reg_win->w_cursor.col))
status = RA_NOMATCH;
break;
case RE_MARK:
// Compare the mark position to the match position.
{
int mark = OPERAND(scan)[0];
int cmp = OPERAND(scan)[1];
pos_T *pos;
pos = getmark_buf(rex.reg_buf, mark, FALSE);
if (pos == NULL // mark doesn't exist
|| pos->lnum <= 0) // mark isn't set in reg_buf
{
status = RA_NOMATCH;
}
else
{
colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum
&& pos->col == MAXCOL
? (colnr_T)STRLEN(reg_getline(
pos->lnum - rex.reg_firstlnum))
: pos->col;
if ((pos->lnum == rex.lnum + rex.reg_firstlnum
? (pos_col == (colnr_T)(rex.input - rex.line)
? (cmp == '<' || cmp == '>')
: (pos_col < (colnr_T)(rex.input - rex.line)
? cmp != '>'
: cmp != '<'))
: (pos->lnum < rex.lnum + rex.reg_firstlnum
? cmp != '>'
: cmp != '<')))
status = RA_NOMATCH;
}
}
break;
case RE_VISUAL:
if (!reg_match_visual())
status = RA_NOMATCH;
break;
case RE_LNUM:
if (!REG_MULTI || !re_num_cmp((long_u)(rex.lnum + rex.reg_firstlnum),
scan))
status = RA_NOMATCH;
break;
case RE_COL:
if (!re_num_cmp((long_u)(rex.input - rex.line) + 1, scan))
status = RA_NOMATCH;
break;
case RE_VCOL:
if (!re_num_cmp((long_u)win_linetabsize(
rex.reg_win == NULL ? curwin : rex.reg_win,
rex.line, (colnr_T)(rex.input - rex.line)) + 1, scan))
status = RA_NOMATCH;
break;
case BOW: // \<word; rex.input points to w
if (c == NUL) // Can't match at end of line
status = RA_NOMATCH;
else if (has_mbyte)
{
int this_class;
// Get class of current and previous char (if it exists).
this_class = mb_get_class_buf(rex.input, rex.reg_buf);
if (this_class <= 1)
status = RA_NOMATCH; // not on a word at all
else if (reg_prev_class() == this_class)
status = RA_NOMATCH; // previous char is in same word
}
else
{
if (!vim_iswordc_buf(c, rex.reg_buf) || (rex.input > rex.line
&& vim_iswordc_buf(rex.input[-1], rex.reg_buf)))
status = RA_NOMATCH;
}
break;
case EOW: // word\>; rex.input points after d
if (rex.input == rex.line) // Can't match at start of line
status = RA_NOMATCH;
else if (has_mbyte)
{
int this_class, prev_class;
// Get class of current and previous char (if it exists).
this_class = mb_get_class_buf(rex.input, rex.reg_buf);
prev_class = reg_prev_class();
if (this_class == prev_class
|| prev_class == 0 || prev_class == 1)
status = RA_NOMATCH;
}
else
{
if (!vim_iswordc_buf(rex.input[-1], rex.reg_buf)
|| (rex.input[0] != NUL
&& vim_iswordc_buf(c, rex.reg_buf)))
status = RA_NOMATCH;
}
break; // Matched with EOW
case ANY:
// ANY does not match new lines.
if (c == NUL)
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case IDENT:
if (!vim_isIDc(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case SIDENT:
if (VIM_ISDIGIT(*rex.input) || !vim_isIDc(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case KWORD:
if (!vim_iswordp_buf(rex.input, rex.reg_buf))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case SKWORD:
if (VIM_ISDIGIT(*rex.input)
|| !vim_iswordp_buf(rex.input, rex.reg_buf))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case FNAME:
if (!vim_isfilec(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case SFNAME:
if (VIM_ISDIGIT(*rex.input) || !vim_isfilec(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case PRINT:
if (!vim_isprintc(PTR2CHAR(rex.input)))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case SPRINT:
if (VIM_ISDIGIT(*rex.input) || !vim_isprintc(PTR2CHAR(rex.input)))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case WHITE:
if (!VIM_ISWHITE(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case NWHITE:
if (c == NUL || VIM_ISWHITE(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case DIGIT:
if (!ri_digit(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case NDIGIT:
if (c == NUL || ri_digit(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case HEX:
if (!ri_hex(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case NHEX:
if (c == NUL || ri_hex(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case OCTAL:
if (!ri_octal(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case NOCTAL:
if (c == NUL || ri_octal(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case WORD:
if (!ri_word(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case NWORD:
if (c == NUL || ri_word(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case HEAD:
if (!ri_head(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case NHEAD:
if (c == NUL || ri_head(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case ALPHA:
if (!ri_alpha(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case NALPHA:
if (c == NUL || ri_alpha(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case LOWER:
if (!ri_lower(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case NLOWER:
if (c == NUL || ri_lower(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case UPPER:
if (!ri_upper(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case NUPPER:
if (c == NUL || ri_upper(c))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case EXACTLY:
{
int len;
char_u *opnd;
opnd = OPERAND(scan);
// Inline the first byte, for speed.
if (*opnd != *rex.input
&& (!rex.reg_ic
|| (!enc_utf8
&& MB_TOLOWER(*opnd) != MB_TOLOWER(*rex.input))))
status = RA_NOMATCH;
else if (*opnd == NUL)
{
// match empty string always works; happens when "~" is
// empty.
}
else
{
if (opnd[1] == NUL && !(enc_utf8 && rex.reg_ic))
{
len = 1; // matched a single byte above
}
else
{
// Need to match first byte again for multi-byte.
len = (int)STRLEN(opnd);
if (cstrncmp(opnd, rex.input, &len) != 0)
status = RA_NOMATCH;
}
// Check for following composing character, unless %C
// follows (skips over all composing chars).
if (status != RA_NOMATCH
&& enc_utf8
&& UTF_COMPOSINGLIKE(rex.input, rex.input + len)
&& !rex.reg_icombine
&& OP(next) != RE_COMPOSING)
{
// raaron: This code makes a composing character get
// ignored, which is the correct behavior (sometimes)
// for voweled Hebrew texts.
status = RA_NOMATCH;
}
if (status != RA_NOMATCH)
rex.input += len;
}
}
break;
case ANYOF:
case ANYBUT:
if (c == NUL)
status = RA_NOMATCH;
else if ((cstrchr(OPERAND(scan), c) == NULL) == (op == ANYOF))
status = RA_NOMATCH;
else
ADVANCE_REGINPUT();
break;
case MULTIBYTECODE:
if (has_mbyte)
{
int i, len;
char_u *opnd;
int opndc = 0, inpc;
opnd = OPERAND(scan);
// Safety check (just in case 'encoding' was changed since
// compiling the program).
if ((len = (*mb_ptr2len)(opnd)) < 2)
{
status = RA_NOMATCH;
break;
}
if (enc_utf8)
opndc = utf_ptr2char(opnd);
if (enc_utf8 && utf_iscomposing(opndc))
{
// When only a composing char is given match at any
// position where that composing char appears.
status = RA_NOMATCH;
for (i = 0; rex.input[i] != NUL;
i += utf_ptr2len(rex.input + i))
{
inpc = utf_ptr2char(rex.input + i);
if (!utf_iscomposing(inpc))
{
if (i > 0)
break;
}
else if (opndc == inpc)
{
// Include all following composing chars.
len = i + utfc_ptr2len(rex.input + i);
status = RA_MATCH;
break;
}
}
}
else
for (i = 0; i < len; ++i)
if (opnd[i] != rex.input[i])
{
status = RA_NOMATCH;
break;
}
rex.input += len;
}
else
status = RA_NOMATCH;
break;
case RE_COMPOSING:
if (enc_utf8)
{
// Skip composing characters.
while (utf_iscomposing(utf_ptr2char(rex.input)))
MB_CPTR_ADV(rex.input);
}
break;
case NOTHING:
break;
case BACK:
{
int i;
backpos_T *bp;
// When we run into BACK we need to check if we don't keep
// looping without matching any input. The second and later
// times a BACK is encountered it fails if the input is still
// at the same position as the previous time.
// The positions are stored in "backpos" and found by the
// current value of "scan", the position in the RE program.
bp = (backpos_T *)backpos.ga_data;
for (i = 0; i < backpos.ga_len; ++i)
if (bp[i].bp_scan == scan)
break;
if (i == backpos.ga_len)
{
// First time at this BACK, make room to store the pos.
if (ga_grow(&backpos, 1) == FAIL)
status = RA_FAIL;
else
{
// get "ga_data" again, it may have changed
bp = (backpos_T *)backpos.ga_data;
bp[i].bp_scan = scan;
++backpos.ga_len;
}
}
else if (reg_save_equal(&bp[i].bp_pos))
// Still at same position as last time, fail.
status = RA_NOMATCH;
if (status != RA_FAIL && status != RA_NOMATCH)
reg_save(&bp[i].bp_pos, &backpos);
}
break;
case MOPEN + 0: // Match start: \zs
case MOPEN + 1: // \(
case MOPEN + 2:
case MOPEN + 3:
case MOPEN + 4:
case MOPEN + 5:
case MOPEN + 6:
case MOPEN + 7:
case MOPEN + 8:
case MOPEN + 9:
{
no = op - MOPEN;
cleanup_subexpr();
rp = regstack_push(RS_MOPEN, scan);
if (rp == NULL)
status = RA_FAIL;
else
{
rp->rs_no = no;
save_se(&rp->rs_un.sesave, &rex.reg_startpos[no],
&rex.reg_startp[no]);
// We simply continue and handle the result when done.
}
}
break;
case NOPEN: // \%(
case NCLOSE: // \) after \%(
if (regstack_push(RS_NOPEN, scan) == NULL)
status = RA_FAIL;
// We simply continue and handle the result when done.
break;
#ifdef FEAT_SYN_HL
case ZOPEN + 1:
case ZOPEN + 2:
case ZOPEN + 3:
case ZOPEN + 4:
case ZOPEN + 5:
case ZOPEN + 6:
case ZOPEN + 7:
case ZOPEN + 8:
case ZOPEN + 9:
{
no = op - ZOPEN;
cleanup_zsubexpr();
rp = regstack_push(RS_ZOPEN, scan);
if (rp == NULL)
status = RA_FAIL;
else
{
rp->rs_no = no;
save_se(&rp->rs_un.sesave, ®_startzpos[no],
®_startzp[no]);
// We simply continue and handle the result when done.
}
}
break;
#endif
case MCLOSE + 0: // Match end: \ze
case MCLOSE + 1: // \)
case MCLOSE + 2:
case MCLOSE + 3:
case MCLOSE + 4:
case MCLOSE + 5:
case MCLOSE + 6:
case MCLOSE + 7:
case MCLOSE + 8:
case MCLOSE + 9:
{
no = op - MCLOSE;
cleanup_subexpr();
rp = regstack_push(RS_MCLOSE, scan);
if (rp == NULL)
status = RA_FAIL;
else
{
rp->rs_no = no;
save_se(&rp->rs_un.sesave, &rex.reg_endpos[no],
&rex.reg_endp[no]);
// We simply continue and handle the result when done.
}
}
break;
#ifdef FEAT_SYN_HL
case ZCLOSE + 1: // \) after \z(
case ZCLOSE + 2:
case ZCLOSE + 3:
case ZCLOSE + 4:
case ZCLOSE + 5:
case ZCLOSE + 6:
case ZCLOSE + 7:
case ZCLOSE + 8:
case ZCLOSE + 9:
{
no = op - ZCLOSE;
cleanup_zsubexpr();
rp = regstack_push(RS_ZCLOSE, scan);
if (rp == NULL)
status = RA_FAIL;
else
{
rp->rs_no = no;
save_se(&rp->rs_un.sesave, ®_endzpos[no],
®_endzp[no]);
// We simply continue and handle the result when done.
}
}
break;
#endif
case BACKREF + 1:
case BACKREF + 2:
case BACKREF + 3:
case BACKREF + 4:
case BACKREF + 5:
case BACKREF + 6:
case BACKREF + 7:
case BACKREF + 8:
case BACKREF + 9:
{
int len;
no = op - BACKREF;
cleanup_subexpr();
if (!REG_MULTI) // Single-line regexp
{
if (rex.reg_startp[no] == NULL || rex.reg_endp[no] == NULL)
{
// Backref was not set: Match an empty string.
len = 0;
}
else
{
// Compare current input with back-ref in the same
// line.
len = (int)(rex.reg_endp[no] - rex.reg_startp[no]);
if (cstrncmp(rex.reg_startp[no], rex.input, &len) != 0)
status = RA_NOMATCH;
}
}
else // Multi-line regexp
{
if (rex.reg_startpos[no].lnum < 0
|| rex.reg_endpos[no].lnum < 0)
{
// Backref was not set: Match an empty string.
len = 0;
}
else
{
if (rex.reg_startpos[no].lnum == rex.lnum
&& rex.reg_endpos[no].lnum == rex.lnum)
{
// Compare back-ref within the current line.
len = rex.reg_endpos[no].col
- rex.reg_startpos[no].col;
if (cstrncmp(rex.line + rex.reg_startpos[no].col,
rex.input, &len) != 0)
status = RA_NOMATCH;
}
else
{
// Messy situation: Need to compare between two
// lines.
int r = match_with_backref(
rex.reg_startpos[no].lnum,
rex.reg_startpos[no].col,
rex.reg_endpos[no].lnum,
rex.reg_endpos[no].col,
&len);
if (r != RA_MATCH)
status = r;
}
}
}
// Matched the backref, skip over it.
rex.input += len;
}
break;
#ifdef FEAT_SYN_HL
case ZREF + 1:
case ZREF + 2:
case ZREF + 3:
case ZREF + 4:
case ZREF + 5:
case ZREF + 6:
case ZREF + 7:
case ZREF + 8:
case ZREF + 9:
{
int len;
cleanup_zsubexpr();
no = op - ZREF;
if (re_extmatch_in != NULL
&& re_extmatch_in->matches[no] != NULL)
{
len = (int)STRLEN(re_extmatch_in->matches[no]);
if (cstrncmp(re_extmatch_in->matches[no],
rex.input, &len) != 0)
status = RA_NOMATCH;
else
rex.input += len;
}
else
{
// Backref was not set: Match an empty string.
}
}
break;
#endif
case BRANCH:
{
if (OP(next) != BRANCH) // No choice.
next = OPERAND(scan); // Avoid recursion.
else
{
rp = regstack_push(RS_BRANCH, scan);
if (rp == NULL)
status = RA_FAIL;
else
status = RA_BREAK; // rest is below
}
}
break;
case BRACE_LIMITS:
{
if (OP(next) == BRACE_SIMPLE)
{
bl_minval = OPERAND_MIN(scan);
bl_maxval = OPERAND_MAX(scan);
}
else if (OP(next) >= BRACE_COMPLEX
&& OP(next) < BRACE_COMPLEX + 10)
{
no = OP(next) - BRACE_COMPLEX;
brace_min[no] = OPERAND_MIN(scan);
brace_max[no] = OPERAND_MAX(scan);
brace_count[no] = 0;
}
else
{
internal_error("BRACE_LIMITS");
status = RA_FAIL;
}
}
break;
case BRACE_COMPLEX + 0:
case BRACE_COMPLEX + 1:
case BRACE_COMPLEX + 2:
case BRACE_COMPLEX + 3:
case BRACE_COMPLEX + 4:
case BRACE_COMPLEX + 5:
case BRACE_COMPLEX + 6:
case BRACE_COMPLEX + 7:
case BRACE_COMPLEX + 8:
case BRACE_COMPLEX + 9:
{
no = op - BRACE_COMPLEX;
++brace_count[no];
// If not matched enough times yet, try one more
if (brace_count[no] <= (brace_min[no] <= brace_max[no]
? brace_min[no] : brace_max[no]))
{
rp = regstack_push(RS_BRCPLX_MORE, scan);
if (rp == NULL)
status = RA_FAIL;
else
{
rp->rs_no = no;
reg_save(&rp->rs_un.regsave, &backpos);
next = OPERAND(scan);
// We continue and handle the result when done.
}
break;
}
// If matched enough times, may try matching some more
if (brace_min[no] <= brace_max[no])
{
// Range is the normal way around, use longest match
if (brace_count[no] <= brace_max[no])
{
rp = regstack_push(RS_BRCPLX_LONG, scan);
if (rp == NULL)
status = RA_FAIL;
else
{
rp->rs_no = no;
reg_save(&rp->rs_un.regsave, &backpos);
next = OPERAND(scan);
// We continue and handle the result when done.
}
}
}
else
{
// Range is backwards, use shortest match first
if (brace_count[no] <= brace_min[no])
{
rp = regstack_push(RS_BRCPLX_SHORT, scan);
if (rp == NULL)
status = RA_FAIL;
else
{
reg_save(&rp->rs_un.regsave, &backpos);
// We continue and handle the result when done.
}
}
}
}
break;
case BRACE_SIMPLE:
case STAR:
case PLUS:
{
regstar_T rst;
// Lookahead to avoid useless match attempts when we know
// what character comes next.
if (OP(next) == EXACTLY)
{
rst.nextb = *OPERAND(next);
if (rex.reg_ic)
{
if (MB_ISUPPER(rst.nextb))
rst.nextb_ic = MB_TOLOWER(rst.nextb);
else
rst.nextb_ic = MB_TOUPPER(rst.nextb);
}
else
rst.nextb_ic = rst.nextb;
}
else
{
rst.nextb = NUL;
rst.nextb_ic = NUL;
}
if (op != BRACE_SIMPLE)
{
rst.minval = (op == STAR) ? 0 : 1;
rst.maxval = MAX_LIMIT;
}
else
{
rst.minval = bl_minval;
rst.maxval = bl_maxval;
}
// When maxval > minval, try matching as much as possible, up
// to maxval. When maxval < minval, try matching at least the
// minimal number (since the range is backwards, that's also
// maxval!).
rst.count = regrepeat(OPERAND(scan), rst.maxval);
if (got_int)
{
status = RA_FAIL;
break;
}
if (rst.minval <= rst.maxval
? rst.count >= rst.minval : rst.count >= rst.maxval)
{
// It could match. Prepare for trying to match what
// follows. The code is below. Parameters are stored in
// a regstar_T on the regstack.
if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)
{
emsg(_(e_pattern_uses_more_memory_than_maxmempattern));
status = RA_FAIL;
}
else if (ga_grow(®stack, sizeof(regstar_T)) == FAIL)
status = RA_FAIL;
else
{
regstack.ga_len += sizeof(regstar_T);
rp = regstack_push(rst.minval <= rst.maxval
? RS_STAR_LONG : RS_STAR_SHORT, scan);
if (rp == NULL)
status = RA_FAIL;
else
{
*(((regstar_T *)rp) - 1) = rst;
status = RA_BREAK; // skip the restore bits
}
}
}
else
status = RA_NOMATCH;
}
break;
case NOMATCH:
case MATCH:
case SUBPAT:
rp = regstack_push(RS_NOMATCH, scan);
if (rp == NULL)
status = RA_FAIL;
else
{
rp->rs_no = op;
reg_save(&rp->rs_un.regsave, &backpos);
next = OPERAND(scan);
// We continue and handle the result when done.
}
break;
case BEHIND:
case NOBEHIND:
// Need a bit of room to store extra positions.
if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp)
{
emsg(_(e_pattern_uses_more_memory_than_maxmempattern));
status = RA_FAIL;
}
else if (ga_grow(®stack, sizeof(regbehind_T)) == FAIL)
status = RA_FAIL;
else
{
regstack.ga_len += sizeof(regbehind_T);
rp = regstack_push(RS_BEHIND1, scan);
if (rp == NULL)
status = RA_FAIL;
else
{
// Need to save the subexpr to be able to restore them
// when there is a match but we don't use it.
save_subexpr(((regbehind_T *)rp) - 1);
rp->rs_no = op;
reg_save(&rp->rs_un.regsave, &backpos);
// First try if what follows matches. If it does then we
// check the behind match by looping.
}
}
break;
case BHPOS:
if (REG_MULTI)
{
if (behind_pos.rs_u.pos.col != (colnr_T)(rex.input - rex.line)
|| behind_pos.rs_u.pos.lnum != rex.lnum)
status = RA_NOMATCH;
}
else if (behind_pos.rs_u.ptr != rex.input)
status = RA_NOMATCH;
break;
case NEWL:
if ((c != NUL || !REG_MULTI || rex.lnum > rex.reg_maxline
|| rex.reg_line_lbr)
&& (c != '\n' || !rex.reg_line_lbr))
status = RA_NOMATCH;
else if (rex.reg_line_lbr)
ADVANCE_REGINPUT();
else
reg_nextline();
break;
case END:
status = RA_MATCH; // Success!
break;
default:
iemsg(_(e_corrupted_regexp_program));
#ifdef DEBUG
printf("Illegal op code %d\n", op);
#endif
status = RA_FAIL;
break;
}
}
// If we can't continue sequentially, break the inner loop.
if (status != RA_CONT)
break;
// Continue in inner loop, advance to next item.
scan = next;
} // end of inner loop
// If there is something on the regstack execute the code for the state.
// If the state is popped then loop and use the older state.
while (regstack.ga_len > 0 && status != RA_FAIL)
{
rp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len) - 1;
switch (rp->rs_state)
{
case RS_NOPEN:
// Result is passed on as-is, simply pop the state.
regstack_pop(&scan);
break;
case RS_MOPEN:
// Pop the state. Restore pointers when there is no match.
if (status == RA_NOMATCH)
restore_se(&rp->rs_un.sesave, &rex.reg_startpos[rp->rs_no],
&rex.reg_startp[rp->rs_no]);
regstack_pop(&scan);
break;
#ifdef FEAT_SYN_HL
case RS_ZOPEN:
// Pop the state. Restore pointers when there is no match.
if (status == RA_NOMATCH)
restore_se(&rp->rs_un.sesave, ®_startzpos[rp->rs_no],
®_startzp[rp->rs_no]);
regstack_pop(&scan);
break;
#endif
case RS_MCLOSE:
// Pop the state. Restore pointers when there is no match.
if (status == RA_NOMATCH)
restore_se(&rp->rs_un.sesave, &rex.reg_endpos[rp->rs_no],
&rex.reg_endp[rp->rs_no]);
regstack_pop(&scan);
break;
#ifdef FEAT_SYN_HL
case RS_ZCLOSE:
// Pop the state. Restore pointers when there is no match.
if (status == RA_NOMATCH)
restore_se(&rp->rs_un.sesave, ®_endzpos[rp->rs_no],
®_endzp[rp->rs_no]);
regstack_pop(&scan);
break;
#endif
case RS_BRANCH:
if (status == RA_MATCH)
// this branch matched, use it
regstack_pop(&scan);
else
{
if (status != RA_BREAK)
{
// After a non-matching branch: try next one.
reg_restore(&rp->rs_un.regsave, &backpos);
scan = rp->rs_scan;
}
if (scan == NULL || OP(scan) != BRANCH)
{
// no more branches, didn't find a match
status = RA_NOMATCH;
regstack_pop(&scan);
}
else
{
// Prepare to try a branch.
rp->rs_scan = regnext(scan);
reg_save(&rp->rs_un.regsave, &backpos);
scan = OPERAND(scan);
}
}
break;
case RS_BRCPLX_MORE:
// Pop the state. Restore pointers when there is no match.
if (status == RA_NOMATCH)
{
reg_restore(&rp->rs_un.regsave, &backpos);
--brace_count[rp->rs_no]; // decrement match count
}
regstack_pop(&scan);
break;
case RS_BRCPLX_LONG:
// Pop the state. Restore pointers when there is no match.
if (status == RA_NOMATCH)
{
// There was no match, but we did find enough matches.
reg_restore(&rp->rs_un.regsave, &backpos);
--brace_count[rp->rs_no];
// continue with the items after "\{}"
status = RA_CONT;
}
regstack_pop(&scan);
if (status == RA_CONT)
scan = regnext(scan);
break;
case RS_BRCPLX_SHORT:
// Pop the state. Restore pointers when there is no match.
if (status == RA_NOMATCH)
// There was no match, try to match one more item.
reg_restore(&rp->rs_un.regsave, &backpos);
regstack_pop(&scan);
if (status == RA_NOMATCH)
{
scan = OPERAND(scan);
status = RA_CONT;
}
break;
case RS_NOMATCH:
// Pop the state. If the operand matches for NOMATCH or
// doesn't match for MATCH/SUBPAT, we fail. Otherwise backup,
// except for SUBPAT, and continue with the next item.
if (status == (rp->rs_no == NOMATCH ? RA_MATCH : RA_NOMATCH))
status = RA_NOMATCH;
else
{
status = RA_CONT;
if (rp->rs_no != SUBPAT) // zero-width
reg_restore(&rp->rs_un.regsave, &backpos);
}
regstack_pop(&scan);
if (status == RA_CONT)
scan = regnext(scan);
break;
case RS_BEHIND1:
if (status == RA_NOMATCH)
{
regstack_pop(&scan);
regstack.ga_len -= sizeof(regbehind_T);
}
else
{
// The stuff after BEHIND/NOBEHIND matches. Now try if
// the behind part does (not) match before the current
// position in the input. This must be done at every
// position in the input and checking if the match ends at
// the current position.
// save the position after the found match for next
reg_save(&(((regbehind_T *)rp) - 1)->save_after, &backpos);
// Start looking for a match with operand at the current
// position. Go back one character until we find the
// result, hitting the start of the line or the previous
// line (for multi-line matching).
// Set behind_pos to where the match should end, BHPOS
// will match it. Save the current value.
(((regbehind_T *)rp) - 1)->save_behind = behind_pos;
behind_pos = rp->rs_un.regsave;
rp->rs_state = RS_BEHIND2;
reg_restore(&rp->rs_un.regsave, &backpos);
scan = OPERAND(rp->rs_scan) + 4;
}
break;
case RS_BEHIND2:
// Looping for BEHIND / NOBEHIND match.
if (status == RA_MATCH && reg_save_equal(&behind_pos))
{
// found a match that ends where "next" started
behind_pos = (((regbehind_T *)rp) - 1)->save_behind;
if (rp->rs_no == BEHIND)
reg_restore(&(((regbehind_T *)rp) - 1)->save_after,
&backpos);
else
{
// But we didn't want a match. Need to restore the
// subexpr, because what follows matched, so they have
// been set.
status = RA_NOMATCH;
restore_subexpr(((regbehind_T *)rp) - 1);
}
regstack_pop(&scan);
regstack.ga_len -= sizeof(regbehind_T);
}
else
{
long limit;
// No match or a match that doesn't end where we want it: Go
// back one character. May go to previous line once.
no = OK;
limit = OPERAND_MIN(rp->rs_scan);
if (REG_MULTI)
{
if (limit > 0
&& ((rp->rs_un.regsave.rs_u.pos.lnum
< behind_pos.rs_u.pos.lnum
? (colnr_T)STRLEN(rex.line)
: behind_pos.rs_u.pos.col)
- rp->rs_un.regsave.rs_u.pos.col >= limit))
no = FAIL;
else if (rp->rs_un.regsave.rs_u.pos.col == 0)
{
if (rp->rs_un.regsave.rs_u.pos.lnum
< behind_pos.rs_u.pos.lnum
|| reg_getline(
--rp->rs_un.regsave.rs_u.pos.lnum)
== NULL)
no = FAIL;
else
{
reg_restore(&rp->rs_un.regsave, &backpos);
rp->rs_un.regsave.rs_u.pos.col =
(colnr_T)STRLEN(rex.line);
}
}
else
{
if (has_mbyte)
{
char_u *line =
reg_getline(rp->rs_un.regsave.rs_u.pos.lnum);
rp->rs_un.regsave.rs_u.pos.col -=
(*mb_head_off)(line, line
+ rp->rs_un.regsave.rs_u.pos.col - 1) + 1;
}
else
--rp->rs_un.regsave.rs_u.pos.col;
}
}
else
{
if (rp->rs_un.regsave.rs_u.ptr == rex.line)
no = FAIL;
else
{
MB_PTR_BACK(rex.line, rp->rs_un.regsave.rs_u.ptr);
if (limit > 0 && (long)(behind_pos.rs_u.ptr
- rp->rs_un.regsave.rs_u.ptr) > limit)
no = FAIL;
}
}
if (no == OK)
{
// Advanced, prepare for finding match again.
reg_restore(&rp->rs_un.regsave, &backpos);
scan = OPERAND(rp->rs_scan) + 4;
if (status == RA_MATCH)
{
// We did match, so subexpr may have been changed,
// need to restore them for the next try.
status = RA_NOMATCH;
restore_subexpr(((regbehind_T *)rp) - 1);
}
}
else
{
// Can't advance. For NOBEHIND that's a match.
behind_pos = (((regbehind_T *)rp) - 1)->save_behind;
if (rp->rs_no == NOBEHIND)
{
reg_restore(&(((regbehind_T *)rp) - 1)->save_after,
&backpos);
status = RA_MATCH;
}
else
{
// We do want a proper match. Need to restore the
// subexpr if we had a match, because they may have
// been set.
if (status == RA_MATCH)
{
status = RA_NOMATCH;
restore_subexpr(((regbehind_T *)rp) - 1);
}
}
regstack_pop(&scan);
regstack.ga_len -= sizeof(regbehind_T);
}
}
break;
case RS_STAR_LONG:
case RS_STAR_SHORT:
{
regstar_T *rst = ((regstar_T *)rp) - 1;
if (status == RA_MATCH)
{
regstack_pop(&scan);
regstack.ga_len -= sizeof(regstar_T);
break;
}
// Tried once already, restore input pointers.
if (status != RA_BREAK)
reg_restore(&rp->rs_un.regsave, &backpos);
// Repeat until we found a position where it could match.
for (;;)
{
if (status != RA_BREAK)
{
// Tried first position already, advance.
if (rp->rs_state == RS_STAR_LONG)
{
// Trying for longest match, but couldn't or
// didn't match -- back up one char.
if (--rst->count < rst->minval)
break;
if (rex.input == rex.line)
{
// backup to last char of previous line
if (rex.lnum == 0)
{
status = RA_NOMATCH;
break;
}
--rex.lnum;
rex.line = reg_getline(rex.lnum);
// Just in case regrepeat() didn't count
// right.
if (rex.line == NULL)
break;
rex.input = rex.line + STRLEN(rex.line);
fast_breakcheck();
}
else
MB_PTR_BACK(rex.line, rex.input);
}
else
{
// Range is backwards, use shortest match first.
// Careful: maxval and minval are exchanged!
// Couldn't or didn't match: try advancing one
// char.
if (rst->count == rst->minval
|| regrepeat(OPERAND(rp->rs_scan), 1L) == 0)
break;
++rst->count;
}
if (got_int)
break;
}
else
status = RA_NOMATCH;
// If it could match, try it.
if (rst->nextb == NUL || *rex.input == rst->nextb
|| *rex.input == rst->nextb_ic)
{
reg_save(&rp->rs_un.regsave, &backpos);
scan = regnext(rp->rs_scan);
status = RA_CONT;
break;
}
}
if (status != RA_CONT)
{
// Failed.
regstack_pop(&scan);
regstack.ga_len -= sizeof(regstar_T);
status = RA_NOMATCH;
}
}
break;
}
// If we want to continue the inner loop or didn't pop a state
// continue matching loop
if (status == RA_CONT || rp == (regitem_T *)
((char *)regstack.ga_data + regstack.ga_len) - 1)
break;
}
// May need to continue with the inner loop, starting at "scan".
if (status == RA_CONT)
continue;
// If the regstack is empty or something failed we are done.
if (regstack.ga_len == 0 || status == RA_FAIL)
{
if (scan == NULL)
{
// We get here only if there's trouble -- normally "case END" is
// the terminating point.
iemsg(_(e_corrupted_regexp_program));
#ifdef DEBUG
printf("Premature EOL\n");
#endif
}
return (status == RA_MATCH);
}
} // End of loop until the regstack is empty.
// NOTREACHED
}
| 1
|
353,010
|
nameUIDValidate(
Syntax *syntax,
struct berval *in )
{
int rc;
struct berval dn, uid;
if( BER_BVISEMPTY( in ) ) return LDAP_SUCCESS;
ber_dupbv( &dn, in );
if( !dn.bv_val ) return LDAP_OTHER;
/* if there's a "#", try bitStringValidate()... */
uid.bv_val = strrchr( dn.bv_val, '#' );
if ( !BER_BVISNULL( &uid ) ) {
uid.bv_val++;
uid.bv_len = dn.bv_len - ( uid.bv_val - dn.bv_val );
rc = bitStringValidate( NULL, &uid );
if ( rc == LDAP_SUCCESS ) {
/* in case of success, trim the UID,
* otherwise treat it as part of the DN */
dn.bv_len -= uid.bv_len + 1;
uid.bv_val[-1] = '\0';
}
}
rc = dnValidate( NULL, &dn );
ber_memfree( dn.bv_val );
return rc;
}
| 0
|
310,317
|
lookup_cached_dir_by_fp(const char *fp)
{
cached_dir_t *d = NULL;
if (tor_digest_is_zero(fp) && cached_consensuses)
d = strmap_get(cached_consensuses, "ns");
else if (memchr(fp, '\0', DIGEST_LEN) && cached_consensuses &&
(d = strmap_get(cached_consensuses, fp))) {
/* this here interface is a nasty hack XXXX023 */;
} else if (router_digest_is_me(fp) && the_v2_networkstatus)
d = the_v2_networkstatus;
else if (cached_v2_networkstatus)
d = digestmap_get(cached_v2_networkstatus, fp);
return d;
}
| 0
|
226,101
|
/*this is using chpl format according to some NeroRecode samples*/
GF_Err tfdt_box_read(GF_Box *s,GF_BitStream *bs)
{
GF_TFBaseMediaDecodeTimeBox *ptr = (GF_TFBaseMediaDecodeTimeBox *)s;
if (ptr->version==1) {
ISOM_DECREASE_SIZE(ptr, 8);
ptr->baseMediaDecodeTime = gf_bs_read_u64(bs);
} else {
ISOM_DECREASE_SIZE(ptr, 4);
ptr->baseMediaDecodeTime = (u32) gf_bs_read_u32(bs);
}
return GF_OK;
| 0
|
450,399
|
static int tight_fill_palette(VncState *vs, int x, int y,
size_t count, uint32_t *bg, uint32_t *fg,
VncPalette *palette)
{
int max;
max = count / tight_conf[vs->tight->compression].idx_max_colors_divisor;
if (max < 2 &&
count >= tight_conf[vs->tight->compression].mono_min_rect_size) {
max = 2;
}
if (max >= 256) {
max = 256;
}
switch (vs->client_pf.bytes_per_pixel) {
case 4:
return tight_fill_palette32(vs, x, y, max, count, bg, fg, palette);
case 2:
return tight_fill_palette16(vs, x, y, max, count, bg, fg, palette);
default:
max = 2;
return tight_fill_palette8(vs, x, y, max, count, bg, fg, palette);
}
return 0;
}
| 0
|
254,065
|
char* get(const std::string& name) const
{
char* ret = qs_k2v(name.c_str(), key_value_pairs_.data(), key_value_pairs_.size());
return ret;
}
| 0
|
462,421
|
addEPollSock(epolld_type_t typ, void *ptr, int sock, epolld_t **pEpd)
{
DEFiRet;
epolld_t *epd = NULL;
CHKmalloc(epd = calloc(1, sizeof(epolld_t)));
epd->typ = typ;
epd->ptr = ptr;
epd->sock = sock;
*pEpd = epd;
epd->ev.events = EPOLLIN|EPOLLET|EPOLLONESHOT;
epd->ev.data.ptr = (void*) epd;
if(epoll_ctl(epollfd, EPOLL_CTL_ADD, sock, &(epd->ev)) != 0) {
char errStr[1024];
int eno = errno;
errmsg.LogError(0, RS_RET_EPOLL_CTL_FAILED, "os error (%d) during epoll ADD: %s",
eno, rs_strerror_r(eno, errStr, sizeof(errStr)));
ABORT_FINALIZE(RS_RET_EPOLL_CTL_FAILED);
}
DBGPRINTF("imptcp: added socket %d to epoll[%d] set\n", sock, epollfd);
finalize_it:
if(iRet != RS_RET_OK) {
if (epd != NULL) {
errmsg.LogError(0, RS_RET_INTERNAL_ERROR, "error: could not initialize mutex for ptcp "
"connection for socket: %d", sock);
}
free(epd);
}
RETiRet;
}
| 0
|
390,575
|
SendDeviceLedInfo( XkbSrvLedInfoPtr sli,
ClientPtr client)
{
xkbDeviceLedsWireDesc wire;
int length;
length= 0;
wire.ledClass= sli->class;
wire.ledID= sli->id;
wire.namesPresent= sli->namesPresent;
wire.mapsPresent= sli->mapsPresent;
wire.physIndicators= sli->physIndicators;
wire.state= sli->effectiveState;
if (client->swapped) {
register int n;
swaps(&wire.ledClass,n);
swaps(&wire.ledID,n);
swapl(&wire.namesPresent,n);
swapl(&wire.mapsPresent,n);
swapl(&wire.physIndicators,n);
swapl(&wire.state,n);
}
WriteToClient(client,SIZEOF(xkbDeviceLedsWireDesc),(char *)&wire);
length+= SIZEOF(xkbDeviceLedsWireDesc);
if (sli->namesPresent|sli->mapsPresent) {
register unsigned i,bit;
if (sli->namesPresent) {
CARD32 awire;
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
if (sli->namesPresent&bit) {
awire= (CARD32)sli->names[i];
if (client->swapped) {
register int n;
swapl(&awire,n);
}
WriteToClient(client,4,(char *)&awire);
length+= 4;
}
}
}
if (sli->mapsPresent) {
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
xkbIndicatorMapWireDesc iwire;
if (sli->mapsPresent&bit) {
iwire.flags= sli->maps[i].flags;
iwire.whichGroups= sli->maps[i].which_groups;
iwire.groups= sli->maps[i].groups;
iwire.whichMods= sli->maps[i].which_mods;
iwire.mods= sli->maps[i].mods.mask;
iwire.realMods= sli->maps[i].mods.real_mods;
iwire.virtualMods= sli->maps[i].mods.vmods;
iwire.ctrls= sli->maps[i].ctrls;
if (client->swapped) {
register int n;
swaps(&iwire.virtualMods,n);
swapl(&iwire.ctrls,n);
}
WriteToClient(client,SIZEOF(xkbIndicatorMapWireDesc),
(char *)&iwire);
length+= SIZEOF(xkbIndicatorMapWireDesc);
}
}
}
}
return length;
}
| 0
|
294,422
|
rt_rewrite_frags(VALUE hash)
{
VALUE seconds;
seconds = del_hash("seconds");
if (!NIL_P(seconds)) {
VALUE offset, d, h, min, s, fr;
offset = ref_hash("offset");
if (!NIL_P(offset))
seconds = f_add(seconds, offset);
d = f_idiv(seconds, INT2FIX(DAY_IN_SECONDS));
fr = f_mod(seconds, INT2FIX(DAY_IN_SECONDS));
h = f_idiv(fr, INT2FIX(HOUR_IN_SECONDS));
fr = f_mod(fr, INT2FIX(HOUR_IN_SECONDS));
min = f_idiv(fr, INT2FIX(MINUTE_IN_SECONDS));
fr = f_mod(fr, INT2FIX(MINUTE_IN_SECONDS));
s = f_idiv(fr, INT2FIX(1));
fr = f_mod(fr, INT2FIX(1));
set_hash("jd", f_add(UNIX_EPOCH_IN_CJD, d));
set_hash("hour", h);
set_hash("min", min);
set_hash("sec", s);
set_hash("sec_fraction", fr);
}
return hash;
}
| 0
|
222,844
|
bool IsNumericType(const DataType dtype) {
static const gtl::FlatSet<DataType>* const kRealNumberTypes =
CHECK_NOTNULL((new gtl::FlatSet<DataType>{
// Floating point.
DT_BFLOAT16,
DT_HALF,
DT_FLOAT,
DT_DOUBLE,
// Int / UInt.
DT_INT8,
DT_INT16,
DT_INT32,
DT_INT64,
DT_UINT8,
DT_UINT16,
DT_UINT32,
DT_UINT64,
// Quantized Int.
DT_QINT8,
DT_QUINT8,
DT_QINT16,
DT_QUINT16,
DT_QINT32,
// Bool.
DT_BOOL,
}));
return kRealNumberTypes->find(dtype) != kRealNumberTypes->end();
}
| 0
|
462,227
|
PJ_DEF(pj_status_t) pj_stun_msg_add_msgint_attr(pj_pool_t *pool,
pj_stun_msg *msg)
{
pj_stun_msgint_attr *attr = NULL;
pj_status_t status;
status = pj_stun_msgint_attr_create(pool, &attr);
if (status != PJ_SUCCESS)
return status;
return pj_stun_msg_add_attr(msg, &attr->hdr);
}
| 0
|
274,693
|
callbacks_drawingarea_configure_event (GtkWidget *widget, GdkEventConfigure *event)
{
GdkDrawable *drawable = widget->window;
gdk_drawable_get_size (drawable, &screenRenderInfo.displayWidth, &screenRenderInfo.displayHeight);
/* set this up if cairo is compiled, since we may need to switch over to
using the surface at any time */
int x_off=0, y_off=0;
if (GDK_IS_WINDOW(widget->window)) {
/* query the window's backbuffer if it has one */
GdkWindow *window = GDK_WINDOW(widget->window);
gdk_window_get_internal_paint_info (window, &drawable, &x_off, &y_off);
}
if (screen.windowSurface)
cairo_surface_destroy ((cairo_surface_t *)
screen.windowSurface);
#if defined(WIN32) || defined(QUARTZ)
cairo_t *cairoTarget = gdk_cairo_create (GDK_WINDOW(widget->window));
screen.windowSurface = cairo_get_target (cairoTarget);
/* increase surface reference by one so it isn't freed when the cairo_t
is destroyed next */
screen.windowSurface = cairo_surface_reference (screen.windowSurface);
cairo_destroy (cairoTarget);
#else
GdkVisual *visual = gdk_drawable_get_visual (drawable);
screen.windowSurface = (gpointer) cairo_xlib_surface_create (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
GDK_VISUAL_XVISUAL (visual),
screenRenderInfo.displayWidth,
screenRenderInfo.displayHeight);
#endif
/* if this is the first time, go ahead and call autoscale even if we don't
have a model loaded */
if ((screenRenderInfo.scaleFactorX < 0.001)||(screenRenderInfo.scaleFactorY < 0.001)) {
gerbv_render_zoom_to_fit_display (mainProject, &screenRenderInfo);
}
render_refresh_rendered_image_on_screen();
return TRUE;
}
| 0
|
259,717
|
json_t * user_auth_scheme_module_init(struct config_module * config, json_t * j_parameters, const char * mod_name, void ** cls) {
UNUSED(config);
json_t * j_result = is_scheme_parameters_valid(j_parameters), * j_element = NULL, * j_return;
size_t index = 0;
char * message;
if (check_result_value(j_result, G_OK)) {
*cls = json_pack("{sO sO sO sO sI sI sO ss so sO sO sO sO sO ss s[]}",
"challenge-length", json_object_get(j_parameters, "challenge-length"),
"rp-origin", json_object_get(j_parameters, "rp-origin"),
"credential-expiration", json_object_get(j_parameters, "credential-expiration"),
"credential-assertion", json_object_get(j_parameters, "credential-assertion"),
"ctsProfileMatch", json_object_get(j_parameters, "ctsProfileMatch")!=NULL?json_integer_value(json_object_get(j_parameters, "ctsProfileMatch")):-1,
"basicIntegrity", json_object_get(j_parameters, "basicIntegrity")!=NULL?json_integer_value(json_object_get(j_parameters, "basicIntegrity")):-1,
"session-mandatory", json_object_get(j_parameters, "session-mandatory")!=NULL?json_object_get(j_parameters, "session-mandatory"):json_true(),
"seed", !json_string_length(json_object_get(j_parameters, "seed"))?"":json_string_value(json_object_get(j_parameters, "seed")),
"fmt", json_object_get(j_parameters, "fmt")!=NULL?json_deep_copy(json_object_get(j_parameters, "fmt")):json_pack("{sosososososo}", "packed", json_true(), "tpm", json_true(), "android-key", json_true(), "android-safetynet", json_true(), "fido-u2f", json_true(), "none", json_true()),
"force-fmt-none", json_object_get(j_parameters, "force-fmt-none")!=NULL?json_object_get(j_parameters, "force-fmt-none"):json_false(),
"google-root-ca-r2", json_string_length(json_object_get(j_parameters, "google-root-ca-r2"))?json_object_get(j_parameters, "google-root-ca-r2"):json_null(),
"google-root-ca-r2-content", json_object_get(j_parameters, "google-root-ca-r2-content")!=NULL?json_object_get(j_parameters, "google-root-ca-r2-content"):json_null(),
"root-ca-list", json_array_size(json_object_get(j_parameters, "root-ca-list"))?json_object_get(j_parameters, "root-ca-list"):json_null(),
"root-ca-array", json_object_get(j_parameters, "root-ca-array")!=NULL?json_object_get(j_parameters, "root-ca-array"):json_null(),
"mod_name", mod_name,
"pubKey-cred-params");
json_array_foreach(json_object_get(j_parameters, "pubKey-cred-params"), index, j_element) {
json_array_append_new(json_object_get((json_t *)*cls, "pubKey-cred-params"), json_pack("{sssO}", "type", "public-key", "alg", j_element));
}
j_return = json_pack("{si}", "result", G_OK);
} else if (check_result_value(j_result, G_ERROR_PARAM)) {
message = json_dumps(json_object_get(j_result, "error"), JSON_COMPACT);
y_log_message(Y_LOG_LEVEL_ERROR, "user_auth_scheme_module_init webauthn - Error input parameters: %s", message);
o_free(message);
j_return = json_pack("{sisO}", "result", G_ERROR_PARAM, "error", json_object_get(j_result, "error"));
} else {
j_return = json_pack("{si}", "result", G_ERROR);
}
json_decref(j_result);
return j_return;
}
| 0
|
337,841
|
struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc,
__u16 key_id)
{
struct sctp_authhdr auth_hdr;
struct sctp_hmac *hmac_desc;
struct sctp_chunk *retval;
/* Get the first hmac that the peer told us to use */
hmac_desc = sctp_auth_asoc_get_hmac(asoc);
if (unlikely(!hmac_desc))
return NULL;
retval = sctp_make_control(asoc, SCTP_CID_AUTH, 0,
hmac_desc->hmac_len + sizeof(auth_hdr),
GFP_ATOMIC);
if (!retval)
return NULL;
auth_hdr.hmac_id = htons(hmac_desc->hmac_id);
auth_hdr.shkey_id = htons(key_id);
retval->subh.auth_hdr = sctp_addto_chunk(retval, sizeof(auth_hdr),
&auth_hdr);
skb_put_zero(retval->skb, hmac_desc->hmac_len);
/* Adjust the chunk header to include the empty MAC */
retval->chunk_hdr->length =
htons(ntohs(retval->chunk_hdr->length) + hmac_desc->hmac_len);
retval->chunk_end = skb_tail_pointer(retval->skb);
return retval;
}
| 0
|
291,800
|
static int init_path(struct rtrs_clt_path *clt_path)
{
int err;
char str[NAME_MAX];
struct rtrs_addr path = {
.src = &clt_path->s.src_addr,
.dst = &clt_path->s.dst_addr,
};
rtrs_addr_to_str(&path, str, sizeof(str));
mutex_lock(&clt_path->init_mutex);
err = init_conns(clt_path);
if (err) {
rtrs_err(clt_path->clt,
"init_conns() failed: err=%d path=%s [%s:%u]\n", err,
str, clt_path->hca_name, clt_path->hca_port);
goto out;
}
err = rtrs_send_path_info(clt_path);
if (err) {
rtrs_err(clt_path->clt,
"rtrs_send_path_info() failed: err=%d path=%s [%s:%u]\n",
err, str, clt_path->hca_name, clt_path->hca_port);
goto out;
}
rtrs_clt_path_up(clt_path);
out:
mutex_unlock(&clt_path->init_mutex);
return err;
}
| 0
|
310,091
|
TINFO_MVCUR(NCURSES_SP_DCLx int yold, int xold, int ynew, int xnew)
{
int rc;
rc = _nc_real_mvcur(NCURSES_SP_ARGx
yold, xold,
ynew, xnew,
NCURSES_SP_NAME(_nc_outch),
TRUE);
if ((SP_PARM != 0) && (SP_PARM->_endwin == ewInitial))
NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
return rc;
}
| 0
|
262,798
|
static int next_chunk_len(struct mctp_serial *dev)
{
int i;
/* either we have no bytes to send ... */
if (dev->txpos == dev->txlen)
return 0;
/* ... or the next byte to send is an escaped byte; requiring a
* single-byte chunk...
*/
if (needs_escape(dev->txbuf[dev->txpos]))
return 1;
/* ... or we have one or more bytes up to the next escape - this chunk
* will be those non-escaped bytes, and does not include the escaped
* byte.
*/
for (i = 1; i + dev->txpos + 1 < dev->txlen; i++) {
if (needs_escape(dev->txbuf[dev->txpos + i + 1]))
break;
}
return i;
}
| 0
|
373,526
|
ipf_is_valid_v6_frag(struct ipf *ipf, struct dp_packet *pkt)
{
const struct eth_header *l2 = dp_packet_eth(pkt);
const struct ovs_16aligned_ip6_hdr *l3 = dp_packet_l3(pkt);
const char *l4 = dp_packet_l4(pkt);
if (OVS_UNLIKELY(!l2 || !l3 || !l4)) {
goto invalid_pkt;
}
size_t l3_size = dp_packet_l3_size(pkt);
size_t l3_hdr_size = sizeof *l3;
if (OVS_UNLIKELY(l3_size < l3_hdr_size)) {
goto invalid_pkt;
}
uint8_t nw_frag = 0;
uint8_t nw_proto = l3->ip6_nxt;
const void *data = l3 + 1;
size_t datasize = l3_size - l3_hdr_size;
const struct ovs_16aligned_ip6_frag *frag_hdr = NULL;
if (!parse_ipv6_ext_hdrs(&data, &datasize, &nw_proto, &nw_frag,
&frag_hdr) || !nw_frag || !frag_hdr) {
return false;
}
int pl = ntohs(l3->ip6_plen);
if (OVS_UNLIKELY(pl + l3_hdr_size != l3_size)) {
goto invalid_pkt;
}
ovs_be16 ip6f_offlg = frag_hdr->ip6f_offlg;
if (OVS_UNLIKELY(!ipf_is_v6_frag(ip6f_offlg))) {
return false;
}
uint32_t min_v6_frag_size_;
atomic_read_relaxed(&ipf->min_v6_frag_size, &min_v6_frag_size_);
bool lf = ipf_is_last_v6_frag(ip6f_offlg);
if (OVS_UNLIKELY(!lf && dp_packet_l3_size(pkt) < min_v6_frag_size_)) {
ipf_count(ipf, true, IPF_NFRAGS_TOO_SMALL);
goto invalid_pkt;
}
return true;
invalid_pkt:
pkt->md.ct_state = CS_INVALID;
return false;
}
| 0
|
225,774
|
GF_Err tmax_box_write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
GF_TMAXBox *ptr = (GF_TMAXBox *)s;
if (ptr == NULL) return GF_BAD_PARAM;
e = gf_isom_box_write_header(s, bs);
if (e) return e;
gf_bs_write_u32(bs, ptr->maxTime);
return GF_OK;
}
| 0
|
252,355
|
static MZ_FORCEINLINE int mz_zip_reader_filename_compare(
const mz_zip_array *pCentral_dir_array,
const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR,
mz_uint r_len) {
const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(
pCentral_dir_array, mz_uint8,
MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32,
l_index)),
*pE;
mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS);
mz_uint8 l = 0, r = 0;
pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
pE = pL + MZ_MIN(l_len, r_len);
while (pL < pE) {
if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR))) break;
pL++;
pR++;
}
return (pL == pE) ? (int)(l_len - r_len) : (l - r);
}
| 0
|
513,306
|
bool JOIN::add_having_as_table_cond(JOIN_TAB *tab)
{
tmp_having->update_used_tables();
table_map used_tables= tab->table->map | OUTER_REF_TABLE_BIT;
/* If tmp table is not used then consider conditions of const table also */
if (!need_tmp)
used_tables|= const_table_map;
DBUG_ENTER("JOIN::add_having_as_table_cond");
Item* sort_table_cond= make_cond_for_table(thd, tmp_having, used_tables,
(table_map) 0, false,
false, false);
if (sort_table_cond)
{
if (!tab->select)
{
if (!(tab->select= new SQL_SELECT))
DBUG_RETURN(true);
tab->select->head= tab->table;
}
if (!tab->select->cond)
tab->select->cond= sort_table_cond;
else
{
if (!(tab->select->cond=
new (thd->mem_root) Item_cond_and(thd,
tab->select->cond,
sort_table_cond)))
DBUG_RETURN(true);
}
if (tab->pre_idx_push_select_cond)
{
if (sort_table_cond->type() == Item::COND_ITEM)
sort_table_cond= sort_table_cond->copy_andor_structure(thd);
if (!(tab->pre_idx_push_select_cond=
new (thd->mem_root) Item_cond_and(thd,
tab->pre_idx_push_select_cond,
sort_table_cond)))
DBUG_RETURN(true);
}
if (tab->select->cond && !tab->select->cond->fixed)
tab->select->cond->fix_fields(thd, 0);
if (tab->pre_idx_push_select_cond && !tab->pre_idx_push_select_cond->fixed)
tab->pre_idx_push_select_cond->fix_fields(thd, 0);
tab->select->pre_idx_push_select_cond= tab->pre_idx_push_select_cond;
tab->set_select_cond(tab->select->cond, __LINE__);
tab->select_cond->top_level_item();
DBUG_EXECUTE("where",print_where(tab->select->cond,
"select and having",
QT_ORDINARY););
having= make_cond_for_table(thd, tmp_having, ~ (table_map) 0,
~used_tables, false, false, false);
DBUG_EXECUTE("where",
print_where(having, "having after sort", QT_ORDINARY););
}
DBUG_RETURN(false);
}
| 0
|
317,311
|
static inline u32 open_file_to_av(struct file *file)
{
u32 av = file_to_av(file);
struct inode *inode = file_inode(file);
if (selinux_policycap_openperm() &&
inode->i_sb->s_magic != SOCKFS_MAGIC)
av |= FILE__OPEN;
return av;
}
| 0
|
438,686
|
static struct rpmsg_device *rpmsg_virtio_add_ctrl_dev(struct virtio_device *vdev)
{
struct virtproc_info *vrp = vdev->priv;
struct virtio_rpmsg_channel *vch;
struct rpmsg_device *rpdev_ctrl;
int err = 0;
vch = kzalloc(sizeof(*vch), GFP_KERNEL);
if (!vch)
return ERR_PTR(-ENOMEM);
/* Link the channel to the vrp */
vch->vrp = vrp;
/* Assign public information to the rpmsg_device */
rpdev_ctrl = &vch->rpdev;
rpdev_ctrl->ops = &virtio_rpmsg_ops;
rpdev_ctrl->dev.parent = &vrp->vdev->dev;
rpdev_ctrl->dev.release = virtio_rpmsg_release_device;
rpdev_ctrl->little_endian = virtio_is_little_endian(vrp->vdev);
err = rpmsg_ctrldev_register_device(rpdev_ctrl);
if (err) {
/* vch will be free in virtio_rpmsg_release_device() */
return ERR_PTR(err);
}
return rpdev_ctrl;
}
| 0
|
301,430
|
static const char *vfswrap_connectpath(struct vfs_handle_struct *handle,
const char *fname)
{
return handle->conn->connectpath;
}
| 0
|
226,215
|
GF_Err nump_box_size(GF_Box *s)
{
s->size += 8;
return GF_OK;
}
| 0
|
390,623
|
SetKeySyms( ClientPtr client,
XkbDescPtr xkb,
xkbSetMapReq * req,
xkbSymMapWireDesc * wire,
XkbChangesPtr changes,
DeviceIntPtr dev)
{
register unsigned i,s;
XkbSymMapPtr oldMap;
KeySym * newSyms;
KeySym * pSyms;
unsigned first,last;
oldMap = &xkb->map->key_sym_map[req->firstKeySym];
for (i=0;i<req->nKeySyms;i++,oldMap++) {
pSyms = (KeySym *)&wire[1];
if (wire->nSyms>0) {
newSyms = XkbResizeKeySyms(xkb,i+req->firstKeySym,wire->nSyms);
for (s=0;s<wire->nSyms;s++) {
newSyms[s]= pSyms[s];
}
if (client->swapped) {
int n;
for (s=0;s<wire->nSyms;s++) {
swapl(&newSyms[s],n);
}
}
}
oldMap->kt_index[0] = wire->ktIndex[0];
oldMap->kt_index[1] = wire->ktIndex[1];
oldMap->kt_index[2] = wire->ktIndex[2];
oldMap->kt_index[3] = wire->ktIndex[3];
oldMap->group_info = wire->groupInfo;
oldMap->width = wire->width;
wire= (xkbSymMapWireDesc *)&pSyms[wire->nSyms];
}
first= req->firstKeySym;
last= first+req->nKeySyms-1;
if (changes->map.changed&XkbKeySymsMask) {
int oldLast= (changes->map.first_key_sym+changes->map.num_key_syms-1);
if (changes->map.first_key_sym<first)
first= changes->map.first_key_sym;
if (oldLast>last)
last= oldLast;
}
changes->map.changed|= XkbKeySymsMask;
changes->map.first_key_sym = first;
changes->map.num_key_syms = (last-first+1);
s= 0;
for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
if (XkbKeyNumGroups(xkb,i)>s)
s= XkbKeyNumGroups(xkb,i);
}
if (s!=xkb->ctrls->num_groups) {
xkbControlsNotify cn;
XkbControlsRec old;
cn.keycode= 0;
cn.eventType= 0;
cn.requestMajor= XkbReqCode;
cn.requestMinor= X_kbSetMap;
old= *xkb->ctrls;
xkb->ctrls->num_groups= s;
if (XkbComputeControlsNotify(dev,&old,xkb->ctrls,&cn,False))
XkbSendControlsNotify(dev,&cn);
}
return (char *)wire;
}
| 0
|
366,192
|
int count_mounts(struct mnt_namespace *ns, struct mount *mnt)
{
unsigned int max = READ_ONCE(sysctl_mount_max);
unsigned int mounts = 0, old, pending, sum;
struct mount *p;
for (p = mnt; p; p = next_mnt(p, mnt))
mounts++;
old = ns->mounts;
pending = ns->pending_mounts;
sum = old + pending;
if ((old > sum) ||
(pending > sum) ||
(max < sum) ||
(mounts > (max - sum)))
return -ENOSPC;
ns->pending_mounts = pending + mounts;
return 0;
}
| 0
|
253,620
|
static inline void smb2_sg_set_buf(struct scatterlist *sg, const void *buf,
unsigned int buflen)
{
void *addr;
/*
* VMAP_STACK (at least) puts stack into the vmalloc address space
*/
if (is_vmalloc_addr(buf))
addr = vmalloc_to_page(buf);
else
addr = virt_to_page(buf);
sg_set_page(sg, addr, buflen, offset_in_page(buf));
}
| 0
|
274,700
|
callbacks_align_files_from_sel_clicked (
GtkMenuItem *menu_item, gpointer user_data)
{
gerbv_fileinfo_t *fi[2];
gerbv_selection_item_t item[2];
gerbv_net_t *net;
gerbv_selection_info_t *sel_info = &screen.selectionInfo;
int align_second_to_first = GPOINTER_TO_INT(user_data);
gdouble x[2], y[2];
int i;
if (selection_length (sel_info) != 2)
return;
item[0] = selection_get_item_by_index(sel_info, 0);
item[1] = selection_get_item_by_index(sel_info, 1);
fi[0] = gerbv_get_fileinfo_for_image (item[0].image, mainProject);
fi[1] = gerbv_get_fileinfo_for_image (item[1].image, mainProject);
if (fi[0] == NULL || fi[1] == NULL || fi[0] == fi[1])
return;
/* Calculate aligning coords */
for (i = 0; i < 2; i++) {
net = item[i].net;
switch (net->aperture_state) {
case GERBV_APERTURE_STATE_FLASH:
x[i] = net->stop_x;
y[i] = net->stop_y;
break;
case GERBV_APERTURE_STATE_ON:
switch (net->interpolation) {
case GERBV_INTERPOLATION_LINEARx1:
case GERBV_INTERPOLATION_LINEARx10:
case GERBV_INTERPOLATION_LINEARx01:
case GERBV_INTERPOLATION_LINEARx001:
x[i] = (net->stop_x + net->start_x)/2;
y[i] = (net->stop_y + net->start_y)/2;
break;
case GERBV_INTERPOLATION_CW_CIRCULAR:
case GERBV_INTERPOLATION_CCW_CIRCULAR:
x[i] = net->cirseg->cp_x;
y[i] = net->cirseg->cp_y;
break;
default:
GERB_COMPILE_ERROR (_("Can't align by this "
"type of object"));
return;
}
break;
default:
GERB_COMPILE_ERROR (_("Can't align by this "
"type of object"));
return;
}
gerbv_transform_coord_for_image(x + i, y + i,
item[i].image, mainProject);
}
if (align_second_to_first) {
fi[1]->transform.translateX += x[0] - x[1];
fi[1]->transform.translateY += y[0] - y[1];
} else {
fi[0]->transform.translateX += x[1] - x[0];
fi[0]->transform.translateY += y[1] - y[0];
}
render_refresh_rendered_image_on_screen ();
callbacks_update_layer_tree ();
}
| 0
|
365,760
|
static void sixpack_close(struct tty_struct *tty)
{
struct sixpack *sp;
write_lock_irq(&disc_data_lock);
sp = tty->disc_data;
tty->disc_data = NULL;
write_unlock_irq(&disc_data_lock);
if (!sp)
return;
/*
* We have now ensured that nobody can start using ap from now on, but
* we have to wait for all existing users to finish.
*/
if (!refcount_dec_and_test(&sp->refcnt))
wait_for_completion(&sp->dead);
/* We must stop the queue to avoid potentially scribbling
* on the free buffers. The sp->dead completion is not sufficient
* to protect us from sp->xbuff access.
*/
netif_stop_queue(sp->dev);
unregister_netdev(sp->dev);
del_timer_sync(&sp->tx_t);
del_timer_sync(&sp->resync_t);
/* Free all 6pack frame buffers after unreg. */
kfree(sp->rbuff);
kfree(sp->xbuff);
free_netdev(sp->dev);
}
| 0
|
366,315
|
void mnt_release_group_id(struct mount *mnt)
{
ida_free(&mnt_group_ida, mnt->mnt_group_id);
mnt->mnt_group_id = 0;
}
| 0
|
200,157
|
readconf_main(void)
{
int sep = 0;
struct stat statbuf;
uschar *s, *filename;
uschar *list = config_main_filelist;
/* Loop through the possible file names */
while((filename = string_nextinlist(&list, &sep, big_buffer, big_buffer_size))
!= NULL)
{
/* Cut out all the fancy processing unless specifically wanted */
#if defined(CONFIGURE_FILE_USE_NODE) || defined(CONFIGURE_FILE_USE_EUID)
uschar *suffix = filename + Ustrlen(filename);
/* Try for the node-specific file if a node name exists */
#ifdef CONFIGURE_FILE_USE_NODE
struct utsname uts;
if (uname(&uts) >= 0)
{
#ifdef CONFIGURE_FILE_USE_EUID
sprintf(CS suffix, ".%ld.%.256s", (long int)original_euid, uts.nodename);
config_file = Ufopen(filename, "rb");
if (config_file == NULL)
#endif /* CONFIGURE_FILE_USE_EUID */
{
sprintf(CS suffix, ".%.256s", uts.nodename);
config_file = Ufopen(filename, "rb");
}
}
#endif /* CONFIGURE_FILE_USE_NODE */
/* Otherwise, try the generic name, possibly with the euid added */
#ifdef CONFIGURE_FILE_USE_EUID
if (config_file == NULL)
{
sprintf(CS suffix, ".%ld", (long int)original_euid);
config_file = Ufopen(filename, "rb");
}
#endif /* CONFIGURE_FILE_USE_EUID */
/* Finally, try the unadorned name */
if (config_file == NULL)
{
*suffix = 0;
config_file = Ufopen(filename, "rb");
}
#else /* if neither defined */
/* This is the common case when the fancy processing is not included. */
config_file = Ufopen(filename, "rb");
#endif
/* If the file does not exist, continue to try any others. For any other
error, break out (and die). */
if (config_file != NULL || errno != ENOENT) break;
}
/* On success, save the name for verification; config_filename is used when
logging configuration errors (it changes for .included files) whereas
config_main_filename is the name shown by -bP. Failure to open a configuration
file is a serious disaster. */
if (config_file != NULL)
{
config_filename = config_main_filename = string_copy(filename);
}
else
{
if (filename == NULL)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "non-existent configuration file(s): "
"%s", config_main_filelist);
else
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "%s", string_open_failed(errno,
"configuration file %s", filename));
}
/* Check the status of the file we have opened, unless it was specified on
the command line, in which case privilege was given away at the start. */
if (!config_changed)
{
if (fstat(fileno(config_file), &statbuf) != 0)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to stat configuration file %s",
big_buffer);
if ((statbuf.st_uid != root_uid /* owner not root */
#ifdef CONFIGURE_OWNER
&& statbuf.st_uid != config_uid /* owner not the special one */
#endif
) || /* or */
(statbuf.st_gid != root_gid /* group not root & */
#ifdef CONFIGURE_GROUP
&& statbuf.st_gid != config_gid /* group not the special one */
#endif
&& (statbuf.st_mode & 020) != 0) || /* group writeable */
/* or */
((statbuf.st_mode & 2) != 0)) /* world writeable */
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "Exim configuration file %s has the "
"wrong owner, group, or mode", big_buffer);
}
/* Process the main configuration settings. They all begin with a lower case
letter. If we see something starting with an upper case letter, it is taken as
a macro definition. */
while ((s = get_config_line()) != NULL)
{
if (isupper(s[0])) read_macro_assignment(s);
else if (Ustrncmp(s, "domainlist", 10) == 0)
read_named_list(&domainlist_anchor, &domainlist_count,
MAX_NAMED_LIST, s+10, US"domain list");
else if (Ustrncmp(s, "hostlist", 8) == 0)
read_named_list(&hostlist_anchor, &hostlist_count,
MAX_NAMED_LIST, s+8, US"host list");
else if (Ustrncmp(s, US"addresslist", 11) == 0)
read_named_list(&addresslist_anchor, &addresslist_count,
MAX_NAMED_LIST, s+11, US"address list");
else if (Ustrncmp(s, US"localpartlist", 13) == 0)
read_named_list(&localpartlist_anchor, &localpartlist_count,
MAX_NAMED_LIST, s+13, US"local part list");
else
(void) readconf_handle_option(s, optionlist_config, optionlist_config_size,
NULL, US"main option \"%s\" unknown");
}
/* If local_sender_retain is set, local_from_check must be unset. */
if (local_sender_retain && local_from_check)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "both local_from_check and "
"local_sender_retain are set; this combination is not allowed");
/* If the timezone string is empty, set it to NULL, implying no TZ variable
wanted. */
if (timezone_string != NULL && *timezone_string == 0) timezone_string = NULL;
/* The max retry interval must not be greater than 24 hours. */
if (retry_interval_max > 24*60*60) retry_interval_max = 24*60*60;
/* remote_max_parallel must be > 0 */
if (remote_max_parallel <= 0) remote_max_parallel = 1;
/* Save the configured setting of freeze_tell, so we can re-instate it at the
start of a new SMTP message. */
freeze_tell_config = freeze_tell;
/* The primary host name may be required for expansion of spool_directory
and log_file_path, so make sure it is set asap. It is obtained from uname(),
but if that yields an unqualified value, make a FQDN by using gethostbyname to
canonize it. Some people like upper case letters in their host names, so we
don't force the case. */
if (primary_hostname == NULL)
{
uschar *hostname;
struct utsname uts;
if (uname(&uts) < 0)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "uname() failed to yield host name");
hostname = US uts.nodename;
if (Ustrchr(hostname, '.') == NULL)
{
int af = AF_INET;
struct hostent *hostdata;
#if HAVE_IPV6
if (!disable_ipv6 && (dns_ipv4_lookup == NULL ||
match_isinlist(hostname, &dns_ipv4_lookup, 0, NULL, NULL, MCL_DOMAIN,
TRUE, NULL) != OK))
af = AF_INET6;
#else
af = AF_INET;
#endif
for (;;)
{
#if HAVE_IPV6
#if HAVE_GETIPNODEBYNAME
int error_num;
hostdata = getipnodebyname(CS hostname, af, 0, &error_num);
#else
hostdata = gethostbyname2(CS hostname, af);
#endif
#else
hostdata = gethostbyname(CS hostname);
#endif
if (hostdata != NULL)
{
hostname = US hostdata->h_name;
break;
}
if (af == AF_INET) break;
af = AF_INET;
}
}
primary_hostname = string_copy(hostname);
}
/* Set up default value for smtp_active_hostname */
smtp_active_hostname = primary_hostname;
/* If spool_directory wasn't set in the build-time configuration, it must have
got set above. Of course, writing to the log may not work if log_file_path is
not set, but it will at least get to syslog or somewhere, with any luck. */
if (*spool_directory == 0)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "spool_directory undefined: cannot "
"proceed");
/* Expand the spool directory name; it may, for example, contain the primary
host name. Same comment about failure. */
s = expand_string(spool_directory);
if (s == NULL)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to expand spool_directory "
"\"%s\": %s", spool_directory, expand_string_message);
spool_directory = s;
/* Expand log_file_path, which must contain "%s" in any component that isn't
the null string or "syslog". It is also allowed to contain one instance of %D.
However, it must NOT contain % followed by anything else. */
if (*log_file_path != 0)
{
uschar *ss, *sss;
int sep = ':'; /* Fixed for log file path */
s = expand_string(log_file_path);
if (s == NULL)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to expand log_file_path "
"\"%s\": %s", log_file_path, expand_string_message);
ss = s;
while ((sss = string_nextinlist(&ss,&sep,big_buffer,big_buffer_size)) != NULL)
{
uschar *t;
if (sss[0] == 0 || Ustrcmp(sss, "syslog") == 0) continue;
t = Ustrstr(sss, "%s");
if (t == NULL)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "log_file_path \"%s\" does not "
"contain \"%%s\"", sss);
*t = 'X';
t = Ustrchr(sss, '%');
if (t != NULL)
{
if (t[1] != 'D' || Ustrchr(t+2, '%') != NULL)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "log_file_path \"%s\" contains "
"unexpected \"%%\" character", s);
}
}
log_file_path = s;
}
/* Interpret syslog_facility into an integer argument for 'ident' param to
openlog(). Default is LOG_MAIL set in globals.c. Allow the user to omit the
leading "log_". */
if (syslog_facility_str != NULL)
{
int i;
uschar *s = syslog_facility_str;
if ((Ustrlen(syslog_facility_str) >= 4) &&
(strncmpic(syslog_facility_str, US"log_", 4) == 0))
s += 4;
for (i = 0; i < syslog_list_size; i++)
{
if (strcmpic(s, syslog_list[i].name) == 0)
{
syslog_facility = syslog_list[i].value;
break;
}
}
if (i >= syslog_list_size)
{
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"failed to interpret syslog_facility \"%s\"", syslog_facility_str);
}
}
/* Expand pid_file_path */
if (*pid_file_path != 0)
{
s = expand_string(pid_file_path);
if (s == NULL)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to expand pid_file_path "
"\"%s\": %s", pid_file_path, expand_string_message);
pid_file_path = s;
}
/* Compile the regex for matching a UUCP-style "From_" line in an incoming
message. */
regex_From = regex_must_compile(uucp_from_pattern, FALSE, TRUE);
/* Unpick the SMTP rate limiting options, if set */
if (smtp_ratelimit_mail != NULL)
{
unpick_ratelimit(smtp_ratelimit_mail, &smtp_rlm_threshold,
&smtp_rlm_base, &smtp_rlm_factor, &smtp_rlm_limit);
}
if (smtp_ratelimit_rcpt != NULL)
{
unpick_ratelimit(smtp_ratelimit_rcpt, &smtp_rlr_threshold,
&smtp_rlr_base, &smtp_rlr_factor, &smtp_rlr_limit);
}
/* The qualify domains default to the primary host name */
if (qualify_domain_sender == NULL)
qualify_domain_sender = primary_hostname;
if (qualify_domain_recipient == NULL)
qualify_domain_recipient = qualify_domain_sender;
/* Setting system_filter_user in the configuration sets the gid as well if a
name is given, but a numerical value does not. */
if (system_filter_uid_set && !system_filter_gid_set)
{
struct passwd *pw = getpwuid(system_filter_uid);
if (pw == NULL)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "Failed to look up uid %ld",
(long int)system_filter_uid);
system_filter_gid = pw->pw_gid;
system_filter_gid_set = TRUE;
}
/* If the errors_reply_to field is set, check that it is syntactically valid
and ensure it contains a domain. */
if (errors_reply_to != NULL)
{
uschar *errmess;
int start, end, domain;
uschar *recipient = parse_extract_address(errors_reply_to, &errmess,
&start, &end, &domain, FALSE);
if (recipient == NULL)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"error in errors_reply_to (%s): %s", errors_reply_to, errmess);
if (domain == 0)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"errors_reply_to (%s) does not contain a domain", errors_reply_to);
}
/* If smtp_accept_queue or smtp_accept_max_per_host is set, then
smtp_accept_max must also be set. */
if (smtp_accept_max == 0 &&
(smtp_accept_queue > 0 || smtp_accept_max_per_host != NULL))
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"smtp_accept_max must be set if smtp_accept_queue or "
"smtp_accept_max_per_host is set");
/* Set up the host number if anything is specified. It is an expanded string
so that it can be computed from the host name, for example. We do this last
so as to ensure that everything else is set up before the expansion. */
if (host_number_string != NULL)
{
uschar *end;
uschar *s = expand_string(host_number_string);
long int n = Ustrtol(s, &end, 0);
while (isspace(*end)) end++;
if (*end != 0)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"localhost_number value is not a number: %s", s);
if (n > LOCALHOST_MAX)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"localhost_number is greater than the maximum allowed value (%d)",
LOCALHOST_MAX);
host_number = n;
}
#ifdef SUPPORT_TLS
/* If tls_verify_hosts is set, tls_verify_certificates must also be set */
if ((tls_verify_hosts != NULL || tls_try_verify_hosts != NULL) &&
tls_verify_certificates == NULL)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"tls_%sverify_hosts is set, but tls_verify_certificates is not set",
(tls_verify_hosts != NULL)? "" : "try_");
/* If openssl_options is set, validate it */
if (openssl_options != NULL)
{
# ifdef USE_GNUTLS
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"openssl_options is set but we're using GnuTLS");
# else
long dummy;
if (!(tls_openssl_options_parse(openssl_options, &dummy)))
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"openssl_options parse error: %s", openssl_options);
# endif
}
#endif
}
| 1
|
224,200
|
gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep)
{
if (nopeep || no_peephole(s)) goto normal;
else if (dst == src) return;
else {
struct mrb_insn_data data = mrb_last_insn(s);
switch (data.insn) {
case OP_MOVE:
if (dst == src) return; /* remove useless MOVE */
if (data.a == src) {
if (data.b == dst) /* skip swapping MOVE */
return;
if (data.a < s->nlocals) goto normal;
rewind_pc(s);
s->lastpc = addr_pc(s, mrb_prev_pc(s, data.addr));
gen_move(s, dst, data.b, FALSE);
return;
}
if (dst == data.a) { /* skip overwritten move */
rewind_pc(s);
s->lastpc = addr_pc(s, mrb_prev_pc(s, data.addr));
gen_move(s, dst, src, FALSE);
return;
}
goto normal;
case OP_LOADNIL: case OP_LOADSELF: case OP_LOADT: case OP_LOADF:
case OP_LOADI__1:
case OP_LOADI_0: case OP_LOADI_1: case OP_LOADI_2: case OP_LOADI_3:
case OP_LOADI_4: case OP_LOADI_5: case OP_LOADI_6: case OP_LOADI_7:
if (data.a != src || data.a < s->nlocals) goto normal;
rewind_pc(s);
genop_1(s, data.insn, dst);
return;
case OP_HASH:
if (data.b != 0) goto normal;
/* fall through */
case OP_LOADI: case OP_LOADINEG:
case OP_LOADL: case OP_LOADSYM:
case OP_GETGV: case OP_GETSV: case OP_GETIV: case OP_GETCV:
case OP_GETCONST: case OP_STRING:
case OP_LAMBDA: case OP_BLOCK: case OP_METHOD: case OP_BLKPUSH:
if (data.a != src || data.a < s->nlocals) goto normal;
rewind_pc(s);
genop_2(s, data.insn, dst, data.b);
return;
case OP_LOADI16:
if (data.a != src || data.a < s->nlocals) goto normal;
rewind_pc(s);
genop_2S(s, data.insn, dst, data.b);
return;
case OP_LOADI32:
if (data.a != src || data.a < s->nlocals) goto normal;
else {
uint32_t i = (uint32_t)data.b<<16|data.c;
rewind_pc(s);
genop_2SS(s, data.insn, dst, i);
}
return;
case OP_ARRAY:
if (data.a != src || data.a < s->nlocals || data.a < dst) goto normal;
rewind_pc(s);
if (data.b == 0 || dst == data.a)
genop_2(s, OP_ARRAY, dst, 0);
else
genop_3(s, OP_ARRAY2, dst, data.a, data.b);
return;
case OP_ARRAY2:
if (data.a != src || data.a < s->nlocals || data.a < dst) goto normal;
rewind_pc(s);
genop_3(s, OP_ARRAY2, dst, data.b, data.c);
return;
case OP_AREF:
case OP_GETUPVAR:
if (data.a != src || data.a < s->nlocals) goto normal;
rewind_pc(s);
genop_3(s, data.insn, dst, data.b, data.c);
return;
case OP_ADDI: case OP_SUBI:
if (addr_pc(s, data.addr) == s->lastlabel || data.a != src || data.a < s->nlocals) goto normal;
else {
struct mrb_insn_data data0 = mrb_decode_insn(mrb_prev_pc(s, data.addr));
if (data0.insn != OP_MOVE || data0.a != data.a || data0.b != dst) goto normal;
s->pc = addr_pc(s, data0.addr);
if (addr_pc(s, data0.addr) != s->lastlabel) {
/* constant folding */
data0 = mrb_decode_insn(mrb_prev_pc(s, data0.addr));
mrb_int n;
if (data0.a == dst && get_int_operand(s, &data0, &n)) {
if ((data.insn == OP_ADDI && !mrb_int_add_overflow(n, data.b, &n)) ||
(data.insn == OP_SUBI && !mrb_int_sub_overflow(n, data.b, &n))) {
s->pc = addr_pc(s, data0.addr);
gen_int(s, dst, n);
return;
}
}
}
}
genop_2(s, data.insn, dst, data.b);
return;
default:
break;
}
}
normal:
genop_2(s, OP_MOVE, dst, src);
return;
}
| 0
|
317,067
|
static int smk_ipv4_check(struct sock *sk, struct sockaddr_in *sap)
{
struct smack_known *skp;
int rc = 0;
struct smack_known *hkp;
struct socket_smack *ssp = sk->sk_security;
struct smk_audit_info ad;
rcu_read_lock();
hkp = smack_ipv4host_label(sap);
if (hkp != NULL) {
#ifdef CONFIG_AUDIT
struct lsm_network_audit net;
smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net);
ad.a.u.net->family = sap->sin_family;
ad.a.u.net->dport = sap->sin_port;
ad.a.u.net->v4info.daddr = sap->sin_addr.s_addr;
#endif
skp = ssp->smk_out;
rc = smk_access(skp, hkp, MAY_WRITE, &ad);
rc = smk_bu_note("IPv4 host check", skp, hkp, MAY_WRITE, rc);
/*
* Clear the socket netlabel if it's set.
*/
if (!rc)
smack_netlbl_delete(sk);
}
rcu_read_unlock();
return rc;
}
| 0
|
366,294
|
void kern_unmount_array(struct vfsmount *mnt[], unsigned int num)
{
unsigned int i;
for (i = 0; i < num; i++)
if (mnt[i])
real_mount(mnt[i])->mnt_ns = NULL;
synchronize_rcu_expedited();
for (i = 0; i < num; i++)
mntput(mnt[i]);
}
| 0
|
522,358
|
int GmfSetHONodesOrdering(int64_t MshIdx, int KwdCod, int *BasTab, int *OrdTab)
{
int i, j, k, flg, NmbNod, NmbCrd;
GmfMshSct *msh = (GmfMshSct *)MshIdx;
KwdSct *kwd;
// printf("\n\tGmfSetHONodesOrdering 0\n");
if( (KwdCod < 1) || (KwdCod > GmfMaxKwd) )
return(0);
kwd = &msh->KwdTab[ KwdCod ];
// Find the Bezier indices dimension according to the element's kind
switch(KwdCod)
{
case GmfEdges : NmbNod = 2; NmbCrd = 1; break;
case GmfEdgesP2 : NmbNod = 3; NmbCrd = 1; break;
case GmfEdgesP3 : NmbNod = 4; NmbCrd = 1; break;
case GmfEdgesP4 : NmbNod = 5; NmbCrd = 1; break;
case GmfTriangles : NmbNod = 3; NmbCrd = 3; break;
case GmfTrianglesP2 : NmbNod = 6; NmbCrd = 3; break;
case GmfTrianglesP3 : NmbNod = 10; NmbCrd = 3; break;
case GmfTrianglesP4 : NmbNod = 15; NmbCrd = 3; break;
case GmfQuadrilaterals : NmbNod = 4; NmbCrd = 2; break;
case GmfQuadrilateralsQ2 : NmbNod = 9; NmbCrd = 2; break;
case GmfQuadrilateralsQ3 : NmbNod = 16; NmbCrd = 2; break;
case GmfQuadrilateralsQ4 : NmbNod = 25; NmbCrd = 2; break;
case GmfTetrahedra : NmbNod = 4; NmbCrd = 4; break;
case GmfTetrahedraP2 : NmbNod = 10; NmbCrd = 4; break;
case GmfTetrahedraP3 : NmbNod = 20; NmbCrd = 4; break;
case GmfTetrahedraP4 : NmbNod = 35; NmbCrd = 4; break;
case GmfPyramids : NmbNod = 5; NmbCrd = 3; break;
case GmfPyramidsP2 : NmbNod = 14; NmbCrd = 3; break;
case GmfPyramidsP3 : NmbNod = 30; NmbCrd = 3; break;
case GmfPyramidsP4 : NmbNod = 55; NmbCrd = 3; break;
case GmfPrisms : NmbNod = 6; NmbCrd = 4; break;
case GmfPrismsP2 : NmbNod = 18; NmbCrd = 4; break;
case GmfPrismsP3 : NmbNod = 40; NmbCrd = 4; break;
case GmfPrismsP4 : NmbNod = 75; NmbCrd = 4; break;
case GmfHexahedra : NmbNod = 8; NmbCrd = 3; break;
case GmfHexahedraQ2 : NmbNod = 27; NmbCrd = 3; break;
case GmfHexahedraQ3 : NmbNod = 64; NmbCrd = 3; break;
case GmfHexahedraQ4 : NmbNod =125; NmbCrd = 3; break;
default : return(0);
}
// Free and rebuild the mapping table if there were already one
if(kwd->OrdTab)
free(kwd->OrdTab);
if(!(kwd->OrdTab = malloc(NmbNod * sizeof(int))))
return(0);
// Find the corresponding Bezier coordinates from the source table
for(i=0;i<NmbNod;i++)
{
for(j=0;j<NmbNod;j++)
{
flg = 1;
for(k=0;k<NmbCrd;k++)
if(BasTab[ i * NmbCrd + k ] != OrdTab[ j * NmbCrd + k ])
{
flg = 0;
break;
}
if(flg)
kwd->OrdTab[j] = i;
}
}
// Check the ordering consistency
for(i=0;i<NmbNod;i++)
{
flg = 0;
for(j=0;j<NmbNod;j++)
if(kwd->OrdTab[j] == i)
{
flg = 1;
break;
}
if(!flg)
{
for(j=0;j<NmbNod;j++)
kwd->OrdTab[j] = j;
return(0);
}
}
return(1);
}
| 0
|
310,141
|
line_capability(const char *name)
{
bool result = FALSE;
static const char *table[] =
{
"csr", /* change_scroll_region */
"clear", /* clear_screen */
"ed", /* clr_eos */
"cwin", /* create_window */
"cup", /* cursor_address */
"cud1", /* cursor_down */
"home", /* cursor_home */
"mrcup", /* cursor_mem_address */
"ll", /* cursor_to_ll */
"cuu1", /* cursor_up */
"dl1", /* delete_line */
"hd", /* down_half_line */
"flash", /* flash_screen */
"ff", /* form_feed */
"il1", /* insert_line */
"nel", /* newline */
"dl", /* parm_delete_line */
"cud", /* parm_down_cursor */
"indn", /* parm_index */
"il", /* parm_insert_line */
"rin", /* parm_rindex */
"cuu", /* parm_up_cursor */
"mc0", /* print_screen */
"vpa", /* row_address */
"ind", /* scroll_forward */
"ri", /* scroll_reverse */
"hu", /* up_half_line */
};
size_t n;
for (n = 0; n < SIZEOF(table); ++n) {
if (!strcmp(name, table[n])) {
result = TRUE;
break;
}
}
return result;
}
| 0
|
312,483
|
qf_goto_cwindow(qf_info_T *qi, int resize, int sz, int vertsplit)
{
win_T *win;
win = qf_find_win(qi);
if (win == NULL)
return FAIL;
win_goto(win);
if (resize)
{
if (vertsplit)
{
if (sz != win->w_width)
win_setwidth(sz);
}
else if (sz != win->w_height && win->w_height
+ win->w_status_height + tabline_height() < cmdline_row)
win_setheight(sz);
}
return OK;
}
| 0
|
498,110
|
const char *cgit_rooturl(void)
{
if (ctx.cfg.virtual_root)
return ctx.cfg.virtual_root;
else
return ctx.cfg.script_name;
}
| 0
|
236,182
|
GF_Err krok_box_write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
u32 i;
GF_TextKaraokeBox*ptr = (GF_TextKaraokeBox*)s;
e = gf_isom_box_write_header(s, bs);
if (e) return e;
gf_bs_write_u32(bs, ptr->highlight_starttime);
gf_bs_write_u16(bs, ptr->nb_entries);
for (i=0; i<ptr->nb_entries; i++) {
gf_bs_write_u32(bs, ptr->records[i].highlight_endtime);
gf_bs_write_u16(bs, ptr->records[i].start_charoffset);
gf_bs_write_u16(bs, ptr->records[i].end_charoffset);
}
return GF_OK;
}
| 0
|
221,422
|
void nested_sync_control_from_vmcb02(struct vcpu_svm *svm)
{
u32 mask;
svm->nested.ctl.event_inj = svm->vmcb->control.event_inj;
svm->nested.ctl.event_inj_err = svm->vmcb->control.event_inj_err;
/* Only a few fields of int_ctl are written by the processor. */
mask = V_IRQ_MASK | V_TPR_MASK;
if (!(svm->nested.ctl.int_ctl & V_INTR_MASKING_MASK) &&
svm_is_intercept(svm, INTERCEPT_VINTR)) {
/*
* In order to request an interrupt window, L0 is usurping
* svm->vmcb->control.int_ctl and possibly setting V_IRQ
* even if it was clear in L1's VMCB. Restoring it would be
* wrong. However, in this case V_IRQ will remain true until
* interrupt_window_interception calls svm_clear_vintr and
* restores int_ctl. We can just leave it aside.
*/
mask &= ~V_IRQ_MASK;
}
svm->nested.ctl.int_ctl &= ~mask;
svm->nested.ctl.int_ctl |= svm->vmcb->control.int_ctl & mask;
}
| 0
|
226,119
|
GF_Err minf_box_write(GF_Box *s, GF_BitStream *bs)
{
return gf_isom_box_write_header(s, bs);
}
| 0
|
225,094
|
void FillAttrMap(const OpDef& op_def, AttrMap* attr_map) {
for (const auto& attr : op_def.attr()) {
(*attr_map)[attr.name()] = &attr;
}
}
| 0
|
259,610
|
void HierarchicalBitmapRequester::ReconstructRegion(const RectAngle<LONG> &orgregion,const struct RectangleRequest *rr)
{
#if ACCUSOFT_CODE
class ColorTrafo *ctrafo = ColorTrafoOf(false,!rr->rr_bColorTrafo);
UBYTE i;
if (m_bSubsampling && rr->rr_bUpsampling) {
for(i = rr->rr_usFirstComponent;i <= rr->rr_usLastComponent;i++) {
class Component *comp = m_pFrame->ComponentOf(i);
UBYTE subx = comp->SubXOf();
UBYTE suby = comp->SubYOf();
class UpsamplerBase *up; // upsampler
LONG bx,by;
RectAngle<LONG> blocks;
//
// Compute the region of blocks
assert(subx > 0 && suby > 0);
if ((up = m_ppUpsampler[i])) {
LONG bwidth = ((m_ulPixelWidth + subx - 1) / subx + 7) >> 3;
LONG bheight = ((m_ulPixelHeight + suby - 1) / suby + 7) >> 3;
LONG rx = (subx > 1)?(1):(0);
LONG ry = (suby > 1)?(1):(0);
// The +/-1 include additional lines required for subsampling expansion
blocks.ra_MinX = ((orgregion.ra_MinX / subx - rx) >> 3);
blocks.ra_MaxX = ((orgregion.ra_MaxX / subx + rx) >> 3);
blocks.ra_MinY = ((orgregion.ra_MinY / suby - ry) >> 3);
blocks.ra_MaxY = ((orgregion.ra_MaxY / suby + ry) >> 3);
// Clip.
if (blocks.ra_MinX < 0) blocks.ra_MinX = 0;
if (blocks.ra_MaxX >= bwidth) blocks.ra_MaxX = bwidth - 1;
if (blocks.ra_MinY < 0) blocks.ra_MinY = 0;
if (blocks.ra_MaxY >= bheight) blocks.ra_MaxY = bheight - 1;
up->SetBufferedRegion(blocks); // also removes the rectangle of blocks already buffered.
//
for(by = blocks.ra_MinY;by <= blocks.ra_MaxY;by++) {
Pull8Lines(i);
for(bx = blocks.ra_MinX;bx <= blocks.ra_MaxX;bx++) {
LONG dst[64];
FetchRegion(bx,m_ppDecodingMCU + (i << 3),dst);
up->DefineRegion(bx,by,dst);
}
Release8Lines(i);
}
} else {
// Load into the decoding MCU
Pull8Lines(i);
}
}
// Now push blocks into the color transformer from the upsampler.
{
RectAngle<LONG> r;
ULONG minx = orgregion.ra_MinX >> 3;
ULONG maxx = orgregion.ra_MaxX >> 3;
ULONG miny = orgregion.ra_MinY >> 3;
ULONG maxy = orgregion.ra_MaxY >> 3;
ULONG x,y;
if (maxy > m_ulMaxMCU)
maxy = m_ulMaxMCU;
for(y = miny,r.ra_MinY = orgregion.ra_MinY;y <= maxy;y++,r.ra_MinY = r.ra_MaxY + 1) {
r.ra_MaxY = (r.ra_MinY & -8) + 7;
if (r.ra_MaxY > orgregion.ra_MaxY)
r.ra_MaxY = orgregion.ra_MaxY;
for(x = minx,r.ra_MinX = orgregion.ra_MinX;x <= maxx;x++,r.ra_MinX = r.ra_MaxX + 1) {
r.ra_MaxX = (r.ra_MinX & -8) + 7;
if (r.ra_MaxX > orgregion.ra_MaxX)
r.ra_MaxX = orgregion.ra_MaxX;
for(i = 0;i < m_ucCount;i++) {
if (i >= rr->rr_usFirstComponent && i <= rr->rr_usLastComponent) {
ExtractBitmap(m_ppTempIBM[i],r,i);
if (m_ppUpsampler[i]) {
// Upsampled case, take from the upsampler, transform
// into the color buffer.
m_ppUpsampler[i]->UpsampleRegion(r,m_ppCTemp[i]);
} else {
FetchRegion(x,m_ppDecodingMCU + (i << 3),m_ppCTemp[i]);
}
} else {
// Not requested, zero the buffer.
memset(m_ppCTemp[i],0,sizeof(LONG) * 64);
}
}
ctrafo->YCbCr2RGB(r,m_ppTempIBM,m_ppCTemp,NULL);
}
//
// Advance the quantized rows for the non-subsampled components,
// upsampled components have been advanced above.
for(i = rr->rr_usFirstComponent;i <= rr->rr_usLastComponent;i++) {
if (m_ppUpsampler[i] == NULL)
Release8Lines(i);
}
}
}
} else {
// direct case, no upsampling required, residual coding possible, but not applied here.
RectAngle<LONG> r;
RectAngle<LONG> region = orgregion;
SubsampledRegion(region,rr);
ULONG minx = region.ra_MinX >> 3;
ULONG maxx = region.ra_MaxX >> 3;
ULONG miny = region.ra_MinY >> 3;
ULONG maxy = region.ra_MaxY >> 3;
ULONG x,y;
if (maxy > m_ulMaxMCU)
maxy = m_ulMaxMCU;
for(i = rr->rr_usFirstComponent;i <= rr->rr_usLastComponent;i++) {
Pull8Lines(i);
}
for(y = miny,r.ra_MinY = region.ra_MinY;y <= maxy;y++,r.ra_MinY = r.ra_MaxY + 1) {
r.ra_MaxY = (r.ra_MinY & -8) + 7;
if (r.ra_MaxY > region.ra_MaxY)
r.ra_MaxY = region.ra_MaxY;
for(x = minx,r.ra_MinX = region.ra_MinX;x <= maxx;x++,r.ra_MinX = r.ra_MaxX + 1) {
r.ra_MaxX = (r.ra_MinX & -8) + 7;
if (r.ra_MaxX > region.ra_MaxX)
r.ra_MaxX = region.ra_MaxX;
for(i = 0;i < m_ucCount;i++) {
LONG *dst = m_ppCTemp[i];
if (i >= rr->rr_usFirstComponent && i <= rr->rr_usLastComponent) {
ExtractBitmap(m_ppTempIBM[i],r,i);
FetchRegion(x,m_ppDecodingMCU + (i << 3),dst);
} else {
memset(dst,0,sizeof(LONG) * 64);
}
}
//
// Perform the color transformation now.
ctrafo->YCbCr2RGB(r,m_ppTempIBM,m_ppCTemp,NULL);
} // of loop over x
//
// Advance the rows.
for(i = rr->rr_usFirstComponent;i <= rr->rr_usLastComponent;i++) {
Release8Lines(i);
}
}
}
#else
NOREF(orgregion);
NOREF(rr);
#endif
}
| 0
|
411,929
|
need_referral(krb5_context context, krb5_kdc_configuration *config,
const KDCOptions * const options, krb5_principal server,
krb5_realm **realms)
{
const char *name;
if(!options->canonicalize && server->name.name_type != KRB5_NT_SRV_INST)
return FALSE;
if (server->name.name_string.len == 1)
name = server->name.name_string.val[0];
else if (server->name.name_string.len == 3) {
/*
This is used to give referrals for the
E3514235-4B06-11D1-AB04-00C04FC2DCD2/NTDSGUID/DNSDOMAIN
SPN form, which is used for inter-domain communication in AD
*/
name = server->name.name_string.val[2];
kdc_log(context, config, 4, "Giving 3 part referral for %s", name);
*realms = malloc(sizeof(char *)*2);
if (*realms == NULL) {
krb5_set_error_message(context, ENOMEM, N_("malloc: out of memory", ""));
return FALSE;
}
(*realms)[0] = strdup(name);
(*realms)[1] = NULL;
return TRUE;
} else if (server->name.name_string.len > 1)
name = server->name.name_string.val[1];
else
return FALSE;
kdc_log(context, config, 5, "Searching referral for %s", name);
return _krb5_get_host_realm_int(context, name, FALSE, realms) == 0;
}
| 0
|
459,513
|
get_callchain_entry_for_task(struct task_struct *task, u32 init_nr)
{
#ifdef CONFIG_STACKTRACE
struct perf_callchain_entry *entry;
int rctx;
entry = get_callchain_entry(&rctx);
if (!entry)
return NULL;
entry->nr = init_nr +
stack_trace_save_tsk(task, (unsigned long *)(entry->ip + init_nr),
sysctl_perf_event_max_stack - init_nr, 0);
/* stack_trace_save_tsk() works on unsigned long array, while
* perf_callchain_entry uses u64 array. For 32-bit systems, it is
* necessary to fix this mismatch.
*/
if (__BITS_PER_LONG != 64) {
unsigned long *from = (unsigned long *) entry->ip;
u64 *to = entry->ip;
int i;
/* copy data from the end to avoid using extra buffer */
for (i = entry->nr - 1; i >= (int)init_nr; i--)
to[i] = (u64)(from[i]);
}
put_callchain_entry(rctx);
return entry;
#else /* CONFIG_STACKTRACE */
return NULL;
#endif
}
| 0
|
247,757
|
bool InvertibleRWFunction::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const
{
return GetValueHelper<RWFunction>(this, name, valueType, pValue).Assignable()
CRYPTOPP_GET_FUNCTION_ENTRY(Prime1)
CRYPTOPP_GET_FUNCTION_ENTRY(Prime2)
CRYPTOPP_GET_FUNCTION_ENTRY(MultiplicativeInverseOfPrime2ModPrime1)
;
}
| 0
|
421,387
|
static void sblock(int d, js_Ast *list)
{
ps("[\n");
in(d+1);
while (list) {
assert(list->type == AST_LIST);
snode(d+1, list->a);
list = list->b;
if (list) {
nl();
in(d+1);
}
}
nl(); in(d); pc(']');
}
| 0
|
252,403
|
static void swap8(tinyexr::tinyexr_uint64 *val) {
#ifdef MINIZ_LITTLE_ENDIAN
(void)val;
#else
tinyexr::tinyexr_uint64 tmp = (*val);
unsigned char *dst = reinterpret_cast<unsigned char *>(val);
unsigned char *src = reinterpret_cast<unsigned char *>(&tmp);
dst[0] = src[7];
dst[1] = src[6];
dst[2] = src[5];
dst[3] = src[4];
dst[4] = src[3];
dst[5] = src[2];
dst[6] = src[1];
dst[7] = src[0];
#endif
}
| 0
|
439,073
|
ModuleExport size_t RegisterFLIFImage(void)
{
char
version[MaxTextExtent];
MagickInfo
*entry;
*version='\0';
entry=SetMagickInfo("FLIF");
#if defined(MAGICKCORE_FLIF_DELEGATE)
entry->decoder=(DecodeImageHandler *) ReadFLIFImage;
entry->encoder=(EncodeImageHandler *) WriteFLIFImage;
(void) FormatLocaleString(version,MaxTextExtent,"libflif %d.%d.%d [%04X]",
(FLIF_VERSION >> 16) & 0xff,
(FLIF_VERSION >> 8) & 0xff,
(FLIF_VERSION >> 0) & 0xff,FLIF_ABI_VERSION);
#endif
entry->description=ConstantString("Free Lossless Image Format");
entry->adjoin=MagickTrue;
entry->module=ConstantString("FLIF");
entry->mime_type=ConstantString("image/flif");
entry->magick=(IsImageFormatHandler *) IsFLIF;
if (*version != '\0')
entry->version=ConstantString(version);
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
| 0
|
220,186
|
void Graph::ReleaseNode(Node* node) {
TF_DCHECK_OK(IsValidNode(node)) << node->DebugString();
nodes_[node->id()] = nullptr;
free_nodes_.push_back(node);
--num_nodes_;
node->Clear();
}
| 0
|
233,839
|
int fmtutil_default_box_handler(deark *c, struct de_boxesctx *bctx)
{
struct de_boxdata *curbox = bctx->curbox;
if(curbox->is_uuid) {
if(!de_memcmp(curbox->uuid, "\xb1\x4b\xf8\xbd\x08\x3d\x4b\x43\xa5\xae\x8c\xd7\xd5\xa6\xce\x03", 16)) {
de_dbg(c, "GeoTIFF data at %"I64_FMT", len=%"I64_FMT, curbox->payload_pos, curbox->payload_len);
dbuf_create_file_from_slice(bctx->f, curbox->payload_pos, curbox->payload_len, "geo.tif", NULL, DE_CREATEFLAG_IS_AUX);
}
else if(!de_memcmp(curbox->uuid, "\xbe\x7a\xcf\xcb\x97\xa9\x42\xe8\x9c\x71\x99\x94\x91\xe3\xaf\xac", 16)) {
de_dbg(c, "XMP data at %"I64_FMT", len=%"I64_FMT, curbox->payload_pos, curbox->payload_len);
dbuf_create_file_from_slice(bctx->f, curbox->payload_pos, curbox->payload_len, "xmp", NULL, DE_CREATEFLAG_IS_AUX);
}
else if(!de_memcmp(curbox->uuid, "\x2c\x4c\x01\x00\x85\x04\x40\xb9\xa0\x3e\x56\x21\x48\xd6\xdf\xeb", 16)) {
de_dbg(c, "Photoshop resources at %"I64_FMT", len=%"I64_FMT, curbox->payload_pos, curbox->payload_len);
de_dbg_indent(c, 1);
fmtutil_handle_photoshop_rsrc(c, bctx->f, curbox->payload_pos, curbox->payload_len, 0x0);
de_dbg_indent(c, -1);
}
else if(!de_memcmp(curbox->uuid, "\x05\x37\xcd\xab\x9d\x0c\x44\x31\xa7\x2a\xfa\x56\x1f\x2a\x11\x3e", 16) ||
!de_memcmp(curbox->uuid, "JpgTiffExif->JP2", 16))
{
de_dbg(c, "Exif data at %"I64_FMT", len=%"I64_FMT, curbox->payload_pos, curbox->payload_len);
de_dbg_indent(c, 1);
fmtutil_handle_exif(c, curbox->payload_pos, curbox->payload_len);
de_dbg_indent(c, -1);
}
}
return 1;
}
| 0
|
225,438
|
static void free_buffers(struct v4l2_loopback_device *dev)
{
MARK();
dprintk("freeing image@%p for dev:%p\n", dev ? dev->image : NULL, dev);
if (dev->image) {
vfree(dev->image);
dev->image = NULL;
}
if (dev->timeout_image) {
vfree(dev->timeout_image);
dev->timeout_image = NULL;
}
dev->imagesize = 0;
}
| 0
|
256,172
|
ALWAYS_INLINE void MulAdd3Way(const Packet a1, const Packet a2, const Packet a3,
const bfloat16** binp1, const bfloat16** binp2,
const bfloat16** binp3, float** out) {
auto inp1 = reinterpret_cast<const float*>(*binp1);
auto inp2 = reinterpret_cast<const float*>(*binp2);
auto inp3 = reinterpret_cast<const float*>(*binp3);
auto c1 = LOAD(*out);
auto c2 = LOAD(*out + kNumOperands);
const auto b1 = LOAD(inp1);
EXPAND_BFLOAT_L(b1, b1_0);
EXPAND_BFLOAT_U(b1, b1_1);
*binp1 += 2 * kNumOperands;
const auto b2 = LOAD(inp2);
EXPAND_BFLOAT_L(b2, b2_0);
EXPAND_BFLOAT_U(b2, b2_1);
*binp2 += 2 * kNumOperands;
const auto b3 = LOAD(inp3);
EXPAND_BFLOAT_L(b3, b3_0);
EXPAND_BFLOAT_U(b3, b3_1);
*binp3 += 2 * kNumOperands;
FMA(a1, b1_0, c1, c1);
FMA(a1, b1_1, c2, c2);
FMA(a2, b2_0, c1, c1);
FMA(a2, b2_1, c2, c2);
FMA(a3, b3_0, c1, c1);
FMA(a3, b3_1, c2, c2);
STORE(*out, c1);
STORE(*out + kNumOperands, c2);
*out += 2 * kNumOperands;
}
| 0
|
278,274
|
tabstop_first(int *ts)
{
return ts != NULL ? ts[1] : 8;
}
| 0
|
294,366
|
tmx_m_secs(union DateData *x)
{
VALUE s;
int df;
s = day_to_sec(f_sub(m_real_jd(x),
UNIX_EPOCH_IN_CJD));
if (simple_dat_p(x))
return s;
df = m_df(x);
if (df)
s = f_add(s, INT2FIX(df));
return s;
}
| 0
|
220,174
|
const Edge* Graph::AddEdge(Node* source, int x, Node* dest, int y) {
TF_DCHECK_OK(IsValidNode(source)) << source->DebugString();
TF_DCHECK_OK(IsValidNode(dest)) << dest->DebugString();
// source/sink must only be linked via control slots, and
// control slots must only be linked to control slots.
if (source == source_node() || dest == sink_node() || x == kControlSlot ||
y == kControlSlot) {
DCHECK_EQ(x, kControlSlot) << source->DebugString();
DCHECK_EQ(y, kControlSlot) << dest->DebugString();
}
Edge* e = nullptr;
if (free_edges_.empty()) {
e = new (arena_.Alloc(sizeof(Edge))) Edge; // placement new
} else {
e = free_edges_.back();
free_edges_.pop_back();
}
e->id_ = edges_.size();
e->src_ = source;
e->dst_ = dest;
e->src_output_ = x;
e->dst_input_ = y;
CHECK(source->out_edges_.insert(e).second);
CHECK(dest->in_edges_.insert(e).second);
edges_.push_back(e);
++num_edges_;
if (!e->IsControlEdge()) {
if (dest->in_edges_.size() >= dest->props_->input_types.size()) {
// Note: this only produces consistent results at graph construction,
// and only when all incoming edges are up-to-date.
// If the graph is subsequently modified, or if the node is added before
// any of its upstream nodes, this type information would change as well.
// In general, graph transformations should run shole-graph type inference
// when done, and should not rely on types being fully up to date
// after each AddNode.
// TODO(mdan): Should we even run type inference here any more?
dest->RunForwardTypeInference();
}
}
return e;
}
| 0
|
273,919
|
static void list(ctrl_t *ctrl, char *arg, int mode)
{
char *path;
if (string_valid(arg)) {
char *ptr, *quot;
/* Check if client sends ls arguments ... */
ptr = arg;
while (*ptr) {
if (isspace(*ptr))
ptr++;
if (*ptr == '-') {
while (*ptr && !isspace(*ptr))
ptr++;
}
break;
}
/* Strip any "" from "<arg>" */
while ((quot = strchr(ptr, '"'))) {
char *ptr2;
ptr2 = strchr("[1], '"');
if (ptr2) {
memmove(ptr2, &ptr2[1], strlen(ptr2));
memmove(quot, "[1], strlen(quot));
}
}
arg = ptr;
}
if (mode >= 2)
path = compose_abspath(ctrl, arg);
else
path = compose_path(ctrl, arg);
if (!path) {
send_msg(ctrl->sd, "550 No such file or directory.\r\n");
return;
}
ctrl->list_mode = mode;
ctrl->file = strdup(arg ? arg : "");
ctrl->i = 0;
ctrl->d_num = scandir(path, &ctrl->d, NULL, alphasort);
if (ctrl->d_num == -1) {
send_msg(ctrl->sd, "550 No such file or directory.\r\n");
DBG("Failed reading directory '%s': %s", path, strerror(errno));
return;
}
DBG("Reading directory %s ... %d number of entries", path, ctrl->d_num);
if (ctrl->data_sd > -1) {
send_msg(ctrl->sd, "125 Data connection already open; transfer starting.\r\n");
uev_io_init(ctrl->ctx, &ctrl->data_watcher, do_LIST, ctrl, ctrl->data_sd, UEV_WRITE);
return;
}
do_PORT(ctrl, 1);
}
| 0
|
413,651
|
R_API RList *r_core_anal_fcn_get_calls(RCore *core, RAnalFunction *fcn) {
RAnalRef *refi;
RListIter *iter, *iter2;
// get all references from this function
RList *refs = r_anal_function_get_refs (fcn);
// sanity check
if (!r_list_empty (refs)) {
// iterate over all the references and remove these which aren't of type call
r_list_foreach_safe (refs, iter, iter2, refi) {
if (refi->type != R_ANAL_REF_TYPE_CALL) {
r_list_delete (refs, iter);
}
}
}
return refs;
}
| 0
|
346,429
|
ex_finish(exarg_T *eap)
{
if (sourcing_a_script(eap))
do_finish(eap, FALSE);
else
emsg(_(e_finish_used_outside_of_sourced_file));
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.