FileType *ConsoleTools::selectType(HRCParser *hrcParser, LineSource *lineSource){ FileType *type = null; if (typeDescription != null){ type = hrcParser->getFileType(typeDescription); if (type == null){ for(int idx = 0;; idx++){ type = hrcParser->enumerateFileTypes(idx); if (type == null) break; if (type->getDescription() != null && type->getDescription()->length() >= typeDescription->length() && DString(type->getDescription(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription)) break; if (type->getName()->length() >= typeDescription->length() && DString(type->getName(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription)) break; type = null; } } } if (typeDescription == null || type == null){ StringBuffer textStart; int totalLength = 0; for(int i = 0; i < 4; i++){ String *iLine = lineSource->getLine(i); if (iLine == null) break; textStart.append(iLine); textStart.append(DString("\n")); totalLength += iLine->length(); if (totalLength > 500) break; } type = hrcParser->chooseFileType(inputFileName, &textStart, 0); } return type; }
static void get_color_styles(const char ***names, const char ***descr) { ParserFactory *pf = MCEditColorer::pf; if (pf == null) { *names = null; *descr = null; return; } Vector<const char *> hrd_styles; int i = 0; while (true){ const String * hrd = pf->enumerateHRDInstances(DString("console"), i++); if (hrd == null) break; hrd_styles.addElement(hrd->getChars()); hrd_styles.addElement(pf->getHRDescription(DString("console"), *hrd)->getChars()); } const char **hrd_names = new const char*[hrd_styles.size()/2 + 1]; const char **hrd_descr = new const char*[hrd_styles.size()/2 + 1]; for (i = 0; i < hrd_styles.size()/2; i++) { hrd_names[i] = hrd_styles.elementAt(i*2); hrd_descr[i] = hrd_styles.elementAt(i*2+1); } hrd_names[i] = null; hrd_descr[i] = null; *names = hrd_names; *descr = hrd_descr; }
FileInputSource::FileInputSource(const String *basePath, FileInputSource *base){ bool prefix = true; if (basePath->startsWith(DString("file://"))){ baseLocation = new SString(basePath, 7, -1); }else if (basePath->startsWith(DString("file:/"))){ baseLocation = new SString(basePath, 6, -1); }else if (basePath->startsWith(DString("file:"))){ baseLocation = new SString(basePath, 5, -1); }else{ if (isRelative(basePath) && base != null) baseLocation = getAbsolutePath(base->getLocation(), basePath); else baseLocation = new SString(basePath); prefix = false; }; #if defined _WIN32 // replace the environment variables to their values size_t i=ExpandEnvironmentStrings(baseLocation->getTChars(),NULL,0); TCHAR *temp = new TCHAR[i]; ExpandEnvironmentStrings(baseLocation->getTChars(),temp,static_cast<DWORD>(i)); delete baseLocation; baseLocation = new SString(temp); delete[] temp; #endif if(prefix && (baseLocation->indexOf(':') == -1 || baseLocation->indexOf(':') > 10) && !baseLocation->startsWith(DString("/"))){ StringBuffer *n_baseLocation = new StringBuffer(); n_baseLocation->append(DString("/")).append(baseLocation); delete baseLocation; baseLocation = n_baseLocation; } stream = null; };
void FarHrcSettings::readXML(String* file, bool userValue) { xercesc::XercesDOMParser xml_parser; XmlParserErrorHandler error_handler(nullptr); xml_parser.setErrorHandler(&error_handler); xml_parser.setLoadExternalDTD(false); xml_parser.setSkipDTDValidation(true); XmlInputSource* config = XmlInputSource::newInstance(file->getWChars(), static_cast<XMLCh*>(nullptr)); xml_parser.parse(*config->getInputSource()); if (error_handler.getSawErrors()) { delete config; throw ParserFactoryException(DString("Error reading hrcsettings.xml.")); } xercesc::DOMDocument* catalog = xml_parser.getDocument(); xercesc::DOMElement* elem = catalog->getDocumentElement(); const XMLCh* tagPrototype = L"prototype"; const XMLCh* tagHrcSettings = L"hrc-settings"; if (elem == nullptr || !xercesc::XMLString::equals(elem->getNodeName(), tagHrcSettings)) { delete config; throw FarHrcSettingsException(DString("main '<hrc-settings>' block not found")); } for (xercesc::DOMNode* node = elem->getFirstChild(); node != nullptr; node = node->getNextSibling()) { if (node->getNodeType() == xercesc::DOMNode::ELEMENT_NODE) { xercesc::DOMElement* subelem = static_cast<xercesc::DOMElement*>(node); if (xercesc::XMLString::equals(subelem->getNodeName(), tagPrototype)) { UpdatePrototype(subelem, userValue); } } } delete config; }
String *DocumentBuilder::consumeEntityRef(bool useExtEnt){ consume("&", 1); StringBuffer *sb = new StringBuffer(10); while(peek() != ';'){ sb->append(get()); } get(); const String *ent = entitiesHash.get(sb); const String *extEnt = null; if (useExtEnt){ extEnt = extEntitiesHash.get(sb); }; delete sb; if (ent == null && extEnt == null){ throw ParseException(DString("Undefined Entity Reference")); } if (ent != null){ return new StringBuffer(ent); } if (extEnt != null){ if (er == null) return null; InputSource *is = er->resolveEntity(null, extEnt); const byte *bytes = is->openStream(); int length = is->length(); src_overflow = new SString(DString(bytes, length)); delete is; return null; } return null; }
FileType *ColorerFilter::selectType(HRCParser *hrcParser, String *fline) { FileType *type = null; if (typeDescription != null) { type = hrcParser->getFileType(typeDescription); if (type == null) { for(int idx = 0;; idx++) { type = hrcParser->enumerateFileTypes(idx); if (type == null) { break; } if (type->getDescription() != null && type->getDescription()->length() >= typeDescription->length() && DString(type->getDescription(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription)) { break; } if (type->getName()->length() >= typeDescription->length() && DString(type->getName(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription)) { break; } type = null; } } } if (typeDescription == null || type == null) { type = hrcParser->chooseFileType(inputFileName, fline, 0); } return type; }
void StyledHRDMapper::loadRegionMappings(InputSource *is) { DocumentBuilder docbuilder; Document *hrdbase = docbuilder.parse(is); Element *hbase = hrdbase->getDocumentElement(); if (*hbase->getNodeName() != "hrd"){ docbuilder.free(hrdbase); throw Exception(DString("Error loading HRD file")); }; for(Node *curel = hbase->getFirstChild(); curel; curel = curel->getNextSibling()){ if (curel->getNodeType() == Node::ELEMENT_NODE && *curel->getNodeName() == "assign"){ const String *name = ((Element*)curel)->getAttribute(DString("name")); if (name == null) continue; if (regionDefines.get(name) != null){ delete regionDefines.get(name); } int val = 0; bool bfore = UnicodeTools::getNumber(((Element*)curel)->getAttribute(DString("fore")), &val); int fore = val; bool bback = UnicodeTools::getNumber(((Element*)curel)->getAttribute(DString("back")), &val); int back = val; int style = 0; if (UnicodeTools::getNumber(((Element*)curel)->getAttribute(DString("style")), &val)){ style = val; } RegionDefine *rdef = new StyledRegion(bfore, bback, fore, back, style); regionDefines.put(name, rdef); }; }; docbuilder.free(hrdbase); };
int TextParserImpl::searchKW(const SchemeNode *node, int no, int lowlen, int hilen) { if (!node->kwList->num) return MATCH_NOTHING; if (node->kwList->minKeywordLength+gx > lowlen) return MATCH_NOTHING; if (gx < lowlen && !node->kwList->firstChar->inClass((*str)[gx])) return MATCH_NOTHING; int left = 0; int right = node->kwList->num; while(true){ int pos = left + (right-left)/2; int kwlen = node->kwList->kwList[pos].keyword->length(); if (lowlen < gx+kwlen) kwlen = lowlen-gx; int cr; if (node->kwList->matchCase) cr = node->kwList->kwList[pos].keyword->compareTo(DString(*str, gx, kwlen)); else cr = node->kwList->kwList[pos].keyword->compareToIgnoreCase(DString(*str, gx, kwlen)); if (cr == 0 && right-left == 1){ bool badbound = false; if (!node->kwList->kwList[pos].isSymbol){ if (!node->worddiv){ if (gx && (Character::isLetterOrDigit((*str)[gx-1]) || (*str)[gx-1] == '_')) badbound = true; if (gx + kwlen < lowlen && (Character::isLetterOrDigit((*str)[gx + kwlen]) || (*str)[gx + kwlen] == '_')) badbound = true; }else{ // custom check for word bound if (gx && !node->worddiv->inClass((*str)[gx-1])) badbound = true; if (gx + kwlen < lowlen && !node->worddiv->inClass((*str)[gx + kwlen])) badbound = true; }; }; if (!badbound){ CLR_TRACE("TextParserImpl", "KW matched. gx=%d, region=%s", gx, node->kwList->kwList[pos].region->getName()->getChars()); addRegion(gy, gx, gx + kwlen, node->kwList->kwList[pos].region); gx += kwlen; return MATCH_RE; }; }; if (right-left == 1){ left = node->kwList->kwList[pos].ssShorter; if (left != -1){ right = left+1; continue; }; break; }; if (cr == 1) right = pos; if (cr == 0 || cr == -1) left = pos; }; return MATCH_NOTHING; };
String *DocumentBuilder::consumeAttributeValue(){ wchar qc = get(); if (qc != '"' && qc != '\''){ throw ParseException(DString("Qoute character is required here")); } StringBuffer *sb = new StringBuffer(); while(true){ if (isCharRef()){ sb->append(consumeCharRef()); continue; } if (isEntityRef()){ String *entext = consumeEntityRef(false); if (entext){ sb->append(entext); delete entext; } continue; } wchar qc2 = peek(); if (qc2 == -1){ delete sb; } get(); if (qc2 == qc) return sb; sb->append(qc2); } }
void ConsoleTools::profile(int loopCount){ clock_t msecs; // parsers factory ParserFactory pf(catalogPath); // Source file text lines store. TextLinesStore textLinesStore; textLinesStore.loadFile(inputFileName, inputEncoding, true); // Base editor to make primary parse BaseEditor baseEditor(&pf, &textLinesStore); // HRD RegionMapper linking baseEditor.setRegionMapper(&DString("console"), hrdName); FileType *type = selectType(pf.getHRCParser(), &textLinesStore); type->getBaseScheme(); baseEditor.setFileType(type); msecs = clock(); while(loopCount--){ baseEditor.modifyLineEvent(0); baseEditor.lineCountEvent(textLinesStore.getLineCount()); baseEditor.validate(-1, false); } msecs = clock() - msecs; printf("%ld\n", (msecs*1000)/CLOCKS_PER_SEC ); }
extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved ) { switch( fdwReason ) { case DLL_PROCESS_ATTACH: { // obtain the path to the folder plugin, without being attached to the file name wchar_t path[MAX_PATH]; if (!GetModuleFileName(hinstDLL, path, MAX_PATH)){ return false; } DString module(path, 0); int pos = module.lastIndexOf('\\'); pos = module.lastIndexOf('\\',pos); PluginPath = new StringBuffer(DString(module, 0, pos)); } break; case DLL_PROCESS_DETACH: delete PluginPath; break; } return true; }
void SString::construct(const String *cstring, int s, int l){ if (s < 0 || s > cstring->length() || l < -1) throw Exception(DString("bad string constructor parameters")); if (l == -1) l = cstring->length()-s; wstr = new wchar[l]; for(len = 0; len < l; len++) wstr[len] = (*cstring)[s+len]; }
void ConsoleTools::viewFile(){ try{ // Source file text lines store. TextLinesStore textLinesStore; textLinesStore.loadFile(inputFileName, inputEncoding, true); // parsers factory ParserFactory pf(catalogPath); // Base editor to make primary parse BaseEditor baseEditor(&pf, &textLinesStore); // HRD RegionMapper linking baseEditor.setRegionMapper(&DString("console"), hrdName); FileType *type = selectType(pf.getHRCParser(), &textLinesStore); baseEditor.setFileType(type); // Initial line count notify baseEditor.lineCountEvent(textLinesStore.getLineCount()); int background; const StyledRegion *rd = StyledRegion::cast(baseEditor.rd_def_Text); if (rd != null && rd->bfore && rd->bback) background = rd->fore + (rd->back<<4); else background = 0x1F; // File viewing in console window TextConsoleViewer viewer(&baseEditor, &textLinesStore, background, outputEncodingIndex); viewer.view(); }catch(Exception &e){ fprintf(stderr, "%s\n", e.getMessage()->getChars()); }catch(...){ fprintf(stderr, "unknown exception ...\n"); } }
void ConsoleTools::listTypes(bool load, bool useNames){ Writer *writer = null; try{ writer = new StreamWriter(stdout, outputEncodingIndex, bomOutput); ParserFactory pf(catalogPath); HRCParser *hrcParser = pf.getHRCParser(); fprintf(stderr, "\nloading file types...\n"); for(int idx = 0;; idx++){ FileType *type = hrcParser->enumerateFileTypes(idx); if (type == null) break; if (useNames){ writer->write(StringBuffer(type->getName())+"\n"); }else{ if (type->getGroup() != null){ writer->write(StringBuffer(type->getGroup()) + ": "); } writer->write(type->getDescription()); writer->write(DString("\n")); } if (load) type->getBaseScheme(); } delete writer; }catch(Exception &e){ delete writer; fprintf(stderr, "%s\n", e.getMessage()->getChars()); } }
DString FileTools::extractFileExtension(const DString & in_strPath, char in_cDelimiter) { DString tmp_strFilename = extractFilename(in_strPath, in_cDelimiter); DString::size_type tmp_uiPos = tmp_strFilename.find_last_of('.'); if ( DString::npos != tmp_uiPos ) return tmp_strFilename.substr(tmp_uiPos); return DString(); }
void FarHrcSettings::readProfile() { StringBuffer* path = new StringBuffer(PluginPath); path->append(DString(FarProfileXml)); readXML(path, false); delete path; }
void FarHrcSettings::UpdatePrototype(xercesc::DOMElement* elem, bool userValue) { const XMLCh* tagProtoAttrParamName = L"name"; const XMLCh* tagParam = L"param"; const XMLCh* tagParamAttrParamName = L"name"; const XMLCh* tagParamAttrParamValue = L"value"; const XMLCh* tagParamAttrParamDescription = L"description"; const XMLCh* typeName = elem->getAttribute(tagProtoAttrParamName); if (typeName == nullptr) { return; } HRCParser* hrcParser = parserFactory->getHRCParser(); DString typenamed = DString(typeName); FileTypeImpl* type = static_cast<FileTypeImpl*>(hrcParser->getFileType(&typenamed)); if (type == nullptr) { return; } for (xercesc::DOMNode* node = elem->getFirstChild(); node != nullptr; node = node->getNextSibling()) { if (node->getNodeType() == xercesc::DOMNode::ELEMENT_NODE) { xercesc::DOMElement* subelem = static_cast<xercesc::DOMElement*>(node); if (xercesc::XMLString::equals(subelem->getNodeName(), tagParam)) { const XMLCh* name = subelem->getAttribute(tagParamAttrParamName); const XMLCh* value = subelem->getAttribute(tagParamAttrParamValue); const XMLCh* descr = subelem->getAttribute(tagParamAttrParamDescription); if (*name == '\0' || *value == '\0') { continue; } if (type->getParamValue(DString(name)) == nullptr) { type->addParam(new SString(DString(name))); } if (descr != nullptr) { type->setParamDescription(DString(name), new SString(DString(descr))); } if (userValue) { type->setParamValue(DString(name), new SString(DString(value))); } else { delete type->getParamDefaultValue(DString(name)); type->setParamDefaultValue(DString(name), new SString(DString(value))); } } } } }
int set_current_type (const char *type) { if (type == null) { baseEditor->chooseFileType(null); return true; } return baseEditor->setFileType(DString(type)) != null ? true : false; }
void DocumentBuilder::consumeSpaces(int mins){ while(Character::isWhitespace(peek())){ get(); mins--; } if (mins > 0){ throw ParseException(DString("Space is required")); } }
FarEditor::FarEditor(PluginStartupInfo *info, ParserFactory *pf) { parserFactory = pf; baseEditor = new BaseEditor(parserFactory, this); this->info = info; info->EditorControl(ECTL_GETINFO, &ei); oldFAR = info->StructSize < sizeof(PluginStartupInfo); cursorRegion = null; unicodeEncodingIndex = -1; farEncodingIndex = -3; prevLinePosition = 0; blockTopPosition = -1; inRedraw = false; inHandler = false; ignoreChange = false; idleCount = 0; ret_str = null; ret_strNumber = -1; maxLineLength = 0; fullBackground = true; showHorizontalCross = showVerticalCross = true; crossZOrder = 0; horzCrossColor = 0x0E; vertCrossColor = 0x0E; drawPairs = drawSyntax = true; oldOutline = false; maxTime = 3000; newback = newfore = -1; rdBackground = null; visibleLevel = 100; const Region *def_Outlined = pf->getHRCParser()->getRegion(&DString("def:Outlined")); const Region *def_Error = pf->getHRCParser()->getRegion(&DString("def:Error")); structOutliner = new Outliner(baseEditor, def_Outlined); errorOutliner = new Outliner(baseEditor, def_Error); }
wchar DocumentBuilder::consumeCharRef(){ if (!(peek(0) == '&' && peek(1) == '#')){ throw ParseException(DString("&# syntax of Character Reference is required")); }; consume("&#", 2); StringBuffer *sb = new StringBuffer("#"); while(peek() != ';'){ sb->append(get()); } get(); int c = -1; bool b = getXMLNumber(*sb, &c); delete sb; if (!b || c > 0xFFFF || c < 0){ throw ParseException(DString("Invalid Character Reference numeric value")); } return (wchar)c; }
void DocumentBuilder::consumeDocument(){ consumeXmlDecl(); consumeMisc(doc); consumeDTD(); consumeMisc(doc); consumeElement(doc); consumeMisc(doc); if (peek() != -1){ throw ParseException(DString("Extra markup after the root element")); } }
/* Searches previous elements num with same partial name fe: 3: getParameterName 0 2: getParameter 0 1: getParam 0 0: getPar -1 */ void KeywordList::substrIndex(){ for(int i = num-1; i > 0; i--) for(int ii = i-1; ii != 0; ii--){ if ((*kwList[ii].keyword)[0] != (*kwList[i].keyword)[0]) break; if (kwList[ii].keyword->length() < kwList[i].keyword->length() && DString(kwList[i].keyword, 0, kwList[ii].keyword->length()) == *kwList[ii].keyword){ kwList[i].ssShorter = ii; break; }; }; };
MCEditColorer(WEdit *edit) { try{ if (pf == null) { pf = new ParserFactory(); // cleanup color index map for (int idx = 0; idx < 16*16; idx++){ colorer_color_map[idx] = -1; } } this->edit = edit; colorer_store_handle(edit, this); lineSource = new MCLineSource(edit); baseEditor = new BaseEditor(pf, lineSource); baseEditor->chooseFileType(&DString(colorer_get_filename(edit))); /* Loading color style */ try { if (*colorer_hrd_string == 0) { strcpy(colorer_hrd_string, "default"); } baseEditor->setRegionMapper(&DString("console"), &DString(colorer_hrd_string)); } catch (Exception &e) { baseEditor->setRegionMapper(&DString("console"), &DString("default")); } baseEditor->setRegionCompact(true); const Region *def_Outlined = pf->getHRCParser()->getRegion(&DString("def:Outlined")); const Region *def_Error = pf->getHRCParser()->getRegion(&DString("def:Error")); structOutliner = new Outliner(baseEditor, def_Outlined); //errorOutliner = new Outliner(baseEditor, def_Error); CLR_TRACE("MC", "filename: %s", colorer_get_filename(edit)); CLR_TRACE("MC", "filetype: %s", baseEditor->getFileType()->getName()->getChars()); def_fore = StyledRegion::cast(baseEditor->rd_def_Text)->fore; def_back = StyledRegion::cast(baseEditor->rd_def_Text)->back; def_mc = colorer_convert_color(StyledRegion::cast(baseEditor->rd_def_Text)); // def_mc_bg= try_alloc_color_pair(null, win_colors[def_back]); CLR_TRACE("MC", "def_fore=%d, def_back=%d, def_mc=%d", def_fore, def_back, def_mc); CLR_TRACE("MC", "def_mc_bg=%d", def_mc_bg); pairMatch = null; } catch(Exception &e) { // TODO: notify about disabled colorer CLR_TRACE("MC", "Exception in MCEditColorer: %s", e.getMessage()->getChars()); option_syntax_colorer = 0; return; } }
void FarHrcSettings::readProfileFromRegistry() { HRCParser* hrcParser = parserFactory->getHRCParser(); SettingsControl ColorerSettings; size_t hrc_subkey; hrc_subkey = ColorerSettings.rGetSubKey(0, HrcSettings); FarSettingsEnum fse; fse.StructSize = sizeof(FarSettingsEnum); // enum all the sections in HrcSettings if (ColorerSettings.rEnum(hrc_subkey, &fse)) { for (size_t i = 0; i < fse.Count; i++) { if (fse.Items[i].Type == FST_SUBKEY) { //check whether we have such a scheme DString named = DString(fse.Items[i].Name); FileTypeImpl* type = static_cast<FileTypeImpl*>(hrcParser->getFileType(&named)); if (type) { // enum all params in the section size_t type_subkey; type_subkey = ColorerSettings.rGetSubKey(hrc_subkey, fse.Items[i].Name); FarSettingsEnum type_fse; type_fse.StructSize = sizeof(FarSettingsEnum); if (ColorerSettings.rEnum(type_subkey, &type_fse)) { for (size_t j = 0; j < type_fse.Count; j++) { if (type_fse.Items[j].Type == FST_STRING) { DString name_fse= DString(type_fse.Items[j].Name); if (type->getParamValue(name_fse) == nullptr) { type->addParam(&name_fse); } const wchar_t* p = ColorerSettings.Get(type_subkey, type_fse.Items[j].Name, static_cast<wchar_t*>(nullptr)); if (p) { type->setParamValue(DString(type_fse.Items[j].Name), &DString(p)); } } } } } } } } }
void ConsoleTools::RETest(){ SMatches match; CRegExp *re; bool res; char text[255]; re = new CRegExp(); do{ printf("\nregexp:"); gets(text); if (!re->setRE(&DString(text))) continue; printf("exprn:"); gets(text); res = re->parse(&DString(text), &match); printf("%s\nmatch: ",res?"ok":"error"); for(int i = 0; i < match.cMatch; i++){ printf("%d:(%d,%d), ",i,match.s[i],match.e[i]); } }while(text[0]); delete re; }
void BaseEditor::remapLRS(bool recreate){ if (recreate || lrSupport == null){ delete lrSupport; if (regionCompact){ lrSupport = new LineRegionsCompactSupport(); }else{ lrSupport = new LineRegionsSupport(); } lrSupport->resize(lrSize); lrSupport->clear(); }; lrSupport->setRegionMapper(regionMapper); lrSupport->setSpecialRegion(def_Special); invalidLine = 0; rd_def_Text = rd_def_HorzCross = rd_def_VertCross = null; if (regionMapper != null){ rd_def_Text = regionMapper->getRegionDefine(DString("def:Text")); rd_def_HorzCross = regionMapper->getRegionDefine(DString("def:HorzCross")); rd_def_VertCross = regionMapper->getRegionDefine(DString("def:VertCross")); }; }
EError CRegExp::setRELow(const String &expr) { int len = expr.length(); if (!len) return EERROR; if (tree_root) delete tree_root; tree_root = null; #ifndef NAMED_MATCHES_IN_HASH for(int bp = 0; bp < cnMatch; bp++) if(brnames[bp]) delete brnames[bp]; #endif cMatch = 0; #ifndef NAMED_MATCHES_IN_HASH cnMatch = 0; #endif endChange = startChange = false; int start = 0; while (Character::isWhitespace(expr[start])) start++; if (expr[start] == '/') start++; else return ESYNTAX; bool ok = false; ignoreCase = extend = singleLine = multiLine = false; for (int i = len-1; i >= start && !ok; i--) if (expr[i] == '/'){ for (int j = i+1; j < len; j++){ if (expr[j] == 'i') ignoreCase = true; if (expr[j] == 'x') extend = true; if (expr[j] == 's') singleLine = true; if (expr[j] == 'm') multiLine = true; }; len = i-start; ok = true; }; if (!ok) return ESYNTAX; // making tree structure tree_root = new SRegInfo; tree_root->op = ReBrackets; tree_root->un.param = new SRegInfo; tree_root->un.param->parent = tree_root; tree_root->param0 = cMatch++; int endPos; EError err = setStructs(tree_root->un.param, DString(&expr, start, len), endPos); if (endPos != len) err = EBRACKETS; if (err) return err; optimize(); return EOK; };
FileType *BaseEditor::chooseFileType(const String *fileName) { if (lineSource == null) { currentFileType = hrcParser->chooseFileType(fileName, null); } else { int chooseStr=CHOOSE_STR, chooseLen=CHOOSE_LEN; DString dsd("default"); FileType *def = hrcParser->getFileType(&dsd); if(def) { chooseStr = def->getParamValueInt(DString("firstlines"), chooseStr); chooseLen = def->getParamValueInt(DString("firstlinebytes"), chooseLen); } currentFileType = chooseFileTypeCh(fileName, chooseStr, chooseLen); } setFileType(currentFileType); return currentFileType; }
FileInputSource::FileInputSource(const String *basePath, FileInputSource *base){ bool prefix = true; if (basePath->startsWith(DString("file://"))){ baseLocation = new SString(basePath, 7, -1); }else if (basePath->startsWith(DString("file:/"))){ baseLocation = new SString(basePath, 6, -1); }else if (basePath->startsWith(DString("file:"))){ baseLocation = new SString(basePath, 5, -1); }else{ if (isRelative(basePath) && base != null) baseLocation = getAbsolutePath(base->getLocation(), basePath); else baseLocation = new SString(basePath); prefix = false; }; if(prefix && (baseLocation->indexOf(':') == -1 || baseLocation->indexOf(':') > 10) && !baseLocation->startsWith(DString("/"))){ StringBuffer *n_baseLocation = new StringBuffer(); n_baseLocation->append(DString("/")).append(baseLocation); delete baseLocation; baseLocation = n_baseLocation; } stream = null; };