コード例 #1
0
		T popOrSleep() {
			std::unique_lock<std::mutex> lock(m_mutex);
			while(m_container.empty()) m_empty.wait(lock);
			T res = Pop(m_container, 0);
			return res;
		}
コード例 #2
0
ファイル: GtkDrawOp.cpp プロジェクト: AbdelghaniDr/mirror
void SystemDraw::EndOp()
{
	FlushText();
	Pop();
}
コード例 #3
0
ファイル: final3.cpp プロジェクト: tiagorg/unifei-cco210
void CompactaArquivo(ARVORE *Raiz)
{
   // Definição de variáveis
   FILE *P1, *P2;
   DADOS Info;
   ARVORE *q, *p;
	PILHA PilhaA;
	int VLogico, valor = 0;

	// Inicialização das variáveis
	q = Raiz;
	VLogico = 1;
	PilhaA.Topo = 0;

   P1 = fopen("AGENDA.DAT", "rb");
	if (P1 == NULL)
		return;

	P2 = fopen("NOVO.DAT", "wb+");
	if (P2 == NULL)
   {
		fclose(P1);
      return;
   }

   while (VLogico == 1)
   {
      // Varrendo a SubArvore a Esquerda
      while(q != NULL)
      {
         p = q;
			fseek(P1, p->EnderecoRegistro, 0);
			fread(&Info, sizeof(DADOS), 1, P1);
         fwrite(&Info, sizeof(DADOS), 1, P2);
         p->EnderecoRegistro = valor * sizeof(DADOS);
         valor++;
         Push(&PilhaA, p);
         q = p->LL;
      }
      q = Pop(&PilhaA);

      if ((PilhaA.Topo == 0) && (q->RL == NULL)) VLogico = 0;
      q = q->RL;
   }

//   SalvaArvore(Raiz);
   fclose(P1);
   fclose(P2);

   // Remove o arquivo original, com lixo
   if (remove("AGENDA.DAT") != 0) {
   	printf("\n\tNao foi possivel remover o arquivo AGENDA.DAT.\n");
      getch();
      return;
   }

   // Transforma o arquivo Novo.dat, no arquivo original
   if (rename("NOVO.DAT", "AGENDA.DAT") != 0) {
		printf("\n\tNao foi possivel renomear o arquivo NOVO.DAT.\n");
      getch();
      return;
   }
} // Fim de CompactaArquivo
コード例 #4
0
ファイル: xbexpfnc.cpp プロジェクト: utech/UtechLib
/*!
  \param Func
*/
xbShort xbExpn::ProcessFunction( char * Func )
{
/* 1 - pop function from stack
   2 - verify function name and get no of parms needed 
   3 - verify no of parms >= remainder of stack
   4 - pop parms off stack
   5 - execute function
   6 - push result back on stack
*/


  char   *buf = 0;
  xbExpNode *p1, *p2, *p3, *WorkNode, *FuncNode;
  xbShort  ParmsNeeded,len;
  char   ptype = 0;  /* process type s=string, l=logical, d=double */
  xbDouble DoubResult = 0;
  xbLong   IntResult = 0;
  FuncNode = (xbExpNode *) Pop();

  ParmsNeeded = GetFuncInfo( Func, 1 );

  if( ParmsNeeded == -1 ) {
    return XB_INVALID_FUNCTION;
  }
  else {
    ParmsNeeded = 0;
    if( FuncNode->Sibling1 ) ParmsNeeded++;
    if( FuncNode->Sibling2 ) ParmsNeeded++;
    if( FuncNode->Sibling3 ) ParmsNeeded++;
  }

  if( ParmsNeeded > GetStackDepth())
    return XB_INSUFFICIENT_PARMS;

  p1 = p2 = p3 = NULL;
  if( ParmsNeeded > 2 ) p3 = (xbExpNode *) Pop(); 
  if( ParmsNeeded > 1 ) p2 = (xbExpNode *) Pop(); 
  if( ParmsNeeded > 0 ) p1 = (xbExpNode *) Pop(); 
  memset( WorkBuf, 0x00, WorkBufMaxLen+1);

  if( strncmp( Func, "ABS", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = ABS( GetDoub( p1 ));
  }
  else if( strncmp( Func, "ASC", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = ASC( p1->StringResult );
  }
  else if( strncmp( Func, "AT", 2 ) == 0 ) {  
    ptype = 'd';
    DoubResult = AT( p1->StringResult, p2->StringResult );
  }
  else if( strncmp( Func, "CDOW", 4 ) == 0 ) {  
    ptype = 's';
    buf = CDOW( p1->StringResult );
  }
  else if( strncmp( Func, "CHR", 3 ) == 0 ) {  
    ptype = 's';
    buf = CHR( GetInt( p1 ));
  }
  else if( strncmp( Func, "CMONTH", 6 ) == 0 ) {  
    ptype = 's';
    buf = CMONTH( p1->StringResult );
  }
  else if( strncmp( Func, "CTOD", 4 ) == 0 ) {  
    ptype = 's';
    buf = CTOD( p1->StringResult );
  }
  else if( strncmp( Func, "DATE", 4 ) == 0 ) {  
    ptype = 's';
    buf = DATE();
  }
  else if( strncmp( Func, "DAY", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = DAY( p1->StringResult );
  }
  else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'C' ) {  
    ptype = 's';
    buf = DESCEND( p1->StringResult.c_str() );
  }
  else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'N' ) {  
    ptype = 'd';
    DoubResult = DESCEND( GetDoub( p1 ));
  }
  else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'D' ) {  
    xbDate d( p1->StringResult );
    ptype = 'd';
    DoubResult = DESCEND( d );
  }
  else if( strncmp( Func, "DOW", 3 ) == 0 ) {
    ptype = 'd';
    DoubResult = DOW( p1->StringResult );
  }
  else if( strncmp( Func, "DTOC", 4 ) == 0 ) {  
    ptype = 's';
    buf = DTOC( p1->StringResult );
  }
  else if( strncmp( Func, "DTOS", 4 ) == 0 ) {  
    ptype = 's';
    buf = DTOS( p1->StringResult );
  }
  else if( strncmp( Func, "EXP", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = EXP( GetDoub( p1 ));
  }
  else if( strncmp( Func, "IIF", 3 ) == 0 ){
    ptype = 's';
    buf = IIF( p1->IntResult, p2->StringResult, p3->StringResult );
  }
  else if( strncmp( Func, "INT", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = INT( GetDoub( p1 ));
  }
  else if( strncmp( Func, "ISALPHA", 7 ) == 0 ) {  
    ptype = 'l';
    IntResult = ISALPHA( p1->StringResult );
  }
  else if( strncmp( Func, "ISLOWER", 7 ) == 0 ) {  
    ptype = 'l';
    IntResult = ISLOWER( p1->StringResult );
  }
  else if( strncmp( Func, "ISUPPER", 7 ) == 0 ) {  
    ptype = 'l';
    IntResult = ISUPPER( p1->StringResult );
  }
  else if( strncmp( Func, "LEN", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = LEN( p1->StringResult );
  }
  else if( strncmp( Func, "LEFT", 4 ) == 0 ) {  
    ptype = 's';
    buf = LEFT( p1->StringResult, INT( p2->DoubResult ));
  }
  else if( strncmp( Func, "LTRIM", 5 ) == 0 ) {  
    ptype = 's';
    buf = LTRIM( p1->StringResult );
  }  
  else if( strncmp( Func, "LOG", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = LOG( GetDoub( p1 ));
  }  
  else if( strncmp( Func, "LOWER", 5 ) == 0 ) {  
    ptype = 's';
    buf = LOWER( p1->StringResult );
  }  
  else if( strncmp( Func, "MAX", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = MAX( GetDoub( p1 ), GetDoub( p2 ));
  }  
  else if( strncmp( Func, "MIN", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = MIN( GetDoub( p1 ), GetDoub( p2 ));
  }  
  else if( strncmp( Func, "MONTH", 5 ) == 0 ) {  
    ptype = 'd';
    DoubResult = MONTH( p1->StringResult );
  } 

  else if( strncmp( Func, "RECNO", 5 ) == 0 )
  {
    ptype = 'd';
    DoubResult = RECNO( FuncNode->dbf );
  }

  else if( strncmp( Func, "REPLICATE", 9 ) == 0 ) {
    ptype = 's';
    buf = REPLICATE( p1->StringResult, GetInt( p2 ));
  }
  else if( strncmp( Func, "RIGHT", 5 ) == 0 ) {
    ptype = 's';
    buf = RIGHT( p1->StringResult, GetInt( p2 ));
  }
  else if( strncmp( Func, "RTRIM", 5 ) == 0 ) {  
    ptype = 's';
    buf = RTRIM( p1->StringResult );
  }  
  else if( strncmp( Func, "SPACE", 5 ) == 0 ) {  
    ptype = 's';
    buf = SPACE( INT( GetDoub( p1 )));
  }
  else if( strncmp( Func, "SQRT", 4 ) == 0 ) {  
    ptype = 'd';
    DoubResult = SQRT( GetDoub( p1 ));
  }
  else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 1 ) {
    ptype = 's';
    buf = STRZERO( p1->StringResult );
  }   
  else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 2 ) {
    ptype = 's';
    buf = STRZERO( p1->StringResult, GetInt( p2 ));
  }   
  else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 3 ) {
    ptype = 's';
    buf = STRZERO( p1->StringResult, GetInt( p2 ), GetInt( p3 ));
  }   

  else if( strncmp( Func, "STR", 3 ) == 0 && p3 ) {
    ptype = 's';
    if(p1->ExpressionType == 'N')
      buf = STR( p1->DoubResult, GetInt( p2 ), GetInt( p3 ));
    else
      buf = STR( p1->StringResult, GetInt( p2 ), GetInt( p3 ));
  }   

  else if( strncmp( Func, "STR", 3 ) == 0 && p2 ) {
    ptype = 's';
    buf = STR( p1->StringResult, GetInt( p2 ));
  }

  else if( strncmp( Func, "STR", 3 ) == 0 && p1 ) {
    ptype = 's';
    buf = STR( p1->StringResult );
  }
   
  else if( strncmp( Func, "SUBSTR", 6 ) == 0 ) {
    ptype = 's';
    buf = SUBSTR( p1->StringResult, GetInt( p2 ), GetInt( p3 )); 
  }
  else if( strncmp( Func, "TRIM", 4 ) == 0 ) {  
    ptype = 's';
    buf = TRIM( p1->StringResult );
  }  
  else if( strncmp( Func, "UPPER", 5 ) == 0 ) {  
    ptype = 's';
    buf = UPPER( p1->StringResult );
  }  
  else if( strncmp( Func, "VAL", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = VAL( p1->StringResult );
  }  
  else if( strncmp( Func, "YEAR", 4 ) == 0 ) {  
    ptype = 'd';
    DoubResult = YEAR( p1->StringResult );
  }  
  if( p1 && !p1->InTree ) delete p1;
  if( p2 && !p2->InTree ) delete p2;
  if( p3 && !p3->InTree ) delete p3;
  if( !FuncNode->InTree ) delete FuncNode;
  if( buf ){
    len = strlen( buf );
    WorkNode = new xbExpNode;
    if( !WorkNode )
      return XB_NO_MEMORY;
    WorkNode->ResultLen = len + 1;
    
  } else {    
    len = 0;
    WorkNode = new xbExpNode;
    if( !WorkNode )
      return XB_NO_MEMORY;
    WorkNode->ResultLen = 0;
  }

  switch( ptype ){
   case 's':                               /* string or char result */
    WorkNode->DataLen = len;
    WorkNode->ExpressionType = 'C';
    WorkNode->Type = 's';
    WorkNode->StringResult = buf;
    break;
   case 'd':                               /* numeric result */
    WorkNode->DataLen = 0;
    WorkNode->ExpressionType = 'N';
    WorkNode->Type = 'd';
    WorkNode->DoubResult = DoubResult;
    break;
   case 'l':                               /* logical result */
    WorkNode->DataLen = 0;
    WorkNode->ExpressionType = 'L';
    WorkNode->Type = 'l';
    WorkNode->IntResult = IntResult;
    break;
   default:
    std::cout << "\nInternal error. " << ptype;
    break;
  }
  Push(WorkNode);
  return XB_NO_ERROR;
}
コード例 #5
0
ファイル: Configurable.cpp プロジェクト: simpla-fusion/SimPla
Configurable::Configurable(Configurable const &other) : Configurable() {
    m_db_->Set(other.m_db_);
    Push();Pop();
}
コード例 #6
0
ファイル: Main.c プロジェクト: QingDengKuZhu/LinkStack
int main(void)
{
	int select;		/*保存选择变量*/
	Elem e;			/*保存从函数返回的结点的值*/
	Elem v;			/*保存传递给函数的结点的值*/
	
	size_t i= 0;
	LINKSTACK S;
	InitStack(&S);	/*初始化栈*/

	srand((int)time(NULL));

	while (1)	/*while_@1*/
	{
		if (!(S.pBottom))
		{
			printf("栈不存在!\n");
			break;
		}

		system("cls");
		Menu();

		printf("请输入您的选择(1~9):");
		scanf("%d", &select);
		getchar();

		switch (select)	/*switch_@1*/
		{
		case 1:			/*入栈.*/
			v = InputValue("入栈元素为:");
			Push(&S, v);
			printf("入栈操作成功!\n");
			
			getchar();
			break;
		case 2:			/*输出栈中元素.*/
			printf("栈为:");
			TraveStack(&S);
			
			getchar();
			break;
		case 3:			/*出栈.*/
			if (OK == Pop(&S, &e))
			{
				printf("出栈成功,出栈元素是%d!\n", e);
			}
			else
			{
				printf("出栈失败!\n");
			}

			getchar();
			break;

		case 4:			/*输出栈的长度.*/
			printf("栈长为: %d \n", StackLength(&S));
			
			getchar();
			break;

		case 5:			/*清空栈.*/
			ClearStack(&S);
			printf("该栈已经清空!\n");
			
			getchar();
			break;
	
		case 6:			/*销毁栈.*/
			DestroyStack(&S);
			printf("栈已删除!\n");
			
			getchar();	
			break;
			
		case 7:			/*返回栈顶结点元素.*/
			if (OK == GetTop(&S, &e))
			{
				printf("栈顶为:%d\n", e);
			}
			else
			{
				printf("不存在栈顶元素!\n");
			}

			getchar();	
			break;

		case 8:			/*判断栈是否为空.*/
			if (StackEmpty(&S) == TRUE)
			{
				printf("栈为空!\n");
			}
			else
			{
				printf("栈非空!\n");
			}

			getchar();	
			break;

		case 9:			/*进制转换*/
			{
				int d;
				unsigned int m, n;
				v = InputValue("请输入一个非负整数:");
				d = InputValue("请输入转换进制:");
				if (v < 0 ||d<2 ||d>16)
				{
					printf("输入数据错误!\n");
					break;
				}
				
				m = (unsigned int)v;
				n = (unsigned int)d;
				Conversion_ten_to_n(m, n);
			
				getchar();
				break;
			}

		default:
			printf("请重新选择!\n");
			
			getchar();
			break;
		}/*switch_@1*/

	}	/*while_@1*/
	
	return EXIT_SUCCESS;
}
コード例 #7
0
nsCParserNode* nsDTDContext::Pop() {
  nsEntryStack   *theTempStyleStack=0; // This has no use here...
  return Pop(theTempStyleStack);
}
コード例 #8
0
ファイル: OpcodeMop0xx.cpp プロジェクト: yokwe/mesa-emulator
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// 073  ASSIGN_MOP(z, SGB)
__attribute__((always_inline)) static inline void E_SG_(CARD16 arg) {
	if (DEBUG_TRACE_OPCODE) logger.debug("TRACE %6o  SG %3d", savedPC, arg);
	CARD16 *p = Store(GF + arg);
	// NO PAGE FAULT AFTER HERE
	*p = Pop();
}
コード例 #9
0
void ApuAE()
{
   // POP A
   Pop(IAPU.YA.B.A);
   IAPU.PC++;
}
コード例 #10
0
ファイル: MathParser.cpp プロジェクト: darwinbeing/trade
void CMathParser::Reduce(WORD  Reduction)//{ Completes a reduction }
{
	TokenRec Token1, Token2;

	switch(Reduction)
	{
	case 1 : 
	  {
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  CurrToken.Value = Token1.Value + Token2.Value;
	  break;
	  }//  end;
	case 2 : {//begin
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  CurrToken.Value = Token2.Value - Token1.Value;
	  break;
	}//    end;
	case 4 :// begin
	{
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  CurrToken.Value = Token1.Value * Token2.Value;
	  break;
	}//    end;
	case 5 : //begin
	{
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  if (fabs(Token1.Value) < 0.000001 )
		ErrorCode = MP_ErrMath;
	  else
		CurrToken.Value = Token2.Value / Token1.Value;
	  break;
	}//    end;

	//{ MOD operator }
	case 100 : //begin
	{
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  if (fabs(Token1.Value) < 0.000001)
		ErrorCode = MP_ErrMath;
	  else
		CurrToken.Value = Round(Token2.Value) % Round(Token1.Value);
	  break;
	}//end;

	case 7 :
	{
	  Pop(Token1);
	  Pop(Token2);
	  Pop(Token2);
	  if (Token2.Value < 0.0)
		ErrorCode = MP_ErrMath;
	  else if ((Token1.Value * log(Token2.Value) < -MP_ExpLimit) ||
			  (Token1.Value * log(Token2.Value) > MP_ExpLimit)) 
		ErrorCode = MP_ErrMath;
	  else
		CurrToken.Value = exp(Token1.Value * log(Token2.Value));
	  break;
	}//end;
	case 9 : 
	{//begin
	  Pop(Token1);
	  Pop(Token2);
	  CurrToken.Value = -Token1.Value;
	  break;
	}//end;
	case 11 : break;//raise Exception.Create('Invalid reduction'); break;
	case 13 : break;//raise Exception.Create('Invalid reduction'); break;
	case 14 : 
	{//begin
	  Pop(Token1);
	  Pop(CurrToken);
	  Pop(Token1);
	  break;
	}//end;

	case 16 : 
	{//begin
		Pop(Token1);
		Pop(CurrToken);
		Pop(Token1);
		Pop(Token1);
		if( Token1.FuncName == "ABS")
		CurrToken.Value = fabs(CurrToken.Value);
		else if (Token1.FuncName == "ATAN")
		CurrToken.Value = atan(CurrToken.Value);
		else if (Token1.FuncName == "COS")
		{//      begin
		 if ((CurrToken.Value < -9E18) || (CurrToken.Value > 9E18))
			ErrorCode = MP_ErrMath;
		 else
			CurrToken.Value = cos(CurrToken.Value);
		}//end {...if Token1.FuncName = 'SIN' }
		else if (Token1.FuncName == "EXP")
		{//      begin
		if ((CurrToken.Value < -MP_ExpLimit) || (CurrToken.Value > MP_ExpLimit))// then
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = exp(CurrToken.Value);
		}//end
		else if (Token1.FuncName == "LN")// then
		{//      begin
		if (CurrToken.Value <= 0)
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = log(CurrToken.Value);
		}//end
		else if (Token1.FuncName == "ROUND")
		{//     begin
		if ((CurrToken.Value < -1E9) || (CurrToken.Value > 1E9))
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = Round(CurrToken.Value);
		}//end
		else if (Token1.FuncName == "SIN")
		{//      begin
		 if( (CurrToken.Value < -9E18) || (CurrToken.Value > 9E18))
			ErrorCode = MP_ErrMath;
		 else
			CurrToken.Value = sin(CurrToken.Value);
		 }//end {...if Token1.FuncName = 'SIN' }
		else if (Token1.FuncName == "SQRT")
		{//begin
		if( CurrToken.Value < 0 )//then
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = sqrt(CurrToken.Value);
		}//end
		else if (Token1.FuncName == "SQR")
		{//begin
		if ((CurrToken.Value < -MP_SQRLIMIT) || (CurrToken.Value > MP_SQRLIMIT))// then
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = sqrt(CurrToken.Value);
		}//end
		else if (Token1.FuncName == "TRUNC")
		{//begin
		if ((CurrToken.Value < -1E9) || (CurrToken.Value > 1E9))
		  ErrorCode = MP_ErrMath;
		else
		  CurrToken.Value = (int)(CurrToken.Value);//Trunc
		}
		else if(Token1.FuncName == "NOT")//end;//EXPAND
		{
		if (CurrToken.Value < 0.001 && CurrToken.Value > -0.001)
			CurrToken.Value = 1.0;
		else 
			CurrToken.Value = 0.0;
		}
		else if(Token1.FuncName == "BOOL")//end;//EXPAND
		{
		if (CurrToken.Value < 0.001 && CurrToken.Value > -0.001)
			CurrToken.Value = 0.0;
		else 
			CurrToken.Value = 1.0;
		}
		else if(Token1.FuncName == "SGN")//end;//EXPAND
		{
		if (CurrToken.Value > 0.0)
			CurrToken.Value = 1.0;
		else 
			CurrToken.Value = 0;
		}
		break;
	}//end;
	case 3:
	case 6:
	case 8:
	case 10:
	case 12:
	case 15 : Pop(CurrToken); break;
	}//  end; { case }

	CurrToken.State = GotoState(Reduction);
	Push(CurrToken);
}
コード例 #11
0
ファイル: main.c プロジェクト: Miveth/-MIA-201114726
void escribir(){
if(orden == 1){

    if(oblint(disk.sise)==0 || oblichar(disk.name)==0 || oblichar(disk.path)==0){
    printf("PARAMETRO CHAR OBLIGATORIO VACIO \n");

    return;
    }
  //  printf("/n este es el unit ahora /n %s",disk.unit);
    if(oblichar(disk.unit)==0){
//disk.unit = "m";
  //  printf("UNIT ES OPCIONAL SE PROPORCIONARA EL VALOR M \n");
    strcpy(disk.unit,"m");
    texto.valuni = 1000000;
    }else{
    texto.valuni = evaluarunidad(disk.unit);
        if((texto.valuni)==0){
        return;
        }
    }

    printf(texto.tex);
//printf("HOLA JAI %d \n",texto.valuni);

//    disk.path = sincomas;

    buscpath();
    strcpy(rdisk.path,sincomas);
  //  scad(disk.path);
    carpeta(sincomas);
    strcpy(disk.path,sincomas);
    sincomas = "";
    scad(disk.name);
    strcpy(disk.name,sincomas);
    sincomas = "";
    crearchivo(disk.path,disk.name,disk.sise,texto.valuni);

}else if(orden == 2){

    buscpath();
    strcpy(rdisk.path,sincomas);
    if(oblichar(rdisk.path)==0){
    printf("PARAMETRO CHAR OBLIGATORIO VACIO \n");

    return;
    }

    strcpy(rdisk.path,sincomas);
    compdisco(rdisk.path);

}else if(orden == 3){

    if(oblichar(fmdisk.path)==0 || oblint(fmdisk.size)==0 || oblichar(fmdisk.name)==0){
    printf("PARAMETRO CHAR OBLIGATORIO VACIO \n");

    return;
    }

     if(oblichar(fmdisk.unit)==0){
//disk.unit = "m";
    //printf("UNIT ES OPCIONAL SE PROPORCIONARA EL VALOR k \n");
    strcpy(fmdisk.unit,"k");
    texto.valuni = 1000;
    }else{
    texto.valuni = evaluarunidad(fmdisk.unit);
        if((texto.valuni)==0){
        return;
        }
    }
    if(oblichar(fmdisk.type)==0){

    strcpy(fmdisk.type,"p");
    //printf("TYPE DEFAULT P %s \n",fmdisk.type);
    }else{
    if(evaluartype(fmdisk.type)==0){

    return;}
    }
    if(oblichar(fmdisk.fit)==0){
    strcpy(fmdisk.fit,"wf");
  //  printf("FIT DEFAULT WF %s \n",fmdisk.fit);

    }else{
    if(evaluarfit(fmdisk.fit)==0){
    return;
    }
    }
    if(oblichar(fmdisk.dele)==0){
    }else{
    if(evaluardele(fmdisk.dele)==0){
    return;
    }
    }

particiones();


}else if(orden == 4){
printf("%s  %s",name,path);
        if(oblichar(name)==0 || oblichar(path)==0){
        Pop(&pil);
        printf("\n PARA MONTAR PARTICION DEBES INGRESAR LOS PARAMENTROS OBLIGATORIOS \n");
    return;
    }

    buscpath();
    strcpy(path,sincomas);
    scad(name);
    strcpy(name,sincomas);
    montpart();

}else if(orden == 6){
    if(oblichar(exec)==0){
    printf("\n ERROR, PARAMETROS OBLIGATORIOS VACIOS \n");
    return;
    }
    buscpath();
    strcpy(exec,sincomas);
    leerscript(exec);
}

if(orden == 7){
char l = 97;
    printf("caracter %c %s\n",l,id);


/*char ide[1];
ide[0] = id[3];
     int n;
     n = atoi(ide);
*/

    if(oblichar(namer)==0 || oblichar(pathr)==0 || oblichar(id)==0){

    printf("\n ERROR, PARAMETROS OBLIGATORIOS VACIOS \n");
    return;
    }
        char ide[1];
    ide[0] = id[3];
     int n;
     n = atoi(ide);

     printf("%s %d",id,n);

     printf("llegue aqui");
  if(busPart(&pil, n)==1){
  return;
  }

buscpath();
strcpy(pathr,sincomas);

carpeta(pathr);
graphviz(pathr);


//   return v;


}
orden = 0;



}
コード例 #12
0
/*------------------------------------------------------------------
 * Function:            Search
 * Purpose:             Search for an optimal tour
 * Global vars in:      mat, n
 * Global vars in/out:  best_tour
 */
void *Search(void* rank) {
    city_t nbr;
    city_t city;
    weight_t cost;
	weight_t local_best_cost = best_tour.cost;
    tour_t* tour_p;
    stack_elt_t* stack_p = NULL;
	stack_elt_t* temp_p;
	long my_rank = (long) rank;
	int quotient, leftovers, i;
	int partial_tour_count, first_final_city, last_final_city;
	
	
	quotient = (n-1) / thread_count;
	leftovers = (n-1) % thread_count;
	
	if(my_rank < leftovers){
		partial_tour_count = quotient+1;
		first_final_city = my_rank*partial_tour_count + 1;
	} 
	else{
		partial_tour_count = quotient;
		first_final_city = my_rank*partial_tour_count + leftovers + 1;
	}
	last_final_city = first_final_city + partial_tour_count - 1;
	
	for(i = first_final_city; i <= last_final_city; i++){
		tour_p = malloc(sizeof(tour_t));
    	Initialize_tour(tour_p);
		tour_p->cities[tour_p->count] = 0;
		tour_p->count++;
		tour_p->cost = 0;
		
		temp_p = malloc(sizeof(stack_elt_t));	
		temp_p->tour_p = tour_p;
		temp_p->city = i;
		temp_p->cost = mat[i];
		
		temp_p->next_p = stack_p;
		stack_p = temp_p;

	}

    while (!Empty(stack_p)) {
       Pop(&tour_p, &city, &cost, &stack_p);
       tour_p->cities[tour_p->count] = city;
       tour_p->cost += cost;
       tour_p->count++;
       if (tour_p->count == n) {
			if (tour_p->cost + mat[city*n + 0] < local_best_cost){
				Check_best_tour(city, tour_p, &local_best_cost);	
			}
       } else {
          for (nbr = n-1; nbr > 0; nbr--) {
			 pthread_mutex_lock(&mutex);
             if (Feasible(city, nbr, tour_p, local_best_cost)) 
                Push(tour_p, nbr, mat[n*city+nbr], &stack_p);
			 pthread_mutex_unlock(&mutex);
			}
       }

       /* Push duplicates the tour.  So it needs to be freed */
       free(tour_p->cities);
       free(tour_p);
    }  /* while */
	return NULL;
}  /* Search */
コード例 #13
0
bool Book::Process( FILE *infile, wxProgressDialog &progress )
{
    bool aborted = false;
    char buf[BOOK_BUFLEN+10];
    static char comment_buf[10000];
    int ch, comment_ch=0, previous_ch=0, push_back=0, len=0, move_number=0;
    STATE state=INIT, old_state, save_state=INIT;
    static int nag_value;
    fseek(infile,0,SEEK_END);
    unsigned long file_len=ftell(infile);
    rewind(infile);

    // Loop through characters
    ch = fgetc(infile);
    int old_percent = -1;
    unsigned char modulo_256=0;
    while( ch != EOF )
    {
        if( modulo_256 == 0 )
        {
            unsigned long file_offset=ftell(infile);
            int percent;
            if( file_len == 0 )
                percent = 100;
            else if( file_len < 10000000 )
                percent = (int)( (file_offset*100L) / file_len );
            else // if( file_len > 10000000 )
                percent = (int)( file_offset / (file_len/100L) );
            if( percent != old_percent )
            {
#if wxABI_VERSION > 28600
                if( progress.CanAcceptFocus() )
#endif
                progress.SetFocus();
                if( !progress.Update( percent>100 ? 100 : percent ) )
                {
                    aborted = true;
                    break;
                }
            }
            old_percent = percent;
        }
        modulo_256++;
        modulo_256 &= 0xff;
        if( push_back == '\0' )
        {
            error_buf[error_ptr++] = (char)ch;
            error_ptr &= (sizeof(error_buf)-1);
        }
        push_back = '\0';

        debug_buf[debug_ptr].c     = (char)ch;
        debug_buf[debug_ptr].state = state;
        debug_ptr++;
        debug_ptr &= (nbrof(debug_buf)-1);

        // State machine
        old_state = state;
        if( ch == '{' && (
                                state!=HEADER     &&
                                state!=IN_COMMENT &&
                                state!=IN_MOVE_BLACK &&
                                state!=IN_MOVE_WHITE
                         )
          )
        {
            save_state = state;
            comment_ch = '{';
            state = IN_COMMENT;
        }
        else if( ch == ';' && (
                                state!=HEADER     &&
                                state!=IN_COMMENT &&
                                state!=IN_MOVE_BLACK &&
                                state!=IN_MOVE_WHITE
                              )
               )
        {
            save_state = state;
            comment_ch = ';';
            state = IN_COMMENT;
        }
        else if( state==IN_COMMENT &&
                    (
                        (comment_ch=='{' && ch=='}') ||
                        (comment_ch==';' && ch!=';' && previous_ch=='\n')
                    )
               )
        {
            if( comment_ch == ';' )
                push_back = ch;
            comment_buf[len] = '\0';
            state = save_state;
        }
        else if( ch == '$' && (
                                state!=HEADER     &&
                                state!=IN_COMMENT &&
                                state!=IN_MOVE_BLACK &&
                                state!=IN_MOVE_WHITE
                         )
          )
        {
            save_state = state;
            state = IN_DOLLAR;
            nag_value = 0;
        }
        else if( state==IN_DOLLAR && isascii(ch) && isdigit(ch) )
        {
            nag_value = nag_value*10+(ch-'0');
        }
        else if( state==IN_DOLLAR && isascii(ch) && !isdigit(ch) )
        {
        /*  const char *nag_array[] =
            {
                "",
                " !",     // $1   
                " ?",     // $2   
                " !!",    // $3   
                " ??",    // $4   
                " !?",    // $5   
                " ?!",    // $6   
                "",       // $7   
                "",       // $8   
                " ??",    // $9   
                " =",     // $10  
                " =",     // $11  
                " =",     // $12  
                "",       // $13  
                " +=",    // $14  
                " =+",    // $15  
                " +/-",   // $16  
                " -/+",   // $17  
                " +-",    // $18  
                " -+",    // $19  
                " +-",    // $20  
                " -+"     // $21
            };   */
            push_back = ch;
            state = save_state;
        }
        else if( ch == '(' && (
                                state!=HEADER     &&
                                state!=IN_COMMENT &&
                                state!=ERROR_STATE      &&
                                state!=IN_MOVE_BLACK &&
                                state!=IN_MOVE_WHITE
                              )
               )
            state = Push(state);
        else if( ch == ')' && (
                                state!=HEADER     &&
                                state!=IN_COMMENT &&
                                state!=ERROR_STATE      &&
                                state!=IN_MOVE_BLACK &&
                                state!=IN_MOVE_WHITE
                              )
               )
        {
            state = Pop();
        }
        else
        {

            switch( state )
            {
                case IN_COMMENT:
                {
                    if( len < sizeof(comment_buf)-3 )
                    {
                        if( comment_ch == '{' )
                            comment_buf[len++] = (char)ch;
                        else
                        {
                            if( ch!=';' || previous_ch!='\n' )
                                comment_buf[len++] = (char)ch;
                        }
                    }
                    break;
                }

                case INIT:
                {
                    push_back = ch;
                    state = PREFIX;
                    break;
                }

                case PREFIX:
                {
                    if( ch == '[' )
                    {
                        state = HEADER;
                        push_back = ch;
                    }
                    else if( isascii(ch) && isdigit(ch) )
                    {
                        push_back = ch;
                        state = MOVE_NUMBER;
                    }
                    else if( ch == '*' )
                    {
                        push_back = ch;
                        state = MOVE_NUMBER;
                    }
                    break;
                }

                case HEADER:
                {
                    if( len < BOOK_BUFLEN )
                        buf[len++] = (char)ch;
                    if( ch == ']' )
                        state = PREFIX;
                    break;
                }

                case MOVE_NUMBER:
                {
                    if( ch=='.' || ch==' ' || ch=='\t' || ch=='\n' )
                    {
                        buf[len] = '\0';
                        len = 0;
                        if( TestResult(buf) )
                            state = PREFIX;
                        else if( (move_number=atoi(buf)) > 0 )
                        {
                            state = POST_MOVE_NUMBER;
                            if( ch == '.' )
                                push_back = ch;
                        }
                        else
                        {
                            Error( "Bad move number" );
                            state = ERROR_STATE;
                        }
                    }
                    else
                    {
                        if( len < BOOK_BUFLEN )
                            buf[len++] = (char)ch;
                        else
                        {
                            Error( "Internal buffer overflow" );
                            state = ERROR_STATE;
                        }
                    }
                    break;
                }

                case POST_MOVE_NUMBER:
                {
                    if( ch == '.' )
                        state = POST_MOVE_NUMBER_HAVE_PERIOD;
                    else if( ch!=' ' && ch!='\t' && ch!='\n' )
                    {
                        Error( "Bad move number" );
                        state = ERROR_STATE;
                    }
                    break;
                }

                case POST_MOVE_NUMBER_HAVE_PERIOD:
                {
                    if( ch == '.' )
                        state = POST_MOVE_NUMBER_BLACK;
                    else
                    {
                        push_back = ch;
                        state = PRE_MOVE_WHITE;
                    }
                    break;
                }

                case POST_MOVE_NUMBER_BLACK:
                {
                    if( ch != '.' )
                    {
                        push_back = ch;
                        state = PRE_MOVE_BLACK;
                    }
                    break;
                }

                case ERROR_STATE:
                {
                    if( ch == '[' )
                    {
                        push_back = ch;
                        state = PREFIX;
                    }
                    break;
                }

                case PRE_MOVE_WHITE:
                case PRE_MOVE_BLACK:
                {
                    if( ch == '[' )
                    {
                        push_back = ch;
                        state = PREFIX;
                    }
                    else if( isascii(ch) && isdigit(ch) )
                    {
                        push_back = ch;
                        state = MOVE_NUMBER;
                    }
                    else if( ch!=' ' && ch!='\t' && ch!='\n' )
                    {
                        push_back = ch;
                        state = (state==PRE_MOVE_WHITE?IN_MOVE_WHITE:IN_MOVE_BLACK);
                    }
                    break;
                }

                case IN_MOVE_WHITE:
                case IN_MOVE_BLACK:
                {
                    if( ch == '[' )
                    {
                        push_back = ch;
                        state = PREFIX;
                    }
                    else if( ch==' ' || ch=='\t' || ch=='\n' || ch=='(' || ch==')' || ch=='{' || ch=='}' || ch=='$' )
                    {
                        buf[len] = '\0';
                        len = 0;
                        if( TestResult(buf) )
                            state = PREFIX;
                        else if( !DoMove(state==IN_MOVE_WHITE,move_number,buf) )
                            state = ERROR_STATE;
                        else
                            state = (state==IN_MOVE_WHITE?PRE_MOVE_BLACK:BETWEEN_MOVES);
                        if( ch=='(' || ch==')' || ch=='{' || ch=='}' || ch=='?' )
                            push_back = ch;
                    }
                    else
                    {
                        if( len < BOOK_BUFLEN )
                            buf[len++] = (char)ch;
                        else
                        {
                            Error( "Internal buffer overflow" );
                            state = ERROR_STATE;
                        }
                    }
                    break;
                }

                case BETWEEN_MOVES:
                {
                    if( ch == '[' )
                    {
                        push_back = ch;
                        state = PREFIX;
                    }
                    else if( isascii(ch) && isdigit(ch) )
                    {
                        push_back = ch;
                        state = MOVE_NUMBER;
                    }
                    break;
                }
            }
        }

        // State changes
        if( state != old_state )
        {
            //fprintf( debug_log_file(), "State change %s->%s\n", ShowState(old_state), ShowState(state) );
            if( old_state == HEADER )
            {
                buf[len++] = '\0';
                Header( buf );
            }
            if( state==HEADER || state==IN_COMMENT || state==MOVE_NUMBER || state==IN_MOVE_WHITE || state==IN_MOVE_BLACK )
                len=0;
            if( state==PREFIX && ( 
                                    //old_state==IN_COMMENT || 
                                    old_state==BETWEEN_MOVES ||
                                    old_state==MOVE_NUMBER ||
                                    old_state==POST_MOVE_NUMBER ||
                                    old_state==POST_MOVE_NUMBER_HAVE_PERIOD ||
                                    old_state==POST_MOVE_NUMBER_BLACK ||
                                    old_state==PRE_MOVE_WHITE ||
                                    old_state==PRE_MOVE_BLACK ||
                                    old_state==IN_MOVE_WHITE  ||
                                    old_state==IN_MOVE_BLACK
                                 )
              )
            {
                GameOver();
            }
            if( state==PREFIX && old_state!=HEADER && old_state!=IN_COMMENT )
            {
                GameBegin();
            }
        }

        // Next character
        previous_ch = ch;
        if( push_back )
            ch = push_back;
        else
        {
            ch = fgetc(infile);
            if( ch==EOF &&  (
                                state==MOVE_NUMBER ||
                                state==POST_MOVE_NUMBER ||
                                state==POST_MOVE_NUMBER_HAVE_PERIOD ||
                                state==POST_MOVE_NUMBER_BLACK ||
                                state==PRE_MOVE_WHITE ||
                                state==PRE_MOVE_BLACK ||
                                state==BETWEEN_MOVES
                            )
              )
                GameOver();
        }
    }
    FileOver();
    return aborted;
}       
コード例 #14
0
ファイル: CallBack.cpp プロジェクト: arnout/nano-cast
bool WaitList::WakeupWaiters(bool status)
{
    while (Head() != NULL)
        Dispatcher::Call(Pop(), status);
    return OK;
}
コード例 #15
0
ファイル: nodebuilder.cpp プロジェクト: adasworks/yaml-cpp
void NodeBuilder::OnMapEnd() {
  assert(m_mapDepth > 0);
  m_mapDepth--;
  Pop();
}
コード例 #16
0
void ApuCE()
{
   // POP X
   Pop(IAPU.X);
   IAPU.PC++;
}
コード例 #17
0
ファイル: CriticalPath.cpp プロジェクト: Og192/CPro
Status CriticalPath(ALGraph &G)
{
	SqStack T;
	int i,j,k;
	ArcNode *p;
	if (!TopologicalOrder(G,T))
	{
		return ERROR;
	}
	j = G.vertices[0].data.ve;//j的初值
	for (i = 1; i < G.vexnum;++i)
	{
		if (G.vertices[i].data.ve > j)
		{
			j = G.vertices[i].data.ve;//j = MAX(ve)完成点的最早发生时间
		}
	}
	for (i = 0; i < G.vexnum; ++i)//初始化顶点事件的最迟发生时间
	{
		G.vertices[i].data.vl = j;
	}
	while (!StackEmpty(T))//按逆拓扑序求各顶点的vl值
	{
		Pop(T,j);
		p = G.vertices[j].firstarc;
		while (p)
		{
			k = p->data.adjvex;//后序顶点的值
			if (G.vertices[k].data.vl - p->data.info->weight < G.vertices[j].data.vl)
			{//事件j的最迟发生时间 > 其直接后继事件的最迟发生时间 - <j,k>的权值
				G.vertices[j].data.vl = G.vertices[k].data.vl - p->data.info->weight;
			 //事件j的最迟发生时间 = 其直接后继事件的最迟发生时间 - <j,k>的权值
			}
			 p = p->nextarc;
		}
	}
	printf("\ni  ve  vl\n");
	for (i = 0; i < G.vexnum; ++i)
	{
		printf("%d  ",i);//输出序号
		Visitel(G.vertices[i].data);//输出ve、vl的值
		if (G.vertices[i].data.ve == G.vertices[i].data.vl)
		{//事件(顶点)的最早发生时间 = 最迟发生时间
			printf("  关键路径经过的顶点");
		}
		printf("\n");
	}
	printf("j  k  权值  ee  el\n");
	for (j = 0; j < G.vexnum; ++j)
	{
		for (p = G.vertices[j].firstarc;p;p = p->nextarc)
		{
			k = p->data.adjvex;//邻接顶点(直接后继事件)的序号
			p->data.info->ee = G.vertices[j].data.ve;//ee(活动<i,j>的最早开始时间 = (顶点j)事件最早发生时间)
			p->data.info->el = G.vertices[k].data.vl - p->data.info->weight;
			////el(活动<j,k>的最迟开始时间)=(顶点k)事件最迟发生时间-<j,k>的权值
			printf("%s->%s",G.vertices[j].data.name,G.vertices[k].data.name);
			OutputArcwel(p->data.info);
			if (p->data.info->ee == p->data.info->el)
			{//活动最早开始时间 = 活动最迟开始时间 
				printf("  关键活动");
			}
			printf("\n");
		}
	}
	return OK;
}
コード例 #18
0
void ApuEE()
{
   // POP Y
   Pop(IAPU.YA.B.Y);
   IAPU.PC++;
}
コード例 #19
0
ファイル: stack.cpp プロジェクト: ArtyomLinnik/Study
void Stack::operator-- ()
{
	return Pop();
}
コード例 #20
0
ファイル: n_2.cpp プロジェクト: ricky626/OpenGL-Programming
int main()
{
	HEAD* List = Create();

	SaveData data = { 0, 0, 0, 0 };
	
	EnQueue(List, data);

	char sel = 0;

	while (1)
	{
		printf("명령어 입력 : ");
		scanf("%s", &sel);

		switch (sel)
		{
		case '+':
			printf("Push 입력 : ");
			scanf("%d %d %d", &data.x, &data.y, &data.z);

			Push(List, data);
			PrintAll(List);
			break;
		case '-':
			Pop(List);
			PrintAll(List);
			break;
		case 'e':
			printf("EnQueue 입력 : ");
			scanf("%d %d %d", &data.x, &data.y, &data.z);

			EnQueue(List, data);
			PrintAll(List);
			break;
		case 'd':
			DeQueue(List);
			PrintAll(List);
			break;
		case 'l':
			printf("length of stack : %d \t length of queue : %d\n", stack_count, queue_count);
			break;
		case 'c':
			DeleteAll(List);
			break;
		case 'm':
			FindMaxNum(List);
			break;
		case 'n':
			FindMinNum(List);
			break;
		case 'q':
			break;
		default:
			break;
		}
	}
	

	return 0;
}
コード例 #21
0
 ~CSortedStack() {
   while (NumberOfItem != 0) {
     Pop();
   }
 }
コード例 #22
0
int main(void)
{
    // int i;
    // pthread_t handles[nStealers];    // We will not touch it
    pthread_t handles[4];    // We will not touch it
    // Obj *items = malloc(nItems*sizeof(Obj));    // something creating by malloc must be tracked
    int items = __VERIFIER_atomic_malloc(8 * 1);  // items is a pointer

    // for (i = 0; i < nItems; i++)
    // {
    // Init_ObjType(&items[i]);    // related to tracked variable also need to be tracked
    Init_ObjType(items + 0);    // related to tracked variable also need to be tracked
    Init_ObjType(items + 1);    // related to tracked variable also need to be tracked
    Init_ObjType(items + 2);    // related to tracked variable also need to be tracked
    Init_ObjType(items + 3);    // related to tracked variable also need to be tracked
    Init_ObjType(items + 4);    // related to tracked variable also need to be tracked
    Init_ObjType(items + 5);    // related to tracked variable also need to be tracked
    Init_ObjType(items + 6);    // related to tracked variable also need to be tracked
    Init_ObjType(items + 7);    // related to tracked variable also need to be tracked
    // }

    WorkStealQueue q;

    Init_WorkStealQueue(&q, INITQSIZE);

    // for (i = 0; i < nStealers; i++)
    // {
    pthread_create(&handles[0], NULL, Stealer, &q);  // No
    pthread_create(&handles[1], NULL, Stealer, &q);  // No
    pthread_create(&handles[2], NULL, Stealer, &q);  // No
    pthread_create(&handles[3], NULL, Stealer, &q);  // No
    // }

    // for (i = 0; i < nItems / 2; i++)
    {
        // Push(&q, &items[0]);
        Push(&q, items);
        // Push(&q, &items[1]);
        Push(&q, items + 1);
        // Obj *r; // r is track
        int r; // r is track
        if (Pop(&q, &r))    // r is tracked
        {
            Operation(r);
        }
    }
    {
        // Push(&q, &items[2]);
        Push(&q, items + 2);
        // Push(&q, &items[3]);
        Push(&q, items + 3);
        // Obj *r; // r is track
        int r; // r is track
        if (Pop(&q, &r))    // r is tracked
        {
            Operation(r);
        }
    }

    {
        // Push(&q, &items[2]);
        Push(&q, items + 4);
        // Push(&q, &items[3]);
        Push(&q, items + 5);
        // Obj *r; // r is track
        int r; // r is track
        if (Pop(&q, &r))    // r is tracked
        {
            Operation(r);
        }
    }

    {
        // Push(&q, &items[2]);
        Push(&q, items + 6);
        // Push(&q, &items[3]);
        Push(&q, items + 7);
        // Obj *r; // r is track
        int r; // r is track
        if (Pop(&q, &r))    // r is tracked
        {
            Operation(r);
        }
    }

    // for (i = 0; i < nItems / 2; i++)
    {
        // Obj *r; // r is tracked
        int r; // r is track
        if (Pop(&q, &r))
        {
            Operation(r);
        }
    }
    {
        // Obj *r; // r is tracked
        int r; // r is track
        if (Pop(&q, &r))
        {
            Operation(r);
        }
    }
    {
        // Obj *r; // r is tracked
        int r; // r is track
        if (Pop(&q, &r))
        {
            Operation(r);
        }
    }
    {
        // Obj *r; // r is tracked
        int r; // r is track
        if (Pop(&q, &r))
        {
            Operation(r);
        }
    }

    // for (i = 0; i < nStealers; i++)
    // {
    pthread_join(handles[0], NULL);
    pthread_join(handles[1], NULL);
    pthread_join(handles[2], NULL);
    pthread_join(handles[3], NULL);
    // }

    // for (i = 0; i < nItems; i++)
    // {
    // Check(&items[0]);
    Check(items + 0);
    // Check(&items[1]);
    Check(items + 1);
    // Check(&items[2]);
    Check(items + 2);
    // Check(&items[3]);
    Check(items + 3);
    Check(items + 4);
    Check(items + 5);
    Check(items + 6);
    Check(items + 7);
    // }

    __VERIFIER_atomic_free(items);
    return 0;
}
コード例 #23
0
ファイル: xbexpprc.cpp プロジェクト: Chaduke/bah.mod
/*!
  \param RecBufSw
*/
xbShort xbExpn::ProcessOperator( xbShort RecBufSw )
{
  xbExpNode * WorkNode;
  char Operator[6]; 
  char t;
  if( GetStackDepth() < 3 ) 
    return XB_PARSE_ERROR;
  WorkNode = (xbExpNode *) Pop();
  if( WorkNode->Len > 5 )
    return XB_PARSE_ERROR;

  memset( Operator, 0x00, 6 );
  strncpy( Operator, WorkNode->NodeText, WorkNode->Len );
  if( !WorkNode->InTree ) 
    delete WorkNode;

  /* load up operand 1 */
  WorkNode = (xbExpNode *) Pop();
  if(( OpType1 = GetOperandType( WorkNode )) == 0 )
    return XB_PARSE_ERROR;

  if( OpLen1 < WorkNode->DataLen+1 && WorkNode->Type != 'd' ) {
    if( OpLen1 > 0 ) free( Op1 );
    if(( Op1 = (char *) malloc( WorkNode->DataLen+1 )) == NULL ) {
      return XB_NO_MEMORY;
    }
    OpLen1 = WorkNode->DataLen+1;
  }
  OpDataLen1 = WorkNode->DataLen;
  memset( Op1, 0x00, WorkNode->DataLen+1 );
  if( WorkNode->Type == 'D' && WorkNode->dbf ) {    /* database field  */
    WorkNode->dbf->GetField( WorkNode->FieldNo, Op1, RecBufSw );
    t = WorkNode->dbf->GetFieldType( WorkNode->FieldNo );
    if( t == 'N' || t == 'F' )
      Opd1 = strtod( WorkNode->StringResult, 0 );
    else if( t == 'D' ){   // date field
      xbDate d;
      Opd1 = d.JulianDays( WorkNode->StringResult );
    }
  }
  else if( WorkNode->Type == 'C' )     /* constant        */
    memcpy( Op1, WorkNode->NodeText, WorkNode->DataLen );
  else if( WorkNode->Type == 's' )     /* previous result */
    memcpy( Op1, WorkNode->StringResult, WorkNode->DataLen+1 );
  else if( WorkNode->Type == 'd' )     /* previous numeric result */   
    Opd1 = WorkNode->DoubResult;
  else if( WorkNode->Type == 'N' )     /* previous numeric result */   
    Opd1 = strtod( WorkNode->StringResult, 0 );
  else if(WorkNode->Type == 'l')       /* previous logical result 3/26/00 dtb */
    Opd1 = WorkNode->IntResult;
  if( !WorkNode->InTree ) 
    delete WorkNode;

  /* load up operand 2 */
  WorkNode = (xbExpNode *) Pop();
  if(( OpType2 = GetOperandType( WorkNode )) == 0 )
    return XB_PARSE_ERROR;

  if( OpLen2 < WorkNode->DataLen+1 && WorkNode->Type != 'd' ) {
    if( OpLen2 > 0 ) free( Op2 );
    if(( Op2 = (char *) malloc( WorkNode->DataLen+1 )) == NULL ) {
      return XB_NO_MEMORY;
    }
    OpLen2 = WorkNode->DataLen+1;
  }
  OpDataLen2 = WorkNode->DataLen;
  memset( Op2, 0x00, WorkNode->DataLen+1 );
  if( WorkNode->Type == 'D' && WorkNode->dbf ) {    /* database field  */
    WorkNode->dbf->GetField( WorkNode->FieldNo, Op2, RecBufSw );
    t = WorkNode->dbf->GetFieldType( WorkNode->FieldNo );
    if( t == 'N' || t == 'F' )
      Opd2 = strtod( WorkNode->StringResult, 0 );
    else if( t == 'D' ){   // date field
      xbDate d;
      Opd2 = d.JulianDays( WorkNode->StringResult );
    }
  }
  else if( WorkNode->Type == 'C' )     /* constant        */
    memcpy( Op2, WorkNode->NodeText, WorkNode->DataLen );
  else if( WorkNode->Type == 's' )     /* previous result */
    memcpy( Op2, WorkNode->StringResult, WorkNode->DataLen+1 );
  else if( WorkNode->Type == 'd' )     /* previous numeric result */
    Opd2 = WorkNode->DoubResult;
  else if( WorkNode->Type == 'N' )     /* previous numeric result */   
    Opd2 = strtod( WorkNode->StringResult, 0 );
  else if(WorkNode->Type == 'l')       /* previous logical result 3/26/00 dtb*/
    Opd2 = WorkNode->IntResult;
  if( !WorkNode->InTree )
    delete WorkNode;
  if( !ValidOperation( Operator, OpType1, OpType2 ))
    return XB_PARSE_ERROR;

  if( OpType1 == 'N' || OpType1 == 'L' || OpType1 == 'D' ) /* numeric procesing */
    return NumericOperation( Operator );
  else                    /* must be character */
    return  AlphaOperation( Operator );
}
コード例 #24
0
ファイル: nodebuilder.cpp プロジェクト: adasworks/yaml-cpp
void NodeBuilder::OnNull(const Mark& mark, anchor_t anchor) {
  detail::node& node = Push(mark, anchor);
  node.set_null();
  Pop();
}
コード例 #25
0
ファイル: fx_sax_imp.cpp プロジェクト: primiano/pdfium-merge
void CFX_SAXReader::SkipNode() {
  int32_t iLen = m_SkipStack.GetSize();
  if (m_SkipChar == '\'' || m_SkipChar == '\"') {
    if (m_CurByte != m_SkipChar) {
      return;
    }
    iLen--;
    FXSYS_assert(iLen > -1);
    m_SkipStack.RemoveAt(iLen, 1);
    m_SkipChar = iLen ? m_SkipStack[iLen - 1] : 0;
    return;
  }
  switch (m_CurByte) {
    case '<':
      m_SkipChar = '>';
      m_SkipStack.Add('>');
      break;
    case '[':
      m_SkipChar = ']';
      m_SkipStack.Add(']');
      break;
    case '(':
      m_SkipChar = ')';
      m_SkipStack.Add(')');
      break;
    case '\'':
      m_SkipChar = '\'';
      m_SkipStack.Add('\'');
      break;
    case '\"':
      m_SkipChar = '\"';
      m_SkipStack.Add('\"');
      break;
    default:
      if (m_CurByte == m_SkipChar) {
        iLen--;
        m_SkipStack.RemoveAt(iLen, 1);
        m_SkipChar = iLen ? m_SkipStack[iLen - 1] : 0;
        if (iLen == 0 && m_CurByte == '>') {
          m_iDataLength = m_iDataPos;
          m_iDataPos = 0;
          if (m_iDataLength >= 9 &&
              FXSYS_memcmp(m_pszData, "[CDATA[", 7 * sizeof(uint8_t)) == 0 &&
              FXSYS_memcmp(m_pszData + m_iDataLength - 2, "]]",
                           2 * sizeof(uint8_t)) == 0) {
            Pop();
            m_iDataLength -= 9;
            m_dwDataOffset += 7;
            FXSYS_memmove(m_pszData, m_pszData + 7,
                          m_iDataLength * sizeof(uint8_t));
            m_bCharData = TRUE;
            if (m_pHandler) {
              NotifyData();
            }
            m_bCharData = FALSE;
          } else {
            Pop();
          }
          m_eMode = FX_SAXMODE_Text;
        }
      }
      break;
  }
  if (iLen > 0) {
    ParseChar(m_CurByte);
  }
}
コード例 #26
0
ファイル: nodebuilder.cpp プロジェクト: adasworks/yaml-cpp
void NodeBuilder::OnAlias(const Mark& /* mark */, anchor_t anchor) {
  detail::node& node = *m_anchors[anchor];
  Push(node);
  Pop();
}
コード例 #27
0
ファイル: CPU.cpp プロジェクト: Mantrapps/OS_Lab
    // work as control unit in CPU
    void CPU::Decode()
    {
        if (CPU_Status==CPU_End) return;
        switch(Reg_IR)
        {
                //load value load the value into the AC
            case 1:
                Load_Value();
                break;
                //load addr load the value at the address into the AC
            case 2:
                Load_addr();
                break;
                //LoadInd addr
            case 3:
                LoadInd_addr();
                break;
                //loadIdxX addr
            case 4:
                LoadIdxX_addr();
                break;
                //LoadIdxY addr
            case 5:
                LoadIdxY_addr();
                break;
                //LoadSpX
            case 6:
                LoadSpX();
                break;
                //Store addr
            case 7:
                Store_addr();
                break;
                // get a random int from 1 to 100 into AC
            case 8:
                Get();
                break;
                //Put port
            case 9:
                Put_Port();
                break;
                //addX
            case 10:
                AddX();
                break;
                //add Y
            case 11:
                AddY();
                break;
                //Sub X
            case 12:
                SubX();
                break;
                //Sub y
            case 13:
                SubY();
                break;
                //copy the value in the AC to X
            case 14:
                CopyToX();
                break;
                //copy the value in X to the AC
            case 15:
                CopyFromX();
                break;
                //copy the value in the AC to Y
            case 16:
                CopyToY();
                break;
                //copy the value in Y to the AC
            case 17:
                CopyFromY();
                break;
                //copy the value in SP to the AC
            case 18:
                CopyToSp();
                break;
                // Copy From Sp
            case 19:
                CopyFromSp();
                break;
                //Jump addr
            case 20:
                Jump_addr();
                break;
                //Jump If equal addr
            case 21:
                JumpIfEqual_addr();
                break;
                //Jump If not equal addr
            case 22:
                JumpIfNotEqual_addr();
                break;
                //call addr
            case 23:
                Call_addr();
                break;
                //ret
            case 24:
                Ret();
                break;
                //inc X
            case 25:
                IncX();
                break;
                //Dec X
            case 26:
                DecX();
                break;
                //Push AC onto Stack
            case 27:
                Push();
                //push();
                break;
                //Pop from stack into AC
            case 28:
                Pop();
                //pop();
                break;
                //Int
            case 29:
                Int(Sys_Interrupt_Start, Reg_PC, CPU_KernelMode);
                break;
                //IRet
            case 30:
                IRet();
                break;
                //End Execution
            case 50:
                End();
                break;
        }
        if (CPU_Status==CPU_End) {
            return;
        }
        ++Instruction_Counter;
        //std::cout<<"Decode Complete: PC "<<Reg_PC<<" IR: "<<Reg_IR<<" AC: "<<Reg_AC<<" sp: "<<Reg_SP<<" x: "<<Reg_X<<" y: "<<Reg_Y<<std::endl;
        //std::cout<<std::endl;

    }
コード例 #28
0
ファイル: nodebuilder.cpp プロジェクト: adasworks/yaml-cpp
void NodeBuilder::OnSequenceEnd() { Pop(); }
コード例 #29
0
ファイル: stack.c プロジェクト: terana/ILove_Coding
void Add (struct Stack_t *This) {
    int flag = (This && This->top <= This->size && This->top > 1);
    assert (flag);
    Push (This, Pop(This) + Pop(This));    
}
コード例 #30
0
		T popNoSleep() {
			std::unique_lock<std::mutex> lock(m_mutex);
			if(m_container.empty()) throw CExEmptyContainer();
			T res = Pop(m_container, 0);
			return res;
		}