idx
int64
func
string
target
int64
366,208
static void lock_mnt_tree(struct mount *mnt) { struct mount *p; for (p = mnt; p; p = next_mnt(p, mnt)) { int flags = p->mnt.mnt_flags; /* Don't allow unprivileged users to change mount flags */ flags |= MNT_LOCK_ATIME; if (flags & MNT_READONLY) flags |= MNT_LOCK_READONLY; if (flags & MNT_NODEV) flags |= MNT_LOCK_NODEV; if (flags & MNT_NOSUID) flags |= MNT_LOCK_NOSUID; if (flags & MNT_NOEXEC) flags |= MNT_LOCK_NOEXEC; /* Don't allow unprivileged users to reveal what is under a mount */ if (list_empty(&p->mnt_expire)) flags |= MNT_LOCKED; p->mnt.mnt_flags = flags; } }
0
343,161
static void __exit esp6_fini(void) { if (xfrm6_protocol_deregister(&esp6_protocol, IPPROTO_ESP) < 0) pr_info("%s: can't remove protocol\n", __func__); xfrm_unregister_type(&esp6_type, AF_INET6); }
0
261,902
njs_string_to_c_string(njs_vm_t *vm, njs_value_t *value) { u_char *p, *data, *start; size_t size; if (value->short_string.size != NJS_STRING_LONG) { start = value->short_string.start; size = value->short_string.size; if (size < NJS_STRING_SHORT) { start[size] = '\0'; return (const char *) start; } } else { start = value->long_string.data->start; size = value->long_string.size; } data = njs_mp_alloc(vm->mem_pool, size + 1); if (njs_slow_path(data == NULL)) { njs_memory_error(vm); return NULL; } p = njs_cpymem(data, start, size); *p++ = '\0'; return (const char *) data; }
0
434,091
alist_check_arg_idx(void) { win_T *win; tabpage_T *tp; FOR_ALL_TAB_WINDOWS(tp, win) if (win->w_alist == curwin->w_alist) check_arg_idx(win); }
0
391,645
static void schedule_async_open(struct timeval request_time, struct smb_request *req) { struct deferred_open_record state; struct timeval timeout; timeout = timeval_set(20, 0); ZERO_STRUCT(state); state.delayed_for_oplocks = false; state.async_open = true; if (!request_timed_out(request_time, timeout)) { defer_open(NULL, request_time, timeout, req, &state); } }
0
336,538
static bool reds_send_link_error(RedLinkInfo *link, uint32_t error) { struct { SpiceLinkHeader header; SpiceLinkReply reply; } msg; SPICE_VERIFY(sizeof(msg) == sizeof(SpiceLinkHeader) + sizeof(SpiceLinkReply)); msg.header.magic = SPICE_MAGIC; msg.header.size = GUINT32_TO_LE(sizeof(msg.reply)); msg.header.major_version = GUINT32_TO_LE(SPICE_VERSION_MAJOR); msg.header.minor_version = GUINT32_TO_LE(SPICE_VERSION_MINOR); memset(&msg.reply, 0, sizeof(msg.reply)); msg.reply.error = GUINT32_TO_LE(error); return red_stream_write_all(link->stream, &msg, sizeof(msg)); }
0
440,881
FreeAuditTimer(void) { if (auditTimer != NULL) { /* Force output of pending messages */ TimerForce(auditTimer); TimerFree(auditTimer); auditTimer = NULL; } }
0
310,172
cleanup(void) { int rc; #if NO_LEAKS free_namelist(namelst); _nc_leaks_dump_entry(); #endif if (tmp_fp != 0) fclose(tmp_fp); if (to_remove != 0) { #if HAVE_REMOVE rc = remove(to_remove); #else rc = unlink(to_remove); #endif if (rc != 0) perror(to_remove); } }
0
405,712
static void xemaclite_disable_interrupts(struct net_local *drvdata) { u32 reg_data; /* Disable the Global Interrupt Enable */ xemaclite_writel(XEL_GIER_GIE_MASK, drvdata->base_addr + XEL_GIER_OFFSET); /* Disable the Tx interrupts for the first buffer */ reg_data = xemaclite_readl(drvdata->base_addr + XEL_TSR_OFFSET); xemaclite_writel(reg_data & (~XEL_TSR_XMIT_IE_MASK), drvdata->base_addr + XEL_TSR_OFFSET); /* Disable the Rx interrupts for the first buffer */ reg_data = xemaclite_readl(drvdata->base_addr + XEL_RSR_OFFSET); xemaclite_writel(reg_data & (~XEL_RSR_RECV_IE_MASK), drvdata->base_addr + XEL_RSR_OFFSET); }
0
253,725
static unsigned int ccp_queue_buf(struct ccp_data *data, unsigned int from) { struct ccp_sg_workarea *sg_wa = &data->sg_wa; struct ccp_dm_workarea *dm_wa = &data->dm_wa; unsigned int buf_count, nbytes; /* Clear the buffer if setting it */ if (!from) memset(dm_wa->address, 0, dm_wa->length); if (!sg_wa->sg) return 0; /* Perform the copy operation * nbytes will always be <= UINT_MAX because dm_wa->length is * an unsigned int */ nbytes = min_t(u64, sg_wa->bytes_left, dm_wa->length); scatterwalk_map_and_copy(dm_wa->address, sg_wa->sg, sg_wa->sg_used, nbytes, from); /* Update the structures and generate the count */ buf_count = 0; while (sg_wa->bytes_left && (buf_count < dm_wa->length)) { nbytes = min(sg_dma_len(sg_wa->dma_sg) - sg_wa->sg_used, dm_wa->length - buf_count); nbytes = min_t(u64, sg_wa->bytes_left, nbytes); buf_count += nbytes; ccp_update_sg_workarea(sg_wa, nbytes); } return buf_count; }
0
283,753
static void zynq_slcr_register_types(void) { type_register_static(&zynq_slcr_info); }
0
221,505
add_tzdata_args (FlatpakBwrap *bwrap, GFile *runtime_files) { g_autofree char *raw_timezone = flatpak_get_timezone (); g_autofree char *timezone_content = g_strdup_printf ("%s\n", raw_timezone); g_autofree char *localtime_content = g_strconcat ("../usr/share/zoneinfo/", raw_timezone, NULL); g_autoptr(GFile) runtime_zoneinfo = NULL; if (runtime_files) runtime_zoneinfo = g_file_resolve_relative_path (runtime_files, "share/zoneinfo"); /* Check for runtime /usr/share/zoneinfo */ if (runtime_zoneinfo != NULL && g_file_query_exists (runtime_zoneinfo, NULL)) { /* Check for host /usr/share/zoneinfo */ if (g_file_test ("/usr/share/zoneinfo", G_FILE_TEST_IS_DIR)) { /* Here we assume the host timezone file exist in the host data */ flatpak_bwrap_add_args (bwrap, "--ro-bind", "/usr/share/zoneinfo", "/usr/share/zoneinfo", "--symlink", localtime_content, "/etc/localtime", NULL); } else { g_autoptr(GFile) runtime_tzfile = g_file_resolve_relative_path (runtime_zoneinfo, raw_timezone); /* Check if host timezone file exist in the runtime tzdata */ if (g_file_query_exists (runtime_tzfile, NULL)) flatpak_bwrap_add_args (bwrap, "--symlink", localtime_content, "/etc/localtime", NULL); } } flatpak_bwrap_add_args_data (bwrap, "timezone", timezone_content, -1, "/etc/timezone", NULL); }
0
313,760
nv_ver_scrollbar(cmdarg_T *cap) { if (cap->oap->op_type != OP_NOP) clearopbeep(cap->oap); // Even if an operator was pending, we still want to scroll gui_do_scroll(); }
0
253,585
smb2_get_next_mid(struct TCP_Server_Info *server) { __u64 mid; /* for SMB2 we need the current value */ spin_lock(&GlobalMid_Lock); mid = server->CurrentMid++; spin_unlock(&GlobalMid_Lock); return mid; }
0
219,980
int callback_glewlwyd_user_get_session_list (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_session_list; size_t offset = 0, limit = GLEWLWYD_DEFAULT_LIMIT_SIZE; long int l_converted = 0; char * endptr = NULL, * sort = NULL; if (u_map_get(request->map_url, "offset") != NULL) { l_converted = strtol(u_map_get(request->map_url, "offset"), &endptr, 10); if (!(*endptr) && l_converted > 0) { offset = (size_t)l_converted; } } if (u_map_get(request->map_url, "limit") != NULL) { l_converted = strtol(u_map_get(request->map_url, "limit"), &endptr, 10); if (!(*endptr) && l_converted > 0) { limit = (size_t)l_converted; } } if (0 == o_strcmp(u_map_get(request->map_url, "sort"), "session_hash") || 0 == o_strcmp(u_map_get(request->map_url, "sort"), "user_agent") || 0 == o_strcmp(u_map_get(request->map_url, "sort"), "issued_for") || 0 == o_strcmp(u_map_get(request->map_url, "sort"), "expiration") || 0 == o_strcmp(u_map_get(request->map_url, "sort"), "last_login") || 0 == o_strcmp(u_map_get(request->map_url, "sort"), "enabled")) { sort = msprintf("gpgr_%s%s", u_map_get(request->map_url, "sort"), (u_map_get_case(request->map_url, "desc")!=NULL?" DESC":" ASC")); } j_session_list = get_user_session_list(config, json_string_value(json_object_get((json_t *)response->shared_data, "username")), u_map_get(request->map_url, "pattern"), offset, limit, sort); if (check_result_value(j_session_list, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_session_list, "session")); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_get_session_list - Error get_user_session_list"); response->status = 500; } json_decref(j_session_list); return U_CALLBACK_CONTINUE; }
0
256,153
void wrapper_libxsmm_spmdm_compute_generic_thread( empty_type_wrapper<bfloat16>, const libxsmm_spmdm_handle* handle, char transA, char transB, const bfloat16* alpha, libxsmm_CSR_sparseslice* A_sparse, const bfloat16* B, char transC, const bfloat16* beta, float* C, int block_id, int tid, int nthreads) { return libxsmm_spmdm_compute_bfloat16_thread( handle, transA, transB, reinterpret_cast<const libxsmm_bfloat16*>(alpha), A_sparse, reinterpret_cast<const libxsmm_bfloat16*>(B), transC, reinterpret_cast<const libxsmm_bfloat16*>(beta), C, block_id, tid, nthreads); }
0
225,638
GF_Err rtpo_box_size(GF_Box *s) { s->size += 4; return GF_OK; }
0
453,006
static int nft_fwd_validate(const struct nft_ctx *ctx, const struct nft_expr *expr, const struct nft_data **data) { return nft_chain_validate_hooks(ctx->chain, (1 << NF_NETDEV_INGRESS) | (1 << NF_NETDEV_EGRESS)); }
0
261,392
static int decode_sao_type_idx(thread_context* tctx) { logtrace(LogSlice,"# sao_type_idx_luma/chroma\n"); int bit0 = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_SAO_TYPE_IDX]); if (bit0==0) { logtrace(LogSymbols,"$1 sao_type_idx=%d\n",0); return 0; } else { int bit1 = decode_CABAC_bypass(&tctx->cabac_decoder); if (bit1==0) { logtrace(LogSymbols,"$1 sao_type_idx=%d\n",1); return 1; } else { logtrace(LogSymbols,"$1 sao_type_idx=%d\n",2); return 2; } } }
0
427,705
cdf_read(const cdf_info_t *info, off_t off, void *buf, size_t len) { size_t siz = CAST(size_t, off + len); if (CAST(off_t, off + len) != CAST(off_t, siz)) goto out; if (info->i_buf != NULL && info->i_len >= siz) { (void)memcpy(buf, &info->i_buf[off], len); return CAST(ssize_t, len); } if (info->i_fd == -1) goto out; if (pread(info->i_fd, buf, len, off) != CAST(ssize_t, len)) return -1; return CAST(ssize_t, len); out: errno = EINVAL; return -1; }
0
281,636
void CLASS nokia_load_raw() { uchar *data, *dp; int rev, dwide, row, col, c; rev = 3 * (order == 0x4949); dwide = (raw_width * 5 + 1) / 4; data = (uchar *) malloc (dwide*2); merror (data, "nokia_load_raw()"); #ifdef LIBRAW_LIBRARY_BUILD try { #endif for (row=0; row < raw_height; row++) { #ifdef LIBRAW_LIBRARY_BUILD checkCancel(); #endif if (fread (data+dwide, 1, dwide, ifp) < dwide) derror(); FORC(dwide) data[c] = data[dwide+(c ^ rev)]; for (dp=data, col=0; col < raw_width; dp+=5, col+=4) FORC4 RAW(row,col+c) = (dp[c] << 2) | (dp[4] >> (c << 1) & 3); } #ifdef LIBRAW_LIBRARY_BUILD } catch (...){ free (data); throw; } #endif free (data); maximum = 0x3ff; }
0
413,650
static inline bool get_next_i(IterCtx *ctx, size_t *next_i) { (*next_i)++; ut64 cur_addr = *next_i + ctx->start_addr; if (ctx->fcn) { if (!ctx->cur_bb) { ctx->path = r_list_new (); ctx->switch_path = r_list_new (); ctx->bbl = r_list_clone (ctx->fcn->bbs); ctx->cur_bb = r_anal_get_block_at (ctx->fcn->anal, ctx->fcn->addr); if (!ctx->cur_bb) { return false; } r_list_push (ctx->path, ctx->cur_bb); } RAnalBlock *bb = ctx->cur_bb; if (cur_addr >= bb->addr + bb->size) { r_reg_arena_push (ctx->fcn->anal->reg); RListIter *bbit = NULL; if (bb->switch_op) { RAnalCaseOp *cop = r_list_first (bb->switch_op->cases); bbit = r_list_find (ctx->bbl, &cop->jump, (RListComparator)find_bb); if (bbit) { r_list_push (ctx->switch_path, bb->switch_op->cases->head); } } else { bbit = r_list_find (ctx->bbl, &bb->jump, (RListComparator)find_bb); if (!bbit && bb->fail != UT64_MAX) { bbit = r_list_find (ctx->bbl, &bb->fail, (RListComparator)find_bb); } } if (!bbit) { RListIter *cop_it = r_list_last (ctx->switch_path); RAnalBlock *prev_bb = NULL; do { r_reg_arena_pop (ctx->fcn->anal->reg); prev_bb = r_list_pop (ctx->path); if (prev_bb->fail != UT64_MAX) { bbit = r_list_find (ctx->bbl, &prev_bb->fail, (RListComparator)find_bb); if (bbit) { r_reg_arena_push (ctx->fcn->anal->reg); r_list_push (ctx->path, prev_bb); } } if (!bbit && cop_it) { RAnalCaseOp *cop = cop_it->data; if (cop->jump == prev_bb->addr && cop_it->n) { cop = cop_it->n->data; r_list_pop (ctx->switch_path); r_list_push (ctx->switch_path, cop_it->n); cop_it = cop_it->n; bbit = r_list_find (ctx->bbl, &cop->jump, (RListComparator)find_bb); } } if (cop_it && !cop_it->n) { r_list_pop (ctx->switch_path); cop_it = r_list_last (ctx->switch_path); } } while (!bbit && !r_list_empty (ctx->path)); } if (!bbit) { r_list_free (ctx->path); r_list_free (ctx->switch_path); r_list_free (ctx->bbl); ctx->path = NULL; ctx->switch_path = NULL; ctx->bbl = NULL; return false; } if (!bbit->data) { return false; } if (!bbit->data) { return false; } ctx->cur_bb = bbit->data; r_list_push (ctx->path, ctx->cur_bb); r_list_delete (ctx->bbl, bbit); *next_i = ctx->cur_bb->addr - ctx->start_addr; } } else if (cur_addr >= ctx->end_addr) { return false; } if (*next_i == 0) { return false; } return true; }
0
314,519
static void parse_bandwidth_info(pj_scanner *scanner, pjmedia_sdp_bandw *bandw, volatile parse_context *ctx) { pj_str_t str; ctx->last_error = PJMEDIA_SDP_EINBANDW; /* b= */ pj_scan_advance_n(scanner, 2, SKIP_WS); /* modifier */ pj_scan_get_until_ch(scanner, ':', &bandw->modifier); pj_scan_get_char(scanner); /* value */ pj_scan_get_until_chr(scanner, " \t\r\n", &str); bandw->value = pj_strtoul(&str); /* We've got what we're looking for, skip anything until newline */ pj_scan_skip_line(scanner); }
0
248,241
DLLIMPORT cfg_t *cfg_getnsec(cfg_t *cfg, const char *name, unsigned int index) { return cfg_opt_getnsec(cfg_getopt(cfg, name), index); }
0
225,813
GF_Err stss_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; u32 i; GF_SyncSampleBox *ptr = (GF_SyncSampleBox *)s; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u32(bs, ptr->nb_entries); for (i = 0; i < ptr->nb_entries; i++) { gf_bs_write_u32(bs, ptr->sampleNumbers[i]); } return GF_OK; }
0
218,768
static MagickBooleanType ReadPSDLayersInternal(Image *image, const ImageInfo *image_info,const PSDInfo *psd_info, const MagickBooleanType skip_layers,ExceptionInfo *exception) { char type[4]; LayerInfo *layer_info; MagickSizeType size; MagickBooleanType status; ssize_t i; ssize_t count, j, number_layers; size=GetLayerInfoSize(psd_info,image); status=MagickTrue; if (size != 0) { layer_info=(LayerInfo *) NULL; number_layers=(ssize_t) ReadBlobSignedShort(image); if (number_layers < 0) { /* The first alpha channel in the merged result contains the transparency data for the merged result. */ number_layers=MagickAbsoluteValue(number_layers); if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " negative layer count corrected for"); image->matte=MagickTrue; } /* We only need to know if the image has an alpha channel */ if (skip_layers != MagickFalse) return(MagickTrue); if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " image contains %.20g layers",(double) number_layers); if (number_layers == 0) ThrowBinaryException(CorruptImageError,"InvalidNumberOfLayers", image->filename); layer_info=(LayerInfo *) AcquireQuantumMemory((size_t) number_layers, sizeof(*layer_info)); if (layer_info == (LayerInfo *) NULL) { if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " allocation of LayerInfo failed"); ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); } (void) memset(layer_info,0,(size_t) number_layers*sizeof(*layer_info)); for (i=0; i < number_layers; i++) { ssize_t top, left, bottom, right; if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " reading layer #%.20g",(double) i+1); top=(ssize_t) ReadBlobSignedLong(image); left=(ssize_t) ReadBlobSignedLong(image); bottom=(ssize_t) ReadBlobSignedLong(image); right=(ssize_t) ReadBlobSignedLong(image); if ((right < left) || (bottom < top)) { layer_info=DestroyLayerInfo(layer_info,number_layers); ThrowBinaryException(CorruptImageError,"ImproperImageHeader", image->filename); } layer_info[i].page.y=top; layer_info[i].page.x=left; layer_info[i].page.width=(size_t) (right-left); layer_info[i].page.height=(size_t) (bottom-top); layer_info[i].channels=ReadBlobShort(image); if (layer_info[i].channels > MaxPSDChannels) { layer_info=DestroyLayerInfo(layer_info,number_layers); ThrowBinaryException(CorruptImageError,"MaximumChannelsExceeded", image->filename); } if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " offset(%.20g,%.20g), size(%.20g,%.20g), channels=%.20g", (double) layer_info[i].page.x,(double) layer_info[i].page.y, (double) layer_info[i].page.height,(double) layer_info[i].page.width,(double) layer_info[i].channels); for (j=0; j < (ssize_t) layer_info[i].channels; j++) { layer_info[i].channel_info[j].type=(short) ReadBlobShort(image); if ((layer_info[i].channel_info[j].type < -4) || (layer_info[i].channel_info[j].type > 4)) { layer_info=DestroyLayerInfo(layer_info,number_layers); ThrowBinaryException(CorruptImageError,"NoSuchImageChannel", image->filename); } layer_info[i].channel_info[j].size=(size_t) GetPSDSize(psd_info, image); if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " channel[%.20g]: type=%.20g, size=%.20g",(double) j, (double) layer_info[i].channel_info[j].type, (double) layer_info[i].channel_info[j].size); } if (CheckPSDChannels(image,psd_info,&layer_info[i]) == MagickFalse) { layer_info=DestroyLayerInfo(layer_info,number_layers); ThrowBinaryException(CorruptImageError,"ImproperImageHeader", image->filename); } count=ReadPSDString(image,type,4); if ((count != 4) || (LocaleNCompare(type,"8BIM",4) != 0)) { if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " layer type was %.4s instead of 8BIM", type); layer_info=DestroyLayerInfo(layer_info,number_layers); ThrowBinaryException(CorruptImageError,"ImproperImageHeader", image->filename); } count=ReadPSDString(image,layer_info[i].blendkey,4); if (count != 4) { layer_info=DestroyLayerInfo(layer_info,number_layers); ThrowBinaryException(CorruptImageError,"ImproperImageHeader", image->filename); } layer_info[i].opacity=(Quantum) ScaleCharToQuantum((unsigned char) ReadBlobByte(image)); layer_info[i].clipping=(unsigned char) ReadBlobByte(image); layer_info[i].flags=(unsigned char) ReadBlobByte(image); layer_info[i].visible=!(layer_info[i].flags & 0x02); if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " blend=%.4s, opacity=%.20g, clipping=%s, flags=%d, visible=%s", layer_info[i].blendkey,(double) layer_info[i].opacity, layer_info[i].clipping ? "true" : "false",layer_info[i].flags, layer_info[i].visible ? "true" : "false"); (void) ReadBlobByte(image); /* filler */ size=ReadBlobLong(image); if (size != 0) { MagickSizeType combined_length, length; if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " layer contains additional info"); length=ReadBlobLong(image); combined_length=length+4; if (length != 0) { /* Layer mask info. */ layer_info[i].mask.page.y=(ssize_t) ReadBlobSignedLong(image); layer_info[i].mask.page.x=(ssize_t) ReadBlobSignedLong(image); layer_info[i].mask.page.height=(size_t) ( ReadBlobSignedLong(image)-layer_info[i].mask.page.y); layer_info[i].mask.page.width=(size_t) ( ReadBlobSignedLong(image)-layer_info[i].mask.page.x); layer_info[i].mask.background=(unsigned char) ReadBlobByte( image); layer_info[i].mask.flags=(unsigned char) ReadBlobByte(image); if (!(layer_info[i].mask.flags & 0x01)) { layer_info[i].mask.page.y=layer_info[i].mask.page.y- layer_info[i].page.y; layer_info[i].mask.page.x=layer_info[i].mask.page.x- layer_info[i].page.x; } if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " layer mask: offset(%.20g,%.20g), size(%.20g,%.20g), length=%.20g", (double) layer_info[i].mask.page.x,(double) layer_info[i].mask.page.y,(double) layer_info[i].mask.page.width, (double) layer_info[i].mask.page.height,(double) ((MagickOffsetType) length)-18); /* Skip over the rest of the layer mask information. */ if (DiscardBlobBytes(image,(MagickSizeType) (length-18)) == MagickFalse) { layer_info=DestroyLayerInfo(layer_info,number_layers); ThrowBinaryException(CorruptImageError,"UnexpectedEndOfFile", image->filename); } } length=ReadBlobLong(image); combined_length+=length+4; if (length != 0) { /* Layer blending ranges info. */ if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " layer blending ranges: length=%.20g",(double) ((MagickOffsetType) length)); if (DiscardBlobBytes(image,length) == MagickFalse) { layer_info=DestroyLayerInfo(layer_info,number_layers); ThrowBinaryException(CorruptImageError, "UnexpectedEndOfFile",image->filename); } } /* Layer name. */ length=(MagickSizeType) (unsigned char) ReadBlobByte(image); combined_length+=length+1; if (length > 0) (void) ReadBlob(image,(size_t) length++,layer_info[i].name); layer_info[i].name[length]='\0'; if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " layer name: %s",layer_info[i].name); if ((length % 4) != 0) { length=4-(length % 4); combined_length+=length; /* Skip over the padding of the layer name */ if (DiscardBlobBytes(image,length) == MagickFalse) { layer_info=DestroyLayerInfo(layer_info,number_layers); ThrowBinaryException(CorruptImageError, "UnexpectedEndOfFile",image->filename); } } length=(MagickSizeType) size-combined_length; if (length > 0) { unsigned char *info; if (length > GetBlobSize(image)) { layer_info=DestroyLayerInfo(layer_info,number_layers); ThrowBinaryException(CorruptImageError, "InsufficientImageDataInFile",image->filename); } layer_info[i].info=AcquireStringInfo((const size_t) length); info=GetStringInfoDatum(layer_info[i].info); (void) ReadBlob(image,(const size_t) length,info); } } } for (i=0; i < number_layers; i++) { if ((layer_info[i].page.width == 0) || (layer_info[i].page.height == 0)) { if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " layer data is empty"); if (layer_info[i].info != (StringInfo *) NULL) layer_info[i].info=DestroyStringInfo(layer_info[i].info); continue; } /* Allocate layered image. */ layer_info[i].image=CloneImage(image,layer_info[i].page.width, layer_info[i].page.height,MagickFalse,exception); if (layer_info[i].image == (Image *) NULL) { layer_info=DestroyLayerInfo(layer_info,number_layers); if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " allocation of image for layer %.20g failed",(double) i); ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); } if (layer_info[i].info != (StringInfo *) NULL) { (void) SetImageProfile(layer_info[i].image,"psd:additional-info", layer_info[i].info); layer_info[i].info=DestroyStringInfo(layer_info[i].info); } } if (image_info->ping == MagickFalse) { for (i=0; i < number_layers; i++) { if (layer_info[i].image == (Image *) NULL) { for (j=0; j < (ssize_t) layer_info[i].channels; j++) { if (DiscardBlobBytes(image,(MagickSizeType) layer_info[i].channel_info[j].size) == MagickFalse) { layer_info=DestroyLayerInfo(layer_info,number_layers); ThrowBinaryException(CorruptImageError, "UnexpectedEndOfFile",image->filename); } } continue; } if (image->debug != MagickFalse) (void) LogMagickEvent(CoderEvent,GetMagickModule(), " reading data for layer %.20g",(double) i); status=ReadPSDLayer(image,image_info,psd_info,&layer_info[i], exception); if (status == MagickFalse) break; status=SetImageProgress(image,LoadImagesTag,(MagickOffsetType) i, (MagickSizeType) number_layers); if (status == MagickFalse) break; } } if (status != MagickFalse) { for (i=0; i < number_layers; i++) { if (layer_info[i].image == (Image *) NULL) { for (j=i; j < number_layers - 1; j++) layer_info[j] = layer_info[j+1]; number_layers--; i--; } } if (number_layers > 0) { for (i=0; i < number_layers; i++) { if (i > 0) layer_info[i].image->previous=layer_info[i-1].image; if (i < (number_layers-1)) layer_info[i].image->next=layer_info[i+1].image; layer_info[i].image->page=layer_info[i].page; } image->next=layer_info[0].image; layer_info[0].image->previous=image; } layer_info=(LayerInfo *) RelinquishMagickMemory(layer_info); } else layer_info=DestroyLayerInfo(layer_info,number_layers); } return(status); }
0
242,938
static int ssl_prepare_record_content( mbedtls_ssl_context *ssl, mbedtls_record *rec ) { int ret, done = 0; MBEDTLS_SSL_DEBUG_BUF( 4, "input record from network", rec->buf, rec->buf_len ); #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) if( mbedtls_ssl_hw_record_read != NULL ) { MBEDTLS_SSL_DEBUG_MSG( 2, ( "going for mbedtls_ssl_hw_record_read()" ) ); ret = mbedtls_ssl_hw_record_read( ssl ); if( ret != 0 && ret != MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_hw_record_read", ret ); return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED ); } if( ret == 0 ) done = 1; } #endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */ if( !done && ssl->transform_in != NULL ) { unsigned char const old_msg_type = rec->type; if( ( ret = mbedtls_ssl_decrypt_buf( ssl, ssl->transform_in, rec ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "ssl_decrypt_buf", ret ); #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) if( ret == MBEDTLS_ERR_SSL_UNEXPECTED_CID && ssl->conf->ignore_unexpected_cid == MBEDTLS_SSL_UNEXPECTED_CID_IGNORE ) { MBEDTLS_SSL_DEBUG_MSG( 3, ( "ignoring unexpected CID" ) ); ret = MBEDTLS_ERR_SSL_CONTINUE_PROCESSING; } #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ return( ret ); } if( old_msg_type != rec->type ) { MBEDTLS_SSL_DEBUG_MSG( 4, ( "record type after decrypt (before %d): %d", old_msg_type, rec->type ) ); } MBEDTLS_SSL_DEBUG_BUF( 4, "input payload after decrypt", rec->buf + rec->data_offset, rec->data_len ); #if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) /* We have already checked the record content type * in ssl_parse_record_header(), failing or silently * dropping the record in the case of an unknown type. * * Since with the use of CIDs, the record content type * might change during decryption, re-check the record * content type, but treat a failure as fatal this time. */ if( ssl_check_record_type( rec->type ) ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "unknown record type" ) ); return( MBEDTLS_ERR_SSL_INVALID_RECORD ); } #endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */ if( rec->data_len == 0 ) { #if defined(MBEDTLS_SSL_PROTO_TLS1_2) if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 && rec->type != MBEDTLS_SSL_MSG_APPLICATION_DATA ) { /* TLS v1.2 explicitly disallows zero-length messages which are not application data */ MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid zero-length message type: %d", ssl->in_msgtype ) ); return( MBEDTLS_ERR_SSL_INVALID_RECORD ); } #endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ ssl->nb_zero++; /* * Three or more empty messages may be a DoS attack * (excessive CPU consumption). */ if( ssl->nb_zero > 3 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "received four consecutive empty " "messages, possible DoS attack" ) ); /* Treat the records as if they were not properly authenticated, * thereby failing the connection if we see more than allowed * by the configured bad MAC threshold. */ return( MBEDTLS_ERR_SSL_INVALID_MAC ); } } else ssl->nb_zero = 0; #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) { ; /* in_ctr read from peer, not maintained internally */ } else #endif { unsigned i; for( i = 8; i > mbedtls_ssl_ep_len( ssl ); i-- ) if( ++ssl->in_ctr[i - 1] != 0 ) break; /* The loop goes to its end iff the counter is wrapping */ if( i == mbedtls_ssl_ep_len( ssl ) ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "incoming message counter would wrap" ) ); return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING ); } } } #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) { mbedtls_ssl_dtls_replay_update( ssl ); } #endif /* Check actual (decrypted) record content length against * configured maximum. */ if( ssl->in_msglen > MBEDTLS_SSL_IN_CONTENT_LEN ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); return( MBEDTLS_ERR_SSL_INVALID_RECORD ); } return( 0 ); }
0
359,277
DEFUN (no_neighbor_peer_group, no_neighbor_peer_group_cmd, "no neighbor WORD peer-group", NO_STR NEIGHBOR_STR "Neighbor tag\n" "Configure peer-group\n") { struct peer_group *group; group = peer_group_lookup (vty->index, argv[0]); if (group) peer_group_delete (group); else { vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); return CMD_WARNING; } return CMD_SUCCESS; }
0
488,418
static __init void vdso_setup_trampolines(struct lib32_elfinfo *v32, struct lib64_elfinfo *v64) { /* * Find signal trampolines */ #ifdef CONFIG_PPC64 vdso64_rt_sigtramp = find_function64(v64, "__kernel_sigtramp_rt64"); #endif vdso32_sigtramp = find_function32(v32, "__kernel_sigtramp32"); vdso32_rt_sigtramp = find_function32(v32, "__kernel_sigtramp_rt32"); }
0
522,325
static void RecBlk(GmfMshSct *msh, const void *blk, int siz) { // Copy this line-block into the main mesh buffer if(siz) { memcpy(&msh->blk[ msh->pos ], blk, (size_t)(siz * WrdSiz)); msh->pos += siz * WrdSiz; } // When the buffer is full or this procedure is APIF77ed with a 0 size, // flush the cache on disk if( (msh->pos > BufSiz) || (!siz && msh->pos) ) { #ifdef GMF_WINDOWS /* * [Bruno] TODO: check that msh->pos is smaller * than 4G (fits in 32 bits). * Note: for now, when trying to write more than 4Gb, it will * trigger an error (longjmp). * As far as I understand: * Given that this function just flushes the cache, and given that * the cache size is 10000 words, this is much much smaller than 4Gb * so there is probably no problem. */ #ifdef WITH_GMF_AIO if(write(msh->FilDes, msh->blk, (int)msh->pos) != (ssize_t)msh->pos) #else if(fwrite(msh->blk, 1, (size_t)msh->pos, msh->hdl) != msh->pos) #endif longjmp(msh->err, -30); #else #ifdef WITH_GMF_AIO if(write(msh->FilDes, msh->blk, msh->pos) != (ssize_t)msh->pos) #else if(fwrite(msh->blk, 1, msh->pos, msh->hdl) != msh->pos) #endif longjmp(msh->err, -31); #endif msh->pos = 0; } }
0
273,894
static void handle_CLNT(ctrl_t *ctrl, char *arg) { send_msg(ctrl->sd, "200 CLNT\r\n"); }
0
261,209
MqttProp* MqttClient_PropsAdd(MqttProp **head) { return MqttProps_Add(head); }
0
248,326
DLLIMPORT unsigned int cfg_opt_size(cfg_opt_t *opt) { if (opt) return opt->nvalues; return 0; }
0
473,993
st_init_strcasetable_with_size(st_index_t size) { return st_init_table_with_size(&type_strcasehash, size); }
0
244,038
GF_Err trik_box_size(GF_Box *s) { GF_TrickPlayBox *ptr = (GF_TrickPlayBox *) s; ptr->size += 8 * ptr->entry_count; return GF_OK; }
0
261,947
njs_encode_hex(njs_str_t *dst, const njs_str_t *src) { u_char *p, c; size_t i, len; const u_char *start; static const u_char hex[16] = "0123456789abcdef"; len = src->length; start = src->start; p = dst->start; for (i = 0; i < len; i++) { c = start[i]; *p++ = hex[c >> 4]; *p++ = hex[c & 0x0f]; } }
0
195,291
void Compute(OpKernelContext* context) override { const Tensor& rhs = context->input(1); // We always return the input ref. context->forward_ref_input_to_ref_output(0, 0); // We can't always know how this value will be used downstream, so make // conservative assumptions in specifying constraints on the memory // allocation attributes, unless the Grappler graph analysis determined that // it was safe not to. AllocatorAttributes attr; if (!relax_constraints_) { attr.set_gpu_compatible(true); attr.set_nic_compatible(true); } { mutex_lock l(*context->input_ref_mutex(0)); const Tensor& old_lhs = context->mutable_input(0, /* lock_held */ true); const bool same_shape = old_lhs.shape().IsSameSize(rhs.shape()); if (validate_shape_) { OP_REQUIRES(context, same_shape, errors::InvalidArgument( "Assign requires shapes of both tensors to match. " "lhs shape= ", old_lhs.shape().DebugString(), " rhs shape= ", rhs.shape().DebugString())); } // In the code below we try to minimize the amount of memory allocation // and copying by trying the following two shortcuts: // 1. If the lhs is initialized and has the same number of elements as // the rhs we can avoid a memory allocation. // 2. If we can reuse the rhs buffer we avoid both a memory allocation // and copying. // 1. Try to copy into an existing buffer. if (old_lhs.IsInitialized() && old_lhs.shape().num_elements() == rhs.shape().num_elements()) { // The existing lhs tensor has already been initialized and the right // hand side can fit in the underlying buffer. Tensor reshaped_old_lhs; if (same_shape) { reshaped_old_lhs = old_lhs; } else { CHECK(reshaped_old_lhs.CopyFrom(old_lhs, rhs.shape())); context->replace_ref_input(0, reshaped_old_lhs, /* lock_held */ true); } if (use_exclusive_lock_) { Copy(context, &reshaped_old_lhs, rhs); return; } } else { // 2. Try to reuse the rhs. std::unique_ptr<Tensor> input_alias = context->forward_input( 1, OpKernelContext::Params::kNoReservation /*output_index*/, rhs.dtype(), rhs.shape(), DEVICE_MEMORY, attr); if (input_alias != nullptr) { // Update the ref to point to the new buffer. context->replace_ref_input(0, *input_alias, /* lock_held */ true); return; } // Otherwise, create a new tensor whose shape matches the // right hand side, hand off to lhs and copy the rhs into it. Tensor copy_tensor; OP_REQUIRES_OK(context, context->allocate_temp(old_lhs.dtype(), rhs.shape(), &copy_tensor, attr)); // We track memory of variables in variable ops instead of in this // assign op. context->clear_recorded_memory(); context->replace_ref_input(0, copy_tensor, /* lock_held */ true); if (use_exclusive_lock_) { Copy(context, &copy_tensor, rhs); return; } } } // The tensor has already been initialized and the right hand side // matches the left hand side's shape. We have been told to do the // copy outside the lock. Tensor old_unlocked_lhs = context->mutable_input(0, /* lock_held */ false); Copy(context, &old_unlocked_lhs, rhs); }
1
223,384
static void do_utfpeakcharback_invalid(compiler_common *common) { /* Peak a character back. Does not modify STR_PTR. */ DEFINE_COMPILER; sljit_s32 i; sljit_s32 has_cmov = sljit_has_cpu_feature(SLJIT_HAS_CMOV); struct sljit_jump *jump[2]; struct sljit_label *two_byte_entry; struct sljit_label *three_byte_entry; struct sljit_label *exit_invalid_label; struct sljit_jump *exit_invalid[8]; sljit_emit_fast_enter(compiler, RETURN_ADDR, 0); OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(3)); exit_invalid[0] = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0xc0); jump[0] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, STR_PTR, 0); /* Two-byte sequence. */ OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2)); OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc2); jump[1] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x1e); two_byte_entry = LABEL(); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); /* If TMP1 is in 0x80-0xbf range, TMP1 is also increased by (0x2 << 6). */ OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0); OP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0); JUMPHERE(jump[1]); OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc2 - 0x80); OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x80); exit_invalid[1] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x40); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); /* Three-byte sequence. */ OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-3)); OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xe0); jump[1] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x10); three_byte_entry = LABEL(); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 12); OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xd800); if (has_cmov) { OP2U(SLJIT_SUB | SLJIT_SET_LESS, TMP1, 0, SLJIT_IMM, 0x800); CMOV(SLJIT_LESS, TMP1, SLJIT_IMM, -0xd800); exit_invalid[2] = NULL; } else exit_invalid[2] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0x800); OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xd800); if (has_cmov) { OP2U(SLJIT_SUB | SLJIT_SET_LESS, TMP1, 0, SLJIT_IMM, 0x800); CMOV(SLJIT_LESS, TMP1, SLJIT_IMM, INVALID_UTF_CHAR); exit_invalid[3] = NULL; } else exit_invalid[3] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0x800); OP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0); JUMPHERE(jump[1]); OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xe0 - 0x80); exit_invalid[4] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x40); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 12); OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); /* Four-byte sequence. */ OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-4)); OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x10000); OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xf0); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 18); /* ADD is used instead of OR because of the SUB 0x10000 above. */ OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0); if (has_cmov) { OP2U(SLJIT_SUB | SLJIT_SET_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0x100000); CMOV(SLJIT_GREATER_EQUAL, TMP1, SLJIT_IMM, INVALID_UTF_CHAR - 0x10000); exit_invalid[5] = NULL; } else exit_invalid[5] = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 0x100000); OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x10000); OP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0); JUMPHERE(jump[0]); OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(1)); jump[0] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, STR_PTR, 0); /* Two-byte sequence. */ OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2)); OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc2); CMPTO(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0x1e, two_byte_entry); OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc2 - 0x80); OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x80); exit_invalid[6] = CMP(SLJIT_GREATER_EQUAL, TMP2, 0, SLJIT_IMM, 0x40); OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6); OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0); /* Three-byte sequence. */ OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-3)); OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xe0); CMPTO(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0x10, three_byte_entry); OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR); OP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0); JUMPHERE(jump[0]); exit_invalid[7] = CMP(SLJIT_GREATER, TMP2, 0, STR_PTR, 0); /* Two-byte sequence. */ OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2)); OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xc2); CMPTO(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0x1e, two_byte_entry); exit_invalid_label = LABEL(); for (i = 0; i < 8; i++) sljit_set_label(exit_invalid[i], exit_invalid_label); OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR); OP_SRC(SLJIT_FAST_RETURN, RETURN_ADDR, 0); }
0
346,455
source_runtime(char_u *name, int flags) { return source_in_path(p_rtp, name, flags, NULL); }
0
90,151
WifiNetwork* GetWifiNetworkByName(const std::string& name) { for (size_t i = 0; i < wifi_networks_.size(); ++i) { if (wifi_networks_[i]->name().compare(name) == 0) { return wifi_networks_[i]; } } return NULL; }
0
489,210
static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct inode *inode) { if (S_ISDIR(inode->i_mode)) { struct hfsplus_cat_folder *folder; folder = &entry->folder; memset(folder, 0, sizeof(*folder)); folder->type = cpu_to_be16(HFSPLUS_FOLDER); folder->id = cpu_to_be32(inode->i_ino); HFSPLUS_I(inode).create_date = folder->create_date = folder->content_mod_date = folder->attribute_mod_date = folder->access_date = hfsp_now2mt(); hfsplus_set_perms(inode, &folder->permissions); if (inode == HFSPLUS_SB(inode->i_sb).hidden_dir) /* invisible and namelocked */ folder->user_info.frFlags = cpu_to_be16(0x5000); return sizeof(*folder); } else { struct hfsplus_cat_file *file; file = &entry->file; memset(file, 0, sizeof(*file)); file->type = cpu_to_be16(HFSPLUS_FILE); file->flags = cpu_to_be16(HFSPLUS_FILE_THREAD_EXISTS); file->id = cpu_to_be32(cnid); HFSPLUS_I(inode).create_date = file->create_date = file->content_mod_date = file->attribute_mod_date = file->access_date = hfsp_now2mt(); if (cnid == inode->i_ino) { hfsplus_set_perms(inode, &file->permissions); if (S_ISLNK(inode->i_mode)) { file->user_info.fdType = cpu_to_be32(HFSP_SYMLINK_TYPE); file->user_info.fdCreator = cpu_to_be32(HFSP_SYMLINK_CREATOR); } else { file->user_info.fdType = cpu_to_be32(HFSPLUS_SB(inode->i_sb).type); file->user_info.fdCreator = cpu_to_be32(HFSPLUS_SB(inode->i_sb).creator); } if ((file->permissions.rootflags | file->permissions.userflags) & HFSPLUS_FLG_IMMUTABLE) file->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED); } else { file->user_info.fdType = cpu_to_be32(HFSP_HARDLINK_TYPE); file->user_info.fdCreator = cpu_to_be32(HFSP_HFSPLUS_CREATOR); file->user_info.fdFlags = cpu_to_be16(0x100); file->create_date = HFSPLUS_I(HFSPLUS_SB(inode->i_sb).hidden_dir).create_date; file->permissions.dev = cpu_to_be32(HFSPLUS_I(inode).dev); } return sizeof(*file); } }
0
269,489
static void TIFFReadPhotoshopLayers(const ImageInfo *image_info,Image *image, ExceptionInfo *exception) { const char *option; const StringInfo *profile; CustomStreamInfo *custom_stream; Image *layers; ImageInfo *clone_info; PhotoshopProfile photoshop_profile; PSDInfo info; ssize_t i; if (GetImageListLength(image) != 1) return; if ((image_info->number_scenes == 1) && (image_info->scene == 0)) return; option=GetImageOption(image_info,"tiff:ignore-layers"); if (option != (const char * ) NULL) return; profile=GetImageProfile(image,"tiff:37724"); if (profile == (const StringInfo *) NULL) return; for (i=0; i < (ssize_t) profile->length-8; i++) { if (LocaleNCompare((const char *) (profile->datum+i), image->endian == MSBEndian ? "8BIM" : "MIB8",4) != 0) continue; i+=4; if ((LocaleNCompare((const char *) (profile->datum+i), image->endian == MSBEndian ? "Layr" : "ryaL",4) == 0) || (LocaleNCompare((const char *) (profile->datum+i), image->endian == MSBEndian ? "LMsk" : "ksML",4) == 0) || (LocaleNCompare((const char *) (profile->datum+i), image->endian == MSBEndian ? "Lr16" : "61rL",4) == 0) || (LocaleNCompare((const char *) (profile->datum+i), image->endian == MSBEndian ? "Lr32" : "23rL",4) == 0)) break; } i+=4; if (i >= (ssize_t) (profile->length-8)) return; photoshop_profile.data=(StringInfo *) profile; photoshop_profile.length=profile->length; custom_stream=TIFFAcquireCustomStreamForReading(&photoshop_profile,exception); if (custom_stream == (CustomStreamInfo *) NULL) return; layers=CloneImage(image,0,0,MagickTrue,exception); if (layers == (Image *) NULL) { custom_stream=DestroyCustomStreamInfo(custom_stream); return; } (void) DeleteImageProfile(layers,"tiff:37724"); AttachCustomStream(layers->blob,custom_stream); SeekBlob(layers,(MagickOffsetType) i,SEEK_SET); InitPSDInfo(layers,&info); clone_info=CloneImageInfo(image_info); clone_info->number_scenes=0; (void) ReadPSDLayers(layers,clone_info,&info,exception); clone_info=DestroyImageInfo(clone_info); DeleteImageFromList(&layers); if (layers != (Image *) NULL) { SetImageArtifact(image,"tiff:has-layers","true"); AppendImageToList(&image,layers); while (layers != (Image *) NULL) { SetImageArtifact(layers,"tiff:has-layers","true"); DetachBlob(layers->blob); layers=GetNextImageInList(layers); } } custom_stream=DestroyCustomStreamInfo(custom_stream); }
0
221,175
GF_HEVCConfig *gf_odf_hevc_cfg_read(u8 *dsi, u32 dsi_size, Bool is_lhvc) { GF_BitStream *bs = gf_bs_new(dsi, dsi_size, GF_BITSTREAM_READ); GF_HEVCConfig *cfg = gf_odf_hevc_cfg_read_bs(bs, is_lhvc); gf_bs_del(bs); return cfg; }
0
252,374
void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags) { int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags); if (file_index < 0) { if (pSize) *pSize = 0; return MZ_FALSE; } return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags); }
0
310,006
set_background_color(NCURSES_SP_DCLx int bg, NCURSES_SP_OUTC outc) { #ifdef USE_TERM_DRIVER CallDriver_3(SP_PARM, td_color, FALSE, bg, outc); #else if (set_a_background) { TPUTS_TRACE("set_a_background"); NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx TIPARM_1(set_a_background, bg), 1, outc); } else { TPUTS_TRACE("set_background"); NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx TIPARM_1(set_background, toggled_colors(bg)), 1, outc); } #endif }
0
440,879
LogMessageVerb(MessageType type, int verb, const char *format, ...) { va_list ap; va_start(ap, format); LogVMessageVerb(type, verb, format, ap); va_end(ap); }
0
224,237
R_API ut32 r_io_bank_first(RIO *io) { ut32 bankid = -1; r_id_storage_get_lowest (io->banks, &bankid); return bankid; }
0
366,174
static struct ns_common *mntns_get(struct task_struct *task) { struct ns_common *ns = NULL; struct nsproxy *nsproxy; task_lock(task); nsproxy = task->nsproxy; if (nsproxy) { ns = &nsproxy->mnt_ns->ns; get_mnt_ns(to_mnt_ns(ns)); } task_unlock(task); return ns; }
0
413,611
R_API int r_core_anal_search_xrefs(RCore *core, ut64 from, ut64 to, PJ *pj, int rad) { const bool cfg_debug = r_config_get_b (core->config, "cfg.debug"); bool cfg_anal_strings = r_config_get_i (core->config, "anal.strings"); ut64 at; int count = 0; int bsz = 8096; RAnalOp op = { 0 }; if (from == to) { return -1; } if (from > to) { eprintf ("Invalid range (0x%"PFMT64x " >= 0x%"PFMT64x")\n", from, to); return -1; } if (core->blocksize <= OPSZ) { eprintf ("Error: block size too small\n"); return -1; } ut8 *buf = malloc (bsz); if (!buf) { eprintf ("Error: cannot allocate a block\n"); return -1; } ut8 *block = malloc (bsz); if (!block) { eprintf ("Error: cannot allocate a temp block\n"); free (buf); return -1; } r_cons_break_push (NULL, NULL); at = from; st64 asm_sub_varmin = r_config_get_i (core->config, "asm.sub.varmin"); int maxopsz = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_MAX_OP_SIZE); int minopsz = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_MIN_OP_SIZE); if (maxopsz < 1) { maxopsz = 4; } if (minopsz < 1) { minopsz = 1; } if (bsz < maxopsz) { // wtf eprintf ("Error: Something is really wrong deep inside\n"); free (block); return -1; } while (at < to && !r_cons_is_breaked ()) { int i = 0, ret = bsz; if (!r_io_is_valid_offset (core->io, at, R_PERM_X)) { break; } ut64 left = to - at; if (bsz > left) { bsz = left; } (void)r_io_read_at (core->io, at, buf, bsz); memset (block, -1, bsz); if (!memcmp (buf, block, bsz)) { // eprintf ("Error: skipping uninitialized block \n"); at += ret; continue; } memset (block, 0, bsz); if (!memcmp (buf, block, bsz)) { // eprintf ("Error: skipping uninitialized block \n"); at += ret; continue; } (void) r_anal_op (core->anal, &op, at, buf, bsz, R_ANAL_OP_MASK_BASIC | R_ANAL_OP_MASK_HINT); while ((i + maxopsz) < bsz && !r_cons_is_breaked ()) { r_anal_op_fini (&op); ret = r_anal_op (core->anal, &op, at + i, buf + i, bsz - i, R_ANAL_OP_MASK_BASIC | R_ANAL_OP_MASK_HINT); if (ret < 1) { i += minopsz; continue; } i += ret; if (i > bsz) { // at += minopsz; break; } // find references if ((st64)op.val > asm_sub_varmin && op.val != UT64_MAX && op.val != UT32_MAX) { if (found_xref (core, op.addr, op.val, R_ANAL_REF_TYPE_DATA, pj, rad, cfg_debug, cfg_anal_strings)) { count++; } } // find references if (op.ptr && op.ptr != UT64_MAX && op.ptr != UT32_MAX) { if (found_xref (core, op.addr, op.ptr, R_ANAL_REF_TYPE_DATA, pj, rad, cfg_debug, cfg_anal_strings)) { count++; } } // find references if (op.addr > 512 && op.disp > 512 && op.disp && op.disp != UT64_MAX) { if (found_xref (core, op.addr, op.disp, R_ANAL_REF_TYPE_DATA, pj, rad, cfg_debug, cfg_anal_strings)) { count++; } } switch (op.type) { case R_ANAL_OP_TYPE_JMP: case R_ANAL_OP_TYPE_CJMP: if (found_xref (core, op.addr, op.jump, R_ANAL_REF_TYPE_CODE, pj, rad, cfg_debug, cfg_anal_strings)) { count++; } break; case R_ANAL_OP_TYPE_CALL: case R_ANAL_OP_TYPE_CCALL: if (found_xref (core, op.addr, op.jump, R_ANAL_REF_TYPE_CALL, pj, rad, cfg_debug, cfg_anal_strings)) { count++; } break; case R_ANAL_OP_TYPE_UJMP: case R_ANAL_OP_TYPE_IJMP: case R_ANAL_OP_TYPE_RJMP: case R_ANAL_OP_TYPE_IRJMP: case R_ANAL_OP_TYPE_MJMP: case R_ANAL_OP_TYPE_UCJMP: count++; if (found_xref (core, op.addr, op.ptr, R_ANAL_REF_TYPE_CODE, pj, rad, cfg_debug, cfg_anal_strings)) { count++; } break; case R_ANAL_OP_TYPE_UCALL: case R_ANAL_OP_TYPE_ICALL: case R_ANAL_OP_TYPE_RCALL: case R_ANAL_OP_TYPE_IRCALL: case R_ANAL_OP_TYPE_UCCALL: if (found_xref (core, op.addr, op.ptr, R_ANAL_REF_TYPE_CALL, pj, rad, cfg_debug, cfg_anal_strings)) { count++; } break; default: break; } } r_anal_op_fini (&op); if (i < 1) { break; } at += i + 1; } r_cons_break_pop (); free (buf); free (block); return count; }
0
310,171
is_csi(const char *s) { int result = 0; if (s != 0) { if (UChar(s[0]) == CSI) result = 1; else if (s[0] == ESC && s[1] == L_BRACK) result = 2; } return result; }
0
244,133
GF_Err ihdr_box_read(GF_Box *s,GF_BitStream *bs) { GF_J2KImageHeaderBox *ptr = (GF_J2KImageHeaderBox *) s; ISOM_DECREASE_SIZE(s, 14) ptr->height = gf_bs_read_u32(bs); ptr->width = gf_bs_read_u32(bs); ptr->nb_comp = gf_bs_read_u16(bs); ptr->bpc = gf_bs_read_u8(bs); ptr->Comp = gf_bs_read_u8(bs); ptr->UnkC = gf_bs_read_u8(bs); ptr->IPR = gf_bs_read_u8(bs); return GF_OK; }
0
389,702
alloc_tv(void) { return ALLOC_CLEAR_ONE(typval_T); }
0
244,076
GF_Err fiin_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem) { FDItemInformationBox *ptr = (FDItemInformationBox *)s; switch(a->type) { case GF_ISOM_BOX_TYPE_PAEN: BOX_FIELD_LIST_ASSIGN(partition_entries) return GF_OK; case GF_ISOM_BOX_TYPE_SEGR: BOX_FIELD_ASSIGN(session_info, FDSessionGroupBox) return GF_OK; case GF_ISOM_BOX_TYPE_GITN: BOX_FIELD_ASSIGN(group_id_to_name, GroupIdToNameBox) return GF_OK; } return GF_OK; }
0
376,347
gpg_ctx_op_wait (struct _GpgCtx *gpg) { #ifndef G_OS_WIN32 sigset_t mask, omask; pid_t retval; gint status; if (!gpg->exited) { sigemptyset (&mask); sigaddset (&mask, SIGALRM); sigprocmask (SIG_BLOCK, &mask, &omask); alarm (1); retval = waitpid (gpg->pid, &status, 0); alarm (0); sigprocmask (SIG_SETMASK, &omask, NULL); if (retval == (pid_t) -1 && errno == EINTR) { /* The child is hanging: send a friendly reminder. */ kill (gpg->pid, SIGTERM); sleep (1); retval = waitpid (gpg->pid, &status, WNOHANG); if (retval == (pid_t) 0) { /* Still hanging; use brute force. */ kill (gpg->pid, SIGKILL); sleep (1); retval = waitpid (gpg->pid, &status, WNOHANG); } } } else { status = gpg->exit_status; retval = gpg->pid; } if (retval != (pid_t) -1 && WIFEXITED (status)) return WEXITSTATUS (status); else return -1; #else return -1; #endif }
0
332,373
free_operatorfunc_option(void) { # ifdef FEAT_EVAL free_callback(&opfunc_cb); # endif }
0
349,882
static int hw_atl_utils_mpi_set_state(struct aq_hw_s *self, enum hal_atl_utils_fw_state_e state) { u32 val = aq_hw_read_reg(self, HW_ATL_MPI_CONTROL_ADR); struct hw_atl_utils_mbox_header mbox; u32 transaction_id = 0; int err = 0; if (state == MPI_RESET) { hw_atl_utils_mpi_read_mbox(self, &mbox); transaction_id = mbox.transaction_id; err = readx_poll_timeout_atomic(hw_atl_utils_get_mpi_mbox_tid, self, mbox.transaction_id, transaction_id != mbox.transaction_id, 1000U, 100000U); if (err < 0) goto err_exit; } /* On interface DEINIT we disable DW (raise bit) * Otherwise enable DW (clear bit) */ if (state == MPI_DEINIT || state == MPI_POWER) val |= HW_ATL_MPI_DIRTY_WAKE_MSK; else val &= ~HW_ATL_MPI_DIRTY_WAKE_MSK; /* Set new state bits */ val = val & ~HW_ATL_MPI_STATE_MSK; val |= state & HW_ATL_MPI_STATE_MSK; aq_hw_write_reg(self, HW_ATL_MPI_CONTROL_ADR, val); err_exit: return err; }
0
244,012
GF_Err rvcc_box_size(GF_Box *s) { GF_RVCConfigurationBox *ptr = (GF_RVCConfigurationBox *)s; ptr->size += 2; if (! ptr->predefined_rvc_config) ptr->size += 2; return GF_OK; }
0
387,762
int InstanceKlass::find_method_index(const Array<Method*>* methods, const Symbol* name, const Symbol* signature, OverpassLookupMode overpass_mode, StaticLookupMode static_mode, PrivateLookupMode private_mode) { const bool skipping_overpass = (overpass_mode == skip_overpass); const bool skipping_static = (static_mode == skip_static); const bool skipping_private = (private_mode == skip_private); const int hit = binary_search(methods, name); if (hit != -1) { const Method* const m = methods->at(hit); // Do linear search to find matching signature. First, quick check // for common case, ignoring overpasses if requested. if (method_matches(m, signature, skipping_overpass, skipping_static, skipping_private)) { return hit; } // search downwards through overloaded methods int i; for (i = hit - 1; i >= 0; --i) { const Method* const m = methods->at(i); assert(m->is_method(), "must be method"); if (m->name() != name) { break; } if (method_matches(m, signature, skipping_overpass, skipping_static, skipping_private)) { return i; } } // search upwards for (i = hit + 1; i < methods->length(); ++i) { const Method* const m = methods->at(i); assert(m->is_method(), "must be method"); if (m->name() != name) { break; } if (method_matches(m, signature, skipping_overpass, skipping_static, skipping_private)) { return i; } } // not found #ifdef ASSERT const int index = (skipping_overpass || skipping_static || skipping_private) ? -1 : linear_search(methods, name, signature); assert(-1 == index, "binary search should have found entry %d", index); #endif } return -1; }
0
512,883
longlong val_datetime_packed(THD *thd) { Datetime::Options_cmp opt(thd); return has_value() ? Datetime(thd, this, opt).to_packed() : 0; }
0
255,784
create_user_authz(authz_full_t *authz, const char *repository, const char *user, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { int i; node_t *root = create_node(NULL, result_pool); construction_context_t *ctx = create_construction_context(scratch_pool); /* Use a separate sub-pool to keep memory usage tight. */ apr_pool_t *subpool = svn_pool_create(scratch_pool); /* Find all ACLs for REPOSITORY. */ apr_array_header_t *acls = apr_array_make(subpool, authz->acls->nelts, sizeof(authz_acl_t *)); for (i = 0; i < authz->acls->nelts; ++i) { const authz_acl_t *acl = &APR_ARRAY_IDX(authz->acls, i, authz_acl_t); if (svn_authz__acl_applies_to_repo(acl, repository)) { /* ACLs in the AUTHZ are sorted by path and repository. * So, if there is a rule for the repo and a global rule for the * same path, we will detect them here. */ if (acls->nelts) { const authz_acl_t *prev_acl = APR_ARRAY_IDX(acls, acls->nelts - 1, const authz_acl_t *); if (svn_authz__compare_paths(&prev_acl->rule, &acl->rule) == 0) { svn_boolean_t global_acl_applies; svn_boolean_t repos_acl_applies; /* Previous ACL is a global rule. */ SVN_ERR_ASSERT_NO_RETURN(!strcmp(prev_acl->rule.repos, AUTHZ_ANY_REPOSITORY)); /* Current ACL is a per-repository rule. */ SVN_ERR_ASSERT_NO_RETURN(strcmp(acl->rule.repos, AUTHZ_ANY_REPOSITORY)); global_acl_applies = svn_authz__get_acl_access(NULL, prev_acl, user, repository); repos_acl_applies = svn_authz__get_acl_access(NULL, acl, user, repository); /* Prefer rules which apply to both this user and this path * over rules which apply only to the path. In cases where * both rules apply to user and path, always prefer the * repository-specific rule. */ if (!global_acl_applies || repos_acl_applies) { apr_array_pop(acls); APR_ARRAY_PUSH(acls, const authz_acl_t *) = acl; } } else APR_ARRAY_PUSH(acls, const authz_acl_t *) = acl; } else APR_ARRAY_PUSH(acls, const authz_acl_t *) = acl; } } /* Filtering and tree construction. */ for (i = 0; i < acls->nelts; ++i) process_acl(ctx, APR_ARRAY_IDX(acls, i, const authz_acl_t *), root, repository, user, result_pool, subpool); /* If there is no relevant rule at the root node, the "no access" default * applies. Give it a SEQUENCE_NUMBER that will never overrule others. */ if (!has_local_rule(&root->rights)) { root->rights.access.sequence_number = 0; root->rights.access.rights = authz_access_none; } /* Trim the tree. * * We can't do pattern comparison, so for most pattern rules we cannot * say that a set of rules "eclipses" / overrides a given other set of * rules for all possible paths. That limits the accuracy of our check * for recursive access in similar ways than for non-pattern rules. * * However, the user expects a rule ending with "**" to eclipse any older * rule in that sub-tree recursively. So, this trim function removes * eclipsed nodes from the tree. */ svn_pool_clear(subpool); trim_tree(root, NO_SEQUENCE_NUMBER, subpool); /* Calculate recursive rights. * * This is a bottom-up calculation of the range of access rights * specified anywhere in the respective sub-tree, including the base * node itself. * * To prevent additional finalization passes, we piggy-back the addition * of the ordering links of the prefix and suffix sub-node rules. */ svn_pool_clear(subpool); finalize_tree(root, &root->rights, subpool); /* Done. */ svn_pool_destroy(subpool); return root; }
0
267,842
vm_run_global (const ecma_compiled_code_t *bytecode_p, /**< pointer to bytecode to run */ ecma_object_t *function_object_p) /**< function object if available */ { #if JERRY_BUILTIN_REALMS ecma_object_t *global_obj_p = (ecma_object_t *) ecma_op_function_get_realm (bytecode_p); #else /* !JERRY_BUILTIN_REALMS */ ecma_object_t *global_obj_p = ecma_builtin_get_global (); #endif /* JERRY_BUILTIN_REALMS */ #if JERRY_ESNEXT if (bytecode_p->status_flags & CBC_CODE_FLAGS_LEXICAL_BLOCK_NEEDED) { ecma_create_global_lexical_block (global_obj_p); } #endif /* JERRY_ESNEXT */ ecma_object_t *const global_scope_p = ecma_get_global_scope (global_obj_p); vm_frame_ctx_shared_t shared; shared.bytecode_header_p = bytecode_p; shared.function_object_p = function_object_p; shared.status_flags = 0; #if JERRY_BUILTIN_REALMS ecma_value_t this_binding = ((ecma_global_object_t *) global_obj_p)->this_binding; ecma_global_object_t *saved_global_object_p = JERRY_CONTEXT (global_object_p); JERRY_CONTEXT (global_object_p) = (ecma_global_object_t *) global_obj_p; #else /* !JERRY_BUILTIN_REALMS */ ecma_value_t this_binding = ecma_make_object_value (global_obj_p); #endif /* JERRY_BUILTIN_REALMS */ ecma_value_t result = vm_run (&shared, this_binding, global_scope_p); #if JERRY_BUILTIN_REALMS JERRY_CONTEXT (global_object_p) = saved_global_object_p; #endif /* JERRY_BUILTIN_REALMS */ return result; } /* vm_run_global */
0
385,853
SYSCALL_DEFINE5(fchownat, int, dfd, const char __user *, filename, uid_t, user, gid_t, group, int, flag) { struct path path; int error = -EINVAL; int lookup_flags; if ((flag & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0) goto out; lookup_flags = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; if (flag & AT_EMPTY_PATH) lookup_flags |= LOOKUP_EMPTY; retry: error = user_path_at(dfd, filename, lookup_flags, &path); if (error) goto out; error = mnt_want_write(path.mnt); if (error) goto out_release; error = chown_common(&path, user, group); mnt_drop_write(path.mnt); out_release: path_put(&path); if (retry_estale(error, lookup_flags)) { lookup_flags |= LOOKUP_REVAL; goto retry; } out: return error; }
0
241,364
TensorShapes GetOutputMatrixShapes( const TensorShapes& input_matrix_shapes) const final { return TensorShapes({TensorShape({input_matrix_shapes[0].dim_size(1), input_matrix_shapes[1].dim_size(1)})}); }
0
312,465
qf_goto_tabwin_with_file(int fnum) { tabpage_T *tp; win_T *wp; FOR_ALL_TAB_WINDOWS(tp, wp) if (wp->w_buffer->b_fnum == fnum) { goto_tabpage_win(tp, wp); return TRUE; } return FALSE; }
0
337,817
struct sctp_chunk *sctp_make_shutdown_ack(const struct sctp_association *asoc, const struct sctp_chunk *chunk) { struct sctp_chunk *retval; retval = sctp_make_control(asoc, SCTP_CID_SHUTDOWN_ACK, 0, 0, GFP_ATOMIC); /* RFC 2960 6.4 Multi-homed SCTP Endpoints * * An endpoint SHOULD transmit reply chunks (e.g., SACK, * HEARTBEAT ACK, * etc.) to the same destination transport * address from which it * received the DATA or control chunk * to which it is replying. * * [ACK back to where the SHUTDOWN came from.] */ if (retval && chunk) retval->transport = chunk->transport; return retval; }
0
390,578
SetVirtualModMap( XkbSrvInfoPtr xkbi, xkbSetMapReq * req, xkbVModMapWireDesc * wire, XkbChangesPtr changes) { register unsigned i,first,last; XkbServerMapPtr srv = xkbi->desc->server; first= req->firstVModMapKey; last= req->firstVModMapKey+req->nVModMapKeys-1; bzero(&srv->vmodmap[first],req->nVModMapKeys*sizeof(unsigned short)); for (i=0;i<req->totalVModMapKeys;i++,wire++) { srv->vmodmap[wire->key]= wire->vmods; } if (first>0) { if (changes->map.changed&XkbVirtualModMapMask) { int oldLast; oldLast= changes->map.first_vmodmap_key+ changes->map.num_vmodmap_keys-1; if (changes->map.first_vmodmap_key<first) first= changes->map.first_vmodmap_key; if (oldLast>last) last= oldLast; } changes->map.first_vmodmap_key= first; changes->map.num_vmodmap_keys= (last-first)+1; } return (char *)wire; }
0
459,090
static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, struct tcf_block_ext_info *ei, struct netlink_ext_ack *extack) { struct net_device *dev = q->dev_queue->dev; int err; down_write(&block->cb_lock); /* If tc offload feature is disabled and the block we try to bind * to already has some offloaded filters, forbid to bind. */ if (dev->netdev_ops->ndo_setup_tc && !tc_can_offload(dev) && tcf_block_offload_in_use(block)) { NL_SET_ERR_MSG(extack, "Bind to offloaded block failed as dev has offload disabled"); err = -EOPNOTSUPP; goto err_unlock; } err = tcf_block_offload_cmd(block, dev, q, ei, FLOW_BLOCK_BIND, extack); if (err == -EOPNOTSUPP) goto no_offload_dev_inc; if (err) goto err_unlock; up_write(&block->cb_lock); return 0; no_offload_dev_inc: if (tcf_block_offload_in_use(block)) goto err_unlock; err = 0; block->nooffloaddevcnt++; err_unlock: up_write(&block->cb_lock); return err; }
0
463,182
static void annotate_state_unset_scope(annotate_state_t *state) { init_internal(); if (state->ourmailbox) mailbox_close(&state->ourmailbox); state->mailbox = NULL; if (state->ourmbentry) mboxlist_entry_free(&state->ourmbentry); state->mbentry = NULL; state->uid = 0; state->which = ANNOTATION_SCOPE_UNKNOWN; annotate_putdb(&state->d); }
0
261,191
const char* MqttClient_GetProtocolVersionString(MqttClient *client) { const char* str = NULL; int ver = MqttClient_GetProtocolVersion(client); switch (ver) { case MQTT_CONNECT_PROTOCOL_LEVEL_4: return "v3.1.1"; #ifdef WOLFMQTT_V5 case MQTT_CONNECT_PROTOCOL_LEVEL_5: return "v5"; #endif default: break; } return str; }
0
220,241
Status Graph::AddWhileContext(StringPiece frame_name, std::vector<Node*> enter_nodes, std::vector<Node*> exit_nodes, OutputTensor cond_output, std::vector<OutputTensor> body_inputs, std::vector<OutputTensor> body_outputs, WhileContext** result) { auto pair = while_ctxs_.insert(std::pair<std::string, WhileContext>( std::string(frame_name), WhileContext(frame_name, std::move(enter_nodes), std::move(exit_nodes), cond_output, std::move(body_inputs), std::move(body_outputs)))); if (!pair.second) { *result = nullptr; return errors::InvalidArgument("WhileContext with frame name '", frame_name, "' already exists"); } *result = &pair.first->second; return Status::OK(); }
0
462,250
static void* clone_sockaddr_attr(pj_pool_t *pool, const void *src) { pj_stun_sockaddr_attr *dst = PJ_POOL_ALLOC_T(pool, pj_stun_sockaddr_attr); pj_memcpy(dst, src, sizeof(pj_stun_sockaddr_attr)); return (void*)dst; }
0
402,631
SECU_FilePasswd(PK11SlotInfo *slot, PRBool retry, void *arg) { cms_context *cms = (cms_context *)arg; int fd; char *file = NULL; char *token_name = slot ? PK11_GetTokenName(slot) : NULL; struct token_pass *phrases = NULL; size_t nphrases = 0; char *phrase = NULL; char *start; char *ret = NULL; char *path; ingress(); dprintf("token_name: %s", token_name); path = cms->pwdata.data; if (!path || retry) goto err; phrases = calloc(1, sizeof(struct token_pass)); if (!phrases) goto err; fd = open(path, O_RDONLY|O_CLOEXEC); if (fd < 0) { goto err_phrases; } else { size_t file_len = 0; int rc; rc = read_file(fd, &file, &file_len); set_errno_guard(); close(fd); if (rc < 0 || file_len < 1) goto err_file; file[file_len-1] = '\0'; dprintf("file_len:%zd", file_len); dprintf("file:\"%s\"", file); unbreak_line_continuations(file, file_len); } start = file; while (start && start[0]) { size_t span; struct token_pass *new_phrases; int rc; char c; new_phrases = reallocarray(phrases, nphrases + 1, sizeof(struct token_pass)); if (!new_phrases) goto err_phrases; phrases = new_phrases; memset(&new_phrases[nphrases], 0, sizeof(struct token_pass)); span = strspn(start, whitespace_and_eol_chars); dprintf("whitespace span is %zd", span); start += span; span = strcspn(start, eol_chars); dprintf("non-whitespace span is %zd", span); c = start[span]; start[span] = '\0'; dprintf("file:\"%s\"", file); rc = parse_pwfile_line(start, &phrases[nphrases++]); dprintf("parse_pwfile_line returned %d", rc); if (rc < 0) goto err_phrases; if (c != '\0') span++; start += span; dprintf("start is file[%ld] == '\\x%02hhx'", start - file, start[0]); } qsort(phrases, nphrases, sizeof(struct token_pass), token_pass_cmp); cms->pwdata.source = PW_DATABASE; xfree(cms->pwdata.data); cms->pwdata.pwdb.phrases = phrases; cms->pwdata.pwdb.nphrases = nphrases; for (size_t i = 0; i < nphrases; i++) { if (phrases[i].token == NULL || phrases[i].token[0] == '\0' || (token_name && !strcmp(token_name, phrases[i].token))) { phrase = phrases[i].pass; break; } } if (phrase) { ret = PORT_Strdup(phrase); if (!ret) errno = ENOMEM; } err_file: xfree(file); err_phrases: xfree(phrases); err: dprintf("ret:\"%s\"", ret ? ret : "(null)"); egress(); return ret; }
0
231,691
TEST_F(QuicServerTransportTest, ReceiveConnectionCloseTwice) { auto qLogger = std::make_shared<FileQLogger>(VantagePoint::Server); server->getNonConstConn().qLogger = qLogger; ShortHeader header( ProtectionType::KeyPhaseZero, *server->getConn().serverConnectionId, clientNextAppDataPacketNum++); RegularQuicPacketBuilder builder( server->getConn().udpSendPacketLen, std::move(header), 0 /* largestAcked */); builder.encodePacketHeader(); std::string errMsg = "Mind the gap"; ConnectionCloseFrame connClose( QuicErrorCode(TransportErrorCode::NO_ERROR), errMsg); writeFrame(std::move(connClose), builder); auto packet = std::move(builder).buildPacket(); EXPECT_CALL(connCallback, onConnectionEnd()); deliverDataWithoutErrorCheck(packetToBuf(packet)); // Now the transport should be closed EXPECT_EQ( QuicErrorCode(TransportErrorCode::NO_ERROR), server->getConn().localConnectionError->first); EXPECT_EQ( server->getConn().peerConnectionError->first, QuicErrorCode(TransportErrorCode::NO_ERROR)); auto closedMsg = folly::to<std::string>("Server closed by peer reason=", errMsg); EXPECT_EQ(server->getConn().peerConnectionError->second, closedMsg); EXPECT_TRUE(server->isClosed()); EXPECT_TRUE(verifyFramePresent( serverWrites, *makeClientEncryptedCodec(), QuicFrame::Type::ConnectionCloseFrame)); serverWrites.clear(); deliverDataWithoutErrorCheck(packetToBuf(packet)); EXPECT_FALSE(verifyFramePresent( serverWrites, *makeClientEncryptedCodec(), QuicFrame::Type::ConnectionCloseFrame)); std::vector<int> indices = getQLogEventIndices(QLogEventType::PacketDrop, qLogger); EXPECT_EQ(indices.size(), 1); auto tmp = std::move(qLogger->logs[indices[0]]); auto event = dynamic_cast<QLogPacketDropEvent*>(tmp.get()); EXPECT_EQ(event->packetSize, 29); EXPECT_EQ( event->dropReason, QuicTransportStatsCallback::toString( PacketDropReason::SERVER_STATE_CLOSED)); }
0
220,847
inline void GetActivationMinMax(FusedActivationFunctionType ac, float* output_activation_min, float* output_activation_max) { switch (ac) { case FusedActivationFunctionType::kNone: *output_activation_min = std::numeric_limits<float>::lowest(); *output_activation_max = std::numeric_limits<float>::max(); break; case FusedActivationFunctionType::kRelu: *output_activation_min = 0.f; *output_activation_max = std::numeric_limits<float>::max(); break; case FusedActivationFunctionType::kRelu1: *output_activation_min = -1.f; *output_activation_max = 1.f; break; case FusedActivationFunctionType::kRelu6: *output_activation_min = 0.f; *output_activation_max = 6.f; break; } }
0
409,497
term_cursor_mode(int forced) { static int showing_mode = -1; char_u *p; // Only do something when redrawing the screen and we can restore the // mode. if (!full_screen || *T_CEI == NUL) { # ifdef FEAT_TERMRESPONSE if (forced && initial_cursor_shape > 0) // Restore to initial values. term_cursor_shape(initial_cursor_shape, initial_cursor_blink); # endif return; } if ((State & MODE_REPLACE) == MODE_REPLACE) { if (forced || showing_mode != MODE_REPLACE) { if (*T_CSR != NUL) p = T_CSR; // Replace mode cursor else p = T_CSI; // fall back to Insert mode cursor if (*p != NUL) { out_str(p); showing_mode = MODE_REPLACE; } } } else if (State & MODE_INSERT) { if ((forced || showing_mode != MODE_INSERT) && *T_CSI != NUL) { out_str(T_CSI); // Insert mode cursor showing_mode = MODE_INSERT; } } else if (forced || showing_mode != MODE_NORMAL) { out_str(T_CEI); // non-Insert mode cursor showing_mode = MODE_NORMAL; } }
0
474,460
HandleToObject( TPMI_DH_OBJECT handle // IN: handle of the object ) { UINT32 index; // Return NULL if the handle references a permanent handle because there is no // associated OBJECT. if(HandleGetType(handle) == TPM_HT_PERMANENT) return NULL; // In this implementation, the handle is determined by the slot occupied by the // object. index = handle - TRANSIENT_FIRST; pAssert(index < MAX_LOADED_OBJECTS); pAssert(s_objects[index].attributes.occupied); return &s_objects[index]; }
0
262,034
Proto_ConcatXMLStrings(gchar *str1, gchar *str2) { gchar *newStr; if (NULL == str2) { return str1; } newStr = g_strdup_printf("%s%s", str1, str2); g_free(str1); g_free(str2); return newStr; }
0
221,636
std::unique_ptr<FunctionPass> CreateSymbolicShapeOptimizationPass( bool constraints_only) { return std::make_unique<SymbolicShapeOptimizationPass>(constraints_only); }
0
254,723
njs_typed_array_from(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t unused) { double num; int64_t length, i; njs_int_t ret; njs_value_t *this, *source, *mapfn; njs_value_t arguments[3], retval; njs_function_t *function; njs_typed_array_t *array; this = njs_argument(args, 0); if (njs_slow_path(!njs_is_constructor(this))) { njs_type_error(vm, "%s is not a constructor", njs_type_string(this->type)); return NJS_ERROR; } mapfn = njs_arg(args, nargs, 2); if (njs_slow_path(!njs_is_function_or_undefined(mapfn))) { njs_type_error(vm, "\"mapfn\" argument is not callable"); return NJS_ERROR; } function = NULL; if (njs_is_function(mapfn)) { function = njs_function(mapfn); } source = njs_arg(args, nargs, 1); ret = njs_value_to_object(vm, source); if (njs_slow_path(ret != NJS_OK)) { return ret; } ret = njs_object_length(vm, source, &length); if (njs_slow_path(ret == NJS_ERROR)) { return ret; } njs_set_number(&arguments[0], length); ret = njs_typed_array_create(vm, this, arguments, 1, &vm->retval); if (njs_slow_path(ret != NJS_OK)) { return NJS_ERROR; } array = njs_typed_array(&vm->retval); arguments[0] = *njs_arg(args, nargs, 3); for (i = 0; i < length; i++) { ret = njs_value_property_i64(vm, source, i, &retval); if (njs_slow_path(ret == NJS_ERROR)) { return NJS_ERROR; } if (function != NULL) { arguments[1] = retval; njs_set_number(&arguments[2], i); ret = njs_function_apply(vm, function, arguments, 3, &retval); if (njs_slow_path(ret != NJS_OK)) { return NJS_ERROR; } } ret = njs_value_to_number(vm, &retval, &num); if (njs_slow_path(ret != NJS_OK)) { return NJS_ERROR; } njs_typed_array_prop_set(vm, array, i, num); } njs_set_typed_array(&vm->retval, array); return NJS_OK; }
0
139,223
gfx::Rect OverlayWindowViews::GetPlayPauseControlsBounds() { return play_pause_controls_view_->GetMirroredBounds(); }
0
210,700
static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset, struct inode **i) { squashfs_dir_header_2 dirh; char buffer[sizeof(squashfs_dir_entry_2) + SQUASHFS_NAME_LEN + 1] __attribute__((aligned)); squashfs_dir_entry_2 *dire = (squashfs_dir_entry_2 *) buffer; long long start; int bytes; int dir_count, size; struct dir_ent *new_dir; struct dir *dir; TRACE("squashfs_opendir: inode start block %d, offset %d\n", block_start, offset); *i = read_inode(block_start, offset); dir = malloc(sizeof(struct dir)); if(dir == NULL) EXIT_UNSQUASH("squashfs_opendir: malloc failed!\n"); dir->dir_count = 0; dir->cur_entry = 0; dir->mode = (*i)->mode; dir->uid = (*i)->uid; dir->guid = (*i)->gid; dir->mtime = (*i)->time; dir->xattr = (*i)->xattr; dir->dirs = NULL; if ((*i)->data == 0) /* * if the directory is empty, skip the unnecessary * lookup_entry, this fixes the corner case with * completely empty filesystems where lookup_entry correctly * returning -1 is incorrectly treated as an error */ return dir; start = sBlk.s.directory_table_start + (*i)->start; bytes = lookup_entry(directory_table_hash, start); if(bytes == -1) EXIT_UNSQUASH("squashfs_opendir: directory block %d not " "found!\n", block_start); bytes += (*i)->offset; size = (*i)->data + bytes; while(bytes < size) { if(swap) { squashfs_dir_header_2 sdirh; memcpy(&sdirh, directory_table + bytes, sizeof(sdirh)); SQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh); } else memcpy(&dirh, directory_table + bytes, sizeof(dirh)); dir_count = dirh.count + 1; TRACE("squashfs_opendir: Read directory header @ byte position " "%d, %d directory entries\n", bytes, dir_count); bytes += sizeof(dirh); /* dir_count should never be larger than SQUASHFS_DIR_COUNT */ if(dir_count > SQUASHFS_DIR_COUNT) { ERROR("File system corrupted: too many entries in directory\n"); goto corrupted; } while(dir_count--) { if(swap) { squashfs_dir_entry_2 sdire; memcpy(&sdire, directory_table + bytes, sizeof(sdire)); SQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire); } else memcpy(dire, directory_table + bytes, sizeof(*dire)); bytes += sizeof(*dire); /* size should never be SQUASHFS_NAME_LEN or larger */ if(dire->size >= SQUASHFS_NAME_LEN) { ERROR("File system corrupted: filename too long\n"); goto corrupted; } memcpy(dire->name, directory_table + bytes, dire->size + 1); dire->name[dire->size + 1] = '\0'; TRACE("squashfs_opendir: directory entry %s, inode " "%d:%d, type %d\n", dire->name, dirh.start_block, dire->offset, dire->type); if((dir->dir_count % DIR_ENT_SIZE) == 0) { new_dir = realloc(dir->dirs, (dir->dir_count + DIR_ENT_SIZE) * sizeof(struct dir_ent)); if(new_dir == NULL) EXIT_UNSQUASH("squashfs_opendir: " "realloc failed!\n"); dir->dirs = new_dir; } strcpy(dir->dirs[dir->dir_count].name, dire->name); dir->dirs[dir->dir_count].start_block = dirh.start_block; dir->dirs[dir->dir_count].offset = dire->offset; dir->dirs[dir->dir_count].type = dire->type; dir->dir_count ++; bytes += dire->size + 1; } } return dir; corrupted: free(dir->dirs); free(dir); return NULL; }
1
90,810
UpdateAccessTimeTask( QuotaManager* manager, const GURL& origin, StorageType type, base::Time accessed_time) : DatabaseTaskBase(manager), origin_(origin), type_(type), accessed_time_(accessed_time) {}
0
487,649
static int set_one_prio(struct task_struct *p, int niceval, int error) { int no_nice; if (p->uid != current->euid && p->euid != current->euid && !capable(CAP_SYS_NICE)) { error = -EPERM; goto out; } if (niceval < task_nice(p) && !can_nice(p, niceval)) { error = -EACCES; goto out; } no_nice = security_task_setnice(p, niceval); if (no_nice) { error = no_nice; goto out; } if (error == -ESRCH) error = 0; set_user_nice(p, niceval); out: return error; }
0
242,616
Status Put(Tuple* tuple) { std::unique_lock<std::mutex> lock(mu_); std::size_t tuple_bytes = GetTupleBytes(*tuple); // Sanity check so that we don't block for ever below if (memory_limit_ > 0 && tuple_bytes > memory_limit_) { return Status( errors::ResourceExhausted("Attempted to insert " "tensors with combined size of '", tuple_bytes, "' bytes into " "Staging Area with a memory limit of '", memory_limit_, "'.")); } // If buffer capacity is bounded wait until elements have been removed if (IsBounded()) { full_cond_var_.wait(lock, [tuple_bytes, this]() { // If there's a memory limit, check if there's space for insertion bool memory_limit_valid = memory_limit_ > 0 ? !WouldExceedMemoryLimit(tuple_bytes) : true; // If we're configured for capacity check if there's space for insertion bool capacity_valid = capacity_ > 0 ? !IsCapacityFull() : true; // Stop waiting upon success for both conditions return capacity_valid && memory_limit_valid; }); } // Update bytes in the Staging Area current_bytes_ += tuple_bytes; // Store tuple buf_.push_back(std::move(*tuple)); lock.unlock(); // Notify all removers. Removers // may be peeking at a specific element or waiting // for the element at the front of the deque. // As we don't know the appropriate one to wake up // we should wake them all. non_empty_cond_var_.notify_all(); return Status::OK(); }
0
508,856
void unsafe_mixed_statement(LEX::enum_stmt_accessed_table a, LEX::enum_stmt_accessed_table b, uint condition) { int type= 0; int index= (1U << a) | (1U << b); for (type= 0; type < 256; type++) { if ((type & index) == index) { binlog_unsafe_map[type] |= condition; } } }
0
225,112
bool OpDefEqual(const OpDef& o1, const OpDef& o2) { // attr order doesn't matter. // Compare it separately here instead of serializing below. if (!RepeatedAttrDefEqual(o1.attr(), o2.attr())) return false; // `control_output` order doesn't matter. std::set<string> control_output1(o1.control_output().begin(), o1.control_output().end()); std::set<string> control_output2(o2.control_output().begin(), o2.control_output().end()); if (control_output1 != control_output2) return false; // Clear `attr` and `control_output` fields, serialize, and compare serialized // strings. OpDef o1_copy = o1; OpDef o2_copy = o2; o1_copy.clear_attr(); o1_copy.clear_control_output(); o2_copy.clear_attr(); o2_copy.clear_control_output(); return AreSerializedProtosEqual(o1_copy, o2_copy); }
0
458,923
get_c_indent(void) { pos_T cur_curpos; int amount; int scope_amount; int cur_amount = MAXCOL; colnr_T col; char_u *theline; char_u *linecopy; pos_T *trypos; pos_T *comment_pos; pos_T *tryposBrace = NULL; pos_T tryposCopy; pos_T our_paren_pos; char_u *start; int start_brace; #define BRACE_IN_COL0 1 // '{' is in column 0 #define BRACE_AT_START 2 // '{' is at start of line #define BRACE_AT_END 3 // '{' is at end of line linenr_T ourscope; char_u *l; char_u *look; char_u terminated; int lookfor; int whilelevel; linenr_T lnum; int n; int iscase; int lookfor_break; int lookfor_cpp_namespace = FALSE; int cont_amount = 0; // amount for continuation line int original_line_islabel; int added_to_amount = 0; int js_cur_has_key = 0; linenr_T raw_string_start = 0; cpp_baseclass_cache_T cache_cpp_baseclass = { FALSE, { MAXLNUM, 0 } }; // make a copy, value is changed below int ind_continuation = curbuf->b_ind_continuation; // remember where the cursor was when we started cur_curpos = curwin->w_cursor; // if we are at line 1 zero indent is fine, right? if (cur_curpos.lnum == 1) return 0; // Get a copy of the current contents of the line. // This is required, because only the most recent line obtained with // ml_get is valid! linecopy = vim_strsave(ml_get(cur_curpos.lnum)); if (linecopy == NULL) return 0; // In insert mode and the cursor is on a ')' truncate the line at the // cursor position. We don't want to line up with the matching '(' when // inserting new stuff. // For unknown reasons the cursor might be past the end of the line, thus // check for that. if ((State & INSERT) && curwin->w_cursor.col < (colnr_T)STRLEN(linecopy) && linecopy[curwin->w_cursor.col] == ')') linecopy[curwin->w_cursor.col] = NUL; theline = skipwhite(linecopy); // move the cursor to the start of the line curwin->w_cursor.col = 0; original_line_islabel = cin_islabel(); // XXX // If we are inside a raw string don't change the indent. // Ignore a raw string inside a comment. comment_pos = ind_find_start_comment(); if (comment_pos != NULL) { // findmatchlimit() static pos is overwritten, make a copy tryposCopy = *comment_pos; comment_pos = &tryposCopy; } trypos = find_start_rawstring(curbuf->b_ind_maxcomment); if (trypos != NULL && (comment_pos == NULL || LT_POS(*trypos, *comment_pos))) { amount = -1; goto laterend; } // #defines and so on go at the left when included in 'cinkeys', // excluding pragmas when customized in 'cinoptions' if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', TRUE))) { char_u *directive = skipwhite(theline + 1); if (curbuf->b_ind_pragma == 0 || STRNCMP(directive, "pragma", 6) != 0) { amount = curbuf->b_ind_hash_comment; goto theend; } } // Is it a non-case label? Then that goes at the left margin too unless: // - JS flag is set. // - 'L' item has a positive value. if (original_line_islabel && !curbuf->b_ind_js && curbuf->b_ind_jump_label < 0) { amount = 0; goto theend; } // If we're inside a "//" comment and there is a "//" comment in a // previous line, lineup with that one. if (cin_islinecomment(theline) && (trypos = find_line_comment()) != NULL) // XXX { // find how indented the line beginning the comment is getvcol(curwin, trypos, &col, NULL, NULL); amount = col; goto theend; } // If we're inside a comment and not looking at the start of the // comment, try using the 'comments' option. if (!cin_iscomment(theline) && comment_pos != NULL) // XXX { int lead_start_len = 2; int lead_middle_len = 1; char_u lead_start[COM_MAX_LEN]; // start-comment string char_u lead_middle[COM_MAX_LEN]; // middle-comment string char_u lead_end[COM_MAX_LEN]; // end-comment string char_u *p; int start_align = 0; int start_off = 0; int done = FALSE; // find how indented the line beginning the comment is getvcol(curwin, comment_pos, &col, NULL, NULL); amount = col; *lead_start = NUL; *lead_middle = NUL; p = curbuf->b_p_com; while (*p != NUL) { int align = 0; int off = 0; int what = 0; while (*p != NUL && *p != ':') { if (*p == COM_START || *p == COM_END || *p == COM_MIDDLE) what = *p++; else if (*p == COM_LEFT || *p == COM_RIGHT) align = *p++; else if (VIM_ISDIGIT(*p) || *p == '-') off = getdigits(&p); else ++p; } if (*p == ':') ++p; (void)copy_option_part(&p, lead_end, COM_MAX_LEN, ","); if (what == COM_START) { STRCPY(lead_start, lead_end); lead_start_len = (int)STRLEN(lead_start); start_off = off; start_align = align; } else if (what == COM_MIDDLE) { STRCPY(lead_middle, lead_end); lead_middle_len = (int)STRLEN(lead_middle); } else if (what == COM_END) { // If our line starts with the middle comment string, line it // up with the comment opener per the 'comments' option. if (STRNCMP(theline, lead_middle, lead_middle_len) == 0 && STRNCMP(theline, lead_end, STRLEN(lead_end)) != 0) { done = TRUE; if (curwin->w_cursor.lnum > 1) { // If the start comment string matches in the previous // line, use the indent of that line plus offset. If // the middle comment string matches in the previous // line, use the indent of that line. XXX look = skipwhite(ml_get(curwin->w_cursor.lnum - 1)); if (STRNCMP(look, lead_start, lead_start_len) == 0) amount = get_indent_lnum(curwin->w_cursor.lnum - 1); else if (STRNCMP(look, lead_middle, lead_middle_len) == 0) { amount = get_indent_lnum(curwin->w_cursor.lnum - 1); break; } // If the start comment string doesn't match with the // start of the comment, skip this entry. XXX else if (STRNCMP(ml_get(comment_pos->lnum) + comment_pos->col, lead_start, lead_start_len) != 0) continue; } if (start_off != 0) amount += start_off; else if (start_align == COM_RIGHT) amount += vim_strsize(lead_start) - vim_strsize(lead_middle); break; } // If our line starts with the end comment string, line it up // with the middle comment if (STRNCMP(theline, lead_middle, lead_middle_len) != 0 && STRNCMP(theline, lead_end, STRLEN(lead_end)) == 0) { amount = get_indent_lnum(curwin->w_cursor.lnum - 1); // XXX if (off != 0) amount += off; else if (align == COM_RIGHT) amount += vim_strsize(lead_start) - vim_strsize(lead_middle); done = TRUE; break; } } } // If our line starts with an asterisk, line up with the // asterisk in the comment opener; otherwise, line up // with the first character of the comment text. if (done) ; else if (theline[0] == '*') amount += 1; else { // If we are more than one line away from the comment opener, take // the indent of the previous non-empty line. If 'cino' has "CO" // and we are just below the comment opener and there are any // white characters after it line up with the text after it; // otherwise, add the amount specified by "c" in 'cino' amount = -1; for (lnum = cur_curpos.lnum - 1; lnum > comment_pos->lnum; --lnum) { if (linewhite(lnum)) // skip blank lines continue; amount = get_indent_lnum(lnum); // XXX break; } if (amount == -1) // use the comment opener { if (!curbuf->b_ind_in_comment2) { start = ml_get(comment_pos->lnum); look = start + comment_pos->col + 2; // skip / and * if (*look != NUL) // if something after it comment_pos->col = (colnr_T)(skipwhite(look) - start); } getvcol(curwin, comment_pos, &col, NULL, NULL); amount = col; if (curbuf->b_ind_in_comment2 || *look == NUL) amount += curbuf->b_ind_in_comment; } } goto theend; } // Are we looking at a ']' that has a match? if (*skipwhite(theline) == ']' && (trypos = find_match_char('[', curbuf->b_ind_maxparen)) != NULL) { // align with the line containing the '['. amount = get_indent_lnum(trypos->lnum); goto theend; } // Are we inside parentheses or braces? XXX if (((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL && curbuf->b_ind_java == 0) || (tryposBrace = find_start_brace()) != NULL || trypos != NULL) { if (trypos != NULL && tryposBrace != NULL) { // Both an unmatched '(' and '{' is found. Use the one which is // closer to the current cursor position, set the other to NULL. if (trypos->lnum != tryposBrace->lnum ? trypos->lnum < tryposBrace->lnum : trypos->col < tryposBrace->col) trypos = NULL; else tryposBrace = NULL; } if (trypos != NULL) { // If the matching paren is more than one line away, use the indent of // a previous non-empty line that matches the same paren. if (theline[0] == ')' && curbuf->b_ind_paren_prev) { // Line up with the start of the matching paren line. amount = get_indent_lnum(curwin->w_cursor.lnum - 1); // XXX } else { amount = -1; our_paren_pos = *trypos; for (lnum = cur_curpos.lnum - 1; lnum > our_paren_pos.lnum; --lnum) { l = skipwhite(ml_get(lnum)); if (cin_nocode(l)) // skip comment lines continue; if (cin_ispreproc_cont(&l, &lnum, &amount)) continue; // ignore #define, #if, etc. curwin->w_cursor.lnum = lnum; // Skip a comment or raw string. XXX if ((trypos = ind_find_start_CORS(NULL)) != NULL) { lnum = trypos->lnum + 1; continue; } // XXX if ((trypos = find_match_paren( corr_ind_maxparen(&cur_curpos))) != NULL && trypos->lnum == our_paren_pos.lnum && trypos->col == our_paren_pos.col) { amount = get_indent_lnum(lnum); // XXX if (theline[0] == ')') { if (our_paren_pos.lnum != lnum && cur_amount > amount) cur_amount = amount; amount = -1; } break; } } } // Line up with line where the matching paren is. XXX // If the line starts with a '(' or the indent for unclosed // parentheses is zero, line up with the unclosed parentheses. if (amount == -1) { int ignore_paren_col = 0; int is_if_for_while = 0; if (curbuf->b_ind_if_for_while) { // Look for the outermost opening parenthesis on this line // and check whether it belongs to an "if", "for" or "while". pos_T cursor_save = curwin->w_cursor; pos_T outermost; char_u *line; trypos = &our_paren_pos; do { outermost = *trypos; curwin->w_cursor.lnum = outermost.lnum; curwin->w_cursor.col = outermost.col; trypos = find_match_paren(curbuf->b_ind_maxparen); } while (trypos && trypos->lnum == outermost.lnum); curwin->w_cursor = cursor_save; line = ml_get(outermost.lnum); is_if_for_while = cin_is_if_for_while_before_offset(line, &outermost.col); } amount = skip_label(our_paren_pos.lnum, &look); look = skipwhite(look); if (*look == '(') { linenr_T save_lnum = curwin->w_cursor.lnum; char_u *line; int look_col; // Ignore a '(' in front of the line that has a match before // our matching '('. curwin->w_cursor.lnum = our_paren_pos.lnum; line = ml_get_curline(); look_col = (int)(look - line); curwin->w_cursor.col = look_col + 1; if ((trypos = findmatchlimit(NULL, ')', 0, curbuf->b_ind_maxparen)) != NULL && trypos->lnum == our_paren_pos.lnum && trypos->col < our_paren_pos.col) ignore_paren_col = trypos->col + 1; curwin->w_cursor.lnum = save_lnum; look = ml_get(our_paren_pos.lnum) + look_col; } if (theline[0] == ')' || (curbuf->b_ind_unclosed == 0 && is_if_for_while == 0) || (!curbuf->b_ind_unclosed_noignore && *look == '(' && ignore_paren_col == 0)) { // If we're looking at a close paren, line up right there; // otherwise, line up with the next (non-white) character. // When b_ind_unclosed_wrapped is set and the matching paren is // the last nonwhite character of the line, use either the // indent of the current line or the indentation of the next // outer paren and add b_ind_unclosed_wrapped (for very long // lines). if (theline[0] != ')') { cur_amount = MAXCOL; l = ml_get(our_paren_pos.lnum); if (curbuf->b_ind_unclosed_wrapped && cin_ends_in(l, (char_u *)"(", NULL)) { // look for opening unmatched paren, indent one level // for each additional level n = 1; for (col = 0; col < our_paren_pos.col; ++col) { switch (l[col]) { case '(': case '{': ++n; break; case ')': case '}': if (n > 1) --n; break; } } our_paren_pos.col = 0; amount += n * curbuf->b_ind_unclosed_wrapped; } else if (curbuf->b_ind_unclosed_whiteok) our_paren_pos.col++; else { col = our_paren_pos.col + 1; while (VIM_ISWHITE(l[col])) col++; if (l[col] != NUL) // In case of trailing space our_paren_pos.col = col; else our_paren_pos.col++; } } // Find how indented the paren is, or the character after it // if we did the above "if". if (our_paren_pos.col > 0) { getvcol(curwin, &our_paren_pos, &col, NULL, NULL); if (cur_amount > (int)col) cur_amount = col; } } if (theline[0] == ')' && curbuf->b_ind_matching_paren) { // Line up with the start of the matching paren line. } else if ((curbuf->b_ind_unclosed == 0 && is_if_for_while == 0) || (!curbuf->b_ind_unclosed_noignore && *look == '(' && ignore_paren_col == 0)) { if (cur_amount != MAXCOL) amount = cur_amount; } else { // Add b_ind_unclosed2 for each '(' before our matching one, // but ignore (void) before the line (ignore_paren_col). col = our_paren_pos.col; while ((int)our_paren_pos.col > ignore_paren_col) { --our_paren_pos.col; switch (*ml_get_pos(&our_paren_pos)) { case '(': amount += curbuf->b_ind_unclosed2; col = our_paren_pos.col; break; case ')': amount -= curbuf->b_ind_unclosed2; col = MAXCOL; break; } } // Use b_ind_unclosed once, when the first '(' is not inside // braces if (col == MAXCOL) amount += curbuf->b_ind_unclosed; else { curwin->w_cursor.lnum = our_paren_pos.lnum; curwin->w_cursor.col = col; if (find_match_paren_after_brace(curbuf->b_ind_maxparen) != NULL) amount += curbuf->b_ind_unclosed2; else { if (is_if_for_while) amount += curbuf->b_ind_if_for_while; else amount += curbuf->b_ind_unclosed; } } // For a line starting with ')' use the minimum of the two // positions, to avoid giving it more indent than the previous // lines: // func_long_name( if (x // arg && yy // ) ^ not here ) ^ not here if (cur_amount < amount) amount = cur_amount; } } // add extra indent for a comment if (cin_iscomment(theline)) amount += curbuf->b_ind_comment; } else { // We are inside braces, there is a { before this line at the position // stored in tryposBrace. // Make a copy of tryposBrace, it may point to pos_copy inside // find_start_brace(), which may be changed somewhere. tryposCopy = *tryposBrace; tryposBrace = &tryposCopy; trypos = tryposBrace; ourscope = trypos->lnum; start = ml_get(ourscope); // Now figure out how indented the line is in general. // If the brace was at the start of the line, we use that; // otherwise, check out the indentation of the line as // a whole and then add the "imaginary indent" to that. look = skipwhite(start); if (*look == '{') { getvcol(curwin, trypos, &col, NULL, NULL); amount = col; if (*start == '{') start_brace = BRACE_IN_COL0; else start_brace = BRACE_AT_START; } else { // That opening brace might have been on a continuation // line. if so, find the start of the line. curwin->w_cursor.lnum = ourscope; // Position the cursor over the rightmost paren, so that // matching it will take us back to the start of the line. lnum = ourscope; if (find_last_paren(start, '(', ')') && (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) lnum = trypos->lnum; // It could have been something like // case 1: if (asdf && // ldfd) { // } if ((curbuf->b_ind_js || curbuf->b_ind_keep_case_label) && cin_iscase(skipwhite(ml_get_curline()), FALSE)) amount = get_indent(); else if (curbuf->b_ind_js) amount = get_indent_lnum(lnum); else amount = skip_label(lnum, &l); start_brace = BRACE_AT_END; } // For Javascript check if the line starts with "key:". if (curbuf->b_ind_js) js_cur_has_key = cin_has_js_key(theline); // If we're looking at a closing brace, that's where // we want to be. otherwise, add the amount of room // that an indent is supposed to be. if (theline[0] == '}') { // they may want closing braces to line up with something // other than the open brace. indulge them, if so. amount += curbuf->b_ind_close_extra; } else { // If we're looking at an "else", try to find an "if" // to match it with. // If we're looking at a "while", try to find a "do" // to match it with. lookfor = LOOKFOR_INITIAL; if (cin_iselse(theline)) lookfor = LOOKFOR_IF; else if (cin_iswhileofdo(theline, cur_curpos.lnum)) // XXX lookfor = LOOKFOR_DO; if (lookfor != LOOKFOR_INITIAL) { curwin->w_cursor.lnum = cur_curpos.lnum; if (find_match(lookfor, ourscope) == OK) { amount = get_indent(); // XXX goto theend; } } // We get here if we are not on an "while-of-do" or "else" (or // failed to find a matching "if"). // Search backwards for something to line up with. // First set amount for when we don't find anything. // if the '{' is _really_ at the left margin, use the imaginary // location of a left-margin brace. Otherwise, correct the // location for b_ind_open_extra. if (start_brace == BRACE_IN_COL0) // '{' is in column 0 { amount = curbuf->b_ind_open_left_imag; lookfor_cpp_namespace = TRUE; } else if (start_brace == BRACE_AT_START && lookfor_cpp_namespace) // '{' is at start { lookfor_cpp_namespace = TRUE; } else { if (start_brace == BRACE_AT_END) // '{' is at end of line { amount += curbuf->b_ind_open_imag; l = skipwhite(ml_get_curline()); if (cin_is_cpp_namespace(l)) amount += curbuf->b_ind_cpp_namespace; else if (cin_is_cpp_extern_c(l)) amount += curbuf->b_ind_cpp_extern_c; } else { // Compensate for adding b_ind_open_extra later. amount -= curbuf->b_ind_open_extra; if (amount < 0) amount = 0; } } lookfor_break = FALSE; if (cin_iscase(theline, FALSE)) // it's a switch() label { lookfor = LOOKFOR_CASE; // find a previous switch() label amount += curbuf->b_ind_case; } else if (cin_isscopedecl(theline)) // private:, ... { lookfor = LOOKFOR_SCOPEDECL; // class decl is this block amount += curbuf->b_ind_scopedecl; } else { if (curbuf->b_ind_case_break && cin_isbreak(theline)) // break; ... lookfor_break = TRUE; lookfor = LOOKFOR_INITIAL; // b_ind_level from start of block amount += curbuf->b_ind_level; } scope_amount = amount; whilelevel = 0; // Search backwards. If we find something we recognize, line up // with that. // // If we're looking at an open brace, indent // the usual amount relative to the conditional // that opens the block. curwin->w_cursor = cur_curpos; for (;;) { curwin->w_cursor.lnum--; curwin->w_cursor.col = 0; // If we went all the way back to the start of our scope, line // up with it. if (curwin->w_cursor.lnum <= ourscope) { // We reached end of scope: // If looking for an enum or structure initialization // go further back: // If it is an initializer (enum xxx or xxx =), then // don't add ind_continuation, otherwise it is a variable // declaration: // int x, // here; <-- add ind_continuation if (lookfor == LOOKFOR_ENUM_OR_INIT) { if (curwin->w_cursor.lnum == 0 || curwin->w_cursor.lnum < ourscope - curbuf->b_ind_maxparen) { // nothing found (abuse curbuf->b_ind_maxparen as // limit) assume terminated line (i.e. a variable // initialization) if (cont_amount > 0) amount = cont_amount; else if (!curbuf->b_ind_js) amount += ind_continuation; break; } l = ml_get_curline(); // If we're in a comment or raw string now, skip to // the start of it. trypos = ind_find_start_CORS(NULL); if (trypos != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; continue; } // Skip preprocessor directives and blank lines. if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)) continue; if (cin_nocode(l)) continue; terminated = cin_isterminated(l, FALSE, TRUE); // If we are at top level and the line looks like a // function declaration, we are done // (it's a variable declaration). if (start_brace != BRACE_IN_COL0 || !cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0)) { // if the line is terminated with another ',' // it is a continued variable initialization. // don't add extra indent. // TODO: does not work, if a function // declaration is split over multiple lines: // cin_isfuncdecl returns FALSE then. if (terminated == ',') break; // if it is an enum declaration or an assignment, // we are done. if (terminated != ';' && cin_isinit()) break; // nothing useful found if (terminated == 0 || terminated == '{') continue; } if (terminated != ';') { // Skip parens and braces. Position the cursor // over the rightmost paren, so that matching it // will take us back to the start of the line. // XXX trypos = NULL; if (find_last_paren(l, '(', ')')) trypos = find_match_paren( curbuf->b_ind_maxparen); if (trypos == NULL && find_last_paren(l, '{', '}')) trypos = find_start_brace(); if (trypos != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; continue; } } // it's a variable declaration, add indentation // like in // int a, // b; if (cont_amount > 0) amount = cont_amount; else amount += ind_continuation; } else if (lookfor == LOOKFOR_UNTERM) { if (cont_amount > 0) amount = cont_amount; else amount += ind_continuation; } else { if (lookfor != LOOKFOR_TERM && lookfor != LOOKFOR_CPP_BASECLASS && lookfor != LOOKFOR_COMMA) { amount = scope_amount; if (theline[0] == '{') { amount += curbuf->b_ind_open_extra; added_to_amount = curbuf->b_ind_open_extra; } } if (lookfor_cpp_namespace) { // Looking for C++ namespace, need to look further // back. if (curwin->w_cursor.lnum == ourscope) continue; if (curwin->w_cursor.lnum == 0 || curwin->w_cursor.lnum < ourscope - FIND_NAMESPACE_LIM) break; l = ml_get_curline(); // If we're in a comment or raw string now, skip // to the start of it. trypos = ind_find_start_CORS(NULL); if (trypos != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; continue; } // Skip preprocessor directives and blank lines. if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)) continue; // Finally the actual check for "namespace". if (cin_is_cpp_namespace(l)) { amount += curbuf->b_ind_cpp_namespace - added_to_amount; break; } else if (cin_is_cpp_extern_c(l)) { amount += curbuf->b_ind_cpp_extern_c - added_to_amount; break; } if (cin_nocode(l)) continue; } } break; } // If we're in a comment or raw string now, skip to the start // of it. XXX if ((trypos = ind_find_start_CORS(&raw_string_start)) != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; continue; } l = ml_get_curline(); // If this is a switch() label, may line up relative to that. // If this is a C++ scope declaration, do the same. iscase = cin_iscase(l, FALSE); if (iscase || cin_isscopedecl(l)) { // we are only looking for cpp base class // declaration/initialization any longer if (lookfor == LOOKFOR_CPP_BASECLASS) break; // When looking for a "do" we are not interested in // labels. if (whilelevel > 0) continue; // case xx: // c = 99 + <- this indent plus continuation //-> here; if (lookfor == LOOKFOR_UNTERM || lookfor == LOOKFOR_ENUM_OR_INIT) { if (cont_amount > 0) amount = cont_amount; else amount += ind_continuation; break; } // case xx: <- line up with this case // x = 333; // case yy: if ( (iscase && lookfor == LOOKFOR_CASE) || (iscase && lookfor_break) || (!iscase && lookfor == LOOKFOR_SCOPEDECL)) { // Check that this case label is not for another // switch() XXX if ((trypos = find_start_brace()) == NULL || trypos->lnum == ourscope) { amount = get_indent(); // XXX break; } continue; } n = get_indent_nolabel(curwin->w_cursor.lnum); // XXX // case xx: if (cond) <- line up with this if // y = y + 1; // -> s = 99; // // case xx: // if (cond) <- line up with this line // y = y + 1; // -> s = 99; if (lookfor == LOOKFOR_TERM) { if (n) amount = n; if (!lookfor_break) break; } // case xx: x = x + 1; <- line up with this x // -> y = y + 1; // // case xx: if (cond) <- line up with this if // -> y = y + 1; if (n) { amount = n; l = after_label(ml_get_curline()); if (l != NULL && cin_is_cinword(l)) { if (theline[0] == '{') amount += curbuf->b_ind_open_extra; else amount += curbuf->b_ind_level + curbuf->b_ind_no_brace; } break; } // Try to get the indent of a statement before the switch // label. If nothing is found, line up relative to the // switch label. // break; <- may line up with this line // case xx: // -> y = 1; scope_amount = get_indent() + (iscase // XXX ? curbuf->b_ind_case_code : curbuf->b_ind_scopedecl_code); lookfor = curbuf->b_ind_case_break ? LOOKFOR_NOBREAK : LOOKFOR_ANY; continue; } // Looking for a switch() label or C++ scope declaration, // ignore other lines, skip {}-blocks. if (lookfor == LOOKFOR_CASE || lookfor == LOOKFOR_SCOPEDECL) { if (find_last_paren(l, '{', '}') && (trypos = find_start_brace()) != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; } continue; } // Ignore jump labels with nothing after them. if (!curbuf->b_ind_js && cin_islabel()) { l = after_label(ml_get_curline()); if (l == NULL || cin_nocode(l)) continue; } // Ignore #defines, #if, etc. // Ignore comment and empty lines. // (need to get the line again, cin_islabel() may have // unlocked it) l = ml_get_curline(); if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount) || cin_nocode(l)) continue; // Are we at the start of a cpp base class declaration or // constructor initialization? XXX n = FALSE; if (lookfor != LOOKFOR_TERM && curbuf->b_ind_cpp_baseclass > 0) { n = cin_is_cpp_baseclass(&cache_cpp_baseclass); l = ml_get_curline(); } if (n) { if (lookfor == LOOKFOR_UNTERM) { if (cont_amount > 0) amount = cont_amount; else amount += ind_continuation; } else if (theline[0] == '{') { // Need to find start of the declaration. lookfor = LOOKFOR_UNTERM; ind_continuation = 0; continue; } else // XXX amount = get_baseclass_amount( cache_cpp_baseclass.lpos.col); break; } else if (lookfor == LOOKFOR_CPP_BASECLASS) { // only look, whether there is a cpp base class // declaration or initialization before the opening brace. if (cin_isterminated(l, TRUE, FALSE)) break; else continue; } // What happens next depends on the line being terminated. // If terminated with a ',' only consider it terminating if // there is another unterminated statement behind, eg: // 123, // sizeof // here // Otherwise check whether it is an enumeration or structure // initialisation (not indented) or a variable declaration // (indented). terminated = cin_isterminated(l, FALSE, TRUE); if (js_cur_has_key) { js_cur_has_key = 0; // only check the first line if (curbuf->b_ind_js && terminated == ',') { // For Javascript we might be inside an object: // key: something, <- align with this // key: something // or: // key: something + <- align with this // something, // key: something lookfor = LOOKFOR_JS_KEY; } } if (lookfor == LOOKFOR_JS_KEY && cin_has_js_key(l)) { amount = get_indent(); break; } if (lookfor == LOOKFOR_COMMA) { if (tryposBrace != NULL && tryposBrace->lnum >= curwin->w_cursor.lnum) break; if (terminated == ',') // line below current line is the one that starts a // (possibly broken) line ending in a comma. break; else { amount = get_indent(); if (curwin->w_cursor.lnum - 1 == ourscope) // line above is start of the scope, thus current // line is the one that stars a (possibly broken) // line ending in a comma. break; } } if (terminated == 0 || (lookfor != LOOKFOR_UNTERM && terminated == ',')) { if (lookfor != LOOKFOR_ENUM_OR_INIT && (*skipwhite(l) == '[' || l[STRLEN(l) - 1] == '[')) amount += ind_continuation; // if we're in the middle of a paren thing, // go back to the line that starts it so // we can get the right prevailing indent // if ( foo && // bar ) // Position the cursor over the rightmost paren, so that // matching it will take us back to the start of the line. // Ignore a match before the start of the block. (void)find_last_paren(l, '(', ')'); trypos = find_match_paren(corr_ind_maxparen(&cur_curpos)); if (trypos != NULL && (trypos->lnum < tryposBrace->lnum || (trypos->lnum == tryposBrace->lnum && trypos->col < tryposBrace->col))) trypos = NULL; // If we are looking for ',', we also look for matching // braces. if (trypos == NULL && terminated == ',' && find_last_paren(l, '{', '}')) trypos = find_start_brace(); if (trypos != NULL) { // Check if we are on a case label now. This is // handled above. // case xx: if ( asdf && // asdf) curwin->w_cursor = *trypos; l = ml_get_curline(); if (cin_iscase(l, FALSE) || cin_isscopedecl(l)) { ++curwin->w_cursor.lnum; curwin->w_cursor.col = 0; continue; } } // Skip over continuation lines to find the one to get the // indent from // char *usethis = "bla{backslash} // bla", // here; if (terminated == ',') { while (curwin->w_cursor.lnum > 1) { l = ml_get(curwin->w_cursor.lnum - 1); if (*l == NUL || l[STRLEN(l) - 1] != '\\') break; --curwin->w_cursor.lnum; curwin->w_cursor.col = 0; } } // Get indent and pointer to text for current line, // ignoring any jump label. XXX if (curbuf->b_ind_js) cur_amount = get_indent(); else cur_amount = skip_label(curwin->w_cursor.lnum, &l); // If this is just above the line we are indenting, and it // starts with a '{', line it up with this line. // while (not) // -> { // } if (terminated != ',' && lookfor != LOOKFOR_TERM && theline[0] == '{') { amount = cur_amount; // Only add b_ind_open_extra when the current line // doesn't start with a '{', which must have a match // in the same line (scope is the same). Probably: // { 1, 2 }, // -> { 3, 4 } if (*skipwhite(l) != '{') amount += curbuf->b_ind_open_extra; if (curbuf->b_ind_cpp_baseclass && !curbuf->b_ind_js) { // have to look back, whether it is a cpp base // class declaration or initialization lookfor = LOOKFOR_CPP_BASECLASS; continue; } break; } // Check if we are after an "if", "while", etc. // Also allow " } else". if (cin_is_cinword(l) || cin_iselse(skipwhite(l))) { // Found an unterminated line after an if (), line up // with the last one. // if (cond) // 100 + // -> here; if (lookfor == LOOKFOR_UNTERM || lookfor == LOOKFOR_ENUM_OR_INIT) { if (cont_amount > 0) amount = cont_amount; else amount += ind_continuation; break; } // If this is just above the line we are indenting, we // are finished. // while (not) // -> here; // Otherwise this indent can be used when the line // before this is terminated. // yyy; // if (stat) // while (not) // xxx; // -> here; amount = cur_amount; if (theline[0] == '{') amount += curbuf->b_ind_open_extra; if (lookfor != LOOKFOR_TERM) { amount += curbuf->b_ind_level + curbuf->b_ind_no_brace; break; } // Special trick: when expecting the while () after a // do, line up with the while() // do // x = 1; // -> here l = skipwhite(ml_get_curline()); if (cin_isdo(l)) { if (whilelevel == 0) break; --whilelevel; } // When searching for a terminated line, don't use the // one between the "if" and the matching "else". // Need to use the scope of this "else". XXX // If whilelevel != 0 continue looking for a "do {". if (cin_iselse(l) && whilelevel == 0) { // If we're looking at "} else", let's make sure we // find the opening brace of the enclosing scope, // not the one from "if () {". if (*l == '}') curwin->w_cursor.col = (colnr_T)(l - ml_get_curline()) + 1; if ((trypos = find_start_brace()) == NULL || find_match(LOOKFOR_IF, trypos->lnum) == FAIL) break; } } // If we're below an unterminated line that is not an // "if" or something, we may line up with this line or // add something for a continuation line, depending on // the line before this one. else { // Found two unterminated lines on a row, line up with // the last one. // c = 99 + // 100 + // -> here; if (lookfor == LOOKFOR_UNTERM) { // When line ends in a comma add extra indent if (terminated == ',') amount += ind_continuation; break; } if (lookfor == LOOKFOR_ENUM_OR_INIT) { // Found two lines ending in ',', lineup with the // lowest one, but check for cpp base class // declaration/initialization, if it is an // opening brace or we are looking just for // enumerations/initializations. if (terminated == ',') { if (curbuf->b_ind_cpp_baseclass == 0) break; lookfor = LOOKFOR_CPP_BASECLASS; continue; } // Ignore unterminated lines in between, but // reduce indent. if (amount > cur_amount) amount = cur_amount; } else { // Found first unterminated line on a row, may // line up with this line, remember its indent // 100 + // -> here; l = ml_get_curline(); amount = cur_amount; n = (int)STRLEN(l); if (terminated == ',' && (*skipwhite(l) == ']' || (n >=2 && l[n - 2] == ']'))) break; // If previous line ends in ',', check whether we // are in an initialization or enum // struct xxx = // { // sizeof a, // 124 }; // or a normal possible continuation line. // but only, of no other statement has been found // yet. if (lookfor == LOOKFOR_INITIAL && terminated == ',') { if (curbuf->b_ind_js) { // Search for a line ending in a comma // and line up with the line below it // (could be the current line). // some = [ // 1, <- line up here // 2, // some = [ // 3 + <- line up here // 4 * // 5, // 6, if (cin_iscomment(skipwhite(l))) break; lookfor = LOOKFOR_COMMA; trypos = find_match_char('[', curbuf->b_ind_maxparen); if (trypos != NULL) { if (trypos->lnum == curwin->w_cursor.lnum - 1) { // Current line is first inside // [], line up with it. break; } ourscope = trypos->lnum; } } else { lookfor = LOOKFOR_ENUM_OR_INIT; cont_amount = cin_first_id_amount(); } } else { if (lookfor == LOOKFOR_INITIAL && *l != NUL && l[STRLEN(l) - 1] == '\\') // XXX cont_amount = cin_get_equal_amount( curwin->w_cursor.lnum); if (lookfor != LOOKFOR_TERM && lookfor != LOOKFOR_JS_KEY && lookfor != LOOKFOR_COMMA && raw_string_start != curwin->w_cursor.lnum) lookfor = LOOKFOR_UNTERM; } } } } // Check if we are after a while (cond); // If so: Ignore until the matching "do". else if (cin_iswhileofdo_end(terminated)) // XXX { // Found an unterminated line after a while ();, line up // with the last one. // while (cond); // 100 + <- line up with this one // -> here; if (lookfor == LOOKFOR_UNTERM || lookfor == LOOKFOR_ENUM_OR_INIT) { if (cont_amount > 0) amount = cont_amount; else amount += ind_continuation; break; } if (whilelevel == 0) { lookfor = LOOKFOR_TERM; amount = get_indent(); // XXX if (theline[0] == '{') amount += curbuf->b_ind_open_extra; } ++whilelevel; } // We are after a "normal" statement. // If we had another statement we can stop now and use the // indent of that other statement. // Otherwise the indent of the current statement may be used, // search backwards for the next "normal" statement. else { // Skip single break line, if before a switch label. It // may be lined up with the case label. if (lookfor == LOOKFOR_NOBREAK && cin_isbreak(skipwhite(ml_get_curline()))) { lookfor = LOOKFOR_ANY; continue; } // Handle "do {" line. if (whilelevel > 0) { l = cin_skipcomment(ml_get_curline()); if (cin_isdo(l)) { amount = get_indent(); // XXX --whilelevel; continue; } } // Found a terminated line above an unterminated line. Add // the amount for a continuation line. // x = 1; // y = foo + // -> here; // or // int x = 1; // int foo, // -> here; if (lookfor == LOOKFOR_UNTERM || lookfor == LOOKFOR_ENUM_OR_INIT) { if (cont_amount > 0) amount = cont_amount; else amount += ind_continuation; break; } // Found a terminated line above a terminated line or "if" // etc. line. Use the amount of the line below us. // x = 1; x = 1; // if (asdf) y = 2; // while (asdf) ->here; // here; // ->foo; if (lookfor == LOOKFOR_TERM) { if (!lookfor_break && whilelevel == 0) break; } // First line above the one we're indenting is terminated. // To know what needs to be done look further backward for // a terminated line. else { // position the cursor over the rightmost paren, so // that matching it will take us back to the start of // the line. Helps for: // func(asdr, // asdfasdf); // here; term_again: l = ml_get_curline(); if (find_last_paren(l, '(', ')') && (trypos = find_match_paren( curbuf->b_ind_maxparen)) != NULL) { // Check if we are on a case label now. This is // handled above. // case xx: if ( asdf && // asdf) curwin->w_cursor = *trypos; l = ml_get_curline(); if (cin_iscase(l, FALSE) || cin_isscopedecl(l)) { ++curwin->w_cursor.lnum; curwin->w_cursor.col = 0; continue; } } // When aligning with the case statement, don't align // with a statement after it. // case 1: { <-- don't use this { position // stat; // } // case 2: // stat; // } iscase = (curbuf->b_ind_keep_case_label && cin_iscase(l, FALSE)); // Get indent and pointer to text for current line, // ignoring any jump label. amount = skip_label(curwin->w_cursor.lnum, &l); if (theline[0] == '{') amount += curbuf->b_ind_open_extra; // See remark above: "Only add b_ind_open_extra.." l = skipwhite(l); if (*l == '{') amount -= curbuf->b_ind_open_extra; lookfor = iscase ? LOOKFOR_ANY : LOOKFOR_TERM; // When a terminated line starts with "else" skip to // the matching "if": // else 3; // indent this; // Need to use the scope of this "else". XXX // If whilelevel != 0 continue looking for a "do {". if (lookfor == LOOKFOR_TERM && *l != '}' && cin_iselse(l) && whilelevel == 0) { if ((trypos = find_start_brace()) == NULL || find_match(LOOKFOR_IF, trypos->lnum) == FAIL) break; continue; } // If we're at the end of a block, skip to the start of // that block. l = ml_get_curline(); if (find_last_paren(l, '{', '}') // XXX && (trypos = find_start_brace()) != NULL) { curwin->w_cursor = *trypos; // if not "else {" check for terminated again // but skip block for "} else {" l = cin_skipcomment(ml_get_curline()); if (*l == '}' || !cin_iselse(l)) goto term_again; ++curwin->w_cursor.lnum; curwin->w_cursor.col = 0; } } } } } } // add extra indent for a comment if (cin_iscomment(theline)) amount += curbuf->b_ind_comment; // subtract extra left-shift for jump labels if (curbuf->b_ind_jump_label > 0 && original_line_islabel) amount -= curbuf->b_ind_jump_label; goto theend; } // ok -- we're not inside any sort of structure at all! // // This means we're at the top level, and everything should // basically just match where the previous line is, except // for the lines immediately following a function declaration, // which are K&R-style parameters and need to be indented. // // if our line starts with an open brace, forget about any // prevailing indent and make sure it looks like the start // of a function if (theline[0] == '{') { amount = curbuf->b_ind_first_open; goto theend; } // If the NEXT line is a function declaration, the current // line needs to be indented as a function type spec. // Don't do this if the current line looks like a comment or if the // current line is terminated, ie. ends in ';', or if the current line // contains { or }: "void f() {\n if (1)" if (cur_curpos.lnum < curbuf->b_ml.ml_line_count && !cin_nocode(theline) && vim_strchr(theline, '{') == NULL && vim_strchr(theline, '}') == NULL && !cin_ends_in(theline, (char_u *)":", NULL) && !cin_ends_in(theline, (char_u *)",", NULL) && cin_isfuncdecl(NULL, cur_curpos.lnum + 1, cur_curpos.lnum + 1) && !cin_isterminated(theline, FALSE, TRUE)) { amount = curbuf->b_ind_func_type; goto theend; } // search backwards until we find something we recognize amount = 0; curwin->w_cursor = cur_curpos; while (curwin->w_cursor.lnum > 1) { curwin->w_cursor.lnum--; curwin->w_cursor.col = 0; l = ml_get_curline(); // If we're in a comment or raw string now, skip to the start // of it. XXX if ((trypos = ind_find_start_CORS(NULL)) != NULL) { curwin->w_cursor.lnum = trypos->lnum + 1; curwin->w_cursor.col = 0; continue; } // Are we at the start of a cpp base class declaration or // constructor initialization? XXX n = FALSE; if (curbuf->b_ind_cpp_baseclass != 0 && theline[0] != '{') { n = cin_is_cpp_baseclass(&cache_cpp_baseclass); l = ml_get_curline(); } if (n) { // XXX amount = get_baseclass_amount(cache_cpp_baseclass.lpos.col); break; } // Skip preprocessor directives and blank lines. if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)) continue; if (cin_nocode(l)) continue; // If the previous line ends in ',', use one level of // indentation: // int foo, // bar; // do this before checking for '}' in case of eg. // enum foobar // { // ... // } foo, // bar; n = 0; if (cin_ends_in(l, (char_u *)",", NULL) || (*l != NUL && (n = l[STRLEN(l) - 1]) == '\\')) { // take us back to opening paren if (find_last_paren(l, '(', ')') && (trypos = find_match_paren( curbuf->b_ind_maxparen)) != NULL) curwin->w_cursor = *trypos; // For a line ending in ',' that is a continuation line go // back to the first line with a backslash: // char *foo = "bla{backslash} // bla", // here; while (n == 0 && curwin->w_cursor.lnum > 1) { l = ml_get(curwin->w_cursor.lnum - 1); if (*l == NUL || l[STRLEN(l) - 1] != '\\') break; --curwin->w_cursor.lnum; curwin->w_cursor.col = 0; } amount = get_indent(); // XXX if (amount == 0) amount = cin_first_id_amount(); if (amount == 0) amount = ind_continuation; break; } // If the line looks like a function declaration, and we're // not in a comment, put it the left margin. if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) // XXX break; l = ml_get_curline(); // Finding the closing '}' of a previous function. Put // current line at the left margin. For when 'cino' has "fs". if (*skipwhite(l) == '}') break; // (matching {) // If the previous line ends on '};' (maybe followed by // comments) align at column 0. For example: // char *string_array[] = { "foo", // / * x * / "b};ar" }; / * foobar * / if (cin_ends_in(l, (char_u *)"};", NULL)) break; // If the previous line ends on '[' we are probably in an // array constant: // something = [ // 234, <- extra indent if (cin_ends_in(l, (char_u *)"[", NULL)) { amount = get_indent() + ind_continuation; break; } // Find a line only has a semicolon that belongs to a previous // line ending in '}', e.g. before an #endif. Don't increase // indent then. if (*(look = skipwhite(l)) == ';' && cin_nocode(look + 1)) { pos_T curpos_save = curwin->w_cursor; while (curwin->w_cursor.lnum > 1) { look = ml_get(--curwin->w_cursor.lnum); if (!(cin_nocode(look) || cin_ispreproc_cont( &look, &curwin->w_cursor.lnum, &amount))) break; } if (curwin->w_cursor.lnum > 0 && cin_ends_in(look, (char_u *)"}", NULL)) break; curwin->w_cursor = curpos_save; } // If the PREVIOUS line is a function declaration, the current // line (and the ones that follow) needs to be indented as // parameters. if (cin_isfuncdecl(&l, curwin->w_cursor.lnum, 0)) { amount = curbuf->b_ind_param; break; } // If the previous line ends in ';' and the line before the // previous line ends in ',' or '\', ident to column zero: // int foo, // bar; // indent_to_0 here; if (cin_ends_in(l, (char_u *)";", NULL)) { l = ml_get(curwin->w_cursor.lnum - 1); if (cin_ends_in(l, (char_u *)",", NULL) || (*l != NUL && l[STRLEN(l) - 1] == '\\')) break; l = ml_get_curline(); } // Doesn't look like anything interesting -- so just // use the indent of this line. // // Position the cursor over the rightmost paren, so that // matching it will take us back to the start of the line. find_last_paren(l, '(', ')'); if ((trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) curwin->w_cursor = *trypos; amount = get_indent(); // XXX break; } // add extra indent for a comment if (cin_iscomment(theline)) amount += curbuf->b_ind_comment; // add extra indent if the previous line ended in a backslash: // "asdfasdf{backslash} // here"; // char *foo = "asdf{backslash} // here"; if (cur_curpos.lnum > 1) { l = ml_get(cur_curpos.lnum - 1); if (*l != NUL && l[STRLEN(l) - 1] == '\\') { cur_amount = cin_get_equal_amount(cur_curpos.lnum - 1); if (cur_amount > 0) amount = cur_amount; else if (cur_amount == 0) amount += ind_continuation; } } theend: if (amount < 0) amount = 0; laterend: // put the cursor back where it belongs curwin->w_cursor = cur_curpos; vim_free(linecopy); return amount; }
0
317,295
static void selinux_sock_graft(struct sock *sk, struct socket *parent) { struct inode_security_struct *isec = inode_security_novalidate(SOCK_INODE(parent)); struct sk_security_struct *sksec = sk->sk_security; if (sk->sk_family == PF_INET || sk->sk_family == PF_INET6 || sk->sk_family == PF_UNIX) isec->sid = sksec->sid; sksec->sclass = isec->sclass; }
0
223,422
static SLJIT_INLINE unsigned int char_othercase(compiler_common *common, unsigned int c) { /* Returns with the othercase. */ #ifdef SUPPORT_UNICODE if ((common->utf || common->ucp) && c > 127) return UCD_OTHERCASE(c); #endif return TABLE_GET(c, common->fcc, c); }
0
453,040
static void nft_fwd_neigh_eval(const struct nft_expr *expr, struct nft_regs *regs, const struct nft_pktinfo *pkt) { struct nft_fwd_neigh *priv = nft_expr_priv(expr); void *addr = &regs->data[priv->sreg_addr]; int oif = regs->data[priv->sreg_dev]; unsigned int verdict = NF_STOLEN; struct sk_buff *skb = pkt->skb; struct net_device *dev; int neigh_table; switch (priv->nfproto) { case NFPROTO_IPV4: { struct iphdr *iph; if (skb->protocol != htons(ETH_P_IP)) { verdict = NFT_BREAK; goto out; } if (skb_try_make_writable(skb, sizeof(*iph))) { verdict = NF_DROP; goto out; } iph = ip_hdr(skb); ip_decrease_ttl(iph); neigh_table = NEIGH_ARP_TABLE; break; } case NFPROTO_IPV6: { struct ipv6hdr *ip6h; if (skb->protocol != htons(ETH_P_IPV6)) { verdict = NFT_BREAK; goto out; } if (skb_try_make_writable(skb, sizeof(*ip6h))) { verdict = NF_DROP; goto out; } ip6h = ipv6_hdr(skb); ip6h->hop_limit--; neigh_table = NEIGH_ND_TABLE; break; } default: verdict = NFT_BREAK; goto out; } dev = dev_get_by_index_rcu(nft_net(pkt), oif); if (dev == NULL) return; skb->dev = dev; skb->tstamp = 0; neigh_xmit(neigh_table, dev, addr, skb); out: regs->verdict.code = verdict; }
0
359,301
DEFUN (clear_ip_bgp_instance_all_ipv4_in_prefix_filter, clear_ip_bgp_instance_all_ipv4_in_prefix_filter_cmd, "clear ip bgp view WORD * ipv4 (unicast|multicast) in prefix-filter", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Address family\n" "Address Family modifier\n" "Address Family modifier\n" "Soft reconfig inbound update\n" "Push out prefix-list ORF and do inbound soft reconfig\n") { if (strncmp (argv[1], "m", 1) == 0) return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, clear_all, BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all, BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); }
0
384,286
gs_heap_resize_string(gs_memory_t * mem, byte * data, uint old_num, uint new_num, client_name_t cname) { if (gs_heap_object_type(mem, data) != &st_bytes) lprintf2("%s: resizing non-string 0x%lx!\n", client_name_string(cname), (ulong) data); return gs_heap_resize_object(mem, data, new_num, cname); }
0
238,314
static void dummy_free(struct digest *d) {}
0
240,271
shift_delete_registers() { int n; y_current = &y_regs[9]; free_yank_all(); // free register nine for (n = 9; n > 1; --n) y_regs[n] = y_regs[n - 1]; y_current = &y_regs[1]; if (!y_append) y_previous = y_current; y_regs[1].y_array = NULL; // set register one to empty }
0
508,895
LEX::LEX() : explain(NULL), result(0), arena_for_set_stmt(0), mem_root_for_set_stmt(0), option_type(OPT_DEFAULT), context_analysis_only(0), sphead(0), is_lex_started(0), limit_rows_examined_cnt(ULONGLONG_MAX) { init_dynamic_array2(&plugins, sizeof(plugin_ref), plugins_static_buffer, INITIAL_LEX_PLUGIN_LIST_SIZE, INITIAL_LEX_PLUGIN_LIST_SIZE, 0); reset_query_tables_list(TRUE); mi.init(); init_dynamic_array2(&delete_gtid_domain, sizeof(uint32), gtid_domain_static_buffer, initial_gtid_domain_buffer_size, initial_gtid_domain_buffer_size, 0); }
0
312,507
qf_view_result(int split) { qf_info_T *qi = &ql_info; if (IS_LL_WINDOW(curwin)) qi = GET_LOC_LIST(curwin); if (qf_list_empty(qf_get_curlist(qi))) { emsg(_(e_no_errors)); return; } if (split) { // Open the selected entry in a new window qf_jump_newwin(qi, 0, (long)curwin->w_cursor.lnum, FALSE, TRUE); do_cmdline_cmd((char_u *) "clearjumps"); return; } do_cmdline_cmd((char_u *)(IS_LL_WINDOW(curwin) ? ".ll" : ".cc")); }
0
247,125
void gf_fs_print_stats(GF_FilterSession *fsess) { u64 run_time=0, active_time=0, nb_tasks=0, nb_filters=0; u32 i, count; GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\n")); gf_mx_p(fsess->filters_mx); count=gf_list_count(fsess->filters); for (i=0; i<count; i++) { GF_Filter *f = gf_list_get(fsess->filters, i); if (f->multi_sink_target) continue; nb_filters++; } GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("Filter stats - %d filters\n", nb_filters)); for (i=0; i<count; i++) { u32 k, ipids, opids; GF_Filter *f = gf_list_get(fsess->filters, i); if (f->multi_sink_target) continue; gf_mx_p(f->tasks_mx); ipids = f->num_input_pids; opids = f->num_output_pids; GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\tFilter ")); print_filter_name(f, GF_FALSE, GF_FALSE); GF_LOG(GF_LOG_INFO, GF_LOG_APP, (" : %d input pids %d output pids "LLU" tasks "LLU" us process time\n", ipids, opids, f->nb_tasks_done, f->time_process)); if (ipids) { GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\t\t"LLU" packets processed "LLU" bytes processed", f->nb_pck_processed, f->nb_bytes_processed)); if (f->time_process) { GF_LOG(GF_LOG_INFO, GF_LOG_APP, (" (%g pck/sec %g mbps)", (Double) f->nb_pck_processed*1000000/f->time_process, (Double) f->nb_bytes_processed*8/f->time_process)); } GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\n")); } if (opids) { if (f->nb_hw_pck_sent) { GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\t\t"LLU" hardware frames sent", f->nb_hw_pck_sent)); if (f->time_process) { GF_LOG(GF_LOG_INFO, GF_LOG_APP, (" (%g pck/sec)", (Double) f->nb_hw_pck_sent*1000000/f->time_process)); } } else if (f->nb_pck_sent) { GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\t\t"LLU" packets sent "LLU" bytes sent", f->nb_pck_sent, f->nb_bytes_sent)); if (f->time_process) { GF_LOG(GF_LOG_INFO, GF_LOG_APP, (" (%g pck/sec %g mbps)", (Double) f->nb_pck_sent*1000000/f->time_process, (Double) f->nb_bytes_sent*8/f->time_process)); } } GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\n")); } for (k=0; k<ipids; k++) { GF_FilterPidInst *pid = gf_list_get(f->input_pids, k); if (!pid->pid) continue; if (pid->requires_full_data_block && (pid->nb_reagg_pck != pid->pid->nb_pck_sent) ) { GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\t\t* input PID %s: %d frames (%d packets) received\n", pid->pid->name, pid->nb_reagg_pck, pid->pid->nb_pck_sent)); } else { GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\t\t* input PID %s: %d packets received\n", pid->pid->name, pid->pid->nb_pck_sent)); } } #ifndef GPAC_DISABLE_LOG for (k=0; k<opids; k++) { GF_FilterPid *pid = gf_list_get(f->output_pids, k); GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\t\t* output PID %s: %d packets sent\n", pid->name, pid->nb_pck_sent)); } if (f->nb_errors) { GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\t\t%d errors while processing\n", f->nb_errors)); } #endif gf_mx_v(f->tasks_mx); } gf_mx_v(fsess->filters_mx); count=gf_list_count(fsess->threads); GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("Session stats - threads %d\n", 1+count)); GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\tThread %u: run_time "LLU" us active_time "LLU" us nb_tasks "LLU"\n", 1, fsess->main_th.run_time, fsess->main_th.active_time, fsess->main_th.nb_tasks)); run_time+=fsess->main_th.run_time; active_time+=fsess->main_th.active_time; nb_tasks+=fsess->main_th.nb_tasks; for (i=0; i<count; i++) { GF_SessionThread *s = gf_list_get(fsess->threads, i); GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\tThread %u: run_time "LLU" us active_time "LLU" us nb_tasks "LLU"\n", i+2, s->run_time, s->active_time, s->nb_tasks)); run_time+=s->run_time; active_time+=s->active_time; nb_tasks+=s->nb_tasks; } GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\nTotal: run_time "LLU" us active_time "LLU" us nb_tasks "LLU"\n", run_time, active_time, nb_tasks)); }
0
202,304
find_match_text(colnr_T startcol, int regstart, char_u *match_text) { colnr_T col = startcol; int c1, c2; int len1, len2; int match; for (;;) { match = TRUE; len2 = MB_CHAR2LEN(regstart); // skip regstart for (len1 = 0; match_text[len1] != NUL; len1 += MB_CHAR2LEN(c1)) { c1 = PTR2CHAR(match_text + len1); c2 = PTR2CHAR(rex.line + col + len2); if (c1 != c2 && (!rex.reg_ic || MB_CASEFOLD(c1) != MB_CASEFOLD(c2))) { match = FALSE; break; } len2 += MB_CHAR2LEN(c2); } if (match // check that no composing char follows && !(enc_utf8 && utf_iscomposing(PTR2CHAR(rex.line + col + len2)))) { cleanup_subexpr(); if (REG_MULTI) { rex.reg_startpos[0].lnum = rex.lnum; rex.reg_startpos[0].col = col; rex.reg_endpos[0].lnum = rex.lnum; rex.reg_endpos[0].col = col + len2; } else { rex.reg_startp[0] = rex.line + col; rex.reg_endp[0] = rex.line + col + len2; } return 1L; } // Try finding regstart after the current match. col += MB_CHAR2LEN(regstart); // skip regstart if (skip_to_start(regstart, &col) == FAIL) break; } return 0L; }
1
437,297
compile_length_quantifier_node(QuantNode* qn, regex_t* reg) { int len, mod_tlen; int infinite = IS_REPEAT_INFINITE(qn->upper); enum QuantBodyEmpty empty_info = qn->body_empty_info; int tlen = compile_length_tree(NODE_QUANT_BODY(qn), reg); if (tlen < 0) return tlen; if (tlen == 0) return 0; /* anychar repeat */ if (is_anychar_infinite_greedy(qn)) { if (qn->lower <= 1 || int_multiply_cmp(tlen, qn->lower, QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0) { if (IS_NOT_NULL(qn->next_head_exact)) return SIZE_OP_ANYCHAR_STAR_PEEK_NEXT + tlen * qn->lower; else return SIZE_OP_ANYCHAR_STAR + tlen * qn->lower; } } if (empty_info == QUANT_BODY_IS_NOT_EMPTY) mod_tlen = tlen; else mod_tlen = tlen + (SIZE_OP_EMPTY_CHECK_START + SIZE_OP_EMPTY_CHECK_END); if (infinite && (qn->lower <= 1 || int_multiply_cmp(tlen, qn->lower, QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0)) { if (qn->lower == 1 && tlen > QUANTIFIER_EXPAND_LIMIT_SIZE) { len = SIZE_OP_JUMP; } else { len = tlen * qn->lower; } if (qn->greedy) { if (IS_NOT_NULL(qn->head_exact)) len += SIZE_OP_PUSH_OR_JUMP_EXACT1 + mod_tlen + SIZE_OP_JUMP; else if (IS_NOT_NULL(qn->next_head_exact)) len += SIZE_OP_PUSH_IF_PEEK_NEXT + mod_tlen + SIZE_OP_JUMP; else len += SIZE_OP_PUSH + mod_tlen + SIZE_OP_JUMP; } else len += SIZE_OP_JUMP + mod_tlen + SIZE_OP_PUSH; } else if (qn->upper == 0 && qn->is_refered != 0) { /* /(?<n>..){0}/ */ len = SIZE_OP_JUMP + tlen; } else if (!infinite && qn->greedy && (qn->upper == 1 || int_multiply_cmp(tlen + SIZE_OP_PUSH, qn->upper, QUANTIFIER_EXPAND_LIMIT_SIZE) <= 0)) { len = tlen * qn->lower; len += (SIZE_OP_PUSH + tlen) * (qn->upper - qn->lower); } else if (!qn->greedy && qn->upper == 1 && qn->lower == 0) { /* '??' */ len = SIZE_OP_PUSH + SIZE_OP_JUMP + tlen; } else { len = SIZE_OP_REPEAT_INC + mod_tlen + SIZE_OPCODE + SIZE_RELADDR + SIZE_MEMNUM; } return len; }
0
274,728
callbacks_drawingarea_button_release_event (GtkWidget *widget, GdkEventButton *event) { gint index; if (event->type != GDK_BUTTON_RELEASE) return TRUE; switch (screen.state) { case IN_MOVE: screen.off_x = 0; screen.off_y = 0; render_refresh_rendered_image_on_screen (); callbacks_switch_to_normal_tool_cursor (screen.tool); break; case IN_ZOOM_OUTLINE: if ((event->state & GDK_SHIFT_MASK) != 0) { render_zoom_display (ZOOM_OUT_CMOUSE, 0, event->x, event->y); } /* if the user just clicks without dragging, then simply zoom in a preset amount */ else if ((abs(screen.start_x - event->x) < 4) && (abs(screen.start_y - event->y) < 4)) { render_zoom_display (ZOOM_IN_CMOUSE, 0, event->x, event->y); } else { render_calculate_zoom_from_outline (widget, event); } callbacks_switch_to_normal_tool_cursor (screen.tool); break; case IN_SELECTION_DRAG: /* selection will only work with cairo, so do nothing if it's not compiled */ index = callbacks_get_selected_row_index (); if ((index >= 0) && mainProject->file[index]->isVisible) { enum selection_action sel_action = SELECTION_REPLACE; if (event->state & GDK_SHIFT_MASK) sel_action = SELECTION_ADD; else if (event->state & GDK_CONTROL_MASK) sel_action = SELECTION_TOGGLE; /* determine if this was just a click or a box drag */ if ((fabs((double)(screen.last_x - screen.start_x)) < 5) && (fabs((double)(screen.last_y - screen.start_y)) < 5)) { render_fill_selection_buffer_from_mouse_click ( event->x, event->y, index, sel_action); } else { render_fill_selection_buffer_from_mouse_drag ( event->x, event->y, screen.start_x, screen.start_y, index, sel_action); } /* Check if anything was selected */ update_selected_object_message (TRUE); check_align_files_possibility (&screen.selectionInfo); } else { render_refresh_rendered_image_on_screen (); } break; default: break; } screen.state = NORMAL; return TRUE; } /* button_release_event */
0