mirror of
https://github.com/fltk/fltk.git
synced 2026-05-27 10:57:58 +08:00
Fix nanosvg implementation of nsvg__atof() to allow compilation with Visual Studio 7.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12435 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+13
-5
@@ -1081,7 +1081,7 @@ static double nsvg__atof(const char* s)
|
|||||||
char* cur = (char*)s;
|
char* cur = (char*)s;
|
||||||
char* end = NULL;
|
char* end = NULL;
|
||||||
double res = 0.0, sign = 1.0;
|
double res = 0.0, sign = 1.0;
|
||||||
long long intPart = 0, fracPart = 0;
|
double intPart = 0, fracPart = 0;
|
||||||
char hasIntPart = 0, hasFracPart = 0;
|
char hasIntPart = 0, hasFracPart = 0;
|
||||||
|
|
||||||
// Parse optional sign
|
// Parse optional sign
|
||||||
@@ -1095,7 +1095,11 @@ static double nsvg__atof(const char* s)
|
|||||||
// Parse integer part
|
// Parse integer part
|
||||||
if (nsvg__isdigit(*cur)) {
|
if (nsvg__isdigit(*cur)) {
|
||||||
// Parse digit sequence
|
// Parse digit sequence
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
intPart = (double)_strtoi64(cur, &end, 10);
|
||||||
|
#else
|
||||||
intPart = (double)strtoll(cur, &end, 10);
|
intPart = (double)strtoll(cur, &end, 10);
|
||||||
|
#endif
|
||||||
if (cur != end) {
|
if (cur != end) {
|
||||||
res = (double)intPart;
|
res = (double)intPart;
|
||||||
hasIntPart = 1;
|
hasIntPart = 1;
|
||||||
@@ -1108,7 +1112,11 @@ static double nsvg__atof(const char* s)
|
|||||||
cur++; // Skip '.'
|
cur++; // Skip '.'
|
||||||
if (nsvg__isdigit(*cur)) {
|
if (nsvg__isdigit(*cur)) {
|
||||||
// Parse digit sequence
|
// Parse digit sequence
|
||||||
fracPart = strtoll(cur, &end, 10);
|
#ifdef _MSC_VER
|
||||||
|
fracPart = (double)_strtoi64(cur, &end, 10);
|
||||||
|
#else
|
||||||
|
fracPart = (double)strtoll(cur, &end, 10);
|
||||||
|
#endif
|
||||||
if (cur != end) {
|
if (cur != end) {
|
||||||
res += (double)fracPart / pow(10.0, (double)(end - cur));
|
res += (double)fracPart / pow(10.0, (double)(end - cur));
|
||||||
hasFracPart = 1;
|
hasFracPart = 1;
|
||||||
@@ -1123,11 +1131,11 @@ static double nsvg__atof(const char* s)
|
|||||||
|
|
||||||
// Parse optional exponent
|
// Parse optional exponent
|
||||||
if (*cur == 'e' || *cur == 'E') {
|
if (*cur == 'e' || *cur == 'E') {
|
||||||
int expPart = 0;
|
double expPart = 0;
|
||||||
cur++; // skip 'E'
|
cur++; // skip 'E'
|
||||||
expPart = strtol(cur, &end, 10); // Parse digit sequence with sign
|
expPart = (double)strtol(cur, &end, 10); // Parse digit sequence with sign
|
||||||
if (cur != end) {
|
if (cur != end) {
|
||||||
res *= pow(10.0, (double)expPart);
|
res *= pow(10.0, expPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,17 +25,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef HAVE_LONG_LONG
|
#if !defined(HAVE_LONG_LONG)
|
||||||
typedef long long fl_nsvg_int;
|
static double strtoll(const char *str, char **endptr, int base) {
|
||||||
#else
|
return (double)strtol(str, endptr, base);
|
||||||
typedef long fl_nsvg_int;
|
}
|
||||||
# define strtoll(a, b, c) strtol(a, b, c)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define NANOSVG_ALL_COLOR_KEYWORDS // Include full list of color keywords.
|
#define NANOSVG_ALL_COLOR_KEYWORDS // Include full list of color keywords.
|
||||||
#define NANOSVG_IMPLEMENTATION // Expands implementation
|
#define NANOSVG_IMPLEMENTATION // Expands implementation
|
||||||
#include "../nanosvg/fl_nanosvg.h"
|
#include "../nanosvg/nanosvg.h"
|
||||||
|
|
||||||
#define NANOSVGRAST_IMPLEMENTATION // Expands implementation
|
#define NANOSVGRAST_IMPLEMENTATION // Expands implementation
|
||||||
#include "../nanosvg/altsvgrast.h"
|
#include "../nanosvg/altsvgrast.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user