Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Classes | Functions
fpointarray.cpp File Reference
#include "fpointarray.h"
#include <cstdarg>
#include <math.h>
#include <qregexp.h>
#include "util.h"

Go to the source code of this file.

Classes

struct  SVGState

Functions

static const char * getCoord (const char *ptr, double &number)

Function Documentation

static const char* getCoord ( const char *  ptr,
double &  number 
) [static]

Definition at line 779 of file fpointarray.cpp.

{
       int integer, exponent;
       double decimal, frac;
       int sign, expsign;
       
       exponent = 0;
       integer = 0;
       frac = 1.0;
       decimal = 0;
       sign = 1;
       expsign = 1;
       
       // read the sign
       if(*ptr == '+')
              ptr++;
       else if(*ptr == '-')
       {
              ptr++;
              sign = -1;
       }
       
       // read the integer part
       while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9')
              integer = (integer * 10) + *(ptr++) - '0';
       if(*ptr == '.') // read the decimals
       {
              ptr++;
              while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9')
                     decimal += (*(ptr++) - '0') * (frac *= 0.1);
       }
       
       if(*ptr == 'e' || *ptr == 'E') // read the exponent part
       {
              ptr++;
              
              // read the sign of the exponent
              if(*ptr == '+')
                     ptr++;
              else if(*ptr == '-')
              {
                     ptr++;
                     expsign = -1;
              }
              
              exponent = 0;
              while(*ptr != '\0' && *ptr >= '0' && *ptr <= '9')
              {
                     exponent *= 10;
                     exponent += *ptr - '0';
                     ptr++;
              }
       }
       number = integer + decimal;
       number *= sign * pow( static_cast<double>(10), static_cast<double>( expsign * exponent ) );
       // skip the following space
       if(*ptr == ' ')
              ptr++;
       
       return ptr;
}