summaryrefslogtreecommitdiff
path: root/fitz/base_string.c
diff options
context:
space:
mode:
Diffstat (limited to 'fitz/base_string.c')
-rw-r--r--fitz/base_string.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/fitz/base_string.c b/fitz/base_string.c
index dd9f8ea2..8ed08911 100644
--- a/fitz/base_string.c
+++ b/fitz/base_string.c
@@ -1,11 +1,4 @@
-#include "fitz.h"
-
-int
-fz_is_big_endian(void)
-{
- static const int one = 1;
- return *(char*)&one == 0;
-}
+#include "fitz-internal.h"
char *
fz_strsep(char **stringp, const char *delim)
@@ -36,8 +29,8 @@ fz_strlcpy(char *dst, const char *src, int siz)
if (n == 0) {
if (siz != 0)
*d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
+ while (*s++)
+ ;
}
return(s - src - 1); /* count does not include NUL */
@@ -108,7 +101,7 @@ enum
};
int
-chartorune(int *rune, char *str)
+fz_chartorune(int *rune, char *str)
{
int c, c1, c2, c3;
long l;
@@ -183,16 +176,15 @@ bad:
}
int
-runetochar(char *str, int *rune)
+fz_runetochar(char *str, int rune)
{
/* Runes are signed, so convert to unsigned for range check. */
- unsigned long c;
+ unsigned long c = (unsigned long)rune;
/*
* one character sequence
* 00000-0007F => 00-7F
*/
- c = *rune;
if(c <= Rune1) {
str[0] = c;
return 1;
@@ -240,10 +232,10 @@ runetochar(char *str, int *rune)
}
int
-runelen(int c)
+fz_runelen(int c)
{
char str[10];
- return runetochar(str, &c);
+ return fz_runetochar(str, c);
}
float fz_atof(const char *s)
@@ -256,10 +248,11 @@ float fz_atof(const char *s)
* as we convert to a float. */
errno = 0;
d = strtod(s, NULL);
- if (errno == ERANGE || d > FLT_MAX || d < -FLT_MAX) {
+ if (errno == ERANGE || isnan(d)) {
/* Return 1.0, as it's a small known value that won't cause a
- * divide by 0. */
+ divide by 0. */
return 1.0;
}
+ d = CLAMP(d, -FLT_MAX, FLT_MAX);
return (float)d;
}