idx
int64
func
string
target
int64
390,593
_CheckSetShapes( XkbGeometryPtr geom, xkbSetGeometryReq * req, char ** wire_inout, ClientPtr client) { register int i; char * wire; wire= *wire_inout; if (req->nShapes<1) { client->errorValue= _XkbErrCode2(0x06,req->nShapes); return BadValue; } else { xkbShapeWireDesc * shapeWire; XkbShapePtr shape; register int o; shapeWire= (xkbShapeWireDesc *)wire; for (i=0;i<req->nShapes;i++) { xkbOutlineWireDesc * olWire; XkbOutlinePtr ol; shape= XkbAddGeomShape(geom,shapeWire->name,shapeWire->nOutlines); if (!shape) return BadAlloc; olWire= (xkbOutlineWireDesc *)(&shapeWire[1]); for (o=0;o<shapeWire->nOutlines;o++) { register int p; XkbPointPtr pt; xkbPointWireDesc * ptWire; ol= XkbAddGeomOutline(shape,olWire->nPoints); if (!ol) return BadAlloc; ol->corner_radius= olWire->cornerRadius; ptWire= (xkbPointWireDesc *)&olWire[1]; for (p=0,pt=ol->points;p<olWire->nPoints;p++,pt++) { pt->x= ptWire[p].x; pt->y= ptWire[p].y; if (client->swapped) { register int n; swaps(&pt->x,n); swaps(&pt->y,n); } } ol->num_points= olWire->nPoints; olWire= (xkbOutlineWireDesc *)(&ptWire[olWire->nPoints]); } if (shapeWire->primaryNdx!=XkbNoShape) shape->primary= &shape->outlines[shapeWire->primaryNdx]; if (shapeWire->approxNdx!=XkbNoShape) shape->approx= &shape->outlines[shapeWire->approxNdx]; shapeWire= (xkbShapeWireDesc *)olWire; } wire= (char *)shapeWire; } if (geom->num_shapes!=req->nShapes) { client->errorValue= _XkbErrCode3(0x07,geom->num_shapes,req->nShapes); return BadMatch; } *wire_inout= wire; return Success; }
0
474,062
gb18030_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc) { return onigenc_mb4_is_code_ctype(enc, code, ctype); }
0
218,986
Status ConstantFolding::Optimize(Cluster* cluster, const GrapplerItem& item, GraphDef* optimized_graph) { // TensorFlow flushes denormals to zero and rounds to nearest, so we do // the same here. port::ScopedFlushDenormal flush; port::ScopedSetRound round(FE_TONEAREST); nodes_to_preserve_ = item.NodesToPreserve(); for (const auto& feed : item.feed) { feed_nodes_.insert(NodeName(feed.first)); } if (cpu_device_ == nullptr) { owned_device_.reset(new DeviceSimple()); cpu_device_ = owned_device_.get(); } graph_contains_assign_or_inplace_op_ = false; for (const NodeDef& node : item.graph.node()) { if (ModifiesInputsInPlace(node) || HasRefInput(node)) { graph_contains_assign_or_inplace_op_ = true; break; } } has_fetch_ = !item.fetch.empty(); GrapplerItem item_to_optimize = item; GraphProperties properties(item_to_optimize); // It's possible to feed a placeholder with a tensor of any shape: make sure // that the shape inference deals with this conservatively unless we're in // aggressive mode. const bool assume_valid_feeds = opt_level_ == RewriterConfig::AGGRESSIVE; if (!properties .InferStatically(assume_valid_feeds, /*aggressive_shape_inference=*/false, /*include_input_tensor_values=*/false, /*include_output_tensor_values=*/true) .ok()) { properties.Clear(); } *optimized_graph = GraphDef(); item_to_optimize.graph.Swap(optimized_graph); int64_t node_count; do { GRAPPLER_RETURN_IF_DEADLINE_EXCEEDED(); graph_modified_ = false; item_to_optimize.graph.Swap(optimized_graph); node_count = item_to_optimize.graph.node_size(); TF_RETURN_IF_ERROR(RunOptimizationPass(cluster, &item_to_optimize, &properties, optimized_graph)); } while (graph_modified_ || optimized_graph->node_size() != node_count); *optimized_graph->mutable_library() = item.graph.library(); *optimized_graph->mutable_versions() = item.graph.versions(); return Status::OK(); }
0
442,823
CURLcode _my_setopt(CURL *curl, const char *name, CURLoption tag, ...) { va_list arg; CURLcode ret; char *bufp; char value[256]; bool remark=FALSE; va_start(arg, tag); if(tag < CURLOPTTYPE_OBJECTPOINT) { long lval = va_arg(arg, long); snprintf(value, sizeof(value), "%ld", lval); ret = curl_easy_setopt(curl, tag, lval); } else if(tag < CURLOPTTYPE_OFF_T) { void *pval = va_arg(arg, void *); unsigned char *ptr = (unsigned char *)pval; /* function pointers are never printable */ if (tag >= CURLOPTTYPE_FUNCTIONPOINT) { if (pval) { snprintf(value, sizeof(value), "%p", pval); remark = TRUE; } else strcpy(value, "NULL"); } /* attempt to figure out if it is a string (since the tag numerical doesn't offer this info) and then output it as a string if so */ else if(pval && isgraph(ptr[0]) && isgraph(ptr[1]) && isgraph(ptr[2])) snprintf(value, sizeof(value), "\"%s\"", (char *)ptr); else if(pval) { snprintf(value, sizeof(value), "%p", pval); remark = TRUE; } else { strcpy(value, "NULL"); /* value fits more than 5 bytes */ } ret = curl_easy_setopt(curl, tag, pval); } else { curl_off_t oval = va_arg(arg, curl_off_t); snprintf(value, sizeof(value), "(curl_off_t)%Od", oval); ret = curl_easy_setopt(curl, tag, oval); } bufp = curl_maprintf("%scurl_easy_setopt(hnd, %s, %s);%s", remark?"/* ":"", name, value, remark?" [REMARK] */":""); if (!bufp || !curl_slist_append(easycode, bufp)) ret = CURLE_OUT_OF_MEMORY; if (bufp) curl_free(bufp); va_end(arg); return ret; }
0
219,964
int callback_glewlwyd_check_user_profile_valid (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; char * session_uid; json_t * j_user; int ret, res; if ((session_uid = get_session_id(config, request)) != NULL) { j_user = get_current_user_for_session(config, session_uid); if (check_result_value(j_user, G_OK) && json_object_get(json_object_get(j_user, "user"), "enabled") == json_true()) { if ((res = is_scope_list_valid_for_session(config, config->profile_scope, session_uid)) == G_OK) { if (ulfius_set_response_shared_data(response, json_deep_copy(json_object_get(j_user, "user")), (void (*)(void *))&json_decref) != U_OK) { ret = U_CALLBACK_ERROR; } else { ret = U_CALLBACK_IGNORE; } } else { if (res == G_ERROR) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_check_user_session - Error is_scope_list_valid_for_session"); } ret = U_CALLBACK_UNAUTHORIZED; } } else { ret = U_CALLBACK_UNAUTHORIZED; } json_decref(j_user); } else { ret = U_CALLBACK_UNAUTHORIZED; } o_free(session_uid); return ret; }
0
413,604
R_API int r_core_anal_fcn_list(RCore *core, const char *input, const char *rad) { char temp[64]; r_return_val_if_fail (core && core->anal, 0); if (r_list_empty (core->anal->fcns)) { if (*rad == 'j') { r_cons_println ("[]"); } return 0; } if (*rad == '.') { RList *fcns = r_anal_get_functions_in (core->anal, core->offset); if (!fcns || r_list_empty (fcns)) { eprintf ("No functions at current address.\n"); r_list_free (fcns); return -1; } fcn_list_default (core, fcns, false); r_list_free (fcns); return 0; } if (rad && (*rad == 'l' || *rad == 'j')) { fcnlist_gather_metadata (core->anal, core->anal->fcns); } const char *name = input; ut64 addr = core->offset; if (input && *input) { name = input + 1; addr = r_num_math (core->num, name); } RList *fcns = r_list_newf (NULL); if (!fcns) { return -1; } RListIter *iter; RAnalFunction *fcn; r_list_foreach (core->anal->fcns, iter, fcn) { if (!input || r_anal_function_contains (fcn, addr) || (!strcmp (name, fcn->name))) { r_list_append (fcns, fcn); } } // Use afls[asn] to sort by address, size or name, dont sort it here .. r_list_sort (fcns, &cmpfcn); if (!rad) { fcn_list_default (core, fcns, false); r_list_free (fcns); return 0; } switch (*rad) { case '+': r_core_anal_fcn_list_size (core); break; case '=': { // afl= r_list_sort (fcns, cmpaddr); RList *flist = r_list_newf ((RListFree) r_listinfo_free); if (!flist) { r_list_free (fcns); return -1; } ls_foreach (fcns, iter, fcn) { RInterval inter = {r_anal_function_min_addr (fcn), r_anal_function_linear_size (fcn) }; RListInfo *info = r_listinfo_new (r_core_anal_fcn_name (core, fcn), inter, inter, -1, sdb_itoa (fcn->bits, temp, 10)); if (!info) { break; } r_list_append (flist, info); } RTable *table = r_core_table (core, "functions"); r_table_visual_list (table, flist, core->offset, core->blocksize, r_cons_get_size (NULL), r_config_get_i (core->config, "scr.color")); r_cons_printf ("\n%s\n", r_table_tostring (table)); r_table_free (table); r_list_free (flist); break; } case ',': // "afl," "afl,j" case 't': // "aflt" "afltj" if (rad[1] == 'j') { fcn_list_table (core, r_str_trim_head_ro (rad + 2), 'j'); } else { fcn_list_table (core, r_str_trim_head_ro (rad + 1), rad[1]); } break; case 'l': // "afll" "afllj" if (rad[1] == 'j') { fcn_list_verbose_json (core, fcns); } else { char *sp = strchr (rad, ' '); fcn_list_verbose (core, fcns, sp?sp+1: NULL); } break; case 'q': if (rad[1] == 'j') { fcn_list_json (core, fcns, true); } else { fcn_list_default (core, fcns, true); } break; case 'j': fcn_list_json (core, fcns, false); break; case '*': fcn_list_detail (core, fcns); break; case 'm': // "aflm" { char mode = 'm'; if (rad[1] != 0) { if (rad[1] == 'j') { // "aflmj" mode = 'j'; } else if (rad[1] == 'q') { // "aflmq" mode = 'q'; } } fcn_print_makestyle (core, fcns, mode); break; } case 1: fcn_list_legacy (core, fcns); break; default: fcn_list_default (core, fcns, false); break; } r_list_free (fcns); return 0; }
0
509,526
int maria_check_definition(MARIA_KEYDEF *t1_keyinfo, MARIA_COLUMNDEF *t1_recinfo, uint t1_keys, uint t1_recs, MARIA_KEYDEF *t2_keyinfo, MARIA_COLUMNDEF *t2_recinfo, uint t2_keys, uint t2_recs, bool strict) { uint i, j; DBUG_ENTER("maria_check_definition"); if ((strict ? t1_keys != t2_keys : t1_keys > t2_keys)) { DBUG_PRINT("error", ("Number of keys differs: t1_keys=%u, t2_keys=%u", t1_keys, t2_keys)); DBUG_RETURN(1); } if (t1_recs != t2_recs) { DBUG_PRINT("error", ("Number of recs differs: t1_recs=%u, t2_recs=%u", t1_recs, t2_recs)); DBUG_RETURN(1); } for (i= 0; i < t1_keys; i++) { HA_KEYSEG *t1_keysegs= t1_keyinfo[i].seg; HA_KEYSEG *t2_keysegs= t2_keyinfo[i].seg; if (t1_keyinfo[i].flag & HA_FULLTEXT && t2_keyinfo[i].flag & HA_FULLTEXT) continue; else if (t1_keyinfo[i].flag & HA_FULLTEXT || t2_keyinfo[i].flag & HA_FULLTEXT) { DBUG_PRINT("error", ("Key %d has different definition", i)); DBUG_PRINT("error", ("t1_fulltext= %d, t2_fulltext=%d", MY_TEST(t1_keyinfo[i].flag & HA_FULLTEXT), MY_TEST(t2_keyinfo[i].flag & HA_FULLTEXT))); DBUG_RETURN(1); } if (t1_keyinfo[i].flag & HA_SPATIAL && t2_keyinfo[i].flag & HA_SPATIAL) continue; else if (t1_keyinfo[i].flag & HA_SPATIAL || t2_keyinfo[i].flag & HA_SPATIAL) { DBUG_PRINT("error", ("Key %d has different definition", i)); DBUG_PRINT("error", ("t1_spatial= %d, t2_spatial=%d", MY_TEST(t1_keyinfo[i].flag & HA_SPATIAL), MY_TEST(t2_keyinfo[i].flag & HA_SPATIAL))); DBUG_RETURN(1); } if (t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs || t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg) { DBUG_PRINT("error", ("Key %d has different definition", i)); DBUG_PRINT("error", ("t1_keysegs=%d, t1_key_alg=%d", t1_keyinfo[i].keysegs, t1_keyinfo[i].key_alg)); DBUG_PRINT("error", ("t2_keysegs=%d, t2_key_alg=%d", t2_keyinfo[i].keysegs, t2_keyinfo[i].key_alg)); DBUG_RETURN(1); } for (j= t1_keyinfo[i].keysegs; j--;) { uint8 t1_keysegs_j__type= t1_keysegs[j].type; /* Table migration from 4.1 to 5.1. In 5.1 a *TEXT key part is always HA_KEYTYPE_VARTEXT2. In 4.1 we had only the equivalent of HA_KEYTYPE_VARTEXT1. Since we treat both the same on MyISAM level, we can ignore a mismatch between these types. */ if ((t1_keysegs[j].flag & HA_BLOB_PART) && (t2_keysegs[j].flag & HA_BLOB_PART)) { if ((t1_keysegs_j__type == HA_KEYTYPE_VARTEXT2) && (t2_keysegs[j].type == HA_KEYTYPE_VARTEXT1)) t1_keysegs_j__type= HA_KEYTYPE_VARTEXT1; /* purecov: tested */ else if ((t1_keysegs_j__type == HA_KEYTYPE_VARBINARY2) && (t2_keysegs[j].type == HA_KEYTYPE_VARBINARY1)) t1_keysegs_j__type= HA_KEYTYPE_VARBINARY1; /* purecov: inspected */ } if (t1_keysegs_j__type != t2_keysegs[j].type || t1_keysegs[j].language != t2_keysegs[j].language || t1_keysegs[j].null_bit != t2_keysegs[j].null_bit || t1_keysegs[j].length != t2_keysegs[j].length) { DBUG_PRINT("error", ("Key segment %d (key %d) has different " "definition", j, i)); DBUG_PRINT("error", ("t1_type=%d, t1_language=%d, t1_null_bit=%d, " "t1_length=%d", t1_keysegs[j].type, t1_keysegs[j].language, t1_keysegs[j].null_bit, t1_keysegs[j].length)); DBUG_PRINT("error", ("t2_type=%d, t2_language=%d, t2_null_bit=%d, " "t2_length=%d", t2_keysegs[j].type, t2_keysegs[j].language, t2_keysegs[j].null_bit, t2_keysegs[j].length)); DBUG_RETURN(1); } } } for (i= 0; i < t1_recs; i++) { MARIA_COLUMNDEF *t1_rec= &t1_recinfo[i]; MARIA_COLUMNDEF *t2_rec= &t2_recinfo[i]; /* FIELD_SKIP_ZERO can be changed to FIELD_NORMAL in maria_create, see NOTE1 in ma_create.c */ if ((t1_rec->type != t2_rec->type && !(t1_rec->type == (int) FIELD_SKIP_ZERO && t1_rec->length == 1 && t2_rec->type == (int) FIELD_NORMAL)) || t1_rec->length != t2_rec->length || t1_rec->null_bit != t2_rec->null_bit) { DBUG_PRINT("error", ("Field %d has different definition", i)); DBUG_PRINT("error", ("t1_type=%d, t1_length=%d, t1_null_bit=%d", t1_rec->type, t1_rec->length, t1_rec->null_bit)); DBUG_PRINT("error", ("t2_type=%d, t2_length=%d, t2_null_bit=%d", t2_rec->type, t2_rec->length, t2_rec->null_bit)); DBUG_RETURN(1); } } DBUG_RETURN(0); }
0
226,129
GF_Err stri_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; u32 i; GF_SubTrackInformationBox *ptr = (GF_SubTrackInformationBox *)s; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u16(bs, ptr->switch_group); gf_bs_write_u16(bs, ptr->alternate_group); gf_bs_write_u32(bs, ptr->sub_track_id); for (i = 0; i < ptr->attribute_count; i++) { gf_bs_write_u32(bs, ptr->attribute_list[i]); } return GF_OK;
0
225,113
void RemoveDescriptionsFromOpList(OpList* op_list) { for (int i = 0; i < op_list->op_size(); ++i) { OpDef* op_def = op_list->mutable_op(i); RemoveDescriptionsFromOpDef(op_def); } }
0
514,312
multi_update::multi_update(THD *thd_arg, TABLE_LIST *table_list, List<TABLE_LIST> *leaves_list, List<Item> *field_list, List<Item> *value_list, enum enum_duplicates handle_duplicates_arg, bool ignore_arg): select_result_interceptor(thd_arg), all_tables(table_list), leaves(leaves_list), update_tables(0), tmp_tables(0), updated(0), found(0), fields(field_list), values(value_list), table_count(0), copy_field(0), handle_duplicates(handle_duplicates_arg), do_update(1), trans_safe(1), transactional_tables(0), ignore(ignore_arg), error_handled(0), prepared(0), updated_sys_ver(0) { }
0
359,846
WandPrivate void CLISettingOptionInfo(MagickCLI *cli_wand, const char *option,const char *arg1n, const char *arg2n) { ssize_t parse; /* option argument parsing (string to value table lookup) */ const char /* percent escaped versions of the args */ *arg1, *arg2; #define _image_info (cli_wand->wand.image_info) #define _image (cli_wand->wand.images) #define _exception (cli_wand->wand.exception) #define _draw_info (cli_wand->draw_info) #define _quantize_info (cli_wand->quantize_info) #define IfSetOption (*option=='-') #define ArgBoolean IfSetOption ? MagickTrue : MagickFalse #define ArgBooleanNot IfSetOption ? MagickFalse : MagickTrue #define ArgBooleanString (IfSetOption?"true":"false") #define ArgOption(def) (IfSetOption?arg1:(const char *)(def)) assert(cli_wand != (MagickCLI *) NULL); assert(cli_wand->signature == MagickWandSignature); assert(cli_wand->wand.signature == MagickWandSignature); if (cli_wand->wand.debug != MagickFalse) (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), "- Setting Option: %s \"%s\" \"%s\"", option,arg1n,arg2n); arg1 = arg1n, arg2 = arg2n; #if 1 #define _process_flags (cli_wand->process_flags) #define _option_type ((CommandOptionFlags) cli_wand->command->flags) /* Interpret Percent Escapes in Arguments - using first image */ if ( (((_process_flags & ProcessInterpretProperities) != 0 ) || ((_option_type & AlwaysInterpretArgsFlag) != 0) ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { /* Interpret Percent escapes in argument 1 */ if (arg1n != (char *) NULL) { arg1=InterpretImageProperties(_image_info,_image,arg1n,_exception); if (arg1 == (char *) NULL) { CLIWandException(OptionWarning,"InterpretPropertyFailure",option); arg1=arg1n; /* use the given argument as is */ } } if (arg2n != (char *) NULL) { arg2=InterpretImageProperties(_image_info,_image,arg2n,_exception); if (arg2 == (char *) NULL) { CLIWandException(OptionWarning,"InterpretPropertyFailure",option); arg2=arg2n; /* use the given argument as is */ } } } #undef _process_flags #undef _option_type #endif switch (*(option+1)) { case 'a': { if (LocaleCompare("adjoin",option+1) == 0) { _image_info->adjoin = ArgBoolean; break; } if (LocaleCompare("affine",option+1) == 0) { CLIWandWarnReplaced("-draw 'affine ...'"); if (IfSetOption) (void) ParseAffineGeometry(arg1,&_draw_info->affine,_exception); else GetAffineMatrix(&_draw_info->affine); break; } if (LocaleCompare("antialias",option+1) == 0) { _image_info->antialias = _draw_info->stroke_antialias = _draw_info->text_antialias = ArgBoolean; break; } if (LocaleCompare("attenuate",option+1) == 0) { if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,ArgOption("1.0")); break; } if (LocaleCompare("authenticate",option+1) == 0) { (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'b': { if (LocaleCompare("background",option+1) == 0) { /* FUTURE: both _image_info attribute & ImageOption in use! _image_info only used directly for generating new images. SyncImageSettings() used to set per-image attribute. FUTURE: if _image_info->background_color is not set then we should fall back to per-image background_color At this time -background will 'wipe out' the per-image background color! Better error handling of QueryColorCompliance() needed. */ (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); (void) QueryColorCompliance(ArgOption(MogrifyBackgroundColor),AllCompliance, &_image_info->background_color,_exception); break; } if (LocaleCompare("bias",option+1) == 0) { /* FUTURE: bias OBSOLETED, replaced by Artifact "convolve:bias" as it is actually rarely used except in direct convolve operations Usage outside a direct convolve operation is actally non-sensible! SyncImageSettings() used to set per-image attribute. */ if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,"convolve:bias",ArgOption(NULL)); break; } if (LocaleCompare("black-point-compensation",option+1) == 0) { /* Used as a image chromaticity setting SyncImageSettings() used to set per-image attribute. */ (void) SetImageOption(_image_info,option+1,ArgBooleanString); break; } if (LocaleCompare("blue-primary",option+1) == 0) { /* Image chromaticity X,Y NB: Y=X if Y not defined Used by many coders including PNG SyncImageSettings() used to set per-image attribute. */ arg1=ArgOption("0.0"); if (IsGeometry(arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("bordercolor",option+1) == 0) { /* FUTURE: both _image_info attribute & ImageOption in use! SyncImageSettings() used to set per-image attribute. Better error checking of QueryColorCompliance(). */ if (IfSetOption) { (void) SetImageOption(_image_info,option+1,arg1); (void) QueryColorCompliance(arg1,AllCompliance, &_image_info->border_color,_exception); (void) QueryColorCompliance(arg1,AllCompliance, &_draw_info->border_color,_exception); break; } (void) DeleteImageOption(_image_info,option+1); (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, &_image_info->border_color,_exception); (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, &_draw_info->border_color,_exception); break; } if (LocaleCompare("box",option+1) == 0) { CLIWandWarnReplaced("-undercolor"); CLISettingOptionInfo(cli_wand,"-undercolor",arg1, arg2); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'c': { if (LocaleCompare("cache",option+1) == 0) { MagickSizeType limit; if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); limit=MagickResourceInfinity; if (LocaleCompare("unlimited",arg1) != 0) limit=(MagickSizeType) SiPrefixToDoubleInterval(arg1,100.0); (void) SetMagickResourceLimit(MemoryResource,limit); (void) SetMagickResourceLimit(MapResource,2*limit); break; } if (LocaleCompare("caption",option+1) == 0) { (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); break; } if (LocaleCompare("colorspace",option+1) == 0) { /* Setting used for new images via AquireImage() But also used as a SimpleImageOperator Undefined colorspace means don't modify images on read or as a operation */ parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse, ArgOption("undefined")); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace",option, arg1); _image_info->colorspace=(ColorspaceType) parse; break; } if (LocaleCompare("comment",option+1) == 0) { (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); break; } if (LocaleCompare("compose",option+1) == 0) { /* FUTURE: _image_info should be used, SyncImageSettings() used to set per-image attribute. - REMOVE This setting should NOT be used to set image 'compose' "-layer" operators shoud use _image_info if defined otherwise they should use a per-image compose setting. */ parse = ParseCommandOption(MagickComposeOptions,MagickFalse, ArgOption("undefined")); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedComposeOperator", option,arg1); _image_info->compose=(CompositeOperator) parse; (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); break; } if (LocaleCompare("compress",option+1) == 0) { /* FUTURE: What should be used? _image_info or ImageOption ??? The former is more efficent, but Crisy prefers the latter! SyncImageSettings() used to set per-image attribute. The coders appears to use _image_info, not Image_Option however the image attribute (for save) is set from the ImageOption! Note that "undefined" is a different setting to "none". */ parse = ParseCommandOption(MagickCompressOptions,MagickFalse, ArgOption("undefined")); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedImageCompression", option,arg1); _image_info->compression=(CompressionType) parse; (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'd': { if (LocaleCompare("debug",option+1) == 0) { /* SyncImageSettings() used to set per-image attribute. */ arg1=ArgOption("none"); parse = ParseCommandOption(MagickLogEventOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedEventType", option,arg1); (void) SetLogEventMask(arg1); _image_info->debug=IsEventLogging(); /* extract logging*/ cli_wand->wand.debug=IsEventLogging(); break; } if (LocaleCompare("define",option+1) == 0) { if (LocaleNCompare(arg1,"registry:",9) == 0) { if (IfSetOption) (void) DefineImageRegistry(StringRegistryType,arg1+9,_exception); else (void) DeleteImageRegistry(arg1+9); break; } /* DefineImageOption() equals SetImageOption() but with '=' */ if (IfSetOption) (void) DefineImageOption(_image_info,arg1); else if (DeleteImageOption(_image_info,arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"NoSuchOption",option,arg1); break; } if (LocaleCompare("delay",option+1) == 0) { /* Only used for new images via AcquireImage() FUTURE: Option should also be used for "-morph" (color morphing) */ arg1=ArgOption("0"); if (IsGeometry(arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("density",option+1) == 0) { /* FUTURE: strings used in _image_info attr and _draw_info! Basically as density can be in a XxY form! SyncImageSettings() used to set per-image attribute. */ if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); (void) CloneString(&_image_info->density,ArgOption(NULL)); (void) CloneString(&_draw_info->density,_image_info->density); break; } if (LocaleCompare("depth",option+1) == 0) { /* This is also a SimpleImageOperator! for 8->16 vaule trunc !!!! SyncImageSettings() used to set per-image attribute. */ if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); _image_info->depth=IfSetOption?StringToUnsignedLong(arg1) :MAGICKCORE_QUANTUM_DEPTH; break; } if (LocaleCompare("direction",option+1) == 0) { /* Image Option is only used to set _draw_info */ arg1=ArgOption("undefined"); parse = ParseCommandOption(MagickDirectionOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedDirectionType", option,arg1); _draw_info->direction=(DirectionType) parse; (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("display",option+1) == 0) { (void) CloneString(&_image_info->server_name,ArgOption(NULL)); (void) CloneString(&_draw_info->server_name,_image_info->server_name); break; } if (LocaleCompare("dispose",option+1) == 0) { /* only used in setting new images */ arg1=ArgOption("undefined"); parse = ParseCommandOption(MagickDisposeOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedDisposeMethod", option,arg1); (void) SetImageOption(_image_info,option+1,ArgOption("undefined")); break; } if (LocaleCompare("dissimilarity-threshold",option+1) == 0) { /* FUTURE: this is only used by CompareImages() which is used only by the "compare" CLI program at this time. */ arg1=ArgOption(DEFAULT_DISSIMILARITY_THRESHOLD); if (IsGeometry(arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("dither",option+1) == 0) { /* _image_info attr (on/off), _quantize_info attr (on/off) but also ImageInfo and _quantize_info method! FUTURE: merge the duality of the dithering options */ _image_info->dither = ArgBoolean; (void) SetImageOption(_image_info,option+1,ArgOption("none")); _quantize_info->dither_method=(DitherMethod) ParseCommandOption( MagickDitherOptions,MagickFalse,ArgOption("none")); if (_quantize_info->dither_method == NoDitherMethod) _image_info->dither = MagickFalse; break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'e': { if (LocaleCompare("encoding",option+1) == 0) { (void) CloneString(&_draw_info->encoding,ArgOption("undefined")); (void) SetImageOption(_image_info,option+1,_draw_info->encoding); break; } if (LocaleCompare("endian",option+1) == 0) { /* Both _image_info attr and ImageInfo */ arg1 = ArgOption("undefined"); parse = ParseCommandOption(MagickEndianOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedEndianType", option,arg1); /* FUTURE: check alloc/free of endian string! - remove? */ _image_info->endian=(EndianType) (*arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("extract",option+1) == 0) { (void) CloneString(&_image_info->extract,ArgOption(NULL)); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'f': { if (LocaleCompare("family",option+1) == 0) { (void) CloneString(&_draw_info->family,ArgOption(NULL)); break; } if (LocaleCompare("features",option+1) == 0) { (void) SetImageOption(_image_info,"identify:features", ArgBooleanString); if (IfSetOption) (void) SetImageArtifact(_image,"verbose","true"); break; } if (LocaleCompare("fill",option+1) == 0) { /* Set "fill" OR "fill-pattern" in _draw_info The original fill color is preserved if a fill-pattern is given. That way it does not effect other operations that directly using the fill color and, can be retored using "+tile". */ MagickBooleanType status; ExceptionInfo *sans; PixelInfo color; arg1 = ArgOption("none"); /* +fill turns it off! */ (void) SetImageOption(_image_info,option+1,arg1); if (_draw_info->fill_pattern != (Image *) NULL) _draw_info->fill_pattern=DestroyImage(_draw_info->fill_pattern); /* is it a color or a image? -- ignore exceptions */ sans=AcquireExceptionInfo(); status=QueryColorCompliance(arg1,AllCompliance,&color,sans); sans=DestroyExceptionInfo(sans); if (status == MagickFalse) _draw_info->fill_pattern=GetImageCache(_image_info,arg1,_exception); else _draw_info->fill=color; break; } if (LocaleCompare("filter",option+1) == 0) { /* SyncImageSettings() used to set per-image attribute. */ arg1 = ArgOption("undefined"); parse = ParseCommandOption(MagickFilterOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedImageFilter", option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("font",option+1) == 0) { (void) CloneString(&_draw_info->font,ArgOption(NULL)); (void) CloneString(&_image_info->font,_draw_info->font); break; } if (LocaleCompare("format",option+1) == 0) { (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); break; } if (LocaleCompare("fuzz",option+1) == 0) { /* Option used to set image fuzz! unless blank canvas (from color) Image attribute used for color compare operations SyncImageSettings() used to set per-image attribute. FUTURE: Can't find anything else using _image_info->fuzz directly! convert structure attribute to 'option' string */ arg1=ArgOption("0"); if (IsGeometry(arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); _image_info->fuzz=StringToDoubleInterval(arg1,(double) QuantumRange+1.0); (void) SetImageOption(_image_info,option+1,arg1); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'g': { if (LocaleCompare("gravity",option+1) == 0) { /* SyncImageSettings() used to set per-image attribute. */ arg1 = ArgOption("none"); parse = ParseCommandOption(MagickGravityOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedGravityType", option,arg1); _draw_info->gravity=(GravityType) parse; (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("green-primary",option+1) == 0) { /* Image chromaticity X,Y NB: Y=X if Y not defined SyncImageSettings() used to set per-image attribute. Used directly by many coders */ arg1=ArgOption("0.0"); if (IsGeometry(arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'h': { if (LocaleCompare("highlight-color",option+1) == 0) { /* FUTURE: this is only used by CompareImages() which is used only by the "compare" CLI program at this time. */ (void) SetImageOption(_image_info,"compare:highlight-color", ArgOption(NULL)); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'i': { if (LocaleCompare("illuminant",option+1) == 0) { (void) SetImageOption(_image_info,"color:illuminant", ArgOption(NULL)); break; } if (LocaleCompare("intensity",option+1) == 0) { arg1 = ArgOption("undefined"); parse = ParseCommandOption(MagickPixelIntensityOptions,MagickFalse, arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedIntensityType", option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("intent",option+1) == 0) { /* Only used by coders: MIFF, MPC, BMP, PNG and for image profile call to AcquireTransformTLS() SyncImageSettings() used to set per-image attribute. */ arg1 = ArgOption("undefined"); parse = ParseCommandOption(MagickIntentOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedIntentType", option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("interlace",option+1) == 0) { /* _image_info is directly used by coders (so why an image setting?) SyncImageSettings() used to set per-image attribute. */ arg1 = ArgOption("undefined"); parse = ParseCommandOption(MagickInterlaceOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedInterlaceType", option,arg1); _image_info->interlace=(InterlaceType) parse; (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("interline-spacing",option+1) == 0) { if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); _draw_info->interline_spacing=StringToDouble(ArgOption("0"), (char **) NULL); break; } if (LocaleCompare("interpolate",option+1) == 0) { /* SyncImageSettings() used to set per-image attribute. */ arg1 = ArgOption("undefined"); parse = ParseCommandOption(MagickInterpolateOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedInterpolateMethod", option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("interword-spacing",option+1) == 0) { if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); _draw_info->interword_spacing=StringToDouble(ArgOption("0"),(char **) NULL); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'k': { if (LocaleCompare("kerning",option+1) == 0) { if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); _draw_info->kerning=StringToDouble(ArgOption("0"),(char **) NULL); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'l': { if (LocaleCompare("label",option+1) == 0) { /* only used for new images - not in SyncImageOptions() */ (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); break; } if (LocaleCompare("limit",option+1) == 0) { MagickSizeType limit; limit=MagickResourceInfinity; parse= ParseCommandOption(MagickResourceOptions,MagickFalse,arg1); if ( parse < 0 ) CLIWandExceptArgBreak(OptionError,"UnrecognizedResourceType", option,arg1); if (LocaleCompare("unlimited",arg2) != 0) limit=(MagickSizeType) SiPrefixToDoubleInterval(arg2,100.0); (void) SetMagickResourceLimit((ResourceType)parse,limit); break; } if (LocaleCompare("log",option+1) == 0) { if (IfSetOption) { if ((strchr(arg1,'%') == (char *) NULL)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetLogFormat(arg1); } break; } if (LocaleCompare("lowlight-color",option+1) == 0) { /* FUTURE: this is only used by CompareImages() which is used only by the "compare" CLI program at this time. */ (void) SetImageOption(_image_info,"compare:lowlight-color", ArgOption(NULL)); break; } if (LocaleCompare("loop",option+1) == 0) { /* SyncImageSettings() used to set per-image attribute. */ arg1=ArgOption("0"); if (IsGeometry(arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'm': { if (LocaleCompare("mattecolor",option+1) == 0) { /* SyncImageSettings() used to set per-image attribute. */ (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); (void) QueryColorCompliance(ArgOption(MogrifyAlphaColor), AllCompliance,&_image_info->matte_color,_exception); break; } if (LocaleCompare("metric",option+1) == 0) { /* FUTURE: this is only used by CompareImages() which is used only by the "compare" CLI program at this time. */ parse=ParseCommandOption(MagickMetricOptions,MagickFalse,arg1); if ( parse < 0 ) CLIWandExceptArgBreak(OptionError,"UnrecognizedMetricType", option,arg1); (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); break; } if (LocaleCompare("moments",option+1) == 0) { (void) SetImageOption(_image_info,"identify:moments", ArgBooleanString); if (IfSetOption) (void) SetImageArtifact(_image,"verbose","true"); break; } if (LocaleCompare("monitor",option+1) == 0) { (void) SetImageInfoProgressMonitor(_image_info, IfSetOption? MonitorProgress: (MagickProgressMonitor) NULL, (void *) NULL); break; } if (LocaleCompare("monochrome",option+1) == 0) { /* Setting (used by some input coders!) -- why? Warning: This is also Special '-type' SimpleOperator */ _image_info->monochrome= ArgBoolean; break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'o': { if (LocaleCompare("orient",option+1) == 0) { /* Is not used when defining for new images. This makes it more of a 'operation' than a setting FUTURE: make set meta-data operator instead. SyncImageSettings() used to set per-image attribute. */ parse=ParseCommandOption(MagickOrientationOptions,MagickFalse, ArgOption("undefined")); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedImageOrientation", option,arg1); _image_info->orientation=(OrientationType)parse; (void) SetImageOption(_image_info,option+1, ArgOption(NULL)); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'p': { if (LocaleCompare("page",option+1) == 0) { /* Only used for new images and image generators. SyncImageSettings() used to set per-image attribute. ????? That last is WRONG!!!! FUTURE: adjust named 'page' sizes according density */ char *canonical_page, page[MagickPathExtent]; const char *image_option; MagickStatusType flags; RectangleInfo geometry; if (!IfSetOption) { (void) DeleteImageOption(_image_info,option+1); (void) CloneString(&_image_info->page,(char *) NULL); break; } (void) memset(&geometry,0,sizeof(geometry)); image_option=GetImageOption(_image_info,"page"); if (image_option != (const char *) NULL) flags=ParseAbsoluteGeometry(image_option,&geometry); canonical_page=GetPageGeometry(arg1); flags=ParseAbsoluteGeometry(canonical_page,&geometry); canonical_page=DestroyString(canonical_page); (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu", (unsigned long) geometry.width,(unsigned long) geometry.height); if (((flags & XValue) != 0) || ((flags & YValue) != 0)) (void) FormatLocaleString(page,MagickPathExtent,"%lux%lu%+ld%+ld", (unsigned long) geometry.width,(unsigned long) geometry.height, (long) geometry.x,(long) geometry.y); (void) SetImageOption(_image_info,option+1,page); (void) CloneString(&_image_info->page,page); break; } if (LocaleCompare("ping",option+1) == 0) { _image_info->ping=ArgBoolean; break; } if (LocaleCompare("pointsize",option+1) == 0) { if (IfSetOption) { if (IsGeometry(arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); _image_info->pointsize = _draw_info->pointsize = StringToDouble(arg1,(char **) NULL); } else { _image_info->pointsize=0.0; /* unset pointsize */ _draw_info->pointsize=12.0; } break; } if (LocaleCompare("precision",option+1) == 0) { arg1=ArgOption("-1"); if (IsGeometry(arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetMagickPrecision(StringToInteger(arg1)); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'q': { if (LocaleCompare("quality",option+1) == 0) { if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); _image_info->quality= IfSetOption ? StringToUnsignedLong(arg1) : UNDEFINED_COMPRESSION_QUALITY; (void) SetImageOption(_image_info,option+1,ArgOption("0")); break; } if (LocaleCompare("quantize",option+1) == 0) { /* Just a set direct in _quantize_info */ arg1=ArgOption("undefined"); parse=ParseCommandOption(MagickColorspaceOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedColorspace", option,arg1); _quantize_info->colorspace=(ColorspaceType)parse; break; } if (LocaleCompare("quiet",option+1) == 0) { /* FUTURE: if two -quiet is performed you can not do +quiet! This needs to be checked over thoughly. */ static WarningHandler warning_handler = (WarningHandler) NULL; WarningHandler tmp = SetWarningHandler((WarningHandler) NULL); if ( tmp != (WarningHandler) NULL) warning_handler = tmp; /* remember the old handler */ if (!IfSetOption) /* set the old handler */ warning_handler=SetWarningHandler(warning_handler); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'r': { if (LocaleCompare("red-primary",option+1) == 0) { /* Image chromaticity X,Y NB: Y=X if Y not defined Used by many coders SyncImageSettings() used to set per-image attribute. */ arg1=ArgOption("0.0"); if (IsGeometry(arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("regard-warnings",option+1) == 0) /* FUTURE: to be replaced by a 'fatal-level' type setting */ break; if (LocaleCompare("render",option+1) == 0) { /* _draw_info only setting */ _draw_info->render= ArgBooleanNot; break; } if (LocaleCompare("respect-parenthesis",option+1) == 0) { /* link image and setting stacks - option is itself saved on stack! */ (void) SetImageOption(_image_info,option+1,ArgBooleanString); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 's': { if (LocaleCompare("sampling-factor",option+1) == 0) { /* FUTURE: should be converted to jpeg:sampling_factor */ if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) CloneString(&_image_info->sampling_factor,ArgOption(NULL)); break; } if (LocaleCompare("scene",option+1) == 0) { /* SyncImageSettings() used to set this as a per-image attribute. What ??? Why ???? */ if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); _image_info->scene=StringToUnsignedLong(ArgOption("0")); break; } if (LocaleCompare("seed",option+1) == 0) { if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); SetRandomSecretKey( IfSetOption ? (unsigned long) StringToUnsignedLong(arg1) : (unsigned long) time((time_t *) NULL)); break; } if (LocaleCompare("size",option+1) == 0) { /* FUTURE: string in _image_info -- convert to Option ??? Look at the special handling for "size" in SetImageOption() */ (void) CloneString(&_image_info->size,ArgOption(NULL)); break; } if (LocaleCompare("stretch",option+1) == 0) { arg1=ArgOption("undefined"); parse = ParseCommandOption(MagickStretchOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedStretchType", option,arg1); _draw_info->stretch=(StretchType) parse; break; } if (LocaleCompare("stroke",option+1) == 0) { /* set stroke color OR stroke-pattern UPDATE: ensure stroke color is not destroyed is a pattern is given. Just in case the color is also used for other purposes. */ MagickBooleanType status; ExceptionInfo *sans; PixelInfo color; arg1 = ArgOption("none"); /* +fill turns it off! */ (void) SetImageOption(_image_info,option+1,arg1); if (_draw_info->stroke_pattern != (Image *) NULL) _draw_info->stroke_pattern=DestroyImage(_draw_info->stroke_pattern); /* is it a color or a image? -- ignore exceptions */ sans=AcquireExceptionInfo(); status=QueryColorCompliance(arg1,AllCompliance,&color,sans); sans=DestroyExceptionInfo(sans); if (status == MagickFalse) _draw_info->stroke_pattern=GetImageCache(_image_info,arg1,_exception); else _draw_info->stroke=color; break; } if (LocaleCompare("strokewidth",option+1) == 0) { if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); _draw_info->stroke_width=StringToDouble(ArgOption("1.0"), (char **) NULL); break; } if (LocaleCompare("style",option+1) == 0) { arg1=ArgOption("undefined"); parse = ParseCommandOption(MagickStyleOptions,MagickFalse,arg1); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedStyleType", option,arg1); _draw_info->style=(StyleType) parse; break; } #if 0 if (LocaleCompare("subimage-search",option+1) == 0) { /* FUTURE: this is only used by CompareImages() which is used only by the "compare" CLI program at this time. */ (void) SetImageOption(_image_info,option+1,ArgBooleanString); break; } #endif if (LocaleCompare("synchronize",option+1) == 0) { /* FUTURE: syncronize to storage - but what does that mean? */ _image_info->synchronize = ArgBoolean; break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 't': { if (LocaleCompare("taint",option+1) == 0) { /* SyncImageSettings() used to set per-image attribute. */ (void) SetImageOption(_image_info,option+1,ArgBooleanString); break; } if (LocaleCompare("texture",option+1) == 0) { /* Note: arguments do not have percent escapes expanded */ /* FUTURE: move _image_info string to option splay-tree Other than "montage" what uses "texture" ???? */ (void) CloneString(&_image_info->texture,ArgOption(NULL)); break; } if (LocaleCompare("tile",option+1) == 0) { /* Note: arguments do not have percent escapes expanded */ _draw_info->fill_pattern=IfSetOption ?GetImageCache(_image_info,arg1,_exception) :DestroyImage(_draw_info->fill_pattern); break; } if (LocaleCompare("tile-offset",option+1) == 0) { /* SyncImageSettings() used to set per-image attribute. ??? */ arg1=ArgOption("0"); if (IsGeometry(arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } if (LocaleCompare("transparent-color",option+1) == 0) { /* FUTURE: both _image_info attribute & ImageOption in use! _image_info only used for generating new images. SyncImageSettings() used to set per-image attribute. Note that +transparent-color, means fall-back to image attribute so ImageOption is deleted, not set to a default. */ if (IfSetOption && (IsGeometry(arg1) == MagickFalse)) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); (void) QueryColorCompliance(ArgOption("none"),AllCompliance, &_image_info->transparent_color,_exception); break; } if (LocaleCompare("treedepth",option+1) == 0) { (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); _quantize_info->tree_depth=StringToUnsignedLong(ArgOption("0")); break; } if (LocaleCompare("type",option+1) == 0) { /* SyncImageSettings() used to set per-image attribute. */ parse=ParseCommandOption(MagickTypeOptions,MagickFalse, ArgOption("undefined")); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedImageType", option,arg1); _image_info->type=(ImageType) parse; (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'u': { if (LocaleCompare("undercolor",option+1) == 0) { (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); (void) QueryColorCompliance(ArgOption("none"),AllCompliance, &_draw_info->undercolor,_exception); break; } if (LocaleCompare("units",option+1) == 0) { /* SyncImageSettings() used to set per-image attribute. Should this effect _draw_info X and Y resolution? FUTURE: this probably should be part of the density setting */ parse=ParseCommandOption(MagickResolutionOptions,MagickFalse, ArgOption("undefined")); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedUnitsType", option,arg1); _image_info->units=(ResolutionType) parse; (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'v': { if (LocaleCompare("verbose",option+1) == 0) { /* FUTURE: Remember all options become image artifacts _image_info->verbose is only used by coders. */ (void) SetImageOption(_image_info,option+1,ArgBooleanString); _image_info->verbose= ArgBoolean; _image_info->ping=MagickFalse; /* verbose can't be a ping */ break; } if (LocaleCompare("virtual-pixel",option+1) == 0) { /* SyncImageSettings() used to set per-image attribute. This is VERY deep in the image caching structure. */ parse=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, ArgOption("undefined")); if (parse < 0) CLIWandExceptArgBreak(OptionError,"UnrecognizedVirtualPixelMethod", option,arg1); (void) SetImageOption(_image_info,option+1,ArgOption(NULL)); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } case 'w': { if (LocaleCompare("weight",option+1) == 0) { ssize_t weight; weight=ParseCommandOption(MagickWeightOptions,MagickFalse,arg1); if (weight == -1) weight=(ssize_t) StringToUnsignedLong(arg1); _draw_info->weight=(size_t) weight; break; } if (LocaleCompare("white-point",option+1) == 0) { /* Used as a image chromaticity setting SyncImageSettings() used to set per-image attribute. */ arg1=ArgOption("0.0"); if (IsGeometry(arg1) == MagickFalse) CLIWandExceptArgBreak(OptionError,"InvalidArgument",option,arg1); (void) SetImageOption(_image_info,option+1,arg1); break; } CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } default: CLIWandExceptionBreak(OptionError,"UnrecognizedOption",option); } /* clean up percent escape interpreted strings */ if ((arg1 && arg1n) && (arg1 != arg1n )) arg1=DestroyString((char *) arg1); if ((arg2 && arg2n) && (arg2 != arg2n )) arg2=DestroyString((char *) arg2); #undef _image_info #undef _exception #undef _draw_info #undef _quantize_info #undef IfSetOption #undef ArgBoolean #undef ArgBooleanNot #undef ArgBooleanString #undef ArgOption return; }
0
279,951
check_overwrite( exarg_T *eap, buf_T *buf, char_u *fname, // file name to be used (can differ from // buf->ffname) char_u *ffname, // full path version of fname int other) // writing under other name { /* * Write to another file or b_flags set or not writing the whole file: * overwriting only allowed with '!'. */ if ( (other || (buf->b_flags & BF_NOTEDITED) || ((buf->b_flags & BF_NEW) && vim_strchr(p_cpo, CPO_OVERNEW) == NULL) || (buf->b_flags & BF_READERR)) && !p_wa && vim_fexists(ffname)) { if (!eap->forceit && !eap->append) { #ifdef UNIX // with UNIX it is possible to open a directory if (mch_isdir(ffname)) { semsg(_(e_src_is_directory), ffname); return FAIL; } #endif #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) { char_u buff[DIALOG_MSG_SIZE]; dialog_msg(buff, _("Overwrite existing file \"%s\"?"), fname); if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) != VIM_YES) return FAIL; eap->forceit = TRUE; } else #endif { emsg(_(e_file_exists)); return FAIL; } } // For ":w! filename" check that no swap file exists for "filename". if (other && !emsg_silent) { char_u *dir; char_u *p; int r; char_u *swapname; // We only try the first entry in 'directory', without checking if // it's writable. If the "." directory is not writable the write // will probably fail anyway. // Use 'shortname' of the current buffer, since there is no buffer // for the written file. if (*p_dir == NUL) { dir = alloc(5); if (dir == NULL) return FAIL; STRCPY(dir, "."); } else { dir = alloc(MAXPATHL); if (dir == NULL) return FAIL; p = p_dir; copy_option_part(&p, dir, MAXPATHL, ","); } swapname = makeswapname(fname, ffname, curbuf, dir); vim_free(dir); r = vim_fexists(swapname); if (r) { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if (p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) { char_u buff[DIALOG_MSG_SIZE]; dialog_msg(buff, _("Swap file \"%s\" exists, overwrite anyway?"), swapname); if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) != VIM_YES) { vim_free(swapname); return FAIL; } eap->forceit = TRUE; } else #endif { semsg(_(e_swap_file_exists_str_silent_overrides), swapname); vim_free(swapname); return FAIL; } } vim_free(swapname); } } return OK; }
0
222,852
bool GraphProperties::HasOutputProperties(const string& node_name) const { return output_properties_.find(node_name) != output_properties_.end(); }
0
395,067
redraw_buf_later(buf_T *buf, int type) { win_T *wp; FOR_ALL_WINDOWS(wp) { if (wp->w_buffer == buf) redraw_win_later(wp, type); } #if defined(FEAT_TERMINAL) && defined(FEAT_PROP_POPUP) // terminal in popup window is not in list of windows if (curwin->w_buffer == buf) redraw_win_later(curwin, type); #endif }
0
384,889
f_fnamemodify(typval_T *argvars, typval_T *rettv) { char_u *fname; char_u *mods; int usedlen = 0; int len = 0; char_u *fbuf = NULL; char_u buf[NUMBUFLEN]; if (in_vim9script() && (check_for_string_arg(argvars, 0) == FAIL || check_for_string_arg(argvars, 1) == FAIL)) return; fname = tv_get_string_chk(&argvars[0]); mods = tv_get_string_buf_chk(&argvars[1], buf); if (mods == NULL || fname == NULL) fname = NULL; else { len = (int)STRLEN(fname); if (mods != NULL && *mods != NUL) (void)modify_fname(mods, FALSE, &usedlen, &fname, &fbuf, &len); } rettv->v_type = VAR_STRING; if (fname == NULL) rettv->vval.v_string = NULL; else rettv->vval.v_string = vim_strnsave(fname, len); vim_free(fbuf); }
0
226,230
GF_Err prhd_box_read(GF_Box *s, GF_BitStream *bs) { GF_ProjectionHeaderBox *ptr = (GF_ProjectionHeaderBox *)s; ISOM_DECREASE_SIZE(ptr, 12) ptr->yaw = (s32) gf_bs_read_u32(bs); ptr->pitch = (s32) gf_bs_read_u32(bs); ptr->roll = (s32) gf_bs_read_u32(bs); return GF_OK;
0
463,124
static void annotation_get_usermodseq(annotate_state_t *state, struct annotate_entry_list *entry) { struct buf value = BUF_INITIALIZER; struct mboxname_counters counters; char *mboxname = NULL; memset(&counters, 0, sizeof(struct mboxname_counters)); assert(state); assert(state->userid); mboxname = mboxname_user_mbox(state->userid, NULL); mboxname_read_counters(mboxname, &counters); buf_printf(&value, "%llu", counters.highestmodseq); output_entryatt(state, entry->name, state->userid, &value); free(mboxname); buf_free(&value); }
0
508,369
fill_record(THD *thd, TABLE *table_arg, List<Item> &fields, List<Item> &values, bool ignore_errors, bool update) { List_iterator_fast<Item> f(fields),v(values); Item *value, *fld; Item_field *field; bool save_abort_on_warning= thd->abort_on_warning; bool save_no_errors= thd->no_errors; DBUG_ENTER("fill_record"); thd->no_errors= ignore_errors; /* Reset the table->auto_increment_field_not_null as it is valid for only one row. */ if (fields.elements) { /* On INSERT or UPDATE fields are checked to be from the same table, thus we safely can take table from the first field. */ fld= (Item_field*)f++; if (!(field= fld->field_for_view_update())) { my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name); goto err; } DBUG_ASSERT(field->field->table == table_arg); table_arg->auto_increment_field_not_null= FALSE; f.rewind(); } while ((fld= f++)) { if (!(field= fld->field_for_view_update())) { my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), fld->name); goto err; } value=v++; Field *rfield= field->field; TABLE* table= rfield->table; if (table->next_number_field && rfield->field_index == table->next_number_field->field_index) table->auto_increment_field_not_null= TRUE; if (rfield->vcol_info && !value->vcol_assignment_allowed_value() && table->s->table_category != TABLE_CATEGORY_TEMPORARY) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN, ER_THD(thd, ER_WARNING_NON_DEFAULT_VALUE_FOR_VIRTUAL_COLUMN), rfield->field_name, table->s->table_name.str); } if (rfield->stored_in_db() && (value->save_in_field(rfield, 0)) < 0 && !ignore_errors) { my_message(ER_UNKNOWN_ERROR, ER_THD(thd, ER_UNKNOWN_ERROR), MYF(0)); goto err; } rfield->set_has_explicit_value(); } if (update) table_arg->evaluate_update_default_function(); else if (table_arg->default_field && table_arg->update_default_fields(ignore_errors)) goto err; /* Update virtual fields */ if (table_arg->vfield && table_arg->update_virtual_fields(table_arg->file, VCOL_UPDATE_FOR_WRITE)) goto err; thd->abort_on_warning= save_abort_on_warning; thd->no_errors= save_no_errors; DBUG_RETURN(thd->is_error()); err: DBUG_PRINT("error",("got error")); thd->abort_on_warning= save_abort_on_warning; thd->no_errors= save_no_errors; if (fields.elements) table_arg->auto_increment_field_not_null= FALSE; DBUG_RETURN(TRUE); }
0
220,205
void Graph::ToGraphDefSubRange(GraphDef* graph_def, int from_node_id) const { graph_def->Clear(); *graph_def->mutable_versions() = versions(); *graph_def->mutable_library() = ops_.ToProto(); graph_def->mutable_node()->Reserve(std::max(1, num_nodes() - from_node_id)); std::vector<const Edge*> inputs; // Construct this outside the loop for speed. for (auto id = from_node_id; id < num_node_ids(); ++id) { const Node* node = FindNodeId(id); if (node == nullptr || !node->IsOp()) continue; NodeDef* node_def = graph_def->add_node(); *node_def = node->def(); // Use the node's assigned device, if any, instead of the device requested // in the NodeDef. if (!node->assigned_device_name().empty()) { node_def->set_device(node->assigned_device_name()); } // Get the inputs for this Node. We make sure control inputs are // after data inputs, as required by GraphDef. inputs.clear(); inputs.resize(node->num_inputs(), nullptr); for (const Edge* edge : node->in_edges()) { if (edge->IsControlEdge()) { inputs.push_back(edge); } else { DCHECK(edge->dst_input() < inputs.size()) << "Edge " << edge->DebugString() << " is overflowing the expected number of inputs (" << node->num_inputs() << ") for node " << node->DebugString(); CHECK(inputs[edge->dst_input()] == nullptr) << "Edge " << edge->src()->name() << "->" << edge->dst()->name() << " conflicts with pre-existing input edge " << inputs[edge->dst_input()]->src()->name() << "->" << inputs[edge->dst_input()]->dst()->name(); inputs[edge->dst_input()] = edge; } } // Sort the control inputs for more predictable serialization. std::sort(inputs.begin() + node->num_inputs(), inputs.end(), [](const Edge* a, const Edge* b) -> bool { return a->src()->name() < b->src()->name(); }); node_def->clear_input(); node_def->mutable_input()->Reserve(inputs.size()); for (size_t i = 0; i < inputs.size(); ++i) { const Edge* edge = inputs[i]; if (edge == nullptr) { if (i < node->requested_inputs().size()) { node_def->add_input(node->requested_inputs()[i]); } else { node_def->add_input(""); } } else { const Node* src = edge->src(); if (!src->IsOp()) continue; AddInput(node_def, src->name(), edge->src_output()); } } } }
0
233,837
void fmtutil_read_iff_format(deark *c, struct de_iffctx *ictx, i64 pos, i64 len) { if(!ictx->f || !ictx->handle_chunk_fn) return; // Internal error ictx->level = 0; fourcc_clear(&ictx->main_fmt4cc); fourcc_clear(&ictx->main_contentstype4cc); fourcc_clear(&ictx->curr_container_fmt4cc); fourcc_clear(&ictx->curr_container_contentstype4cc); if(ictx->alignment==0) { ictx->alignment = 2; } if(ictx->sizeof_len==0) { ictx->sizeof_len = 4; } if(ictx->input_encoding==DE_ENCODING_UNKNOWN) { ictx->input_encoding = DE_ENCODING_ASCII; } do_iff_chunk_sequence(c, ictx, pos, len, 0); }
0
220,450
Status ComputeConv2DDimension(const Conv2DParameters& params, const Tensor& input, const Tensor& filter, Conv2DDimensions* dimensions) { // Check that 2D convolution input and filter have exactly 4 dimensions. TF_REQUIRES(input.dims() == 4, errors::InvalidArgument("input must be 4-dimensional", input.shape().DebugString())); TF_REQUIRES(filter.dims() == 4, errors::InvalidArgument("filter must be 4-dimensional: ", filter.shape().DebugString())); for (int i = 0; i < 3; i++) { TF_REQUIRES( FastBoundsCheck(filter.dim_size(i), std::numeric_limits<int>::max()), errors::InvalidArgument("filter too large")); } // The last dimension for input is in_depth. Check that it is the same as the // filter's in_depth or it is evenly divisible by filter's in_depth. const int64_t in_depth_raw = GetTensorDim(input, params.data_format, 'C'); const int64_t patch_depth_raw = filter.dim_size(2); TF_REQUIRES(FastBoundsCheck(in_depth_raw, std::numeric_limits<int>::max()), errors::InvalidArgument("Input depth too large")); TF_REQUIRES(FastBoundsCheck(patch_depth_raw, std::numeric_limits<int>::max()), errors::InvalidArgument("Patch depth too large")); const int in_depth = static_cast<int>(in_depth_raw); const int patch_depth = static_cast<int>(patch_depth_raw); TF_REQUIRES(patch_depth > 0, errors::InvalidArgument( "filter depth must be stricly positive, got ", patch_depth)); TF_REQUIRES(in_depth % patch_depth == 0, errors::InvalidArgument( "input depth must be evenly divisible by filter depth: ", in_depth, " vs ", patch_depth)); // The last dimension for filter is out_depth. const int out_depth = static_cast<int>(filter.dim_size(3)); // The second dimension for input is rows/height. // The first dimension for filter is rows/height. const int64_t input_rows_raw = GetTensorDim(input, params.data_format, 'H'); TF_REQUIRES(FastBoundsCheck(input_rows_raw, std::numeric_limits<int>::max()), errors::InvalidArgument("Input rows too large")); const int input_rows = static_cast<int>(input_rows_raw); const int filter_rows = static_cast<int>(filter.dim_size(0)); // The third dimension for input is columns/width. // The second dimension for filter is columns/width. const int64_t input_cols_raw = GetTensorDim(input, params.data_format, 'W'); TF_REQUIRES(FastBoundsCheck(input_cols_raw, std::numeric_limits<int>::max()), errors::InvalidArgument("Input cols too large")); const int input_cols = static_cast<int>(input_cols_raw); const int filter_cols = static_cast<int>(filter.dim_size(1)); // The first dimension for input is batch. const int64_t batch_raw = GetTensorDim(input, params.data_format, 'N'); TF_REQUIRES(FastBoundsCheck(batch_raw, std::numeric_limits<int>::max()), errors::InvalidArgument("batch is too large")); const int batch = static_cast<int>(batch_raw); // Take the stride and dilation from the second and third dimensions only (we // do not support striding or dilation on the batch or depth dimension). const int stride_rows = GetTensorDim(params.strides, params.data_format, 'H'); const int stride_cols = GetTensorDim(params.strides, params.data_format, 'W'); const int dilation_rows = GetTensorDim(params.dilations, params.data_format, 'H'); const int dilation_cols = GetTensorDim(params.dilations, params.data_format, 'W'); int64_t pad_rows_before, pad_rows_after, pad_cols_before, pad_cols_after; if (params.padding == Padding::EXPLICIT) { GetExplicitPaddingForDim(params.explicit_paddings, params.data_format, 'H', &pad_rows_before, &pad_rows_after); GetExplicitPaddingForDim(params.explicit_paddings, params.data_format, 'W', &pad_cols_before, &pad_cols_after); } // Compute windowed output sizes for rows and columns. int64_t out_rows = 0, out_cols = 0; TF_RETURN_IF_ERROR(GetWindowedOutputSizeVerboseV2( input_rows, filter_rows, dilation_rows, stride_rows, params.padding, &out_rows, &pad_rows_before, &pad_rows_after)); TF_RETURN_IF_ERROR(GetWindowedOutputSizeVerboseV2( input_cols, filter_cols, dilation_cols, stride_cols, params.padding, &out_cols, &pad_cols_before, &pad_cols_after)); dimensions->batch = batch; dimensions->input_rows = input_rows; dimensions->input_cols = input_cols; dimensions->in_depth = in_depth; dimensions->filter_rows = filter_rows; dimensions->filter_cols = filter_cols; dimensions->patch_depth = patch_depth; dimensions->out_depth = out_depth; dimensions->stride_rows = stride_rows; dimensions->stride_cols = stride_cols; dimensions->dilation_rows = dilation_rows; dimensions->dilation_cols = dilation_cols; dimensions->out_rows = out_rows; dimensions->out_cols = out_cols; dimensions->pad_rows_before = pad_rows_before; dimensions->pad_rows_after = pad_rows_after; dimensions->pad_cols_before = pad_cols_before; dimensions->pad_cols_after = pad_cols_after; return Status::OK(); }
0
418,772
f_getmousepos(typval_T *argvars UNUSED, typval_T *rettv) { dict_T *d; win_T *wp; int row = mouse_row; int col = mouse_col; varnumber_T winid = 0; varnumber_T winrow = 0; varnumber_T wincol = 0; linenr_T lnum = 0; varnumber_T column = 0; if (rettv_dict_alloc(rettv) == FAIL) return; d = rettv->vval.v_dict; dict_add_number(d, "screenrow", (varnumber_T)mouse_row + 1); dict_add_number(d, "screencol", (varnumber_T)mouse_col + 1); wp = mouse_find_win(&row, &col, FIND_POPUP); if (wp != NULL) { int top_off = 0; int left_off = 0; int height = wp->w_height + wp->w_status_height; #ifdef FEAT_PROP_POPUP if (WIN_IS_POPUP(wp)) { top_off = popup_top_extra(wp); left_off = popup_left_extra(wp); height = popup_height(wp); } #endif if (row < height) { winid = wp->w_id; winrow = row + 1; wincol = col + 1; row -= top_off; col -= left_off; if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width) { (void)mouse_comp_pos(wp, &row, &col, &lnum, NULL); col = vcol2col(wp, lnum, col); column = col + 1; } } } dict_add_number(d, "winid", winid); dict_add_number(d, "winrow", winrow); dict_add_number(d, "wincol", wincol); dict_add_number(d, "line", (varnumber_T)lnum); dict_add_number(d, "column", column); }
0
498,627
apply_colormap (guchar *dest, const guchar *src, guint width, const guchar *cmap, gboolean alpha, guint16 index) { guint x; if (alpha) { for (x = 0; x < width; x++) { *(dest++) = cmap[(*src - index) * 4]; *(dest++) = cmap[(*src - index) * 4 + 1]; *(dest++) = cmap[(*src - index) * 4 + 2]; *(dest++) = cmap[(*src - index) * 4 + 3]; src++; } } else { for (x = 0; x < width; x++) { *(dest++) = cmap[(*src - index) * 3]; *(dest++) = cmap[(*src - index) * 3 + 1]; *(dest++) = cmap[(*src - index) * 3 + 2]; src++; } } }
0
312,570
qf_jump_to_usable_window(int qf_fnum, int newwin, int *opened_window) { win_T *usable_wp = NULL; int usable_win = FALSE; qf_info_T *ll_ref = NULL; // If opening a new window, then don't use the location list referred by // the current window. Otherwise two windows will refer to the same // location list. if (!newwin) ll_ref = curwin->w_llist_ref; if (ll_ref != NULL) { // Find a non-quickfix window with this location list usable_wp = qf_find_win_with_loclist(ll_ref); if (usable_wp != NULL) usable_win = TRUE; } if (!usable_win) { // Locate a window showing a normal buffer win_T *win = qf_find_win_with_normal_buf(); if (win != NULL) usable_win = TRUE; } // If no usable window is found and 'switchbuf' contains "usetab" // then search in other tabs. if (!usable_win && (swb_flags & SWB_USETAB)) usable_win = qf_goto_tabwin_with_file(qf_fnum); // If there is only one window and it is the quickfix window, create a // new one above the quickfix window. if ((ONE_WINDOW && bt_quickfix(curbuf)) || !usable_win || newwin) { if (qf_open_new_file_win(ll_ref) != OK) return FAIL; *opened_window = TRUE; // close it when fail } else { if (curwin->w_llist_ref != NULL) // In a location window qf_goto_win_with_ll_file(usable_wp, qf_fnum, ll_ref); else // In a quickfix window qf_goto_win_with_qfl_file(qf_fnum); } return OK; }
0
224,592
Status MaxPoolShape(shape_inference::InferenceContext* c) { return MaxPoolShapeImpl(c, /*supports_explicit_padding=*/false); }
0
369,338
static int io_shutdown(struct io_kiocb *req, unsigned int issue_flags) { #if defined(CONFIG_NET) struct socket *sock; int ret; if (issue_flags & IO_URING_F_NONBLOCK) return -EAGAIN; sock = sock_from_file(req->file); if (unlikely(!sock)) return -ENOTSOCK; ret = __sys_shutdown_sock(sock, req->shutdown.how); if (ret < 0) req_set_fail(req); io_req_complete(req, ret); return 0; #else return -EOPNOTSUPP; #endif }
0
509,470
static int lex_one_token(YYSTYPE *yylval, THD *thd) { uchar UNINIT_VAR(c); bool comment_closed; int tokval, result_state; uint length; enum my_lex_states state; Lex_input_stream *lip= & thd->m_parser_state->m_lip; LEX *lex= thd->lex; CHARSET_INFO *const cs= thd->charset(); const uchar *const state_map= cs->state_map; const uchar *const ident_map= cs->ident_map; lip->yylval=yylval; // The global state lip->start_token(); state=lip->next_state; lip->next_state=MY_LEX_OPERATOR_OR_IDENT; for (;;) { switch (state) { case MY_LEX_OPERATOR_OR_IDENT: // Next is operator or keyword case MY_LEX_START: // Start of token // Skip starting whitespace while(state_map[c= lip->yyPeek()] == MY_LEX_SKIP) { if (c == '\n') lip->yylineno++; lip->yySkip(); } /* Start of real token */ lip->restart_token(); c= lip->yyGet(); state= (enum my_lex_states) state_map[c]; break; case MY_LEX_ESCAPE: if (!lip->eof() && lip->yyGet() == 'N') { // Allow \N as shortcut for NULL yylval->lex_str.str=(char*) "\\N"; yylval->lex_str.length=2; return NULL_SYM; } /* Fall through */ case MY_LEX_CHAR: // Unknown or single char token case MY_LEX_SKIP: // This should not happen if (c != ')') lip->next_state= MY_LEX_START; // Allow signed numbers return((int) c); case MY_LEX_MINUS_OR_COMMENT: if (lip->yyPeek() == '-' && (my_isspace(cs,lip->yyPeekn(1)) || my_iscntrl(cs,lip->yyPeekn(1)))) { state=MY_LEX_COMMENT; break; } lip->next_state= MY_LEX_START; // Allow signed numbers return((int) c); case MY_LEX_PLACEHOLDER: /* Check for a placeholder: it should not precede a possible identifier because of binlogging: when a placeholder is replaced with its value in a query for the binlog, the query must stay grammatically correct. */ lip->next_state= MY_LEX_START; // Allow signed numbers if (lip->stmt_prepare_mode && !ident_map[(uchar) lip->yyPeek()]) return(PARAM_MARKER); return((int) c); case MY_LEX_COMMA: lip->next_state= MY_LEX_START; // Allow signed numbers /* Warning: This is a work around, to make the "remember_name" rule in sql/sql_yacc.yy work properly. The problem is that, when parsing "select expr1, expr2", the code generated by bison executes the *pre* action remember_name (see select_item) *before* actually parsing the first token of expr2. */ lip->restart_token(); return((int) c); case MY_LEX_IDENT_OR_NCHAR: { uint sep; if (lip->yyPeek() != '\'') { state= MY_LEX_IDENT; break; } /* Found N'string' */ lip->yySkip(); // Skip ' if (lip->get_text(&yylval->lex_str, (sep= lip->yyGetLast()), 2, 1)) { state= MY_LEX_CHAR; // Read char by char break; } lip->body_utf8_append(lip->m_cpp_text_start); lip->body_utf8_append_escape(thd, &yylval->lex_str, national_charset_info, lip->m_cpp_text_end, sep); lex->text_string_is_7bit= (lip->tok_bitmap & 0x80) ? 0 : 1; return(NCHAR_STRING); } case MY_LEX_IDENT_OR_HEX: if (lip->yyPeek() == '\'') { // Found x'hex-number' state= MY_LEX_HEX_NUMBER; break; } /* fall through */ case MY_LEX_IDENT_OR_BIN: if (lip->yyPeek() == '\'') { // Found b'bin-number' state= MY_LEX_BIN_NUMBER; break; } /* fall through */ case MY_LEX_IDENT: const char *start; #if defined(USE_MB) && defined(USE_MB_IDENT) if (use_mb(cs)) { result_state= IDENT_QUOTED; int char_length= my_charlen(cs, lip->get_ptr() - 1, lip->get_end_of_query()); if (char_length <= 0) { state= MY_LEX_CHAR; continue; } lip->skip_binary(char_length - 1); while (ident_map[c=lip->yyGet()]) { char_length= my_charlen(cs, lip->get_ptr() - 1, lip->get_end_of_query()); if (char_length <= 0) break; lip->skip_binary(char_length - 1); } } else #endif { for (result_state= c; ident_map[(uchar) (c= lip->yyGet())]; result_state|= c) ; /* If there were non-ASCII characters, mark that we must convert */ result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; } length= lip->yyLength(); start= lip->get_ptr(); if (lip->ignore_space) { /* If we find a space then this can't be an identifier. We notice this below by checking start != lex->ptr. */ for (; state_map[(uchar) c] == MY_LEX_SKIP ; c= lip->yyGet()) { if (c == '\n') lip->yylineno++; } } if (start == lip->get_ptr() && c == '.' && ident_map[(uchar) lip->yyPeek()]) lip->next_state=MY_LEX_IDENT_SEP; else { // '(' must follow directly if function lip->yyUnget(); if ((tokval = find_keyword(lip, length, c == '('))) { lip->next_state= MY_LEX_START; // Allow signed numbers return(tokval); // Was keyword } lip->yySkip(); // next state does a unget } yylval->lex_str=get_token(lip, 0, length); /* Note: "SELECT _bla AS 'alias'" _bla should be considered as a IDENT if charset haven't been found. So we don't use MYF(MY_WME) with get_charset_by_csname to avoid producing an error. */ if (yylval->lex_str.str[0] == '_') { CHARSET_INFO *cs= get_charset_by_csname(yylval->lex_str.str + 1, MY_CS_PRIMARY, MYF(0)); if (cs) { yylval->charset= cs; lip->m_underscore_cs= cs; lip->body_utf8_append(lip->m_cpp_text_start, lip->get_cpp_tok_start() + length); return(UNDERSCORE_CHARSET); } } lip->body_utf8_append(lip->m_cpp_text_start); lip->body_utf8_append_ident(thd, &yylval->lex_str, lip->m_cpp_text_end); return(result_state); // IDENT or IDENT_QUOTED case MY_LEX_IDENT_SEP: // Found ident and now '.' yylval->lex_str.str= (char*) lip->get_ptr(); yylval->lex_str.length= 1; c= lip->yyGet(); // should be '.' lip->next_state= MY_LEX_IDENT_START; // Next is ident (not keyword) if (!ident_map[(uchar) lip->yyPeek()]) // Probably ` or " lip->next_state= MY_LEX_START; return((int) c); case MY_LEX_NUMBER_IDENT: // number or ident which num-start if (lip->yyGetLast() == '0') { c= lip->yyGet(); if (c == 'x') { while (my_isxdigit(cs,(c = lip->yyGet()))) ; if ((lip->yyLength() >= 3) && !ident_map[c]) { /* skip '0x' */ yylval->lex_str=get_token(lip, 2, lip->yyLength()-2); return (HEX_NUM); } lip->yyUnget(); state= MY_LEX_IDENT_START; break; } else if (c == 'b') { while ((c= lip->yyGet()) == '0' || c == '1') ; if ((lip->yyLength() >= 3) && !ident_map[c]) { /* Skip '0b' */ yylval->lex_str= get_token(lip, 2, lip->yyLength()-2); return (BIN_NUM); } lip->yyUnget(); state= MY_LEX_IDENT_START; break; } lip->yyUnget(); } while (my_isdigit(cs, (c = lip->yyGet()))) ; if (!ident_map[c]) { // Can't be identifier state=MY_LEX_INT_OR_REAL; break; } if (c == 'e' || c == 'E') { // The following test is written this way to allow numbers of type 1e1 if (my_isdigit(cs,lip->yyPeek()) || (c=(lip->yyGet())) == '+' || c == '-') { // Allow 1E+10 if (my_isdigit(cs,lip->yyPeek())) // Number must have digit after sign { lip->yySkip(); while (my_isdigit(cs,lip->yyGet())) ; yylval->lex_str=get_token(lip, 0, lip->yyLength()); return(FLOAT_NUM); } } lip->yyUnget(); } // fall through case MY_LEX_IDENT_START: // We come here after '.' result_state= IDENT; #if defined(USE_MB) && defined(USE_MB_IDENT) if (use_mb(cs)) { result_state= IDENT_QUOTED; while (ident_map[c=lip->yyGet()]) { int char_length= my_charlen(cs, lip->get_ptr() - 1, lip->get_end_of_query()); if (char_length <= 0) break; lip->skip_binary(char_length - 1); } } else #endif { for (result_state=0; ident_map[c= lip->yyGet()]; result_state|= c) ; /* If there were non-ASCII characters, mark that we must convert */ result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; } if (c == '.' && ident_map[(uchar) lip->yyPeek()]) lip->next_state=MY_LEX_IDENT_SEP;// Next is '.' yylval->lex_str= get_token(lip, 0, lip->yyLength()); lip->body_utf8_append(lip->m_cpp_text_start); lip->body_utf8_append_ident(thd, &yylval->lex_str, lip->m_cpp_text_end); return(result_state); case MY_LEX_USER_VARIABLE_DELIMITER: // Found quote char { uint double_quotes= 0; char quote_char= c; // Used char while ((c=lip->yyGet())) { int var_length= my_charlen(cs, lip->get_ptr() - 1, lip->get_end_of_query()); if (var_length == 1) { if (c == quote_char) { if (lip->yyPeek() != quote_char) break; c=lip->yyGet(); double_quotes++; continue; } } #ifdef USE_MB else if (var_length > 1) { lip->skip_binary(var_length - 1); } #endif } if (double_quotes) yylval->lex_str=get_quoted_token(lip, 1, lip->yyLength() - double_quotes -1, quote_char); else yylval->lex_str=get_token(lip, 1, lip->yyLength() -1); if (c == quote_char) lip->yySkip(); // Skip end ` lip->next_state= MY_LEX_START; lip->body_utf8_append(lip->m_cpp_text_start); lip->body_utf8_append_ident(thd, &yylval->lex_str, lip->m_cpp_text_end); return(IDENT_QUOTED); } case MY_LEX_INT_OR_REAL: // Complete int or incomplete real if (c != '.') { // Found complete integer number. yylval->lex_str=get_token(lip, 0, lip->yyLength()); return int_token(yylval->lex_str.str, (uint) yylval->lex_str.length); } // fall through case MY_LEX_REAL: // Incomplete real number while (my_isdigit(cs,c = lip->yyGet())) ; if (c == 'e' || c == 'E') { c = lip->yyGet(); if (c == '-' || c == '+') c = lip->yyGet(); // Skip sign if (!my_isdigit(cs,c)) { // No digit after sign state= MY_LEX_CHAR; break; } while (my_isdigit(cs,lip->yyGet())) ; yylval->lex_str=get_token(lip, 0, lip->yyLength()); return(FLOAT_NUM); } yylval->lex_str=get_token(lip, 0, lip->yyLength()); return(DECIMAL_NUM); case MY_LEX_HEX_NUMBER: // Found x'hexstring' lip->yySkip(); // Accept opening ' while (my_isxdigit(cs, (c= lip->yyGet()))) ; if (c != '\'') return(ABORT_SYM); // Illegal hex constant lip->yySkip(); // Accept closing ' length= lip->yyLength(); // Length of hexnum+3 if ((length % 2) == 0) return(ABORT_SYM); // odd number of hex digits yylval->lex_str=get_token(lip, 2, // skip x' length-3); // don't count x' and last ' return HEX_STRING; case MY_LEX_BIN_NUMBER: // Found b'bin-string' lip->yySkip(); // Accept opening ' while ((c= lip->yyGet()) == '0' || c == '1') ; if (c != '\'') return(ABORT_SYM); // Illegal hex constant lip->yySkip(); // Accept closing ' length= lip->yyLength(); // Length of bin-num + 3 yylval->lex_str= get_token(lip, 2, // skip b' length-3); // don't count b' and last ' return (BIN_NUM); case MY_LEX_CMP_OP: // Incomplete comparison operator lip->next_state= MY_LEX_START; // Allow signed numbers if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP || state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP) { lip->yySkip(); if ((tokval= find_keyword(lip, 2, 0))) return(tokval); lip->yyUnget(); } return(c); case MY_LEX_LONG_CMP_OP: // Incomplete comparison operator lip->next_state= MY_LEX_START; if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP || state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP) { lip->yySkip(); if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP) { lip->yySkip(); if ((tokval= find_keyword(lip, 3, 0))) return(tokval); lip->yyUnget(); } if ((tokval= find_keyword(lip, 2, 0))) return(tokval); lip->yyUnget(); } return(c); case MY_LEX_BOOL: if (c != lip->yyPeek()) { state=MY_LEX_CHAR; break; } lip->yySkip(); tokval = find_keyword(lip,2,0); // Is a bool operator lip->next_state= MY_LEX_START; // Allow signed numbers return(tokval); case MY_LEX_STRING_OR_DELIMITER: if (thd->variables.sql_mode & MODE_ANSI_QUOTES) { state= MY_LEX_USER_VARIABLE_DELIMITER; break; } /* " used for strings */ /* fall through */ case MY_LEX_STRING: // Incomplete text string { uint sep; if (lip->get_text(&yylval->lex_str, (sep= lip->yyGetLast()), 1, 1)) { state= MY_LEX_CHAR; // Read char by char break; } CHARSET_INFO *strcs= lip->m_underscore_cs ? lip->m_underscore_cs : cs; lip->body_utf8_append(lip->m_cpp_text_start); lip->body_utf8_append_escape(thd, &yylval->lex_str, strcs, lip->m_cpp_text_end, sep); lip->m_underscore_cs= NULL; lex->text_string_is_7bit= (lip->tok_bitmap & 0x80) ? 0 : 1; return(TEXT_STRING); } case MY_LEX_COMMENT: // Comment lex->select_lex.options|= OPTION_FOUND_COMMENT; while ((c = lip->yyGet()) != '\n' && c) ; lip->yyUnget(); // Safety against eof state = MY_LEX_START; // Try again break; case MY_LEX_LONG_COMMENT: /* Long C comment? */ if (lip->yyPeek() != '*') { state=MY_LEX_CHAR; // Probable division break; } lex->select_lex.options|= OPTION_FOUND_COMMENT; /* Reject '/' '*', since we might need to turn off the echo */ lip->yyUnget(); lip->save_in_comment_state(); if (lip->yyPeekn(2) == '!' || (lip->yyPeekn(2) == 'M' && lip->yyPeekn(3) == '!')) { bool maria_comment_syntax= lip->yyPeekn(2) == 'M'; lip->in_comment= DISCARD_COMMENT; /* Accept '/' '*' '!', but do not keep this marker. */ lip->set_echo(FALSE); lip->yySkipn(maria_comment_syntax ? 4 : 3); /* The special comment format is very strict: '/' '*' '!', followed by an optional 'M' and exactly 1-2 digits (major), 2 digits (minor), then 2 digits (dot). 32302 -> 3.23.02 50032 -> 5.0.32 50114 -> 5.1.14 100000 -> 10.0.0 */ if ( my_isdigit(cs, lip->yyPeekn(0)) && my_isdigit(cs, lip->yyPeekn(1)) && my_isdigit(cs, lip->yyPeekn(2)) && my_isdigit(cs, lip->yyPeekn(3)) && my_isdigit(cs, lip->yyPeekn(4)) ) { ulong version; uint length= 5; char *end_ptr= (char*) lip->get_ptr()+length; int error; if (my_isdigit(cs, lip->yyPeekn(5))) { end_ptr++; // 6 digit number length++; } version= (ulong) my_strtoll10(lip->get_ptr(), &end_ptr, &error); /* MySQL-5.7 has new features and might have new SQL syntax that MariaDB-10.0 does not understand. Ignore all versioned comments with MySQL versions in the range 50700-999999, but do not ignore MariaDB specific comments for the same versions. */ if (version <= MYSQL_VERSION_ID && (version < 50700 || version > 99999 || maria_comment_syntax)) { /* Accept 'M' 'm' 'm' 'd' 'd' */ lip->yySkipn(length); /* Expand the content of the special comment as real code */ lip->set_echo(TRUE); state=MY_LEX_START; break; /* Do not treat contents as a comment. */ } else { #ifdef WITH_WSREP if (WSREP(thd) && version == 99997 && thd->wsrep_exec_mode == LOCAL_STATE) { WSREP_DEBUG("consistency check: %s", thd->query()); thd->wsrep_consistency_check= CONSISTENCY_CHECK_DECLARED; lip->yySkipn(5); lip->set_echo(TRUE); state=MY_LEX_START; break; /* Do not treat contents as a comment. */ } #endif /* WITH_WSREP */ /* Patch and skip the conditional comment to avoid it being propagated infinitely (eg. to a slave). */ char *pcom= lip->yyUnput(' '); comment_closed= ! consume_comment(lip, 1); if (! comment_closed) { *pcom= '!'; } /* version allowed to have one level of comment inside. */ } } else { /* Not a version comment. */ state=MY_LEX_START; lip->set_echo(TRUE); break; } } else { lip->in_comment= PRESERVE_COMMENT; lip->yySkip(); // Accept / lip->yySkip(); // Accept * comment_closed= ! consume_comment(lip, 0); /* regular comments can have zero comments inside. */ } /* Discard: - regular '/' '*' comments, - special comments '/' '*' '!' for a future version, by scanning until we find a closing '*' '/' marker. Nesting regular comments isn't allowed. The first '*' '/' returns the parser to the previous state. /#!VERSI oned containing /# regular #/ is allowed #/ Inside one versioned comment, another versioned comment is treated as a regular discardable comment. It gets no special parsing. */ /* Unbalanced comments with a missing '*' '/' are a syntax error */ if (! comment_closed) return (ABORT_SYM); state = MY_LEX_START; // Try again lip->restore_in_comment_state(); break; case MY_LEX_END_LONG_COMMENT: if ((lip->in_comment != NO_COMMENT) && lip->yyPeek() == '/') { /* Reject '*' '/' */ lip->yyUnget(); /* Accept '*' '/', with the proper echo */ lip->set_echo(lip->in_comment == PRESERVE_COMMENT); lip->yySkipn(2); /* And start recording the tokens again */ lip->set_echo(TRUE); lip->in_comment=NO_COMMENT; state=MY_LEX_START; } else state=MY_LEX_CHAR; // Return '*' break; case MY_LEX_SET_VAR: // Check if ':=' if (lip->yyPeek() != '=') { state=MY_LEX_CHAR; // Return ':' break; } lip->yySkip(); return (SET_VAR); case MY_LEX_SEMICOLON: // optional line terminator state= MY_LEX_CHAR; // Return ';' break; case MY_LEX_EOL: if (lip->eof()) { lip->yyUnget(); // Reject the last '\0' lip->set_echo(FALSE); lip->yySkip(); lip->set_echo(TRUE); /* Unbalanced comments with a missing '*' '/' are a syntax error */ if (lip->in_comment != NO_COMMENT) return (ABORT_SYM); lip->next_state=MY_LEX_END; // Mark for next loop return(END_OF_INPUT); } state=MY_LEX_CHAR; break; case MY_LEX_END: lip->next_state=MY_LEX_END; return(0); // We found end of input last time /* Actually real shouldn't start with . but allow them anyhow */ case MY_LEX_REAL_OR_POINT: if (my_isdigit(cs,lip->yyPeek())) state = MY_LEX_REAL; // Real else { state= MY_LEX_IDENT_SEP; // return '.' lip->yyUnget(); // Put back '.' } break; case MY_LEX_USER_END: // end '@' of user@hostname switch (state_map[(uchar) lip->yyPeek()]) { case MY_LEX_STRING: case MY_LEX_USER_VARIABLE_DELIMITER: case MY_LEX_STRING_OR_DELIMITER: break; case MY_LEX_USER_END: lip->next_state=MY_LEX_SYSTEM_VAR; break; default: lip->next_state=MY_LEX_HOSTNAME; break; } yylval->lex_str.str=(char*) lip->get_ptr(); yylval->lex_str.length=1; return((int) '@'); case MY_LEX_HOSTNAME: // end '@' of user@hostname for (c=lip->yyGet() ; my_isalnum(cs,c) || c == '.' || c == '_' || c == '$'; c= lip->yyGet()) ; yylval->lex_str=get_token(lip, 0, lip->yyLength()); return(LEX_HOSTNAME); case MY_LEX_SYSTEM_VAR: yylval->lex_str.str=(char*) lip->get_ptr(); yylval->lex_str.length=1; lip->yySkip(); // Skip '@' lip->next_state= (state_map[(uchar) lip->yyPeek()] == MY_LEX_USER_VARIABLE_DELIMITER ? MY_LEX_OPERATOR_OR_IDENT : MY_LEX_IDENT_OR_KEYWORD); return((int) '@'); case MY_LEX_IDENT_OR_KEYWORD: /* We come here when we have found two '@' in a row. We should now be able to handle: [(global | local | session) .]variable_name */ for (result_state= 0; ident_map[c= lip->yyGet()]; result_state|= c) ; /* If there were non-ASCII characters, mark that we must convert */ result_state= result_state & 0x80 ? IDENT_QUOTED : IDENT; if (c == '.') lip->next_state=MY_LEX_IDENT_SEP; length= lip->yyLength(); if (length == 0) return(ABORT_SYM); // Names must be nonempty. if ((tokval= find_keyword(lip, length,0))) { lip->yyUnget(); // Put back 'c' return(tokval); // Was keyword } yylval->lex_str=get_token(lip, 0, length); lip->body_utf8_append(lip->m_cpp_text_start); lip->body_utf8_append_ident(thd, &yylval->lex_str, lip->m_cpp_text_end); return(result_state); } } }
0
384,820
skiptobin(char_u *q) { char_u *p = q; while (*p != NUL && !vim_isbdigit(*p)) // skip to next digit ++p; return p; }
0
269,319
static av_always_inline void snow_horizontal_compose_liftS_lead_out(int i, IDWTELEM * dst, IDWTELEM * src, IDWTELEM * ref, int width, int w){ for(; i<w; i++){ dst[i] = src[i] + ((ref[i] + ref[(i+1)]+W_BO + 4 * src[i]) >> W_BS); } if(width&1){ dst[w] = src[w] + ((2 * ref[w] + W_BO + 4 * src[w]) >> W_BS); } }
0
210,701
static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset, struct inode **i) { squashfs_dir_header_3 dirh; char buffer[sizeof(squashfs_dir_entry_3) + SQUASHFS_NAME_LEN + 1] __attribute__((aligned)); squashfs_dir_entry_3 *dire = (squashfs_dir_entry_3 *) buffer; long long start; int bytes; int dir_count, size; struct dir_ent *new_dir; struct dir *dir; TRACE("squashfs_opendir: inode start block %d, offset %d\n", block_start, offset); *i = read_inode(block_start, offset); dir = malloc(sizeof(struct dir)); if(dir == NULL) EXIT_UNSQUASH("squashfs_opendir: malloc failed!\n"); dir->dir_count = 0; dir->cur_entry = 0; dir->mode = (*i)->mode; dir->uid = (*i)->uid; dir->guid = (*i)->gid; dir->mtime = (*i)->time; dir->xattr = (*i)->xattr; dir->dirs = NULL; if ((*i)->data == 3) /* * if the directory is empty, skip the unnecessary * lookup_entry, this fixes the corner case with * completely empty filesystems where lookup_entry correctly * returning -1 is incorrectly treated as an error */ return dir; start = sBlk.s.directory_table_start + (*i)->start; bytes = lookup_entry(directory_table_hash, start); if(bytes == -1) EXIT_UNSQUASH("squashfs_opendir: directory block %d not " "found!\n", block_start); bytes += (*i)->offset; size = (*i)->data + bytes - 3; while(bytes < size) { if(swap) { squashfs_dir_header_3 sdirh; memcpy(&sdirh, directory_table + bytes, sizeof(sdirh)); SQUASHFS_SWAP_DIR_HEADER_3(&dirh, &sdirh); } else memcpy(&dirh, directory_table + bytes, sizeof(dirh)); dir_count = dirh.count + 1; TRACE("squashfs_opendir: Read directory header @ byte position " "%d, %d directory entries\n", bytes, dir_count); bytes += sizeof(dirh); /* dir_count should never be larger than SQUASHFS_DIR_COUNT */ if(dir_count > SQUASHFS_DIR_COUNT) { ERROR("File system corrupted: too many entries in directory\n"); goto corrupted; } while(dir_count--) { if(swap) { squashfs_dir_entry_3 sdire; memcpy(&sdire, directory_table + bytes, sizeof(sdire)); SQUASHFS_SWAP_DIR_ENTRY_3(dire, &sdire); } else memcpy(dire, directory_table + bytes, sizeof(*dire)); bytes += sizeof(*dire); /* size should never be SQUASHFS_NAME_LEN or larger */ if(dire->size >= SQUASHFS_NAME_LEN) { ERROR("File system corrupted: filename too long\n"); goto corrupted; } memcpy(dire->name, directory_table + bytes, dire->size + 1); dire->name[dire->size + 1] = '\0'; TRACE("squashfs_opendir: directory entry %s, inode " "%d:%d, type %d\n", dire->name, dirh.start_block, dire->offset, dire->type); if((dir->dir_count % DIR_ENT_SIZE) == 0) { new_dir = realloc(dir->dirs, (dir->dir_count + DIR_ENT_SIZE) * sizeof(struct dir_ent)); if(new_dir == NULL) EXIT_UNSQUASH("squashfs_opendir: " "realloc failed!\n"); dir->dirs = new_dir; } strcpy(dir->dirs[dir->dir_count].name, dire->name); dir->dirs[dir->dir_count].start_block = dirh.start_block; dir->dirs[dir->dir_count].offset = dire->offset; dir->dirs[dir->dir_count].type = dire->type; dir->dir_count ++; bytes += dire->size + 1; } } return dir; corrupted: free(dir->dirs); free(dir); return NULL; }
1
310,127
quit(int status, const char *fmt, ...) { va_list argp; va_start(argp, fmt); fprintf(stderr, "%s: ", prg_name); vfprintf(stderr, fmt, argp); fprintf(stderr, "\n"); va_end(argp); ExitProgram(status); }
0
430,456
static size_t get_ufid_len(const struct nlattr *attr, bool log) { size_t len; if (!attr) return 0; len = nla_len(attr); if (len < 1 || len > MAX_UFID_LENGTH) { OVS_NLERR(log, "ufid size %u bytes exceeds the range (1, %d)", nla_len(attr), MAX_UFID_LENGTH); return 0; } return len; }
0
477,281
static void tipc_aead_users_dec(struct tipc_aead __rcu *aead, int lim) { struct tipc_aead *tmp; rcu_read_lock(); tmp = rcu_dereference(aead); if (tmp) atomic_add_unless(&rcu_dereference(aead)->users, -1, lim); rcu_read_unlock(); }
0
338,221
bool WasmBinaryBuilder::maybeVisitAtomicRMW(Expression*& out, uint8_t code) { if (code < BinaryConsts::AtomicRMWOps_Begin || code > BinaryConsts::AtomicRMWOps_End) { return false; } auto* curr = allocator.alloc<AtomicRMW>(); // Set curr to the given opcode, type and size. #define SET(opcode, optype, size) \ curr->op = RMW##opcode; \ curr->type = optype; \ curr->bytes = size // Handle the cases for all the valid types for a particular opcode #define SET_FOR_OP(Op) \ case BinaryConsts::I32AtomicRMW##Op: \ SET(Op, Type::i32, 4); \ break; \ case BinaryConsts::I32AtomicRMW##Op##8U: \ SET(Op, Type::i32, 1); \ break; \ case BinaryConsts::I32AtomicRMW##Op##16U: \ SET(Op, Type::i32, 2); \ break; \ case BinaryConsts::I64AtomicRMW##Op: \ SET(Op, Type::i64, 8); \ break; \ case BinaryConsts::I64AtomicRMW##Op##8U: \ SET(Op, Type::i64, 1); \ break; \ case BinaryConsts::I64AtomicRMW##Op##16U: \ SET(Op, Type::i64, 2); \ break; \ case BinaryConsts::I64AtomicRMW##Op##32U: \ SET(Op, Type::i64, 4); \ break; switch (code) { SET_FOR_OP(Add); SET_FOR_OP(Sub); SET_FOR_OP(And); SET_FOR_OP(Or); SET_FOR_OP(Xor); SET_FOR_OP(Xchg); default: WASM_UNREACHABLE("unexpected opcode"); } #undef SET_FOR_OP #undef SET BYN_TRACE("zz node: AtomicRMW\n"); Address readAlign; readMemoryAccess(readAlign, curr->offset); if (readAlign != curr->bytes) { throwError("Align of AtomicRMW must match size"); } curr->value = popNonVoidExpression(); curr->ptr = popNonVoidExpression(); curr->finalize(); out = curr; return true; }
0
225,562
void Compute(OpKernelContext* context) override { // There are two steps when calculating gradient for FractionalMaxPool. // 1) Walk through the process of calculating fractional pooling given // pooling region; however, in the process, keep track of where the max // element comes from. (arg_max) // 2) Populate the value of out_backprop to where arg_max indicates. If // we support overlapping, it is likely to have multiple out_backprop[i] // propagates back to the same arg_max value. typedef Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>> ConstEigenMatrixMap; typedef Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>> EigenMatrixMap; typedef Eigen::Map<Eigen::Matrix<int64, Eigen::Dynamic, Eigen::Dynamic>> EigenIndexMatrixMap; const Tensor& tensor_in = context->input(0); const Tensor& tensor_out = context->input(1); const Tensor& out_backprop = context->input(2); const Tensor& height_seq_tensor = context->input(3); const Tensor& width_seq_tensor = context->input(4); // Just to make it similar to FractionalMaxPoolOp. constexpr int tensor_in_and_out_dims = 4; OP_REQUIRES( context, tensor_in.dims() == tensor_in_and_out_dims, errors::InvalidArgument("orig_input should be a tensor of rank 4, got ", tensor_in.DebugString())); OP_REQUIRES(context, tensor_in.NumElements() > 0, errors::InvalidArgument("orig_input must not be empty, got ", tensor_in.DebugString())); OP_REQUIRES(context, tensor_out.dims() == tensor_in_and_out_dims, errors::InvalidArgument( "orig_output should be a tensor of rank 4, got ", tensor_out.DebugString())); OP_REQUIRES(context, tensor_out.NumElements() > 0, errors::InvalidArgument("orig_output must not be empty, got ", tensor_out.DebugString())); std::vector<int64_t> input_size(tensor_in_and_out_dims); std::vector<int64_t> output_size(tensor_in_and_out_dims); for (int i = 0; i < tensor_in_and_out_dims; ++i) { input_size[i] = tensor_in.dim_size(i); } for (int i = 0; i < tensor_in_and_out_dims; ++i) { output_size[i] = tensor_out.dim_size(i); } // --------- // Step 1 // --------- Tensor tensor_out_dup; OP_REQUIRES_OK(context, context->forward_input_or_allocate_temp( {1}, DataTypeToEnum<T>::v(), tensor_out.shape(), &tensor_out_dup)); Tensor tensor_out_arg_max; OP_REQUIRES_OK(context, context->allocate_temp(DataTypeToEnum<int64_t>::v(), tensor_out.shape(), &tensor_out_arg_max)); // Find arg_max for each tensor_out ConstEigenMatrixMap tensor_in_mat( tensor_in.flat<T>().data(), input_size[3], input_size[2] * input_size[1] * input_size[0]); EigenMatrixMap tensor_out_dup_mat( tensor_out_dup.flat<T>().data(), output_size[3], output_size[2] * output_size[1] * output_size[0]); EigenIndexMatrixMap tensor_out_arg_max_mat( tensor_out_arg_max.flat<int64_t>().data(), output_size[3], output_size[2] * output_size[1] * output_size[0]); tensor_out_arg_max.flat<int64_t>().setConstant(kInvalidMaxPoolingIndex); // Initializes the duplicate output tensor with MIN<T>. tensor_out_dup.flat<T>().setConstant(Eigen::NumTraits<T>::lowest()); auto height_seq_tensor_flat = height_seq_tensor.flat<int64_t>(); auto width_seq_tensor_flat = width_seq_tensor.flat<int64_t>(); // Now walk through the process of fractional max pooling again. // For both input and output, // 0: batch // 1: height / row // 2: width / col // 3: depth / channel const int64_t height_max = input_size[1] - 1; const int64_t width_max = input_size[2] - 1; for (int64_t b = 0; b < input_size[0]; ++b) { // height sequence. for (int64_t hs = 0; hs < height_seq_tensor.dim_size(0) - 1; ++hs) { // height start and end. const int64_t height_start = height_seq_tensor_flat(hs); int64_t height_end = overlapping_ ? height_seq_tensor_flat(hs + 1) : height_seq_tensor_flat(hs + 1) - 1; height_end = std::min(height_end, height_max); // width sequence. for (int64_t ws = 0; ws < width_seq_tensor.dim_size(0) - 1; ++ws) { const int64_t out_index = (b * output_size[1] + hs) * output_size[2] + ws; // width start and end. const int64_t width_start = width_seq_tensor_flat(ws); int64_t width_end = overlapping_ ? width_seq_tensor_flat(ws + 1) : width_seq_tensor_flat(ws + 1) - 1; width_end = std::min(width_end, width_max); for (int64_t h = height_start; h <= height_end; ++h) { for (int64_t w = width_start; w <= width_end; ++w) { const int64_t in_index = (b * input_size[1] + h) * input_size[2] + w; // Walk through each channel (depth). for (int64_t d = 0; d < input_size[3]; ++d) { const T& input_ref = tensor_in_mat.coeffRef(d, in_index); T& output_ref = tensor_out_dup_mat.coeffRef(d, out_index); int64_t& out_arg_max_ref = tensor_out_arg_max_mat.coeffRef(d, out_index); if (output_ref < input_ref || out_arg_max_ref == kInvalidMaxPoolingIndex) { output_ref = input_ref; int input_offset = in_index * input_size[3] + d; out_arg_max_ref = input_offset; } } } } } } } // Check tensor_out_dup is the same as tensor_out. ConstEigenMatrixMap tensor_out_mat( tensor_out.flat<T>().data(), output_size[3], output_size[2] * output_size[1] * output_size[0]); const int64_t num_reshaped_cols = output_size[2] * output_size[1] * output_size[0]; for (int64_t i = 0; i < num_reshaped_cols; ++i) { for (int64_t j = 0; j < output_size[3]; ++j) { DCHECK_EQ(tensor_out_dup_mat(j, i), tensor_out_mat(j, i)); } } Tensor* output = nullptr; OP_REQUIRES_OK(context, context->forward_input_or_allocate_output( {0}, 0, tensor_in.shape(), &output)); output->flat<T>().setZero(); auto out_backprop_flat = out_backprop.flat<T>(); auto input_backprop_flat = output->flat<T>(); auto out_arg_max_flat = tensor_out_arg_max.flat<int64_t>(); int num_total_outputs = out_backprop_flat.size(); int num_total_inputs = input_backprop_flat.size(); for (int index = 0; index < num_total_outputs; ++index) { int input_backprop_index = out_arg_max_flat(index); // According to maxpooling_op.cc, the performance impact below is small. CHECK(input_backprop_index >= 0 && input_backprop_index < num_total_inputs) << "Invalid input backprop index: " << input_backprop_index << ", " << num_total_inputs; input_backprop_flat(input_backprop_index) += out_backprop_flat(index); } }
0
452,260
PHP_FUNCTION(xsl_xsltprocessor_transform_to_doc) { zval *id, *docp = NULL; xmlDoc *newdocp; xsltStylesheetPtr sheetp; int ret, ret_class_len=0; char *ret_class = NULL; xsl_object *intern; id = getThis(); intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC); sheetp = (xsltStylesheetPtr) intern->ptr; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|s!", &docp, &ret_class, &ret_class_len) == FAILURE) { RETURN_FALSE; } newdocp = php_xsl_apply_stylesheet(id, intern, sheetp, docp TSRMLS_CC); if (newdocp) { if (ret_class) { int found; char *curclass_name; zend_class_entry *curce, **ce; php_libxml_node_object *interndoc; curce = Z_OBJCE_P(docp); curclass_name = curce->name; while (curce->parent != NULL) { curce = curce->parent; } found = zend_lookup_class(ret_class, ret_class_len, &ce TSRMLS_CC); if ((found != SUCCESS) || !instanceof_function(*ce, curce TSRMLS_CC)) { xmlFreeDoc(newdocp); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expecting class compatible with %s, '%s' given", curclass_name, ret_class); RETURN_FALSE; } object_init_ex(return_value, *ce); interndoc = (php_libxml_node_object *)zend_objects_get_address(return_value TSRMLS_CC); php_libxml_increment_doc_ref(interndoc, newdocp TSRMLS_CC); php_libxml_increment_node_ptr(interndoc, (xmlNodePtr)newdocp, (void *)interndoc TSRMLS_CC); } else { DOM_RET_OBJ((xmlNodePtr) newdocp, &ret, NULL); } } else { RETURN_FALSE; } }
0
383,337
int gdImageSelectiveBlur( gdImagePtr src) { int x, y, i, j; float new_r, new_g, new_b; int new_pxl, cpxl, pxl, new_a=0; float flt_r [3][3]; float flt_g [3][3]; float flt_b [3][3]; float flt_r_sum, flt_g_sum, flt_b_sum; gdImagePtr srcback; typedef int (*FuncPtr)(gdImagePtr, int, int); FuncPtr f; if (src==NULL) { return 0; } /* We need the orinal image with each safe neoghb. pixel */ srcback = gdImageCreateTrueColor (src->sx, src->sy); gdImageCopy(srcback, src,0,0,0,0,src->sx,src->sy); if (srcback==NULL) { return 0; } f = GET_PIXEL_FUNCTION(src); for(y = 0; y<src->sy; y++) { for (x=0; x<src->sx; x++) { flt_r_sum = flt_g_sum = flt_b_sum = 0.0; cpxl = f(src, x, y); for (j=0; j<3; j++) { for (i=0; i<3; i++) { if ((j == 1) && (i == 1)) { flt_r[1][1] = flt_g[1][1] = flt_b[1][1] = 0.5; } else { pxl = f(src, x-(3>>1)+i, y-(3>>1)+j); new_a = gdImageAlpha(srcback, pxl); new_r = ((float)gdImageRed(srcback, cpxl)) - ((float)gdImageRed (srcback, pxl)); if (new_r < 0.0f) { new_r = -new_r; } if (new_r != 0) { flt_r[j][i] = 1.0f/new_r; } else { flt_r[j][i] = 1.0f; } new_g = ((float)gdImageGreen(srcback, cpxl)) - ((float)gdImageGreen(srcback, pxl)); if (new_g < 0.0f) { new_g = -new_g; } if (new_g != 0) { flt_g[j][i] = 1.0f/new_g; } else { flt_g[j][i] = 1.0f; } new_b = ((float)gdImageBlue(srcback, cpxl)) - ((float)gdImageBlue(srcback, pxl)); if (new_b < 0.0f) { new_b = -new_b; } if (new_b != 0) { flt_b[j][i] = 1.0f/new_b; } else { flt_b[j][i] = 1.0f; } } flt_r_sum += flt_r[j][i]; flt_g_sum += flt_g[j][i]; flt_b_sum += flt_b [j][i]; } } for (j=0; j<3; j++) { for (i=0; i<3; i++) { if (flt_r_sum != 0.0) { flt_r[j][i] /= flt_r_sum; } if (flt_g_sum != 0.0) { flt_g[j][i] /= flt_g_sum; } if (flt_b_sum != 0.0) { flt_b [j][i] /= flt_b_sum; } } } new_r = new_g = new_b = 0.0; for (j=0; j<3; j++) { for (i=0; i<3; i++) { pxl = f(src, x-(3>>1)+i, y-(3>>1)+j); new_r += (float)gdImageRed(srcback, pxl) * flt_r[j][i]; new_g += (float)gdImageGreen(srcback, pxl) * flt_g[j][i]; new_b += (float)gdImageBlue(srcback, pxl) * flt_b[j][i]; } } new_r = (new_r > 255.0f)? 255.0f : ((new_r < 0.0f)? 0.0f:new_r); new_g = (new_g > 255.0f)? 255.0f : ((new_g < 0.0f)? 0.0f:new_g); new_b = (new_b > 255.0f)? 255.0f : ((new_b < 0.0f)? 0.0f:new_b); new_pxl = gdImageColorAllocateAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a); if (new_pxl == -1) { new_pxl = gdImageColorClosestAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a); } if ((y >= 0) && (y < src->sy)) { gdImageSetPixel (src, x, y, new_pxl); } } } gdImageDestroy(srcback); return 1; }
0
210,887
e1000_send_packet(E1000State *s, const uint8_t *buf, int size) { static const int PTCregs[6] = { PTC64, PTC127, PTC255, PTC511, PTC1023, PTC1522 }; NetClientState *nc = qemu_get_queue(s->nic); if (s->phy_reg[PHY_CTRL] & MII_CR_LOOPBACK) { nc->info->receive(nc, buf, size); } else { qemu_send_packet(nc, buf, size); } inc_tx_bcast_or_mcast_count(s, buf); e1000x_increase_size_stats(s->mac_reg, PTCregs, size); }
1
442,571
static void test_memslot_invalid_group_id(void) { RedMemSlotInfo mem_info; init_meminfo(&mem_info); memslot_get_virt(&mem_info, 0, 16, 1); }
0
95,897
void AddChromeFrameWorkItems(const InstallationState& original_state, const InstallerState& installer_state, const FilePath& setup_path, const Version& new_version, const Product& product, WorkItemList* list) { DCHECK(product.is_chrome_frame()); if (!installer_state.is_multi_install()) { VLOG(1) << "Not adding GCF specific work items for single install."; return; } std::wstring version_key(product.distribution()->GetVersionKey()); bool ready_mode = product.HasOption(kOptionReadyMode); HKEY root = installer_state.root_key(); const bool is_install = (installer_state.operation() != InstallerState::UNINSTALL); bool update_chrome_uninstall_command = false; BrowserDistribution* dist = installer_state.multi_package_binaries_distribution(); if (ready_mode) { list->AddCreateRegKeyWorkItem(root, dist->GetStateKey()); list->AddSetRegValueWorkItem(root, dist->GetStateKey(), kChromeFrameReadyModeField, static_cast<int64>(is_install ? 1 : 0), // The value we want to set. is_install ? false : true); // Overwrite existing value. if (is_install) { FilePath installer_path(installer_state .GetInstallerDirectory(new_version).Append(setup_path.BaseName())); CommandLine basic_cl(installer_path); basic_cl.AppendSwitch(switches::kChromeFrame); basic_cl.AppendSwitch(switches::kMultiInstall); if (installer_state.system_install()) basic_cl.AppendSwitch(switches::kSystemLevel); CommandLine temp_opt_out(basic_cl); temp_opt_out.AppendSwitch(switches::kChromeFrameReadyModeTempOptOut); CommandLine end_temp_opt_out(basic_cl); end_temp_opt_out.AppendSwitch( switches::kChromeFrameReadyModeEndTempOptOut); CommandLine opt_out(installer_path); AppendUninstallCommandLineFlags(installer_state, product, &opt_out); opt_out.AppendSwitch(switches::kForceUninstall); CommandLine opt_in(basic_cl); opt_in.AppendSwitch(switches::kChromeFrameReadyModeOptIn); list->AddSetRegValueWorkItem(root, version_key, google_update::kRegCFTempOptOutCmdField, temp_opt_out.command_line_string(), true); list->AddSetRegValueWorkItem(root, version_key, google_update::kRegCFEndTempOptOutCmdField, end_temp_opt_out.command_line_string(), true); list->AddSetRegValueWorkItem(root, version_key, google_update::kRegCFOptOutCmdField, opt_out.command_line_string(), true); list->AddSetRegValueWorkItem(root, version_key, google_update::kRegCFOptInCmdField, opt_in.command_line_string(), true); } else { update_chrome_uninstall_command = (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER) == NULL); } } else { list->AddDeleteRegValueWorkItem(root, dist->GetStateKey(), kChromeFrameReadyModeField); const Product* chrome = installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); if (chrome) { } else { const ProductState* chrome_state = original_state.GetProductState( installer_state.system_install(), BrowserDistribution::CHROME_BROWSER); update_chrome_uninstall_command = (chrome_state != NULL) && chrome_state->is_multi_install(); } } if (!ready_mode || !is_install) { list->AddDeleteRegValueWorkItem(root, version_key, google_update::kRegCFTempOptOutCmdField); list->AddDeleteRegValueWorkItem(root, version_key, google_update::kRegCFEndTempOptOutCmdField); list->AddDeleteRegValueWorkItem(root, version_key, google_update::kRegCFOptOutCmdField); list->AddDeleteRegValueWorkItem(root, version_key, google_update::kRegCFOptInCmdField); } if (update_chrome_uninstall_command) { const ProductState* chrome_state = original_state.GetProductState( installer_state.system_install(), BrowserDistribution::CHROME_BROWSER); if (chrome_state != NULL) { DCHECK(chrome_state->is_multi_install()); Product chrome(BrowserDistribution::GetSpecificDistribution( BrowserDistribution::CHROME_BROWSER)); chrome.InitializeFromUninstallCommand(chrome_state->uninstall_command()); AddUninstallShortcutWorkItems(installer_state, setup_path, chrome_state->version(), list, chrome); } else { NOTREACHED() << "What happened to Chrome?"; } } }
0
238,606
static int check_stack_read_fixed_off(struct bpf_verifier_env *env, /* func where src register points to */ struct bpf_func_state *reg_state, int off, int size, int dst_regno) { struct bpf_verifier_state *vstate = env->cur_state; struct bpf_func_state *state = vstate->frame[vstate->curframe]; int i, slot = -off - 1, spi = slot / BPF_REG_SIZE; struct bpf_reg_state *reg; u8 *stype, type; stype = reg_state->stack[spi].slot_type; reg = &reg_state->stack[spi].spilled_ptr; if (is_spilled_reg(&reg_state->stack[spi])) { u8 spill_size = 1; for (i = BPF_REG_SIZE - 1; i > 0 && stype[i - 1] == STACK_SPILL; i--) spill_size++; if (size != BPF_REG_SIZE || spill_size != BPF_REG_SIZE) { if (reg->type != SCALAR_VALUE) { verbose_linfo(env, env->insn_idx, "; "); verbose(env, "invalid size of register fill\n"); return -EACCES; } mark_reg_read(env, reg, reg->parent, REG_LIVE_READ64); if (dst_regno < 0) return 0; if (!(off % BPF_REG_SIZE) && size == spill_size) { /* The earlier check_reg_arg() has decided the * subreg_def for this insn. Save it first. */ s32 subreg_def = state->regs[dst_regno].subreg_def; state->regs[dst_regno] = *reg; state->regs[dst_regno].subreg_def = subreg_def; } else { for (i = 0; i < size; i++) { type = stype[(slot - i) % BPF_REG_SIZE]; if (type == STACK_SPILL) continue; if (type == STACK_MISC) continue; verbose(env, "invalid read from stack off %d+%d size %d\n", off, i, size); return -EACCES; } mark_reg_unknown(env, state->regs, dst_regno); } state->regs[dst_regno].live |= REG_LIVE_WRITTEN; return 0; } if (dst_regno >= 0) { /* restore register state from stack */ state->regs[dst_regno] = *reg; /* mark reg as written since spilled pointer state likely * has its liveness marks cleared by is_state_visited() * which resets stack/reg liveness for state transitions */ state->regs[dst_regno].live |= REG_LIVE_WRITTEN; } else if (__is_pointer_value(env->allow_ptr_leaks, reg)) { /* If dst_regno==-1, the caller is asking us whether * it is acceptable to use this value as a SCALAR_VALUE * (e.g. for XADD). * We must not allow unprivileged callers to do that * with spilled pointers. */ verbose(env, "leaking pointer from stack off %d\n", off); return -EACCES; } mark_reg_read(env, reg, reg->parent, REG_LIVE_READ64); } else { for (i = 0; i < size; i++) { type = stype[(slot - i) % BPF_REG_SIZE]; if (type == STACK_MISC) continue; if (type == STACK_ZERO) continue; verbose(env, "invalid read from stack off %d+%d size %d\n", off, i, size); return -EACCES; } mark_reg_read(env, reg, reg->parent, REG_LIVE_READ64); if (dst_regno >= 0) mark_reg_stack_read(env, reg_state, off, off + size, dst_regno); } return 0; }
0
336,629
void stat_remove_counter(SpiceServer *reds, RedStatCounter *counter) { if (counter->counter) { stat_file_remove_counter(reds->stat_file, counter->counter); counter->counter = NULL; } }
0
232,298
GF_Box *gf_isom_box_find_child(GF_List *children, u32 code) { u32 i, count; if (!children) return NULL; count = gf_list_count(children); for (i=0; i<count; i++) { GF_Box *c = gf_list_get(children, i); if (c->type==code) return c; if (c->type==GF_ISOM_BOX_TYPE_UNKNOWN) { if (((GF_UnknownBox*)c)->original_4cc==code) return c; } if (c->type==GF_ISOM_BOX_TYPE_UUID) { if (((GF_UUIDBox*)c)->internal_4cc==code) return c; } } return NULL;
0
338,091
Signature WasmBinaryBuilder::getSignatureByFunctionIndex(Index index) { auto heapType = getTypeByFunctionIndex(index); if (!heapType.isSignature()) { throwError("invalid signature type " + heapType.toString()); } return heapType.getSignature(); }
0
220,237
Status Node::input_node(int idx, const Node** const_n) const { Node* n; TF_RETURN_IF_ERROR(input_node(idx, &n)); *const_n = n; return Status::OK(); }
0
336,808
lprn_put_params(gx_device * dev, gs_param_list * plist) { gx_device_lprn *const lprn = (gx_device_lprn *) dev; int ecode = 0; int code; gs_param_name param_name; bool ManualFeed = lprn->ManualFeed; bool NegativePrint = lprn->NegativePrint; bool Tumble = lprn->Tumble; bool RITOff = lprn->RITOff; int BlockLine = lprn->BlockLine; int BlockWidth = lprn->nBw; int BlockHeight = lprn->nBh; bool ShowBubble = lprn->ShowBubble; if ((code = param_read_bool(plist, (param_name = "ManualFeed"), &ManualFeed)) < 0) { param_signal_error(plist, param_name, ecode = code); } if ((code = param_read_bool(plist, (param_name = "NegativePrint"), &NegativePrint)) < 0) { param_signal_error(plist, param_name, ecode = code); } if ((code = param_read_bool(plist, (param_name = "Tumble"), &Tumble)) < 0) { param_signal_error(plist, param_name, ecode = code); } if ((code = param_read_bool(plist, (param_name = "RITOff"), &RITOff)) < 0) { param_signal_error(plist, param_name, ecode = code); } switch (code = param_read_int(plist, (param_name = "BlockWidth"), &BlockWidth)) { case 0: if (BlockWidth < 0) ecode = gs_error_rangecheck; else break; goto bwidthe; default: ecode = code; bwidthe:param_signal_error(plist, param_name, ecode = code); case 1: break; } switch (code = param_read_int(plist, (param_name = "BlockLine"), &BlockLine)) { case 0: if (BlockLine < 0) ecode = gs_error_rangecheck; else break; goto crowe; default: ecode = code; crowe:param_signal_error(plist, param_name, ecode = code); case 1: break; } switch (code = param_read_int(plist, (param_name = "BlockHeight"), &BlockHeight)) { case 0: if (BlockHeight < 0) ecode = gs_error_rangecheck; else break; goto bheighte; default: ecode = code; bheighte:param_signal_error(plist, param_name, ecode = code); case 1: break; } if ((code = param_read_bool(plist, (param_name = "ShowBubble"), &ShowBubble)) < 0) { param_signal_error(plist, param_name, ecode = code); } if (ecode < 0) return ecode; code = gdev_prn_put_params(dev, plist); if (code < 0) return code; lprn->ManualFeed = ManualFeed; lprn->NegativePrint = NegativePrint; lprn->Tumble = Tumble; lprn->RITOff = RITOff; lprn->BlockLine = BlockLine; lprn->nBw = BlockWidth; lprn->nBh = BlockHeight; lprn->ShowBubble = ShowBubble; return 0; }
0
508,395
MDL_deadlock_handler(Open_table_context *ot_ctx_arg) : m_ot_ctx(ot_ctx_arg), m_is_active(FALSE) {}
0
231,663
std::unique_ptr<QuicReadCodec> makeClientEncryptedCodec( bool handshakeCipher = false) { FizzCryptoFactory cryptoFactory; auto readCodec = std::make_unique<QuicReadCodec>(QuicNodeType::Client); readCodec->setOneRttReadCipher(test::createNoOpAead()); readCodec->setOneRttHeaderCipher(test::createNoOpHeaderCipher()); readCodec->setHandshakeReadCipher(test::createNoOpAead()); readCodec->setHandshakeHeaderCipher(test::createNoOpHeaderCipher()); readCodec->setClientConnectionId(*clientConnectionId); readCodec->setCodecParameters( CodecParameters(kDefaultAckDelayExponent, QuicVersion::MVFST)); if (handshakeCipher) { readCodec->setInitialReadCipher(cryptoFactory.getServerInitialCipher( *initialDestinationConnectionId, QuicVersion::MVFST)); readCodec->setInitialHeaderCipher( cryptoFactory.makeServerInitialHeaderCipher( *initialDestinationConnectionId, QuicVersion::MVFST)); } return readCodec; }
0
317,059
static void selinux_ib_free_security(void *ib_sec) { kfree(ib_sec); }
0
267,954
static RBinClass *__getClass(RBinFile *bf, const char *name) { r_return_val_if_fail (bf && bf->o && bf->o->classes_ht && name, NULL); return ht_pp_find (bf->o->classes_ht, name, NULL); }
0
386,501
void DL_Dxf::writeSpline(DL_WriterA& dw, const DL_SplineData& data, const DL_Attributes& attrib) { dw.entity("SPLINE"); if (version==DL_VERSION_2000) { dw.dxfString(100, "AcDbEntity"); } dw.entityAttributes(attrib); if (version==DL_VERSION_2000) { dw.dxfString(100, "AcDbSpline"); } dw.dxfInt(70, data.flags); dw.dxfInt(71, data.degree); dw.dxfInt(72, data.nKnots); // number of knots dw.dxfInt(73, data.nControl); // number of control points dw.dxfInt(74, data.nFit); // number of fit points }
0
272,346
generate_name(cms_context *cms, SECItem *der, CERTName *certname) { void *marka = PORT_ArenaMark(cms->arena); CERTRDN **rdns = certname->rdns; CERTRDN *rdn; int num_items = 0; int rc = 0; while (rdns && (rdn = *rdns++) != NULL) { CERTAVA **avas = rdn->avas; while (avas && ((*avas++) != NULL)) num_items++; } if (num_items == 0) { PORT_ArenaRelease(cms->arena, marka); cnreterr(-1, cms, "No name items to encode"); } SECItem items[num_items]; int i = 0; rdns = certname->rdns; while (rdns && (rdn = *rdns++) != NULL) { CERTAVA **avas = rdn->avas; CERTAVA *ava; while (avas && (ava = *avas++) != NULL) { SECItem avader; rc = generate_ava(cms, &avader, ava); if (rc < 0) { PORT_ArenaRelease(cms->arena, marka); return -1; } SECItem *list[2] = { &avader, NULL, }; rc = wrap_in_set(cms, &items[i], list); if (rc < 0) { PORT_ArenaRelease(cms->arena, marka); return -1; } i++; } } wrap_in_seq(cms, der, &items[0], num_items); PORT_ArenaUnmark(cms->arena, marka); return 0; }
0
349,259
static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset, struct inode **i) { squashfs_dir_header_3 dirh; char buffer[sizeof(squashfs_dir_entry_3) + SQUASHFS_NAME_LEN + 1] __attribute__((aligned)); squashfs_dir_entry_3 *dire = (squashfs_dir_entry_3 *) buffer; long long start; int bytes = 0; int dir_count, size, res; struct dir_ent *ent, *cur_ent = NULL; struct dir *dir; TRACE("squashfs_opendir: inode start block %d, offset %d\n", block_start, offset); *i = read_inode(block_start, offset); dir = malloc(sizeof(struct dir)); if(dir == NULL) MEM_ERROR(); dir->dir_count = 0; dir->cur_entry = NULL; dir->mode = (*i)->mode; dir->uid = (*i)->uid; dir->guid = (*i)->gid; dir->mtime = (*i)->time; dir->xattr = (*i)->xattr; dir->dirs = NULL; if ((*i)->data == 3) /* * if the directory is empty, skip the unnecessary * lookup_entry, this fixes the corner case with * completely empty filesystems where lookup_entry correctly * returning -1 is incorrectly treated as an error */ return dir; start = sBlk.s.directory_table_start + (*i)->start; offset = (*i)->offset; size = (*i)->data + bytes - 3; while(bytes < size) { if(swap) { squashfs_dir_header_3 sdirh; res = read_directory_data(&sdirh, &start, &offset, sizeof(sdirh)); if(res) SQUASHFS_SWAP_DIR_HEADER_3(&dirh, &sdirh); } else res = read_directory_data(&dirh, &start, &offset, sizeof(dirh)); if(res == FALSE) goto corrupted; dir_count = dirh.count + 1; TRACE("squashfs_opendir: Read directory header @ byte position " "%d, %d directory entries\n", bytes, dir_count); bytes += sizeof(dirh); /* dir_count should never be larger than SQUASHFS_DIR_COUNT */ if(dir_count > SQUASHFS_DIR_COUNT) { ERROR("File system corrupted: too many entries in directory\n"); goto corrupted; } while(dir_count--) { if(swap) { squashfs_dir_entry_3 sdire; res = read_directory_data(&sdire, &start, &offset, sizeof(sdire)); if(res) SQUASHFS_SWAP_DIR_ENTRY_3(dire, &sdire); } else res = read_directory_data(dire, &start, &offset, sizeof(*dire)); if(res == FALSE) goto corrupted; bytes += sizeof(*dire); /* size should never be SQUASHFS_NAME_LEN or larger */ if(dire->size >= SQUASHFS_NAME_LEN) { ERROR("File system corrupted: filename too long\n"); goto corrupted; } res = read_directory_data(dire->name, &start, &offset, dire->size + 1); if(res == FALSE) goto corrupted; dire->name[dire->size + 1] = '\0'; /* check name for invalid characters (i.e /, ., ..) */ if(check_name(dire->name, dire->size + 1) == FALSE) { ERROR("File system corrupted: invalid characters in name\n"); goto corrupted; } TRACE("squashfs_opendir: directory entry %s, inode " "%d:%d, type %d\n", dire->name, dirh.start_block, dire->offset, dire->type); ent = malloc(sizeof(struct dir_ent)); if(ent == NULL) MEM_ERROR(); ent->name = strdup(dire->name); ent->start_block = dirh.start_block; ent->offset = dire->offset; ent->type = dire->type; ent->next = NULL; if(cur_ent == NULL) dir->dirs = ent; else cur_ent->next = ent; cur_ent = ent; dir->dir_count ++; bytes += dire->size + 1; } } /* check directory for duplicate names and sorting */ if(check_directory(dir) == FALSE) { ERROR("File system corrupted: directory has duplicate names or is unsorted\n"); goto corrupted; } return dir; corrupted: squashfs_closedir(dir); return NULL; }
0
313,546
static int __must_check rose_add_node(struct rose_route_struct *rose_route, struct net_device *dev) { struct rose_node *rose_node, *rose_tmpn, *rose_tmpp; struct rose_neigh *rose_neigh; int i, res = 0; spin_lock_bh(&rose_node_list_lock); spin_lock_bh(&rose_neigh_list_lock); rose_node = rose_node_list; while (rose_node != NULL) { if ((rose_node->mask == rose_route->mask) && (rosecmpm(&rose_route->address, &rose_node->address, rose_route->mask) == 0)) break; rose_node = rose_node->next; } if (rose_node != NULL && rose_node->loopback) { res = -EINVAL; goto out; } rose_neigh = rose_neigh_list; while (rose_neigh != NULL) { if (ax25cmp(&rose_route->neighbour, &rose_neigh->callsign) == 0 && rose_neigh->dev == dev) break; rose_neigh = rose_neigh->next; } if (rose_neigh == NULL) { rose_neigh = kmalloc(sizeof(*rose_neigh), GFP_ATOMIC); if (rose_neigh == NULL) { res = -ENOMEM; goto out; } rose_neigh->callsign = rose_route->neighbour; rose_neigh->digipeat = NULL; rose_neigh->ax25 = NULL; rose_neigh->dev = dev; rose_neigh->count = 0; rose_neigh->use = 0; rose_neigh->dce_mode = 0; rose_neigh->loopback = 0; rose_neigh->number = rose_neigh_no++; rose_neigh->restarted = 0; skb_queue_head_init(&rose_neigh->queue); timer_setup(&rose_neigh->ftimer, NULL, 0); timer_setup(&rose_neigh->t0timer, NULL, 0); if (rose_route->ndigis != 0) { rose_neigh->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC); if (rose_neigh->digipeat == NULL) { kfree(rose_neigh); res = -ENOMEM; goto out; } rose_neigh->digipeat->ndigi = rose_route->ndigis; rose_neigh->digipeat->lastrepeat = -1; for (i = 0; i < rose_route->ndigis; i++) { rose_neigh->digipeat->calls[i] = rose_route->digipeaters[i]; rose_neigh->digipeat->repeated[i] = 0; } } rose_neigh->next = rose_neigh_list; rose_neigh_list = rose_neigh; } /* * This is a new node to be inserted into the list. Find where it needs * to be inserted into the list, and insert it. We want to be sure * to order the list in descending order of mask size to ensure that * later when we are searching this list the first match will be the * best match. */ if (rose_node == NULL) { rose_tmpn = rose_node_list; rose_tmpp = NULL; while (rose_tmpn != NULL) { if (rose_tmpn->mask > rose_route->mask) { rose_tmpp = rose_tmpn; rose_tmpn = rose_tmpn->next; } else { break; } } /* create new node */ rose_node = kmalloc(sizeof(*rose_node), GFP_ATOMIC); if (rose_node == NULL) { res = -ENOMEM; goto out; } rose_node->address = rose_route->address; rose_node->mask = rose_route->mask; rose_node->count = 1; rose_node->loopback = 0; rose_node->neighbour[0] = rose_neigh; if (rose_tmpn == NULL) { if (rose_tmpp == NULL) { /* Empty list */ rose_node_list = rose_node; rose_node->next = NULL; } else { rose_tmpp->next = rose_node; rose_node->next = NULL; } } else { if (rose_tmpp == NULL) { /* 1st node */ rose_node->next = rose_node_list; rose_node_list = rose_node; } else { rose_tmpp->next = rose_node; rose_node->next = rose_tmpn; } } rose_neigh->count++; goto out; } /* We have space, slot it in */ if (rose_node->count < 3) { rose_node->neighbour[rose_node->count] = rose_neigh; rose_node->count++; rose_neigh->count++; } out: spin_unlock_bh(&rose_neigh_list_lock); spin_unlock_bh(&rose_node_list_lock); return res; }
0
450,433
int vnc_zrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) { vs->zrle->type = VNC_ENCODING_ZRLE; return zrle_send_framebuffer_update(vs, x, y, w, h); }
0
432,710
static void draw_fill_color_rgb( wmfAPI* API, const wmfRGB* rgb ) { PixelWand *fill_color; fill_color=NewPixelWand(); PixelSetRedQuantum(fill_color,ScaleCharToQuantum(rgb->r)); PixelSetGreenQuantum(fill_color,ScaleCharToQuantum(rgb->g)); PixelSetBlueQuantum(fill_color,ScaleCharToQuantum(rgb->b)); PixelSetAlphaQuantum(fill_color,OpaqueAlpha); DrawSetFillColor(WmfDrawingWand,fill_color); fill_color=DestroyPixelWand(fill_color); }
0
387,741
jint InstanceKlass::compute_modifier_flags(TRAPS) const { jint access = access_flags().as_int(); // But check if it happens to be member class. InnerClassesIterator iter(this); for (; !iter.done(); iter.next()) { int ioff = iter.inner_class_info_index(); // Inner class attribute can be zero, skip it. // Strange but true: JVM spec. allows null inner class refs. if (ioff == 0) continue; // only look at classes that are already loaded // since we are looking for the flags for our self. Symbol* inner_name = constants()->klass_name_at(ioff); if (name() == inner_name) { // This is really a member class. access = iter.inner_access_flags(); break; } } // Remember to strip ACC_SUPER bit return (access & (~JVM_ACC_SUPER)) & JVM_ACC_WRITTEN_FLAGS; }
0
264,709
Graph* GetConstantGraph( const Graph* orig_graph, const std::vector<Node*>& nodes, const std::unordered_map<const Node*, std::vector<Tensor>>& shape_replacement_map, std::map<NodeAndOutput, NodeAndOutput>* tensors_to_fetch, const ConstantFoldNameGenerator& generate_new_name) { Graph* constant_graph = new Graph(orig_graph->op_registry()); std::unordered_map<Node*, std::vector<Node*>> node_map; node_map[orig_graph->source_node()] = {constant_graph->source_node()}; node_map[orig_graph->sink_node()] = {constant_graph->sink_node()}; for (Node* n : nodes) { if (shape_replacement_map.count(n) == 0) { AddNodeToConstantGraph(n, &node_map, constant_graph); } else { AddShapeNodeToConstantGraph(n, shape_replacement_map, &node_map, generate_new_name, constant_graph); } } for (auto const& added_nodes : node_map) { for (const Edge* out_edge : added_nodes.first->out_edges()) { if (node_map.count(out_edge->dst()) == 0) { if (out_edge->IsControlEdge()) continue; if (added_nodes.second.size() == 1) { tensors_to_fetch->insert( {{added_nodes.second[0], out_edge->src_output()}, {added_nodes.first, out_edge->src_output()}}); } else { // The node had multiple outputs and was replaced by a // vector of constants, so the NodeAndOutput is the 0th // output of the kth added constant, rather than the kth // output of the added node as in the standard case above. tensors_to_fetch->insert( {{added_nodes.second[out_edge->src_output()], 0}, {added_nodes.first, out_edge->src_output()}}); } } } } return constant_graph; }
0
226,127
GF_Err trun_box_size(GF_Box *s) { GF_TrackFragmentRunBox *ptr = (GF_TrackFragmentRunBox *)s; #ifdef GF_ENABLE_CTRN if (ptr->use_ctrn) return ctrn_box_size(ptr); #endif ptr->size += 4; //The rest depends on the flags if (ptr->flags & GF_ISOM_TRUN_DATA_OFFSET) ptr->size += 4; if (ptr->flags & GF_ISOM_TRUN_FIRST_FLAG) ptr->size += 4; if (ptr->sample_order) { u32 nb_bytes = 1; if (ptr->sample_count>0xFFFFFF) nb_bytes = 4; else if (ptr->sample_count>0xFFFF) nb_bytes = 3; else if (ptr->sample_count>0xFF) nb_bytes = 2; ptr->size += ptr->sample_count*nb_bytes; } if (! (ptr->flags & (GF_ISOM_TRUN_DURATION | GF_ISOM_TRUN_SIZE | GF_ISOM_TRUN_FLAGS | GF_ISOM_TRUN_CTS_OFFSET) ) ) { return GF_OK; } //if nothing to do, this will be skipped automatically if (ptr->flags & GF_ISOM_TRUN_DURATION) ptr->size += 4*ptr->nb_samples; if (ptr->flags & GF_ISOM_TRUN_SIZE) ptr->size += 4*ptr->nb_samples; //SHOULDN'T BE USED IF GF_ISOM_TRUN_FIRST_FLAG IS DEFINED if (ptr->flags & GF_ISOM_TRUN_FLAGS) ptr->size += 4*ptr->nb_samples; if (ptr->flags & GF_ISOM_TRUN_CTS_OFFSET) ptr->size += 4*ptr->nb_samples; return GF_OK;
0
281,160
int xfrm_policy_flush(struct net *net, u8 type, bool task_valid) { int dir, err = 0, cnt = 0; spin_lock_bh(&net->xfrm.xfrm_policy_lock); err = xfrm_policy_flush_secctx_check(net, type, task_valid); if (err) goto out; for (dir = 0; dir < XFRM_POLICY_MAX; dir++) { struct xfrm_policy *pol; int i; again1: hlist_for_each_entry(pol, &net->xfrm.policy_inexact[dir], bydst) { if (pol->type != type) continue; __xfrm_policy_unlink(pol, dir); spin_unlock_bh(&net->xfrm.xfrm_policy_lock); cnt++; xfrm_audit_policy_delete(pol, 1, task_valid); xfrm_policy_kill(pol); spin_lock_bh(&net->xfrm.xfrm_policy_lock); goto again1; } for (i = net->xfrm.policy_bydst[dir].hmask; i >= 0; i--) { again2: hlist_for_each_entry(pol, net->xfrm.policy_bydst[dir].table + i, bydst) { if (pol->type != type) continue; __xfrm_policy_unlink(pol, dir); spin_unlock_bh(&net->xfrm.xfrm_policy_lock); cnt++; xfrm_audit_policy_delete(pol, 1, task_valid); xfrm_policy_kill(pol); spin_lock_bh(&net->xfrm.xfrm_policy_lock); goto again2; } } } if (!cnt) err = -ESRCH; out: spin_unlock_bh(&net->xfrm.xfrm_policy_lock); return err; }
0
101,702
WebProcessProxy::~WebProcessProxy() { if (m_webConnection) m_webConnection->invalidate(); }
0
517,437
static void do_viewlog(HttpRequest req, HttpResponse res) { if (is_readonly(req)) { send_error(req, res, SC_FORBIDDEN, "You do not have sufficient privileges to access this page"); return; } do_head(res, "_viewlog", "View log", 100); if ((Run.flags & Run_Log) && ! (Run.flags & Run_UseSyslog)) { FILE *f = fopen(Run.files.log, "r"); if (f) { size_t n; char buf[512]; StringBuffer_append(res->outputbuffer, "<br><p><form><textarea cols=120 rows=30 readonly>"); while ((n = fread(buf, sizeof(char), sizeof(buf) - 1, f)) > 0) { buf[n] = 0; escapeHTML(res->outputbuffer, buf); } fclose(f); StringBuffer_append(res->outputbuffer, "</textarea></form>"); } else { StringBuffer_append(res->outputbuffer, "Error opening logfile: %s", STRERROR); } } else { StringBuffer_append(res->outputbuffer, "<b>Cannot view logfile:</b><br>"); if (! (Run.flags & Run_Log)) StringBuffer_append(res->outputbuffer, "Monit was started without logging"); else StringBuffer_append(res->outputbuffer, "Monit uses syslog"); } do_foot(res); }
0
234,158
load_debug_sup_file (const char * main_filename, void * file) { if (! load_debug_section (debug_sup, file)) return; /* No .debug_sup section. */ struct dwarf_section * section; section = & debug_displays [debug_sup].section; assert (section != NULL); if (section->start == NULL || section->size < 5) { warn (_(".debug_sup section is corrupt/empty\n")); return; } if (section->start[2] != 0) return; /* This is a supplementary file. */ const char * filename = (const char *) section->start + 3; if (strnlen (filename, section->size - 3) == section->size - 3) { warn (_("filename in .debug_sup section is corrupt\n")); return; } if (filename[0] != '/' && strchr (main_filename, '/')) { char * new_name; int new_len; new_len = asprintf (& new_name, "%.*s/%s", (int) (strrchr (main_filename, '/') - main_filename), main_filename, filename); if (new_len < 3) { warn (_("unable to construct path for supplementary debug file")); if (new_len > -1) free (new_name); return; } filename = new_name; } else { /* PR 27796: Make sure that we pass a filename that can be free'd to add_separate_debug_file(). */ filename = strdup (filename); if (filename == NULL) { warn (_("out of memory constructing filename for .debug_sup link\n")); return; } } void * handle = open_debug_file (filename); if (handle == NULL) { warn (_("unable to open file '%s' referenced from .debug_sup section\n"), filename); free ((void *) filename); return; } printf (_("%s: Found supplementary debug file: %s\n\n"), main_filename, filename); /* FIXME: Compare the checksums, if present. */ add_separate_debug_file (filename, handle); }
0
256,418
PJ_DEF(void) pjmedia_rtcp_fb_setting_dup( pj_pool_t *pool, pjmedia_rtcp_fb_setting *dst, const pjmedia_rtcp_fb_setting *src) { unsigned i; pj_assert(pool && dst && src); pj_memcpy(dst, src, sizeof(pjmedia_rtcp_fb_setting)); for (i = 0; i < src->cap_count; ++i) { pjmedia_rtcp_fb_cap_dup(pool, &dst->caps[i], &src->caps[i]); } }
0
417,092
bool PlayerGeneric::isIdle() const { if (player) return player->isIdle(); return idle; }
0
224,729
GF_Err meta_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem) { GF_MetaBox *ptr = (GF_MetaBox *)s; switch (a->type) { case GF_ISOM_BOX_TYPE_HDLR: BOX_FIELD_ASSIGN(handler, GF_HandlerBox) break; case GF_ISOM_BOX_TYPE_PITM: BOX_FIELD_ASSIGN(primary_resource, GF_PrimaryItemBox) break; case GF_ISOM_BOX_TYPE_DINF: BOX_FIELD_ASSIGN(file_locations, GF_DataInformationBox) break; case GF_ISOM_BOX_TYPE_ILOC: BOX_FIELD_ASSIGN(item_locations, GF_ItemLocationBox) break; case GF_ISOM_BOX_TYPE_IPRO: BOX_FIELD_ASSIGN(protections, GF_ItemProtectionBox) break; case GF_ISOM_BOX_TYPE_IINF: BOX_FIELD_ASSIGN(item_infos, GF_ItemInfoBox) break; case GF_ISOM_BOX_TYPE_IREF: BOX_FIELD_ASSIGN(item_refs, GF_ItemReferenceBox); break; case GF_ISOM_BOX_TYPE_IPRP: BOX_FIELD_ASSIGN(item_props, GF_ItemPropertiesBox) break; case GF_ISOM_BOX_TYPE_GRPL: BOX_FIELD_ASSIGN(groups_list, GF_GroupListBox) break; } return GF_OK; }
0
389,546
xmlInitParser(void) { if (xmlParserInitialized != 0) return; #ifdef LIBXML_THREAD_ENABLED __xmlGlobalInitMutexLock(); if (xmlParserInitialized == 0) { #endif xmlInitThreads(); xmlInitGlobals(); if ((xmlGenericError == xmlGenericErrorDefaultFunc) || (xmlGenericError == NULL)) initGenericErrorDefaultFunc(NULL); xmlInitMemory(); xmlInitCharEncodingHandlers(); xmlDefaultSAXHandlerInit(); xmlRegisterDefaultInputCallbacks(); #ifdef LIBXML_OUTPUT_ENABLED xmlRegisterDefaultOutputCallbacks(); #endif /* LIBXML_OUTPUT_ENABLED */ #ifdef LIBXML_HTML_ENABLED htmlInitAutoClose(); htmlDefaultSAXHandlerInit(); #endif #ifdef LIBXML_XPATH_ENABLED xmlXPathInit(); #endif xmlParserInitialized = 1; #ifdef LIBXML_THREAD_ENABLED } __xmlGlobalInitMutexUnlock(); #endif }
0
242,266
bool PamAuthenticateUser(BareosSocket* UA_sock, const std::string& username_in, const std::string& password_in, std::string& authenticated_username) { std::unique_ptr<PamData> pam_callback_data(new PamData(UA_sock, password_in)); std::unique_ptr<struct pam_conv> pam_conversation_container( new struct pam_conv); struct pam_handle* pamh = nullptr; /* pam session handle */ bool interactive = true; if (!username_in.empty() && !password_in.empty()) { interactive = false; } pam_conversation_container->conv = interactive ? PamConversationCallback : PamLocalCallback; pam_conversation_container->appdata_ptr = pam_callback_data.get(); const char* username = username_in.empty() ? nullptr : username_in.c_str(); int err = pam_start(service_name.c_str(), username, pam_conversation_container.get(), &pamh); if (err != PAM_SUCCESS) { Dmsg1(debuglevel, "PAM start failed: %s\n", pam_strerror(pamh, err)); return false; } err = DoPamAuth(pamh, username, authenticated_username); if (pam_end(pamh, err) != PAM_SUCCESS) { Dmsg1(debuglevel, "PAM end failed: %s\n", pam_strerror(pamh, err)); return false; } if (err == PAM_SUCCESS) { bool ok = true; if (interactive) { ok = PamConvSendMessage(UA_sock, "", PAM_SUCCESS); } return ok; } return false; }
0
473,934
big5_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end, OnigEncoding enc) { return onigenc_mbn_is_mbc_ambiguous(enc, flag, pp, end); }
0
436,095
static int io_iopoll_check(struct io_ring_ctx *ctx, long min) { unsigned int nr_events = 0; int ret = 0; /* * We disallow the app entering submit/complete with polling, but we * still need to lock the ring to prevent racing with polled issue * that got punted to a workqueue. */ mutex_lock(&ctx->uring_lock); /* * Don't enter poll loop if we already have events pending. * If we do, we can potentially be spinning for commands that * already triggered a CQE (eg in error). */ if (test_bit(0, &ctx->check_cq_overflow)) __io_cqring_overflow_flush(ctx, false); if (io_cqring_events(ctx)) goto out; do { /* * If a submit got punted to a workqueue, we can have the * application entering polling for a command before it gets * issued. That app will hold the uring_lock for the duration * of the poll right here, so we need to take a breather every * now and then to ensure that the issue has a chance to add * the poll to the issued list. Otherwise we can spin here * forever, while the workqueue is stuck trying to acquire the * very same mutex. */ if (list_empty(&ctx->iopoll_list)) { u32 tail = ctx->cached_cq_tail; mutex_unlock(&ctx->uring_lock); io_run_task_work(); mutex_lock(&ctx->uring_lock); /* some requests don't go through iopoll_list */ if (tail != ctx->cached_cq_tail || list_empty(&ctx->iopoll_list)) break; } ret = io_do_iopoll(ctx, &nr_events, min); } while (!ret && nr_events < min && !need_resched()); out: mutex_unlock(&ctx->uring_lock); return ret; }
0
482,466
appendInstructionChar( const FileInfo *file, widechar *passInstructions, int *passIC, widechar ch) { if (*passIC >= MAXSTRING) { compileError(file, "multipass operand too long"); return 0; } passInstructions[(*passIC)++] = ch; return 1; }
0
513,035
Item_ref(THD *thd, Name_resolution_context *context_arg, const char *db_arg, const char *table_name_arg, const LEX_CSTRING *field_name_arg): Item_ident(thd, context_arg, db_arg, table_name_arg, field_name_arg), set_properties_only(0), ref(0), reference_trough_name(1) {}
0
223,404
static int get_framesize(compiler_common *common, PCRE2_SPTR cc, PCRE2_SPTR ccend, BOOL recursive, BOOL *needs_control_head) { int length = 0; int possessive = 0; BOOL stack_restore = FALSE; BOOL setsom_found = recursive; BOOL setmark_found = recursive; /* The last capture is a local variable even for recursions. */ BOOL capture_last_found = FALSE; #if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD SLJIT_ASSERT(common->control_head_ptr != 0); *needs_control_head = TRUE; #else *needs_control_head = FALSE; #endif if (ccend == NULL) { ccend = bracketend(cc) - (1 + LINK_SIZE); if (!recursive && (*cc == OP_CBRAPOS || *cc == OP_SCBRAPOS)) { possessive = length = (common->capture_last_ptr != 0) ? 5 : 3; /* This is correct regardless of common->capture_last_ptr. */ capture_last_found = TRUE; } cc = next_opcode(common, cc); } SLJIT_ASSERT(cc != NULL); while (cc < ccend) switch(*cc) { case OP_SET_SOM: SLJIT_ASSERT(common->has_set_som); stack_restore = TRUE; if (!setsom_found) { length += 2; setsom_found = TRUE; } cc += 1; break; case OP_MARK: case OP_COMMIT_ARG: case OP_PRUNE_ARG: case OP_THEN_ARG: SLJIT_ASSERT(common->mark_ptr != 0); stack_restore = TRUE; if (!setmark_found) { length += 2; setmark_found = TRUE; } if (common->control_head_ptr != 0) *needs_control_head = TRUE; cc += 1 + 2 + cc[1]; break; case OP_RECURSE: stack_restore = TRUE; if (common->has_set_som && !setsom_found) { length += 2; setsom_found = TRUE; } if (common->mark_ptr != 0 && !setmark_found) { length += 2; setmark_found = TRUE; } if (common->capture_last_ptr != 0 && !capture_last_found) { length += 2; capture_last_found = TRUE; } cc += 1 + LINK_SIZE; break; case OP_CBRA: case OP_CBRAPOS: case OP_SCBRA: case OP_SCBRAPOS: stack_restore = TRUE; if (common->capture_last_ptr != 0 && !capture_last_found) { length += 2; capture_last_found = TRUE; } length += 3; cc += 1 + LINK_SIZE + IMM2_SIZE; break; case OP_THEN: stack_restore = TRUE; if (common->control_head_ptr != 0) *needs_control_head = TRUE; cc ++; break; default: stack_restore = TRUE; /* Fall through. */ case OP_NOT_WORD_BOUNDARY: case OP_WORD_BOUNDARY: case OP_NOT_DIGIT: case OP_DIGIT: case OP_NOT_WHITESPACE: case OP_WHITESPACE: case OP_NOT_WORDCHAR: case OP_WORDCHAR: case OP_ANY: case OP_ALLANY: case OP_ANYBYTE: case OP_NOTPROP: case OP_PROP: case OP_ANYNL: case OP_NOT_HSPACE: case OP_HSPACE: case OP_NOT_VSPACE: case OP_VSPACE: case OP_EXTUNI: case OP_EODN: case OP_EOD: case OP_CIRC: case OP_CIRCM: case OP_DOLL: case OP_DOLLM: case OP_CHAR: case OP_CHARI: case OP_NOT: case OP_NOTI: case OP_EXACT: case OP_POSSTAR: case OP_POSPLUS: case OP_POSQUERY: case OP_POSUPTO: case OP_EXACTI: case OP_POSSTARI: case OP_POSPLUSI: case OP_POSQUERYI: case OP_POSUPTOI: case OP_NOTEXACT: case OP_NOTPOSSTAR: case OP_NOTPOSPLUS: case OP_NOTPOSQUERY: case OP_NOTPOSUPTO: case OP_NOTEXACTI: case OP_NOTPOSSTARI: case OP_NOTPOSPLUSI: case OP_NOTPOSQUERYI: case OP_NOTPOSUPTOI: case OP_TYPEEXACT: case OP_TYPEPOSSTAR: case OP_TYPEPOSPLUS: case OP_TYPEPOSQUERY: case OP_TYPEPOSUPTO: case OP_CLASS: case OP_NCLASS: case OP_XCLASS: case OP_CALLOUT: case OP_CALLOUT_STR: cc = next_opcode(common, cc); SLJIT_ASSERT(cc != NULL); break; } /* Possessive quantifiers can use a special case. */ if (SLJIT_UNLIKELY(possessive == length)) return stack_restore ? no_frame : no_stack; if (length > 0) return length + 1; return stack_restore ? no_frame : no_stack; }
0
253,523
smb2_query_dir_next(const unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *fid, __u16 search_flags, struct cifs_search_info *srch_inf) { return SMB2_query_directory(xid, tcon, fid->persistent_fid, fid->volatile_fid, 0, srch_inf); }
0
310,324
dirserv_add_extrainfo(extrainfo_t *ei, const char **msg) { routerinfo_t *ri; int r; tor_assert(msg); *msg = NULL; ri = router_get_by_digest(ei->cache_info.identity_digest); if (!ri) { *msg = "No corresponding router descriptor for extra-info descriptor"; extrainfo_free(ei); return ROUTER_BAD_EI; } /* If it's too big, refuse it now. Otherwise we'll cache it all over the * network and it'll clog everything up. */ if (ei->cache_info.signed_descriptor_len > MAX_EXTRAINFO_UPLOAD_SIZE) { log_notice(LD_DIR, "Somebody attempted to publish an extrainfo " "with size %d. Either this is an attack, or the " "MAX_EXTRAINFO_UPLOAD_SIZE (%d) constant is too low.", (int)ei->cache_info.signed_descriptor_len, MAX_EXTRAINFO_UPLOAD_SIZE); *msg = "Extrainfo document was too large"; extrainfo_free(ei); return ROUTER_BAD_EI; } if ((r = routerinfo_incompatible_with_extrainfo(ri, ei, NULL, msg))) { extrainfo_free(ei); return r < 0 ? ROUTER_WAS_NOT_NEW : ROUTER_BAD_EI; } router_add_extrainfo_to_routerlist(ei, msg, 0, 0); return ROUTER_ADDED_SUCCESSFULLY; }
0
312,578
qf_parse_fmt_r(regmatch_T *rmp, int midx, char_u **tail) { if (rmp->startp[midx] == NULL) return QF_FAIL; *tail = rmp->startp[midx]; return QF_OK; }
0
312,538
qf_setprop_context(qf_list_T *qfl, dictitem_T *di) { typval_T *ctx; free_tv(qfl->qf_ctx); ctx = alloc_tv(); if (ctx != NULL) copy_tv(&di->di_tv, ctx); qfl->qf_ctx = ctx; return OK; }
0
485,285
static int unzzip_cat (int argc, char ** argv, int extract) { int argn; ZZIP_DIR* disk; zzip_error_t error; if (argc == 1) { printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n"); return -1; /* better provide an archive argument */ } disk = zzip_dir_open (argv[1], &error); if (! disk) { fprintf(stderr, "%s: %s\n", argv[1], zzip_strerror(error)); return -1; } if (argc == 2) { /* list all */ ZZIP_DIRENT entry; while(zzip_dir_read(disk, &entry)) { char* name = entry.d_name; FILE* out = stdout; if (extract) out = create_fopen(name, "w", 1); if (out) { unzzip_cat_file (disk, name, out); if (extract) fclose(out); } } } else { /* list only the matching entries - in order of zip directory */ ZZIP_DIRENT entry; while(zzip_dir_read(disk, &entry)) { char* name = entry.d_name; for (argn=1; argn < argc; argn++) { if (! _zzip_fnmatch (argv[argn], name, FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD)) { FILE* out = stdout; if (extract) out = create_fopen(name, "w", 1); if (out) { unzzip_cat_file (disk, name, out); if (extract) fclose(out); } break; /* match loop */ } } } } zzip_dir_close(disk); return 0; }
0
359,314
peer_port_vty (struct vty *vty, const char *ip_str, int afi, const char *port_str) { struct peer *peer; u_int16_t port; struct servent *sp; peer = peer_lookup_vty (vty, ip_str); if (! peer) return CMD_WARNING; if (! port_str) { sp = getservbyname ("bgp", "tcp"); port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); } else { VTY_GET_INTEGER("port", port, port_str); } peer_port_set (peer, port); return CMD_SUCCESS; }
0
400,769
size_t copy_page_from_iter(struct page *page, size_t offset, size_t bytes, struct iov_iter *i) { if (unlikely(!page_copy_sane(page, offset, bytes))) return 0; if (likely(iter_is_iovec(i))) return copy_page_from_iter_iovec(page, offset, bytes, i); if (iov_iter_is_bvec(i) || iov_iter_is_kvec(i) || iov_iter_is_xarray(i)) { void *kaddr = kmap_local_page(page); size_t wanted = _copy_from_iter(kaddr + offset, bytes, i); kunmap_local(kaddr); return wanted; } WARN_ON(1); return 0; }
0
276,973
ReadSample(SampleReader& reader, AP4_Track& track, AP4_Sample& sample, AP4_DataBuffer& sample_data, double& ts, double& duration, bool& eos) { AP4_Result result = reader.ReadSample(sample, sample_data); if (AP4_FAILED(result)) { if (result == AP4_ERROR_EOS) { // advance the timestamp by the last sample's duration ts += duration; eos = true; return AP4_SUCCESS; } else { return result; } } ts = (double)sample.GetDts()/(double)track.GetMediaTimeScale(); duration = sample.GetDuration()/(double)track.GetMediaTimeScale(); return AP4_SUCCESS; }
0
309,943
onsig(int n GCC_UNUSED) { interrupted = TRUE; }
0
359,253
bgp_vty_return (struct vty *vty, int ret) { const char *str = NULL; switch (ret) { case BGP_ERR_INVALID_VALUE: str = "Invalid value"; break; case BGP_ERR_INVALID_FLAG: str = "Invalid flag"; break; case BGP_ERR_PEER_INACTIVE: str = "Activate the neighbor for the address family first"; break; case BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER: str = "Invalid command for a peer-group member"; break; case BGP_ERR_PEER_GROUP_SHUTDOWN: str = "Peer-group has been shutdown. Activate the peer-group first"; break; case BGP_ERR_PEER_GROUP_HAS_THE_FLAG: str = "This peer is a peer-group member. Please change peer-group configuration"; break; case BGP_ERR_PEER_FLAG_CONFLICT: str = "Can't set override-capability and strict-capability-match at the same time"; break; case BGP_ERR_PEER_GROUP_MEMBER_EXISTS: str = "No activate for peergroup can be given only if peer-group has no members"; break; case BGP_ERR_PEER_BELONGS_TO_GROUP: str = "No activate for an individual peer-group member is invalid"; break; case BGP_ERR_PEER_GROUP_AF_UNCONFIGURED: str = "Activate the peer-group for the address family first"; break; case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: str = "Specify remote-as or peer-group remote AS first"; break; case BGP_ERR_PEER_GROUP_CANT_CHANGE: str = "Cannot change the peer-group. Deconfigure first"; break; case BGP_ERR_PEER_GROUP_MISMATCH: str = "Cannot have different peer-group for the neighbor"; break; case BGP_ERR_PEER_FILTER_CONFLICT: str = "Prefix/distribute list can not co-exist"; break; case BGP_ERR_NOT_INTERNAL_PEER: str = "Invalid command. Not an internal neighbor"; break; case BGP_ERR_REMOVE_PRIVATE_AS: str = "Private AS cannot be removed for IBGP peers"; break; case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: str = "Local-AS allowed only for EBGP peers"; break; case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: str = "Cannot have local-as same as BGP AS number"; break; } if (str) { vty_out (vty, "%% %s%s", str, VTY_NEWLINE); return CMD_WARNING; } return CMD_SUCCESS; }
0
508,799
bool st_select_lex::add_index_hint (THD *thd, char *str, uint length) { return index_hints->push_front(new (thd->mem_root) Index_hint(current_index_hint_type, current_index_hint_clause, str, length), thd->mem_root); }
0
225,901
void fecr_box_del(GF_Box *s) { FECReservoirBox *ptr = (FECReservoirBox *)s; if (ptr == NULL) return; if (ptr->entries) gf_free(ptr->entries); gf_free(ptr);
0
307,864
void ciEnv::dump_replay_data_unsafe(outputStream* out) { ResourceMark rm; #if INCLUDE_JVMTI out->print_cr("JvmtiExport can_access_local_variables %d", _jvmti_can_access_local_variables); out->print_cr("JvmtiExport can_hotswap_or_post_breakpoint %d", _jvmti_can_hotswap_or_post_breakpoint); out->print_cr("JvmtiExport can_post_on_exceptions %d", _jvmti_can_post_on_exceptions); #endif // INCLUDE_JVMTI GrowableArray<ciMetadata*>* objects = _factory->get_ci_metadata(); out->print_cr("# %d ciObject found", objects->length()); for (int i = 0; i < objects->length(); i++) { objects->at(i)->dump_replay_data(out); } dump_compile_data(out); out->flush(); }
0
344,775
argv_assemble(int argc, char **argv) { int i, j, ws, r; char c, *ret; struct sshbuf *buf, *arg; if ((buf = sshbuf_new()) == NULL || (arg = sshbuf_new()) == NULL) fatal_f("sshbuf_new failed"); for (i = 0; i < argc; i++) { ws = 0; sshbuf_reset(arg); for (j = 0; argv[i][j] != '\0'; j++) { r = 0; c = argv[i][j]; switch (c) { case ' ': case '\t': ws = 1; r = sshbuf_put_u8(arg, c); break; case '\\': case '\'': case '"': if ((r = sshbuf_put_u8(arg, '\\')) != 0) break; /* FALLTHROUGH */ default: r = sshbuf_put_u8(arg, c); break; } if (r != 0) fatal_fr(r, "sshbuf_put_u8"); } if ((i != 0 && (r = sshbuf_put_u8(buf, ' ')) != 0) || (ws != 0 && (r = sshbuf_put_u8(buf, '"')) != 0) || (r = sshbuf_putb(buf, arg)) != 0 || (ws != 0 && (r = sshbuf_put_u8(buf, '"')) != 0)) fatal_fr(r, "assemble"); } if ((ret = malloc(sshbuf_len(buf) + 1)) == NULL) fatal_f("malloc failed"); memcpy(ret, sshbuf_ptr(buf), sshbuf_len(buf)); ret[sshbuf_len(buf)] = '\0'; sshbuf_free(buf); sshbuf_free(arg); return ret; }
0
508,919
void st_select_lex::set_explain_type(bool on_the_fly) { bool is_primary= FALSE; if (next_select()) is_primary= TRUE; if (!is_primary && first_inner_unit()) { /* If there is at least one materialized derived|view then it's a PRIMARY select. Otherwise, all derived tables/views were merged and this select is a SIMPLE one. */ for (SELECT_LEX_UNIT *un= first_inner_unit(); un; un= un->next_unit()) { if ((!un->derived || un->derived->is_materialized_derived())) { is_primary= TRUE; break; } } } if (on_the_fly && !is_primary && have_merged_subqueries) is_primary= TRUE; SELECT_LEX *first= master_unit()->first_select(); /* drop UNCACHEABLE_EXPLAIN, because it is for internal usage only */ uint8 is_uncacheable= (uncacheable & ~UNCACHEABLE_EXPLAIN); bool using_materialization= FALSE; Item_subselect *parent_item; if ((parent_item= master_unit()->item) && parent_item->substype() == Item_subselect::IN_SUBS) { Item_in_subselect *in_subs= (Item_in_subselect*)parent_item; /* Surprisingly, in_subs->is_set_strategy() can return FALSE here, even for the last invocation of this function for the select. */ if (in_subs->test_strategy(SUBS_MATERIALIZATION)) using_materialization= TRUE; } if (&master_unit()->thd->lex->select_lex == this) { type= is_primary ? "PRIMARY" : "SIMPLE"; } else { if (this == first) { /* If we're a direct child of a UNION, we're the first sibling there */ if (linkage == DERIVED_TABLE_TYPE) type= "DERIVED"; else if (using_materialization) type= "MATERIALIZED"; else { if (is_uncacheable & UNCACHEABLE_DEPENDENT) type= "DEPENDENT SUBQUERY"; else { type= is_uncacheable? "UNCACHEABLE SUBQUERY" : "SUBQUERY"; } } } else { /* This a non-first sibling in UNION */ if (is_uncacheable & UNCACHEABLE_DEPENDENT) type= "DEPENDENT UNION"; else if (using_materialization) type= "MATERIALIZED UNION"; else { type= is_uncacheable ? "UNCACHEABLE UNION": "UNION"; if (this == master_unit()->fake_select_lex) type= "UNION RESULT"; /* join below may be =NULL when this functions is called at an early stage. It will be later called again and we will set the correct value. */ if (join) { bool uses_cte= false; for (JOIN_TAB *tab= first_linear_tab(join, WITHOUT_BUSH_ROOTS, WITH_CONST_TABLES); tab; tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) { /* pos_in_table_list=NULL for e.g. post-join aggregation JOIN_TABs. */ if (!(tab->table && tab->table->pos_in_table_list)) continue; TABLE_LIST *tbl= tab->table->pos_in_table_list; if (tbl->with && tbl->with->is_recursive && tbl->is_with_table_recursive_reference()) { uses_cte= true; break; } } if (uses_cte) type= "RECURSIVE UNION"; } } } } if (!on_the_fly) options|= SELECT_DESCRIBE; }
0
442,802
void progressbarinit(struct ProgressData *bar, struct Configurable *config) { #ifdef __EMX__ /* 20000318 mgs */ int scr_size [2]; #endif char *colp; memset(bar, 0, sizeof(struct ProgressData)); /* pass this through to progress function so * it can display progress towards total file * not just the part that's left. (21-may-03, dbyron) */ if (config->use_resume) bar->initial_size = config->resume_from; /* TODO: get terminal width through ansi escapes or something similar. try to update width when xterm is resized... - 19990617 larsa */ #ifndef __EMX__ /* 20000318 mgs * OS/2 users most likely won't have this env var set, and besides that * we're using our own way to determine screen width */ colp = curlx_getenv("COLUMNS"); if (colp != NULL) { bar->width = atoi(colp); curl_free(colp); } else bar->width = 79; #else /* 20000318 mgs * We use this emx library call to get the screen width, and subtract * one from what we got in order to avoid a problem with the cursor * advancing to the next line if we print a string that is as long as * the screen is wide. */ _scrsize(scr_size); bar->width = scr_size[0] - 1; #endif bar->out = config->errors; }
0
223,397
static SLJIT_INLINE void add_prefix_char(PCRE2_UCHAR chr, fast_forward_char_data *chars, BOOL last) { sljit_u32 i, count = chars->count; if (count == 255) return; if (count == 0) { chars->count = 1; chars->chars[0] = chr; if (last) chars->last_count = 1; return; } for (i = 0; i < count; i++) if (chars->chars[i] == chr) return; if (count >= MAX_DIFF_CHARS) { chars->count = 255; return; } chars->chars[count] = chr; chars->count = count + 1; if (last) chars->last_count++; }
0
310,055
_nc_trim_sgr0(TERMTYPE2 *tp) { char *result = exit_attribute_mode; T((T_CALLED("_nc_trim_sgr0()"))); if (PRESENT(exit_attribute_mode) && PRESENT(set_attributes)) { bool found = FALSE; char *on = set_attribute_9(tp, 1); char *off = set_attribute_9(tp, 0); char *end = strdup(exit_attribute_mode); char *tmp; size_t i, j, k; TR(TRACE_DATABASE, ("checking if we can trim sgr0 based on sgr")); TR(TRACE_DATABASE, ("sgr0 %s", _nc_visbuf(end))); TR(TRACE_DATABASE, ("sgr(9:off) %s", _nc_visbuf(off))); TR(TRACE_DATABASE, ("sgr(9:on) %s", _nc_visbuf(on))); if (!rewrite_sgr(on, enter_alt_charset_mode) || !rewrite_sgr(off, exit_alt_charset_mode) || !rewrite_sgr(end, exit_alt_charset_mode)) { FreeIfNeeded(off); } else if (similar_sgr(off, end) && !similar_sgr(off, on)) { TR(TRACE_DATABASE, ("adjusting sgr(9:off) : %s", _nc_visbuf(off))); result = off; /* * If rmacs is a substring of sgr(0), remove that chunk. */ if (PRESENT(exit_alt_charset_mode)) { TR(TRACE_DATABASE, ("scan for rmacs %s", _nc_visbuf(exit_alt_charset_mode))); j = strlen(off); k = strlen(exit_alt_charset_mode); if (j > k) { for (i = 0; i <= (j - k); ++i) { unsigned k2 = compare_part(exit_alt_charset_mode, off + i); if (k2 != 0) { found = TRUE; chop_out(off, (unsigned) i, (unsigned) (i + k2)); break; } } } } /* * SGR 10 would reset to normal font. */ if (!found) { if ((i = (size_t) is_csi(off)) != 0 && off[strlen(off) - 1] == 'm') { TR(TRACE_DATABASE, ("looking for SGR 10 in %s", _nc_visbuf(off))); tmp = skip_zero(off + i); if (tmp[0] == '1' && skip_zero(tmp + 1) != tmp + 1) { i = (size_t) (tmp - off); if (off[i - 1] == ';') i--; j = (size_t) (skip_zero(tmp + 1) - off); (void) chop_out(off, (unsigned) i, (unsigned) j); found = TRUE; } } } if (!found && (tmp = strstr(end, off)) != 0 && strcmp(end, off) != 0) { i = (size_t) (tmp - end); j = strlen(off); tmp = strdup(end); chop_out(tmp, (unsigned) i, (unsigned) j); free(off); result = tmp; } TR(TRACE_DATABASE, ("...adjusted sgr0 : %s", _nc_visbuf(result))); if (!strcmp(result, exit_attribute_mode)) { TR(TRACE_DATABASE, ("...same result, discard")); free(result); result = exit_attribute_mode; } } else { /* * Either the sgr does not reference alternate character set, * or it is incorrect. That's too hard to decide right now. */ free(off); } FreeIfNeeded(end); FreeIfNeeded(on); } else { /* * Possibly some applications are confused if sgr0 contains rmacs, * but that would be a different bug report -TD */ } returnPtr(result); }
0
265,450
static int sqfs_count_metablks(void *table, u32 offset, int table_size) { int count = 0, cur_size = 0, ret; u32 data_size; bool comp; do { ret = sqfs_read_metablock(table, offset + cur_size, &comp, &data_size); if (ret) return -EINVAL; cur_size += data_size + SQFS_HEADER_SIZE; count++; } while (cur_size < table_size); return count; }
0
387,587
static size_t compute_user_elem_size(size_t size, unsigned int count) { return sizeof(struct user_element) + size * count; }
0
317,259
static int smack_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size) { struct sockaddr_in *sip = (struct sockaddr_in *) msg->msg_name; #if IS_ENABLED(CONFIG_IPV6) struct sockaddr_in6 *sap = (struct sockaddr_in6 *) msg->msg_name; #endif #ifdef SMACK_IPV6_SECMARK_LABELING struct socket_smack *ssp = sock->sk->sk_security; struct smack_known *rsp; #endif int rc = 0; /* * Perfectly reasonable for this to be NULL */ if (sip == NULL) return 0; switch (sock->sk->sk_family) { case AF_INET: if (msg->msg_namelen < sizeof(struct sockaddr_in) || sip->sin_family != AF_INET) return -EINVAL; rc = smk_ipv4_check(sock->sk, sip); break; #if IS_ENABLED(CONFIG_IPV6) case AF_INET6: if (msg->msg_namelen < SIN6_LEN_RFC2133 || sap->sin6_family != AF_INET6) return -EINVAL; #ifdef SMACK_IPV6_SECMARK_LABELING rsp = smack_ipv6host_label(sap); if (rsp != NULL) rc = smk_ipv6_check(ssp->smk_out, rsp, sap, SMK_CONNECTING); #endif #ifdef SMACK_IPV6_PORT_LABELING rc = smk_ipv6_port_check(sock->sk, sap, SMK_SENDING); #endif #endif /* IS_ENABLED(CONFIG_IPV6) */ break; } return rc; }
0
219,952
int callback_default (const struct _u_request * request, struct _u_response * response, void * user_data) { UNUSED(request); UNUSED(user_data); json_t * json_body = json_pack("{ssss}", "error", "resource not found", "message", "no resource available at this address"); ulfius_set_json_body_response(response, 404, json_body); json_decref(json_body); return U_CALLBACK_CONTINUE; }
0
338,040
void WasmBinaryBuilder::verifyInt8(int8_t x) { int8_t y = getInt8(); if (x != y) { throwError("surprising value"); } }
0
446,409
RZ_API ut64 rz_dyldcache_va2pa(RzDyldCache *cache, uint64_t vaddr, ut32 *offset, ut32 *left) { rz_return_val_if_fail(cache, UT64_MAX); ut64 slide = rz_dyldcache_get_slide(cache); ut64 res = va2pa(vaddr, cache->n_maps, cache->maps, cache->buf, slide, offset, left); if (res == UT64_MAX) { res = 0; } return res; }
0
229,227
event::event_type parse_event_type(const sstring& value) { if (value == "TOPOLOGY_CHANGE") { return event::event_type::TOPOLOGY_CHANGE; } else if (value == "STATUS_CHANGE") { return event::event_type::STATUS_CHANGE; } else if (value == "SCHEMA_CHANGE") { return event::event_type::SCHEMA_CHANGE; } else { throw exceptions::protocol_exception(format("Invalid value '{}' for Event.Type", value)); } }
0
215,342
int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start, int len, int write, int force, struct page **pages, struct vm_area_struct **vmas) { int i; unsigned int vm_flags; if (len <= 0) return 0; /* * Require read or write permissions. * If 'force' is set, we only require the "MAY" flags. */ vm_flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD); vm_flags &= force ? (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE); i = 0; do { struct vm_area_struct *vma; unsigned int foll_flags; vma = find_extend_vma(mm, start); if (!vma && in_gate_area(tsk, start)) { unsigned long pg = start & PAGE_MASK; struct vm_area_struct *gate_vma = get_gate_vma(tsk); pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t *pte; if (write) /* user gate pages are read-only */ return i ? : -EFAULT; if (pg > TASK_SIZE) pgd = pgd_offset_k(pg); else pgd = pgd_offset_gate(mm, pg); BUG_ON(pgd_none(*pgd)); pud = pud_offset(pgd, pg); BUG_ON(pud_none(*pud)); pmd = pmd_offset(pud, pg); if (pmd_none(*pmd)) return i ? : -EFAULT; pte = pte_offset_map(pmd, pg); if (pte_none(*pte)) { pte_unmap(pte); return i ? : -EFAULT; } if (pages) { struct page *page = vm_normal_page(gate_vma, start, *pte); pages[i] = page; if (page) get_page(page); } pte_unmap(pte); if (vmas) vmas[i] = gate_vma; i++; start += PAGE_SIZE; len--; continue; } if (!vma || (vma->vm_flags & (VM_IO | VM_PFNMAP)) || !(vm_flags & vma->vm_flags)) return i ? : -EFAULT; if (is_vm_hugetlb_page(vma)) { i = follow_hugetlb_page(mm, vma, pages, vmas, &start, &len, i, write); continue; } foll_flags = FOLL_TOUCH; if (pages) foll_flags |= FOLL_GET; if (!write && !(vma->vm_flags & VM_LOCKED) && (!vma->vm_ops || !vma->vm_ops->fault)) foll_flags |= FOLL_ANON; do { struct page *page; /* * If tsk is ooming, cut off its access to large memory * allocations. It has a pending SIGKILL, but it can't * be processed until returning to user space. */ if (unlikely(test_tsk_thread_flag(tsk, TIF_MEMDIE))) return -ENOMEM; if (write) foll_flags |= FOLL_WRITE; cond_resched(); while (!(page = follow_page(vma, start, foll_flags))) { int ret; ret = handle_mm_fault(mm, vma, start, foll_flags & FOLL_WRITE); if (ret & VM_FAULT_ERROR) { if (ret & VM_FAULT_OOM) return i ? i : -ENOMEM; else if (ret & VM_FAULT_SIGBUS) return i ? i : -EFAULT; BUG(); } if (ret & VM_FAULT_MAJOR) tsk->maj_flt++; else tsk->min_flt++; /* * The VM_FAULT_WRITE bit tells us that * do_wp_page has broken COW when necessary, * even if maybe_mkwrite decided not to set * pte_write. We can thus safely do subsequent * page lookups as if they were reads. */ if (ret & VM_FAULT_WRITE) foll_flags &= ~FOLL_WRITE; cond_resched(); } if (pages) { pages[i] = page; flush_anon_page(vma, page, start); flush_dcache_page(page); } if (vmas) vmas[i] = vma; i++; start += PAGE_SIZE; len--; } while (len && start < vma->vm_end); } while (len); return i; }
1
247,623
TEST_P(SslSocketTest, X509ExtensionsCertificateSerialNumber) { const std::string client_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/extensions_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/extensions_key.pem" )EOF"; const std::string server_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/extensions_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/extensions_key.pem" validation_context: trusted_ca: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.pem" require_client_certificate: true )EOF"; TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, true, GetParam()); testUtil(test_options.setExpectedSerialNumber(TEST_EXTENSIONS_CERT_SERIAL)); }
0