// Открыть диалог с подтверждением параметров создания/закрытия/пересоздания консоли int CRecreateDlg::RecreateDlg(RConStartArgsEx* apArgs, bool abDontAutoSelCmd /*= false*/) { if (!this) { _ASSERTE(this); return IDCANCEL; } mb_DontAutoSelCmd = abDontAutoSelCmd; if (mh_Dlg && IsWindow(mh_Dlg)) { DisplayLastError(L"Close previous 'Create dialog' first, please!", -1); return IDCANCEL; } DontEnable de; gpConEmu->SkipOneAppsRelease(true); //if (!gpConEmu->mh_RecreatePasswFont) //{ // gpConEmu->mh_RecreatePasswFont = CreateFont( //} mn_DlgRc = IDCANCEL; mp_Args = apArgs; mh_Parent = (apArgs->aRecreate == cra_EditTab && ghOpWnd) ? ghOpWnd : ghWnd; #ifdef _DEBUG if ((mh_Parent == ghWnd) && gpConEmu->isIconic()) { _ASSERTE(FALSE && "Window must be shown before dialog!"); } #endif InitVars(); bool bPrev = gpConEmu->SetSkipOnFocus(true); CDpiForDialog::Create(mp_DpiAware); // Modal dialog (CreateDialog) int nRc = CDynDialog::ExecuteDialog(IDD_RESTART, mh_Parent, RecreateDlgProc, (LPARAM)this); UNREFERENCED_PARAMETER(nRc); gpConEmu->SetSkipOnFocus(bPrev); FreeVars(); //if (gpConEmu->mh_RecreatePasswFont) //{ // DeleteObject(gpConEmu->mh_RecreatePasswFont); // gpConEmu->mh_RecreatePasswFont = NULL; //} gpConEmu->SkipOneAppsRelease(false); return mn_DlgRc; }
/* ================== End ================== */ void ImageCutter::End() { if (mOk) { FreeVars (); mOk = false; } }
/* ************************* End ************************* */ void DebugApi::End() { if (mOk) { //mCout->close (); FreeVars (); mOk = false; } }
// Открыть диалог с подтверждением параметров создания/закрытия/пересоздания консоли int CRecreateDlg::RecreateDlg(RConStartArgs* apArgs) { if (!this) { _ASSERTE(this); return IDCANCEL; } if (mh_Dlg && IsWindow(mh_Dlg)) { DisplayLastError(L"Close previous 'Create dialog' first, please!", -1); return IDCANCEL; } DontEnable de; gpConEmu->SkipOneAppsRelease(true); //if (!gpConEmu->mh_RecreatePasswFont) //{ // gpConEmu->mh_RecreatePasswFont = CreateFont( //} mn_DlgRc = IDCANCEL; mp_Args = apArgs; mh_Parent = (apArgs->aRecreate == cra_EditTab && ghOpWnd) ? ghOpWnd : ghWnd; #ifdef _DEBUG if ((mh_Parent == ghWnd) && gpConEmu->isIconic()) { _ASSERTE(FALSE && "Window must be shown before dialog!"); } #endif InitVars(); bool bPrev = gpConEmu->SetSkipOnFocus(true); int nRc = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_RESTART), mh_Parent, RecreateDlgProc, (LPARAM)this); UNREFERENCED_PARAMETER(nRc); gpConEmu->SetSkipOnFocus(bPrev); FreeVars(); //if (gpConEmu->mh_RecreatePasswFont) //{ // DeleteObject(gpConEmu->mh_RecreatePasswFont); // gpConEmu->mh_RecreatePasswFont = NULL; //} gpConEmu->SkipOneAppsRelease(false); return mn_DlgRc; }
/*! \b Operation: This function frees the manager and all the objects that it contains. */ void IND_SurfaceManager::End() { if (mOk) { Debug->Header ("Finalizing SurfaceManager", 5); Debug->Header ("Freeing surfaces" , 5); FreeVars (); Debug->Header ("Surfaces freed", 6); Debug->Header ("IND_SurfaceManager finalized", 6); mOk = false; } }
/*! \b Operation: This function frees the manager and all the objects that it contains. */ void IND_FontManager::End() { if (mOk) { // If the object is loaded, we free it Debug->Header ("Finalizing FontManager", 5); Debug->Header ("Freeing fonts" , 5); FreeVars (); Debug->Header ("Fonts freed", 6); Debug->Header ("FontManager finalized", 6); mOk = false; } }
/*! \b Operation: This function frees the manager and all the objects that it contains. */ void IND_Entity3dManager::End() { if (mOk) { // Si este objeto ya había cargado una entidad 3d, lo liberamos Debug->Header ("Finalizing Entity3dManager", 5); Debug->Header ("Freeing 3d entities" , 5); FreeVars (); Debug->Header ("3d entities freed", 6); Debug->Header ("Entity3dManager finalized", 6); mOk = false; } }
bool texmgr::RunInitCode(int iSlot, char *szInitCode) { // warning: destroys contents of m_tex[iSlot].m_szExpr, // so be sure to call RunInitCode before writing or // compiling that string! FreeCode(iSlot); FreeVars(iSlot); RegisterBuiltInVariables(iSlot); strcpy(m_tex[iSlot].m_szExpr, szInitCode); bool ret = RecompileExpressions(iSlot); // set default values of output variables: // (by not setting these every frame, we allow the values to persist from frame-to-frame.) *(m_tex[iSlot].var_x) = 0.5; *(m_tex[iSlot].var_y) = 0.5; *(m_tex[iSlot].var_sx) = 1.0; *(m_tex[iSlot].var_sy) = 1.0; *(m_tex[iSlot].var_repeatx) = 1.0; *(m_tex[iSlot].var_repeaty) = 1.0; *(m_tex[iSlot].var_rot) = 0.0; *(m_tex[iSlot].var_flipx) = 0.0; *(m_tex[iSlot].var_flipy) = 0.0; *(m_tex[iSlot].var_r) = 1.0; *(m_tex[iSlot].var_g) = 1.0; *(m_tex[iSlot].var_b) = 1.0; *(m_tex[iSlot].var_a) = 1.0; *(m_tex[iSlot].var_blendmode)= 0.0; *(m_tex[iSlot].var_done) = 0.0; *(m_tex[iSlot].var_burn) = 1.0; #ifndef _NO_EXPR_ if (m_tex[iSlot].m_codehandle) NSEEL_code_execute(m_tex[iSlot].m_codehandle); #endif return ret; }
void CRecreateDlg::InitVars() { if (mpsz_DefCmd || mpsz_CurCmd || mpsz_SysCmd || mpsz_DefDir || !ms_RConStartDir.IsEmpty() || !ms_RConCurDir.IsEmpty()) { _ASSERTE(!(mpsz_DefCmd || mpsz_CurCmd || mpsz_SysCmd || mpsz_DefDir || !ms_RConStartDir.IsEmpty() || !ms_RConCurDir.IsEmpty())); FreeVars(); } CVConGuard VCon; CVirtualConsole* pVCon = (gpConEmu->GetActiveVCon(&VCon) >= 0) ? VCon.VCon() : NULL; CRealConsole* pRCon = pVCon ? pVCon->RCon() : NULL; if (pRCon) { ms_RConStartDir.Set(pRCon->GetStartupDir()); pRCon->GetConsoleCurDir(ms_RConCurDir); } // Если уже передана команда через параметры - из текущей консоли не извлекать if (!mp_Args || mp_Args->pszSpecialCmd) { _ASSERTE(mp_Args!=NULL); return; } // AutoStartTaskName - не возвращаем никогда. // Если он выбран при старте - то либо текущая консоль, либо первая команда из AutoStartTaskName, либо команда по умолчанию // Диалог может быть вызван в следующих случаях // * Recreate // * Свободный выбор = cra_EditTab (добавление новой команды в task или выбор шелла при обломе на старте) // * Ни одной консоли нет (предложить то что запускается при старте - Task, команда) // * Консоли есть (пусть наверное будет то что запускается при старте - Task, команда) wchar_t* pszBuf = NULL; _ASSERTE(pRCon || (mp_Args->aRecreate == cra_CreateTab || mp_Args->aRecreate == cra_EditTab)); LPCWSTR pszCmd = pRCon ? pRCon->GetCmd() : NULL; if (pszCmd && *pszCmd) mpsz_CurCmd = lstrdup(pszCmd); LPCWSTR pszSystem = gpSetCls->GetCmd(); if (pszSystem && *pszSystem && (lstrcmpi(pszSystem, AutoStartTaskName) != 0)) mpsz_SysCmd = lstrdup(pszSystem); bool bDirFromRCon = false; if (mp_Args->aRecreate == cra_RecreateTab) { // When recreate - always show active console command line _ASSERTE(pRCon); mpsz_DefCmd = lstrdup(pszCmd); bDirFromRCon = true; } else { // В диалоге запуска новой консоли - нечего делать автостартующему таску? if (lstrcmpi(pszSystem, AutoStartTaskName) == 0) { // Раз активной консоли нет - попробовать взять первую команду из AutoStartTaskName if (!pszCmd) { pszBuf = gpConEmu->LoadConsoleBatch(AutoStartTaskName); wchar_t* pszLine = wcschr(pszBuf, L'\n'); if (pszLine > pszBuf && *(pszLine-1) == L'\r') pszLine--; if (pszLine) *pszLine = 0; bool lbRunAdmin = (mp_Args->RunAsAdministrator == crb_On); pszCmd = gpConEmu->ParseScriptLineOptions(pszBuf, &lbRunAdmin, NULL); if (lbRunAdmin) mp_Args->RunAsAdministrator = crb_On; } else { bDirFromRCon = true; } } else if (pszSystem && *pszSystem) { pszCmd = pszSystem; } else { bDirFromRCon = true; } mpsz_DefCmd = lstrdup(pszCmd); //mpsz_DefDir = lstrdup(mp_Args->pszStartupDir ? mp_Args->pszStartupDir : L""); } if (bDirFromRCon) { TODO("May be try to retrieve current directory of the shell?"); mpsz_DefDir = lstrdup(ms_RConCurDir); } SafeFree(pszBuf); }
int FASTCALL CompileVarBody(U16 flags, S16 *brackCnt, VAR *var, int *_elementsSize, int braceCnt, int cast) { int elementsSize, len; S32 num; VAR *childvar; S16 braceCntStart; int elementsStart; elementsSize = *_elementsSize; if(!PRECOMPILING) { elementsStart = elementsSize; } if(comProc_LabelDeclaration(flags, brackCnt)) { // catch the labels if(braceCnt) { if(GetNextWord()[0]=='}') braceCnt--; } } else { if(var->cast == VARCAST_STRUCT) { braceCntStart = braceCnt; if(szTemp[0]!='{') { error(ERR_STRUCTELEMENTBRACE,szTemp); } else { GetNextWord(); braceCnt++; } childvar = FindFirstVariable(var->childVars); while(childvar) { braceCnt = CompileVarBody(flags|CF_VARCHILD,brackCnt, childvar, &elementsSize, braceCnt, childvar->cast); childvar = childvar->next; if(childvar && !braceCnt) return 0; } if(braceCntStart != braceCnt) { error(ERR_CLOSEBRACEEXP,var->label); } if(!PRECOMPILING) var=var; } else if(szTemp[0]=='{' && var->arraySize) { int arsize = var->arraySize; braceCntStart = braceCnt; GetNextWord(); braceCnt++; childvar = CloneVar(var, curVar, 0); childvar->arraySize = 0; do { braceCnt = CompileVarBody(flags|CF_VARCHILD,brackCnt, childvar, &elementsSize, braceCnt, childvar->cast); arsize--; } while(braceCnt && braceCnt > braceCntStart); FreeVars(&childvar); if(braceCntStart != braceCnt) { error(ERR_CLOSEBRACEEXP,var->label); } if(!PRECOMPILING && arsize < 0) { error(ERR_ARRAYTOOLARGE,var->label); } } else if(szTemp[0]=='"') { if(varcasts[cast].size!=VARSIZE_BYTE) error(ERR_STRINGNOTBYTE,var->label); if(!DoString()) return 0; if(!PRECOMPILING) { len = lenSzStr;//(U16)strlen(szString); if(var->arraySize && len > var->arraySize) { len = var->arraySize; szString[len?len-1:0] = '\0'; error(ERR_STRINGTOOLONG,szString); } BankWrite(szString,len); if(var->arraySize) { BankFill(0,var->arraySize-len); elementsSize += var->arraySize; } else { elementsSize += len; } } } else { CompileImmediateInteger(0, &num, -4, 0); if(!PRECOMPILING) { if(strToInt_LabelObject) { // do the fixup AddFixOffs( strToInt_LabelType, (var->flags&VARFLAG_16BIT)?FIXOFFS_WORD:FIXOFFS_BYTE, curBank->ptr, 0, strToInt_LabelObject ); } if(var->flags&VARFLAG_16BIT) { WriteCodeW(num); elementsSize += 2; } else { WriteCodeB(num); elementsSize ++; } } } if(braceCnt) { if(GetNextWord()[0]=='}') { braceCnt--; } else if(szTemp[0]!=',') { error(ERR_ARRAYCOMMAEXP,var->label); } else { if(GetNextWord()[0]=='}') { braceCnt--; } } } } if(!PRECOMPILING && (flags&CF_VARCHILD)) { int amount = (elementsSize-elementsStart); if(var->arraySize && amount < var->arraySize) { BankFill(0,var->arraySize-amount); elementsSize += var->arraySize-amount; } } *_elementsSize = elementsSize; return braceCnt; }
/* - exec - match regular expression ^ int exec(regex_t *, const chr *, size_t, rm_detail_t *, ^ size_t, regmatch_t [], int); */ int exec( regex_t *re, const chr *string, size_t len, rm_detail_t *details, size_t nmatch, regmatch_t pmatch[], int flags) { AllocVars(v); int st, backref; size_t n; size_t i; #define LOCALMAT 20 regmatch_t mat[LOCALMAT]; #define LOCALDFAS 40 struct dfa *subdfas[LOCALDFAS]; /* * Sanity checks. */ if (re == NULL || string == NULL || re->re_magic != REMAGIC) { FreeVars(v); return REG_INVARG; } if (re->re_csize != sizeof(chr)) { FreeVars(v); return REG_MIXED; } /* * Setup. */ v->re = re; v->g = (struct guts *)re->re_guts; if ((v->g->cflags®_EXPECT) && details == NULL) { FreeVars(v); return REG_INVARG; } if (v->g->info®_UIMPOSSIBLE) { FreeVars(v); return REG_NOMATCH; } backref = (v->g->info®_UBACKREF) ? 1 : 0; v->eflags = flags; if (v->g->cflags®_NOSUB) { nmatch = 0; /* override client */ } v->nmatch = nmatch; if (backref) { /* * Need work area. */ if (v->g->nsub + 1 <= LOCALMAT) { v->pmatch = mat; } else { v->pmatch = (regmatch_t *) MALLOC((v->g->nsub + 1) * sizeof(regmatch_t)); } if (v->pmatch == NULL) { FreeVars(v); return REG_ESPACE; } v->nmatch = v->g->nsub + 1; } else { v->pmatch = pmatch; } v->details = details; v->start = (chr *)string; v->stop = (chr *)string + len; v->err = 0; assert(v->g->ntree >= 0); n = (size_t) v->g->ntree; if (n <= LOCALDFAS) v->subdfas = subdfas; else v->subdfas = (struct dfa **) MALLOC(n * sizeof(struct dfa *)); if (v->subdfas == NULL) { if (v->pmatch != pmatch && v->pmatch != mat) FREE(v->pmatch); FreeVars(v); return REG_ESPACE; } for (i = 0; i < n; i++) v->subdfas[i] = NULL; /* * Do it. */ assert(v->g->tree != NULL); if (backref) { st = complicatedFind(v, &v->g->tree->cnfa, &v->g->cmap); } else { st = simpleFind(v, &v->g->tree->cnfa, &v->g->cmap); } /* * Copy (portion of) match vector over if necessary. */ if (st == REG_OKAY && v->pmatch != pmatch && nmatch > 0) { zapallsubs(pmatch, nmatch); n = (nmatch < v->nmatch) ? nmatch : v->nmatch; memcpy((void*)(pmatch), (void*)(v->pmatch), n*sizeof(regmatch_t)); } /* * Clean up. */ if (v->pmatch != pmatch && v->pmatch != mat) { FREE(v->pmatch); } n = (size_t) v->g->ntree; for (i = 0; i < n; i++) { if (v->subdfas[i] != NULL) freeDFA(v->subdfas[i]); } if (v->subdfas != subdfas) FREE(v->subdfas); FreeVars(v); return st; }
/* - exec - match regular expression ^ int exec(regex_t *, const chr *, size_t, rm_detail_t *, ^ size_t, regmatch_t [], int); */ int exec( regex_t *re, const chr *string, size_t len, rm_detail_t *details, size_t nmatch, regmatch_t pmatch[], int flags) { AllocVars(v); int st; size_t n; int backref; #define LOCALMAT 20 regmatch_t mat[LOCALMAT]; #define LOCALMEM 40 regoff_t mem[LOCALMEM]; /* * Sanity checks. */ if (re == NULL || string == NULL || re->re_magic != REMAGIC) { FreeVars(v); return REG_INVARG; } if (re->re_csize != sizeof(chr)) { FreeVars(v); return REG_MIXED; } /* * Setup. */ v->re = re; v->g = (struct guts *)re->re_guts; if ((v->g->cflags®_EXPECT) && details == NULL) { FreeVars(v); return REG_INVARG; } if (v->g->info®_UIMPOSSIBLE) { FreeVars(v); return REG_NOMATCH; } backref = (v->g->info®_UBACKREF) ? 1 : 0; v->eflags = flags; if (v->g->cflags®_NOSUB) { nmatch = 0; /* override client */ } v->nmatch = nmatch; if (backref) { /* * Need work area. */ if (v->g->nsub + 1 <= LOCALMAT) { v->pmatch = mat; } else { v->pmatch = (regmatch_t *) MALLOC((v->g->nsub + 1) * sizeof(regmatch_t)); } if (v->pmatch == NULL) { FreeVars(v); return REG_ESPACE; } v->nmatch = v->g->nsub + 1; } else { v->pmatch = pmatch; } v->details = details; v->start = (chr *)string; v->stop = (chr *)string + len; v->err = 0; if (backref) { /* * Need retry memory. */ assert(v->g->ntree >= 0); n = (size_t)v->g->ntree; if (n <= LOCALMEM) { v->mem = mem; } else { v->mem = (regoff_t *) MALLOC(n*sizeof(regoff_t)); } if (v->mem == NULL) { if (v->pmatch != pmatch && v->pmatch != mat) { FREE(v->pmatch); } FreeVars(v); return REG_ESPACE; } } else { v->mem = NULL; } /* * Do it. */ assert(v->g->tree != NULL); if (backref) { st = cfind(v, &v->g->tree->cnfa, &v->g->cmap); } else { st = find(v, &v->g->tree->cnfa, &v->g->cmap); } /* * Copy (portion of) match vector over if necessary. */ if (st == REG_OKAY && v->pmatch != pmatch && nmatch > 0) { zapsubs(pmatch, nmatch); n = (nmatch < v->nmatch) ? nmatch : v->nmatch; memcpy(VS(pmatch), VS(v->pmatch), n*sizeof(regmatch_t)); } /* * Clean up. */ if (v->pmatch != pmatch && v->pmatch != mat) { FREE(v->pmatch); } if (v->mem != NULL && v->mem != mem) { FREE(v->mem); } FreeVars(v); return st; }
// note new return type, this now returns the bad block number, else 0 for success. // // I also return -ve block numbers for errors between blocks. Eg if you read 3 good blocks, then find an unexpected // float in the script between blocks 3 & 4 then I return -3 to indicate the error is after that, but not block 4 // int CInterpreter::Interpret( CTokenizer *Tokenizer, CBlockStream *BlockStream, char *filename ) { CBlock block; CToken *token; int type, blockLevel = 0, parenthesisLevel = 0; m_sCurrentFile = filename; // used during error reporting because you can't ask tokenizer for pushed streams m_tokenizer = Tokenizer; m_blockStream = BlockStream; m_iCurrentLine = m_tokenizer->GetCurLine(); token = m_tokenizer->GetToEndOfLine(TK_STRING); m_sCurrentLine = token->GetStringValue(); m_tokenizer->PutBackToken(token, false, NULL, true); m_iBadCBlockNumber = 0; while (m_tokenizer->GetRemainingSize() > 0) { token = m_tokenizer->GetToken( TKF_USES_EOL, 0 ); type = token->GetType(); switch ( type ) { case TK_UNDEFINED: token->Delete(); m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("%d : undefined token", type); return m_iBadCBlockNumber; break; case TK_EOF: break; case TK_EOL: // read the next line, then put it back token->Delete(); m_iCurrentLine = m_tokenizer->GetCurLine(); token = m_tokenizer->GetToEndOfLine(TK_STRING); m_sCurrentLine = token->GetStringValue(); m_tokenizer->PutBackToken(token, false, NULL, true); break; case TK_CHAR: case TK_STRING: token->Delete(); m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : unexpected string"); return m_iBadCBlockNumber; break; case TK_INT: token->Delete(); m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : unexpected integer"); return m_iBadCBlockNumber; break; case TK_FLOAT: token->Delete(); m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : unexpected float"); return m_iBadCBlockNumber; break; case TK_IDENTIFIER: m_iBadCBlockNumber++; if (!GetID( (char *) token->GetStringValue() )) { token->Delete(); return m_iBadCBlockNumber; } token->Delete(); break; case TK_BLOCK_START: token->Delete(); if (parenthesisLevel) { m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : brace inside parenthesis"); return m_iBadCBlockNumber; } blockLevel++; break; case TK_BLOCK_END: token->Delete(); if (parenthesisLevel) { m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : brace inside parenthesis"); return m_iBadCBlockNumber; } block.Create( ID_BLOCK_END ); m_blockStream->WriteBlock( &block ); block.Free(); blockLevel--; break; case TK_OPEN_PARENTHESIS: token->Delete(); blockLevel++; parenthesisLevel++; break; case TK_CLOSED_PARENTHESIS: token->Delete(); blockLevel--; parenthesisLevel--; if (parenthesisLevel<0) { m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : closed parenthesis with no opening match"); return m_iBadCBlockNumber; } break; case TK_VECTOR_START: token->Delete(); m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : unexpected vector"); return m_iBadCBlockNumber; break; case TK_VECTOR_END: token->Delete(); m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : unexpected vector"); return m_iBadCBlockNumber; break; } } if ( blockLevel ) { m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("error : open brace was not closed"); return m_iBadCBlockNumber; } if ( parenthesisLevel ) { m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("error: open parenthesis"); return m_iBadCBlockNumber; } //Release all the variable information, because it's already been written out FreeVars(); m_iBadCBlockNumber = 0; return m_iBadCBlockNumber; //true; }