MCPcopy Create free account
hub / github.com/audacity/audacity / decimal_new

Function decimal_new

lib-src/sqlite/shell.c:4568–4682  ·  view source on GitHub ↗

** Allocate a new Decimal object. Initialize it to the number given ** by the input string. */

Source from the content-addressed store, hash-verified

4566** by the input string.
4567*/
4568static Decimal *decimal_new(
4569 sqlite3_context *pCtx,
4570 sqlite3_value *pIn,
4571 int nAlt,
4572 const unsigned char *zAlt
4573){
4574 Decimal *p;
4575 int n, i;
4576 const unsigned char *zIn;
4577 int iExp = 0;
4578 p = sqlite3_malloc( sizeof(*p) );
4579 if( p==0 ) goto new_no_mem;
4580 p->sign = 0;
4581 p->oom = 0;
4582 p->isInit = 1;
4583 p->isNull = 0;
4584 p->nDigit = 0;
4585 p->nFrac = 0;
4586 if( zAlt ){
4587 n = nAlt,
4588 zIn = zAlt;
4589 }else{
4590 if( sqlite3_value_type(pIn)==SQLITE_NULL ){
4591 p->a = 0;
4592 p->isNull = 1;
4593 return p;
4594 }
4595 n = sqlite3_value_bytes(pIn);
4596 zIn = sqlite3_value_text(pIn);
4597 }
4598 p->a = sqlite3_malloc64( n+1 );
4599 if( p->a==0 ) goto new_no_mem;
4600 for(i=0; isspace(zIn[i]); i++){}
4601 if( zIn[i]=='-' ){
4602 p->sign = 1;
4603 i++;
4604 }else if( zIn[i]=='+' ){
4605 i++;
4606 }
4607 while( i<n && zIn[i]=='0' ) i++;
4608 while( i<n ){
4609 char c = zIn[i];
4610 if( c>='0' && c<='9' ){
4611 p->a[p->nDigit++] = c - '0';
4612 }else if( c=='.' ){
4613 p->nFrac = p->nDigit + 1;
4614 }else if( c=='e' || c=='E' ){
4615 int j = i+1;
4616 int neg = 0;
4617 if( j>=n ) break;
4618 if( zIn[j]=='-' ){
4619 neg = 1;
4620 j++;
4621 }else if( zIn[j]=='+' ){
4622 j++;
4623 }
4624 while( j<n && iExp<1000000 ){
4625 if( zIn[j]>='0' && zIn[j]<='9' ){

Callers 8

decimalFuncFunction · 0.85
decimalCmpFuncFunction · 0.85
decimalCollFuncFunction · 0.85
decimalAddFuncFunction · 0.85
decimalSubFuncFunction · 0.85
decimalSumStepFunction · 0.85
decimalSumInverseFunction · 0.85
decimalMulFuncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected