Browse Source

Fixed file access code to use UTF-8 strings (STR #2440)

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7874 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
pull/49/head
Matthias Melcher 15 years ago
parent
commit
1e77c19688
  1. 1
      CHANGES
  2. 2
      fluid/Fl_Function_Type.cxx
  3. 4
      fluid/Fluid_Image.cxx
  4. 6
      fluid/code.cxx
  5. 4
      fluid/file.cxx
  6. 13
      fluid/fluid.cxx
  7. 3
      src/Fl_BMP_Image.cxx
  8. 2
      src/Fl_File_Icon2.cxx
  9. 3
      src/Fl_JPEG_Image.cxx
  10. 4
      test/colbrowser.cxx
  11. 4
      test/demo.cxx
  12. 4
      test/file_chooser.cxx

1
CHANGES

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
CHANGES IN FLTK 1.3.0
- Fixed file access code to use UTF-8 strings (STR #2440)
- Fixed ARM Unicode cross compilation issue (STR #2432)
- Improved support for faulty X11 clients (STR #2385)
- Fixed xclass support for Fl_Window (STR #2053)

2
fluid/Fl_Function_Type.cxx

@ -879,7 +879,7 @@ void Fl_Data_Type::write_code1() { @@ -879,7 +879,7 @@ void Fl_Data_Type::write_code1() {
int nData = -1;
// path should be set correctly already
if (filename_ && !write_sourceview) {
FILE *f = fopen(filename_, "rb");
FILE *f = fl_fopen(filename_, "rb");
if (!f) {
message = "Can't include binary file. Can't open";
} else {

4
fluid/Fluid_Image.cxx

@ -111,7 +111,7 @@ void Fluid_Image::write_static() { @@ -111,7 +111,7 @@ void Fluid_Image::write_static() {
write_c("static unsigned char %s[] =\n",
unique_id(this, "idata", fl_filename_name(name()), 0));
FILE *f = fopen(name(), "rb");
FILE *f = fl_fopen(name(), "rb");
if (!f) {
// message = "Can't include binary file. Can't open";
} else {
@ -180,7 +180,7 @@ Fluid_Image* Fluid_Image::find(const char *iname) { @@ -180,7 +180,7 @@ Fluid_Image* Fluid_Image::find(const char *iname) {
// no, so now see if the file exists:
goto_source_dir();
FILE *f = fopen(iname,"rb");
FILE *f = fl_fopen(iname,"rb");
if (!f) {
read_error("%s : %s",iname,strerror(errno));
leave_source_dir();

6
fluid/code.cxx

@ -354,13 +354,13 @@ int write_code(const char *s, const char *t) { @@ -354,13 +354,13 @@ int write_code(const char *s, const char *t) {
current_widget_class = 0L;
if (!s) code_file = stdout;
else {
FILE *f = fopen(s, filemode);
FILE *f = fl_fopen(s, filemode);
if (!f) return 0;
code_file = f;
}
if (!t) header_file = stdout;
else {
FILE *f = fopen(t, filemode);
FILE *f = fl_fopen(t, filemode);
if (!f) {fclose(code_file); return 0;}
header_file = f;
}
@ -468,7 +468,7 @@ int write_code(const char *s, const char *t) { @@ -468,7 +468,7 @@ int write_code(const char *s, const char *t) {
}
int write_strings(const char *sfile) {
FILE *fp = fopen(sfile, "w");
FILE *fp = fl_fopen(sfile, "w");
Fl_Type *p;
Fl_Widget_Type *w;
int i;

4
fluid/file.cxx

@ -43,7 +43,7 @@ static FILE *fout; @@ -43,7 +43,7 @@ static FILE *fout;
int open_write(const char *s) {
if (!s) {fout = stdout; return 1;}
FILE *f = fopen(s,"w");
FILE *f = fl_fopen(s,"w");
if (!f) return 0;
fout = f;
return 1;
@ -135,7 +135,7 @@ static const char *fname; @@ -135,7 +135,7 @@ static const char *fname;
int open_read(const char *s) {
lineno = 1;
if (!s) {fin = stdin; fname = "stdin"; return 1;}
FILE *f = fopen(s,"r");
FILE *f = fl_fopen(s,"r");
if (!f) return 0;
fin = f;
fname = s;

13
fluid/fluid.cxx

@ -326,7 +326,7 @@ void save_template_cb(Fl_Widget *, void *) { @@ -326,7 +326,7 @@ void save_template_cb(Fl_Widget *, void *) {
FILE *fp;
if ((fp = fopen(filename, "wb")) == NULL) {
if ((fp = fl_fopen(filename, "wb")) == NULL) {
delete[] pixels;
fl_alert("Error writing %s: %s", filename, strerror(errno));
return;
@ -354,7 +354,7 @@ void save_template_cb(Fl_Widget *, void *) { @@ -354,7 +354,7 @@ void save_template_cb(Fl_Widget *, void *) {
# if 0 // The original PPM output code...
strcpy(ext, ".ppm");
fp = fopen(filename, "wb");
fp = fl_fopen(filename, "wb");
fprintf(fp, "P6\n%d %d 255\n", w, h);
fwrite(pixels, w * h, 3, fp);
fclose(fp);
@ -595,7 +595,7 @@ void new_cb(Fl_Widget *, void *v) { @@ -595,7 +595,7 @@ void new_cb(Fl_Widget *, void *v) {
char line[1024], *ptr, *next;
FILE *infile, *outfile;
if ((infile = fopen(tname, "r")) == NULL) {
if ((infile = fl_fopen(tname, "r")) == NULL) {
fl_alert("Error reading template file \"%s\":\n%s", tname,
strerror(errno));
set_modflag(0);
@ -603,7 +603,7 @@ void new_cb(Fl_Widget *, void *v) { @@ -603,7 +603,7 @@ void new_cb(Fl_Widget *, void *v) {
return;
}
if ((outfile = fopen(cutfname(1), "w")) == NULL) {
if ((outfile = fl_fopen(cutfname(1), "w")) == NULL) {
fl_alert("Error writing buffer file \"%s\":\n%s", cutfname(1),
strerror(errno));
fclose(infile);
@ -1252,7 +1252,7 @@ void print_cb(Fl_Return_Button *, void *) { @@ -1252,7 +1252,7 @@ void print_cb(Fl_Return_Button *, void *) {
"Replace", NULL, outname) == 0) outname = NULL;
}
if (outname) outfile = fopen(outname, "w");
if (outname) outfile = fl_fopen(outname, "w");
else outfile = NULL;
}
@ -1909,8 +1909,9 @@ public: @@ -1909,8 +1909,9 @@ public:
Fl_Process() {_fpt= NULL;}
~Fl_Process() {if (_fpt) close();}
// FIXME: popen needs the utf8 equivalen fl_popen
FILE * popen (const char *cmd, const char *mode="r");
//not necessary here: FILE * fopen (const char *file, const char *mode="r");
//not necessary here: FILE * fl_fopen (const char *file, const char *mode="r");
int close();
FILE * desc() const { return _fpt;} // non null if file is open

3
src/Fl_BMP_Image.cxx

@ -35,6 +35,7 @@ @@ -35,6 +35,7 @@
//
#include <FL/Fl_BMP_Image.H>
#include <FL/fl_utf8.h>
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@ -93,7 +94,7 @@ Fl_BMP_Image::Fl_BMP_Image(const char *bmp) // I - File to read @@ -93,7 +94,7 @@ Fl_BMP_Image::Fl_BMP_Image(const char *bmp) // I - File to read
// Open the file...
if ((fp = fopen(bmp, "rb")) == NULL) return;
if ((fp = fl_fopen(bmp, "rb")) == NULL) return;
// Get the header...
byte = (uchar)getc(fp); // Check "BM" sync chars

2
src/Fl_File_Icon2.cxx

@ -853,7 +853,7 @@ load_kde_mimelnk(const char *filename, // I - mimelnk filename @@ -853,7 +853,7 @@ load_kde_mimelnk(const char *filename, // I - mimelnk filename
pattern[0] = '\0';
iconfilename[0] = '\0';
if ((fp = fopen(filename, "rb")) != NULL) {
if ((fp = fl_fopen(filename, "rb")) != NULL) {
while (fgets(tmp, sizeof(tmp), fp)) {
if ((val = get_kde_val(tmp, "Icon")) != NULL)
strlcpy(iconfilename, val, sizeof(iconfilename));

3
src/Fl_JPEG_Image.cxx

@ -35,6 +35,7 @@ @@ -35,6 +35,7 @@
//
#include <FL/Fl_JPEG_Image.H>
#include <FL/fl_utf8.h>
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@ -117,7 +118,7 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *filename) // I - File to load @@ -117,7 +118,7 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *filename) // I - File to load
array = (uchar *)0;
// Open the image file...
if ((fp = fopen(filename, "rb")) == NULL) return;
if ((fp = fl_fopen(filename, "rb")) == NULL) return;
// Setup the decompressor info and read the header...
dinfo.err = jpeg_std_error((jpeg_error_mgr *)&jerr);

4
test/colbrowser.cxx

@ -149,9 +149,9 @@ load_browser(char *fname) @@ -149,9 +149,9 @@ load_browser(char *fname)
int r, g, b, lr = -1 , lg = -1, lb = -1;
char name[256], buf[256];
#ifdef __EMX__
if (!(fp = fopen(__XOS2RedirRoot(fname), "r")))
if (!(fp = fl_fopen(__XOS2RedirRoot(fname), "r")))
#else
if (!(fp = fopen(fname, "r")))
if (!(fp = fl_fopen(fname, "r")))
#endif
{
fl_alert("%s\n%s\n%s","Load", fname, "Can't open");

4
test/demo.cxx

@ -434,7 +434,7 @@ int load_the_menu(const char* fname) @@ -434,7 +434,7 @@ int load_the_menu(const char* fname)
FILE *fin = 0;
char line[256], mname[64],iname[64],cname[64];
int i,j, mi = 0;
fin = fopen(fname,"r");
fin = fl_fopen(fname,"r");
if (fin == NULL)
{
#if defined ( __APPLE__ )
@ -445,7 +445,7 @@ int load_the_menu(const char* fname) @@ -445,7 +445,7 @@ int load_the_menu(const char* fname)
pos = strrchr(fname,'/');
if (!pos) return 0;
strcpy(pos,"/Resources/demo.menu");
fin = fopen(fname,"r");
fin = fl_fopen(fname,"r");
#endif
}
// if "fin" is still NULL, we will read the menu from the string array in the

4
test/file_chooser.cxx

@ -304,8 +304,8 @@ ps_check(const char *name, // I - Name of file @@ -304,8 +304,8 @@ ps_check(const char *name, // I - Name of file
sprintf(outname, "%s/.preview.ps", home ? home : "");
if (strcmp(name, outname) != 0) {
in = fopen(name, "rb");
out = fopen(outname, "wb");
in = fl_fopen(name, "rb");
out = fl_fopen(outname, "wb");
page = 0;
while (fgets(line, sizeof(line), in) != NULL) {

Loading…
Cancel
Save