]> git.donarmstrong.com Git - xournal.git/commitdiff
Update to 0.3.1 (fix bug with LC_NUMERIC)
authorauroux <auroux>
Sun, 6 Aug 2006 21:38:12 +0000 (21:38 +0000)
committerauroux <auroux>
Sun, 6 Aug 2006 21:38:12 +0000 (21:38 +0000)
ChangeLog
NEWS
README
configure.in
html-doc/manual.html
src/xo-file.c
src/xo-print.c

index b0cec9e93b4af8ac0c84b513a922e98d2c351c14..77b77392b6ee8de29e8acddb3457b43d2ad5cef9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+Version 0.3.1 (Aug 3, 2006):
+  - fixed a file format bug on systems with non-standard numeric locale
+
 Version 0.3 (Jul 23, 2006):
   - new PDF rendering engine: export to PDF generates optimized files
     (smaller and more accurate)
diff --git a/NEWS b/NEWS
index f48165a3c57085d59e5aa617127c630f3b6221c9..59b1c495c05490bf236980d49b8cd07e8de6631e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Version 0.3 (July 23, 2006)
+Version 0.3.1 (August 3, 2006)
 
 Installation:  see INSTALL
 User's manual: see html-doc/manual.html
diff --git a/README b/README
index f48165a3c57085d59e5aa617127c630f3b6221c9..59b1c495c05490bf236980d49b8cd07e8de6631e 100644 (file)
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Version 0.3 (July 23, 2006)
+Version 0.3.1 (August 3, 2006)
 
 Installation:  see INSTALL
 User's manual: see html-doc/manual.html
index e16b40f8c39bc42d339a41f76ceb54f2018b9bd6..a898e9882261bde448cd0001aea68acc9d8b56b0 100644 (file)
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 
 AC_INIT(configure.in)
-AM_INIT_AUTOMAKE(xournal, 0.3)
+AM_INIT_AUTOMAKE(xournal, 0.3.1)
 AM_CONFIG_HEADER(config.h)
 AM_MAINTAINER_MODE
 
index 5ed27187ceb82ebbff7bf42213e5d7129147f69e..be75dea015668eb7605e5a7181e92acff986d1b9 100644 (file)
@@ -24,7 +24,7 @@
   Xournal User's Manual
 </h2>
 <p style="font-size: 0.95em; text-align: center; color: rgb(0,0,0)">
- Version 0.3
+ Version 0.3.1
 </p>
 <hr />
 <p>
@@ -499,6 +499,11 @@ Bug reports and suggestions can also be submitted on Xournal's
 <a name="changelog"></a>
 <h2 class="subtitle">Version history</h2>
 <p>
+Version 0.3.1 (August 3, 2006):
+<ul>
+ <li>fixed a file format bug on systems with non-standard numeric locale</li>
+</p>
+<p>
 Version 0.3 (July 23, 2006):
 <ul>
  <li>new PDF rendering engine: export to PDF generates optimized files
index 1afcd18436545f71ba535a797986d55569625dd6..04992f96cf433ff64c3fa63d9da62d55040d9abe 100644 (file)
@@ -13,6 +13,7 @@
 #include <math.h>
 #include <gdk/gdkx.h>
 #include <X11/Xlib.h>
+#include <locale.h>
 
 #include "xournal.h"
 #include "xo-interface.h"
@@ -81,6 +82,8 @@ gboolean save_journal(const char *filename)
   f = gzopen(filename, "w");
   if (f==NULL) return FALSE;
   chk_attach_names();
+
+  setlocale(LC_NUMERIC, "C");
   
   gzprintf(f, "<?xml version=\"1.0\" standalone=\"no\"?>\n"
      "<title>Xournal document - see http://math.mit.edu/~auroux/software/xournal/</title>\n"
@@ -179,6 +182,8 @@ gboolean save_journal(const char *filename)
     gzprintf(f, "</page>\n");
   }
   gzclose(f);
+  setlocale(LC_NUMERIC, "");
+
   return TRUE;
 }
 
@@ -201,6 +206,13 @@ gboolean close_journal(void)
      use new_journal() to reinitialize them */
 }
 
+// sanitize a string containing floats, in case it may have , instead of .
+
+void cleanup_numeric(char *s)
+{
+  while (*s!=0) { if (*s==',') *s='.'; s++; }
+}
+
 // the XML parser functions for open_journal()
 
 struct Journal tmpJournal;
@@ -253,13 +265,15 @@ void xoj_parser_start_element(GMarkupParseContext *context,
     while (*attribute_names!=NULL) {
       if (!strcmp(*attribute_names, "width")) {
         if (has_attr & 1) *error = xoj_invalid();
-        tmpPage->width = strtod(*attribute_values, &ptr);
+        cleanup_numeric((gchar *)*attribute_values);
+        tmpPage->width = g_ascii_strtod(*attribute_values, &ptr);
         if (ptr == *attribute_values) *error = xoj_invalid();
         has_attr |= 1;
       }
       else if (!strcmp(*attribute_names, "height")) {
         if (has_attr & 2) *error = xoj_invalid();
-        tmpPage->height = strtod(*attribute_values, &ptr);
+        cleanup_numeric((gchar *)*attribute_values);
+        tmpPage->height = g_ascii_strtod(*attribute_values, &ptr);
         if (ptr == *attribute_values) *error = xoj_invalid();
         has_attr |= 2;
       }
@@ -374,7 +388,7 @@ void xoj_parser_start_element(GMarkupParseContext *context,
       else if (!strcmp(*attribute_names, "pageno")) {
         if (tmpPage->bg->type != BG_PDF || (has_attr & 32))
           { *error = xoj_invalid(); return; }
-        tmpPage->bg->file_page_seq = strtod(*attribute_values, &ptr);
+        tmpPage->bg->file_page_seq = strtol(*attribute_values, &ptr, 10);
         if (ptr == *attribute_values) *error = xoj_invalid();
         has_attr |= 32;
       }
@@ -415,7 +429,8 @@ void xoj_parser_start_element(GMarkupParseContext *context,
     while (*attribute_names!=NULL) {
       if (!strcmp(*attribute_names, "width")) {
         if (has_attr & 1) *error = xoj_invalid();
-        tmpItem->brush.thickness = strtod(*attribute_values, &ptr);
+        cleanup_numeric((gchar *)*attribute_values);
+        tmpItem->brush.thickness = g_ascii_strtod(*attribute_values, &ptr);
         if (ptr == *attribute_values) *error = xoj_invalid();
         has_attr |= 1;
       }
@@ -496,11 +511,12 @@ void xoj_parser_text(GMarkupParseContext *context,
   element_name = g_markup_parse_context_get_element(context);
   if (element_name == NULL) return;
   if (!strcmp(element_name, "stroke")) {
+    cleanup_numeric((gchar *)text);
     ptr = text;
     n = 0;
     while (text_len > 0) {
       realloc_cur_path(n/2 + 1);
-      ui.cur_path.coords[n] = strtod(text, (char **)(&ptr));
+      ui.cur_path.coords[n] = g_ascii_strtod(text, (char **)(&ptr));
       if (ptr == text) break;
       text_len -= (ptr - text);
       text = ptr;
index 04493c9c010d59f3c4e79ae72173ec3154f557dd..2050f85badb4d983ba20b025577935e09f42a066 100644 (file)
@@ -7,6 +7,7 @@
 #include <libgnomeprint/gnome-print-job.h>
 #include <zlib.h>
 #include <string.h>
+#include <locale.h>
 
 #include "xournal.h"
 #include "xo-misc.h"
@@ -182,7 +183,7 @@ struct PdfObj *parse_pdf_object(char **ptr, char *eof)
   if (q!=p) {
     if (*q == '.') {
       obj->type = PDFTYPE_REAL;
-      obj->realval = strtod(p, ptr);
+      obj->realval = g_ascii_strtod(p, ptr);
       return obj;
     }
     if (ispdfspace(*q)) {
@@ -820,6 +821,7 @@ gboolean print_to_pdf(char *filename)
   
   f = fopen(filename, "w");
   if (f == NULL) return FALSE;
+  setlocale(LC_NUMERIC, "C");
   annot = FALSE;
   xref.data = NULL;
   uses_pdf = FALSE;
@@ -992,9 +994,15 @@ gboolean print_to_pdf(char *filename)
   g_free(xref.data);
   if (annot) {
     free_pdfobj(pdfinfo.trailerdict);
-    // ...
+    if (pdfinfo.pages!=NULL)
+      for (i=0; i<pdfinfo.npages; i++) {
+        free_pdfobj(pdfinfo.pages[i].resources);
+        free_pdfobj(pdfinfo.pages[i].mediabox);
+        free_pdfobj(pdfinfo.pages[i].contents);
+      }
   }
   
+  setlocale(LC_NUMERIC, "");
   if (fwrite(pdfbuf->str, 1, pdfbuf->len, f) < pdfbuf->len) {
     fclose(f);
     g_string_free(pdfbuf, TRUE);