idx
int64
func
string
target
int64
198,198
void DoCompute(OpKernelContext* c) { core::RefCountPtr<Var> v; OP_REQUIRES_OK(c, LookupResource(c, HandleFromInput(c, 0), &v)); Tensor* params = v->tensor(); const Tensor& indices = c->input(1); const Tensor& updates = c->input(2); // Check that rank(updates.shape) = rank(indices.shape + params.shape[1:]) OP_REQUIRES(c, updates.dims() == 0 || updates.dims() == indices.dims() + params->dims() - 1, errors::InvalidArgument( "Must have updates.shape = indices.shape + " "params.shape[1:] or updates.shape = [], got ", "updates.shape ", updates.shape().DebugString(), ", indices.shape ", indices.shape().DebugString(), ", params.shape ", params->shape().DebugString())); // Check that we have enough index space const int64_t N_big = indices.NumElements(); OP_REQUIRES( c, N_big <= std::numeric_limits<Index>::max(), errors::InvalidArgument("indices has too many elements for ", DataTypeString(DataTypeToEnum<Index>::v()), " indexing: ", N_big, " > ", std::numeric_limits<Index>::max())); const Index N = static_cast<Index>(N_big); OP_REQUIRES( c, params->dim_size(0) <= std::numeric_limits<Index>::max(), errors::InvalidArgument("params.shape[0] too large for ", DataTypeString(DataTypeToEnum<Index>::v()), " indexing: ", params->dim_size(0), " > ", std::numeric_limits<Index>::max())); if (N > 0) { auto indices_flat = indices.flat<Index>(); auto params_flat = params->flat_outer_dims<T>(); if (TensorShapeUtils::IsScalar(updates.shape())) { const auto update = updates.scalar<T>(); functor::ScatterScalarFunctor<Device, T, Index, op> functor; const Index bad_i = functor(c, c->template eigen_device<Device>(), params_flat, update, indices_flat); OP_REQUIRES(c, bad_i < 0, errors::InvalidArgument( "indices", SliceDebugString(indices.shape(), bad_i), " = ", indices_flat(bad_i), " is not in [0, ", params->dim_size(0), ")")); } else { int64_t num_updates = updates.NumElements(); OP_REQUIRES(c, num_updates % N == 0, errors::InvalidArgument( "shape of indices (", indices.shape().DebugString(), ") is not compatible with the shape of updates (", updates.shape().DebugString(), ")")); auto updates_flat = updates.shaped<T, 2>({N, num_updates / N}); functor::ScatterFunctor<Device, T, Index, op> functor; const Index bad_i = functor(c, c->template eigen_device<Device>(), params_flat, updates_flat, indices_flat); OP_REQUIRES(c, bad_i < 0, errors::InvalidArgument( "indices", SliceDebugString(indices.shape(), bad_i), " = ", indices_flat(bad_i), " is not in [0, ", params->dim_size(0), ")")); } } }
1
434,089
ex_previous(exarg_T *eap) { // If past the last one already, go to the last one. if (curwin->w_arg_idx - (int)eap->line2 >= ARGCOUNT) do_argfile(eap, ARGCOUNT - 1); else do_argfile(eap, curwin->w_arg_idx - (int)eap->line2); }
0
374,046
static SymbolsMetadata parseMetadata(RBuffer *buf, int off) { SymbolsMetadata sm = { 0 }; ut8 b[0x100] = { 0 }; (void)r_buf_read_at (buf, off, b, sizeof (b)); sm.addr = off; sm.cputype = r_read_le32 (b); sm.arch = typeString (sm.cputype, &sm.bits); // eprintf ("0x%08x cputype 0x%x -> %s\n", 0x40, sm.cputype, typeString (sm.cputype)); // bits = (strstr (typeString (sm.cputype, &sm.bits), "64"))? 64: 32; sm.subtype = r_read_le32 (b + 4); sm.cpu = subtypeString (sm.subtype); // eprintf ("0x%08x subtype 0x%x -> %s\n", 0x44, sm.subtype, subtypeString (sm.subtype)); sm.n_segments = r_read_le32 (b + 8); // int count = r_read_le32 (b + 0x48); sm.namelen = r_read_le32 (b + 0xc); // eprintf ("0x%08x count %d\n", 0x48, count); // eprintf ("0x%08x strlen %d\n", 0x4c, sm.namelen); // eprintf ("0x%08x filename %s\n", 0x50, b + 16); int delta = 16; //sm.segments = parseSegments (buf, off + sm.namelen + delta, sm.n_segments); sm.size = (sm.n_segments * 32) + sm.namelen + delta; // hack to detect format ut32 nm, nm2, nm3; r_buf_read_at (buf, off + sm.size, (ut8 *)&nm, sizeof (nm)); r_buf_read_at (buf, off + sm.size + 4, (ut8 *)&nm2, sizeof (nm2)); r_buf_read_at (buf, off + sm.size + 8, (ut8 *)&nm3, sizeof (nm3)); // eprintf ("0x%x next %x %x %x\n", off + sm.size, nm, nm2, nm3); if (r_read_le32 (&nm3) != 0xa1b22b1a) { sm.size -= 8; // is64 = true; } return sm; }
0
522,334
int GmfWriteByteFlow(int64_t MshIdx, char *BytTab, int NmbByt) { int i, PadWrd = 0, *WrdTab = (int *)BytTab, NmbWrd = NmbByt / WrdSiz; // Add an extra padding word at the end if needed if(NmbByt > NmbWrd * 4) PadWrd = 1; // Create the keyword with the number of words, not bytes if(!GmfSetKwd(MshIdx, GmfByteFlow, NmbWrd + PadWrd)) return(0); // Reacord the exact number of bytes GmfSetLin(MshIdx, GmfByteFlow, NmbByt); // Write the byteflow as 4-byte words, missing up to 3 endding bytes for(i=0;i<NmbWrd;i++) GmfSetLin(MshIdx, GmfByteFlow, WrdTab[i]); // Write the extra 1,2 or 3 ending bytes if(PadWrd) { PadWrd = 0; // Copy the last bytes in an integer for(i=0; i<NmbByt - NmbWrd * 4; i++) PadWrd |= BytTab[ NmbWrd * 4 + i ] << (i*8); // And write it as the last line GmfSetLin(MshIdx, GmfByteFlow, PadWrd); } return(1); }
0
267,355
append_env (const char *arg) { exec_options.env = realloc (exec_options.env, (exec_options.env_size + 2) * sizeof (*exec_options.env)); if (exec_options.env == NULL) error (EXIT_FAILURE, errno, "cannot allocate memory"); exec_options.env[exec_options.env_size + 1] = NULL; exec_options.env[exec_options.env_size] = xstrdup (arg); exec_options.env_size++; }
0
509,524
void _ma_report_progress(HA_CHECK *param, ulonglong progress, ulonglong max_progress) { thd_progress_report((THD*)param->thd, progress + max_progress * param->stage, max_progress * param->max_stage); }
0
512,457
const Type_handler *type_handler() const { return &type_handler_row; }
0
248,289
static char *strdup(const char *str) { size_t len; char *dup; len = strlen(str) + 1; dup = calloc(len, sizeof(char)); if (!dup) return NULL; memcpy(dup, str, len); return dup; }
0
409,503
term_color(char_u *s, int n) { char buf[20]; int i = *s == CSI ? 1 : 2; // index in s[] just after <Esc>[ or CSI // Special handling of 16 colors, because termcap can't handle it // Also accept "\e[3%dm" for TERMINFO, it is sometimes used // Also accept CSI instead of <Esc>[ if (n >= 8 && t_colors >= 16 && ((s[0] == ESC && s[1] == '[') #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) || (s[0] == ESC && s[1] == '|') #endif || (s[0] == CSI && (i = 1) == 1)) && s[i] != NUL && (STRCMP(s + i + 1, "%p1%dm") == 0 || STRCMP(s + i + 1, "%dm") == 0) && (s[i] == '3' || s[i] == '4')) { #ifdef TERMINFO char *format = "%s%s%%p1%%dm"; #else char *format = "%s%s%%dm"; #endif char *lead = i == 2 ? ( #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) s[1] == '|' ? "\033|" : #endif "\033[") : "\233"; char *tail = s[i] == '3' ? (n >= 16 ? "38;5;" : "9") : (n >= 16 ? "48;5;" : "10"); sprintf(buf, format, lead, tail); OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); } else OUT_STR(tgoto((char *)s, 0, n)); }
0
220,811
SaturatingRoundingMultiplyByPOTParam( gemmlowp::FixedPoint<tRawType, tIntegerBits> a, int exponent) { return gemmlowp::FixedPoint<tRawType, tIntegerBits>::FromRaw( SaturatingRoundingMultiplyByPOTParam(a.raw(), exponent)); }
0
225,817
GF_Err stdp_box_read(GF_Box *s, GF_BitStream *bs) { u32 entry; GF_DegradationPriorityBox *ptr = (GF_DegradationPriorityBox *)s; /*out-of-order stdp, assume no padding at the end and take the entire remaining data for entries*/ if (!ptr->nb_entries) ptr->nb_entries = (u32) ptr->size / 2; else if (ptr->nb_entries > ptr->size / 2) return GF_ISOM_INVALID_FILE; ptr->priorities = (u16 *) gf_malloc(ptr->nb_entries * sizeof(u16)); if (ptr->priorities == NULL) return GF_OUT_OF_MEM; for (entry = 0; entry < ptr->nb_entries; entry++) { ptr->priorities[entry] = gf_bs_read_u16(bs); } ISOM_DECREASE_SIZE(ptr, (2*ptr->nb_entries) ); return GF_OK; }
0
336,557
void reds_on_client_seamless_migrate_complete(RedsState *reds, RedClient *client) { spice_debug("trace"); if (!reds_find_client(reds, client)) { spice_debug("client no longer exists"); return; } client->get_main()->migrate_dst_complete(); }
0
195,954
static pj_status_t parse_query(pj_dns_parsed_query *q, pj_pool_t *pool, const pj_uint8_t *pkt, const pj_uint8_t *start, const pj_uint8_t *max, int *parsed_len) { const pj_uint8_t *p = start; int name_len, name_part_len; pj_status_t status; /* Get the length of the name */ status = get_name_len(0, pkt, start, max, &name_part_len, &name_len); if (status != PJ_SUCCESS) return status; /* Allocate memory for the name */ q->name.ptr = (char*) pj_pool_alloc(pool, name_len+4); q->name.slen = 0; /* Get the name */ status = get_name(0, pkt, start, max, &q->name); if (status != PJ_SUCCESS) return status; p = (start + name_part_len); /* Get the type */ pj_memcpy(&q->type, p, 2); q->type = pj_ntohs(q->type); p += 2; /* Get the class */ pj_memcpy(&q->dnsclass, p, 2); q->dnsclass = pj_ntohs(q->dnsclass); p += 2; *parsed_len = (int)(p - start); return PJ_SUCCESS; }
1
437,312
compile_string_raw_node(StrNode* sn, regex_t* reg) { if (sn->end <= sn->s) return 0; return add_compile_string(sn->s, 1 /* sb */, (int )(sn->end - sn->s), reg, 0); }
0
101,692
void WebProcessProxy::pageVisibilityChanged(WebKit::WebPageProxy *page) { #if PLATFORM(MAC) if (pageIsProcessSuppressible(page)) m_processSuppressiblePages.add(page->pageID()); else m_processSuppressiblePages.remove(page->pageID()); updateProcessSuppressionState(); #else UNUSED_PARAM(page); #endif }
0
509,532
int ha_maria::update_row(const uchar * old_data, const uchar * new_data) { CHECK_UNTIL_WE_FULLY_IMPLEMENTED_VERSIONING("UPDATE in WRITE CONCURRENT"); return maria_update(file, old_data, new_data); }
0
247,714
const std::string& expectedLocalSubject() const { return expected_local_subject_; }
0
387,775
jmethodID InstanceKlass::jmethod_id_or_null(Method* method) { size_t idnum = (size_t)method->method_idnum(); jmethodID* jmeths = methods_jmethod_ids_acquire(); size_t length; // length assigned as debugging crumb jmethodID id = NULL; if (jmeths != NULL && // If there is a cache (length = (size_t)jmeths[0]) > idnum) { // and if it is long enough, id = jmeths[idnum+1]; // Look up the id (may be NULL) } return id; }
0
489,139
static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc, const struct sctp_association *asoc, struct sctp_chunk *init, sctp_cmd_seq_t *commands) { struct sctp_transport *new_addr, *addr; int found; /* Implementor's Guide - Sectin 5.2.2 * ... * Before responding the endpoint MUST check to see if the * unexpected INIT adds new addresses to the association. If new * addresses are added to the association, the endpoint MUST respond * with an ABORT.. */ /* Search through all current addresses and make sure * we aren't adding any new ones. */ new_addr = NULL; found = 0; list_for_each_entry(new_addr, &new_asoc->peer.transport_addr_list, transports) { found = 0; list_for_each_entry(addr, &asoc->peer.transport_addr_list, transports) { if (sctp_cmp_addr_exact(&new_addr->ipaddr, &addr->ipaddr)) { found = 1; break; } } if (!found) break; } /* If a new address was added, ABORT the sender. */ if (!found && new_addr) { sctp_sf_send_restart_abort(&new_addr->ipaddr, init, commands); } /* Return success if all addresses were found. */ return found; }
0
216,767
static int smtp_command_parse_parameters(struct smtp_command_parser *parser) { const unsigned char *p, *mp; uoff_t max_size = (parser->auth_response ? parser->limits.max_auth_size : parser->limits.max_parameters_size); /* We assume parameters to match textstr (HT, SP, Printable US-ASCII). For command parameters, we also accept valid UTF-8 characters. */ p = parser->cur + parser->state.poff; while (p < parser->end) { unichar_t ch; int nch = 1; if (parser->auth_response) ch = *p; else { nch = uni_utf8_get_char_n(p, (size_t)(p - parser->end), &ch); } if (nch < 0) { smtp_command_parser_error(parser, SMTP_COMMAND_PARSE_ERROR_BAD_COMMAND, "Invalid UTF-8 character in command parameters"); return -1; } if ((parser->auth_response || (ch & 0x80) == 0x00) && !smtp_char_is_textstr((unsigned char)ch)) break; p += nch; } if (max_size > 0 && (uoff_t)(p - parser->cur) > max_size) { smtp_command_parser_error(parser, SMTP_COMMAND_PARSE_ERROR_LINE_TOO_LONG, "%s line is too long", (parser->auth_response ? "AUTH response" : "Command")); return -1; } parser->state.poff = p - parser->cur; if (p == parser->end) return 0; /* In the interest of improved interoperability, SMTP receivers SHOULD tolerate trailing white space before the terminating <CRLF>. WSP = SP / HTAB ; white space --> Trim the end of the buffer */ mp = p; if (mp > parser->cur) { while (mp > parser->cur && (*(mp-1) == ' ' || *(mp-1) == '\t')) mp--; } if (!parser->auth_response && mp > parser->cur && *parser->cur == ' ') { smtp_command_parser_error(parser, SMTP_COMMAND_PARSE_ERROR_BAD_COMMAND, "Duplicate space after command name"); return -1; } parser->state.cmd_params = i_strdup_until(parser->cur, mp); parser->cur = p; parser->state.poff = 0; return 1; }
1
390,542
_XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev, xkbSetCompatMapReq *req, char* data, BOOL dryRun) { XkbSrvInfoPtr xkbi; XkbDescPtr xkb; XkbCompatMapPtr compat; int nGroups; unsigned i,bit; xkbi = dev->key->xkbInfo; xkb = xkbi->desc; compat = xkb->compat; if ((req->nSI>0)||(req->truncateSI)) { xkbSymInterpretWireDesc *wire; if (req->firstSI>compat->num_si) { client->errorValue = _XkbErrCode2(0x02,compat->num_si); return BadValue; } wire= (xkbSymInterpretWireDesc *)data; wire+= req->nSI; data = (char *)wire; } nGroups= 0; if (req->groups!=0) { for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) { if ( req->groups&bit ) nGroups++; } } data+= nGroups*SIZEOF(xkbModsWireDesc); if (((data-((char *)req))/4)!=req->length) { return BadLength; } /* Done all the checks we can do */ if (dryRun) return Success; data = (char *)&req[1]; if (req->nSI>0) { xkbSymInterpretWireDesc *wire = (xkbSymInterpretWireDesc *)data; XkbSymInterpretPtr sym; if ((unsigned)(req->firstSI+req->nSI)>compat->num_si) { compat->num_si= req->firstSI+req->nSI; compat->sym_interpret= _XkbTypedRealloc(compat->sym_interpret, compat->num_si, XkbSymInterpretRec); if (!compat->sym_interpret) { compat->num_si= 0; return BadAlloc; } } else if (req->truncateSI) { compat->num_si = req->firstSI+req->nSI; } sym = &compat->sym_interpret[req->firstSI]; for (i=0;i<req->nSI;i++,wire++,sym++) { if (client->swapped) { int n; swapl(&wire->sym,n); } sym->sym= wire->sym; sym->mods= wire->mods; sym->match= wire->match; sym->flags= wire->flags; sym->virtual_mod= wire->virtualMod; memcpy((char *)&sym->act,(char *)&wire->act, SIZEOF(xkbActionWireDesc)); } data = (char *)wire; } else if (req->truncateSI) { compat->num_si = req->firstSI; } if (req->groups!=0) { unsigned i, bit; xkbModsWireDesc *wire = (xkbModsWireDesc *)data; for (i = 0, bit = 1; i < XkbNumKbdGroups; i++, bit <<= 1) { if (req->groups & bit) { if (client->swapped) { int n; swaps(&wire->virtualMods,n); } compat->groups[i].mask= wire->realMods; compat->groups[i].real_mods= wire->realMods; compat->groups[i].vmods= wire->virtualMods; if (wire->virtualMods!=0) { unsigned tmp; tmp= XkbMaskForVMask(xkb,wire->virtualMods); compat->groups[i].mask|= tmp; } data+= SIZEOF(xkbModsWireDesc); wire= (xkbModsWireDesc *)data; } } } i= XkbPaddedSize((data-((char *)req))); if ((i/4)!=req->length) { ErrorF("[xkb] Internal length error on read in _XkbSetCompatMap\n"); return BadLength; } if (dev->xkb_interest) { xkbCompatMapNotify ev; ev.deviceID = dev->id; ev.changedGroups = req->groups; ev.firstSI = req->firstSI; ev.nSI = req->nSI; ev.nTotalSI = compat->num_si; XkbSendCompatMapNotify(dev,&ev); } if (req->recomputeActions) { XkbChangesRec change; unsigned check; XkbEventCauseRec cause; XkbSetCauseXkbReq(&cause,X_kbSetCompatMap,client); bzero(&change,sizeof(XkbChangesRec)); XkbUpdateActions(dev,xkb->min_key_code,XkbNumKeys(xkb),&change,&check, &cause); if (check) XkbCheckSecondaryEffects(xkbi,check,&change,&cause); XkbUpdateCoreDescription(dev,False); XkbSendNotification(dev,&change,&cause); } return Success; }
0
226,192
GF_Err dac3_box_size(GF_Box *s) { GF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s; if (ptr->cfg.is_ec3) { u32 i; s->size += 2; for (i=0; i<ptr->cfg.nb_streams; i++) { s->size += 3; if (ptr->cfg.streams[i].nb_dep_sub) s->size += 1; } } else { s->size += 3; } return GF_OK;
0
414,927
xmlXPathCmpNodesExt(xmlNodePtr node1, xmlNodePtr node2) { int depth1, depth2; int misc = 0, precedence1 = 0, precedence2 = 0; xmlNodePtr miscNode1 = NULL, miscNode2 = NULL; xmlNodePtr cur, root; long l1, l2; if ((node1 == NULL) || (node2 == NULL)) return(-2); if (node1 == node2) return(0); /* * a couple of optimizations which will avoid computations in most cases */ switch (node1->type) { case XML_ELEMENT_NODE: if (node2->type == XML_ELEMENT_NODE) { if ((0 > (long) node1->content) && /* TODO: Would a != 0 suffice here? */ (0 > (long) node2->content) && (node1->doc == node2->doc)) { l1 = -((long) node1->content); l2 = -((long) node2->content); if (l1 < l2) return(1); if (l1 > l2) return(-1); } else goto turtle_comparison; } break; case XML_ATTRIBUTE_NODE: precedence1 = 1; /* element is owner */ miscNode1 = node1; node1 = node1->parent; misc = 1; break; case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_COMMENT_NODE: case XML_PI_NODE: { miscNode1 = node1; /* * Find nearest element node. */ if (node1->prev != NULL) { do { node1 = node1->prev; if (node1->type == XML_ELEMENT_NODE) { precedence1 = 3; /* element in prev-sibl axis */ break; } if (node1->prev == NULL) { precedence1 = 2; /* element is parent */ /* * URGENT TODO: Are there any cases, where the * parent of such a node is not an element node? */ node1 = node1->parent; break; } } while (1); } else { precedence1 = 2; /* element is parent */ node1 = node1->parent; } if ((node1 == NULL) || (node1->type != XML_ELEMENT_NODE) || (0 <= (long) node1->content)) { /* * Fallback for whatever case. */ node1 = miscNode1; precedence1 = 0; } else misc = 1; } break; case XML_NAMESPACE_DECL: /* * TODO: why do we return 1 for namespace nodes? */ return(1); default: break; } switch (node2->type) { case XML_ELEMENT_NODE: break; case XML_ATTRIBUTE_NODE: precedence2 = 1; /* element is owner */ miscNode2 = node2; node2 = node2->parent; misc = 1; break; case XML_TEXT_NODE: case XML_CDATA_SECTION_NODE: case XML_COMMENT_NODE: case XML_PI_NODE: { miscNode2 = node2; if (node2->prev != NULL) { do { node2 = node2->prev; if (node2->type == XML_ELEMENT_NODE) { precedence2 = 3; /* element in prev-sibl axis */ break; } if (node2->prev == NULL) { precedence2 = 2; /* element is parent */ node2 = node2->parent; break; } } while (1); } else { precedence2 = 2; /* element is parent */ node2 = node2->parent; } if ((node2 == NULL) || (node2->type != XML_ELEMENT_NODE) || (0 <= (long) node2->content)) { node2 = miscNode2; precedence2 = 0; } else misc = 1; } break; case XML_NAMESPACE_DECL: return(1); default: break; } if (misc) { if (node1 == node2) { if (precedence1 == precedence2) { /* * The ugly case; but normally there aren't many * adjacent non-element nodes around. */ cur = miscNode2->prev; while (cur != NULL) { if (cur == miscNode1) return(1); if (cur->type == XML_ELEMENT_NODE) return(-1); cur = cur->prev; } return (-1); } else { /* * Evaluate based on higher precedence wrt to the element. * TODO: This assumes attributes are sorted before content. * Is this 100% correct? */ if (precedence1 < precedence2) return(1); else return(-1); } } /* * Special case: One of the helper-elements is contained by the other. * <foo> * <node2> * <node1>Text-1(precedence1 == 2)</node1> * </node2> * Text-6(precedence2 == 3) * </foo> */ if ((precedence2 == 3) && (precedence1 > 1)) { cur = node1->parent; while (cur) { if (cur == node2) return(1); cur = cur->parent; } } if ((precedence1 == 3) && (precedence2 > 1)) { cur = node2->parent; while (cur) { if (cur == node1) return(-1); cur = cur->parent; } } } /* * Speedup using document order if availble. */ if ((node1->type == XML_ELEMENT_NODE) && (node2->type == XML_ELEMENT_NODE) && (0 > (long) node1->content) && (0 > (long) node2->content) && (node1->doc == node2->doc)) { l1 = -((long) node1->content); l2 = -((long) node2->content); if (l1 < l2) return(1); if (l1 > l2) return(-1); } turtle_comparison: if (node1 == node2->prev) return(1); if (node1 == node2->next) return(-1); /* * compute depth to root */ for (depth2 = 0, cur = node2;cur->parent != NULL;cur = cur->parent) { if (cur == node1) return(1); depth2++; } root = cur; for (depth1 = 0, cur = node1;cur->parent != NULL;cur = cur->parent) { if (cur == node2) return(-1); depth1++; } /* * Distinct document (or distinct entities :-( ) case. */ if (root != cur) { return(-2); } /* * get the nearest common ancestor. */ while (depth1 > depth2) { depth1--; node1 = node1->parent; } while (depth2 > depth1) { depth2--; node2 = node2->parent; } while (node1->parent != node2->parent) { node1 = node1->parent; node2 = node2->parent; /* should not happen but just in case ... */ if ((node1 == NULL) || (node2 == NULL)) return(-2); } /* * Find who's first. */ if (node1 == node2->prev) return(1); if (node1 == node2->next) return(-1); /* * Speedup using document order if availble. */ if ((node1->type == XML_ELEMENT_NODE) && (node2->type == XML_ELEMENT_NODE) && (0 > (long) node1->content) && (0 > (long) node2->content) && (node1->doc == node2->doc)) { l1 = -((long) node1->content); l2 = -((long) node2->content); if (l1 < l2) return(1); if (l1 > l2) return(-1); } for (cur = node1->next;cur != NULL;cur = cur->next) if (cur == node2) return(1); return(-1); /* assume there is no sibling list corruption */ }
0
300,808
static void tipc_data_ready(struct sock *sk) { struct socket_wq *wq; rcu_read_lock(); wq = rcu_dereference(sk->sk_wq); if (skwq_has_sleeper(wq)) wake_up_interruptible_sync_poll(&wq->wait, EPOLLIN | EPOLLRDNORM | EPOLLRDBAND); rcu_read_unlock(); }
0
359,546
DEFUN (no_bgp_always_compare_med, no_bgp_always_compare_med_cmd, "no bgp always-compare-med", NO_STR "BGP specific commands\n" "Allow comparing MED from different neighbors\n") { struct bgp *bgp; bgp = vty->index; bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); return CMD_SUCCESS; }
0
236,190
GF_Err tbox_box_size(GF_Box *s) { s->size += 8; return GF_OK; }
0
482,541
addForwardPassRule(TranslationTableOffset ruleOffset, TranslationTableRule *rule, TranslationTableHeader *table) { TranslationTableOffset *forPassRule; switch (rule->opcode) { case CTO_Correct: forPassRule = &table->forPassRules[0]; break; case CTO_Context: forPassRule = &table->forPassRules[1]; break; case CTO_Pass2: forPassRule = &table->forPassRules[2]; break; case CTO_Pass3: forPassRule = &table->forPassRules[3]; break; case CTO_Pass4: forPassRule = &table->forPassRules[4]; break; default: return 0; } while (*forPassRule) { TranslationTableRule *r = (TranslationTableRule *)&table->ruleArea[*forPassRule]; if (rule->charslen > r->charslen) break; forPassRule = &r->charsnext; } rule->charsnext = *forPassRule; *forPassRule = ruleOffset; return 1; }
0
335,104
static int skcipher_recvmsg_nokey(struct kiocb *unused, struct socket *sock, struct msghdr *msg, size_t ignored, int flags) { int err; err = skcipher_check_key(sock); if (err) return err; return skcipher_recvmsg(NULL, sock, msg, ignored, flags); }
0
248,275
DLLIMPORT int cfg_setnfloat(cfg_t *cfg, const char *name, double value, unsigned int index) { cfg_opt_t *opt; opt = cfg_getopt(cfg, name); if (opt && opt->validcb2 && (*opt->validcb2)(cfg, opt, (void *)&value) != 0) return CFG_FAIL; return cfg_opt_setnfloat(opt, value, index); }
0
437,346
compile_length_option_node(EnclosureNode* node, regex_t* reg) { int tlen; OnigOptionType prev = reg->options; reg->options = node->o.options; tlen = compile_length_tree(NODE_ENCLOSURE_BODY(node), reg); reg->options = prev; return tlen; }
0
513,038
bool Item_in_optimizer::eval_not_null_tables(void *opt_arg) { not_null_tables_cache= 0; if (is_top_level_item()) { /* It is possible to determine NULL-rejectedness of the left arguments of IN only if it is a top-level predicate. */ not_null_tables_cache= args[0]->not_null_tables(); } return FALSE; }
0
508,306
void close_tables_for_reopen(THD *thd, TABLE_LIST **tables, const MDL_savepoint &start_of_statement_svp) { TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table(); TABLE_LIST *tmp; /* If table list consists only from tables from prelocking set, table list for new attempt should be empty, so we have to update list's root pointer. */ if (first_not_own_table == *tables) *tables= 0; thd->lex->chop_off_not_own_tables(); /* Reset MDL tickets for procedures/functions */ for (Sroutine_hash_entry *rt= (Sroutine_hash_entry*)thd->lex->sroutines_list.first; rt; rt= rt->next) rt->mdl_request.ticket= NULL; sp_remove_not_own_routines(thd->lex); for (tmp= *tables; tmp; tmp= tmp->next_global) { tmp->table= 0; tmp->mdl_request.ticket= NULL; /* We have to cleanup translation tables of views. */ tmp->cleanup_items(); } /* No need to commit/rollback the statement transaction: it's either not started or we're filling in an INFORMATION_SCHEMA table on the fly, and thus mustn't manipulate with the transaction of the enclosing statement. */ DBUG_ASSERT(thd->transaction.stmt.is_empty() || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)); close_thread_tables(thd); thd->mdl_context.rollback_to_savepoint(start_of_statement_svp); }
0
240,274
write_reg_contents_lst( int name, char_u **strings, int maxlen UNUSED, int must_append, int yank_type, long block_len) { yankreg_T *old_y_previous, *old_y_current; if (name == '/' || name == '=') { char_u *s; if (strings[0] == NULL) s = (char_u *)""; else if (strings[1] != NULL) { emsg(_(e_search_pattern_and_expression_register_may_not_contain_two_or_more_lines)); return; } else s = strings[0]; write_reg_contents_ex(name, s, -1, must_append, yank_type, block_len); return; } if (name == '_') // black hole: nothing to do return; if (init_write_reg(name, &old_y_previous, &old_y_current, must_append, &yank_type) == FAIL) return; str_to_reg(y_current, yank_type, (char_u *)strings, -1, block_len, TRUE); finish_write_reg(name, old_y_previous, old_y_current); }
0
274,757
void ntfs_attr_close(ntfs_attr *na) { if (!na) return; if (NAttrNonResident(na) && na->rl) free(na->rl); /* Don't release if using an internal constant. */ if (na->name != AT_UNNAMED && na->name != NTFS_INDEX_I30 && na->name != STREAM_SDS) free(na->name); free(na); }
0
221,497
regenerate_ld_cache (GPtrArray *base_argv_array, GArray *base_fd_array, GFile *app_id_dir, const char *checksum, GFile *runtime_files, gboolean generate_ld_so_conf, GCancellable *cancellable, GError **error) { g_autoptr(FlatpakBwrap) bwrap = NULL; g_autoptr(GArray) combined_fd_array = NULL; g_autoptr(GFile) ld_so_cache = NULL; g_autoptr(GFile) ld_so_cache_tmp = NULL; g_autofree char *sandbox_cache_path = NULL; g_autofree char *tmp_basename = NULL; g_auto(GStrv) minimal_envp = NULL; g_autofree char *commandline = NULL; int exit_status; glnx_autofd int ld_so_fd = -1; g_autoptr(GFile) ld_so_dir = NULL; if (app_id_dir) ld_so_dir = g_file_get_child (app_id_dir, ".ld.so"); else { g_autoptr(GFile) base_dir = g_file_new_for_path (g_get_user_cache_dir ()); ld_so_dir = g_file_resolve_relative_path (base_dir, "flatpak/ld.so"); } ld_so_cache = g_file_get_child (ld_so_dir, checksum); ld_so_fd = open (flatpak_file_get_path_cached (ld_so_cache), O_RDONLY); if (ld_so_fd >= 0) return glnx_steal_fd (&ld_so_fd); g_debug ("Regenerating ld.so.cache %s", flatpak_file_get_path_cached (ld_so_cache)); if (!flatpak_mkdir_p (ld_so_dir, cancellable, error)) return FALSE; minimal_envp = flatpak_run_get_minimal_env (FALSE, FALSE); bwrap = flatpak_bwrap_new (minimal_envp); flatpak_bwrap_append_args (bwrap, base_argv_array); flatpak_run_setup_usr_links (bwrap, runtime_files, NULL); if (generate_ld_so_conf) { if (!add_ld_so_conf (bwrap, error)) return -1; } else flatpak_bwrap_add_args (bwrap, "--symlink", "../usr/etc/ld.so.conf", "/etc/ld.so.conf", NULL); tmp_basename = g_strconcat (checksum, ".XXXXXX", NULL); glnx_gen_temp_name (tmp_basename); sandbox_cache_path = g_build_filename ("/run/ld-so-cache-dir", tmp_basename, NULL); ld_so_cache_tmp = g_file_get_child (ld_so_dir, tmp_basename); flatpak_bwrap_add_args (bwrap, "--unshare-pid", "--unshare-ipc", "--unshare-net", "--proc", "/proc", "--dev", "/dev", "--bind", flatpak_file_get_path_cached (ld_so_dir), "/run/ld-so-cache-dir", NULL); flatpak_bwrap_sort_envp (bwrap); flatpak_bwrap_envp_to_args (bwrap); if (!flatpak_bwrap_bundle_args (bwrap, 1, -1, FALSE, error)) return -1; flatpak_bwrap_add_args (bwrap, "ldconfig", "-X", "-C", sandbox_cache_path, NULL); flatpak_bwrap_finish (bwrap); commandline = flatpak_quote_argv ((const char **) bwrap->argv->pdata, -1); g_debug ("Running: '%s'", commandline); combined_fd_array = g_array_new (FALSE, TRUE, sizeof (int)); g_array_append_vals (combined_fd_array, base_fd_array->data, base_fd_array->len); g_array_append_vals (combined_fd_array, bwrap->fds->data, bwrap->fds->len); /* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak_close_fds_workaround */ if (!g_spawn_sync (NULL, (char **) bwrap->argv->pdata, bwrap->envp, G_SPAWN_SEARCH_PATH | G_SPAWN_LEAVE_DESCRIPTORS_OPEN, flatpak_bwrap_child_setup_cb, combined_fd_array, NULL, NULL, &exit_status, error)) return -1; if (!WIFEXITED (exit_status) || WEXITSTATUS (exit_status) != 0) { flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _("ldconfig failed, exit status %d"), exit_status); return -1; } ld_so_fd = open (flatpak_file_get_path_cached (ld_so_cache_tmp), O_RDONLY); if (ld_so_fd < 0) { flatpak_fail_error (error, FLATPAK_ERROR_SETUP_FAILED, _("Can't open generated ld.so.cache")); return -1; } if (app_id_dir == NULL) { /* For runs without an app id dir we always regenerate the ld.so.cache */ unlink (flatpak_file_get_path_cached (ld_so_cache_tmp)); } else { g_autoptr(GFile) active = g_file_get_child (ld_so_dir, "active"); /* For app-dirs we keep one checksum alive, by pointing the active symlink to it */ /* Rename to known name, possibly overwriting existing ref if race */ if (rename (flatpak_file_get_path_cached (ld_so_cache_tmp), flatpak_file_get_path_cached (ld_so_cache)) == -1) { glnx_set_error_from_errno (error); return -1; } if (!flatpak_switch_symlink_and_remove (flatpak_file_get_path_cached (active), checksum, error)) return -1; } return glnx_steal_fd (&ld_so_fd); }
0
359,294
DEFUN (no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_cmd, NO_NEIGHBOR_CMD2 "unsuppress-map WORD", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Route-map to selectively unsuppress suppressed routes\n" "Name of route map\n") { return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty)); }
0
221,679
int Socket::loopChunk(int timeout) // reads chunks and sends back until 0 len chunk or timeout { char buff[32000]; int tot_size = 0; int csize = 1; while (csize > 0) { csize = readChunk(buff,32000, timeout); if (csize == 0) // end chunk { if (!writeChunkTrailer(chunked_trailer)) { #ifdef CHUNKDEBUG std::cerr << thread_id << "loopChunk - error in writing chunk trailer" << std::endl; #endif return -1; }; #ifdef CHUNKDEBUG std::cerr << thread_id << "loopChunk tot_size=" << tot_size << std::endl; #endif return tot_size; } if (!(csize > 0 && writeChunk(buff,csize,timeout))) { #ifdef CHUNKDEBUG std::cerr << thread_id << "loopChunk - error" << std::endl; #endif return -1; } tot_size += csize; } return -1; // should never get here! }
0
242,964
int mbedtls_ssl_check_record( mbedtls_ssl_context const *ssl, unsigned char *buf, size_t buflen ) { int ret = 0; MBEDTLS_SSL_DEBUG_MSG( 1, ( "=> mbedtls_ssl_check_record" ) ); MBEDTLS_SSL_DEBUG_BUF( 3, "record buffer", buf, buflen ); /* We don't support record checking in TLS because * (a) there doesn't seem to be a usecase for it, and * (b) In SSLv3 and TLS 1.0, CBC record decryption has state * and we'd need to backup the transform here. */ if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_STREAM ) { ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; goto exit; } #if defined(MBEDTLS_SSL_PROTO_DTLS) else { mbedtls_record rec; ret = ssl_parse_record_header( ssl, buf, buflen, &rec ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 3, "ssl_parse_record_header", ret ); goto exit; } if( ssl->transform_in != NULL ) { ret = mbedtls_ssl_decrypt_buf( ssl, ssl->transform_in, &rec ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 3, "mbedtls_ssl_decrypt_buf", ret ); goto exit; } } } #endif /* MBEDTLS_SSL_PROTO_DTLS */ exit: /* On success, we have decrypted the buffer in-place, so make * sure we don't leak any plaintext data. */ mbedtls_platform_zeroize( buf, buflen ); /* For the purpose of this API, treat messages with unexpected CID * as well as such from future epochs as unexpected. */ if( ret == MBEDTLS_ERR_SSL_UNEXPECTED_CID || ret == MBEDTLS_ERR_SSL_EARLY_MESSAGE ) { ret = MBEDTLS_ERR_SSL_UNEXPECTED_RECORD; } MBEDTLS_SSL_DEBUG_MSG( 1, ( "<= mbedtls_ssl_check_record" ) ); return( ret ); }
0
413,667
static void function_rename(RFlag *flags, RAnalFunction *fcn) { const char *locname = "loc."; const size_t locsize = strlen (locname); char *fcnname = fcn->name; if (strncmp (fcn->name, locname, locsize) == 0) { const char *fcnpfx, *restofname; RFlagItem *f; fcn->type = R_ANAL_FCN_TYPE_FCN; fcnpfx = r_anal_functiontype_tostring (fcn->type); restofname = fcn->name + locsize; fcn->name = r_str_newf ("%s.%s", fcnpfx, restofname); f = r_flag_get_i (flags, fcn->addr); r_flag_rename (flags, f, fcn->name); free (fcnname); } }
0
214,336
static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sadb_msg *hdr, void * const *ext_hdrs) { struct pfkey_sock *pfk = pfkey_sk(sk); struct sk_buff *supp_skb; if (hdr->sadb_msg_satype > SADB_SATYPE_MAX) return -EINVAL; if (hdr->sadb_msg_satype != SADB_SATYPE_UNSPEC) { if (pfk->registered&(1<<hdr->sadb_msg_satype)) return -EEXIST; pfk->registered |= (1<<hdr->sadb_msg_satype); } xfrm_probe_algs(); supp_skb = compose_sadb_supported(hdr, GFP_KERNEL | __GFP_ZERO); if (!supp_skb) { if (hdr->sadb_msg_satype != SADB_SATYPE_UNSPEC) pfk->registered &= ~(1<<hdr->sadb_msg_satype); return -ENOBUFS; } pfkey_broadcast(supp_skb, GFP_KERNEL, BROADCAST_REGISTERED, sk, sock_net(sk)); return 0; }
1
292,170
void LinkResolver::check_method_accessability(Klass* ref_klass, Klass* resolved_klass, Klass* sel_klass, const methodHandle& sel_method, TRAPS) { AccessFlags flags = sel_method->access_flags(); // Special case: arrays always override "clone". JVMS 2.15. // If the resolved klass is an array class, and the declaring class // is java.lang.Object and the method is "clone", set the flags // to public. // // We'll check for the method name first, as that's most likely // to be false (so we'll short-circuit out of these tests). if (sel_method->name() == vmSymbols::clone_name() && sel_klass == SystemDictionary::Object_klass() && resolved_klass->is_array_klass()) { // We need to change "protected" to "public". assert(flags.is_protected(), "clone not protected?"); jint new_flags = flags.as_int(); new_flags = new_flags & (~JVM_ACC_PROTECTED); new_flags = new_flags | JVM_ACC_PUBLIC; flags.set_flags(new_flags); } // assert(extra_arg_result_or_null != NULL, "must be able to return extra argument"); bool can_access = Reflection::verify_member_access(ref_klass, resolved_klass, sel_klass, flags, true, false, CHECK); // Any existing exceptions that may have been thrown, for example LinkageErrors // from nest-host resolution, have been allowed to propagate. if (!can_access) { ResourceMark rm(THREAD); bool same_module = (sel_klass->module() == ref_klass->module()); Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalAccessError(), "class %s tried to access %s%s%smethod '%s' (%s%s%s)", ref_klass->external_name(), sel_method->is_abstract() ? "abstract " : "", sel_method->is_protected() ? "protected " : "", sel_method->is_private() ? "private " : "", sel_method->external_name(), (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(), (same_module) ? "" : "; ", (same_module) ? "" : sel_klass->class_in_module_of_loader() ); return; } }
0
225,495
Status MutableGraphView::SwapRegularFaninsByPorts(absl::string_view node_name, int from_port, int to_port) { auto error_status = [node_name, from_port, to_port](absl::string_view msg) { string params = absl::Substitute("node_name='$0', from_port=$1, to_port=$2", node_name, from_port, to_port); return MutationError("SwapRegularFaninsByPorts", params, msg); }; NodeDef* node = GetNode(node_name); TF_RETURN_IF_ERROR(CheckNodeExists(node_name, node, error_status)); const int last_regular_fanin_port = gtl::FindWithDefault(max_regular_input_port(), node, -1); TF_RETURN_IF_ERROR(CheckPortRange(from_port, /*min=*/0, last_regular_fanin_port, error_status)); TF_RETURN_IF_ERROR(CheckPortRange(to_port, /*min=*/0, last_regular_fanin_port, error_status)); if (from_port == to_port) { return Status::OK(); } TensorId from_fanin = ParseTensorName(node->input(from_port)); TensorId to_fanin = ParseTensorName(node->input(to_port)); if (from_fanin == to_fanin) { return Status::OK(); } InputPort from_input(node, from_port); InputPort to_input(node, to_port); NodeDef* from_fanin_node = GetNode(from_fanin.node()); absl::flat_hash_set<InputPort>* from_fanouts = &fanouts()[{from_fanin_node, from_fanin.index()}]; from_fanouts->erase(from_input); from_fanouts->insert(to_input); NodeDef* to_fanin_node = GetNode(to_fanin.node()); absl::flat_hash_set<InputPort>* to_fanouts = &fanouts()[{to_fanin_node, to_fanin.index()}]; to_fanouts->erase(to_input); to_fanouts->insert(from_input); node->mutable_input()->SwapElements(from_port, to_port); return Status::OK(); }
0
312,563
vgr_process_files( win_T *wp, qf_info_T *qi, vgr_args_T *cmd_args, int *redraw_for_dummy, buf_T **first_match_buf, char_u **target_dir) { int status = FAIL; int_u save_qfid = qf_get_curlist(qi)->qf_id; time_t seconds = 0; char_u *fname; int fi; buf_T *buf; int duplicate_name = FALSE; int using_dummy; char_u *dirname_start = NULL; char_u *dirname_now = NULL; int found_match; aco_save_T aco; dirname_start = alloc_id(MAXPATHL, aid_qf_dirname_start); dirname_now = alloc_id(MAXPATHL, aid_qf_dirname_now); if (dirname_start == NULL || dirname_now == NULL) goto theend; // Remember the current directory, because a BufRead autocommand that does // ":lcd %:p:h" changes the meaning of short path names. mch_dirname(dirname_start, MAXPATHL); seconds = (time_t)0; for (fi = 0; fi < cmd_args->fcount && !got_int && cmd_args->tomatch > 0; ++fi) { fname = shorten_fname1(cmd_args->fnames[fi]); if (time(NULL) > seconds) { // Display the file name every second or so, show the user we are // working on it. seconds = time(NULL); vgr_display_fname(fname); } buf = buflist_findname_exp(cmd_args->fnames[fi]); if (buf == NULL || buf->b_ml.ml_mfp == NULL) { // Remember that a buffer with this name already exists. duplicate_name = (buf != NULL); using_dummy = TRUE; *redraw_for_dummy = TRUE; buf = vgr_load_dummy_buf(fname, dirname_start, dirname_now); } else // Use existing, loaded buffer. using_dummy = FALSE; // Check whether the quickfix list is still valid. When loading a // buffer above, autocommands might have changed the quickfix list. if (!vgr_qflist_valid(wp, qi, save_qfid, cmd_args->qf_title)) goto theend; save_qfid = qf_get_curlist(qi)->qf_id; if (buf == NULL) { if (!got_int) smsg(_("Cannot open file \"%s\""), fname); } else { // Try for a match in all lines of the buffer. // For ":1vimgrep" look for first match only. found_match = vgr_match_buflines(qf_get_curlist(qi), fname, buf, cmd_args->spat, &cmd_args->regmatch, &cmd_args->tomatch, duplicate_name, cmd_args->flags); if (using_dummy) { if (found_match && *first_match_buf == NULL) *first_match_buf = buf; if (duplicate_name) { // Never keep a dummy buffer if there is another buffer // with the same name. wipe_dummy_buffer(buf, dirname_start); buf = NULL; } else if ((cmdmod.cmod_flags & CMOD_HIDE) == 0 || buf->b_p_bh[0] == 'u' // "unload" || buf->b_p_bh[0] == 'w' // "wipe" || buf->b_p_bh[0] == 'd') // "delete" { // When no match was found we don't need to remember the // buffer, wipe it out. If there was a match and it // wasn't the first one or we won't jump there: only // unload the buffer. // Ignore 'hidden' here, because it may lead to having too // many swap files. if (!found_match) { wipe_dummy_buffer(buf, dirname_start); buf = NULL; } else if (buf != *first_match_buf || (cmd_args->flags & VGR_NOJUMP) || existing_swapfile(buf)) { unload_dummy_buffer(buf, dirname_start); // Keeping the buffer, remove the dummy flag. buf->b_flags &= ~BF_DUMMY; buf = NULL; } } if (buf != NULL) { // Keeping the buffer, remove the dummy flag. buf->b_flags &= ~BF_DUMMY; // If the buffer is still loaded we need to use the // directory we jumped to below. if (buf == *first_match_buf && *target_dir == NULL && STRCMP(dirname_start, dirname_now) != 0) *target_dir = vim_strsave(dirname_now); // The buffer is still loaded, the Filetype autocommands // need to be done now, in that buffer. And the modelines // need to be done (again). But not the window-local // options! aucmd_prepbuf(&aco, buf); #if defined(FEAT_SYN_HL) apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, buf->b_fname, TRUE, buf); #endif do_modelines(OPT_NOWIN); aucmd_restbuf(&aco); } } } } status = OK; theend: vim_free(dirname_now); vim_free(dirname_start); return status; }
0
261,238
int wm_SemLock(wm_Sem *s){ dispatch_semaphore_wait(*s, DISPATCH_TIME_FOREVER); return 0; }
0
197,621
void Compute(OpKernelContext* const context) override { // node_id_range const Tensor* node_id_range_t; OP_REQUIRES_OK(context, context->input("node_id_range", &node_id_range_t)); const auto node_id_range = node_id_range_t->vec<int32>(); const int32_t node_id_first = node_id_range(0); // inclusive const int32_t node_id_last = node_id_range(1); // exclusive const Tensor* stats_summary_indices_t; OP_REQUIRES_OK(context, context->input("stats_summary_indices", &stats_summary_indices_t)); const auto stats_summary_indices = stats_summary_indices_t->matrix<int32>(); const int32_t num_sparse_entries = stats_summary_indices_t->dim_size(0); const Tensor* stats_summary_values_t; OP_REQUIRES_OK(context, context->input("stats_summary_values", &stats_summary_values_t)); const auto stats_summary_values = stats_summary_values_t->vec<float>(); const Tensor* stats_summary_shape_t; OP_REQUIRES_OK( context, context->input("stats_summary_shape", &stats_summary_shape_t)); const auto stats_summary_shape = stats_summary_shape_t->vec<int32>(); const int32_t num_buckets = stats_summary_shape(2) - 1; const int32_t stats_dims = stats_summary_shape(3); const Tensor* l1_t; OP_REQUIRES_OK(context, context->input("l1", &l1_t)); const auto l1 = l1_t->scalar<float>()(); const Tensor* l2_t; OP_REQUIRES_OK(context, context->input("l2", &l2_t)); const auto l2 = l2_t->scalar<float>()(); const Tensor* tree_complexity_t; OP_REQUIRES_OK(context, context->input("tree_complexity", &tree_complexity_t)); const auto tree_complexity = tree_complexity_t->scalar<float>()(); const Tensor* min_node_weight_t; OP_REQUIRES_OK(context, context->input("min_node_weight", &min_node_weight_t)); const auto min_node_weight = min_node_weight_t->scalar<float>()(); std::vector<int32> output_node_ids; std::vector<float> output_gains; std::vector<int32> output_feature_dimensions; std::vector<int32> output_thresholds; std::vector<float> output_left_node_contribs; std::vector<float> output_right_node_contribs; std::vector<string> output_split_types; FeatureMap f_map; int32_t previous_node_id = -1; for (int idx = 0; idx < num_sparse_entries; ++idx) { int32_t node_id = stats_summary_indices(idx, 0); if (node_id != previous_node_id) { process_node(f_map, &output_node_ids, &output_gains, &output_feature_dimensions, &output_thresholds, &output_left_node_contribs, &output_right_node_contribs, &output_split_types, previous_node_id, min_node_weight, l1, l2, num_buckets); f_map.clear(); } previous_node_id = node_id; DCHECK_LE(node_id_first, node_id); DCHECK_LT(node_id, node_id_last); const int32_t feature_dim = stats_summary_indices(idx, 1); const int32_t bucket_id = stats_summary_indices(idx, 2); const int32_t stat_dim = stats_summary_indices(idx, 3); std::pair<FeatureMapIterator, bool> const& f_insert_result = f_map.insert( FeatureMapIterator::value_type(feature_dim, BucketMap())); auto& b_map = f_insert_result.first->second; std::pair<BucketMapIterator, bool> const& b_insert_result = b_map.insert(BucketMapIterator::value_type( bucket_id, std::vector<float>(stats_dims))); auto& stats = b_insert_result.first->second; stats[stat_dim] = stats_summary_values(idx); } // for node_id // process the last node id process_node(f_map, &output_node_ids, &output_gains, &output_feature_dimensions, &output_thresholds, &output_left_node_contribs, &output_right_node_contribs, &output_split_types, previous_node_id, min_node_weight, l1, l2, num_buckets); const int num_nodes = output_node_ids.size(); // output_node_ids Tensor* output_node_ids_t = nullptr; OP_REQUIRES_OK(context, context->allocate_output("node_ids", {num_nodes}, &output_node_ids_t)); auto output_node_ids_vec = output_node_ids_t->vec<int32>(); // output_gains Tensor* output_gains_t; OP_REQUIRES_OK(context, context->allocate_output("gains", {num_nodes}, &output_gains_t)); auto output_gains_vec = output_gains_t->vec<float>(); // output_feature_dimensions Tensor* output_feature_dimension_t; OP_REQUIRES_OK(context, context->allocate_output("feature_dimensions", {num_nodes}, &output_feature_dimension_t)); auto output_feature_dimensions_vec = output_feature_dimension_t->vec<int32>(); // output_thresholds Tensor* output_thresholds_t; OP_REQUIRES_OK(context, context->allocate_output("thresholds", {num_nodes}, &output_thresholds_t)); auto output_thresholds_vec = output_thresholds_t->vec<int32>(); // output_left_node_contribs Tensor* output_left_node_contribs_t; OP_REQUIRES_OK( context, context->allocate_output("left_node_contribs", {num_nodes, 1}, &output_left_node_contribs_t)); auto output_left_node_contribs_matrix = output_left_node_contribs_t->matrix<float>(); // output_right_node_contribs Tensor* output_right_node_contribs_t; OP_REQUIRES_OK( context, context->allocate_output("right_node_contribs", {num_nodes, 1}, &output_right_node_contribs_t)); auto output_right_node_contribs_matrix = output_right_node_contribs_t->matrix<float>(); // split type Tensor* output_split_types_t; OP_REQUIRES_OK( context, context->allocate_output("split_with_default_directions", {num_nodes}, &output_split_types_t)); auto output_split_types_vec = output_split_types_t->vec<tstring>(); // Sets output tensors from vectors. for (int i = 0; i < num_nodes; ++i) { output_node_ids_vec(i) = output_node_ids[i]; // Adjust the gains to penalize by tree complexity. output_gains_vec(i) = output_gains[i] - tree_complexity; output_feature_dimensions_vec(i) = output_feature_dimensions[i]; output_thresholds_vec(i) = output_thresholds[i]; // TODO(crawles): change this for multi-class. output_left_node_contribs_matrix(i, 0) = output_left_node_contribs[i]; output_right_node_contribs_matrix(i, 0) = output_right_node_contribs[i]; output_split_types_vec(i) = output_split_types[i]; } }
1
507,765
int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) { if (r == NULL || s == NULL) return 0; BN_clear_free(sig->r); BN_clear_free(sig->s); sig->r = r; sig->s = s; return 1; }
0
333,545
int gdTransformAffineCopy(gdImagePtr dst, int dst_x, int dst_y, const gdImagePtr src, gdRectPtr src_region, const double affine[6]) { int c1x,c1y,c2x,c2y; int backclip = 0; int backup_clipx1, backup_clipy1, backup_clipx2, backup_clipy2; register int x, y, src_offset_x, src_offset_y; double inv[6]; int *dst_p; gdPointF pt, src_pt; gdRect bbox; int end_x, end_y; gdInterpolationMethod interpolation_id_bak = GD_DEFAULT; interpolation_method interpolation_bak; /* These methods use special implementations */ if (src->interpolation_id == GD_BILINEAR_FIXED || src->interpolation_id == GD_BICUBIC_FIXED || src->interpolation_id == GD_NEAREST_NEIGHBOUR) { interpolation_id_bak = src->interpolation_id; interpolation_bak = src->interpolation; gdImageSetInterpolationMethod(src, GD_BICUBIC); } gdImageClipRectangle(src, src_region); if (src_region->x > 0 || src_region->y > 0 || src_region->width < gdImageSX(src) || src_region->height < gdImageSY(src)) { backclip = 1; gdImageGetClip(src, &backup_clipx1, &backup_clipy1, &backup_clipx2, &backup_clipy2); gdImageSetClip(src, src_region->x, src_region->y, src_region->x + src_region->width - 1, src_region->y + src_region->height - 1); } if (!gdTransformAffineBoundingBox(src_region, affine, &bbox)) { if (backclip) { gdImageSetClip(src, backup_clipx1, backup_clipy1, backup_clipx2, backup_clipy2); } gdImageSetInterpolationMethod(src, interpolation_id_bak); return GD_FALSE; } gdImageGetClip(dst, &c1x, &c1y, &c2x, &c2y); end_x = bbox.width + (int) fabs(bbox.x); end_y = bbox.height + (int) fabs(bbox.y); /* Get inverse affine to let us work with destination -> source */ gdAffineInvert(inv, affine); src_offset_x = src_region->x; src_offset_y = src_region->y; if (dst->alphaBlendingFlag) { for (y = bbox.y; y <= end_y; y++) { pt.y = y + 0.5; for (x = 0; x <= end_x; x++) { pt.x = x + 0.5; gdAffineApplyToPointF(&src_pt, &pt, inv); gdImageSetPixel(dst, dst_x + x, dst_y + y, getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, 0)); } } } else { for (y = 0; y <= end_y; y++) { pt.y = y + 0.5 + bbox.y; if ((dst_y + y) < 0 || ((dst_y + y) > gdImageSY(dst) -1)) { continue; } dst_p = dst->tpixels[dst_y + y] + dst_x; for (x = 0; x <= end_x; x++) { pt.x = x + 0.5 + bbox.x; gdAffineApplyToPointF(&src_pt, &pt, inv); if ((dst_x + x) < 0 || (dst_x + x) > (gdImageSX(dst) - 1)) { break; } *(dst_p++) = getPixelInterpolated(src, src_offset_x + src_pt.x, src_offset_y + src_pt.y, -1); } } } /* Restore clip if required */ if (backclip) { gdImageSetClip(src, backup_clipx1, backup_clipy1, backup_clipx2, backup_clipy2); } gdImageSetInterpolationMethod(src, interpolation_id_bak); return GD_TRUE; }
0
237,818
static int acurite_590tx_decode(r_device *decoder, bitbuffer_t *bitbuffer) { data_t *data; uint8_t *b; int row; int sensor_id; // the sensor ID - basically a random number that gets reset whenever the battery is removed int battery_ok; // the battery status: 1 is good, 0 is low int channel; int humidity; int temp_raw; // temperature as read from the data packet float temp_c; // temperature in C row = bitbuffer_find_repeated_row(bitbuffer, 3, 25); // expected are min 3 rows if (row < 0) return DECODE_ABORT_EARLY; if (bitbuffer->bits_per_row[row] > 25) return DECODE_ABORT_LENGTH; b = bitbuffer->bb[row]; if (b[4] != 0) // last byte should be zero return DECODE_FAIL_SANITY; // reject all blank messages if (b[0] == 0 && b[1] == 0 && b[2] == 0 && b[3] == 0) return DECODE_FAIL_SANITY; // parity check: odd parity on bits [0 .. 10] // i.e. 8 bytes and another 2 bits. uint8_t parity = b[0]; // parity as byte parity = (parity >> 4) ^ (parity & 0xF); // fold to nibble parity = (parity >> 2) ^ (parity & 0x3); // fold to 2 bits parity ^= b[1] >> 6; // add remaining bits parity = (parity >> 1) ^ (parity & 0x1); // fold to 1 bit if (!parity) { decoder_log(decoder, 1, __func__, "parity check failed"); return DECODE_FAIL_MIC; } // Processing the temperature: // Upper 4 bits are stored in nibble 1, lower 8 bits are stored in nibble 2 // upper 4 bits of nibble 1 are reserved for other usages (e.g. battery status) sensor_id = b[0] & 0xFE; //first 6 bits and it changes each time it resets or change the battery battery_ok = (b[0] & 0x01); //1=ok, 0=low battery //next 2 bits are checksum //next two bits are identify ID (maybe channel ?) channel = (b[1] >> 4) & 0x03; temp_raw = (int16_t)(((b[1] & 0x0F) << 12) | (b[2] << 4)); temp_raw = temp_raw >> 4; temp_c = (temp_raw - 500) * 0.1f; // NOTE: there seems to be a 50 degree offset? if (temp_raw >= 0 && temp_raw <= 100) // NOTE: no other way to differentiate humidity from temperature? humidity = temp_raw; else humidity = -1; /* clang-format off */ data = data_make( "model", "", DATA_STRING, "Acurite-590TX", "id", "", DATA_INT, sensor_id, "battery_ok", "Battery", DATA_INT, battery_ok, "channel", "Channel", DATA_INT, channel, "humidity", "Humidity", DATA_COND, humidity != -1, DATA_INT, humidity, "temperature_C", "Temperature", DATA_COND, humidity == -1, DATA_FORMAT, "%.1f C", DATA_DOUBLE, temp_c, "mic", "Integrity", DATA_STRING, "PARITY", NULL); /* clang-format on */ decoder_output_data(decoder, data); return 1; }
0
244,321
GF_Err saio_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_SampleAuxiliaryInfoOffsetBox *ptr = (GF_SampleAuxiliaryInfoOffsetBox *) s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_write(s, bs); if (e) return e; if (ptr->flags & 1) { gf_bs_write_u32(bs, ptr->aux_info_type); gf_bs_write_u32(bs, ptr->aux_info_type_parameter); } gf_bs_write_u32(bs, ptr->entry_count); if (ptr->entry_count) { u32 i; if (ptr->sai_data) { if (ptr->sai_data->sai_offset) { if (ptr->version==0) { gf_bs_write_u32(bs, (u32) ptr->sai_data->sai_offset); } else { gf_bs_write_u64(bs, ptr->sai_data->sai_offset); } return GF_OK; } ptr->sai_data->saio_box = ptr; } //store position in bitstream before writing data - offsets can be NULL if a single offset is rewritten later on (cf senc_box_write) ptr->offset_first_offset_field = gf_bs_get_position(bs); if (ptr->version==0) { if (!ptr->offsets) { gf_bs_write_u32(bs, 0); } else { for (i=0; i<ptr->entry_count; i++) gf_bs_write_u32(bs, (u32) ptr->offsets[i]); } } else { if (!ptr->offsets) { gf_bs_write_u64(bs, 0); } else { for (i=0; i<ptr->entry_count; i++) gf_bs_write_u64(bs, ptr->offsets[i]); } } } return GF_OK; }
0
299,910
readconf_one_rewrite(uschar *p, int *existflags, BOOL isglobal) { rewrite_rule *next = store_get(sizeof(rewrite_rule)); next->next = NULL; next->key = string_dequote(&p); while (isspace(*p)) p++; if (*p == 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "missing rewrite replacement string"); next->flags = 0; next->replacement = string_dequote(&p); while (*p != 0) switch (*p++) { case ' ': case '\t': break; case 'q': next->flags |= rewrite_quit; break; case 'w': next->flags |= rewrite_whole; break; case 'h': next->flags |= rewrite_all_headers; break; case 's': next->flags |= rewrite_sender; break; case 'f': next->flags |= rewrite_from; break; case 't': next->flags |= rewrite_to; break; case 'c': next->flags |= rewrite_cc; break; case 'b': next->flags |= rewrite_bcc; break; case 'r': next->flags |= rewrite_replyto; break; case 'E': next->flags |= rewrite_all_envelope; break; case 'F': next->flags |= rewrite_envfrom; break; case 'T': next->flags |= rewrite_envto; break; case 'Q': next->flags |= rewrite_qualify; break; case 'R': next->flags |= rewrite_repeat; break; case 'S': next->flags |= rewrite_smtp; if (next->key[0] != '^' && Ustrncmp(next->key, "\\N^", 3) != 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "rewrite rule has the S flag but is not a regular expression"); break; default: log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "unknown rewrite flag character '%c' " "(could be missing quotes round replacement item)", p[-1]); break; } /* If no action flags are set, set all the "normal" rewrites. */ if ((next->flags & (rewrite_all | rewrite_smtp)) == 0) next->flags |= isglobal? rewrite_all : rewrite_all_headers; /* Remember which exist, for optimization, and return the rule */ *existflags |= next->flags; return next; }
0
326,090
bt_regexec_both( char_u *line, colnr_T col, // column to start looking for match proftime_T *tm, // timeout limit or NULL int *timed_out) // flag set on timeout or NULL { bt_regprog_T *prog; char_u *s; long retval = 0L; // Create "regstack" and "backpos" if they are not allocated yet. // We allocate *_INITIAL amount of bytes first and then set the grow size // to much bigger value to avoid many malloc calls in case of deep regular // expressions. if (regstack.ga_data == NULL) { // Use an item size of 1 byte, since we push different things // onto the regstack. ga_init2(&regstack, 1, REGSTACK_INITIAL); (void)ga_grow(&regstack, REGSTACK_INITIAL); regstack.ga_growsize = REGSTACK_INITIAL * 8; } if (backpos.ga_data == NULL) { ga_init2(&backpos, sizeof(backpos_T), BACKPOS_INITIAL); (void)ga_grow(&backpos, BACKPOS_INITIAL); backpos.ga_growsize = BACKPOS_INITIAL * 8; } if (REG_MULTI) { prog = (bt_regprog_T *)rex.reg_mmatch->regprog; line = reg_getline((linenr_T)0); rex.reg_startpos = rex.reg_mmatch->startpos; rex.reg_endpos = rex.reg_mmatch->endpos; } else { prog = (bt_regprog_T *)rex.reg_match->regprog; rex.reg_startp = rex.reg_match->startp; rex.reg_endp = rex.reg_match->endp; } // Be paranoid... if (prog == NULL || line == NULL) { iemsg(_(e_null_argument)); goto theend; } // Check validity of program. if (prog_magic_wrong()) goto theend; // If the start column is past the maximum column: no need to try. if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol) goto theend; // If pattern contains "\c" or "\C": overrule value of rex.reg_ic if (prog->regflags & RF_ICASE) rex.reg_ic = TRUE; else if (prog->regflags & RF_NOICASE) rex.reg_ic = FALSE; // If pattern contains "\Z" overrule value of rex.reg_icombine if (prog->regflags & RF_ICOMBINE) rex.reg_icombine = TRUE; // If there is a "must appear" string, look for it. if (prog->regmust != NULL) { int c; if (has_mbyte) c = (*mb_ptr2char)(prog->regmust); else c = *prog->regmust; s = line + col; // This is used very often, esp. for ":global". Use three versions of // the loop to avoid overhead of conditions. if (!rex.reg_ic && !has_mbyte) while ((s = vim_strbyte(s, c)) != NULL) { if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) break; // Found it. ++s; } else if (!rex.reg_ic || (!enc_utf8 && mb_char2len(c) > 1)) while ((s = vim_strchr(s, c)) != NULL) { if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) break; // Found it. MB_PTR_ADV(s); } else while ((s = cstrchr(s, c)) != NULL) { if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) break; // Found it. MB_PTR_ADV(s); } if (s == NULL) // Not present. goto theend; } rex.line = line; rex.lnum = 0; reg_toolong = FALSE; // Simplest case: Anchored match need be tried only once. if (prog->reganch) { int c; if (has_mbyte) c = (*mb_ptr2char)(rex.line + col); else c = rex.line[col]; if (prog->regstart == NUL || prog->regstart == c || (rex.reg_ic && (((enc_utf8 && utf_fold(prog->regstart) == utf_fold(c))) || (c < 255 && prog->regstart < 255 && MB_TOLOWER(prog->regstart) == MB_TOLOWER(c))))) retval = regtry(prog, col, tm, timed_out); else retval = 0; } else { #ifdef FEAT_RELTIME int tm_count = 0; #endif // Messy cases: unanchored match. while (!got_int) { if (prog->regstart != NUL) { // Skip until the char we know it must start with. // Used often, do some work to avoid call overhead. if (!rex.reg_ic && !has_mbyte) s = vim_strbyte(rex.line + col, prog->regstart); else s = cstrchr(rex.line + col, prog->regstart); if (s == NULL) { retval = 0; break; } col = (int)(s - rex.line); } // Check for maximum column to try. if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol) { retval = 0; break; } retval = regtry(prog, col, tm, timed_out); if (retval > 0) break; // if not currently on the first line, get it again if (rex.lnum != 0) { rex.lnum = 0; rex.line = reg_getline((linenr_T)0); } if (rex.line[col] == NUL) break; if (has_mbyte) col += (*mb_ptr2len)(rex.line + col); else ++col; #ifdef FEAT_RELTIME // Check for timeout once in a twenty times to avoid overhead. if (tm != NULL && ++tm_count == 20) { tm_count = 0; if (profile_passed_limit(tm)) { if (timed_out != NULL) *timed_out = TRUE; break; } } #endif } } theend: // Free "reg_tofree" when it's a bit big. // Free regstack and backpos if they are bigger than their initial size. if (reg_tofreelen > 400) VIM_CLEAR(reg_tofree); if (regstack.ga_maxlen > REGSTACK_INITIAL) ga_clear(&regstack); if (backpos.ga_maxlen > BACKPOS_INITIAL) ga_clear(&backpos); if (retval > 0) { // Make sure the end is never before the start. Can happen when \zs // and \ze are used. if (REG_MULTI) { lpos_T *start = &rex.reg_mmatch->startpos[0]; lpos_T *end = &rex.reg_mmatch->endpos[0]; if (end->lnum < start->lnum || (end->lnum == start->lnum && end->col < start->col)) rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0]; } else { if (rex.reg_match->endp[0] < rex.reg_match->startp[0]) rex.reg_match->endp[0] = rex.reg_match->startp[0]; } } return retval; }
0
198,004
void Compute(OpKernelContext* context) override { // boxes: [batch_size, num_anchors, q, 4] const Tensor& boxes = context->input(0); // scores: [batch_size, num_anchors, num_classes] const Tensor& scores = context->input(1); OP_REQUIRES( context, (boxes.dim_size(0) == scores.dim_size(0)), errors::InvalidArgument("boxes and scores must have same batch size")); // max_output_size: scalar const Tensor& max_output_size = context->input(2); OP_REQUIRES( context, TensorShapeUtils::IsScalar(max_output_size.shape()), errors::InvalidArgument("max_size_per_class must be 0-D, got shape ", max_output_size.shape().DebugString())); const int max_size_per_class = max_output_size.scalar<int>()(); // max_total_size: scalar const Tensor& max_total_size = context->input(3); OP_REQUIRES( context, TensorShapeUtils::IsScalar(max_total_size.shape()), errors::InvalidArgument("max_total_size must be 0-D, got shape ", max_total_size.shape().DebugString())); const int max_total_size_per_batch = max_total_size.scalar<int>()(); OP_REQUIRES(context, max_total_size_per_batch > 0, errors::InvalidArgument("max_total_size must be > 0")); // Throw warning when `max_total_size` is too large as it may cause OOM. if (max_total_size_per_batch > pow(10, 6)) { LOG(WARNING) << "Detected a large value for `max_total_size`. This may " << "cause OOM error. (max_total_size: " << max_total_size.scalar<int>()() << ")"; } // iou_threshold: scalar const Tensor& iou_threshold = context->input(4); OP_REQUIRES(context, TensorShapeUtils::IsScalar(iou_threshold.shape()), errors::InvalidArgument("iou_threshold must be 0-D, got shape ", iou_threshold.shape().DebugString())); const float iou_threshold_val = iou_threshold.scalar<float>()(); // score_threshold: scalar const Tensor& score_threshold = context->input(5); OP_REQUIRES( context, TensorShapeUtils::IsScalar(score_threshold.shape()), errors::InvalidArgument("score_threshold must be 0-D, got shape ", score_threshold.shape().DebugString())); const float score_threshold_val = score_threshold.scalar<float>()(); OP_REQUIRES(context, iou_threshold_val >= 0 && iou_threshold_val <= 1, errors::InvalidArgument("iou_threshold must be in [0, 1]")); int num_boxes = 0; const int num_classes = scores.dim_size(2); ParseAndCheckCombinedNMSBoxSizes(context, boxes, &num_boxes, num_classes); CheckCombinedNMSScoreSizes(context, num_boxes, scores); if (!context->status().ok()) { return; } BatchedNonMaxSuppressionOp(context, boxes, scores, num_boxes, max_size_per_class, max_total_size_per_batch, score_threshold_val, iou_threshold_val, pad_per_class_, clip_boxes_); }
1
90,145
virtual NetworkIPConfigVector GetIPConfigs(const std::string& device_path, std::string* hardware_address) { hardware_address->clear(); return NetworkIPConfigVector(); }
0
265,437
int sqfs_exists(const char *filename) { struct fs_dir_stream *dirsp = NULL; struct squashfs_dir_stream *dirs; char *dir, *file; struct fs_dirent *dent; int ret; sqfs_split_path(&file, &dir, filename); /* * sqfs_opendir will uncompress inode and directory tables, and will * return a pointer to the directory that contains the requested file. */ ret = sqfs_opendir(dir, &dirsp); if (ret) { ret = -EINVAL; goto free_strings; } dirs = (struct squashfs_dir_stream *)dirsp; while (!sqfs_readdir(dirsp, &dent)) { ret = strcmp(dent->name, file); if (!ret) break; free(dirs->entry); dirs->entry = NULL; } sqfs_closedir(dirsp); free_strings: free(dir); free(file); return ret == 0; }
0
312,517
qf_clean_dir_stack(struct dir_stack_T **stackptr) { struct dir_stack_T *ds_ptr; while ((ds_ptr = *stackptr) != NULL) { *stackptr = (*stackptr)->next; vim_free(ds_ptr->dirname); vim_free(ds_ptr); } }
0
294,467
time_to_date(VALUE self) { VALUE y, nth, ret; int ry, m, d; y = f_year(self); m = FIX2INT(f_mon(self)); d = FIX2INT(f_mday(self)); decode_year(y, -1, &nth, &ry); ret = d_simple_new_internal(cDate, nth, 0, GREGORIAN, ry, m, d, HAVE_CIVIL); { get_d1(ret); set_sg(dat, DEFAULT_SG); } return ret; }
0
247,135
GF_Filter *gf_fs_get_filter(GF_FilterSession *session, u32 idx) { return session ? gf_list_get(session->filters, idx) : NULL; }
0
314,503
PJ_DEF(pj_status_t) pjmedia_sdp_validate(const pjmedia_sdp_session *sdp) { return pjmedia_sdp_validate2(sdp, PJ_TRUE); }
0
405,410
static inline bool xfrm_policy_mark_match(const struct xfrm_mark *mark, struct xfrm_policy *pol) { return mark->v == pol->mark.v && mark->m == pol->mark.m; }
0
476,118
void composite_suspend(struct usb_gadget *gadget) { struct usb_composite_dev *cdev = get_gadget_data(gadget); struct usb_function *f; /* REVISIT: should we have config level * suspend/resume callbacks? */ DBG(cdev, "suspend\n"); if (cdev->config) { list_for_each_entry(f, &cdev->config->functions, list) { if (f->suspend) f->suspend(f); } } if (cdev->driver->suspend) cdev->driver->suspend(cdev); cdev->suspended = 1; usb_gadget_set_selfpowered(gadget); usb_gadget_vbus_draw(gadget, 2); }
0
473,901
utf32le_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc ARG_UNUSED) { UChar* p = buf; *p++ = (UChar ) (code & 0xff); *p++ = (UChar )((code & 0xff00) >> 8); *p++ = (UChar )((code & 0xff0000) >>16); *p++ = (UChar )((code & 0xff000000) >>24); return 4; }
0
224,744
GF_Err meta_box_write(GF_Box *s, GF_BitStream *bs) { return gf_isom_full_box_write(s, bs); }
0
337,848
struct sctp_chunk *sctp_make_strreset_req( const struct sctp_association *asoc, __u16 stream_num, __be16 *stream_list, bool out, bool in) { __u16 stream_len = stream_num * sizeof(__u16); struct sctp_strreset_outreq outreq; struct sctp_strreset_inreq inreq; struct sctp_chunk *retval; __u16 outlen, inlen; outlen = (sizeof(outreq) + stream_len) * out; inlen = (sizeof(inreq) + stream_len) * in; retval = sctp_make_reconf(asoc, SCTP_PAD4(outlen) + SCTP_PAD4(inlen)); if (!retval) return NULL; if (outlen) { outreq.param_hdr.type = SCTP_PARAM_RESET_OUT_REQUEST; outreq.param_hdr.length = htons(outlen); outreq.request_seq = htonl(asoc->strreset_outseq); outreq.response_seq = htonl(asoc->strreset_inseq - 1); outreq.send_reset_at_tsn = htonl(asoc->next_tsn - 1); sctp_addto_chunk(retval, sizeof(outreq), &outreq); if (stream_len) sctp_addto_chunk(retval, stream_len, stream_list); } if (inlen) { inreq.param_hdr.type = SCTP_PARAM_RESET_IN_REQUEST; inreq.param_hdr.length = htons(inlen); inreq.request_seq = htonl(asoc->strreset_outseq + out); sctp_addto_chunk(retval, sizeof(inreq), &inreq); if (stream_len) sctp_addto_chunk(retval, stream_len, stream_list); } return retval; }
0
310,111
ClrUpdate(NCURSES_SP_DCL0) { TR(TRACE_UPDATE, (T_CALLED("ClrUpdate"))); if (0 != SP_PARM) { int i; NCURSES_CH_T blank = ClrBlank(NCURSES_SP_ARGx StdScreen(SP_PARM)); int nonempty = min(screen_lines(SP_PARM), NewScreen(SP_PARM)->_maxy + 1); ClearScreen(NCURSES_SP_ARGx blank); TR(TRACE_UPDATE, ("updating screen from scratch")); nonempty = ClrBottom(NCURSES_SP_ARGx nonempty); for (i = 0; i < nonempty; i++) TransformLine(NCURSES_SP_ARGx i); } TR(TRACE_UPDATE, (T_RETURN(""))); }
0
317,125
static int selinux_vm_enough_memory(struct mm_struct *mm, long pages) { int rc, cap_sys_admin = 0; rc = cred_has_capability(current_cred(), CAP_SYS_ADMIN, CAP_OPT_NOAUDIT, true); if (rc == 0) cap_sys_admin = 1; return cap_sys_admin; }
0
308,189
static void fastrpc_unmap_dma_buf(struct dma_buf_attachment *attach, struct sg_table *table, enum dma_data_direction dir) { dma_unmap_sg(attach->dev, table->sgl, table->nents, dir); }
0
338,147
bool WasmBinaryBuilder::maybeVisitSIMDShift(Expression*& out, uint32_t code) { SIMDShift* curr; switch (code) { case BinaryConsts::I8x16Shl: curr = allocator.alloc<SIMDShift>(); curr->op = ShlVecI8x16; break; case BinaryConsts::I8x16ShrS: curr = allocator.alloc<SIMDShift>(); curr->op = ShrSVecI8x16; break; case BinaryConsts::I8x16ShrU: curr = allocator.alloc<SIMDShift>(); curr->op = ShrUVecI8x16; break; case BinaryConsts::I16x8Shl: curr = allocator.alloc<SIMDShift>(); curr->op = ShlVecI16x8; break; case BinaryConsts::I16x8ShrS: curr = allocator.alloc<SIMDShift>(); curr->op = ShrSVecI16x8; break; case BinaryConsts::I16x8ShrU: curr = allocator.alloc<SIMDShift>(); curr->op = ShrUVecI16x8; break; case BinaryConsts::I32x4Shl: curr = allocator.alloc<SIMDShift>(); curr->op = ShlVecI32x4; break; case BinaryConsts::I32x4ShrS: curr = allocator.alloc<SIMDShift>(); curr->op = ShrSVecI32x4; break; case BinaryConsts::I32x4ShrU: curr = allocator.alloc<SIMDShift>(); curr->op = ShrUVecI32x4; break; case BinaryConsts::I64x2Shl: curr = allocator.alloc<SIMDShift>(); curr->op = ShlVecI64x2; break; case BinaryConsts::I64x2ShrS: curr = allocator.alloc<SIMDShift>(); curr->op = ShrSVecI64x2; break; case BinaryConsts::I64x2ShrU: curr = allocator.alloc<SIMDShift>(); curr->op = ShrUVecI64x2; break; default: return false; } curr->shift = popNonVoidExpression(); curr->vec = popNonVoidExpression(); curr->finalize(); out = curr; return true; }
0
244,266
GF_Err gitn_box_size(GF_Box *s) { u32 i; GroupIdToNameBox *ptr = (GroupIdToNameBox *)s; ptr->size += 2; for (i=0; i<ptr->nb_entries; i++) { ptr->size += 5; if (ptr->entries[i].name) ptr->size += strlen(ptr->entries[i].name); } return GF_OK; }
0
242,997
static size_t ssl_get_maximum_datagram_size( mbedtls_ssl_context const *ssl ) { size_t mtu = mbedtls_ssl_get_current_mtu( ssl ); #if defined(MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH) size_t out_buf_len = ssl->out_buf_len; #else size_t out_buf_len = MBEDTLS_SSL_OUT_BUFFER_LEN; #endif if( mtu != 0 && mtu < out_buf_len ) return( mtu ); return( out_buf_len ); }
0
386,529
void DL_Dxf::writeXLine(DL_WriterA& dw, const DL_XLineData& data, const DL_Attributes& attrib) { dw.entity("XLINE"); if (version==DL_VERSION_2000) { dw.dxfString(100, "AcDbEntity"); } dw.entityAttributes(attrib); if (version==DL_VERSION_2000) { dw.dxfString(100, "AcDbLine"); } dw.coord(DL_LINE_START_CODE, data.bx, data.by, data.bz); dw.coord(DL_LINE_END_CODE, data.dx, data.dy, data.dz); }
0
326,593
check_symlinks(struct archive_write_disk *a) { struct archive_string error_string; int error_number; int rc; archive_string_init(&error_string); rc = check_symlinks_fsobj(a->name, &error_number, &error_string, a->flags, 0); if (rc != ARCHIVE_OK) { archive_set_error(&a->archive, error_number, "%s", error_string.s); } archive_string_free(&error_string); a->pst = NULL; /* to be safe */ return rc; }
0
226,144
GF_Err trak_box_read(GF_Box *s, GF_BitStream *bs) { GF_Err e; u32 i; GF_TrackBox *ptr = (GF_TrackBox *)s; e = gf_isom_box_array_read(s, bs); if (e) return e; e = gf_isom_check_sample_desc(ptr); if (e) return e; if (!ptr->Header) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Missing TrackHeaderBox\n")); return GF_ISOM_INVALID_FILE; } if (!ptr->Media) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Missing MediaBox\n")); return GF_ISOM_INVALID_FILE; } if (!ptr->Media->information || !ptr->Media->information->sampleTable) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Invalid MediaBox\n")); return GF_ISOM_INVALID_FILE; } if (!ptr->Media->information->sampleTable->SampleSize || (ptr->Media->information->sampleTable->SampleSize->sampleCount==0)) { if (ptr->Header->initial_duration) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Track with no samples but duration defined, ignoring duration\n")); ptr->Header->initial_duration = 0; } } for (i=0; i<gf_list_count(ptr->Media->information->sampleTable->child_boxes); i++) { GF_Box *a = gf_list_get(ptr->Media->information->sampleTable->child_boxes, i); if ((a->type ==GF_ISOM_BOX_TYPE_UUID) && (((GF_UUIDBox *)a)->internal_4cc == GF_ISOM_BOX_UUID_PSEC)) { ptr->sample_encryption = (struct __sample_encryption_box *) a; break; } else if (a->type == GF_ISOM_BOX_TYPE_SENC) { ptr->sample_encryption = (struct __sample_encryption_box *)a; break; } } return e;
0
211,113
static void atusb_disconnect(struct usb_interface *interface) { struct atusb *atusb = usb_get_intfdata(interface); dev_dbg(&atusb->usb_dev->dev, "%s\n", __func__); atusb->shutdown = 1; cancel_delayed_work_sync(&atusb->work); usb_kill_anchored_urbs(&atusb->rx_urbs); atusb_free_urbs(atusb); usb_kill_urb(atusb->tx_urb); usb_free_urb(atusb->tx_urb); ieee802154_unregister_hw(atusb->hw); ieee802154_free_hw(atusb->hw); usb_set_intfdata(interface, NULL); usb_put_dev(atusb->usb_dev); pr_debug("%s done\n", __func__); }
1
293,939
ex_retab(exarg_T *eap) { linenr_T lnum; int got_tab = FALSE; long num_spaces = 0; long num_tabs; long len; long col; long vcol; long start_col = 0; // For start of white-space string long start_vcol = 0; // For start of white-space string long old_len; char_u *ptr; char_u *new_line = (char_u *)1; // init to non-NULL int did_undo; // called u_save for current line #ifdef FEAT_VARTABS int *new_vts_array = NULL; char_u *new_ts_str; // string value of tab argument #else int temp; int new_ts; #endif int save_list; linenr_T first_line = 0; // first changed line linenr_T last_line = 0; // last changed line save_list = curwin->w_p_list; curwin->w_p_list = 0; // don't want list mode here #ifdef FEAT_VARTABS new_ts_str = eap->arg; if (tabstop_set(eap->arg, &new_vts_array) == FAIL) return; while (vim_isdigit(*(eap->arg)) || *(eap->arg) == ',') ++(eap->arg); // This ensures that either new_vts_array and new_ts_str are freshly // allocated, or new_vts_array points to an existing array and new_ts_str // is null. if (new_vts_array == NULL) { new_vts_array = curbuf->b_p_vts_array; new_ts_str = NULL; } else new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str); #else ptr = eap->arg; new_ts = getdigits(&ptr); if (new_ts < 0 && *eap->arg == '-') { emsg(_(e_argument_must_be_positive)); return; } if (new_ts < 0 || new_ts > TABSTOP_MAX) { semsg(_(e_invalid_argument_str), eap->arg); return; } if (new_ts == 0) new_ts = curbuf->b_p_ts; #endif for (lnum = eap->line1; !got_int && lnum <= eap->line2; ++lnum) { ptr = ml_get(lnum); col = 0; vcol = 0; did_undo = FALSE; for (;;) { if (VIM_ISWHITE(ptr[col])) { if (!got_tab && num_spaces == 0) { // First consecutive white-space start_vcol = vcol; start_col = col; } if (ptr[col] == ' ') num_spaces++; else got_tab = TRUE; } else { if (got_tab || (eap->forceit && num_spaces > 1)) { // Retabulate this string of white-space // len is virtual length of white string len = num_spaces = vcol - start_vcol; num_tabs = 0; if (!curbuf->b_p_et) { #ifdef FEAT_VARTABS int t, s; tabstop_fromto(start_vcol, vcol, curbuf->b_p_ts, new_vts_array, &t, &s); num_tabs = t; num_spaces = s; #else temp = new_ts - (start_vcol % new_ts); if (num_spaces >= temp) { num_spaces -= temp; num_tabs++; } num_tabs += num_spaces / new_ts; num_spaces -= (num_spaces / new_ts) * new_ts; #endif } if (curbuf->b_p_et || got_tab || (num_spaces + num_tabs < len)) { if (did_undo == FALSE) { did_undo = TRUE; if (u_save((linenr_T)(lnum - 1), (linenr_T)(lnum + 1)) == FAIL) { new_line = NULL; // flag out-of-memory break; } } // len is actual number of white characters used len = num_spaces + num_tabs; old_len = (long)STRLEN(ptr); new_line = alloc(old_len - col + start_col + len + 1); if (new_line == NULL) break; if (start_col > 0) mch_memmove(new_line, ptr, (size_t)start_col); mch_memmove(new_line + start_col + len, ptr + col, (size_t)(old_len - col + 1)); ptr = new_line + start_col; for (col = 0; col < len; col++) ptr[col] = (col < num_tabs) ? '\t' : ' '; if (ml_replace(lnum, new_line, FALSE) == OK) // "new_line" may have been copied new_line = curbuf->b_ml.ml_line_ptr; if (first_line == 0) first_line = lnum; last_line = lnum; ptr = new_line; col = start_col + len; } } got_tab = FALSE; num_spaces = 0; } if (ptr[col] == NUL) break; vcol += chartabsize(ptr + col, (colnr_T)vcol); if (vcol >= MAXCOL) { emsg(_(e_resulting_text_too_long)); break; } if (has_mbyte) col += (*mb_ptr2len)(ptr + col); else ++col; } if (new_line == NULL) // out of memory break; line_breakcheck(); } if (got_int) emsg(_(e_interrupted)); #ifdef FEAT_VARTABS // If a single value was given then it can be considered equal to // either the value of 'tabstop' or the value of 'vartabstop'. if (tabstop_count(curbuf->b_p_vts_array) == 0 && tabstop_count(new_vts_array) == 1 && curbuf->b_p_ts == tabstop_first(new_vts_array)) ; // not changed else if (tabstop_count(curbuf->b_p_vts_array) > 0 && tabstop_eq(curbuf->b_p_vts_array, new_vts_array)) ; // not changed else redraw_curbuf_later(NOT_VALID); #else if (curbuf->b_p_ts != new_ts) redraw_curbuf_later(NOT_VALID); #endif if (first_line != 0) changed_lines(first_line, 0, last_line + 1, 0L); curwin->w_p_list = save_list; // restore 'list' #ifdef FEAT_VARTABS if (new_ts_str != NULL) // set the new tabstop { // If 'vartabstop' is in use or if the value given to retab has more // than one tabstop then update 'vartabstop'. int *old_vts_ary = curbuf->b_p_vts_array; if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1) { set_string_option_direct((char_u *)"vts", -1, new_ts_str, OPT_FREE|OPT_LOCAL, 0); curbuf->b_p_vts_array = new_vts_array; vim_free(old_vts_ary); } else { // 'vartabstop' wasn't in use and a single value was given to // retab then update 'tabstop'. curbuf->b_p_ts = tabstop_first(new_vts_array); vim_free(new_vts_array); } vim_free(new_ts_str); } #else curbuf->b_p_ts = new_ts; #endif coladvance(curwin->w_curswant); u_clearline(); }
0
261,187
static int MqttClient_HandlePacket(MqttClient* client, MqttPacketType packet_type, void *packet_obj, int timeout_ms) { int rc = MQTT_CODE_SUCCESS; MqttQoS packet_qos = MQTT_QOS_0; word16 packet_id = 0; if (client == NULL || packet_obj == NULL) { return MQTT_CODE_ERROR_BAD_ARG; } switch (packet_type) { case MQTT_PACKET_TYPE_CONNECT_ACK: { rc = MqttClient_DecodePacket(client, client->rx_buf, client->packet.buf_len, packet_obj, &packet_type, &packet_qos, &packet_id); break; } case MQTT_PACKET_TYPE_PUBLISH: { MqttPublish *publish = (MqttPublish*)packet_obj; MqttPacketType resp_type; if (publish->stat == MQTT_MSG_BEGIN || publish->stat == MQTT_MSG_READ) { rc = MqttClient_DecodePacket(client, client->rx_buf, client->packet.buf_len, packet_obj, &packet_type, &packet_qos, &packet_id); if (rc <= 0) { return rc; } } else { /* packet ID and QoS were already established */ packet_id = client->msg.publish.packet_id; packet_qos = client->msg.publish.qos; } rc = MqttClient_Publish_ReadPayload(client, publish, timeout_ms); if (rc < 0) { break; } /* Handle QoS */ if (packet_qos == MQTT_QOS_0) { /* we are done, no QoS response */ break; } /* Determine packet type to write */ resp_type = (packet_qos == MQTT_QOS_1) ? MQTT_PACKET_TYPE_PUBLISH_ACK : MQTT_PACKET_TYPE_PUBLISH_REC; publish->resp.packet_id = packet_id; #ifdef WOLFMQTT_MULTITHREAD /* Lock send socket mutex */ rc = wm_SemLock(&client->lockSend); if (rc != 0) { return rc; } #endif /* Encode publish response */ rc = MqttEncode_PublishResp(client->tx_buf, client->tx_buf_len, resp_type, &publish->resp); #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d," " QoS %d", rc, MqttPacket_TypeDesc(resp_type), resp_type, packet_id, packet_qos); #endif if (rc <= 0) { #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif return rc; } client->packet.buf_len = rc; /* Send publish response packet */ rc = MqttPacket_Write(client, client->tx_buf, client->packet.buf_len); #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif break; } case MQTT_PACKET_TYPE_PUBLISH_ACK: case MQTT_PACKET_TYPE_PUBLISH_REC: case MQTT_PACKET_TYPE_PUBLISH_REL: case MQTT_PACKET_TYPE_PUBLISH_COMP: { MqttPublishResp pubRespObj, *publish_resp = &pubRespObj; XMEMSET(publish_resp, 0, sizeof(MqttPublishResp)); rc = MqttClient_DecodePacket(client, client->rx_buf, client->packet.buf_len, publish_resp, &packet_type, &packet_qos, &packet_id); if (rc <= 0) { return rc; } /* If publish Received or Release QoS then proceed */ if (packet_type != MQTT_PACKET_TYPE_PUBLISH_REC && packet_type != MQTT_PACKET_TYPE_PUBLISH_REL) { break; } #ifdef WOLFMQTT_MULTITHREAD /* Lock send socket mutex */ rc = wm_SemLock(&client->lockSend); if (rc != 0) { return rc; } #endif /* Encode publish response */ publish_resp->packet_id = packet_id; packet_type = (MqttPacketType)((int)packet_type+1); /* next ack */ #ifdef WOLFMQTT_V5 #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("\tPublish response: reason code %d, Type %s (%d)," " ID %d, QoS %d", publish_resp->reason_code, MqttPacket_TypeDesc(packet_type), packet_type, packet_id, packet_qos); #endif /* return reason code to caller */ if (packet_obj != NULL) { MqttPublishResp* caller_rsp = (MqttPublishResp*)packet_obj; caller_rsp->reason_code = publish_resp->reason_code; } /* Publish QoS response needs success reason code, * otherwise will cause disconnect at broker */ publish_resp->reason_code = MQTT_REASON_SUCCESS; #endif rc = MqttEncode_PublishResp(client->tx_buf, client->tx_buf_len, packet_type, publish_resp); #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d," " QoS %d", rc, MqttPacket_TypeDesc(packet_type), packet_type, packet_id, packet_qos); #endif if (rc <= 0) { #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif return rc; } client->packet.buf_len = rc; /* Send publish response packet */ rc = MqttPacket_Write(client, client->tx_buf, client->packet.buf_len); #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif break; } case MQTT_PACKET_TYPE_SUBSCRIBE_ACK: { rc = MqttClient_DecodePacket(client, client->rx_buf, client->packet.buf_len, packet_obj, &packet_type, &packet_qos, &packet_id); break; } case MQTT_PACKET_TYPE_UNSUBSCRIBE_ACK: { rc = MqttClient_DecodePacket(client, client->rx_buf, client->packet.buf_len, packet_obj, &packet_type, &packet_qos, &packet_id); break; } case MQTT_PACKET_TYPE_PING_RESP: { rc = MqttClient_DecodePacket(client, client->rx_buf, client->packet.buf_len, packet_obj, &packet_type, &packet_qos, &packet_id); break; } case MQTT_PACKET_TYPE_AUTH: { #ifdef WOLFMQTT_V5 rc = MqttClient_DecodePacket(client, client->rx_buf, client->packet.buf_len, packet_obj, &packet_type, &packet_qos, &packet_id); #else rc = MQTT_CODE_ERROR_PACKET_TYPE; #endif break; } case MQTT_PACKET_TYPE_DISCONNECT: { #ifdef WOLFMQTT_V5 rc = MqttClient_DecodePacket(client, client->rx_buf, client->packet.buf_len, packet_obj, &packet_type, &packet_qos, &packet_id); #else rc = MQTT_CODE_ERROR_PACKET_TYPE; #endif break; } case MQTT_PACKET_TYPE_CONNECT: case MQTT_PACKET_TYPE_SUBSCRIBE: case MQTT_PACKET_TYPE_UNSUBSCRIBE: case MQTT_PACKET_TYPE_PING_REQ: case MQTT_PACKET_TYPE_ANY: case MQTT_PACKET_TYPE_RESERVED: default: /* these types are only sent from client and should not be sent * by broker */ rc = MQTT_CODE_ERROR_PACKET_TYPE; break; } /* switch (packet_type) */ #ifdef WOLFMQTT_DEBUG_CLIENT if (rc < 0) { PRINTF("MqttClient_HandlePacket: Rc %d, Type %s (%d), QoS %d, ID %d", rc, MqttPacket_TypeDesc(packet_type), packet_type, packet_qos, packet_id); } #endif return rc; }
0
448,553
struct bgp_notify bgp_notify_decapsulate_hard_reset(struct bgp_notify *notify) { struct bgp_notify bn = {}; bn.code = notify->raw_data[0]; bn.subcode = notify->raw_data[1]; bn.length = notify->length - 2; bn.raw_data = XMALLOC(MTYPE_BGP_NOTIFICATION, bn.length); memcpy(bn.raw_data, notify->raw_data + 2, bn.length); return bn; }
0
211,103
_fr_window_ask_overwrite_dialog (OverwriteData *odata) { if ((odata->edata->overwrite == FR_OVERWRITE_ASK) && (odata->current_file != NULL)) { const char *base_name; GFile *destination; base_name = _g_path_get_relative_basename ((char *) odata->current_file->data, odata->edata->base_dir, odata->edata->junk_paths); destination = g_file_get_child (odata->edata->destination, base_name); g_file_query_info_async (destination, G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, G_PRIORITY_DEFAULT, odata->window->priv->cancellable, query_info_ready_for_overwrite_dialog_cb, odata); g_object_unref (destination); return; } if (odata->edata->file_list != NULL) { /* speed optimization: passing NULL when extracting all the * files is faster if the command supports the * propCanExtractAll property. */ if (odata->extract_all) { _g_string_list_free (odata->edata->file_list); odata->edata->file_list = NULL; } odata->edata->overwrite = FR_OVERWRITE_YES; _fr_window_archive_extract_from_edata (odata->window, odata->edata); } else { GtkWidget *d; d = _gtk_message_dialog_new (GTK_WINDOW (odata->window), 0, GTK_STOCK_DIALOG_WARNING, _("Extraction not performed"), NULL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_OK); fr_window_show_error_dialog (odata->window, d, GTK_WINDOW (odata->window), _("Extraction not performed")); fr_window_stop_batch (odata->window); } g_free (odata); }
1
326,119
regmatch( char_u *scan, // Current node. proftime_T *tm UNUSED, // timeout limit or NULL int *timed_out UNUSED) // flag set on timeout or NULL { char_u *next; // Next node. int op; int c; regitem_T *rp; int no; int status; // one of the RA_ values: #ifdef FEAT_RELTIME int tm_count = 0; #endif // Make "regstack" and "backpos" empty. They are allocated and freed in // bt_regexec_both() to reduce malloc()/free() calls. regstack.ga_len = 0; backpos.ga_len = 0; // Repeat until "regstack" is empty. for (;;) { // Some patterns may take a long time to match, e.g., "\([a-z]\+\)\+Q". // Allow interrupting them with CTRL-C. fast_breakcheck(); #ifdef DEBUG if (scan != NULL && regnarrate) { mch_errmsg((char *)regprop(scan)); mch_errmsg("(\n"); } #endif // Repeat for items that can be matched sequentially, without using the // regstack. for (;;) { if (got_int || scan == NULL) { status = RA_FAIL; break; } #ifdef FEAT_RELTIME // Check for timeout once in a 100 times to avoid overhead. if (tm != NULL && ++tm_count == 100) { tm_count = 0; if (profile_passed_limit(tm)) { if (timed_out != NULL) *timed_out = TRUE; status = RA_FAIL; break; } } #endif status = RA_CONT; #ifdef DEBUG if (regnarrate) { mch_errmsg((char *)regprop(scan)); mch_errmsg("...\n"); # ifdef FEAT_SYN_HL if (re_extmatch_in != NULL) { int i; mch_errmsg(_("External submatches:\n")); for (i = 0; i < NSUBEXP; i++) { mch_errmsg(" \""); if (re_extmatch_in->matches[i] != NULL) mch_errmsg((char *)re_extmatch_in->matches[i]); mch_errmsg("\"\n"); } } # endif } #endif next = regnext(scan); op = OP(scan); // Check for character class with NL added. if (!rex.reg_line_lbr && WITH_NL(op) && REG_MULTI && *rex.input == NUL && rex.lnum <= rex.reg_maxline) { reg_nextline(); } else if (rex.reg_line_lbr && WITH_NL(op) && *rex.input == '\n') { ADVANCE_REGINPUT(); } else { if (WITH_NL(op)) op -= ADD_NL; if (has_mbyte) c = (*mb_ptr2char)(rex.input); else c = *rex.input; switch (op) { case BOL: if (rex.input != rex.line) status = RA_NOMATCH; break; case EOL: if (c != NUL) status = RA_NOMATCH; break; case RE_BOF: // We're not at the beginning of the file when below the first // line where we started, not at the start of the line or we // didn't start at the first line of the buffer. if (rex.lnum != 0 || rex.input != rex.line || (REG_MULTI && rex.reg_firstlnum > 1)) status = RA_NOMATCH; break; case RE_EOF: if (rex.lnum != rex.reg_maxline || c != NUL) status = RA_NOMATCH; break; case CURSOR: // Check if the buffer is in a window and compare the // rex.reg_win->w_cursor position to the match position. if (rex.reg_win == NULL || (rex.lnum + rex.reg_firstlnum != rex.reg_win->w_cursor.lnum) || ((colnr_T)(rex.input - rex.line) != rex.reg_win->w_cursor.col)) status = RA_NOMATCH; break; case RE_MARK: // Compare the mark position to the match position. { int mark = OPERAND(scan)[0]; int cmp = OPERAND(scan)[1]; pos_T *pos; size_t col = REG_MULTI ? rex.input - rex.line : 0; pos = getmark_buf(rex.reg_buf, mark, FALSE); // Line may have been freed, get it again. if (REG_MULTI) { rex.line = reg_getline(rex.lnum); rex.input = rex.line + col; } if (pos == NULL // mark doesn't exist || pos->lnum <= 0) // mark isn't set in reg_buf { status = RA_NOMATCH; } else { colnr_T pos_col = pos->lnum == rex.lnum + rex.reg_firstlnum && pos->col == MAXCOL ? (colnr_T)STRLEN(reg_getline( pos->lnum - rex.reg_firstlnum)) : pos->col; if ((pos->lnum == rex.lnum + rex.reg_firstlnum ? (pos_col == (colnr_T)(rex.input - rex.line) ? (cmp == '<' || cmp == '>') : (pos_col < (colnr_T)(rex.input - rex.line) ? cmp != '>' : cmp != '<')) : (pos->lnum < rex.lnum + rex.reg_firstlnum ? cmp != '>' : cmp != '<'))) status = RA_NOMATCH; } } break; case RE_VISUAL: if (!reg_match_visual()) status = RA_NOMATCH; break; case RE_LNUM: if (!REG_MULTI || !re_num_cmp((long_u)(rex.lnum + rex.reg_firstlnum), scan)) status = RA_NOMATCH; break; case RE_COL: if (!re_num_cmp((long_u)(rex.input - rex.line) + 1, scan)) status = RA_NOMATCH; break; case RE_VCOL: if (!re_num_cmp((long_u)win_linetabsize( rex.reg_win == NULL ? curwin : rex.reg_win, rex.line, (colnr_T)(rex.input - rex.line)) + 1, scan)) status = RA_NOMATCH; break; case BOW: // \<word; rex.input points to w if (c == NUL) // Can't match at end of line status = RA_NOMATCH; else if (has_mbyte) { int this_class; // Get class of current and previous char (if it exists). this_class = mb_get_class_buf(rex.input, rex.reg_buf); if (this_class <= 1) status = RA_NOMATCH; // not on a word at all else if (reg_prev_class() == this_class) status = RA_NOMATCH; // previous char is in same word } else { if (!vim_iswordc_buf(c, rex.reg_buf) || (rex.input > rex.line && vim_iswordc_buf(rex.input[-1], rex.reg_buf))) status = RA_NOMATCH; } break; case EOW: // word\>; rex.input points after d if (rex.input == rex.line) // Can't match at start of line status = RA_NOMATCH; else if (has_mbyte) { int this_class, prev_class; // Get class of current and previous char (if it exists). this_class = mb_get_class_buf(rex.input, rex.reg_buf); prev_class = reg_prev_class(); if (this_class == prev_class || prev_class == 0 || prev_class == 1) status = RA_NOMATCH; } else { if (!vim_iswordc_buf(rex.input[-1], rex.reg_buf) || (rex.input[0] != NUL && vim_iswordc_buf(c, rex.reg_buf))) status = RA_NOMATCH; } break; // Matched with EOW case ANY: // ANY does not match new lines. if (c == NUL) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case IDENT: if (!vim_isIDc(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case SIDENT: if (VIM_ISDIGIT(*rex.input) || !vim_isIDc(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case KWORD: if (!vim_iswordp_buf(rex.input, rex.reg_buf)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case SKWORD: if (VIM_ISDIGIT(*rex.input) || !vim_iswordp_buf(rex.input, rex.reg_buf)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case FNAME: if (!vim_isfilec(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case SFNAME: if (VIM_ISDIGIT(*rex.input) || !vim_isfilec(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case PRINT: if (!vim_isprintc(PTR2CHAR(rex.input))) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case SPRINT: if (VIM_ISDIGIT(*rex.input) || !vim_isprintc(PTR2CHAR(rex.input))) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case WHITE: if (!VIM_ISWHITE(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case NWHITE: if (c == NUL || VIM_ISWHITE(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case DIGIT: if (!ri_digit(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case NDIGIT: if (c == NUL || ri_digit(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case HEX: if (!ri_hex(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case NHEX: if (c == NUL || ri_hex(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case OCTAL: if (!ri_octal(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case NOCTAL: if (c == NUL || ri_octal(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case WORD: if (!ri_word(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case NWORD: if (c == NUL || ri_word(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case HEAD: if (!ri_head(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case NHEAD: if (c == NUL || ri_head(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case ALPHA: if (!ri_alpha(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case NALPHA: if (c == NUL || ri_alpha(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case LOWER: if (!ri_lower(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case NLOWER: if (c == NUL || ri_lower(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case UPPER: if (!ri_upper(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case NUPPER: if (c == NUL || ri_upper(c)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case EXACTLY: { int len; char_u *opnd; opnd = OPERAND(scan); // Inline the first byte, for speed. if (*opnd != *rex.input && (!rex.reg_ic || (!enc_utf8 && MB_TOLOWER(*opnd) != MB_TOLOWER(*rex.input)))) status = RA_NOMATCH; else if (*opnd == NUL) { // match empty string always works; happens when "~" is // empty. } else { if (opnd[1] == NUL && !(enc_utf8 && rex.reg_ic)) { len = 1; // matched a single byte above } else { // Need to match first byte again for multi-byte. len = (int)STRLEN(opnd); if (cstrncmp(opnd, rex.input, &len) != 0) status = RA_NOMATCH; } // Check for following composing character, unless %C // follows (skips over all composing chars). if (status != RA_NOMATCH && enc_utf8 && UTF_COMPOSINGLIKE(rex.input, rex.input + len) && !rex.reg_icombine && OP(next) != RE_COMPOSING) { // raaron: This code makes a composing character get // ignored, which is the correct behavior (sometimes) // for voweled Hebrew texts. status = RA_NOMATCH; } if (status != RA_NOMATCH) rex.input += len; } } break; case ANYOF: case ANYBUT: if (c == NUL) status = RA_NOMATCH; else if ((cstrchr(OPERAND(scan), c) == NULL) == (op == ANYOF)) status = RA_NOMATCH; else ADVANCE_REGINPUT(); break; case MULTIBYTECODE: if (has_mbyte) { int i, len; char_u *opnd; int opndc = 0, inpc; opnd = OPERAND(scan); // Safety check (just in case 'encoding' was changed since // compiling the program). if ((len = (*mb_ptr2len)(opnd)) < 2) { status = RA_NOMATCH; break; } if (enc_utf8) opndc = utf_ptr2char(opnd); if (enc_utf8 && utf_iscomposing(opndc)) { // When only a composing char is given match at any // position where that composing char appears. status = RA_NOMATCH; for (i = 0; rex.input[i] != NUL; i += utf_ptr2len(rex.input + i)) { inpc = utf_ptr2char(rex.input + i); if (!utf_iscomposing(inpc)) { if (i > 0) break; } else if (opndc == inpc) { // Include all following composing chars. len = i + utfc_ptr2len(rex.input + i); status = RA_MATCH; break; } } } else for (i = 0; i < len; ++i) if (opnd[i] != rex.input[i]) { status = RA_NOMATCH; break; } rex.input += len; } else status = RA_NOMATCH; break; case RE_COMPOSING: if (enc_utf8) { // Skip composing characters. while (utf_iscomposing(utf_ptr2char(rex.input))) MB_CPTR_ADV(rex.input); } break; case NOTHING: break; case BACK: { int i; backpos_T *bp; // When we run into BACK we need to check if we don't keep // looping without matching any input. The second and later // times a BACK is encountered it fails if the input is still // at the same position as the previous time. // The positions are stored in "backpos" and found by the // current value of "scan", the position in the RE program. bp = (backpos_T *)backpos.ga_data; for (i = 0; i < backpos.ga_len; ++i) if (bp[i].bp_scan == scan) break; if (i == backpos.ga_len) { // First time at this BACK, make room to store the pos. if (ga_grow(&backpos, 1) == FAIL) status = RA_FAIL; else { // get "ga_data" again, it may have changed bp = (backpos_T *)backpos.ga_data; bp[i].bp_scan = scan; ++backpos.ga_len; } } else if (reg_save_equal(&bp[i].bp_pos)) // Still at same position as last time, fail. status = RA_NOMATCH; if (status != RA_FAIL && status != RA_NOMATCH) reg_save(&bp[i].bp_pos, &backpos); } break; case MOPEN + 0: // Match start: \zs case MOPEN + 1: // \( case MOPEN + 2: case MOPEN + 3: case MOPEN + 4: case MOPEN + 5: case MOPEN + 6: case MOPEN + 7: case MOPEN + 8: case MOPEN + 9: { no = op - MOPEN; cleanup_subexpr(); rp = regstack_push(RS_MOPEN, scan); if (rp == NULL) status = RA_FAIL; else { rp->rs_no = no; save_se(&rp->rs_un.sesave, &rex.reg_startpos[no], &rex.reg_startp[no]); // We simply continue and handle the result when done. } } break; case NOPEN: // \%( case NCLOSE: // \) after \%( if (regstack_push(RS_NOPEN, scan) == NULL) status = RA_FAIL; // We simply continue and handle the result when done. break; #ifdef FEAT_SYN_HL case ZOPEN + 1: case ZOPEN + 2: case ZOPEN + 3: case ZOPEN + 4: case ZOPEN + 5: case ZOPEN + 6: case ZOPEN + 7: case ZOPEN + 8: case ZOPEN + 9: { no = op - ZOPEN; cleanup_zsubexpr(); rp = regstack_push(RS_ZOPEN, scan); if (rp == NULL) status = RA_FAIL; else { rp->rs_no = no; save_se(&rp->rs_un.sesave, &reg_startzpos[no], &reg_startzp[no]); // We simply continue and handle the result when done. } } break; #endif case MCLOSE + 0: // Match end: \ze case MCLOSE + 1: // \) case MCLOSE + 2: case MCLOSE + 3: case MCLOSE + 4: case MCLOSE + 5: case MCLOSE + 6: case MCLOSE + 7: case MCLOSE + 8: case MCLOSE + 9: { no = op - MCLOSE; cleanup_subexpr(); rp = regstack_push(RS_MCLOSE, scan); if (rp == NULL) status = RA_FAIL; else { rp->rs_no = no; save_se(&rp->rs_un.sesave, &rex.reg_endpos[no], &rex.reg_endp[no]); // We simply continue and handle the result when done. } } break; #ifdef FEAT_SYN_HL case ZCLOSE + 1: // \) after \z( case ZCLOSE + 2: case ZCLOSE + 3: case ZCLOSE + 4: case ZCLOSE + 5: case ZCLOSE + 6: case ZCLOSE + 7: case ZCLOSE + 8: case ZCLOSE + 9: { no = op - ZCLOSE; cleanup_zsubexpr(); rp = regstack_push(RS_ZCLOSE, scan); if (rp == NULL) status = RA_FAIL; else { rp->rs_no = no; save_se(&rp->rs_un.sesave, &reg_endzpos[no], &reg_endzp[no]); // We simply continue and handle the result when done. } } break; #endif case BACKREF + 1: case BACKREF + 2: case BACKREF + 3: case BACKREF + 4: case BACKREF + 5: case BACKREF + 6: case BACKREF + 7: case BACKREF + 8: case BACKREF + 9: { int len; no = op - BACKREF; cleanup_subexpr(); if (!REG_MULTI) // Single-line regexp { if (rex.reg_startp[no] == NULL || rex.reg_endp[no] == NULL) { // Backref was not set: Match an empty string. len = 0; } else { // Compare current input with back-ref in the same // line. len = (int)(rex.reg_endp[no] - rex.reg_startp[no]); if (cstrncmp(rex.reg_startp[no], rex.input, &len) != 0) status = RA_NOMATCH; } } else // Multi-line regexp { if (rex.reg_startpos[no].lnum < 0 || rex.reg_endpos[no].lnum < 0) { // Backref was not set: Match an empty string. len = 0; } else { if (rex.reg_startpos[no].lnum == rex.lnum && rex.reg_endpos[no].lnum == rex.lnum) { // Compare back-ref within the current line. len = rex.reg_endpos[no].col - rex.reg_startpos[no].col; if (cstrncmp(rex.line + rex.reg_startpos[no].col, rex.input, &len) != 0) status = RA_NOMATCH; } else { // Messy situation: Need to compare between two // lines. int r = match_with_backref( rex.reg_startpos[no].lnum, rex.reg_startpos[no].col, rex.reg_endpos[no].lnum, rex.reg_endpos[no].col, &len); if (r != RA_MATCH) status = r; } } } // Matched the backref, skip over it. rex.input += len; } break; #ifdef FEAT_SYN_HL case ZREF + 1: case ZREF + 2: case ZREF + 3: case ZREF + 4: case ZREF + 5: case ZREF + 6: case ZREF + 7: case ZREF + 8: case ZREF + 9: { int len; cleanup_zsubexpr(); no = op - ZREF; if (re_extmatch_in != NULL && re_extmatch_in->matches[no] != NULL) { len = (int)STRLEN(re_extmatch_in->matches[no]); if (cstrncmp(re_extmatch_in->matches[no], rex.input, &len) != 0) status = RA_NOMATCH; else rex.input += len; } else { // Backref was not set: Match an empty string. } } break; #endif case BRANCH: { if (OP(next) != BRANCH) // No choice. next = OPERAND(scan); // Avoid recursion. else { rp = regstack_push(RS_BRANCH, scan); if (rp == NULL) status = RA_FAIL; else status = RA_BREAK; // rest is below } } break; case BRACE_LIMITS: { if (OP(next) == BRACE_SIMPLE) { bl_minval = OPERAND_MIN(scan); bl_maxval = OPERAND_MAX(scan); } else if (OP(next) >= BRACE_COMPLEX && OP(next) < BRACE_COMPLEX + 10) { no = OP(next) - BRACE_COMPLEX; brace_min[no] = OPERAND_MIN(scan); brace_max[no] = OPERAND_MAX(scan); brace_count[no] = 0; } else { internal_error("BRACE_LIMITS"); status = RA_FAIL; } } break; case BRACE_COMPLEX + 0: case BRACE_COMPLEX + 1: case BRACE_COMPLEX + 2: case BRACE_COMPLEX + 3: case BRACE_COMPLEX + 4: case BRACE_COMPLEX + 5: case BRACE_COMPLEX + 6: case BRACE_COMPLEX + 7: case BRACE_COMPLEX + 8: case BRACE_COMPLEX + 9: { no = op - BRACE_COMPLEX; ++brace_count[no]; // If not matched enough times yet, try one more if (brace_count[no] <= (brace_min[no] <= brace_max[no] ? brace_min[no] : brace_max[no])) { rp = regstack_push(RS_BRCPLX_MORE, scan); if (rp == NULL) status = RA_FAIL; else { rp->rs_no = no; reg_save(&rp->rs_un.regsave, &backpos); next = OPERAND(scan); // We continue and handle the result when done. } break; } // If matched enough times, may try matching some more if (brace_min[no] <= brace_max[no]) { // Range is the normal way around, use longest match if (brace_count[no] <= brace_max[no]) { rp = regstack_push(RS_BRCPLX_LONG, scan); if (rp == NULL) status = RA_FAIL; else { rp->rs_no = no; reg_save(&rp->rs_un.regsave, &backpos); next = OPERAND(scan); // We continue and handle the result when done. } } } else { // Range is backwards, use shortest match first if (brace_count[no] <= brace_min[no]) { rp = regstack_push(RS_BRCPLX_SHORT, scan); if (rp == NULL) status = RA_FAIL; else { reg_save(&rp->rs_un.regsave, &backpos); // We continue and handle the result when done. } } } } break; case BRACE_SIMPLE: case STAR: case PLUS: { regstar_T rst; // Lookahead to avoid useless match attempts when we know // what character comes next. if (OP(next) == EXACTLY) { rst.nextb = *OPERAND(next); if (rex.reg_ic) { if (MB_ISUPPER(rst.nextb)) rst.nextb_ic = MB_TOLOWER(rst.nextb); else rst.nextb_ic = MB_TOUPPER(rst.nextb); } else rst.nextb_ic = rst.nextb; } else { rst.nextb = NUL; rst.nextb_ic = NUL; } if (op != BRACE_SIMPLE) { rst.minval = (op == STAR) ? 0 : 1; rst.maxval = MAX_LIMIT; } else { rst.minval = bl_minval; rst.maxval = bl_maxval; } // When maxval > minval, try matching as much as possible, up // to maxval. When maxval < minval, try matching at least the // minimal number (since the range is backwards, that's also // maxval!). rst.count = regrepeat(OPERAND(scan), rst.maxval); if (got_int) { status = RA_FAIL; break; } if (rst.minval <= rst.maxval ? rst.count >= rst.minval : rst.count >= rst.maxval) { // It could match. Prepare for trying to match what // follows. The code is below. Parameters are stored in // a regstar_T on the regstack. if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp) { emsg(_(e_pattern_uses_more_memory_than_maxmempattern)); status = RA_FAIL; } else if (ga_grow(&regstack, sizeof(regstar_T)) == FAIL) status = RA_FAIL; else { regstack.ga_len += sizeof(regstar_T); rp = regstack_push(rst.minval <= rst.maxval ? RS_STAR_LONG : RS_STAR_SHORT, scan); if (rp == NULL) status = RA_FAIL; else { *(((regstar_T *)rp) - 1) = rst; status = RA_BREAK; // skip the restore bits } } } else status = RA_NOMATCH; } break; case NOMATCH: case MATCH: case SUBPAT: rp = regstack_push(RS_NOMATCH, scan); if (rp == NULL) status = RA_FAIL; else { rp->rs_no = op; reg_save(&rp->rs_un.regsave, &backpos); next = OPERAND(scan); // We continue and handle the result when done. } break; case BEHIND: case NOBEHIND: // Need a bit of room to store extra positions. if ((long)((unsigned)regstack.ga_len >> 10) >= p_mmp) { emsg(_(e_pattern_uses_more_memory_than_maxmempattern)); status = RA_FAIL; } else if (ga_grow(&regstack, sizeof(regbehind_T)) == FAIL) status = RA_FAIL; else { regstack.ga_len += sizeof(regbehind_T); rp = regstack_push(RS_BEHIND1, scan); if (rp == NULL) status = RA_FAIL; else { // Need to save the subexpr to be able to restore them // when there is a match but we don't use it. save_subexpr(((regbehind_T *)rp) - 1); rp->rs_no = op; reg_save(&rp->rs_un.regsave, &backpos); // First try if what follows matches. If it does then we // check the behind match by looping. } } break; case BHPOS: if (REG_MULTI) { if (behind_pos.rs_u.pos.col != (colnr_T)(rex.input - rex.line) || behind_pos.rs_u.pos.lnum != rex.lnum) status = RA_NOMATCH; } else if (behind_pos.rs_u.ptr != rex.input) status = RA_NOMATCH; break; case NEWL: if ((c != NUL || !REG_MULTI || rex.lnum > rex.reg_maxline || rex.reg_line_lbr) && (c != '\n' || !rex.reg_line_lbr)) status = RA_NOMATCH; else if (rex.reg_line_lbr) ADVANCE_REGINPUT(); else reg_nextline(); break; case END: status = RA_MATCH; // Success! break; default: iemsg(_(e_corrupted_regexp_program)); #ifdef DEBUG printf("Illegal op code %d\n", op); #endif status = RA_FAIL; break; } } // If we can't continue sequentially, break the inner loop. if (status != RA_CONT) break; // Continue in inner loop, advance to next item. scan = next; } // end of inner loop // If there is something on the regstack execute the code for the state. // If the state is popped then loop and use the older state. while (regstack.ga_len > 0 && status != RA_FAIL) { rp = (regitem_T *)((char *)regstack.ga_data + regstack.ga_len) - 1; switch (rp->rs_state) { case RS_NOPEN: // Result is passed on as-is, simply pop the state. regstack_pop(&scan); break; case RS_MOPEN: // Pop the state. Restore pointers when there is no match. if (status == RA_NOMATCH) restore_se(&rp->rs_un.sesave, &rex.reg_startpos[rp->rs_no], &rex.reg_startp[rp->rs_no]); regstack_pop(&scan); break; #ifdef FEAT_SYN_HL case RS_ZOPEN: // Pop the state. Restore pointers when there is no match. if (status == RA_NOMATCH) restore_se(&rp->rs_un.sesave, &reg_startzpos[rp->rs_no], &reg_startzp[rp->rs_no]); regstack_pop(&scan); break; #endif case RS_MCLOSE: // Pop the state. Restore pointers when there is no match. if (status == RA_NOMATCH) restore_se(&rp->rs_un.sesave, &rex.reg_endpos[rp->rs_no], &rex.reg_endp[rp->rs_no]); regstack_pop(&scan); break; #ifdef FEAT_SYN_HL case RS_ZCLOSE: // Pop the state. Restore pointers when there is no match. if (status == RA_NOMATCH) restore_se(&rp->rs_un.sesave, &reg_endzpos[rp->rs_no], &reg_endzp[rp->rs_no]); regstack_pop(&scan); break; #endif case RS_BRANCH: if (status == RA_MATCH) // this branch matched, use it regstack_pop(&scan); else { if (status != RA_BREAK) { // After a non-matching branch: try next one. reg_restore(&rp->rs_un.regsave, &backpos); scan = rp->rs_scan; } if (scan == NULL || OP(scan) != BRANCH) { // no more branches, didn't find a match status = RA_NOMATCH; regstack_pop(&scan); } else { // Prepare to try a branch. rp->rs_scan = regnext(scan); reg_save(&rp->rs_un.regsave, &backpos); scan = OPERAND(scan); } } break; case RS_BRCPLX_MORE: // Pop the state. Restore pointers when there is no match. if (status == RA_NOMATCH) { reg_restore(&rp->rs_un.regsave, &backpos); --brace_count[rp->rs_no]; // decrement match count } regstack_pop(&scan); break; case RS_BRCPLX_LONG: // Pop the state. Restore pointers when there is no match. if (status == RA_NOMATCH) { // There was no match, but we did find enough matches. reg_restore(&rp->rs_un.regsave, &backpos); --brace_count[rp->rs_no]; // continue with the items after "\{}" status = RA_CONT; } regstack_pop(&scan); if (status == RA_CONT) scan = regnext(scan); break; case RS_BRCPLX_SHORT: // Pop the state. Restore pointers when there is no match. if (status == RA_NOMATCH) // There was no match, try to match one more item. reg_restore(&rp->rs_un.regsave, &backpos); regstack_pop(&scan); if (status == RA_NOMATCH) { scan = OPERAND(scan); status = RA_CONT; } break; case RS_NOMATCH: // Pop the state. If the operand matches for NOMATCH or // doesn't match for MATCH/SUBPAT, we fail. Otherwise backup, // except for SUBPAT, and continue with the next item. if (status == (rp->rs_no == NOMATCH ? RA_MATCH : RA_NOMATCH)) status = RA_NOMATCH; else { status = RA_CONT; if (rp->rs_no != SUBPAT) // zero-width reg_restore(&rp->rs_un.regsave, &backpos); } regstack_pop(&scan); if (status == RA_CONT) scan = regnext(scan); break; case RS_BEHIND1: if (status == RA_NOMATCH) { regstack_pop(&scan); regstack.ga_len -= sizeof(regbehind_T); } else { // The stuff after BEHIND/NOBEHIND matches. Now try if // the behind part does (not) match before the current // position in the input. This must be done at every // position in the input and checking if the match ends at // the current position. // save the position after the found match for next reg_save(&(((regbehind_T *)rp) - 1)->save_after, &backpos); // Start looking for a match with operand at the current // position. Go back one character until we find the // result, hitting the start of the line or the previous // line (for multi-line matching). // Set behind_pos to where the match should end, BHPOS // will match it. Save the current value. (((regbehind_T *)rp) - 1)->save_behind = behind_pos; behind_pos = rp->rs_un.regsave; rp->rs_state = RS_BEHIND2; reg_restore(&rp->rs_un.regsave, &backpos); scan = OPERAND(rp->rs_scan) + 4; } break; case RS_BEHIND2: // Looping for BEHIND / NOBEHIND match. if (status == RA_MATCH && reg_save_equal(&behind_pos)) { // found a match that ends where "next" started behind_pos = (((regbehind_T *)rp) - 1)->save_behind; if (rp->rs_no == BEHIND) reg_restore(&(((regbehind_T *)rp) - 1)->save_after, &backpos); else { // But we didn't want a match. Need to restore the // subexpr, because what follows matched, so they have // been set. status = RA_NOMATCH; restore_subexpr(((regbehind_T *)rp) - 1); } regstack_pop(&scan); regstack.ga_len -= sizeof(regbehind_T); } else { long limit; // No match or a match that doesn't end where we want it: Go // back one character. May go to previous line once. no = OK; limit = OPERAND_MIN(rp->rs_scan); if (REG_MULTI) { if (limit > 0 && ((rp->rs_un.regsave.rs_u.pos.lnum < behind_pos.rs_u.pos.lnum ? (colnr_T)STRLEN(rex.line) : behind_pos.rs_u.pos.col) - rp->rs_un.regsave.rs_u.pos.col >= limit)) no = FAIL; else if (rp->rs_un.regsave.rs_u.pos.col == 0) { if (rp->rs_un.regsave.rs_u.pos.lnum < behind_pos.rs_u.pos.lnum || reg_getline( --rp->rs_un.regsave.rs_u.pos.lnum) == NULL) no = FAIL; else { reg_restore(&rp->rs_un.regsave, &backpos); rp->rs_un.regsave.rs_u.pos.col = (colnr_T)STRLEN(rex.line); } } else { if (has_mbyte) { char_u *line = reg_getline(rp->rs_un.regsave.rs_u.pos.lnum); rp->rs_un.regsave.rs_u.pos.col -= (*mb_head_off)(line, line + rp->rs_un.regsave.rs_u.pos.col - 1) + 1; } else --rp->rs_un.regsave.rs_u.pos.col; } } else { if (rp->rs_un.regsave.rs_u.ptr == rex.line) no = FAIL; else { MB_PTR_BACK(rex.line, rp->rs_un.regsave.rs_u.ptr); if (limit > 0 && (long)(behind_pos.rs_u.ptr - rp->rs_un.regsave.rs_u.ptr) > limit) no = FAIL; } } if (no == OK) { // Advanced, prepare for finding match again. reg_restore(&rp->rs_un.regsave, &backpos); scan = OPERAND(rp->rs_scan) + 4; if (status == RA_MATCH) { // We did match, so subexpr may have been changed, // need to restore them for the next try. status = RA_NOMATCH; restore_subexpr(((regbehind_T *)rp) - 1); } } else { // Can't advance. For NOBEHIND that's a match. behind_pos = (((regbehind_T *)rp) - 1)->save_behind; if (rp->rs_no == NOBEHIND) { reg_restore(&(((regbehind_T *)rp) - 1)->save_after, &backpos); status = RA_MATCH; } else { // We do want a proper match. Need to restore the // subexpr if we had a match, because they may have // been set. if (status == RA_MATCH) { status = RA_NOMATCH; restore_subexpr(((regbehind_T *)rp) - 1); } } regstack_pop(&scan); regstack.ga_len -= sizeof(regbehind_T); } } break; case RS_STAR_LONG: case RS_STAR_SHORT: { regstar_T *rst = ((regstar_T *)rp) - 1; if (status == RA_MATCH) { regstack_pop(&scan); regstack.ga_len -= sizeof(regstar_T); break; } // Tried once already, restore input pointers. if (status != RA_BREAK) reg_restore(&rp->rs_un.regsave, &backpos); // Repeat until we found a position where it could match. for (;;) { if (status != RA_BREAK) { // Tried first position already, advance. if (rp->rs_state == RS_STAR_LONG) { // Trying for longest match, but couldn't or // didn't match -- back up one char. if (--rst->count < rst->minval) break; if (rex.input == rex.line) { // backup to last char of previous line if (rex.lnum == 0) { status = RA_NOMATCH; break; } --rex.lnum; rex.line = reg_getline(rex.lnum); // Just in case regrepeat() didn't count // right. if (rex.line == NULL) break; rex.input = rex.line + STRLEN(rex.line); fast_breakcheck(); } else MB_PTR_BACK(rex.line, rex.input); } else { // Range is backwards, use shortest match first. // Careful: maxval and minval are exchanged! // Couldn't or didn't match: try advancing one // char. if (rst->count == rst->minval || regrepeat(OPERAND(rp->rs_scan), 1L) == 0) break; ++rst->count; } if (got_int) break; } else status = RA_NOMATCH; // If it could match, try it. if (rst->nextb == NUL || *rex.input == rst->nextb || *rex.input == rst->nextb_ic) { reg_save(&rp->rs_un.regsave, &backpos); scan = regnext(rp->rs_scan); status = RA_CONT; break; } } if (status != RA_CONT) { // Failed. regstack_pop(&scan); regstack.ga_len -= sizeof(regstar_T); status = RA_NOMATCH; } } break; } // If we want to continue the inner loop or didn't pop a state // continue matching loop if (status == RA_CONT || rp == (regitem_T *) ((char *)regstack.ga_data + regstack.ga_len) - 1) break; } // May need to continue with the inner loop, starting at "scan". if (status == RA_CONT) continue; // If the regstack is empty or something failed we are done. if (regstack.ga_len == 0 || status == RA_FAIL) { if (scan == NULL) { // We get here only if there's trouble -- normally "case END" is // the terminating point. iemsg(_(e_corrupted_regexp_program)); #ifdef DEBUG printf("Premature EOL\n"); #endif } return (status == RA_MATCH); } } // End of loop until the regstack is empty. // NOTREACHED }
0
196,611
static int setup_config(int type) { int rv; rv = read_config(cl.configfile, type); if (rv < 0) goto out; if (is_auth_req()) { rv = read_authkey(); if (rv < 0) goto out; #if HAVE_LIBGCRYPT if (!gcry_check_version(NULL)) { log_error("gcry_check_version"); rv = -ENOENT; goto out; } gcry_control(GCRYCTL_DISABLE_SECMEM, 0); gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); #endif } /* Set "local" pointer, ignoring errors. */ if (cl.type == DAEMON && cl.site[0]) { if (!find_site_by_name(cl.site, &local, 1)) { log_error("Cannot find \"%s\" in the configuration.", cl.site); return -EINVAL; } local->local = 1; } else find_myself(NULL, type == CLIENT || type == GEOSTORE); rv = check_config(type); if (rv < 0) goto out; /* Per default the PID file name is derived from the * configuration name. */ if (!cl.lockfile[0]) { snprintf(cl.lockfile, sizeof(cl.lockfile)-1, "%s/%s.pid", BOOTH_RUN_DIR, booth_conf->name); } out: return rv; }
1
500,088
print_krb5_data(char *label, krb5_data *kdata) { int i; printf("%s[%d] ", label, kdata->length); for (i=0; i < (int)kdata->length; i++) { if (0 && isprint((int) kdata->data[i])) printf( "%c ", kdata->data[i]); else printf( "%02x ", (unsigned char) kdata->data[i]); } printf("\n"); }
0
220,415
mrb_ary_new(mrb_state *mrb) { return mrb_ary_new_capa(mrb, 0); }
0
253,575
static int smb3_simple_fallocate_write_range(unsigned int xid, struct cifs_tcon *tcon, struct cifsFileInfo *cfile, loff_t off, loff_t len, char *buf) { struct cifs_io_parms io_parms = {0}; int nbytes; int rc = 0; struct kvec iov[2]; io_parms.netfid = cfile->fid.netfid; io_parms.pid = current->tgid; io_parms.tcon = tcon; io_parms.persistent_fid = cfile->fid.persistent_fid; io_parms.volatile_fid = cfile->fid.volatile_fid; while (len) { io_parms.offset = off; io_parms.length = len; if (io_parms.length > SMB2_MAX_BUFFER_SIZE) io_parms.length = SMB2_MAX_BUFFER_SIZE; /* iov[0] is reserved for smb header */ iov[1].iov_base = buf; iov[1].iov_len = io_parms.length; rc = SMB2_write(xid, &io_parms, &nbytes, iov, 1); if (rc) break; if (nbytes > len) return -EINVAL; buf += nbytes; off += nbytes; len -= nbytes; } return rc; }
0
234,767
static bool is_block_group_to_copy(struct btrfs_fs_info *fs_info, u64 logical) { struct btrfs_block_group *cache; bool ret; /* Non zoned filesystem does not use "to_copy" flag */ if (!btrfs_is_zoned(fs_info)) return false; cache = btrfs_lookup_block_group(fs_info, logical); spin_lock(&cache->lock); ret = cache->to_copy; spin_unlock(&cache->lock); btrfs_put_block_group(cache); return ret; }
0
281,668
fill_input_buffer (j_decompress_ptr cinfo) { #ifndef LIBRAW_NOTHREADS #define jpeg_buffer tls->jpeg_buffer #else static uchar jpeg_buffer[4096]; #endif size_t nbytes; nbytes = fread (jpeg_buffer, 1, 4096, ifp); swab (jpeg_buffer, jpeg_buffer, nbytes); cinfo->src->next_input_byte = jpeg_buffer; cinfo->src->bytes_in_buffer = nbytes; return TRUE; #ifndef LIBRAW_NOTHREADS #undef jpeg_buffer #endif }
0
261,394
static inline int decode_mpm_idx(thread_context* tctx) { logtrace(LogSlice,"# mpm_idx (TU:2)\n"); int mpm = decode_CABAC_TU_bypass(&tctx->cabac_decoder, 2); logtrace(LogSlice,"> mpm_idx = %d\n",mpm); logtrace(LogSymbols,"$1 mpm_idx=%d\n",mpm); return mpm; }
0
234,770
static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, struct btrfs_device *device, fmode_t flags, void *holder) { struct request_queue *q; struct block_device *bdev; struct btrfs_super_block *disk_super; u64 devid; int ret; if (device->bdev) return -EINVAL; if (!device->name) return -EINVAL; ret = btrfs_get_bdev_and_sb(device->name->str, flags, holder, 1, &bdev, &disk_super); if (ret) return ret; devid = btrfs_stack_device_id(&disk_super->dev_item); if (devid != device->devid) goto error_free_page; if (memcmp(device->uuid, disk_super->dev_item.uuid, BTRFS_UUID_SIZE)) goto error_free_page; device->generation = btrfs_super_generation(disk_super); if (btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_SEEDING) { if (btrfs_super_incompat_flags(disk_super) & BTRFS_FEATURE_INCOMPAT_METADATA_UUID) { pr_err( "BTRFS: Invalid seeding and uuid-changed device detected\n"); goto error_free_page; } clear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state); fs_devices->seeding = true; } else { if (bdev_read_only(bdev)) clear_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state); else set_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state); } q = bdev_get_queue(bdev); if (!blk_queue_nonrot(q)) fs_devices->rotating = true; device->bdev = bdev; clear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state); device->mode = flags; fs_devices->open_devices++; if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state) && device->devid != BTRFS_DEV_REPLACE_DEVID) { fs_devices->rw_devices++; list_add_tail(&device->dev_alloc_list, &fs_devices->alloc_list); } btrfs_release_disk_super(disk_super); return 0; error_free_page: btrfs_release_disk_super(disk_super); blkdev_put(bdev, flags); return -EINVAL; }
0
139,237
void OverlayWindowViews::OnNativeWidgetMove() { if (is_initialized_) UpdateControlsVisibility(false); window_bounds_ = GetBounds(); #if defined(OS_CHROMEOS) WindowQuadrant quadrant = GetCurrentWindowQuadrant(GetBounds(), controller_); close_controls_view_->SetPosition(GetBounds().size(), quadrant); resize_handle_view_->SetPosition(GetBounds().size(), quadrant); #endif }
0
247,732
TEST_P(SslReadBufferLimitTest, SomeLimit) { readBufferLimitTest(32 * 1024, 32 * 1024, 256 * 1024, 1, false); }
0
452,986
static int nft_fwd_neigh_dump(struct sk_buff *skb, const struct nft_expr *expr) { struct nft_fwd_neigh *priv = nft_expr_priv(expr); if (nft_dump_register(skb, NFTA_FWD_SREG_DEV, priv->sreg_dev) || nft_dump_register(skb, NFTA_FWD_SREG_ADDR, priv->sreg_addr) || nla_put_be32(skb, NFTA_FWD_NFPROTO, htonl(priv->nfproto))) goto nla_put_failure; return 0; nla_put_failure: return -1; }
0
310,180
drv_initpair(TERMINAL_CONTROL_BLOCK * TCB, int pair, int f, int b) { SCREEN *sp; AssertTCB(); SetSP(); if ((initialize_pair != NULL) && InPalette(f) && InPalette(b)) { const color_t *tp = InfoOf(sp).defaultPalette; TR(TRACE_ATTRS, ("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)", pair, tp[f].red, tp[f].green, tp[f].blue, tp[b].red, tp[b].green, tp[b].blue)); NCURSES_PUTP2("initialize_pair", TIPARM_7(initialize_pair, pair, tp[f].red, tp[f].green, tp[f].blue, tp[b].red, tp[b].green, tp[b].blue)); } }
0
272,334
make_context_specific(cms_context *cms, int ctxt, SECItem *encoded, SECItem *original) { void *rv; ContextSpecificSequence[0].kind = SEC_ASN1_EXPLICIT | SEC_ASN1_CONTEXT_SPECIFIC | ctxt; rv = SEC_ASN1EncodeItem(cms->arena, encoded, original, ContextSpecificSequence); if (rv == NULL) cnreterr(-1, cms, "could not encode context specific data"); return 0; }
0
357,667
bool SQInstance::GetMetaMethod(SQVM* SQ_UNUSED_ARG(v),SQMetaMethod mm,SQObjectPtr &res) { if(sq_type(_class->_metamethods[mm]) != OT_NULL) { res = _class->_metamethods[mm]; return true; } return false; }
0
309,869
load_term(void) { (void) setupterm(tname, STDOUT_FILENO, NULL); }
0
483,495
u64 efi_mem_attributes(unsigned long phys_addr) { efi_memory_desc_t *md; if (!efi_enabled(EFI_MEMMAP)) return 0; for_each_efi_memory_desc(md) { if ((md->phys_addr <= phys_addr) && (phys_addr < (md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)))) return md->attribute; } return 0; }
0
294,518
d_lite_amjd(VALUE self) { get_d1(self); return m_amjd(dat); }
0
344,737
monotime_double(void) { struct timespec ts; monotime_ts(&ts); return ts.tv_sec + ((double)ts.tv_nsec / 1000000000); }
0
389,688
tv_get_number(typval_T *varp) { int error = FALSE; return tv_get_number_chk(varp, &error); // return 0L on error }
0
512,646
cmp_item *cmp_item_datetime::make_same() { return new cmp_item_datetime(); }
0
225,688
GF_Err trgt_box_size(GF_Box *s) { GF_TrackGroupBox *ptr = (GF_TrackGroupBox *)s; ptr->size+= 4; return GF_OK;
0
281,663
void CLASS redcine_load_raw() { #ifndef NO_JASPER int c, row, col; jas_stream_t *in; jas_image_t *jimg; jas_matrix_t *jmat; jas_seqent_t *data; ushort *img, *pix; jas_init(); #ifndef LIBRAW_LIBRARY_BUILD in = jas_stream_fopen (ifname, "rb"); #else in = (jas_stream_t*)ifp->make_jas_stream(); if(!in) throw LIBRAW_EXCEPTION_DECODE_JPEG2000; #endif jas_stream_seek (in, data_offset+20, SEEK_SET); jimg = jas_image_decode (in, -1, 0); #ifndef LIBRAW_LIBRARY_BUILD if (!jimg) longjmp (failure, 3); #else if(!jimg) { jas_stream_close (in); throw LIBRAW_EXCEPTION_DECODE_JPEG2000; } #endif jmat = jas_matrix_create (height/2, width/2); merror (jmat, "redcine_load_raw()"); img = (ushort *) calloc ((height+2), (width+2)*2); merror (img, "redcine_load_raw()"); #ifdef LIBRAW_LIBRARY_BUILD bool fastexitflag = false; try { #endif FORC4 { #ifdef LIBRAW_LIBRARY_BUILD checkCancel(); #endif jas_image_readcmpt (jimg, c, 0, 0, width/2, height/2, jmat); data = jas_matrix_getref (jmat, 0, 0); for (row = c >> 1; row < height; row+=2) for (col = c & 1; col < width; col+=2) img[(row+1)*(width+2)+col+1] = data[(row/2)*(width/2)+col/2]; } for (col=1; col <= width; col++) { img[col] = img[2*(width+2)+col]; img[(height+1)*(width+2)+col] = img[(height-1)*(width+2)+col]; } for (row=0; row < height+2; row++) { img[row*(width+2)] = img[row*(width+2)+2]; img[(row+1)*(width+2)-1] = img[(row+1)*(width+2)-3]; } for (row=1; row <= height; row++) { #ifdef LIBRAW_LIBRARY_BUILD checkCancel(); #endif pix = img + row*(width+2) + (col = 1 + (FC(row,1) & 1)); for ( ; col <= width; col+=2, pix+=2) { c = (((pix[0] - 0x800) << 3) + pix[-(width+2)] + pix[width+2] + pix[-1] + pix[1]) >> 2; pix[0] = LIM(c,0,4095); } } for (row=0; row < height; row++) { #ifdef LIBRAW_LIBRARY_BUILD checkCancel(); #endif for (col=0; col < width; col++) RAW(row,col) = curve[img[(row+1)*(width+2)+col+1]]; } #ifdef LIBRAW_LIBRARY_BUILD } catch (...) { fastexitflag=true; } #endif free (img); jas_matrix_destroy (jmat); jas_image_destroy (jimg); jas_stream_close (in); #ifdef LIBRAW_LIBRARY_BUILD if(fastexitflag) throw LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK; #endif #endif }
0