diff options
| author | Manolo Gouy <Manolo> | 2017-10-04 12:21:46 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2017-10-04 12:21:46 +0000 |
| commit | 7a9d5be6cb2ae831b3c2409788d3a31aa61d62b9 (patch) | |
| tree | 69d644c3dad77a599f4f85dbd376bd43a31cf94d | |
| parent | 5e6bf76b0a75f84dcdaa277d1aef7ab76e2d0631 (diff) | |
Undo commit at r.12475 that is not adequate.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12476 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | FL/Fl_System_Driver.H | 1 | ||||
| -rw-r--r-- | FL/fl_utf8.h | 3 | ||||
| -rw-r--r-- | src/Fl_SVG_Image.cxx | 50 | ||||
| -rw-r--r-- | src/drivers/Posix/Fl_Posix_System_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/Posix/Fl_Posix_System_Driver.cxx | 15 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx | 16 | ||||
| -rw-r--r-- | src/fl_images_core.cxx | 14 | ||||
| -rw-r--r-- | src/fl_utf8.cxx | 9 | ||||
| -rw-r--r-- | test/pixmap_browser.cxx | 3 |
10 files changed, 6 insertions, 107 deletions
diff --git a/FL/Fl_System_Driver.H b/FL/Fl_System_Driver.H index fe8c03aab..bd73a96f9 100644 --- a/FL/Fl_System_Driver.H +++ b/FL/Fl_System_Driver.H @@ -218,7 +218,6 @@ public: virtual const char *meta_name() { return "Meta"; } virtual const char *alt_name() { return "Alt"; } virtual const char *control_name() { return "Ctrl"; } - virtual void* gzopen(const char *fname, const char *mode) { return NULL; } }; #endif // FL_SYSTEM_DRIVER_H diff --git a/FL/fl_utf8.h b/FL/fl_utf8.h index 2215f4b63..ca4ac27e9 100644 --- a/FL/fl_utf8.h +++ b/FL/fl_utf8.h @@ -176,9 +176,6 @@ FL_EXPORT int fl_execvp(const char *file, char *const *argv); /* OD: Portable UTF-8 aware open wrapper */ FL_EXPORT int fl_open(const char* f, int o, ...); - -/* OD: Portable UTF-8 aware gzopen wrapper */ -FL_EXPORT void* fl_gzopen(const char* fname, const char *mode); /* OD: Portable UTF-8 aware unlink wrapper */ FL_EXPORT int fl_unlink(const char *f); diff --git a/src/Fl_SVG_Image.cxx b/src/Fl_SVG_Image.cxx index 05b85b942..c30227daa 100644 --- a/src/Fl_SVG_Image.cxx +++ b/src/Fl_SVG_Image.cxx @@ -24,12 +24,8 @@ #include <FL/fl_utf8.h> #include <FL/fl_draw.H> #include <FL/Fl_Screen_Driver.H> -#include <FL/Fl_System_Driver.H> #include <stdio.h> #include <stdlib.h> -#if defined(HAVE_LIBZ) -#include <zlib.h> -#endif #if !defined(HAVE_LONG_LONG) static double strtoll(const char *str, char **endptr, int base) { @@ -45,8 +41,8 @@ static double strtoll(const char *str, char **endptr, int base) { #include "../nanosvg/altsvgrast.h" -/** The constructor loads the SVG image from the given .svg/.svgz filename or in-memory data. - \param filename A full path and name pointing to a .svg or .svgz file, or NULL. +/** The constructor loads the SVG image from the given .svg filename or in-memory data. + \param filename A full path and name pointing to an SVG file, or NULL. \param filedata A pointer to the memory location of the SVG image data. This parameter allows to load an SVG image from in-memory data, and is used when \p filename is NULL. \note In-memory SVG data is modified by the object constructor and is no longer used after construction. @@ -77,35 +73,6 @@ float Fl_SVG_Image::svg_scaling_(int W, int H) { return (f1 < f2) ? f1 : f2; } -#if defined(HAVE_LIBZ) - -static char *svg_inflate(const char *fname) { - struct stat b; - fl_stat(fname, &b); - long size = b.st_size; - gzFile gzf = (gzFile)fl_gzopen(fname, "r"); - int l; - bool direct = gzdirect(gzf); - long out_size = direct ? size + 1 : 3*size + 1; - char *out = (char*)malloc(out_size); - char *p = out; - do { - if ((!direct) && p + size > out + out_size) { - out_size += size; - char *tmp = (char*)realloc(out, out_size + 1); - p = tmp + (p - out); - out = tmp; - } - l = gzread(gzf, p, size); - if (l > 0) { - p += l; *p = 0; - } - } while ((!direct) && l >0); - gzclose(gzf); - if (!direct) out = (char*)realloc(out, (p-out)+1); - return out; -} -#endif void Fl_SVG_Image::init_(const char *filename, char *filedata, Fl_SVG_Image *copy_source) { if (copy_source) { @@ -121,29 +88,22 @@ void Fl_SVG_Image::init_(const char *filename, char *filedata, Fl_SVG_Image *cop average_weight_ = 1; proportional = true; if (filename) { -#if defined(HAVE_LIBZ) - filedata = svg_inflate(filename); -#else filedata = NULL; FILE *fp = fl_fopen(filename, "rb"); if (fp) { fseek(fp, 0, SEEK_END); - long size = ftell(fp); + size_t size = ftell(fp); fseek(fp, 0, SEEK_SET); filedata = (char*)malloc(size+1); if (filedata) { - if (fread(filedata, 1, size, fp) == size) { - filedata[size] = '\0'; - } + if (fread(filedata, 1, size, fp) == size) filedata[size] = '\0'; else { free(filedata); filedata = NULL; } } fclose(fp); - } -#endif // HAVE_LIBZ - if (!filedata) ld(ERR_FILE_ACCESS); + } else ld(ERR_FILE_ACCESS); } if (filedata) { counted_svg_image_->svg_image = nsvgParse(filedata, "px", 96); diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.H b/src/drivers/Posix/Fl_Posix_System_Driver.H index 9ef8a2909..5b2060283 100644 --- a/src/drivers/Posix/Fl_Posix_System_Driver.H +++ b/src/drivers/Posix/Fl_Posix_System_Driver.H @@ -75,7 +75,6 @@ public: virtual const char *home_directory_name() { return ::getenv("HOME"); } virtual int dot_file_hidden() {return 1;} virtual void gettime(time_t *sec, int *usec); - virtual void* gzopen(const char *fname, const char *mode); }; #endif // FL_POSIX_SYSTEM_DRIVER_H diff --git a/src/drivers/Posix/Fl_Posix_System_Driver.cxx b/src/drivers/Posix/Fl_Posix_System_Driver.cxx index f603c2d17..c2576b268 100644 --- a/src/drivers/Posix/Fl_Posix_System_Driver.cxx +++ b/src/drivers/Posix/Fl_Posix_System_Driver.cxx @@ -34,9 +34,6 @@ #include <pwd.h> #include <unistd.h> #include <time.h> -#if defined(HAVE_LIBZ) -# include <zlib.h> -#endif // // Define missing POSIX/XPG4 macros as needed... @@ -102,18 +99,6 @@ void Fl_Posix_System_Driver::gettime(time_t *sec, int *usec) { *usec = tv.tv_usec; } -void* Fl_Posix_System_Driver::gzopen(const char *fname, const char *mode) { -#if defined(HAVE_LIBZ) - FILE *in = fl_fopen(fname, mode); - if (!in) return NULL; - int fd = dup(fileno(in)); - fclose(in); - return gzdopen(fd, mode); -#else - return NULL; -#endif -} - // // End of "$Id$". // diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H index 99b5b0871..43e0f54e2 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.H @@ -117,7 +117,6 @@ public: virtual void remove_fd(int, int when); virtual void remove_fd(int); virtual void gettime(time_t *sec, int *usec); - virtual void* gzopen(const char *fname, const char *mode); }; #endif // FL_WINAPI_SYSTEM_DRIVER_H diff --git a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx index b0a4c52e1..efbe65d01 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_System_Driver.cxx @@ -50,9 +50,6 @@ typedef RPC_STATUS (WINAPI* uuid_func)(UUID __RPC_FAR *Uuid); #ifdef __CYGWIN__ # include <mntent.h> #endif -#if defined(HAVE_LIBZ) -# include <zlib.h> -#endif inline int isdirsep(char c) { return c == '/' || c == '\\'; } @@ -911,19 +908,6 @@ void Fl_WinAPI_System_Driver::gettime(time_t *sec, int *usec) { *usec = t.millitm * 1000; } -void* Fl_WinAPI_System_Driver::gzopen(const char *fname, const char *mode) { -#if defined(HAVE_LIBZ) - unsigned wl = fl_utf8towc(fname, strlen(fname), NULL, 0) + 1; - wchar_t *wc = new wchar_t[wl]; - fl_utf8towc(fname, strlen(fname), wc, wl); - gzFile gzf = gzopen_w(wc, mode); - delete[] wc; - return gzf; -#else - return NULL; -#endif -} - // // End of "$Id$". // diff --git a/src/fl_images_core.cxx b/src/fl_images_core.cxx index 0a048fa5d..5af696764 100644 --- a/src/fl_images_core.cxx +++ b/src/fl_images_core.cxx @@ -32,13 +32,10 @@ #include <FL/Fl_PNG_Image.H> #include <FL/Fl_PNM_Image.H> #include <FL/Fl_SVG_Image.H> -#include <FL/Fl_System_Driver.H> #include <stdio.h> #include <stdlib.h> #include "flstring.h" -#if defined(HAVE_LIBZ) -#include <zlib.h> -#endif + // // Define a simple global image registration function that registers @@ -93,15 +90,6 @@ fl_check_images(const char *name, // I - Filename #endif // HAVE_LIBJPEG #ifdef FLTK_USE_NANOSVG -# if defined(HAVE_LIBZ) - if (header[0] == 0x1f && header[1] == 0x8b) { - gzFile gzf = (gzFile)fl_gzopen(name, "r"); - if (gzf) { - gzread(gzf, header, headerlen); - gzclose(gzf); - } - } -# endif // HAVE_LIBZ if ( (headerlen > 5 && memcmp(header, "<?xml", 5) == 0) || memcmp(header, "<svg", 4) == 0) return new Fl_SVG_Image(name); diff --git a/src/fl_utf8.cxx b/src/fl_utf8.cxx index 59a16dbf9..b7d58eecd 100644 --- a/src/fl_utf8.cxx +++ b/src/fl_utf8.cxx @@ -335,15 +335,6 @@ FILE *fl_fopen(const char* f, const char *mode) { return Fl::system_driver()->fopen(f, mode); } -/** Same as function gzopen() of zlib, but accepts a UTF-8 encoded filename. - \param fname The UTF-8 encoded filename. - \param mode as in the standard fopen() function - \return A pointer of type gzFile, or NULL if the file can't be opened. - */ -void* fl_gzopen(const char* fname, const char *mode) { - return Fl::system_driver()->gzopen(fname, mode); -} - /** Cross-platform function to run a system command with a UTF-8 encoded string. This function is especially useful under the MSWindows platform where diff --git a/test/pixmap_browser.cxx b/test/pixmap_browser.cxx index 344b3a30b..6de037e5e 100644 --- a/test/pixmap_browser.cxx +++ b/test/pixmap_browser.cxx @@ -79,9 +79,6 @@ void button_cb(Fl_Widget *,void *) { const char *fname = fl_file_chooser("Image file?","*.{bm,bmp,gif,jpg,pbm,pgm,png,ppm,xbm,xpm" #ifdef FLTK_USE_NANOSVG ",svg" -# if defined(HAVE_LIBZ) - ",svgz" -# endif #endif "}", name); puts(fname ? fname : "(null)"); fflush(stdout); |
