Bläddra i källkod

Fix wrong length computations when writing to a file in UTF-8 or other multibyte charsets.

git-svn-id: file:///var/svn/tigccpp/trunk@919 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 17 år sedan
förälder
incheckning
e8e16f7bc4
2 ändrade filer med 5 tillägg och 2 borttagningar
  1. 3 0
      ktigcc/NEWS
  2. 2 2
      ktigcc/tpr.cpp

+ 3 - 0
ktigcc/NEWS

@@ -5,6 +5,9 @@ CVS HEAD (2006-11-16):
 * Added Anjuta 2 project, removed Anjuta 1 project.
 * Fixed missing layout in the Operating System tab of the Program Options
   dialog.
+* Fixed wrong length computations when writing to a file in UTF-8 or other
+  multibyte charsets. (This broke debugging information for projects in a path
+  containing non-ASCII characters.)
 
 
 KTIGCC 1.05 (2006-10-24):

+ 2 - 2
ktigcc/tpr.cpp

@@ -781,7 +781,7 @@ static int writeToFile(FILE *f, const QString &text)
     }
   } else {
     const char *s=smartAscii(text);
-    size_t l=text.length();
+    size_t l=std::strlen(s);
     if (fwrite(s,1,l,f)<l) return -2;
   }
   return 0;
@@ -1021,7 +1021,7 @@ int saveAndSplitFileText(const char *fileName, const QString &fileText,
                             :".appfile \"%1\"; .appline 1\n").arg(escapedFileName);
       // Don't use calc charset for this, it's a host file name.
       const char *s=smartAscii(lineDirective);
-      size_t l=lineDirective.length();
+      size_t l=std::strlen(s);
       if (fwrite(s,1,l,f)<l) return -2;
     }
     if (writeToFile(f,text)) {fclose(f); return -2;}