VIS

src/rt/rtMain.c

Go to the documentation of this file.
00001 
00046 #include "rtInt.h"
00047 #include "rt.h"
00048 #include "ntm.h"
00049 #include "part.h"
00050 #include <errno.h>
00051 #include <math.h>
00052 
00053 static char rcsid[] UNUSED = "$Id: rtMain.c,v 1.36 2010/04/10 00:38:42 fabio Exp $";
00054 
00055 
00056 /*---------------------------------------------------------------------------*/
00057 /* Macro declarations                                                        */
00058 /*---------------------------------------------------------------------------*/
00059 /*---------------------------------------------------------------------------*/
00060 /* Variable declarations                                                     */
00061 /*---------------------------------------------------------------------------*/
00062 
00063 
00066 /*---------------------------------------------------------------------------*/
00067 /* Static function prototypes                                                */
00068 /*---------------------------------------------------------------------------*/
00069 
00070 static int CommandRt( Hrc_Manager_t **hmgr, int argc, char **argv);
00071 static RtConfigs_t * Rt_ReadConfigFile(char *filename);
00072 static char * Rt_SplitLine( char * command, int * argc, char *** argv);
00073 static int Rt_CompareResult(RtConfigs_t *config, RtDesignLists_t *designList, int refOnly);
00074 static int Rt_WriteBatchCommand(RtConfigs_t *config, RtDesignLists_t *designList);
00075 static int Rt_ExecuteVis(RtConfigs_t *config, RtDesignLists_t *designList, int refAndNew, FILE *scriptOut);
00076 static int Rt_WriteResult(RtConfigs_t *config, int size);
00077 static void Rt_FreeRtConfig(RtConfigs_t * config);
00078 static void Rt_FreeCommandResult(RtCommandResults_t *result);
00079 static void Rt_FreeCompareItem(RtCompareItems_t *item);
00080 static void Rt_FreeResultProperty(RtResultPropertys_t *prop);
00081 static void Rt_FreeDesignList(RtDesignLists_t *list);
00082 static void Rt_FreeArgv(int  argc,  char ** argv);
00083 static int Rt_ReadDesignListFile(RtConfigs_t * config);
00084 static int Rt_ReadCommandTemplate(RtConfigs_t * config);
00085 static int RtCheckInputFileAvailability( RtConfigs_t *config, RtDesignLists_t *designList, int withWarning);
00086 static void Rt_RemoveUnderscore(char *name, char *newName);
00087 static int Rt_IsNum(char *tmp);
00088 static int Rt_SetBooleanValue(char *str, char *option);
00089 
00093 /*---------------------------------------------------------------------------*/
00094 /* Definition of exported functions                                          */
00095 /*---------------------------------------------------------------------------*/
00096 
00097 
00114 void
00115 Rt_Init(void)
00116 {
00117   Cmd_CommandAdd("regression_test", CommandRt, /* doesn't changes_network */ 0);
00118 }
00119 
00127 void
00128 Rt_End(void)
00129 {
00130 }
00131 
00454 static int
00455 CommandRt(
00456   Hrc_Manager_t **hmgr,
00457   int argc,
00458   char **argv)
00459 {
00460   char *configurationFile;
00461   char *scriptFile;
00462   RtConfigs_t *config;
00463   RtDesignLists_t *designList;
00464   array_t *designArr;
00465   int i;
00466   FILE *scriptOut;
00467   int c;
00468   error_init();
00469 
00470   if(argc < 2) {
00471      fprintf(vis_stdout, "Error : ConfigurationFile is missed\n");
00472      return(1);
00473   }
00474 
00475   util_getopt_reset();
00476   scriptFile = 0;
00477   scriptOut = 0;
00478   while ((c = util_getopt(argc, argv, "s:h")) != EOF) {
00479     switch(c) {
00480     case 's':
00481       scriptFile = util_strsav(util_optarg);
00482       break;
00483     case 'h':
00484       (void) fprintf(vis_stderr, "usage: regression_test [-h] [-s scriptfile] configuration_file\n");
00485       (void) fprintf(vis_stderr, "    -h \tprint help information\n");
00486       (void) fprintf(vis_stderr, "    -s <scriptfile>\n");
00487       (void) fprintf(vis_stderr, "       \tgenerate shell script file for regression_test\n");
00488       return 0;
00489     default:
00490       (void) fprintf(vis_stderr, "usage: regression_test [-h] [-s scriptfile] configuration_file\n");
00491       (void) fprintf(vis_stderr, "    -h \tprint help information\n");
00492       (void) fprintf(vis_stderr, "    -s <scriptfile>\n");
00493       (void) fprintf(vis_stderr, "       \tgenerate shell script file for regression_test\n");
00494       return 0;
00495     }
00496   }
00497   if(scriptFile) {
00498     if(!(scriptOut = fopen(scriptFile, "w"))) {
00499       fprintf(vis_stdout, "Error : Can't open script file '%s'\n", scriptFile);
00500       return(1);
00501     }
00502   }
00503 
00504   configurationFile = argv[util_optind];
00505   config = Rt_ReadConfigFile(configurationFile);
00506   if(config == 0)                       return(1);
00507 
00508   config->scriptFile = scriptFile;
00509   if(Rt_ReadDesignListFile(config))     {
00510     Rt_FreeRtConfig(config);
00511     return(1);
00512   }
00513   if(Rt_ReadCommandTemplate(config))    {
00514     Rt_FreeRtConfig(config);
00515     return(1);
00516   }
00517 
00518 
00519   designArr = config->designListArr;
00520   for(i=0; i<array_n(designArr); i++) {
00521     designList = array_fetch(RtDesignLists_t *, designArr, i);
00522 
00529     if(RtCheckInputFileAvailability(config, designList, 1)) {
00530        fprintf(vis_stdout, "Skip the design '%s' ..(%d/%d)\n", designList->designNickName, i+1, array_n(designArr));
00531        continue;
00532     }
00540     if(Rt_WriteBatchCommand(config, designList)) {
00541        fprintf(vis_stdout, "ERROR : can't write script for design '%s'\n", designList->designNickName);
00542        continue;
00543     }
00548     if(Rt_ExecuteVis(config, designList, 1, scriptOut)) {
00549        fprintf(vis_stdout, "ERROR : can't execute '%s' for design '%s'\n", config->referenceVisNickName, designList->designNickName);
00550     }
00555     if(Rt_ExecuteVis(config, designList, 2, scriptOut)) {
00556        fprintf(vis_stdout, "ERROR : can't execute '%s' for design '%s'\n", config->newVisNickName, designList->designNickName);
00557     }
00562     if(Rt_CompareResult(config, designList, config->bRefOnly)) {
00563        fprintf(vis_stdout, "ERROR : can't compare result for design '%s'\n", designList->designNickName);
00564     }
00565     fprintf(vis_stdout, "%s complete.. (%d/%d)\n", designList->designNickName, i+1, array_n(designArr));
00566 
00572     if(config->scriptFile == 0) {
00573       if(config->bRefRun || config->bNewRun)
00574         Rt_WriteResult(config, i+1);
00575     }
00576   }
00577 
00581   if(config->scriptFile == 0)
00582     if(Rt_WriteResult(config, array_n(designArr)))      return(1);
00583   alarm(0);
00584 
00585   Rt_FreeRtConfig(config);
00586   if(scriptOut) fclose(scriptOut);
00587   return 0;
00588 }
00589 
00607 static int
00608 RtCheckInputFileAvailability(
00609   RtConfigs_t *config, 
00610   RtDesignLists_t *designList,
00611   int withWarning)
00612 {
00613   st_table *keyTable;
00614   st_generator *gen;
00615   int errorFlag;
00616   char *keyWord;
00617 
00618   keyTable = config->keyWordTable;
00619   if(keyTable == 0)     return(0);
00620   errorFlag = 0;
00621   st_foreach_item(keyTable, gen, &keyWord, NIL(char *)) {
00622     if(!strcasecmp(keyWord, "$CtlFile") && !designList->ctlFile) {
00623       if(withWarning)
00624       fprintf(vis_stdout, "WARNING : Template contains the '$CtlFile', but not in design list\n");
00625       errorFlag = 1;
00626     }
00627     else if(!strcasecmp(keyWord, "$OrdFile") && !designList->ordFile) {
00628       if(withWarning)
00629       fprintf(vis_stdout, "WARNING : Template contains the '$OrdFile', but not in design list\n");
00630       errorFlag = 1;
00631     }
00632     else if(!strcasecmp(keyWord, "$InvFile")&& !designList->invFile) {
00633       if(withWarning)
00634       fprintf(vis_stdout, "WARNING : Template contains the '$InvFile', but not in design list\n");
00635       errorFlag = 1;
00636     }
00637     else if(!strcasecmp(keyWord, "$FairFile")&& !designList->fairFile) {
00638       if(withWarning)
00639       fprintf(vis_stdout, "WARNING : Template contains the '$FairFile', but not in design list\n");
00640       errorFlag = 1;
00641     }
00642     else if(!strcasecmp(keyWord, "$LeFile")&& !designList->leFile) {
00643       if(withWarning)
00644       fprintf(vis_stdout, "WARNING : Template contains the '$LeFile', but not in design list\n");
00645       errorFlag = 1;
00646     }
00647     else if(!strcasecmp(keyWord, "$LtlFile")&& !designList->ltlFile) {
00648       if(withWarning)
00649       fprintf(vis_stdout, "WARNING : Template contains the '$LtlFile', but not in design list\n");
00650       errorFlag = 1;
00651     }
00652     else if(!strcasecmp(keyWord, "$HintFile")&& !designList->hintFile) {
00653       if(withWarning)
00654       fprintf(vis_stdout, "WARNING : Template contains the '$HintFile', but not in design list\n");
00655       errorFlag = 1;
00656     }
00657   }
00658   if(errorFlag == 1)    return(1);
00659   else                  return(0);
00660 }
00661 
00682 static int
00683 Rt_WriteResult(RtConfigs_t *config, int size)
00684 {
00685   FILE *fout;
00686   array_t *cResultArr, *cResultArr2;
00687   array_t *cResultArrSample, *cItemArrSample, *cItemArrSampleMax;
00688   array_t *cItemArr, *cItemArr2, *designArr;
00689   array_t *pArr, *pArr2, *pArrSample;
00690   RtCommandResults_t *cResult, *cResult2, *cResultSample;
00691   RtCompareItems_t *cItem, *cItem2, *cItemSample;
00692   RtDesignLists_t *designList;
00693   RtResultPropertys_t *rProp, *rProp2;
00694   int i, j, k, first_flag;
00695   int property_flag;
00696   int lineNo, estLineNo, errorFlag;
00697   char newName[1024], endStr[10];
00698   char newNName[1024], refNName[1024];
00699   char newTimeout[1024], refTimeout[1024];
00700   double value1, value2;
00701   int lastFailedIndex;
00702   array_t *cResultArrMax;
00703   array_t *cItemArrMax;
00704   double *resultArr;
00705   double totalNum;
00706   double gap;
00707 
00708   pArrSample = 0;
00709   if(!(fout = fopen(config->resultForPerformance, "w"))) {
00710     fprintf(vis_stdout, "Error : Can't open result file '%s'\n", config->resultForPerformance);
00711     return(1);
00712   }
00713   designArr = config->designListArr;
00714 
00718   cItemArrSample = 0;
00719   cResultArrSample = NIL(array_t);
00720   for(k=0; k<array_n(designArr) && k<size; k++) {
00721     designList = array_fetch(RtDesignLists_t *, designArr, k);
00722     cResultArrSample = designList->resultForCommandArr1;
00723     errorFlag = 0;
00724     if(cResultArrSample)        {
00725       for(i=0; i<array_n(cResultArrSample); i++) {
00726         cResult = array_fetch(RtCommandResults_t *, cResultArrSample, i);
00727         cItemArrSample = cResult->compareItemArr;
00728         if(cItemArrSample == NIL(array_t)) {
00729           errorFlag = 1;
00730           break;
00731         }
00732       }
00733     }
00734     if(errorFlag == 0)  break;
00735   }
00736   if(cResultArrSample == NIL(array_t)) {
00737      fprintf(fout, "ERROR : Can't find any output for your design list\n");
00738      fclose(fout);
00739      return(1);
00740   }
00741 
00743   fprintf(fout, "\\documentclass[plain]{article}\n");
00744   fprintf(fout, "\\usepackage{lscape}\n");
00745   fprintf(fout, "\\begin{document}\n");
00746   fprintf(fout, "\\setlength{\\oddsidemargin}{-0.5in}\n");
00751   for(i=0; i<array_n(cResultArrSample); i++) {
00752 
00753     fprintf(fout, "\\begin{table}\n");
00754     cResult = array_fetch(RtCommandResults_t *, cResultArrSample, i);
00755     cItemArrSample = cResult->compareItemArr;
00756  
00757     cItemArrSampleMax = cItemArrSample;
00758     for(k=0; k<array_n(designArr) && k<size; k++) {
00759       designList = array_fetch(RtDesignLists_t *, designArr, k);
00760       cResultArr = designList->resultForCommandArr1;
00761       if(cResultArr)    {
00762           if(array_n(cResultArr) > i) 
00763               cResult = array_fetch(RtCommandResults_t *, cResultArr, i);
00764           else
00765               cResult = 0;
00766           if(!cResult)  continue;
00767           cItemArrSample = cResult->compareItemArr;
00768           if(cItemArrSample && array_n(cItemArrSample) > array_n(cItemArrSampleMax)) {
00769             cItemArrSampleMax = cItemArrSample;
00770           }
00771       }
00772     }
00773     cItemArrSample = cItemArrSampleMax;
00774     if(cItemArrSample == 0) {
00775        fprintf(fout, "ERROR : Can't find any output for your design list\n");
00776        fclose(fout);
00777        return(1);
00778     }
00779       
00780     cResult = array_fetch(RtCommandResults_t *, cResultArrSample, i);
00781     Rt_RemoveUnderscore(cResult->command, newName);
00782     Rt_RemoveUnderscore(config->referenceVisNickName, refNName);
00783     Rt_RemoveUnderscore(config->newVisNickName, newNName);
00784     fprintf(fout, "\\caption{Performance Comparison Table of %s for %s(ref) and %s(new)}\n",
00785         newName, refNName, newNName);
00786     fprintf(fout, "\\begin{center}\n");
00787     fprintf(fout, "\\begin{tabular}{|c||");
00788     for(j=0; j<array_n(cItemArrSample); j++) {
00789       fprintf(fout, "c|c|c|");
00790     }
00791     fprintf(fout, "} \\hline \n");
00792     fprintf(fout, " &");
00793     Rt_RemoveUnderscore(cResult->command, newName);
00794     fprintf(fout, "\\multicolumn{%d}{c|}{%s} ", array_n(cItemArrSample)*3, newName);
00795     fprintf(fout, "\\\\ \\cline{2-%d}\n", array_n(cItemArrSample)*3+1);
00796   
00797     fprintf(fout, " &");
00798     for(j=0; j<array_n(cItemArrSample); j++) {
00799       cItem = array_fetch(RtCompareItems_t *, cItemArrSample, j);
00800       if(j+1 == array_n(cItemArrSample)) 
00801         fprintf(fout, "\\multicolumn{3}{c|}{%s}", cItem->itemNickName);
00802       else 
00803         fprintf(fout, "\\multicolumn{3}{c|}{%s} &", cItem->itemNickName);
00804     }
00805     fprintf(fout, "\\\\ \\cline{2-%d}\n",array_n(cItemArrSample)*3+1);
00806   
00807     fprintf(fout, "Design &");
00808     for(j=0; j<array_n(cItemArrSample); j++) {
00809       if(j+1 == array_n(cItemArrSample)) 
00810         fprintf(fout, "ref & new & (\\%%)");
00811       else 
00812         fprintf(fout, "ref & new & (\\%%) &");
00813     }
00814     fprintf(fout, "\\\\ \\hline \\hline\n");
00815   
00816     lineNo = 0;
00817     for(k=0; k<array_n(designArr) && k<size ; k++) {
00818       lineNo++;
00819   
00824       if(lineNo == 31) {
00825         fprintf(fout, "\\end{tabular}\n");
00826         fprintf(fout, "\\end{center}\n");
00827         fprintf(fout, "\\end{table}\n");
00828         fprintf(fout, "\\clearpage\n");
00829   
00830         fprintf(fout, "\\begin{table}\n");
00831         cResult = array_fetch(RtCommandResults_t *, cResultArrSample, i);
00832         cItemArrSample = cResult->compareItemArr;
00833         Rt_RemoveUnderscore(cResult->command, newName);
00834         Rt_RemoveUnderscore(config->referenceVisNickName, refNName);
00835         Rt_RemoveUnderscore(config->newVisNickName, newNName);
00836         fprintf(fout, "\\caption{Performance Comparison Table of %s for %s(ref) and %s(new)}\n",
00837             newName, refNName, newNName);
00838         fprintf(fout, "\\begin{center}\n");
00839         fprintf(fout, "\\begin{tabular}{|c||");
00840         for(j=0; j<array_n(cItemArrSample); j++) {
00841           fprintf(fout, "c|c|c|");
00842         }
00843         fprintf(fout, "} \\hline \n");
00844         fprintf(fout, " &");
00845         Rt_RemoveUnderscore(cResult->command, newName);
00846         fprintf(fout, "\\multicolumn{%d}{c|}{%s} ", array_n(cItemArrSample)*3, newName);
00847         fprintf(fout, "\\\\ \\cline{2-%d}\n", array_n(cItemArrSample)*3+1);
00848       
00849         fprintf(fout, " &");
00850         for(j=0; j<array_n(cItemArrSample); j++) {
00851           cItem = array_fetch(RtCompareItems_t *, cItemArrSample, j);
00852           if(j+1 == array_n(cItemArrSample)) 
00853             fprintf(fout, "\\multicolumn{3}{c|}{%s}", cItem->itemNickName);
00854           else 
00855             fprintf(fout, "\\multicolumn{3}{c|}{%s} &", cItem->itemNickName);
00856         }
00857         fprintf(fout, "\\\\ \\cline{2-%d}\n",array_n(cItemArrSample)*3+1);
00858       
00859         fprintf(fout, "Design &");
00860         for(j=0; j<array_n(cItemArrSample); j++) {
00861           if(j+1 == array_n(cItemArrSample)) 
00862             fprintf(fout, "ref & new & (\\%%)");
00863           else 
00864             fprintf(fout, "ref & new & (\\%%) &");
00865         }
00866         fprintf(fout, "\\\\ \\hline \\hline\n");
00867       
00868         lineNo = 1;
00869       }
00870       designList = array_fetch(RtDesignLists_t *, designArr, k);
00871       strcpy(newTimeout, "-");
00872       strcpy(refTimeout, "-");
00873       if(RtCheckInputFileAvailability(config, designList, 0)) {
00874         continue;
00875       }
00876       cResultArr = designList->resultForCommandArr1;
00877       cResultArr2 = designList->resultForCommandArr2;
00878       Rt_RemoveUnderscore(designList->designNickName, newName);
00879       fprintf(fout, "%s\t&", newName);
00880       if(cResultArr && array_n(cResultArr) > i)
00881         cResult = array_fetch(RtCommandResults_t *, cResultArr, i);
00882       else 
00883         cResult = 0;
00884   
00885       if(cResultArr2 && array_n(cResultArr2) > i)
00886         cResult2 = array_fetch(RtCommandResults_t *, cResultArr2, i);
00887       else 
00888         cResult2 = 0;
00889   
00890       if(cResult && cResult->bTimeOut)   {
00891         strcpy(refTimeout, "TimeOut");
00892       }
00893       if(cResult2 && cResult2->bTimeOut) {
00894         strcpy(newTimeout, "TimeOut");
00895       }
00896   
00897       if(cResult)
00898         cItemArr = cResult->compareItemArr;
00899       else
00900         cItemArr = 0;
00901       if(cResult2)
00902         cItemArr2 = cResult2->compareItemArr;
00903       else
00904         cItemArr2 = 0;
00905   
00906       if(cItemArr == 0 && cItemArr2 == 0)       {
00907         fprintf(vis_stdout, "Warning : no result for design '%s'\n", designList->designNickName);
00908         for(j=0; j<array_n(cItemArrSample); j++) {
00909           if(j+1 == array_n(cItemArrSample)) 
00910             fprintf(fout, " %s\t& %s\t& -\t", refTimeout, newTimeout);
00911           else 
00912             fprintf(fout, " %s\t& %s\t& -\t&", refTimeout, newTimeout);
00913         }
00914         fprintf(fout, "\\\\ \\hline\n");
00915         continue;
00916       }
00917       else if(cItemArr && cItemArr2) {
00918         if(array_n(cItemArr) != array_n(cItemArr2)) {
00919           fprintf(vis_stdout, "Warning : Can't make table for the compare item,\n");
00920           fprintf(vis_stdout, "           since they are different for '%s'\n", designList->designNickName);
00921           fprintf(vis_stdout, "           Please check your template file again.\n");
00922           for(j=0; j<array_n(cItemArrSample); j++) {
00923             if(j+1 == array_n(cItemArrSample)) 
00924               fprintf(fout, " %s\t& %s\t& -\t", refTimeout, newTimeout);
00925             else 
00926               fprintf(fout, " %s\t& %s\t& -\t&", refTimeout, newTimeout);
00927           }
00928           fprintf(fout, "\\\\ \\hline\n");
00929           continue;
00930         }
00931       }
00932       if(cItemArr)      cItemArrSample = cItemArr;
00933       else              cItemArrSample = cItemArr2;
00934       for(j=0; j<array_n(cItemArrSample); j++) {
00935         if(cItemArr) 
00936           cItem = array_fetch(RtCompareItems_t *, cItemArr, j);
00937         else
00938           cItem = 0;
00939         if(cItemArr2) 
00940           cItem2 = array_fetch(RtCompareItems_t *, cItemArr2, j);
00941         else
00942           cItem2 = 0;
00943     
00944         if(cItem)       sscanf(cItem->value, "%lf", &value1);
00945         if(cItem2)      sscanf(cItem2->value, "%lf", &value2);
00946   
00947         endStr[0] = '\0';
00948         if(j+1 != array_n(cItemArrSample))      {
00949           endStr[0] = '&';
00950           endStr[1] = '\0';
00951         }
00952         if(cItem2 && cItem) {
00953           fprintf(fout, "%s\t& %s\t& %.2f\t%s", cItem->value, cItem2->value, (value1-value2)/value1*100, endStr);
00954         }
00955         else if(cItem)  {
00956           fprintf(fout, "%s\t& %s\t& -\t%s", cItem->value, newTimeout, endStr);
00957         }
00958         else if(cItem2)  {
00959           fprintf(fout, "%s\t& %s\t& -\t%s", refTimeout, cItem2->value, endStr);
00960         }
00961       }
00962       fprintf(fout, "\\\\ \\hline\n");
00963     }
00964     fprintf(fout, "\\end{tabular}\n");
00965     fprintf(fout, "\\end{center}\n");
00966     fprintf(fout, "\\end{table}\n");
00967     fprintf(fout, "\\clearpage\n");
00968   }
00969 
00970   property_flag = 0;
00971   for(k=0; k<array_n(designArr) && k<size; k++) {
00972     designList = array_fetch(RtDesignLists_t *, designArr, k);
00973     cResultArr = designList->resultForCommandArr1;
00974     if(cResultArr)       {
00975       for(i=0; i<array_n(cResultArr); i++) {
00976         cResult = array_fetch(RtCommandResults_t *, cResultArr, i);
00977         pArr = cResult->resultForProperty;
00978         if(pArr && array_n(pArr) > 0)   {
00979           property_flag = 1;
00980           break;
00981         }
00982       }
00983     }
00984     cResultArr = designList->resultForCommandArr2;
00985     if(cResultArr)       {
00986       for(i=0; i<array_n(cResultArr); i++) {
00987         cResult = array_fetch(RtCommandResults_t *, cResultArr, i);
00988         pArr = cResult->resultForProperty;
00989         if(pArr && array_n(pArr) > 0)   {
00990           property_flag = 1;
00991           break;
00992         }
00993       }
00994     }
00995     if(property_flag)   break;
00996   }
00997 
01002   if(property_flag == 1) {
01003     fprintf(fout, "\\begin{table}\n");
01004     Rt_RemoveUnderscore(config->referenceVisNickName, refNName);
01005     Rt_RemoveUnderscore(config->newVisNickName, newNName);
01006     fprintf(fout, "\\caption{Property Comparison Table for %s(ref) \
01007     and %s(new)}\n", refNName, newNName);
01008     fprintf(fout, "\\begin{center}\n");
01009     fprintf(fout, "\\begin{tabular}{|c||c|c||c|c|c||c|c|c||c|} \\hline\n");
01010     fprintf(fout, " & & & \\multicolumn{3}{c||}{ Property(ref) } & \\multicolumn{3}{c||}{ Property(new) } & \\multicolumn{1}{c|}{ Remark }\\\\ \\cline{4-10}\n");
01011     fprintf(fout, "Design & command & index & F or P & cex len & line len  & F or P & cex len  & line len& \\\\ \\hline\n");
01012   
01013     lineNo = 0;
01014     for(k=0; k<array_n(designArr) && k<size; k++) {
01015       designList = array_fetch(RtDesignLists_t *, designArr, k);
01016       if(RtCheckInputFileAvailability(config, designList, 0)) {
01017         continue;
01018       }
01019       cResultArr = designList->resultForCommandArr1;
01020       cResultArr2 = designList->resultForCommandArr2;
01021       if(cResultArr == 0 && cResultArr2 == 0) {
01022         fprintf(vis_stdout, "ERROR : '%s' didn't run properly\n", designList->designNickName);
01023         continue;
01024       }
01025       else if(cResultArr == 0 ) {
01026         cResultArrSample = cResultArr2;
01027       }
01028       else if(cResultArr2 == 0 ) {
01029         cResultArrSample = cResultArr;
01030       }
01031       else {
01032         cResultArrSample = cResultArr;
01033       }
01034   
01035       strcpy(refTimeout, "-");
01036       strcpy(newTimeout, "-");
01037   
01038       first_flag = 0;
01039       for(i=0; i<array_n(cResultArrSample); i++) {
01040         if(cResultArr && array_n(cResultArr) > i)
01041           cResult = array_fetch(RtCommandResults_t *, cResultArr, i);
01042         else
01043           cResult = 0;
01044         if(cResultArr2 && array_n(cResultArr2) > i)
01045           cResult2 = array_fetch(RtCommandResults_t *, cResultArr2, i);
01046         else 
01047           cResult2 = 0;
01048   
01049         if(cResult == 0 && cResult2 == 0)       continue;
01050   
01051         if(cResult && cResult->bTimeOut)         {
01052           strcpy(refTimeout, "TimeOut");
01053         }
01054         if(cResult2 && cResult2->bTimeOut) {
01055           strcpy(newTimeout, "TimeOut");
01056         }
01057   
01058         else if((cResult && !cResult->resultForProperty) &&
01059                 (cResult2 && !cResult2->resultForProperty))     continue;
01060   
01061         if(cResult)
01062           pArr = cResult->resultForProperty;
01063         else
01064           pArr = 0;
01065         if(cResult2)
01066           pArr2 = cResult2->resultForProperty;
01067         else
01068           pArr2 = 0;
01069   
01070         if((!pArr || array_n(pArr) < 1) && (!pArr2 || array_n(pArr2) < 1)) {
01071           continue;
01072         }
01073         else if(pArr && array_n(pArr) >= 1) {
01074           pArrSample = pArr;
01075         }
01076         else if(pArr2 && array_n(pArr2) >= 1) {
01077           pArrSample = pArr2;
01078         }
01079   
01080         estLineNo = 0;
01081         lastFailedIndex = -1;
01082         for(j=0; j<array_n(pArrSample); j++) {
01083           if(pArr && array_n(pArr) > j) 
01084             rProp = array_fetch(RtResultPropertys_t *, pArr, j);
01085           else
01086             rProp = 0;
01087           if(pArr2 && array_n(pArr2) > j) 
01088             rProp2 = array_fetch(RtResultPropertys_t *, pArr2, j);
01089           else
01090             rProp2 = 0;
01091   
01092           if((rProp && !strncasecmp(rProp->failOrPass, "pass", 4)) && 
01093               (rProp2 && !strncasecmp(rProp2->failOrPass, "pass", 4))) {
01094           }
01095           else {
01096             estLineNo++;
01097             lastFailedIndex = j;
01098           }
01099   
01100         }
01101   
01106         if(lineNo + estLineNo > 40) {
01107           fprintf(fout, "\\hline\n");
01108           fprintf(fout, "\\end{tabular}\n");
01109           fprintf(fout, "\\end{center}\n");
01110           fprintf(fout, "\\end{table}\n");
01111           fprintf(fout, "\\clearpage\n");
01112           fprintf(fout, "\\begin{table}\n");
01113           Rt_RemoveUnderscore(config->referenceVisNickName, refNName);
01114           Rt_RemoveUnderscore(config->newVisNickName, newNName);
01115           fprintf(fout, "\\caption{Property Comparison Table for \
01116           %s(ref) and %s(new)}\n", refNName, newNName);
01117           fprintf(fout, "\\begin{center}\n");
01118           fprintf(fout, "\\begin{tabular}{|c||c|c||c|c|c||c|c|c||c|} \\hline\n");
01119           fprintf(fout, " & & & \\multicolumn{3}{c||}{ Property(ref) } & \\multicolumn{3}{c||}{ Property(new) } & \\multicolumn{1}{c|}{ Remark }\\\\ \\cline{4-10}\n");
01120           fprintf(fout, "Design & command & index & F or P & cex len & line len  & F or P & cex len  & line len& \\\\ \\hline\n");
01121           lineNo = 0;
01122         }
01123           
01124         Rt_RemoveUnderscore(designList->designNickName, newName);
01125         if(first_flag==0) {
01126           fprintf(fout, "%s &", newName);
01127           first_flag = 1;
01128         }
01129         else
01130           fprintf(fout, " &");
01131   
01132         for(j=0; j<array_n(pArrSample); j++) {
01133   
01134           lineNo++;
01135           if(pArr && array_n(pArr) > j) 
01136             rProp = array_fetch(RtResultPropertys_t *, pArr, j);
01137           else
01138             rProp = 0;
01139           if(pArr2 && array_n(pArr2) > j) 
01140             rProp2 = array_fetch(RtResultPropertys_t *, pArr2, j);
01141           else
01142             rProp2 = 0;
01143             
01144           if(rProp && !strncasecmp(rProp->failOrPass, "pass", 4) && 
01145              rProp2 && !strncasecmp(rProp2->failOrPass, "pass", 4)) {
01146             if(j==0 && estLineNo == 0) {
01147               if(cResult)
01148                  Rt_RemoveUnderscore(cResult->command, newName);
01149               else 
01150                  Rt_RemoveUnderscore(cResult2->command, newName);
01151               fprintf(fout, " %s & [%d] & passed & passed & - & passed & passed & - & \\\\ ", newName, rProp->index+1);
01152               if(j+1 == array_n(pArrSample) && i+1 == array_n(cResultArrSample)) 
01153                 fprintf(fout, " \\hline\n");
01154               else if(j+1 == array_n(pArrSample))
01155                 fprintf(fout, " \\cline{2-10}\n");
01156               else if(lastFailedIndex <= j && i+1 == array_n(cResultArrSample))   
01157                 fprintf(fout, " \\hline\n");
01158               else if(lastFailedIndex <= j)   
01159                 fprintf(fout, " \\cline{2-10}\n");
01160               else 
01161                 fprintf(fout, " \\cline{4-10}\n");
01162             }
01163             else {
01164               lineNo--;
01165             }
01166             continue;
01167           }
01168   
01169     
01170           if(first_flag==1) {
01171             if(cResult) {
01172               Rt_RemoveUnderscore(cResult->command, newName);
01173               fprintf(fout, " %s & ", newName);
01174             }
01175             else if(cResult2) {
01176               Rt_RemoveUnderscore(cResult2->command, newName);
01177               fprintf(fout, " %s & ", newName);
01178             }
01179             first_flag = 2;
01180           }
01181           else {
01182             fprintf(fout, " & & ");
01183           }
01184   
01185           if(rProp) {
01186             if(rProp->lengthOfInv != -1) 
01187               fprintf(fout, " [%d] & %s & (%d,-) & %d &", rProp->index+1, rProp->failOrPass, rProp->lengthOfInv, rProp->lengthOfCounterExample);
01188             else if(rProp->lengthOfStem == -1 && rProp->lengthOfCycle == -1)
01189               fprintf(fout, " [%d] & %s & - & - &", rProp->index+1, rProp->failOrPass);
01190             else 
01191               fprintf(fout, " [%d] & %s & (%d,%d) & %d & ", rProp->index+1, rProp->failOrPass, rProp->lengthOfStem, rProp->lengthOfCycle,rProp->lengthOfCounterExample );
01192           }
01193           else {
01194             if(rProp2)
01195               fprintf(fout, " [%d] & %s & %s & - & ", rProp2->index+1, refTimeout, refTimeout);
01196             else 
01197               fprintf(fout, " & %s & %s & - & ", refTimeout, refTimeout);
01198           }
01199   
01200           if(rProp2) {
01201             if(rProp2->lengthOfInv != -1) 
01202               fprintf(fout, " %s & (%d,-) & %d ", rProp2->failOrPass,
01203               rProp2->lengthOfInv,rProp2->lengthOfCounterExample );
01204             else if(rProp2->lengthOfStem == -1 && rProp2->lengthOfCycle == -1)
01205               fprintf(fout, " %s & - & - ", rProp2->failOrPass);
01206             else 
01207               fprintf(fout, " %s & (%d,%d) & %d ", rProp2->failOrPass,
01208               rProp2->lengthOfStem, rProp2->lengthOfCycle, rProp2->lengthOfCounterExample);
01209           }
01210           else {
01211             fprintf(fout, " %s & %s & - ", newTimeout, newTimeout);
01212           }
01213   
01214           endStr[0] = '\0';
01215           if(rProp2 && rProp) {
01216              if(rProp->failOrPass == 0 && rProp2->failOrPass)
01217                strcpy(endStr, "Check");
01218              else if(rProp->failOrPass && rProp2->failOrPass == 0)
01219                strcpy(endStr, "Check");
01220              if(rProp->failOrPass == 0 && rProp2->failOrPass == 0)
01221                strcpy(endStr, "Check");
01222              if(strcmp(rProp->failOrPass, rProp2->failOrPass))
01223                strcpy(endStr, "Check");
01224              else if(rProp->lengthOfStem != rProp2->lengthOfStem) 
01225                strcpy(endStr, "Check");
01226              else if(rProp->lengthOfCycle != rProp2->lengthOfCycle)
01227                strcpy(endStr, "Check");
01228              else if(rProp->lengthOfInv != rProp2->lengthOfInv)
01229                strcpy(endStr, "Check");
01230           }
01231           else {
01232             strcpy(endStr, "Check");
01233           }
01234           if(j+1 == array_n(pArrSample) && i+1 == array_n(cResultArrSample)) 
01235             fprintf(fout, " & %s \\\\ \\hline\n",endStr);
01236           else if(j+1 == array_n(pArrSample))
01237             fprintf(fout, " & %s \\\\ \\cline{2-10}\n",endStr);
01238           else if(lastFailedIndex <= j && i+1 == array_n(cResultArrSample))   
01239             fprintf(fout, " & %s \\\\ \\hline\n", endStr);
01240           else if(lastFailedIndex <= j)   
01241             fprintf(fout, " & %s \\\\ \\cline{2-10}\n", endStr);
01242           else 
01243             fprintf(fout, " & %s \\\\ \\cline{4-10}\n",endStr);
01244         }
01245       }
01246     }
01247   
01248     fprintf(fout, "\\end{tabular}\n");
01249     fprintf(fout, "\\end{center}\n");
01250     fprintf(fout, "\\end{table}\n");
01251     fprintf(fout, "\\clearpage\n");
01252   }
01253 
01254 
01258   fprintf(fout, "\\begin{table}\n");
01259   Rt_RemoveUnderscore(config->referenceVisNickName, refNName);
01260   Rt_RemoveUnderscore(config->newVisNickName, newNName);
01261   fprintf(fout, "\\caption{Summary for %s(ref) and %s(new)}\n", refNName, newNName);
01262   fprintf(fout, "\\begin{center}\n");
01263   fprintf(fout, "\\begin{tabular}{|c|c||c|c|c|c||r|r|} \\hline\n");
01264   fprintf(fout, " command & item & \\multicolumn{4}{c||}{ %s } & \\multicolumn{2}{c|}{ geo-mean } \\\\ \\cline{3-8}\n", newNName);
01265   fprintf(fout, " & & win & lose & tie & NA & ref & new \\\\ \\hline \\hline\n");
01266 
01267   cResultArrMax = 0;
01268   for(k=0; k<array_n(designArr) && k<size; k++) {
01269     designList = array_fetch(RtDesignLists_t *, designArr, k);
01270     cResultArr = designList->resultForCommandArr1;
01271     if(cResultArrMax == 0)      cResultArrMax = cResultArr;
01272     else if(cResultArr && array_n(cResultArr) > array_n(cResultArrMax)) {
01273        cResultArrMax = cResultArr;
01274     }
01275   }
01276 
01277   resultArr = ALLOC(double, 6); 
01278   for(i=0; i<array_n(cResultArrMax); i++) {
01279     cResultSample = array_fetch(RtCommandResults_t *, cResultArrMax, i);
01280     fprintf(fout, " %s & ", cResultSample->command);
01281     first_flag = 1;
01282 
01283     cItemArrMax = 0;
01284     for(k=0; k<array_n(designArr) && k<size; k++) {
01285       designList = array_fetch(RtDesignLists_t *, designArr, k);
01286       cResultArr = designList->resultForCommandArr1;
01287       if(cResultArr)    {
01288           if(array_n(cResultArr) > i) 
01289               cResult = array_fetch(RtCommandResults_t *, cResultArr, i);
01290           else
01291               continue;
01292           cItemArrSample = cResult->compareItemArr;
01293           if(cItemArrMax == 0)  cItemArrMax = cItemArrSample;
01294           else if(cItemArrSample && array_n(cItemArrSample) > array_n(cItemArrMax)) {
01295             cItemArrMax = cItemArrSample;
01296           }
01297       }
01298     }
01299 
01300     for(j=0; j<6; j++)  resultArr[j] = 0.0;
01301     resultArr[4] = 1.0;
01302     resultArr[5] = 1.0;
01303 
01304     for(j=0; j<array_n(cItemArrMax); j++) {
01305       for(k=0; k<6; k++)        resultArr[k] = 0.0;
01306       resultArr[4] = 1.0;
01307       resultArr[5] = 1.0;
01308 
01309       cItemSample = array_fetch(RtCompareItems_t *, cItemArrMax, j);
01310       if(first_flag) {
01311         fprintf(fout, "%s &\n", cItemSample->itemNickName);
01312         first_flag = 0;
01313       }
01314       else {
01315         fprintf(fout, " & %s &\n", cItemSample->itemNickName);
01316       }
01317 
01318       for(k=0; k<array_n(designArr) && k<size; k++) {
01319         designList = array_fetch(RtDesignLists_t *, designArr, k);
01320         if(designList->resultForCommandArr1 == 0 ||
01321            designList->resultForCommandArr2 == 0) {
01322            resultArr[3] = resultArr[3] + 1.0;
01323            continue;
01324         }
01325         if(array_n(designList->resultForCommandArr1) <= i ||
01326            array_n(designList->resultForCommandArr2) <= i) {
01327            resultArr[3] = resultArr[3] + 1.0;
01328            continue;
01329         }
01330         cResult = array_fetch(RtCommandResults_t *, designList->resultForCommandArr1, i);
01331         cResult2 = array_fetch(RtCommandResults_t *, designList->resultForCommandArr2, i);
01332         if(cResult == 0 || cResult2 == 0) {
01333            resultArr[3] = resultArr[3] + 1.0;
01334            continue;
01335         }
01336         if(cResult->compareItemArr == 0 ||
01337            cResult2->compareItemArr == 0) {
01338            resultArr[3] = resultArr[3] + 1.0;
01339            continue;
01340         }
01341         if(array_n(cResult->compareItemArr) <= j ||
01342            array_n(cResult2->compareItemArr) <= j) {
01343            resultArr[3] = resultArr[3] + 1.0;
01344            continue;
01345         }
01346         cItem = array_fetch(RtCompareItems_t *, cResult->compareItemArr, j);
01347         cItem2 = array_fetch(RtCompareItems_t *, cResult2->compareItemArr, j);
01348         if(cItem == 0 || cItem2 == 0) {
01349            resultArr[3] = resultArr[3] + 1.0;
01350            continue;
01351         }
01352 
01353         value1 = atof(cItem->value);
01354         value2 = atof(cItem2->value);
01355         if(value1 > value2)     gap = value2;
01356         else                    gap = value1;
01357         gap = gap * 0.02;
01358         if(gap < 1.0)   gap = 1.0;
01359 
01360         if(value1 > value2 + gap)       resultArr[0] = resultArr[0] + 1.0; 
01361         else if(value1+gap < value2)    resultArr[1] = resultArr[1] + 1.0; 
01362         else                            resultArr[2] += 1.0; 
01363       }
01364       totalNum = resultArr[0] + resultArr[1] + resultArr[2];
01365       totalNum = 1.0/totalNum;
01366       for(k=0; k<array_n(designArr) && k<size; k++) {
01367         designList = array_fetch(RtDesignLists_t *, designArr, k);
01368         if(designList->resultForCommandArr1 == 0 ||
01369            designList->resultForCommandArr2 == 0) {
01370            continue;
01371         }
01372         if(array_n(designList->resultForCommandArr1) <= i ||
01373            array_n(designList->resultForCommandArr2) <= i) {
01374            continue;
01375         }
01376         cResult = array_fetch(RtCommandResults_t *, designList->resultForCommandArr1, i);
01377         cResult2 = array_fetch(RtCommandResults_t *, designList->resultForCommandArr2, i);
01378         if(cResult == 0 || cResult2 == 0) {
01379            continue;
01380         }
01381         if(cResult->compareItemArr == 0 ||
01382            cResult2->compareItemArr == 0) {
01383            continue;
01384         }
01385         if(array_n(cResult->compareItemArr) <= j ||
01386            array_n(cResult2->compareItemArr) <= j) {
01387            continue;
01388         }
01389         cItem = array_fetch(RtCompareItems_t *, cResult->compareItemArr, j);
01390         cItem2 = array_fetch(RtCompareItems_t *, cResult2->compareItemArr, j);
01391         if(cItem == 0 || cItem2 == 0) {
01392            continue;
01393         }
01394 
01395         value1 = atof(cItem->value);
01396         value2 = atof(cItem2->value);
01397         if(value1 == 0.0)       value1 = 1.0;
01398         else                    value1 = pow(value1, totalNum);
01399         if(value2 == 0.0)       value2 = 1.0;
01400         else                    value2 = pow(value2, totalNum);
01401 
01402         resultArr[4] *= value1;
01403         resultArr[5] *= value2;
01404       }
01405 
01406       if(array_n(cItemArrMax) == j+1 ) {
01407         fprintf(fout, " %d & %d & %d & %d & %.3f & %.3f \\\\ \\hline\n", 
01408                     (int)resultArr[0], (int)resultArr[1], (int)resultArr[2],
01409                     (int)resultArr[3], resultArr[4], resultArr[5]);
01410       }
01411       else {
01412         fprintf(fout, " %d & %d & %d & %d & %.3f & %.3f \\\\ \\cline{2-8}\n", 
01413                     (int)resultArr[0], (int)resultArr[1], (int)resultArr[2],
01414                     (int)resultArr[3], resultArr[4], resultArr[5]);
01415       }
01416     }
01417   }
01418   free(resultArr);
01419   fprintf(fout, "\\end{tabular}\n");
01420   fprintf(fout, "\\end{center}\n");
01421   fprintf(fout, "\\end{table}\n");
01422 
01423   fprintf(fout, "\\begin{itemize}\n");
01424   Rt_RemoveUnderscore(config->configurationFile, newName);
01425   fprintf(fout, "\\item configuration file : %s\n", newName);
01426   Rt_RemoveUnderscore(config->designDirectory, newName);
01427   fprintf(fout, "\\item design directory : %s\n", newName);
01428   Rt_RemoveUnderscore(config->designList, newName);
01429   fprintf(fout, "\\item design list : %s\n", newName);
01430   Rt_RemoveUnderscore(config->referenceOutDirectory, newName);
01431   fprintf(fout, "\\item reference output dir : %s\n", newName);
01432   Rt_RemoveUnderscore(config->referenceVis, newName);
01433   fprintf(fout, "\\item reference executable : %s\n", newName);
01434   Rt_RemoveUnderscore(config->refCommandTemplate, newName);
01435   fprintf(fout, "\\item reference template : %s\n", newName);
01436   Rt_RemoveUnderscore(config->newOutDirectory, newName);
01437   fprintf(fout, "\\item new output dir : %s\n", newName);
01438   Rt_RemoveUnderscore(config->newVis, newName);
01439   fprintf(fout, "\\item new executable : %s\n", newName);
01440   Rt_RemoveUnderscore(config->newCommandTemplate, newName);
01441   fprintf(fout, "\\item new template : %s\n", newName);
01442   fprintf(fout, "\\end{itemize}\n");
01443   fprintf(fout, "\\clearpage\n");
01444 
01445   fprintf(fout, "\\end{document}\n");
01446   fclose(fout);
01447   fprintf(vis_stdout, "'%s' file was generated as result of regression_test\n", 
01448                config->resultForPerformance);
01449   return(0);
01450 }
01451 
01464 static void
01465 Rt_RemoveUnderscore(char *name, 
01466                     char *newName)
01467 {
01468 int i, index ;
01469 
01470   index = 0;
01471   for(i=0; name[i] != '\0'; i++) {
01472     if(name[i] == '_') {
01473       newName[index++] = '\\';
01474     }
01475     newName[index++] = name[i];
01476   }
01477   newName[index] = '\0';
01478 }
01479 
01495 static int
01496 Rt_CompareResult(RtConfigs_t *config,
01497                  RtDesignLists_t *designList,
01498                  int refOnly)
01499 {
01500   FILE *fin1, *fin2;
01501   char filename1[1024], filename2[1024];
01502   char line[1024], *next;
01503   RtCompareItems_t *item, *newItem;
01504   RtResultPropertys_t *rProperty;
01505   RtCommandResults_t *cResult;
01506   int argc;
01507   char **argv;
01508   int i, len;
01509   int propertyIndex;
01510   int formulaSummary, commandBeginFlag;
01511   int basicLength, stemLength, cycleLength;
01512   int propertyIndexSummary, pIndex;
01513   int invCheckFlag;
01514   int nLine, countLineFlag;
01515   array_t *itemArr;
01516 
01517   propertyIndex = -1;
01518   basicLength = 0;
01519   stemLength = 0;
01520   cycleLength = 0;
01521   invCheckFlag = 0;
01522   propertyIndexSummary = 0;
01523 
01524   sprintf(filename1, "%s/%s/%s.out", config->referenceOutDirectory, 
01525                                      designList->designNickName, 
01526                                      designList->designNickName); 
01527   if(!(fin1 = fopen(filename1, "r"))) {
01528     fprintf(vis_stdout, "Error : Can't open result file '%s'\n", filename1);
01529     return(1);
01530   }
01531 
01532   fin2 = 0;
01533   if(!refOnly) {
01534     sprintf(filename2, "%s/%s/%s.out", config->newOutDirectory, 
01535                                      designList->designNickName, 
01536                                      designList->designNickName); 
01537     if(!(fin2 = fopen(filename2, "r"))) {
01538       fprintf(vis_stdout, "Error : Can't open result file '%s'\n", filename2);
01539       return(1);
01540     }
01541   }
01542 
01548   itemArr = config->compareItemArr;
01549   cResult = 0;
01550   formulaSummary = 0;
01551   commandBeginFlag = 0;
01552   nLine = 0;
01553   countLineFlag = 0;
01554   rProperty = 0;
01555   while(fgets(line, 1024, fin1)) {
01556     if(countLineFlag)   nLine++;
01557     if(line[0] == '\n') continue;
01558     if(!strncasecmp(line, "CommandEnd", 10)) {
01559       if(rProperty && countLineFlag)    {
01560         rProperty->lengthOfCounterExample = nLine;
01561         if(rProperty->lengthOfBasic > -1) {
01562           if(rProperty->lengthOfStem > -1)
01563             rProperty->lengthOfStem = rProperty->lengthOfStem+rProperty->lengthOfBasic-1;
01564           else
01565             rProperty->lengthOfStem = rProperty->lengthOfBasic;
01566         }
01567       }
01568       countLineFlag = 0;
01569       nLine = 0;
01570       rProperty = 0;
01571       commandBeginFlag = 0;
01572     }
01573     else if(!strncasecmp(line, "CommandBegin", 12)) {
01574       propertyIndex = -1;
01575       rProperty = 0;
01576       formulaSummary = 0;
01577       commandBeginFlag = 1;
01578       Rt_SplitLine(line, &argc, &argv);
01579       if(designList->resultForCommandArr1 == 0)
01580         designList->resultForCommandArr1= array_alloc(RtCommandResults_t *, 0);
01581       cResult = ALLOC(RtCommandResults_t, 1);
01582       cResult->resultForProperty = 0;
01583       cResult->compareItemArr = 0;
01584       cResult->command = strdup(argv[1]);
01585       cResult->bTimeOut = 0;
01586       array_insert_last(RtCommandResults_t *, designList->resultForCommandArr1,
01587       cResult);
01588       Rt_FreeArgv(argc, argv);
01589       continue;
01590     }
01591     else if(!strncasecmp(line, "** cmd error", 12)) {
01592       if(cResult)
01593         cResult->error = 1;
01594       fprintf(vis_stdout, "ERROR : Command error was found in the output '%s'\n",
01595       designList->designNickName);
01596       continue;
01597     }
01598     else if(!strncasecmp(line, "# MC: formula", 13) && !formulaSummary) {
01599       if(rProperty && countLineFlag)    {
01600         rProperty->lengthOfCounterExample = nLine;
01601         if(rProperty->lengthOfBasic > -1) {
01602           if(rProperty->lengthOfStem > -1)
01603             rProperty->lengthOfStem = rProperty->lengthOfStem+rProperty->lengthOfBasic-1;
01604           else
01605             rProperty->lengthOfStem = rProperty->lengthOfBasic;
01606         }
01607       }
01608       countLineFlag = 0;
01609       nLine = 0;
01610       propertyIndex++;
01611       Rt_SplitLine(&line[13], &argc, &argv);
01612       rProperty = ALLOC(RtResultPropertys_t, 1);
01613       rProperty->lengthOfBasic = -1;
01614       rProperty->lengthOfStem = -1;
01615       rProperty->lengthOfCycle = -1;
01616       rProperty->lengthOfInv = -1;
01617       rProperty->lengthOfCounterExample = -1;
01618       rProperty->index = propertyIndex;
01619       rProperty->failOrPass = strdup(argv[0]);
01620       if(cResult->resultForProperty == 0)
01621         cResult->resultForProperty = array_alloc(RtResultPropertys_t *, 0);
01622       array_insert_last(RtResultPropertys_t *,cResult->resultForProperty, rProperty); 
01623       basicLength = 1;
01624       stemLength = 0;
01625       cycleLength = 0;
01626       invCheckFlag = 0;
01627       Rt_FreeArgv(argc, argv);
01628       continue;
01629     }
01630     else if((!strncasecmp(line, "# AMC: formula", 14) ||
01631              !strncasecmp(line, "# IMC: formula", 14) ||
01632              !strncasecmp(line, "# BMC: formula", 14) ||
01633              !strncasecmp(line, "# ABS: formula", 14)) && !formulaSummary) {
01634       if(rProperty && countLineFlag)    {
01635         rProperty->lengthOfCounterExample = nLine;
01636         if(rProperty->lengthOfBasic > -1) {
01637           if(rProperty->lengthOfStem > -1)
01638             rProperty->lengthOfStem = rProperty->lengthOfStem+rProperty->lengthOfBasic-1;
01639           else
01640             rProperty->lengthOfStem = rProperty->lengthOfBasic;
01641         }
01642       }
01643       countLineFlag = 0;
01644       nLine = 0;
01645       propertyIndex++;
01646       Rt_SplitLine(&line[14], &argc, &argv);
01647       rProperty = ALLOC(RtResultPropertys_t, 1);
01648       rProperty->lengthOfBasic = -1;
01649       rProperty->lengthOfStem = -1;
01650       rProperty->lengthOfCycle = -1;
01651       rProperty->lengthOfInv = -1;
01652       rProperty->lengthOfCounterExample = -1; 
01653       rProperty->index = propertyIndex;
01654       rProperty->failOrPass = strdup(argv[0]);
01655       if(cResult->resultForProperty == 0)
01656         cResult->resultForProperty = array_alloc(RtResultPropertys_t *, 0);
01657       array_insert_last(RtResultPropertys_t *,cResult->resultForProperty, rProperty); 
01658       basicLength = 1;
01659       stemLength = 0;
01660       cycleLength = 0;
01661       invCheckFlag = 0;
01662       Rt_FreeArgv(argc, argv);
01663       continue;
01664     }
01665     else if(!strncasecmp(line, "# LTL_MC: formula", 17) && !formulaSummary) {
01666       if(rProperty && countLineFlag)    {
01667         rProperty->lengthOfCounterExample = nLine;
01668         if(rProperty->lengthOfBasic > -1) {
01669           if(rProperty->lengthOfStem > -1)
01670             rProperty->lengthOfStem = rProperty->lengthOfStem+rProperty->lengthOfBasic-1;
01671           else
01672             rProperty->lengthOfStem = rProperty->lengthOfBasic;
01673         }
01674       }
01675       countLineFlag = 0;
01676       nLine = 0;
01677       propertyIndex++;
01678       Rt_SplitLine(&line[17], &argc, &argv);
01679       rProperty = ALLOC(RtResultPropertys_t, 1);
01680       rProperty->lengthOfBasic = -1;
01681       rProperty->lengthOfStem = -1;
01682       rProperty->lengthOfCycle = -1;
01683       rProperty->lengthOfInv = -1;
01684       rProperty->lengthOfCounterExample = -1;
01685       rProperty->index = propertyIndex;
01686       rProperty->failOrPass = strdup(argv[0]);
01687       if(cResult->resultForProperty == 0)
01688         cResult->resultForProperty = array_alloc(RtResultPropertys_t *, 0);
01689       array_insert_last(RtResultPropertys_t *,cResult->resultForProperty, rProperty); 
01690       basicLength = 1;
01691       stemLength = 0;
01692       cycleLength = 0;
01693       invCheckFlag = 0;
01694       Rt_FreeArgv(argc, argv);
01695       continue;
01696     }
01697     else if(!strncasecmp(line, "--Fair path stem:", 17)) {
01698       basicLength = 0;
01699       stemLength = 1;
01700       cycleLength = 0;
01701       rProperty->lengthOfInv = -1;
01702       continue;
01703     }
01704     else if(!strncasecmp(line, "--Fair path cycle:", 18)) {
01705       basicLength = 0;
01706       stemLength = 0;
01707       cycleLength = 1;
01708       rProperty->lengthOfInv = -1;
01709       continue;
01710     }
01711     else if(!strncasecmp(line, "# LTL_MC: fair cycle:", 21)) {
01712       basicLength = 0;
01713       stemLength = 0;
01714       cycleLength = 1;
01715       rProperty->lengthOfInv = -1;
01716       continue;
01717     }
01718     else if(!strncasecmp(line, "--State ", 8)) {
01719       if(rProperty == 0) {
01720         fprintf(stdout, "ERROR : The counterexample followed without keyword\n");
01721         continue;
01722       }
01723       Rt_SplitLine(&line[8], &argc, &argv);
01724       len = strlen(argv[0]);
01725       if(argv[0][len-1] == ':') argv[0][len-1] = '\0';
01726       if(basicLength)           rProperty->lengthOfBasic = atoi(argv[0]);
01727       else if(stemLength)       rProperty->lengthOfStem = atoi(argv[0]);
01728       else if(cycleLength)      rProperty->lengthOfCycle = atoi(argv[0]);
01729       else if(invCheckFlag)     rProperty->lengthOfInv = atoi(argv[0]);
01730 
01731       if(stemLength || cycleLength)     rProperty->lengthOfInv = -1;
01732       Rt_FreeArgv(argc, argv);
01733       if(countLineFlag == 0)    countLineFlag = 1;
01734       continue;
01735     }
01736     else if(!strncasecmp(line, "--Goes to state ", 16)) {
01737       if(rProperty == 0) {
01738         fprintf(stdout, "ERROR : The counterexample followed without keyword\n");
01739         continue;
01740       }
01741       Rt_SplitLine(&line[16], &argc, &argv);
01742       len = strlen(argv[0]);
01743       if(argv[0][len-1] == ':') argv[0][len-1] = '\0';
01744       if(basicLength)           rProperty->lengthOfBasic = atoi(argv[0]);
01745       else if(stemLength)       rProperty->lengthOfStem = atoi(argv[0]);
01746       else if(cycleLength)      rProperty->lengthOfCycle = atoi(argv[0]);
01747       else if(invCheckFlag)     rProperty->lengthOfInv = atoi(argv[0]);
01748 
01749       if(stemLength || cycleLength)     rProperty->lengthOfInv = -1;
01750       Rt_FreeArgv(argc, argv);
01751       continue;
01752     }
01753     else if(!strncasecmp(line, "# INV: formula", 14)  && formulaSummary) {
01754       invCheckFlag = 1;
01755       basicLength = 0;
01756       Rt_SplitLine(&line[14], &argc, &argv);
01757       if(cResult->resultForProperty == 0)
01758         cResult->resultForProperty = array_alloc(RtResultPropertys_t *, 0);
01759       if(array_n(cResult->resultForProperty) >= propertyIndexSummary) {
01760           rProperty = array_fetch(RtResultPropertys_t *, cResult->resultForProperty,
01761           propertyIndexSummary-1); 
01762           if(!rProperty) {
01763             rProperty = ALLOC(RtResultPropertys_t, 1);
01764             array_insert(RtResultPropertys_t *,cResult->resultForProperty,
01765             propertyIndexSummary-1, rProperty); 
01766             rProperty->lengthOfStem = -1;
01767             rProperty->lengthOfCycle = -1;
01768             rProperty->lengthOfInv = -1;
01769             rProperty->lengthOfCounterExample = -1; 
01770             rProperty->index = propertyIndexSummary;
01771           }
01772           if(rProperty->index != propertyIndexSummary) {
01773               fprintf(vis_stdout, "Error when compiling log file \n");
01774           }
01775       }
01776       else {
01777           rProperty = ALLOC(RtResultPropertys_t, 1);
01778           array_insert(RtResultPropertys_t *,cResult->resultForProperty,
01779           propertyIndexSummary-1, rProperty); 
01780           rProperty->lengthOfStem = -1;
01781           rProperty->lengthOfCycle = -1;
01782           rProperty->lengthOfInv = -1;
01783           rProperty->lengthOfCounterExample = -1; 
01784           rProperty->index = propertyIndexSummary;
01785       }
01786       if(argv[0][0] == 'f' || argv[0][0] == 'p')
01787         rProperty->failOrPass = strdup(argv[0]);
01788       else
01789         rProperty->failOrPass = strdup(argv[1]);
01790       basicLength = 0;
01791       stemLength = 0;
01792       cycleLength = 0;
01793       Rt_FreeArgv(argc, argv);
01794       propertyIndexSummary++;
01795       continue;
01796     }
01797     else if(!strncasecmp(line, "# INV: formula", 14)  && !formulaSummary) {
01798       invCheckFlag = 1;
01799       if(rProperty && countLineFlag)    rProperty->lengthOfCounterExample = nLine;
01800       countLineFlag = 0;
01801       nLine = 0;
01802       Rt_SplitLine(&line[14], &argc, &argv);
01803       if(Rt_IsNum(argv[0])) {
01804           if(cResult->resultForProperty == 0)
01805             cResult->resultForProperty = array_alloc(RtResultPropertys_t *, 0);
01806           pIndex = atoi(argv[0]);
01807           if(array_n(cResult->resultForProperty) > pIndex) {
01808               rProperty = array_fetch(RtResultPropertys_t *,
01809               cResult->resultForProperty, pIndex-1); 
01810               if(!rProperty) {
01811                   rProperty = ALLOC(RtResultPropertys_t, 1);
01812                   array_insert(RtResultPropertys_t *,cResult->resultForProperty,
01813                   pIndex-1, rProperty); 
01814                   rProperty->lengthOfStem = -1;
01815                   rProperty->lengthOfCycle = -1;
01816                   rProperty->lengthOfInv = -1;
01817                   rProperty->lengthOfCounterExample = -1; 
01818                   rProperty->index = pIndex;
01819               }
01820               if(rProperty->index != pIndex) {
01821                   fprintf(vis_stdout, "Error when compiling log file \n");
01822               }
01823           }
01824           else {
01825               rProperty = ALLOC(RtResultPropertys_t, 1);
01826               array_insert(RtResultPropertys_t *,cResult->resultForProperty,
01827               pIndex-1, rProperty); 
01828               rProperty->lengthOfStem = -1;
01829               rProperty->lengthOfCycle = -1;
01830               rProperty->lengthOfInv = -1;
01831               rProperty->lengthOfCounterExample = -1; 
01832               rProperty->index = pIndex;
01833           }
01834           if(argv[1][0] == 'f' || argv[1][0] == 'p')
01835             rProperty->failOrPass = strdup(argv[1]);
01836           else
01837             rProperty->failOrPass = strdup(argv[2]);
01838           basicLength = 0;
01839           stemLength = 0;
01840           cycleLength = 0;
01841           Rt_FreeArgv(argc, argv);
01842       }
01843       continue;
01844     }
01845     else if(!strncasecmp(line, "# INV: Summary", 14)) {
01846       if(rProperty && countLineFlag)    rProperty->lengthOfCounterExample = nLine;
01847       countLineFlag = 0;
01848       nLine = 0;
01849       formulaSummary = 1;
01850       propertyIndexSummary = 1;
01851       continue;
01852     }
01853     next = strstr(line, "timeout");
01854     if(next == 0) 
01855         next = strstr(line, "Timeout");
01856     if(next) {
01857         if(!strncasecmp(next, "timeout occurred after", 22)) {
01858             cResult->bTimeOut = 1;
01859         }
01860         else if(!strncasecmp(next, "timeout after", 14)) {
01861             cResult->bTimeOut = 1;
01862         }
01863     }
01864     for(i=0; i<array_n(itemArr); i++) {
01865       item = array_fetch(RtCompareItems_t *, itemArr, i);
01866       len = strlen(item->itemName);
01867       if(!strncasecmp(item->itemName, line, len)) {
01868         newItem = ALLOC(RtCompareItems_t, 1);
01869         newItem->itemNickName = strdup(item->itemNickName);
01870         newItem->itemName = 0;
01871         newItem->value = 0;
01872         Rt_SplitLine(&line[len], &argc, &argv);
01873         newItem->value = strdup(argv[0]);
01874         if(cResult->compareItemArr == 0)
01875           cResult->compareItemArr = array_alloc(RtCompareItems_t *, 0);
01876         array_insert_last(RtCompareItems_t *, cResult->compareItemArr, newItem);
01877         Rt_FreeArgv(argc, argv);
01878         break;
01879       }
01880     }
01881   }
01882   if(commandBeginFlag == 1) {
01883     if(cResult->resultForProperty && array_n(cResult->resultForProperty) == 0) 
01884       cResult->resultForProperty = 0;
01885     cResult->compareItemArr = 0;
01886   }
01887 
01888   cResult = 0;
01889   commandBeginFlag = 0;
01890   nLine = 0;
01891   countLineFlag = 0;
01892   rProperty = 0;
01893   while(fgets(line, 1024, fin2)) {
01894     if(countLineFlag) nLine++;
01895     if(line[0] == '\n') continue;
01896     if(!strncasecmp(line, "CommandEnd", 10)) {
01897       if(rProperty && countLineFlag)    {
01898         rProperty->lengthOfCounterExample = nLine;
01899         if(rProperty->lengthOfBasic > -1) {
01900           if(rProperty->lengthOfStem > -1)
01901             rProperty->lengthOfStem = rProperty->lengthOfStem+rProperty->lengthOfBasic-1;
01902           else
01903             rProperty->lengthOfStem = rProperty->lengthOfBasic;
01904         }
01905       }
01906       countLineFlag = 0;
01907       rProperty = 0;
01908       nLine = 0;
01909       commandBeginFlag = 0;
01910     }
01911     else if(!strncasecmp(line, "CommandBegin", 12)) {
01912       propertyIndex = -1;
01913       rProperty = 0;
01914       formulaSummary = 0;
01915       commandBeginFlag = 1;
01916       Rt_SplitLine(line, &argc, &argv);
01917       if(designList->resultForCommandArr2 == 0)
01918         designList->resultForCommandArr2= array_alloc(RtCommandResults_t *, 0);
01919       cResult = ALLOC(RtCommandResults_t, 1);
01920       cResult->resultForProperty = 0;
01921       cResult->compareItemArr = 0;
01922       cResult->bTimeOut = 0;
01923       cResult->command = strdup(argv[1]);
01924       array_insert_last(RtCommandResults_t *, designList->resultForCommandArr2,
01925       cResult);
01926       Rt_FreeArgv(argc, argv);
01927       continue;
01928     }
01929     else if(!strncasecmp(line, "** cmd error", 12)) {
01930       if(cResult)
01931         cResult->error = 1;
01932       fprintf(vis_stdout, "ERROR : Command error was found in the output '%s'\n",
01933       designList->designNickName);
01934       continue;
01935     }
01936     else if(!strncasecmp(line, "# MC: formula", 13) && !formulaSummary) {
01937       if(rProperty && countLineFlag)    {
01938         rProperty->lengthOfCounterExample = nLine;
01939         if(rProperty->lengthOfBasic > -1) {
01940           if(rProperty->lengthOfStem > -1)
01941             rProperty->lengthOfStem = rProperty->lengthOfStem+rProperty->lengthOfBasic-1;
01942           else
01943             rProperty->lengthOfStem = rProperty->lengthOfBasic;
01944         }
01945       }
01946       countLineFlag = 0;
01947       nLine = 0;
01948       propertyIndex++;
01949       Rt_SplitLine(&line[13], &argc, &argv);
01950       rProperty = ALLOC(RtResultPropertys_t, 1);
01951       rProperty->lengthOfBasic = -1;
01952       rProperty->lengthOfStem = -1;
01953       rProperty->lengthOfCycle = -1;
01954       rProperty->lengthOfInv = -1;
01955       rProperty->lengthOfCounterExample = -1; 
01956       rProperty->index = propertyIndex;
01957       rProperty->failOrPass = strdup(argv[0]);
01958       if(cResult->resultForProperty == 0)
01959         cResult->resultForProperty = array_alloc(RtResultPropertys_t *, 0);
01960       array_insert_last(RtResultPropertys_t *,cResult->resultForProperty, rProperty); 
01961       basicLength = 1;
01962       stemLength = 0;
01963       cycleLength = 0;
01964       invCheckFlag = 0;
01965       Rt_FreeArgv(argc, argv);
01966       continue;
01967     }
01968     else if((!strncasecmp(line, "# AMC: formula", 14) ||
01969              !strncasecmp(line, "# IMC: formula", 14) ||
01970              !strncasecmp(line, "# BMC: formula", 14) ||
01971              !strncasecmp(line, "# ABS: formula", 14)) && !formulaSummary) {
01972       if(rProperty && countLineFlag)    {
01973         rProperty->lengthOfCounterExample = nLine;
01974         if(rProperty->lengthOfBasic > -1) {
01975           if(rProperty->lengthOfStem > -1)
01976             rProperty->lengthOfStem = rProperty->lengthOfStem+rProperty->lengthOfBasic-1;
01977           else
01978             rProperty->lengthOfStem = rProperty->lengthOfBasic;
01979         }
01980       }
01981       countLineFlag = 0;
01982       nLine = 0;
01983       propertyIndex++;
01984       Rt_SplitLine(&line[14], &argc, &argv);
01985       rProperty = ALLOC(RtResultPropertys_t, 1);
01986       rProperty->lengthOfBasic = -1;
01987       rProperty->lengthOfStem = -1;
01988       rProperty->lengthOfCycle = -1;
01989       rProperty->lengthOfInv = -1;
01990       rProperty->lengthOfCounterExample = -1; 
01991       rProperty->index = propertyIndex;
01992       rProperty->failOrPass = strdup(argv[0]);
01993       if(cResult->resultForProperty == 0)
01994         cResult->resultForProperty = array_alloc(RtResultPropertys_t *, 0);
01995       array_insert_last(RtResultPropertys_t *,cResult->resultForProperty, rProperty); 
01996       basicLength = 1;
01997       stemLength = 0;
01998       cycleLength = 0;
01999       invCheckFlag = 0;
02000       Rt_FreeArgv(argc, argv);
02001       continue;
02002     }
02003     else if(!strncasecmp(line, "# LTL_MC: formula", 17) && !formulaSummary) {
02004       if(rProperty && countLineFlag)    {
02005         rProperty->lengthOfCounterExample = nLine;
02006         if(rProperty->lengthOfBasic > -1) {
02007           if(rProperty->lengthOfStem > -1)
02008             rProperty->lengthOfStem = rProperty->lengthOfStem+rProperty->lengthOfBasic-1;
02009           else
02010             rProperty->lengthOfStem = rProperty->lengthOfBasic;
02011         }
02012       }
02013       countLineFlag = 0;
02014       nLine = 0;
02015       propertyIndex++;
02016       Rt_SplitLine(&line[17], &argc, &argv);
02017       rProperty = ALLOC(RtResultPropertys_t, 1);
02018       rProperty->lengthOfBasic = -1;
02019       rProperty->lengthOfStem = -1;
02020       rProperty->lengthOfCycle = -1;
02021       rProperty->lengthOfInv = -1;
02022       rProperty->lengthOfCounterExample = -1; 
02023       rProperty->index = propertyIndex;
02024       rProperty->failOrPass = strdup(argv[0]);
02025       if(cResult->resultForProperty == 0)
02026         cResult->resultForProperty = array_alloc(RtResultPropertys_t *, 0);
02027       array_insert_last(RtResultPropertys_t *,cResult->resultForProperty, rProperty); 
02028       basicLength = 1;
02029       stemLength = 0;
02030       cycleLength = 0;
02031       invCheckFlag = 0;
02032       Rt_FreeArgv(argc, argv);
02033       continue;
02034     }
02035     else if(!strncasecmp(line, "--Fair path stem:", 17)) {
02036       basicLength = 0;
02037       stemLength = 1;
02038       cycleLength = 0;
02039       rProperty->lengthOfInv = -1;
02040       continue;
02041     }
02042     else if(!strncasecmp(line, "--Fair path cycle:", 18)) {
02043       basicLength = 0;
02044       stemLength = 0;
02045       cycleLength = 1;
02046       rProperty->lengthOfInv = -1;
02047       continue;
02048     }
02049     else if(!strncasecmp(line, "# LTL_MC: fair cycle:", 21)) {
02050       basicLength = 0;
02051       stemLength = 0;
02052       cycleLength = 1;
02053       rProperty->lengthOfInv = -1;
02054       continue;
02055     }
02056     else if(!strncasecmp(line, "--State ", 8)) {
02057       if(rProperty == 0) {
02058         fprintf(stdout, "ERROR : The counterexample followed without keyword\n");
02059         continue;
02060       }
02061       Rt_SplitLine(&line[8], &argc, &argv);
02062       len = strlen(argv[0]);
02063       if(argv[0][len-1] == ':') argv[0][len-1] = '\0';
02064       if(basicLength)           rProperty->lengthOfBasic = atoi(argv[0]);
02065       else if(stemLength)               rProperty->lengthOfStem = atoi(argv[0]);
02066       else if(cycleLength)      rProperty->lengthOfCycle = atoi(argv[0]);
02067       else if(invCheckFlag)     rProperty->lengthOfInv = atoi(argv[0]);
02068       if(stemLength || cycleLength)     rProperty->lengthOfInv = -1;
02069       if(countLineFlag == 0)    countLineFlag = 1;
02070       Rt_FreeArgv(argc, argv);
02071       continue;
02072     }
02073     else if(!strncasecmp(line, "--Goes to state ", 16)) {
02074       if(rProperty == 0) {
02075         fprintf(stdout, "ERROR : The counterexample followed without keyword\n");
02076         continue;
02077       }
02078       Rt_SplitLine(&line[16], &argc, &argv);
02079       len = strlen(argv[0]);
02080       if(argv[0][len-1] == ':') argv[0][len-1] = '\0';
02081       if(basicLength)           rProperty->lengthOfBasic = atoi(argv[0]);
02082       else if(stemLength)       rProperty->lengthOfStem = atoi(argv[0]);
02083       else if(cycleLength)      rProperty->lengthOfCycle = atoi(argv[0]);
02084       else if(invCheckFlag)     rProperty->lengthOfInv = atoi(argv[0]);
02085       if(stemLength || cycleLength)     rProperty->lengthOfInv = -1;
02086 
02087       Rt_FreeArgv(argc, argv);
02088       continue;
02089     }
02090     else if(!strncasecmp(line, "# INV: formula", 14)  && formulaSummary) {
02091       Rt_SplitLine(&line[14], &argc, &argv);
02092       invCheckFlag = 1;
02093       if(cResult->resultForProperty == 0)
02094         cResult->resultForProperty = array_alloc(RtResultPropertys_t *, 0);
02095       if(array_n(cResult->resultForProperty) >= propertyIndexSummary) {
02096           rProperty = array_fetch(RtResultPropertys_t *, cResult->resultForProperty,
02097           propertyIndexSummary-1); 
02098           if(!rProperty) {
02099             rProperty = ALLOC(RtResultPropertys_t, 1);
02100             array_insert(RtResultPropertys_t *,cResult->resultForProperty,
02101             propertyIndexSummary-1, rProperty); 
02102             rProperty->lengthOfStem = -1;
02103             rProperty->lengthOfCycle = -1;
02104             rProperty->lengthOfInv = -1;
02105             rProperty->lengthOfCounterExample = -1;
02106             rProperty->index = propertyIndexSummary;
02107           }
02108           if(rProperty->index != propertyIndexSummary) {
02109               fprintf(vis_stdout, "Error when compiling log file \n");
02110           }
02111       }
02112       else {
02113           rProperty = ALLOC(RtResultPropertys_t, 1);
02114           array_insert(RtResultPropertys_t *,cResult->resultForProperty,
02115           propertyIndexSummary-1, rProperty); 
02116           rProperty->lengthOfStem = -1;
02117           rProperty->lengthOfCycle = -1;
02118           rProperty->lengthOfInv = -1;
02119           rProperty->lengthOfCounterExample = -1;
02120           rProperty->index = propertyIndexSummary;
02121       }
02122       if(argv[0][0] == 'f' || argv[0][0] == 'p')
02123         rProperty->failOrPass = strdup(argv[0]);
02124       else
02125         rProperty->failOrPass = strdup(argv[1]);
02126       stemLength = 0;
02127       cycleLength = 0;
02128       Rt_FreeArgv(argc, argv);
02129       propertyIndexSummary++;
02130       continue;
02131     }
02132     else if(!strncasecmp(line, "# INV: formula", 14)  && !formulaSummary) {
02133       invCheckFlag = 1;
02134       if(rProperty && countLineFlag)    rProperty->lengthOfCounterExample = nLine;
02135       countLineFlag = 0;
02136       nLine = 0;
02137       Rt_SplitLine(&line[14], &argc, &argv);
02138       if(Rt_IsNum(argv[0])) {
02139           if(cResult->resultForProperty == 0)
02140             cResult->resultForProperty = array_alloc(RtResultPropertys_t *, 0);
02141           pIndex = atoi(argv[0]);
02142           if(array_n(cResult->resultForProperty) > pIndex) {
02143               rProperty = array_fetch(RtResultPropertys_t *,
02144               cResult->resultForProperty, pIndex-1); 
02145               if(!rProperty) {
02146                   rProperty = ALLOC(RtResultPropertys_t, 1);
02147                   array_insert(RtResultPropertys_t *,cResult->resultForProperty,
02148                   pIndex-1, rProperty); 
02149                   rProperty->lengthOfStem = -1;
02150                   rProperty->lengthOfCycle = -1;
02151                   rProperty->lengthOfInv = -1;
02152                   rProperty->lengthOfCounterExample = -1;
02153                   rProperty->index = pIndex;
02154               }
02155               if(rProperty->index != pIndex) {
02156                   fprintf(vis_stdout, "Error when compiling log file \n");
02157               }
02158           }
02159           else {
02160               rProperty = ALLOC(RtResultPropertys_t, 1);
02161               array_insert(RtResultPropertys_t *,cResult->resultForProperty,
02162               pIndex-1, rProperty); 
02163               rProperty->lengthOfStem = -1;
02164               rProperty->lengthOfCycle = -1;
02165               rProperty->lengthOfInv = -1;
02166               rProperty->lengthOfCounterExample = -1;
02167               rProperty->index = pIndex;
02168           }
02169           if(argv[1][0] == 'f' || argv[1][0] == 'p')
02170             rProperty->failOrPass = strdup(argv[1]);
02171           else
02172             rProperty->failOrPass = strdup(argv[2]);
02173           stemLength = 0;
02174           cycleLength = 0;
02175           Rt_FreeArgv(argc, argv);
02176       }
02177       continue;
02178     }
02179     else if(!strncasecmp(line, "# INV: Summary", 14)) {
02180       if(rProperty && countLineFlag)    rProperty->lengthOfCounterExample = nLine;
02181       countLineFlag = 0;
02182       nLine = 0;
02183       formulaSummary = 1;
02184       propertyIndexSummary = 1;
02185       continue;
02186     }
02187 
02188     next = strstr(line, "timeout");
02189     if(next == 0) 
02190         next = strstr(line, "Timeout");
02191     if(next) {
02192         if(!strncasecmp(next, "timeout occurred after", 22)) {
02193             cResult->bTimeOut = 1;
02194         }
02195         else if(!strncasecmp(next, "timeout after", 14)) {
02196             cResult->bTimeOut = 1;
02197         }
02198     }
02199     for(i=0; i<array_n(itemArr); i++) {
02200       item = array_fetch(RtCompareItems_t *, itemArr, i);
02201       len = strlen(item->itemName);
02202       if(!strncasecmp(item->itemName, line, len)) {
02203         newItem = ALLOC(RtCompareItems_t, 1);
02204         newItem->itemNickName = strdup(item->itemNickName);
02205         newItem->itemName = 0;
02206         newItem->value = 0;
02207         Rt_SplitLine(&line[len], &argc, &argv);
02208         newItem->value = strdup(argv[0]);
02209         if(cResult->compareItemArr == 0)
02210           cResult->compareItemArr = array_alloc(RtCompareItems_t *, 0);
02211         array_insert_last(RtCompareItems_t *, cResult->compareItemArr, newItem);
02212         Rt_FreeArgv(argc, argv);
02213         break;
02214       }
02215     }
02216   }
02217   if(commandBeginFlag == 1) {
02218     if(cResult->resultForProperty && array_n(cResult->resultForProperty) == 0) 
02219       cResult->resultForProperty = 0;
02220     cResult->compareItemArr = 0;
02221   }
02222 
02223   fclose(fin1);
02224   fclose(fin2);
02225   return(0);
02226 }
02227 
02239 static int
02240 Rt_IsNum(char *tmp)
02241 {
02242   int i, len;
02243 
02244   len = strlen(tmp);
02245   for(i=0; i<len; i++) {
02246     if(!isdigit((int)tmp[i]))return(0);
02247   }
02248   return(1);
02249 }
02250 
02251 
02263 static int
02264 Rt_ExecuteVis(RtConfigs_t *config,
02265               RtDesignLists_t *designList,
02266               int refAndNew, FILE *scriptOut)
02267 {
02268   char temp[1024];
02269   char dir[1024];
02270   char exe[1024];
02271   char name[1024];
02272   char srcFile[1024];
02273   char outFile[1024];
02274 
02275 
02276   if(refAndNew == 1 && !config->bRefRun)return(0);
02277   if(refAndNew == 2 && !config->bNewRun)return(0);
02278 
02279   if(refAndNew == 1) {
02280     sprintf(dir, "%s/%s", config->referenceOutDirectory, designList->designNickName);  
02281     sprintf(exe, "%s", config->referenceVis);  
02282     sprintf(name, "%s", designList->designNickName);  
02283   }
02284   if(refAndNew == 2) {
02285     sprintf(dir, "%s/%s", config->newOutDirectory, designList->designNickName);  
02286     sprintf(exe, "%s", config->newVis);  
02287     sprintf(name, "%s", designList->designNickName);  
02288   }
02289   sprintf(srcFile, "%s/%s.src", dir, name);
02290   sprintf(outFile, "%s/%s.out", dir, name);
02291 
02292   if(scriptOut) {
02296     sprintf(temp, "%s -x -f %s.src >& %s.out", exe, name, name);
02297     fprintf(scriptOut, "echo %s begin\n", designList->designNickName);
02298     fprintf(scriptOut, "cd %s\n", dir);
02299     fprintf(scriptOut, "%s\n", temp);
02300     fprintf(scriptOut, "cd ../../\n");
02301   }
02302   else {
02303     sprintf(temp, "%s -x -f %s/%s.src > %s/%s.out", exe, dir, name, dir, name);
02304     if (system(temp))
02305       return(1);
02306   }
02311   return(0);
02312 }
02313 
02329 static int
02330 Rt_WriteBatchCommand(RtConfigs_t *config, 
02331                      RtDesignLists_t *designList)
02332 {
02333   FILE *fout1;
02334   FILE *fout2;
02335   char filename1[1024];
02336   char filename2[1024];
02337   char refDir[1024];
02338   char temp[1024];
02339   int i;
02340   RtCommandResults_t *cTemplate;
02341   array_t *cTemplateArrOld;
02342   array_t *cTemplateArrNew;
02343   
02344   fout1 = fout2 = 0;
02345   if(config->bRefRun) {
02346     sprintf(temp, "\\mkdir -p %s/%s", config->referenceOutDirectory, 
02347                                    designList->designNickName);
02348     if (system(temp))
02349       return(1);
02350   }
02351   if(config->bNewRun) {
02352     sprintf(temp, "\\mkdir -p %s/%s", config->newOutDirectory, 
02353                                    designList->designNickName);
02354     if (system(temp))
02355       return(1);
02356   }
02357 
02358   if(config->bRefRun) {
02359     sprintf(filename1, "%s/%s/%s.src", config->referenceOutDirectory, 
02360                                      designList->designNickName,
02361                                      designList->designNickName);
02362     if(!(fout1 = fopen(filename1, "w"))) {
02363       fprintf(vis_stdout, "Error : Can't open command script file '%s'\n", filename1);
02364       return(0);
02365     }
02366   }
02367   if(config->bNewRun) {
02368     sprintf(filename2, "%s/%s/%s.src", config->newOutDirectory, 
02369                                      designList->designNickName,
02370                                      designList->designNickName);
02371     if(!(fout2 = fopen(filename2, "w"))) {
02372       fprintf(vis_stdout, "Error : Can't open command script file '%s'\n", filename2);
02373       fclose(fout1);
02374       return(0);
02375     }
02376   }
02377 
02378   cTemplateArrOld = config->refCommandTemplateArr;
02379   cTemplateArrNew = config->newCommandTemplateArr;
02380   sprintf(refDir, "%s/%s", config->designDirectory, designList->designDirectory);
02381 
02382   if(config->bRefRun) {
02389     fprintf(fout1, "set BaseName %s\n", designList->designNickName);
02390   }
02391   if(config->bNewRun) {
02398     fprintf(fout2, "set BaseName %s\n", designList->designNickName);
02399   }
02400 
02401   if(designList->blifFile) {
02402     if(config->bRefRun)
02403     fprintf(fout1, "set BlifFile %s/%s\n", refDir, designList->blifFile);
02404     if(config->bNewRun)
02405     fprintf(fout2, "set BlifFile %s/%s\n", refDir, designList->blifFile);
02406   }
02407   if(designList->ordFile) {
02408     if(config->bRefRun)
02409     fprintf(fout1, "set OrdFile %s/%s\n", refDir, designList->ordFile);
02410     if(config->bNewRun)
02411     fprintf(fout2, "set OrdFile %s/%s\n", refDir, designList->ordFile);
02412   }
02413   if(designList->ctlFile) {
02414     if(config->bRefRun)
02415     fprintf(fout1, "set CtlFile %s/%s\n", refDir, designList->ctlFile);
02416     if(config->bNewRun)
02417     fprintf(fout2, "set CtlFile %s/%s\n", refDir, designList->ctlFile);
02418   }
02419   if(designList->invFile) {
02420     if(config->bRefRun)
02421     fprintf(fout1, "set InvFile %s/%s\n", refDir, designList->invFile);
02422     if(config->bNewRun)
02423     fprintf(fout2, "set InvFile %s/%s\n", refDir, designList->invFile);
02424   }
02425   if(designList->leFile) {
02426     if(config->bRefRun)
02427     fprintf(fout1, "set LeFile %s/%s\n", refDir, designList->leFile);
02428     if(config->bNewRun)
02429     fprintf(fout2, "set LeFile %s/%s\n", refDir, designList->leFile);
02430   }
02431   if(designList->ltlFile) {
02432     if(config->bRefRun)
02433     fprintf(fout1, "set LtlFile %s/%s\n", refDir, designList->ltlFile);
02434     if(config->bNewRun)
02435     fprintf(fout2, "set LtlFile %s/%s\n", refDir, designList->ltlFile);
02436   }
02437   if(designList->fairFile) {
02438     if(config->bRefRun)
02439     fprintf(fout1, "set FairFile %s/%s\n", refDir, designList->fairFile);
02440     if(config->bNewRun)
02441     fprintf(fout2, "set FairFile %s/%s\n", refDir, designList->fairFile);
02442   }
02443   if(designList->hintFile) {
02444     if(config->bRefRun)
02445     fprintf(fout1, "set HintFile %s/%s\n", refDir, designList->hintFile);
02446     if(config->bNewRun)
02447     fprintf(fout2, "set HintFile %s/%s\n", refDir, designList->hintFile);
02448   }
02449 
02450   if(config->bRefRun) {
02451     if(designList->fairFile)
02452       fprintf(fout1, "set fairOption \"-F%s/%s\"\n", refDir, designList->fairFile);
02453     else
02454       fprintf(fout1, "set fairOption \" \"\n");
02455   }
02456   if(config->bNewRun) {
02457     if(designList->fairFile)
02458       fprintf(fout2, "set fairOption \"-F%s/%s\"\n", refDir, designList->fairFile);
02459     else
02460       fprintf(fout2, "set fairOption \" \"\n");
02461   }
02462 
02463 
02464   if(config->bDefaultInitCommand) {
02465     if(config->bRefRun) {
02466       fprintf(fout1, "echo CommandBegin init\n");
02467       if(designList->ordFile) {
02468         if(designList->bIsMv)
02469            fprintf(fout1, "rlmv $BlifFile\n");
02470         else
02471            fprintf(fout1, "read_blif $BlifFile\n");
02472         fprintf(fout1, "flatten_hierarchy\n");
02473         fprintf(fout1, "static_order -s partial $OrdFile\n");
02474         fprintf(fout1, "build_partition_mdds\n");
02475         if(designList->fairFile)
02476           fprintf(fout1, "rf $FairFile\n");
02477       }
02478       else {
02479         if(designList->bIsMv)
02480            fprintf(fout1, "rlmv $BlifFile\n");
02481         else
02482            fprintf(fout1, "read_blif $BlifFile\n");
02483         fprintf(fout1, "echo init\n");
02484         fprintf(fout1, "init\n");
02485         if(designList->fairFile)
02486           fprintf(fout1, "rf $FairFile\n");
02487       }
02488       fprintf(fout1, "time\n");
02489       fprintf(fout1, "print_bdd_stats\n");
02490       fprintf(fout1, "echo CommandEnd init\n");
02491     }
02492     if(config->bNewRun) {
02493       fprintf(fout2, "echo CommandBegin init\n");
02494       if(designList->ordFile) {
02495         if(designList->bIsMv)
02496            fprintf(fout2, "rlmv $BlifFile\n");
02497         else
02498            fprintf(fout2, "read_blif $BlifFile\n");
02499         fprintf(fout2, "flatten_hierarchy\n");
02500         fprintf(fout2, "static_order -s partial $OrdFile\n");
02501         fprintf(fout2, "build_partition_mdds\n");
02502         if(designList->fairFile)
02503           fprintf(fout2, "rf $FairFile\n");
02504       }
02505       else {
02506         if(designList->bIsMv)
02507            fprintf(fout2, "rlmv $BlifFile\n");
02508         else
02509            fprintf(fout2, "read_blif $BlifFile\n");
02510         fprintf(fout2, "echo init\n");
02511         fprintf(fout2, "init\n");
02512         if(designList->fairFile)
02513           fprintf(fout2, "rf $FairFile\n");
02514       }
02515       fprintf(fout2, "time\n");
02516       fprintf(fout2, "print_bdd_stats\n");
02517       fprintf(fout2, "echo CommandEnd init\n");
02518     } 
02519   }
02520   else {
02526     if(config->bRefRun) {
02527       if(designList->bIsMv)
02528         fprintf(fout1, "alias read_model \"rlmv $BlifFile\"\n");
02529       else
02530         fprintf(fout1, "alias read_model \"read_blif $BlifFile\"\n");
02531       if(designList->fairFile)  
02532         fprintf(fout1, "alias set_fairness \"read_fairness $FairFile\"\n");
02533       else
02534         fprintf(fout1, "alias set_fairness \" \"\n");
02535       if(designList->ordFile)   
02536         fprintf(fout1, "alias order_vars \"so -s input_and_latch $OrdFile\"\n");
02537       else
02538         fprintf(fout1, "alias order_vars \"so\"\n");
02539     }
02540     if(config->bNewRun) {
02541       if(designList->bIsMv)
02542         fprintf(fout2, "alias read_model \"rlmv $BlifFile\"\n");
02543       else
02544         fprintf(fout2, "alias read_model \"read_blif $BlifFile\"\n");
02545       if(designList->fairFile)  
02546         fprintf(fout2, "alias set_fairness \"read_fairness $FairFile\"\n");
02547       else
02548         fprintf(fout2, "alias set_fairness \" \"\n");
02549       if(designList->ordFile)   
02550         fprintf(fout2, "alias order_vars \"so -s input_and_latch $OrdFile\"\n");
02551       else
02552         fprintf(fout2, "alias order_vars \"so\"\n");
02553     } 
02554   }
02555 
02556   if(config->bRefRun) {
02557     for(i=0; i<array_n(cTemplateArrOld); i++) {
02558       cTemplate = array_fetch(RtCommandResults_t *, cTemplateArrOld, i);
02559       fprintf(fout1, "%s\n", cTemplate->command);
02560     }
02561     fprintf(fout1, "quit\n");
02562     fclose(fout1);
02563   }
02564   if(config->bNewRun) {
02565     for(i=0; i<array_n(cTemplateArrNew); i++) {
02566       cTemplate = array_fetch(RtCommandResults_t *, cTemplateArrNew, i);
02567       fprintf(fout2, "%s\n", cTemplate->command);
02568     }
02569     fprintf(fout2, "quit\n");
02570     fclose(fout2);
02571   }
02572 
02573   return(0);
02574 }
02575 
02590 static int
02591 Rt_ReadCommandTemplate(RtConfigs_t * config)
02592 {
02593   FILE  *fin;
02594   char line[1024];
02595   char *filename;
02596   char temp[1024];
02597   int i;
02598   RtCommandResults_t *cResult;
02599   int argc;
02600   char **argv;
02601   char *next, *tmp;
02602 
02603   if(config->bRefRun) {
02604   filename = config->refCommandTemplate;
02605   if(!(fin = fopen(filename, "r"))) {
02606     fprintf(vis_stdout, "Error : Can't open command template file '%s' for reference\n", filename);
02607     return(1);
02608   }
02609 
02610   if(config->keyWordTable == 0)
02611     config->keyWordTable = st_init_table(strcmp, st_strhash);
02612   config->refCommandTemplateArr = array_alloc(RtCommandResults_t *, 0);
02613   while(fgets(line, 1024, fin)) {
02614     if(line[0] == '#')  continue;
02615     cResult = ALLOC(RtCommandResults_t, 1);
02616     cResult->resultForProperty = 0;
02617     cResult->compareItemArr = 0;
02618     cResult->command = 0;
02619     Rt_SplitLine(line, &argc, &argv);
02620     temp[0] = '\0';
02621     for(i=0; i<argc; i++) {
02622       strcat(temp, argv[i]); 
02623       if(i+1 != argc) strcat(temp, " ");
02624       if(argv[i][0] == '$') {
02625          if(!st_lookup(config->keyWordTable, argv[i], &tmp)) {
02626             next = strdup(argv[i]);
02627             st_insert(config->keyWordTable, next, next);
02628          }
02629       }
02630     }
02631     Rt_FreeArgv(argc, argv);
02632     cResult->command = strdup(temp);
02633     array_insert_last(RtCommandResults_t *, config->refCommandTemplateArr, cResult);
02634 
02635   }
02636   fclose(fin);
02637   }
02638 
02639   if(config->bNewRun) {
02640   filename = config->newCommandTemplate;
02641   if(!(fin = fopen(filename, "r"))) {
02642     fprintf(vis_stdout, "Error : Can't open command template file '%s' for new\n", filename);
02643     return(1);
02644   }
02645   if(config->keyWordTable == 0)
02646     config->keyWordTable = st_init_table(strcmp, st_strhash);
02647   config->newCommandTemplateArr = array_alloc(RtCommandResults_t *, 0);
02648   while(fgets(line, 1024, fin)) {
02649     if(line[0] == '#')  continue;
02650     cResult = ALLOC(RtCommandResults_t, 1);
02651     cResult->resultForProperty = 0;
02652     cResult->compareItemArr = 0;
02653     cResult->command = 0;
02654     Rt_SplitLine(line, &argc, &argv);
02655     temp[0] = '\0';
02656     for(i=0; i<argc; i++) {
02657       strcat(temp, argv[i]); 
02658       if(i+1 != argc) strcat(temp, " ");
02659       if(argv[i][0] == '$') {
02660          if(!st_lookup(config->keyWordTable, argv[i], &tmp)) {
02661             next = strdup(argv[i]);
02662             st_insert(config->keyWordTable, next, next);
02663          }
02664       }
02665     }
02666     Rt_FreeArgv(argc, argv);
02667     cResult->command = strdup(temp);
02668     array_insert_last(RtCommandResults_t *, config->newCommandTemplateArr, cResult);
02669   }
02670   fclose(fin);
02671   }
02672   return(0);
02673 }
02674 
02675 
02692 static int
02693 Rt_ReadDesignListFile(RtConfigs_t * config)
02694 {
02695   FILE  *fin;
02696   char line[1024];
02697   char *filename, *str;
02698   char suffix[1024];
02699   int i, j, index, bDot, strLen;
02700   RtDesignLists_t *designList;
02701   int argc;
02702   char **argv;
02703 
02704   filename = config->designList;
02705 
02706   if(!(fin = fopen(filename, "r"))) {
02707     fprintf(vis_stdout, "Error : Can't open design list file '%s'\n", filename);
02708     return(1);
02709   }
02710 
02711   config->designListArr = array_alloc(RtDesignLists_t *, 0);
02712   while(fgets(line, 1024, fin)) {
02713     if(line[0] == '#')  continue;
02714     if(line[0] == '\n') continue;
02715     Rt_SplitLine(line, &argc, &argv);
02716     designList = ALLOC(RtDesignLists_t, 1);
02717     designList->designDirectory = strdup(argv[0]);
02718     designList->designNickName = strdup(argv[1]);
02719     designList->blifFile = strdup(argv[2]);
02720     designList->leFile = 0;
02721     designList->ltlFile = 0;
02722     designList->ordFile = 0;
02723     designList->hintFile = 0;
02724     designList->ctlFile = 0;
02725     designList->invFile = 0;
02726     designList->fairFile = 0;
02727     designList->resultForCommandArr1 = 0;
02728     designList->resultForCommandArr2 = 0;
02729 
02730     str = argv[2];
02731     index = bDot = 0;
02732     strLen = strlen(str);
02733     for(j=strLen; j>=0; j--) {
02734       if(str[j] == '.') {       
02735         bDot = 1; 
02736         break;
02737       }
02738     }
02739     if(bDot==0) {
02740       fprintf(vis_stdout, "Error : Missing blif or mv file in design list '%s'\n",
02741       designList->designNickName);
02742       Rt_FreeArgv(argc, argv);
02743       free(designList);
02744       continue;
02745     }
02746     else {
02747       j++;
02748       for(;str[j] != '\0'; j++) {
02749         suffix[index++] = str[j];
02750       }
02751     }
02752     suffix[index] = '\0';
02753 
02754     if(!strcasecmp(suffix, "blif")) 
02755       designList->bIsMv = 0;
02756     else if(!strcasecmp(suffix, "mv")) 
02757       designList->bIsMv = 1;
02758     else {
02759       fprintf(vis_stdout, "Error : Missing blif or mv file in design list '%s'\n",
02760       designList->designNickName);
02761       Rt_FreeArgv(argc, argv);
02762       free(designList);
02763       continue;
02764     }
02765 
02766     for(i=3; i<argc; i++) {
02767       str = argv[i];
02768       index = bDot = 0;
02769       strLen = strlen(str);
02770       for(j=strLen; j>=0; j--) {
02771         if(str[j] == '.') {     
02772           bDot = 1; 
02773           break;
02774         }
02775       }
02776       if(bDot==0) {
02777         fprintf(vis_stdout, "Error : Illegal suffix of file '%s' in design list '%s'\n", 
02778           argv[i], designList->designNickName);
02779         Rt_FreeArgv(argc, argv);
02780         free(designList);
02781         continue;
02782       }
02783       else {
02784         j++;
02785         for(;str[j] != '\0'; j++) {
02786           suffix[index++] = str[j];
02787         }
02788       }
02789       suffix[index] = '\0';
02790       if(!strcasecmp(suffix, "ctl")) 
02791         designList->ctlFile = strdup(argv[i]);
02792       else if(!strcasecmp(suffix, "fair")) 
02793         designList->fairFile = strdup(argv[i]);
02794       else if(!strcasecmp(suffix, "inv")) 
02795         designList->invFile = strdup(argv[i]);
02796       else if(!strcasecmp(suffix, "le")) 
02797         designList->leFile = strdup(argv[i]);
02798       else if(!strcasecmp(suffix, "ltl")) 
02799         designList->ltlFile = strdup(argv[i]);
02800       else if(!strcasecmp(suffix, "ord")) 
02801         designList->ordFile = strdup(argv[i]);
02802       else if(!strcasecmp(suffix, "hint")) 
02803         designList->hintFile = strdup(argv[i]);
02804       else {
02805         fprintf(vis_stdout, "Illegal suffix of file '%s'\n", argv[i]);
02806         Rt_FreeArgv(argc, argv);
02807         fclose(fin);
02808         return(1);
02809       }
02810     }
02811     array_insert_last(RtDesignLists_t *, config->designListArr, designList);
02812     Rt_FreeArgv(argc, argv);
02813   }
02814 
02815   fclose(fin);
02816   return(0);
02817 }
02818 
02831 static RtConfigs_t *
02832 Rt_ReadConfigFile(char *filename)
02833 {
02834   FILE  *fin;
02835   char line[1024];
02836   char temp[1024];
02837   RtConfigs_t *config;
02838   int i, argc;
02839   int errorFlag;
02840   char **argv;
02841   RtCompareItems_t *cItem;
02842 
02843   if(!(fin = fopen(filename, "r"))) {
02844     fprintf(vis_stdout, "Error : Can't open configuration file '%s'\n", filename);
02845     return(0);
02846   }
02847 
02848   config = ALLOC(RtConfigs_t, 1);
02849   memset(config, 0, sizeof(RtConfigs_t));
02850   config->configurationFile = strdup(filename);
02851   config->compareItemArr = 0;
02852   config->bRefOnly = 0;
02853   config->keyWordTable = 0;
02854   config->bRefRun = -1;
02855   config->bNewRun = -1;
02856   while(fgets(line, 1024, fin)) {
02857     if(line[0] == '#')  continue;
02858     if(line[0] == '\n') continue;
02859     Rt_SplitLine(line, &argc, &argv);
02860     if(argv[0][0] == '\n')      continue;
02861     if(argc < 3)        continue;
02862     if(argv[2] == 0)    continue;
02863     if(!strcasecmp("DesignDirectory", argv[0])) {
02864       config->designDirectory = strdup(argv[2]);
02865     }
02866     else if(!strcasecmp("ReferenceVis", argv[0])) {
02867       config->referenceVis = strdup(argv[2]);
02868     }
02869     else if(!strcasecmp("ReferenceVisNickName", argv[0])) {
02870       config->referenceVisNickName = strdup(argv[2]);
02871     }
02872     else if(!strcasecmp("ReferenceVisOptionFile", argv[0])) {
02873       config->referenceVisOptionFile = strdup(argv[2]);
02874     }
02875     else if(!strcasecmp("ReferenceOutputDir", argv[0])) {
02876       config->referenceOutDirectory = strdup(argv[2]);
02877     }
02878     else if(!strcasecmp("bRefRun", argv[0])) {
02879       config->bRefRun = Rt_SetBooleanValue(argv[2], argv[0]);
02880     }
02881     else if(!strcasecmp("NewVis", argv[0])) {
02882       config->newVis = strdup(argv[2]);
02883     }
02884     else if(!strcasecmp("NewVisNickName", argv[0])) {
02885       config->newVisNickName = strdup(argv[2]);
02886     }
02887     else if(!strcasecmp("NewVisOptionFile", argv[0])) {
02888       config->newVisOptionFile = strdup(argv[2]);
02889     }
02890     else if(!strcasecmp("NewOutputDir", argv[0])) {
02891       config->newOutDirectory = strdup(argv[2]);
02892     }
02893     else if(!strcasecmp("bNewRun", argv[0])) {
02894       config->bNewRun = Rt_SetBooleanValue(argv[2], argv[0]);
02895     }
02896     else if(!strcasecmp("NewCommandTemplate", argv[0])) {
02897       config->newCommandTemplate = strdup(argv[2]);
02898     }
02899     else if(!strcasecmp("RefCommandTemplate", argv[0])) {
02900       config->refCommandTemplate = strdup(argv[2]);
02901     }
02902     else if(!strcasecmp("DesignList", argv[0])) {
02903       config->designList = strdup(argv[2]);
02904     }
02905     else if(!strcasecmp("bCompareCounterExample", argv[0])) {
02906       config->bCompareCounterExample = Rt_SetBooleanValue(argv[2], argv[0]);
02907     }
02908     else if(!strcasecmp("bFinalResultOnly", argv[0])) {
02909       config->bFinalResultOnly = Rt_SetBooleanValue(argv[2], argv[0]);
02910     }
02911     else if(!strcasecmp("bDontRemoveTempFile", argv[0])) {
02912       config->bDontRemoveTempFile = Rt_SetBooleanValue(argv[2], argv[0]);
02913     }
02914     else if(!strcasecmp("bDefaultInitCommand", argv[0])) {
02915       config->bDefaultInitCommand = Rt_SetBooleanValue(argv[2], argv[0]);
02916     }
02917     else if(!strcasecmp("ResultForPerformance", argv[0])) {
02918       config->resultForPerformance = strdup(argv[2]);
02919     }
02920     else if(!strcasecmp("ResultForCounterExample", argv[0])) {
02921       config->resultForCounterExample = strdup(argv[2]);
02922     }
02923     else if(!strcasecmp("CompareItem", argv[0])) {
02924       cItem = ALLOC(RtCompareItems_t, 1);
02925       cItem->itemNickName = strdup(argv[2]);
02926       temp[0] = '\0';
02927       for(i=4; i<argc; i++) {
02928         strcat(temp, argv[i]);
02929         if(i+1 != argc) strcat(temp, " ");
02930       }
02931       cItem->itemName = strdup(temp);
02932       cItem->value = 0;
02933       if(!config->compareItemArr)
02934         config->compareItemArr = array_alloc(RtCompareItems_t *, 0);
02935       array_insert_last(RtCompareItems_t *, config->compareItemArr, cItem);
02936     }
02937     else {
02938       fprintf(vis_stdout, "Unknown option '%s' in configuration file\n", argv[0]);
02939       free(config);
02940       Rt_FreeArgv(argc, argv);
02941       fclose(fin);
02942       return(0);
02943     }
02944     Rt_FreeArgv(argc, argv);
02945   }
02946   fclose(fin);
02947 
02948   errorFlag = 0;
02949   if(config->designDirectory == 0) {
02950     fprintf(stdout, "DesignDirectory is not specified in configuration file '%s'\n",
02951                 filename);
02952     errorFlag = 1;
02953   }
02954   if(config->referenceVis == 0) {
02955     fprintf(stdout, "ReferenceVis is not specified in configuration file '%s'\n",
02956                 filename);
02957     errorFlag = 1;
02958   }
02959   if(config->referenceVisNickName == 0) {
02960     fprintf(stdout, "ReferenceVisNickName is not specified in configuration file '%s'\n",
02961                 filename);
02962     errorFlag = 1;
02963   }
02964   if(config->referenceOutDirectory == 0) {
02965     fprintf(stdout, "ReferenceOutDirectory is not specified in configuration file '%s'\n",
02966                 filename);
02967     errorFlag = 1;
02968   }
02969   if(config->newVis == 0) {
02970     fprintf(stdout, "NewVis is not specified in configuration file '%s'\n",
02971                 filename);
02972     errorFlag = 1;
02973   }
02974   if(config->newVisNickName == 0) {
02975     fprintf(stdout, "NewVisNickName is not specified in configuration file '%s'\n",
02976                 filename);
02977     errorFlag = 1;
02978   }
02979   if(config->newOutDirectory == 0) {
02980     fprintf(stdout, "NewOutDirectory is not specified in configuration file '%s'\n",
02981                 filename);
02982     errorFlag = 1;
02983   }
02984   if(config->bRefRun == -1) {
02985     fprintf(stdout, "bRefRun is not specified in configuration file '%s'\n",
02986                 filename);
02987     errorFlag = 1;
02988   }
02989   if(config->bNewRun == -1) {
02990     fprintf(stdout, "bNewRun is not specified in configuration file '%s'\n",
02991                 filename);
02992     errorFlag = 1;
02993   }
02994   if(config->designList == 0) {
02995     fprintf(stdout, "DesignList is not specified in configuration file '%s'\n",
02996                 filename);
02997     errorFlag = 1;
02998   }
02999   if(config->newCommandTemplate == 0) {
03000     fprintf(stdout, "NewCommandTemplate is not specified in configuration file '%s'\n",
03001                 filename);
03002     errorFlag = 1;
03003   }
03004   if(config->refCommandTemplate == 0) {
03005     fprintf(stdout, "RefCommandTemplate is not specified in configuration file '%s'\n",
03006                 filename);
03007     errorFlag = 1;
03008   }
03009 
03010   if(config->compareItemArr == 0 || array_n(config->compareItemArr) == 0) {
03011     fprintf(stdout, "CompareItem is not specified in configuration file '%s'\n",
03012                 filename);
03013     errorFlag = 1;
03014   }
03015 
03016   if(errorFlag) {
03017     free(config);
03018     return(0);
03019   }
03020   
03021   return(config);
03022 }
03023 
03035 static int
03036 Rt_SetBooleanValue(char *str, char *option)
03037 {
03038 
03039   if(!strcmp("TRUE", str) || !strcmp("1", str))
03040     return(1);
03041   else if(!strcmp("FALSE", str) || !strcmp("0", str))
03042     return(0);
03043   else {
03044     fprintf(vis_stdout, "Warning : Illegal argement for '%s'\n", option);
03045     fprintf(vis_stdout, "          Set with default '%s : TURE'\n", option);
03046     return(1);
03047   }
03048 }
03049 
03062 static char *
03063 Rt_SplitLine(
03064   char * command,
03065   int * argc,
03066   char *** argv)
03067 {
03068   register char *p, *start, c;
03069   register int i, j;
03070   register char *new_arg;
03071   array_t *argv_array;
03072   int single_quote, double_quote;
03073 
03074   argv_array = array_alloc(char *, 5);
03075 
03076   p = command;
03077   for(;;) {
03078     /* skip leading white space */
03079     while (isspace((int)(*p))) {
03080       p++;
03081     }
03082 
03083     /* skip until end of this token */
03084     single_quote = double_quote = 0;
03085     for(start = p; (c = *p) != '\0'; p++) {
03086       if (c == ';' || c == '#' || isspace((int)c)) {
03087         if (! single_quote && ! double_quote) {
03088           break;
03089         }
03090       }
03091       if (c == '\'') {
03092         single_quote = ! single_quote;
03093       }
03094       if (c == '"') {
03095         double_quote = ! double_quote;
03096       }
03097     }
03098     if (single_quote || double_quote) {
03099       (void) fprintf(vis_stderr, "** cmd warning: ignoring unbalanced quote ...\n");
03100     }
03101     if (start == p) break;
03102 
03103     new_arg = ALLOC(char, p - start + 1);
03104     j = 0;
03105     for(i = 0; i < p - start; i++) {
03106       c = start[i];
03107       if ((c != '\'') && (c != '\"')) {
03108         new_arg[j++] = isspace((int)c) ? ' ' : start[i];
03109       }
03110     }
03111     new_arg[j] = '\0';
03112     array_insert_last(char *, argv_array, new_arg);
03113   }
03114 
03115   *argc = array_n(argv_array);
03116   *argv = array_data(char *, argv_array);
03117   array_free(argv_array);
03118   if (*p == ';') {
03119     p++;
03120   }
03121   else if (*p == '#') {
03122     for(; *p != 0; p++) ;               /* skip to end of line */
03123   }
03124   return p;
03125 }    
03126 
03127 
03128 static void
03129 Rt_FreeRtConfig(RtConfigs_t * config)
03130 {
03131   int i;
03132   RtDesignLists_t *list;
03133   array_t *itemArr, *designArr, *resultArr;
03134   st_table *table;
03135   RtCompareItems_t *item;
03136   RtCommandResults_t *result;
03137   st_generator *gen;
03138   char *keyWord;
03139 
03140 
03141   if(config == 0)       return;
03142   
03143   if(config->designDirectory)           free(config->designDirectory);
03144   if(config->designList)                free(config->designList);
03145   if(config->scriptFile)                free(config->scriptFile);
03146   if(config->resultForCounterExample)   free(config->resultForCounterExample);
03147   if(config->resultForPerformance)      free(config->resultForPerformance);
03148 
03149   if(config->referenceVis)              free(config->referenceVis);
03150   if(config->referenceVisNickName)      free(config->referenceVisNickName);
03151   if(config->referenceVisOptionFile)    free(config->referenceVisOptionFile);
03152   if(config->referenceOutDirectory)     free(config->referenceOutDirectory);
03153   if(config->refCommandTemplate)        free(config->refCommandTemplate);
03154 
03155   if(config->newVis)                    free(config->newVis);
03156   if(config->newVisNickName)            free(config->newVisNickName);
03157   if(config->newVisOptionFile)          free(config->newVisOptionFile);
03158   if(config->newOutDirectory)           free(config->newOutDirectory);
03159   if(config->newCommandTemplate)        free(config->newCommandTemplate);
03160 
03161   itemArr = config->compareItemArr;
03162   if(itemArr) {
03163     for(i=0; i<array_n(itemArr); i++) {
03164       item = array_fetch(RtCompareItems_t *, itemArr, i);
03165       Rt_FreeCompareItem(item);
03166     }
03167     array_free(itemArr);
03168   }
03169 
03170   designArr = config->designListArr;
03171   if(designArr) {
03172     for(i=0; i<array_n(designArr); i++) {
03173       list = array_fetch(RtDesignLists_t *, designArr, i);
03174       Rt_FreeDesignList(list);
03175     }
03176     array_free(designArr);
03177   }
03178 
03179   resultArr = config->refCommandTemplateArr;
03180   if(resultArr) {
03181     for(i=0; i<array_n(resultArr); i++) {
03182       result = array_fetch(RtCommandResults_t *, resultArr, i);
03183       Rt_FreeCommandResult(result);
03184     }
03185     array_free(resultArr);
03186   }
03187 
03188   resultArr = config->newCommandTemplateArr;
03189   if(resultArr) {
03190     for(i=0; i<array_n(resultArr); i++) {
03191       result = array_fetch(RtCommandResults_t *, resultArr, i);
03192       Rt_FreeCommandResult(result);
03193     }
03194     array_free(resultArr);
03195   }
03196 
03197   if(config->keyWordTable) {
03198     table = config->keyWordTable;
03199     st_foreach_item(table, gen, &keyWord, NIL(char *)) {
03200       free(keyWord);
03201     }
03202     st_free_table(table);
03203   }
03204 
03205 }
03206 
03207 static void
03208 Rt_FreeDesignList(RtDesignLists_t *list)
03209 {
03210   array_t *resultArr;
03211   RtCommandResults_t *result;
03212   int i;
03213 
03214   if(list == 0) return;
03215 
03216   if(list->designDirectory)     free(list->designDirectory);
03217   if(list->designNickName)      free(list->designNickName);
03218   if(list->blifFile)    free(list->blifFile);
03219   if(list->ctlFile)     free(list->ctlFile);
03220   if(list->invFile)     free(list->invFile);
03221   if(list->leFile)      free(list->leFile);
03222   if(list->fairFile)    free(list->fairFile);
03223   if(list->hintFile)    free(list->hintFile);
03224   if(list->ordFile)     free(list->ordFile);
03225   if(list->ltlFile)     free(list->ltlFile);
03226 
03227   resultArr = list->resultForCommandArr1;
03228   if(resultArr) {
03229     for(i=0; i<array_n(resultArr); i++) {
03230       result = array_fetch(RtCommandResults_t *, resultArr, i);
03231       Rt_FreeCommandResult(result);
03232     }
03233     array_free(resultArr);
03234   }
03235   resultArr = list->resultForCommandArr2;
03236   if(resultArr) {
03237     for(i=0; i<array_n(resultArr); i++) {
03238       result = array_fetch(RtCommandResults_t *, resultArr, i);
03239       Rt_FreeCommandResult(result);
03240     }
03241     array_free(resultArr);
03242   }
03243 
03244   free(list);
03245 }
03246 
03247 static void
03248 Rt_FreeCommandResult(RtCommandResults_t *result)
03249 {
03250   array_t *itemArr;
03251   array_t *propArr;
03252   RtCompareItems_t *item;
03253   RtResultPropertys_t *prop;
03254   int i;
03255 
03256   if(result == 0)       return;
03257   
03258   if(result->command)   free(result->command);
03259 
03260   itemArr = result->compareItemArr;
03261   if(itemArr) {
03262     for(i=0; i<array_n(itemArr); i++) {
03263       item = array_fetch(RtCompareItems_t *, itemArr, i);
03264       Rt_FreeCompareItem(item);
03265     }
03266     array_free(itemArr);
03267   }
03268                           
03269   propArr = result->resultForProperty;
03270   if(propArr) {
03271     for(i=0; i<array_n(propArr); i++) {
03272       prop = array_fetch(RtResultPropertys_t *, propArr, i);
03273       Rt_FreeResultProperty(prop);
03274     }
03275     array_free(propArr);
03276   }
03277 }
03278 
03279 static void
03280 Rt_FreeCompareItem(RtCompareItems_t *item)
03281 {
03282   if(item == 0) return;
03283 
03284   if(item->itemName)    free(item->itemName);
03285   if(item->itemNickName)free(item->itemNickName);
03286   if(item->value)       free(item->value);
03287   free(item);
03288 }
03289 
03290 static void
03291 Rt_FreeResultProperty(RtResultPropertys_t *prop)
03292 {
03293 
03294   if(prop == 0) return;
03295 
03296   if(prop->failOrPass)  free(prop->failOrPass);
03297   free(prop);
03298 }
03299 
03300 static void
03301 Rt_FreeArgv(int  argc,  char ** argv)
03302 {
03303   int i;
03304 
03305   for(i = 0; i < argc; i++) {
03306     FREE(argv[i]);
03307   }
03308   FREE(argv);
03309 }