CriticalLevel CriticalLevelDetector::detectSerial() { CriticalLevel level; CellsLineSeeker seeker(mProjectSpace.getSpaceSize(), mProjectSpace.getCellSize()); std::vector<Cell> pointsArray = mProjectSpace.getPointsArray(); FlightsPointsMap cpoints = mProjectSpace.getFlightsPoints(); compareCells(cpoints, pointsArray, seeker, level); return level; }
CELL * p_member(CELL * params) { CELL * key; CELL * list; long options = -1; char * ptr; ssize_t pos; key = evaluateExpression(params); params = getEvalDefault(params->next, &list); if(params != nilCell) getInteger(params, (UINT *)&options); if(isList(list->type)) list = (CELL *)list->contents; else if (list->type == CELL_STRING) { if(key->type != CELL_STRING) return(errorProcExt(ERR_STRING_EXPECTED, key)); if(options == -1) { ptr = strstr((char *)list->contents, (char *) key->contents); if(ptr) return(stuffString(ptr)); } else { pos = searchBufferRegex((char*)list->contents, 0, (char *)key->contents, list->aux - 1, options, 0); if(pos != -1) return(stuffString((char *)list->contents + pos)); } return(nilCell); } else return(errorProcExt(ERR_LIST_OR_STRING_EXPECTED, params->next)); while(list != nilCell) { if(compareCells(key, list) == 0) break; list = list->next; } if(list == nilCell) return(nilCell); return(makeCell(CELL_EXPRESSION, (UINT)copyList(list))); }
CELL * startsEndsWith(CELL * params, int type) { char * string; char * key; char * keydollar; long options = -1; size_t slen, pos; int klen; CELL * cell, * list; cell = params->next; getEvalDefault(params, &list); if(list->type == CELL_STRING) { string = (char *)list->contents; getString(cell, &key); } else { if(!isList(list->type)) errorProcExt(ERR_LIST_OR_STRING_EXPECTED, params); cell = evaluateExpression(cell); list = (CELL *)list->contents; if(type == ENDS_WITH) while(list->next != nilCell) list = list->next; if(compareCells(list, cell) == 0) return(trueCell); else return(nilCell); } if(cell->next != nilCell) { cell = evaluateExpression(cell->next); getIntegerExt(cell, (UINT*)&options, FALSE); } klen = strlen(key); slen = strlen(string); if(type == STARTS_WITH) { if(options == -1) { if(strncmp(string, key, (size_t)klen) == 0) return(trueCell); } else { if(searchBufferRegex(string, 0, key, slen, options, 0) == 0) return(trueCell); } return(nilCell); } if((options == -1) && (klen > slen)) return(nilCell); if(options == -1) { if(strncmp(string + slen - klen, key, klen) == 0) return(trueCell); } else { /* append $ to the pattern for anchoring at the end */ keydollar = malloc(klen + 4); *keydollar = '('; memcpy(keydollar + 1, key, klen); memcpy(keydollar + 1 + klen, ")$", 2); *(keydollar + klen + 3) = 0; klen = klen + 3; if((pos = searchBufferRegex(string, 0, keydollar, slen, options, &klen)) != -1) { if(pos + klen == slen) { free(keydollar); return(trueCell); } } free(keydollar); } return(nilCell); }