bool CEditLanguageDialog::ExamLanguageText(const TString& strEnum, bool bCheckExist) { bool bRet = false; std::map<TString, std::map<ELanguageType, TString> >& languageMap = CLanguageManager::GetInstance()->GetLanguageMap(); if (strEnum.empty()) { wxMessageBox(_T("enum string Can't be empty!")); } else if (strEnum.find("eLTT_") != 0) { wxMessageBox(_T("enum string should begin with eLTT_")); } else if (!((wxString)strEnum).IsAscii()) { wxMessageBox(_T("enum string should be all ascii!")); } else if (strEnum.find(_T(' '), 0) != 0xFFFFFFFF) { wxMessageBox(_T("enum string can't contain space!")); } else if (bCheckExist && languageMap.find(strEnum) != languageMap.end()) { wxMessageBox(wxString::Format(_T("enum string %s already exists!"), strEnum.c_str())); } else { bRet = true; } return bRet; }
// // For now, keep it simple: if it starts "gl_", it's reserved, independent // of scope. Except, if the symbol table is at the built-in push-level, // which is when we are parsing built-ins. // Also checks for "webgl_" and "_webgl_" reserved identifiers if parsing a // webgl shader. // // Returns true if there was an error. // bool TParseContext::reservedErrorCheck(int line, const TString& identifier) { static const char* reservedErrMsg = "reserved built-in name"; if (!symbolTable.atBuiltInLevel()) { if (identifier.compare(0, 3, "gl_") == 0) { error(line, reservedErrMsg, "gl_", ""); return true; } if (shaderSpec == SH_WEBGL_SPEC) { if (identifier.compare(0, 6, "webgl_") == 0) { error(line, reservedErrMsg, "webgl_", ""); return true; } if (identifier.compare(0, 7, "_webgl_") == 0) { error(line, reservedErrMsg, "_webgl_", ""); return true; } } if (identifier.find("__") != TString::npos) { //error(line, "Two consecutive underscores are reserved for future use.", identifier.c_str(), "", ""); //return true; infoSink.info.message(EPrefixWarning, "Two consecutive underscores are reserved for future use.", line); return false; } } return false; }
// // For now, keep it simple: if it starts "gl_", it's reserved, independent // of scope. Except, if the symbol table is at the built-in push-level, // which is when we are parsing built-ins. // Also checks for "webgl_" and "_webgl_" reserved identifiers if parsing a // webgl shader. // // Returns true if there was an error. // bool TParseContext::reservedErrorCheck(int line, const TString& identifier) { static const char* reservedErrMsg = "reserved built-in name"; if (!symbolTable.atBuiltInLevel()) { if (identifier.compare(0, 3, "gl_") == 0) { error(line, reservedErrMsg, "gl_"); return true; } if (isWebGLBasedSpec(shaderSpec)) { if (identifier.compare(0, 6, "webgl_") == 0) { error(line, reservedErrMsg, "webgl_"); return true; } if (identifier.compare(0, 7, "_webgl_") == 0) { error(line, reservedErrMsg, "_webgl_"); return true; } if (shaderSpec == SH_CSS_SHADERS_SPEC && identifier.compare(0, 4, "css_") == 0) { error(line, reservedErrMsg, "css_"); return true; } } if (identifier.find("__") != TString::npos) { error(line, "identifiers containing two consecutive underscores (__) are reserved as possible future keywords", identifier.c_str()); return true; } } return false; }
void Replace(TString &s, const TString &search, const TString &replace, size_t num) { size_t repl_num = 0; for( size_t pos = 0; ; pos += replace.length() ) { if(repl_num>=num) break; // Locate the subTString to replace pos = s.find( search, pos ); if( pos == TString::npos ) break; // Replace by erasing and inserting s.erase( pos, search.length() ); s.insert( pos, replace ); repl_num+=1; } }
void Package::SetCommandLineArguments(int argc, TCHAR* argv[]) { if (argc > 0) { std::list<TString> args; // Prepare app arguments. Skip value at index 0 - this is path to executable. FBootFields->FCommandName = argv[0]; // Path to executable is at 0 index so start at index 1. for (int index = 1; index < argc; index++) { TString arg = argv[index]; #ifdef DEBUG if (arg == _T("-debug")) { FDebugging = dsNative; } if (arg == _T("-javadebug")) { FDebugging = dsJava; } #endif //DEBUG #ifdef MAC if (arg.find(_T("-psn_"), 0) != TString::npos) { Platform& platform = Platform::GetInstance(); if (platform.IsMainThread() == true) { #ifdef DEBUG printf("%s\n", arg.c_str()); #endif //DEBUG continue; } } if (arg == _T("-NSDocumentRevisionsDebugMode")) { // Ignore -NSDocumentRevisionsDebugMode and the following YES/NO index++; continue; } #endif //MAC args.push_back(arg); } if (args.size() > 0) { FBootFields->FArgs = args; } } }
static TString ProcessCommands(const _TCHAR *file) { FILE *fin; #ifdef UNICODE int err = _wfopen_s(&fin, file, L"r,ccs=unicode"); #else int err = fopen_s(&fin, file, "r"); #endif if (err) return TString(file); FILE *fout; auto output_file = TempFile::Create(TEXT(".txt"), true); #ifdef UNICODE err = _wfopen_s(&fout, output_file.data(), L"w,ccs=unicode"); #else err = fopen_s(&fout, output_file.data(), "w"); #endif if (err) { perror("LinkWrapper:ProcessCommands"); exit(err); } _TINT ch = _gettc(fin); while (ch != _TEOF) { while (ch != _TEOF && _istspace(ch)) { _puttc(ch, fout); ch = _gettc(fin); } // FIXME: input files with spaces in them??? (are they quoted???) TString word; while (ch != _TEOF && !_istspace(ch)) { word.push_back(ch); ch = _gettc(fin); } // FIXME: handle comments (starting with ';') auto comment_pos = word.find(TCHAR(';')); assert(comment_pos == -1 && "Found comment in command file"); if (!word.empty()) { auto new_word = ProcessArg(word.data()); _fputts(new_word.data(), fout); } } fclose(fin); fclose(fout); return output_file; }
// // For now, keep it simple: if it starts "gl_", it's reserved, independent // of scope. Except, if the symbol table is at the built-in push-level, // which is when we are parsing built-ins. // // Returns true if there was an error. // bool TParseContext::reservedErrorCheck(int line, const TString& identifier) { if (!symbolTable.atBuiltInLevel()) { if (identifier.substr(0, 3) == TString("gl_")) { error(line, "reserved built-in name", "gl_", ""); return true; } if (identifier.find("__") != TString::npos) { //error(line, "Two consecutive underscores are reserved for future use.", identifier.c_str(), "", ""); //return true; infoSink.info.message(EPrefixWarning, "Two consecutive underscores are reserved for future use.", line); return false; } } return false; }