示例#1
0
 /*
 ** Free all stems in a list.
 */
 static void fuzzerClearStemList(ref fuzzer_stem pStem)
 {
     //while( pStem ){
     //  fuzzer_stem pNext = pStem.pNext;
     //  sqlite3_free(pStem);
     //  pStem = pNext;
     //}
     pStem = null;
 }
示例#2
0
        /*
        ** Compute the current output term for a fuzzer_stem.
        */
        static int fuzzerRender(
            fuzzer_stem pStem, /* The stem to be rendered */
            ref string pzBuf,  /* Write results into this buffer.  realloc if needed */
            ref int pnBuf      /* Size of the buffer */
            )
        {
            fuzzer_rule pRule = pStem.pRule;
            int         n;
            string      z;

            n = pStem.nBasis + pRule.nTo - pRule.nFrom;
            if ((pnBuf) < n + 1)
            {
                //(*pzBuf) = sqlite3_realloc((*pzBuf), n+100);
                //if( (*pzBuf)==0 ) return SQLITE_NOMEM;
                (pnBuf) = n + 100;
            }
            n = pStem.n;
            //z = pzBuf;
            if (n < 0)
            {
                z = pStem.zBasis.Substring(0, pStem.nBasis + 1);//memcpy(z, pStem.zBasis, pStem.nBasis+1);
            }
            else
            {
                z = pStem.zBasis.Substring(0, n);//memcpy( z, pStem.zBasis, n );
                if (pRule.nTo != 0)
                {
                    z += pRule.zTo.Substring(0, pRule.nTo);//memcpy(&z[n], pRule.zTo, pRule.nTo);
                }
                z += pStem.zBasis.Substring(n + pRule.nFrom, pStem.nBasis - n - pRule.nFrom);
                //memcpy(&z[n+pRule.nTo], &pStem.zBasis[n+pRule.nFrom], pStem.nBasis-n-pRule.nFrom+1);
            }
            pzBuf = z;
            return(SQLITE_OK);
        }
示例#3
0
 /*
 ** Current cost of a stem
 */
 static fuzzer_cost fuzzerCost( fuzzer_stem pStem )
 {
   return pStem.rCostX = pStem.rBaseCost + pStem.pRule.rCost;
 }
示例#4
0
    /*
    ** Compute the current output term for a fuzzer_stem.
    */
    static int fuzzerRender(
      fuzzer_stem pStem,    /* The stem to be rendered */
      ref string pzBuf,     /* Write results into this buffer.  realloc if needed */
      ref int pnBuf         /* Size of the buffer */
    )
    {
      fuzzer_rule pRule = pStem.pRule;
      int n;
      string z;

      n = pStem.nBasis + pRule.nTo - pRule.nFrom;
      if ( ( pnBuf ) < n + 1 )
      {
        //(*pzBuf) = sqlite3_realloc((*pzBuf), n+100);
        //if( (*pzBuf)==0 ) return SQLITE_NOMEM;
        ( pnBuf ) = n + 100;
      }
      n = pStem.n;
      //z = pzBuf;
      if ( n < 0 )
      {
        z = pStem.zBasis.Substring( 0, pStem.nBasis + 1 );//memcpy(z, pStem.zBasis, pStem.nBasis+1);
      }
      else
      {
        z = pStem.zBasis.Substring( 0, n );//memcpy( z, pStem.zBasis, n );
        if ( pRule.nTo != 0 )
          z += pRule.zTo.Substring( 0, pRule.nTo );//memcpy(&z[n], pRule.zTo, pRule.nTo);
        z += pStem.zBasis.Substring( n + pRule.nFrom, pStem.nBasis - n - pRule.nFrom );
        //memcpy(&z[n+pRule.nTo], &pStem.zBasis[n+pRule.nFrom], pStem.nBasis-n-pRule.nFrom+1);
      }
      pzBuf = z;
      return SQLITE_OK;
    }
示例#5
0
 /*
 ** Free all stems in a list.
 */
 static void fuzzerClearStemList( ref fuzzer_stem pStem )
 {
   //while( pStem ){
   //  fuzzer_stem pNext = pStem.pNext;
   //  sqlite3_free(pStem);
   //  pStem = pNext;
   //}
   pStem = null;
 }
示例#6
0
 /*
 ** Current cost of a stem
 */
 static fuzzer_cost fuzzerCost(fuzzer_stem pStem)
 {
     return(pStem.rCostX = pStem.rBaseCost + pStem.pRule.rCost);
 }