コード例 #1
0
ファイル: cgen_cmd.cpp プロジェクト: gitgun/dLabPro
INT16 CGEN_PROTECTED CCgen::OnFile()
{
  char lpFile[L_INPUTLINE];
  GetNextDefToken(lpFile);
  dlp_strconvert(SC_UNESCAPE,lpFile,lpFile);
  dlp_strtrimleft(lpFile);
  dlp_strtrimright(lpFile);

  if (m_bMainProject) ERRORRET(ERR_INVALKEY,"FILE:","MAIN:",0,NOT_EXEC);
  if (m_nAncestor) return O_K;

  INT16 nFType = 0;

  if (!dlp_strlen(lpFile)) ERRORRET(ERR_EXPECTAFTER,"file name","FILE:",0,NOT_EXEC);
  if (m_files.FindItem(lpFile)) ERRORRET(ERR_DDEF_LIST,"FILE",lpFile,0,NOT_EXEC);

  char *ext = &lpFile[strlen(lpFile)-1];
  while (*ext != '.' && ext != lpFile) ext--;
  if (dlp_strncmp(ext,".cpp",L_NAMES) ==0) nFType = FT_CPP;
  if (dlp_strncmp(ext,".c"  ,L_NAMES) ==0) nFType = FT_C;
  if (dlp_strncmp(ext,".h"  ,L_NAMES) ==0) nFType = FT_H;
  if (!nFType) ERRORRET(ERR_FILETYPE,ext,NULL,0,NOT_EXEC);

  SCGFile* nf = m_files.AddItem(lpFile);
  if (!nf) return NOT_EXEC;
  nf->nFType = nFType;

  return O_K;
}
コード例 #2
0
ファイル: data_prt.c プロジェクト: gitgun/dLabPro
/**
 * dlp_sprintx w/o space padding.
 */
INT32 __sprintx(char* sBuf, const void* nData, INT16 nType, BOOL bExact)
{
  dlp_sprintx(sBuf,(char*)nData,nType,bExact);
  dlp_strconvert(SC_PRC_ESCAPE,sBuf,sBuf);
  dlp_strreplace(sBuf,"\n","\\n");
  dlp_strreplace(sBuf,"\r","\\r");
  dlp_strreplace(sBuf,"\t","\\t");
  dlp_strtrimleft(dlp_strtrimright(sBuf));
  return strlen(sBuf);
}
コード例 #3
0
ファイル: file.c プロジェクト: thias42/dLabPro
INT32 CDlpFile_Getlen(CDlpFile* _this)
{
    FILE*    f                      = NULL;
    INT32  nCtr                   = 0;
    char  lpsBuffer[L_INPUTLINE] = "";

    if (!dlp_strlen(_this->m_lpsFlist))
    {
      IERROR(_this,FIL_NEEDFL,0,0,0);
      return 0;
    }
    f = fopen(_this->m_lpsFlist,"r");
    if (!f)
    {
      IERROR(_this,ERR_FILEOPEN,_this->m_lpsFlist,"reading",0);
      return 0;
    }
    while (fgets(lpsBuffer,L_INPUTLINE,f))
      if(dlp_strlen(dlp_strtrimleft(dlp_strtrimright(lpsBuffer))))
        nCtr++;
    fclose(f);
    return nCtr;
	return 0;
}
コード例 #4
0
ファイル: cgen_cmd.cpp プロジェクト: gitgun/dLabPro
INT16 CGEN_PROTECTED CCgen::OnParent()
{
  const char* lpParent = GetRestOfDefLine();

  if (m_bMainProject)
    return IERROR(this,ERR_INVALKEY,"PARENT:","MAIN:",0);
  if (m_nAncestor) return O_K;

  if (!dlp_strlen(lpParent))
    return IERROR(this,ERR_EXPECTAFTER,"name list","PARENT:",0);

  char* tx = (char*)strstr(lpParent,"C(");
  if (tx)
  {
    tx+=2;
    char* ty = strstr(tx,")");
    if (ty) *ty = 0;
    char lpBuf[100]; dlp_strncpy(lpBuf,tx,100);
    do dlp_strtrimleft(lpBuf); while (lpBuf[0] == ',');
    sprintf(m_lpsCxxMoreParents,", %s",lpBuf);
  }

  return O_K;
}
コード例 #5
0
ファイル: data_prt.c プロジェクト: gitgun/dLabPro
/**
 * Prints one block of the instance in vector mode (standard).
 */
INT32 CGEN_PRIVATE CData_PrintVectors_Block
(
  CData* _this,                                                                 /* Pointer to data instance          */
  INT32   nBlock                                                                 /* Block index (<0: ignore blocks)   */
)                                                                               /* Returns number of lines printed   */
{
  INT32 i      = 0;                                                              /* Universal loop counter            */
  INT32 nR     = 0;                                                              /* Current record                    */
  INT32 nR_    = 0;                                                              /* First record to be printed        */
  INT32 nR0    = 0;                                                              /* First record of current page      */
  INT32 nSR    = 0;                                                              /* Number of records of currenr page */
  INT32 nXR    = 0;                                                              /* Last record to print plus one     */
  INT32 nC     = 0;                                                              /* Current component                 */
  INT32 nXC    = 0;                                                              /* Number of components              */
  INT32 nWI    = 0;                                                              /* Component index column width      */
  INT32 nW0    = 0;                                                              /* Head column width                 */
  INT32 nW     = 0;                                                              /* Column width                      */
  INT32 nP     = 0;                                                              /* Current page                      */
  INT32 nPps   = 0;                                                              /* Pages per screen                  */
  INT32 nL     = 0;                                                              /* Line counter                      */
  BOOL bPur   = FALSE;                                                          /* Print physical record unit flag   */
  BOOL bPuc   = FALSE;                                                          /* Print physical component unit flg.*/
  FLOAT64 nBuf = 0.;                                                             /* Double buffer                     */
  char   sBuf[L_SSTR+1];                                                        /* String buffer                     */

  /* Validate */                                                                /* --------------------------------- */
  if (nBlock>=CData_GetNBlocks(_this)) return 0;                                /* Requested block does not exist    */

  /* Initialize */                                                              /* --------------------------------- */
  nR_ = nBlock>=0 ? CData_GetNRecsPerBlock(_this)*nBlock : 0;                   /* Get first record to print         */
  nXR = nBlock>=0 ? nR_+CData_GetNRecsPerBlock(_this) : CData_GetNRecs(_this);  /* Get number of records             */
  nXC = CData_GetNComps(_this);                                                 /* Get number of components          */
  bPur = _this->m_lpTable->m_fsr!=1. && _this->m_lpTable->m_fsr!=0.;            /* Displaying physical record units? */
  bPuc = _this->m_nCinc!=1. && _this->m_nCinc!=0.;                              /* Displaying physical comp. units?  */
  nPps = dlp_maxprintlines()/(nXC+4);                                           /* Compute no. of pages per sceeen   */

  /* Print vectors */                                                           /* --------------------------------- */
  if (nBlock>=0)                                                                /* Printing blockwise?               */
  {                                                                             /* >>                                */
    printf("\n   Block %ld (offset %ld)",(long)nBlock,(long)nR_);               /*   Show current block index        */
    dlp_inc_printlines(1);  nL++;                                               /*   Adjust number of printed lines  */
  }                                                                             /* <<                                */
  for (nR0=nR_; nR0<nXR; )                                                      /* Loop over records                 */
  {                                                                             /* >>                                */
    CData_PrintVectors_GetColWidth(_this,nR0,0,&nWI,&nW0,&nW);                  /*   Comp. head and data col. widths */
    nSR = (dlp_maxprintcols()-nWI-nW0-4)/(nW+1);                                /*   Number of columns to print      */
    if (nR0+nSR>nXR) nSR = nXR-nR0;                                             /*   No more than there are records! */

    /* Print record header */                                                   /*   - - - - - - - - - - - - - - - - */
    if (bPur)                                                                   /*   Display physical record units?  */
    {                                                                           /*   >>                              */
      printf("\n %s ->",__pad(strcpy(sBuf,_this->m_lpRunit),nW0+nWI,'r'));      /*     Print name of physical unit   */
      for (nR=nR0; nR<nR0+nSR; nR++)                                            /*     Loop over remaining records   */
      {                                                                         /*     >>                            */
        nBuf = _this->m_lpTable->m_ofs + (nR-nR_)*_this->m_lpTable->m_fsr;      /*       Compute abscissa value      */
        __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact);                         /*       Print to a string           */
        printf("%s ",__pad(sBuf,nW,'r'));                                       /*       Format and print to screen  */
      }                                                                         /*     <<                            */
      dlp_inc_printlines(1); nL++;                                              /*     Adjust number of printed lines*/
    }                                                                           /*   <<                              */
    sBuf[0]='\0';                                                               /*   Clear string buffer             */
    if (bPuc) sprintf(sBuf,"%s| ",_this->m_lpCunit);                            /*   Print phys. comp. unit name...  */
    printf("\n %s",__pad(sBuf,nW0+nWI+3,'r'));                                  /*   ... or empty string             */
    for (nR=nR0; nR<nR0+nSR; nR++)                                              /*   Loop over remaining records     */
    {                                                                           /*   >>                              */
      i=nR-nR_; __sprintx(sBuf,&i,T_INT,_this->m_bExact);                       /*     Print record index to a str.  */
      printf("%s%c",__pad(sBuf,nW,'r'),CData_RecIsMarked(_this,nR)?'*':' ');    /*     Format and print to screen    */
    }                                                                           /*   <<                              */
    sBuf[0]='\0';                                                               /*   Clear string buffer             */
    if (bPuc) sprintf(sBuf,"%c ",bPuc?'v':' ');                                 /*   Print down arrow ...            */
    printf("\n %s",__pad(sBuf,nW0+nWI+3,'r'));                                  /*   ... or empty string             */
    sBuf[0]='\0'; for (i=0; i<nW; i++) sBuf[i]='.'; sBuf[i]='\0';               /*   Make horizonal delimiter        */
    for (nR=nR0; nR<nR0+nSR; nR++) printf("%s ",sBuf);                          /*   Print one per vector            */
    dlp_inc_printlines(2);  nL+=2;                                              /*   Adjust number of printed lines  */

    /* Print data */                                                            /*   - - - - - - - - - - - - - - - - */
    for (nC=0; nC<nXC; )                                                        /*   Loop over components            */
    {                                                                           /*   >>                              */
      __sprintx(sBuf,&nC,T_INT,_this->m_bExact);                                /*     Print comp. index to a string */
      printf("\n%c%s ",                                                         /*     Format and print to screen    */
        CData_CompIsMarked(_this,nC)?'*':' ',__pad(sBuf,nWI,'r'));              /*     | (incl. "*" for "marked")    */
      if (bPuc && dlp_is_numeric_type_code(CData_GetCompType(_this,nC)))        /*     Display ordinate value?       */
      {                                                                         /*     >>                            */
        nBuf = _this->m_nCofs + nC*_this->m_nCinc;                              /*       Compute it                  */
        __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact);                         /*       Print it to a string        */
      }                                                                         /*     <<                            */
      else strcpy(sBuf,CData_GetCname(_this,nC));                               /*     else display component name   */
      printf("%s: ",__pad(dlp_strtrimleft(dlp_strtrimright(sBuf)),nW0,'r'));    /*     Format and print to screen    */
      for (nR=nR0; nR<nR0+nSR; nR++)                                            /*     Loop over remaining records   */
      {                                                                         /*     >>                            */
        __sprintx(sBuf,CData_XAddr(_this,nR,nC),                                /*       Print cell value to a str.  */
            CData_GetCompType(_this,nC),_this->m_bExact);                       /*         |                         */
        if (dlp_is_symbolic_type_code(CData_GetCompType(_this,nC)))             /*       Is string value             */
          if ((INT32)dlp_strlen(sBuf)>nW)                                        /*         Will not fit in column    */
            dlp_strabbrv(sBuf,sBuf,nW);                                         /*           Abbreviate it           */
        if (dlp_is_numeric_type_code(CData_GetCompType(_this,nC)))              /*       Is numeric value            */
          if (_this->m_bNz && CMPLX_EQUAL(CData_Cfetch(_this,nR,nC),CMPLX(0.)))
            dlp_strcpy(sBuf,"-");
        printf("%s%c",__pad(sBuf,nW,'r'),                                       /*       Format and print to screen  */
          CData_CellIsMarked(_this,nR*CData_GetNComps(_this)+nC)?'*':' ');      /*       | (incl. "*" for "marked")  */
      }                                                                         /*     <<                            */
      dlp_inc_printlines(1); nL++;                                              /*     Adjust number of printed lines*/

      /* Break component listing */                                             /*     - - - - - - - - - - - - - - - */
      if (nPps==0)                                                              /*     Not all comps. fit on screen  */
      {                                                                         /*     >>                            */
        sprintf(sBuf,"component (0..%ld), cancel -3",(long)nXC-1);              /*       Make user hint              */
        if ((nC=dlp_printstop_nix(nC,sBuf,NULL))==-1) break;                    /*       Break listing               */
        if (nC< -2 ) return -1;                                                 /*       Cancelled by user           */
        if (nC>=nXC) break;                                                     /*       No more components -> break */
      }                                                                         /*     <<                            */
      else nC++;                                                                /*     No breaking -> count comps.   */
    }                                                                           /*   <<                              */
    nR0+=nSR;                                                                   /*   First record on next page       */
    nP++;                                                                       /*   Count pages                     */
    if (nR0<nXR)                                                                /*   There are more records          */
    {                                                                           /*   >>                              */
      printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols());           /*     Print a separator             */
      dlp_inc_printlines(1); nL++;                                              /*     Adjust number of printed lines*/
    }                                                                           /*   <<                              */

    /* Break record listing */                                                  /*   - - - - - - - - - - - - - - - - */
    if (((nPps>0 && nP>=nPps) || nPps==0) && nR0<nXR)                           /*   Complicated break condition :)  */
    {                                                                           /*   >>                              */
      dlp_inc_printlines(dlp_maxprintlines());                                  /*     Do stop right here            */
        sprintf(sBuf,"record (%ld..%ld)%s",(long)nR_,(long)nXR-1,               /*     Make user hint                */
          nBlock>=0?", cancel -3":"");                                          /*     |                             */
      if ((nR0=dlp_printstop_nix(--nR0,sBuf,NULL))==-1) break;                  /*     Break listing                 */
      if (nR0< -2 ) return -1;                                                  /*     Cancelled by user             */
      if (nR0< nR_) nR0=nR_;                                                    /*     No previous blocks, please!   */
      if (nR0>=nXR) break;                                                      /*     No more records -> break      */
      nP=0;                                                                     /*     Reset page counter            */
    }                                                                           /*   <<                              */
  }                                                                             /* <<                                */

  return nL;                                                                    /* Return number of printed lines    */
}