Пример #1
0
constraint constraint_undump (FILE *f)
{
  constraint c;
  bool fcnPre, post;
  arithType ar;
  constraintExpr lexpr, expr;
  char *s, *os;
  
  os = mstring_create (MAX_DUMP_LINE_LENGTH);
  s = fgets (os, MAX_DUMP_LINE_LENGTH, f);

  if (!mstring_isDefined (s))
    {
      llfatalbug (message ("Library file is corrupted") );
    }
  
  fcnPre = (bool) reader_getInt (&s);
  advanceField (&s);
  post = (bool) reader_getInt (&s);
  advanceField (&s);
  ar = (arithType) reader_getInt (&s);
  
  s = fgets (os, MAX_DUMP_LINE_LENGTH, f);

  if (! mstring_isDefined(s) )
    {
      llfatalbug(message("Library file is corrupted") );
    }
  
  reader_checkChar (&s, 'l');

  lexpr = constraintExpr_undump (f);

  s = fgets (os, MAX_DUMP_LINE_LENGTH, f);

  reader_checkChar (&s, 'r');
  
  if (! mstring_isDefined(s) )
    {
      llfatalbug(message("Library file is corrupted") );
    }
  
  expr = constraintExpr_undump (f);

  c = constraint_makeNew ();
  
  c->fcnPre = fcnPre; 
  c->post = post;
  c->ar = ar;

  c->lexpr = lexpr;
  c->expr =  expr;

  free (os);
  c = constraint_preserveOrig (c);
  return c;
}
Пример #2
0
void
LSLScanFreshToken (ltoken tok)
{
  if (lastToken < MAXLINE)
    {				
      TokenList[lastToken++] = ltoken_copy (tok);	
    }
  else
    {
      llfatalbug (message ("LSLScanFreshToken: out of range: %s", 
			   cstring_fromChars (lsymbol_toChars (ltoken_getText (tok)))));
    }
}
Пример #3
0
constraint makeConstraintParse3 (constraintExpr l, lltok relOp, constraintExpr r)     
{
  constraint ret;
  ret = constraint_makeNew ();
  llassert (constraintExpr_isDefined (l));
    
  ret->lexpr = constraintExpr_copy (l);

  if (lltok_getTok (relOp) == GE_OP)
    {
      ret->ar = GTE;
    }
  else if (lltok_getTok (relOp) == LE_OP)
    {
      ret->ar = LTE;
    }
  else if (lltok_getTok (relOp) == EQ_OP)
    {
      ret->ar = EQ;
    }
  else
    llfatalbug ( message ("Unsupported relational operator"));

  ret->expr = constraintExpr_copy (r);

  ret->post = TRUE;

  ret->orig = constraint_copy (ret);

  ret = constraint_simplify (ret);
  /* ret->orig = ret; */

  DPRINTF (("GENERATED CONSTRAINT:"));
  DPRINTF ((message ("%s", constraint_unparse (ret))));
  return ret;
}
Пример #4
0
Файл: osd.c Проект: Safe3/themis
cstring osd_absolutePath (cstring cwd, cstring filename)
{
# if defined (UNIX) || defined (OS2)
  /* Setup the current working directory as needed.  */
  cstring cwd2 = cstring_isDefined (cwd) ? cwd : osd_cwd;
  char *abs_buffer;
  char *endp, *outp, *inp;

  /*@access cstring@*/
  llassert (cstring_isDefined (cwd2));
  llassert (cstring_isDefined (filename));

  abs_buffer = (char *) dmalloc (cstring_length (cwd2) + cstring_length (filename) + 2);
  endp = abs_buffer;
  
  /*
  ** Copy the  filename (possibly preceded by the current working
  ** directory name) into the absolutization buffer.  
  */
  
  {
    const char *src_p;

    if (!osd_isConnectChar (filename[0])
# ifdef OS2
	&& !(isalpha (filename[0]) && filename[1] == ':')
# endif
	)
      {
        src_p = cwd2;

        while ((*endp++ = *src_p++) != '\0') 
	  {
	    continue;
	  }

        *(endp-1) = CONNECTCHAR;                        /* overwrite null */
      }

    src_p = filename;

    while ((*endp++ = *src_p++) != '\0')
      {
	continue;
      }
  }
  
  /* Now make a copy of abs_buffer into abs_buffer, shortening the
     filename (by taking out slashes and dots) as we go.  */
  
  outp = inp = abs_buffer;
  *outp++ = *inp++;             /* copy first slash */
#ifdef apollo
  if (inp[0] == '/')
    *outp++ = *inp++;           /* copy second slash */
#endif
  for (;;)
    {
      if (inp[0] == '\0')
	{
	  break;
	}
      else if (osd_isConnectChar (inp[0]) && osd_isConnectChar (outp[-1]))
	{
	  inp++;
	  continue;
	}
      else if (inp[0] == '.' && osd_isConnectChar (outp[-1]))
	{
	  if (inp[1] == '\0')
	    {
	      break;
	    }
	  else if (osd_isConnectChar (inp[1]))
	    {
	      inp += 2;
	      continue;
	    }
	  else if ((inp[1] == '.') 
		   && (inp[2] == '\0' || osd_isConnectChar (inp[2])))
	    {
	      inp += (osd_isConnectChar (inp[2])) ? 3 : 2;
	      outp -= 2;
	
	      while (outp >= abs_buffer && !osd_isConnectChar (*outp))
		{
		  outp--;
		}

	      if (outp < abs_buffer)
		{
		  /* Catch cases like /.. where we try to backup to a
                     point above the absolute root of the logical file
                     system.  */
		  
		  llfatalbug (message ("Invalid file name: %s", filename));
		}

	      *++outp = '\0';
	      continue;
	    }
	  else
	    {
	      ;
	    }
	}
      else
	{
	  ;
	}

      *outp++ = *inp++;
    }
  
  /* On exit, make sure that there is a trailing null, and make sure that
     the last character of the returned string is *not* a slash.  */
  
  *outp = '\0';
  if (osd_isConnectChar (outp[-1]))
    *--outp  = '\0';
  
  /*@noaccess cstring@*/
  return cstring_fromChars (abs_buffer);
# else
  DPRINTF (("Here: %s", filename));
  return cstring_copy (filename);
# endif
}