Author: matt
Date: 2010-11-18 12:00:01 -0800 (Thu, 18 Nov 2010)
New Revision: 7874
Log:
Fixed file access code to use UTF-8 strings (STR #2440)

Modified:
   branches/branch-1.3/CHANGES
   branches/branch-1.3/fluid/Fl_Function_Type.cxx
   branches/branch-1.3/fluid/Fluid_Image.cxx
   branches/branch-1.3/fluid/code.cxx
   branches/branch-1.3/fluid/file.cxx
   branches/branch-1.3/fluid/fluid.cxx
   branches/branch-1.3/src/Fl_BMP_Image.cxx
   branches/branch-1.3/src/Fl_File_Icon2.cxx
   branches/branch-1.3/src/Fl_JPEG_Image.cxx
   branches/branch-1.3/test/colbrowser.cxx
   branches/branch-1.3/test/demo.cxx
   branches/branch-1.3/test/file_chooser.cxx

Modified: branches/branch-1.3/CHANGES
===================================================================
--- branches/branch-1.3/CHANGES 2010-11-18 18:43:41 UTC (rev 7873)
+++ branches/branch-1.3/CHANGES 2010-11-18 20:00:01 UTC (rev 7874)
@@ -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)

Modified: branches/branch-1.3/fluid/Fl_Function_Type.cxx
===================================================================
--- branches/branch-1.3/fluid/Fl_Function_Type.cxx      2010-11-18 18:43:41 UTC 
(rev 7873)
+++ branches/branch-1.3/fluid/Fl_Function_Type.cxx      2010-11-18 20:00:01 UTC 
(rev 7874)
@@ -879,7 +879,7 @@
   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 {

Modified: branches/branch-1.3/fluid/Fluid_Image.cxx
===================================================================
--- branches/branch-1.3/fluid/Fluid_Image.cxx   2010-11-18 18:43:41 UTC (rev 
7873)
+++ branches/branch-1.3/fluid/Fluid_Image.cxx   2010-11-18 20:00:01 UTC (rev 
7874)
@@ -111,7 +111,7 @@
     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 @@
   // 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();

Modified: branches/branch-1.3/fluid/code.cxx
===================================================================
--- branches/branch-1.3/fluid/code.cxx  2010-11-18 18:43:41 UTC (rev 7873)
+++ branches/branch-1.3/fluid/code.cxx  2010-11-18 20:00:01 UTC (rev 7874)
@@ -354,13 +354,13 @@
   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_strings(const char *sfile) {
-  FILE *fp = fopen(sfile, "w");
+  FILE *fp = fl_fopen(sfile, "w");
   Fl_Type *p;
   Fl_Widget_Type *w;
   int i;

Modified: branches/branch-1.3/fluid/file.cxx
===================================================================
--- branches/branch-1.3/fluid/file.cxx  2010-11-18 18:43:41 UTC (rev 7873)
+++ branches/branch-1.3/fluid/file.cxx  2010-11-18 20:00:01 UTC (rev 7874)
@@ -43,7 +43,7 @@
 
 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 @@
 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;

Modified: branches/branch-1.3/fluid/fluid.cxx
===================================================================
--- branches/branch-1.3/fluid/fluid.cxx 2010-11-18 18:43:41 UTC (rev 7873)
+++ branches/branch-1.3/fluid/fluid.cxx 2010-11-18 20:00:01 UTC (rev 7874)
@@ -326,7 +326,7 @@
 
   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 @@
 
 #  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 @@
       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 @@
        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 @@
                    "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 @@
   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

Modified: branches/branch-1.3/src/Fl_BMP_Image.cxx
===================================================================
--- branches/branch-1.3/src/Fl_BMP_Image.cxx    2010-11-18 18:43:41 UTC (rev 
7873)
+++ branches/branch-1.3/src/Fl_BMP_Image.cxx    2010-11-18 20:00:01 UTC (rev 
7874)
@@ -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 @@
 
 
   // 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

Modified: branches/branch-1.3/src/Fl_File_Icon2.cxx
===================================================================
--- branches/branch-1.3/src/Fl_File_Icon2.cxx   2010-11-18 18:43:41 UTC (rev 
7873)
+++ branches/branch-1.3/src/Fl_File_Icon2.cxx   2010-11-18 20:00:01 UTC (rev 
7874)
@@ -853,7 +853,7 @@
   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));

Modified: branches/branch-1.3/src/Fl_JPEG_Image.cxx
===================================================================
--- branches/branch-1.3/src/Fl_JPEG_Image.cxx   2010-11-18 18:43:41 UTC (rev 
7873)
+++ branches/branch-1.3/src/Fl_JPEG_Image.cxx   2010-11-18 20:00:01 UTC (rev 
7874)
@@ -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 @@
   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);

Modified: branches/branch-1.3/test/colbrowser.cxx
===================================================================
--- branches/branch-1.3/test/colbrowser.cxx     2010-11-18 18:43:41 UTC (rev 
7873)
+++ branches/branch-1.3/test/colbrowser.cxx     2010-11-18 20:00:01 UTC (rev 
7874)
@@ -149,9 +149,9 @@
     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");

Modified: branches/branch-1.3/test/demo.cxx
===================================================================
--- branches/branch-1.3/test/demo.cxx   2010-11-18 18:43:41 UTC (rev 7873)
+++ branches/branch-1.3/test/demo.cxx   2010-11-18 20:00:01 UTC (rev 7874)
@@ -434,7 +434,7 @@
   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 @@
     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 

Modified: branches/branch-1.3/test/file_chooser.cxx
===================================================================
--- branches/branch-1.3/test/file_chooser.cxx   2010-11-18 18:43:41 UTC (rev 
7873)
+++ branches/branch-1.3/test/file_chooser.cxx   2010-11-18 20:00:01 UTC (rev 
7874)
@@ -304,8 +304,8 @@
     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) {

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to