diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-03-30 15:25:03 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-03-30 15:25:03 +0200 |
commit | 59ff521faa134a5bd2c4de3621eeadc98d272bac (patch) | |
tree | 165f4275edd59d8438a8e59f055fbfe59f8b9b5e /xps/xpsmem.c | |
parent | 7099f3ec854cdaa5f5f63759703d307fadcfd1a1 (diff) | |
download | mupdf-59ff521faa134a5bd2c4de3621eeadc98d272bac.tar.xz |
xps: Use fitz memory and string functions.
Diffstat (limited to 'xps/xpsmem.c')
-rw-r--r-- | xps/xpsmem.c | 62 |
1 files changed, 4 insertions, 58 deletions
diff --git a/xps/xpsmem.c b/xps/xpsmem.c index baae4e80..a85b2117 100644 --- a/xps/xpsmem.c +++ b/xps/xpsmem.c @@ -21,60 +21,6 @@ xps_strcasecmp(char *a, char *b) return xps_tolower(*a) - xps_tolower(*b); } -int -xps_strlcpy(char *dst, const char *src, int size) -{ - register char *d = dst; - register const char *s = src; - register int n = size; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (size != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ -} - -int -xps_strlcat(char *dst, const char *src, int size) -{ - register char *d = dst; - register const char *s = src; - register int n = size; - int dlen; - - /* Find the end of dst and adjust bytes left but don't go past end */ - while (*d != '\0' && n-- != 0) - d++; - dlen = d - dst; - n = size - dlen; - - if (n == 0) - return dlen + strlen(s); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; - n--; - } - s++; - } - *d = '\0'; - - return dlen + (s - src); /* count does not include NUL */ -} - #define SEP(x) ((x)=='/' || (x) == 0) static char * @@ -137,13 +83,13 @@ xps_absolute_path(char *output, char *base_uri, char *path, int output_size) { if (path[0] == '/') { - xps_strlcpy(output, path, output_size); + fz_strlcpy(output, path, output_size); } else { - xps_strlcpy(output, base_uri, output_size); - xps_strlcat(output, "/", output_size); - xps_strlcat(output, path, output_size); + fz_strlcpy(output, base_uri, output_size); + fz_strlcat(output, "/", output_size); + fz_strlcat(output, path, output_size); } xps_clean_path(output); } |