⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r2build.c

📁 这是一个C程序分析工具
💻 C
字号:
/*====================================================================*/
/*  UNIT   :   @(#)r2build.c	2.5  -  08/04/99 */
/*====================================================================*/
/*  PURPOSE:  This function traverses the Test List and builds a      */
/*            Component List for further analysis.                    */
/*                                                                    */
/*  SYSTEM :  RECON II                                                */
/*                                                                    */
/*  USED BY:  main()                                                  */
/*                                                                    */
/*  HISTORY:                                                          */
/*  VER   DATE        AUTHOR        DESCRIPTION                       */
/*  1.00  23 Feb 93   L. Richard    Created unit.                     */
/*  1.01  10 Mar 93   L. Richard    Implemented gTALK.                */
/*  1.02   4 Apr 93   L. Richard    Modified algorythm that updates   */
/*                                  components in the intermediate    */
/*                                  component list (icl).             */
/*  1.03  31 Oct 93   N. Wilde      Eliminated the combining of 'T'   */
/*                                  and 'F' nodes into 'B' nodes      */
/*  1.04  30 Mar 97   L. Landry     Added btree interface             */
/*  2.2   31 Jan 98   W. Hall       Deleted unused variable 'str'     */
/*  2.3   29 Apr 98   A. Conwell    Chgd tree build per Tisk 30       */
/*  2.31  25 Nov 98   D. Fralish    Call AbortMsg per Tisk 33         */
/*--------------------------------------------------------------------*/

/*==[ INTERFACE ]=====================================================*/

#include "r2.h"
#include "r2build.h"
#include <stdio.h>

/*==[ PRIVATE IMPLEMENTATION ]========================================*/
#include "r2util.h"

/*==[ PUBLIC IMPLEMENTATION ]=========================================*/

/*--------------------------------------------------------------------*/
/*  FUNCTION        BuildCompList                                     */
/*--------------------------------------------------------------------*/

extern BOOL BuildCompList(
  TESTLIST  	*tl,			/* Test case list             */
  COMPLIST	*cl,			/* Component list             */
  Tree          *ptree,                 /* btree for filenames        */
  clinput       *CLInput                /* Command line input struture*/
)
{
  BOOL		error;			/* Error flag                 */
  FILE		*testFILE;		/* Test file path	      */
  TESTNODE	node;			/* Temporary test node	      */
  COMPLIST	*icl;			/* Temporary component list   */
  COMPELEM	elem;			/* Component nodes	      */
  int		fnum;			/* Instrumented File index    */
  int		lnum;			/* Instrumented line number   */
  char		cval;			/* Component type	      */
  long		sval;			/* Switch ordnal value	      */
  int           linenum=0;              /* Linenumber of trace file   */
  char        * R2srcFile;              /* Analysis filename          */
  int           lenName;                /* Length of source filename  */
  char          name[MAXLINE];          /* Test filename              */
  Item          test_item;              /* Item to carry the inputs   */

  /* Assume success */

  error = FALSE;


  /* Process each test file in the test list */

  while (0 < TestListSize( tl ))
  {
    RemoveTestNode( tl, &node );	/* Get top node */
    if (2 == gTALK)
      printf( "R2Analyz: %d %s\n", node.Exhibits, node.Output );

    if (NULL == (testFILE = fopen( node.Output, "r" )))
    {
      printf( "R2Analyz: Cannot open %s!\n", node.Output );
      AbortMsg( "Check trace file names.\n");
    }
    else
    {

      /* Process each instrumentation case */

      /* Create intermediate (temporary) component list */

      CreateCompList( &icl );

	/* Initialize component */
   R2srcFile=node.Output;

      linenum=0;
      while(1==getRecordType(testFILE, &cval))
      {
	linenum++;
	if(gTALK == 2) printf("%c",cval);
	sval=0;
	lnum=0;
        /* read new trace file values */
	if(0==EvalValueType(testFILE,R2srcFile,&lnum,&cval,&sval,
		      name,&lenName,linenum))
	{
	  test_item.size = lenName;
	  strcpy(test_item.file, name);
	  fnum = AddItem(test_item, ptree); /* get index from btree */
	  elem.Index = fnum;
	  elem.Line  = lnum;
	  elem.Cval  = cval;
	  elem.Sval  = sval;
	  elem.Tot   = 1;
	  if (node.Exhibits)
	    elem.With = 1;
	  else
	    elem.With = 0;

	  /* Add to list if not present */
	  if (FALSE == FindCompElem( icl, &elem ))
	    AddCompElem( icl, &elem );
	  if (2 == gTALK)
	    printf( "%d %d %c %ld\n", fnum, lnum, cval, sval );

	}
      } /*while EOF*/
    } /*if NULL*/

    if (2 == gTALK)
      ShowCompList( icl,"Intermediate CL" );

    /* Update the Final Component List */

    MergeCompElem(icl,cl);
    DeleteCompList(&icl);

    fclose(testFILE);

  } /*while TestListSize*/

  if (2 == gTALK)
    ShowCompList( cl, "Final CL" );

  return( error );

} /* BuildCompList() */

/*====================================================================*/
/*  EOF    :  r2build.c                                               */
/*====================================================================*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -