void insert_source(node_t *node, source_t *source) { node_t *quadrant; // Check if the MAX has been reached if (node->contents.length == MAX) subdivide(node); // A node in the tree will be filled with either content or sub // quadrants. Check to see whether subquads exist. if (node->q1 != NULL) { if (source->x >= node->xmid) { if (source->y >= node->ymid) quadrant = node->q1; else quadrant = node->q4; } else { if (source->y >= node->ymid) quadrant = node->q2; else quadrant = node->q3; } insert_source(quadrant, source); } else { // If no subquads exist add source to the list in contents element // Use push() to prepend the source on the list. push(&node->contents, source); } }
void testing_parser(bool verbose) { MACRO_SET set = { 0, 0, CONFIG_OPT_WANT_META | CONFIG_OPT_DEFAULTS_ARE_PARAM_INFO, 0, NULL, NULL, ALLOCATION_POOL(), std::vector<const char*>(), &TestingMacroDefaults }; MACRO_SOURCE source = { false, false, 0, 0, -1, -2 }; insert_source("parse", set, source); testparse(__LINE__, set, def_ctx, source, verbose, "last wins", "FOO= bar\nFOO = baz\n", "\tFOO=baz\n"); testparse(__LINE__, set, def_ctx, source, verbose, "self sub", "FOO= bar\nFOO = $(FOO) baz\n", "\tFOO=bar baz\n"); testparse(__LINE__, set, def_ctx, source, verbose, "self sub picks up subsys", "FOO=bar\nMASTER.FOO= MAR\nFOO = $(FOO) baz\n", "\tFOO=bar baz\n\tMASTER.FOO=MAR\n"); testparse_as("MASTER", __LINE__, set, def_ctx, source, verbose, "self sub picks up subsys2", "FOO=bar\nMASTER.FOO= MAR\nFOO = $(FOO) baz\n", "\tFOO=MAR baz\n\tMASTER.FOO=MAR\n"); testparse_lcl("LOWER", __LINE__, set, def_ctx, source, verbose, "self sub picks up subsys3", "FOO=bar\nMASTER.FOO= MAR\nFOO = $(FOO) baz\n", "\tFOO=bar baz\n\tMASTER.FOO=MAR\n"); const char * n1 = "N1=$(NEGOTIATOR)\nN1_ARGS=-local-name N1\nN1.NEGOTIATOR_LOG=$(LOG)/NegotiatorLog.N1\nN1.SPOOL=$(SPOOL)/N1\n"; const char * n1e1 = "\tN1=$(NEGOTIATOR)\n\tN1_ARGS=-local-name N1\n\tN1.NEGOTIATOR_LOG=$(LOG)/NegotiatorLog.N1\n\tN1.SPOOL=$(SPOOL)/N1\n"; #ifdef WIN32 const char * n1e2 = "\tN1=$(NEGOTIATOR)\n\tN1_ARGS=-local-name N1\n\tN1.NEGOTIATOR_LOG=$(LOG)/NegotiatorLog.N1\n\tN1.SPOOL=$(LOCAL_DIR)\\spool/N1\n"; #else const char * n1e2 = "\tN1=$(NEGOTIATOR)\n\tN1_ARGS=-local-name N1\n\tN1.NEGOTIATOR_LOG=$(LOG)/NegotiatorLog.N1\n\tN1.SPOOL=$(LOCAL_DIR)/spool/N1\n"; #endif testparse(__LINE__, set, def_ctx, source, verbose, "subsys.self sub1", n1, n1e1); testparse_as("NEGOTIATOR", __LINE__, set, def_ctx, source, verbose, "subsys.self sub2", n1, n1e1); testparse_lcl("N1", __LINE__, set, def_ctx, source, verbose, "subsys.self sub3", n1, n1e2); testparse_lcl_as("N1", "NEGOTIATOR", __LINE__, set, def_ctx, source, verbose, "subsys.self sub4", n1, n1e2); }
int insert_rules_for_Nprop_Al() {//copies all rules of Nprop to Aprop_Al and adds to them the support for Al int source_id=insert_source("Jad and Hamza modifications","as needed","Hamza Harkous and Jad Makhlouta"); QStringList added_prefixes; added_prefixes<<"NPref-Al"<<"NPref-BiAl"<<"NPref-Lil"<<"NPref-LiAl"; QStringList added_suffixes; added_suffixes<<"NSuff-AF"; long prefix_cat_id,suffix_cat_id; long stem_cat_id_Nprop=getID("category","Nprop"); long stem_cat_id_Nprop_Al=insert_category("Nprop_Al",STEM,source_id,false); Search_Compatibility search_suffixes(BC,stem_cat_id_Nprop,true); while (search_suffixes.retrieve(suffix_cat_id)) { Search_Compatibility search_prefixes(AB,stem_cat_id_Nprop,false); //qDebug()<<search_prefixes.size()<<" "<<search_suffixes.size()<<"\n"; while (search_prefixes.retrieve(prefix_cat_id)) { insert_compatibility_rules(AB,prefix_cat_id,stem_cat_id_Nprop_Al,source_id); insert_compatibility_rules(AC,prefix_cat_id,suffix_cat_id,source_id); insert_compatibility_rules(BC,stem_cat_id_Nprop_Al,suffix_cat_id,source_id); } QString prefix_cat; foreach(prefix_cat,added_prefixes) { prefix_cat_id=getID("category",prefix_cat); insert_compatibility_rules(AB,prefix_cat_id,stem_cat_id_Nprop_Al,source_id); insert_compatibility_rules(AC,prefix_cat_id,suffix_cat_id,source_id); insert_compatibility_rules(BC,stem_cat_id_Nprop_Al,suffix_cat_id,source_id); } }
static void subdivide(node_t *node) { source_t *source; // Divide up the node node->q1 = new_node(node->xmid, node->ymid, node->box.xmax, node->box.ymax); node->q2 = new_node(node->box.xmin, node->ymid, node->xmid, node->box.ymax); node->q3 = new_node(node->box.xmin, node->box.ymin, node->xmid, node->ymid); node->q4 = new_node(node->xmid, node->box.ymin, node->box.xmax, node->ymid); while ((source = pop(&node->contents))) insert_source(node, source); }
// Populate the testing MACRO_SET with values that we can lookup and expand // in various ways. // static void insert_testing_macros(const char * local, const char * subsys) { static const struct { const char * key; const char * val; } atbl[] = { {"FOO", "bar"}, {"MASTER.foo", "mar"}, {"MASTER.bar", "hi"}, {"lower.bar", "'lo"}, {"lower.pid_snapshot_interval", "12"}, {"LOWER.VANILLA", "4"}, {"MASTER.STANDARD", "2"}, {"RELEASE_DIR", "/condor/test"}, {"TILDE", "/condor/test"}, {"LOWER.LOCAL_DIR", "/condor/lower"}, {"MASTER.SPOOL", "$(LOCAL_DIR)/mspool"}, #ifdef ALLOW_SUBSYS_LOCAL_HEIRARCHY {"MASTER.lower.history", "$(SPOOL)/mlhistory"}, {"lower.master.history", "$(SPOOL)/lmhistory"}, #endif // for $F tests {"fileBase", "base"}, {"fileExt", "ex"}, {"fileDirs", "/dur/der"}, {"fileSimple", "simple.dat"}, {"fileLong", "Now is the time for all good men."}, {"fileCompound", "$(fileDirs)/$(fileBase).$(FileExt)"}, {"fileAbs", "/one/two/three.for"}, {"urlAbs", "file:/one/two/three.for"}, {"fileAbsQuoted", "\"/one/two/three.for\""}, {"fileRel", "ein/zwei/drei.fir"}, {"fileRelSpaces", "\"ein/zw ei/dr ei.fir\""}, {"fileCurRel", "./here"}, {"fileCurRel2", "./uno/dos.tres"}, #ifdef WIN32 {"wfileAbs", "c:\\one\\two\\three.for"}, {"wfileAbsQuoted", "\"c:\\one\\two\\three.for\""}, {"wfileRel", "ein\\zwei\\drei.fir"}, {"wfileRelSpaces", "\"ein\\zw ei\\dr ei.fir\""}, {"wfileCurRel", ".\\here"}, {"wfileCurRel2", ".\\uno\\dos.tres"}, #endif // for $F regressions {"Items5", "aa bb cc dd ee"}, {"Items5Quoted", "\"aa bb cc dd ee\""}, {"List6c", "aa,bb, cc,dd,ee,ff"}, {"MASTER.List6c", "JMK,Vvv,XX,YY,ZKM,ZA"}, {"List6cfq", "$Fq(list6c)"}, // for $INT and $REAL tests {"DoubleVanilla", "$(VANILLA)*2"}, {"HalfVanilla", "$(VANILLA)/2.0"}, {"StandardMinusVM", "$(STANDARD)-$(VM)"}, }; MACRO_EVAL_CONTEXT ctx = { local, subsys, false, 2 }; insert_source("Insert", TestingMacroSet, TestMacroSource); for (size_t ii = 0; ii < COUNTOF(atbl); ++ii) { TestMacroSource.line = ii; insert_macro(atbl[ii].key, atbl[ii].val, TestingMacroSet, TestMacroSource, ctx); } }