texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Texmacs-dev] A few small patches


From: Norbert Nemec
Subject: [Texmacs-dev] A few small patches
Date: Wed, 07 Oct 2009 18:44:04 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

Hi there,

I have here four small patches fixing some minor problems.

Greetings,
Norbert
>From e37863bec96b8b6b8e327b2a6971b949989e85e7 Mon Sep 17 00:00:00 2001
From: Norbert Nemec <address@hidden>
Date: Wed, 7 Oct 2009 12:16:56 +0100
Subject: [PATCH 01/11] Do selection_get_cut operations on the "tmp" buffer by 
default. The "primary" buffer should only be used by explicit cut&paste 
operations by the user.

---
 src/src/Edit/Replace/edit_select.cpp |   42 +++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/src/Edit/Replace/edit_select.cpp 
b/src/src/Edit/Replace/edit_select.cpp
index 571609a..82f7711 100644
--- a/src/src/Edit/Replace/edit_select.cpp
+++ b/src/src/Edit/Replace/edit_select.cpp
@@ -801,27 +801,27 @@ edit_select_rep::raw_cut (path p1, path p2) {
 void
 edit_select_rep::selection_cut (string key) {
   if (inside_active_graphics ()) {
-    tree t= as_tree (eval ("(graphics-cut)"));
-    selection_set (key, t);
-    return;
-  }
-  if (!selection_active_any ()) return;
-  if (selection_active_table ()) {
-    path p1= start_p, p2= end_p;
-    tree sel= selection_get ();
-    selection_set (key, sel);
-    cut (p1, p2);
-  }
-  else {
+    if(key != "none") {
+      tree t= as_tree (eval ("(graphics-cut)"));
+      selection_set (key, t);
+    }
+  } else if (selection_active_any ()) {
     path p1, p2;
-    selection_get (p1, p2);
-    go_to (p2);
-    if (p2 == p1) return;
-
-    tree sel= compute_selection (et, p1, p2);
-    // cout << "Selection " << sel << "\n";
-    selection_set (key, simplify_correct (sel));
-    // cout << "Selected  " << sel << "\n";
+    if (selection_active_table ()) {
+      p1= start_p; p2= end_p;
+      if(key != "none") {
+        tree sel= selection_get ();
+        selection_set (key, sel);
+      }
+    } else {
+      selection_get (p1, p2);
+      go_to (p2);
+      if (p2 == p1) return;
+      if(key != "none") {
+        tree sel= compute_selection (et, p1, p2);
+        selection_set (key, simplify_correct (sel));
+      }
+    }
     cut (p1, p2);
   }
 }
@@ -829,7 +829,7 @@ edit_select_rep::selection_cut (string key) {
 tree
 edit_select_rep::selection_get_cut () {
   tree t= selection_get ();
-  selection_cut ();
+  selection_cut ("none");
   return t;
 }
 
-- 
1.6.3.3

>From 5615cdc68f4838f1505f308be44be449b20da78e Mon Sep 17 00:00:00 2001
From: Norbert Nemec <address@hidden>
Date: Wed, 7 Oct 2009 12:16:56 +0100
Subject: [PATCH 02/11] Fix two minor memory leaks

---
 src/src/Plugins/X11/x_window.cpp  |   10 ++++++++--
 src/src/System/Misc/sys_utils.cpp |    5 ++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/src/Plugins/X11/x_window.cpp b/src/src/Plugins/X11/x_window.cpp
index ae42811..2ee5aec 100644
--- a/src/src/Plugins/X11/x_window.cpp
+++ b/src/src/Plugins/X11/x_window.cpp
@@ -66,6 +66,12 @@ x_window_rep::set_hints (SI min_w, SI min_h, SI max_w, SI 
max_h) {
     wm_hints,
     class_hints
   );
+
+  XFree(size_hints);
+  XFree(wm_hints);
+  XFree(class_hints);
+  XFree(Window_Name.value);
+  XFree(Icon_Name.value);
   // cout << "Setting hints required " << (texmacs_time ()-start_2) << " ms\n";
 }
 
@@ -78,7 +84,7 @@ x_window_rep::initialize () {
   dpy= gui->dpy;
   gc = gui->gc;
   full_screen_flag= false;
-  
+
   // int start_1= texmacs_time ();
   ren->set_origin (0, 0);
   ren->decode (def_w, def_h); def_h= -def_h;
@@ -284,7 +290,7 @@ x_window_rep::get_name () {
 void
 x_window_rep::set_visibility (bool flag) {
   if (flag) XMapRaised (dpy, win);
-  else XUnmapWindow (dpy, win);  
+  else XUnmapWindow (dpy, win);
 }
 
 void
diff --git a/src/src/System/Misc/sys_utils.cpp 
b/src/src/System/Misc/sys_utils.cpp
index 7dc9c09..7782aff 100644
--- a/src/src/System/Misc/sys_utils.cpp
+++ b/src/src/System/Misc/sys_utils.cpp
@@ -86,9 +86,12 @@ set_env (string var, string with) {
   char* _var = as_charp (var);
   char* _with= as_charp (with);
   setenv (_var, _with, 1);
+  tm_delete_array(_var);
+  tm_delete_array(_with);
 #else
   char* _varw= as_charp (var * "=" * with);
   (void) putenv (_varw);
+  // do not delete _varw !!!
+  // -> known memory leak, but solution more complex than it is worth
 #endif
-  // do not delete _var and _with !!!
 }
-- 
1.6.3.3

>From b22de9ca9044aaaff821ce726b43144272817629 Mon Sep 17 00:00:00 2001
From: Norbert Nemec <address@hidden>
Date: Wed, 7 Oct 2009 12:16:56 +0100
Subject: [PATCH 03/11] Fix some issues in the cork-to-latex converter. Also 
remove non-ascii characters from the sources.
 (These are nasty in some editors)

ToDo: output \usepackage[T1]{fontenc} only when really needed
---
 .../progs/convert/latex/latex-texmacs-drd.scm      |  228 ++++++++++++++------
 src/TeXmacs/progs/convert/latex/latex-tools.scm    |    5 +-
 src/TeXmacs/progs/convert/latex/tmtex.scm          |    3 -
 3 files changed, 164 insertions(+), 72 deletions(-)

diff --git a/src/TeXmacs/progs/convert/latex/latex-texmacs-drd.scm 
b/src/TeXmacs/progs/convert/latex/latex-texmacs-drd.scm
index 55473c4..587efe4 100644
--- a/src/TeXmacs/progs/convert/latex/latex-texmacs-drd.scm
+++ b/src/TeXmacs/progs/convert/latex/latex-texmacs-drd.scm
@@ -470,73 +470,167 @@
 ;; Catcode tables
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(drd-table iso-latin-catcodes%
-  ("à" "\\`a")
-  ("À" "\\`A")
-  ("á" "\\'a")
-  ("Á" "\\'A")
-  ("ä" "\\\"a")
-  ("Ä" "\\\"A")
-  ("â" "\\^a")
-  ("Â" "\\^A")
-  ("å" "{\\aa}")
-  ("Å" "{\\AA}")
-  ("Ã" "\\~A")
-  ("ã" "\\~a")
-  ("Æ" "{\\AE}")
-  ("æ" "{\\ae}")
-  ("ç" "\\c{c}")
-  ("Ç" "\\c{C}")
-  ("ð" "{\\dh}")
-  ("Ð" "{\\DH}")
-  ("è" "\\`e")
-  ("È" "\\`E")
-  ("é" "\\'e")
-  ("É" "\\'E")
-  ("ë" "\\\"e")
-  ("Ë" "\\\"E")
-  ("ê" "\\^e")
-  ("Ê" "\\^E")
-  ("ì" "\\`{\\i}")
-  ("Ì" "\\`I")
-  ("í" "\\'{\\i}")
-  ("Í" "\\'I")
-  ("ï" "\\\"{\\i}")
-  ("Ï" "\\\"I")
-  ("î" "\\^{\\i}")
-  ("Î" "\\^I")
-  ("Ñ" "\\~N")
-  ("ñ" "\\~n")
-  ("ò" "\\`o")
-  ("Ò" "\\`O")
-  ("ó" "\\'o")
-  ("Ó" "\\'O")
-  ("ö" "\\\"o")
-  ("Ö" "\\\"O")
-  ("ô" "\\^o")
-  ("Ô" "\\^O")
-  ("Õ" "\\~O")
-  ("õ" "\\~o")
-  ("Ø" "{\\O}")
-  ("ø" "{\\o}")
-  ("ß" "{\\ss}")
-  ("þ" "{\\th}")
-  ("Þ" "{\\TH}")
-  ("ù" "\\`u")
-  ("Ù" "\\`U")
-  ("ú" "\\'u")
-  ("Ú" "\\'U")
-  ("ü" "\\\"u")
-  ("Ü" "\\\"U")
-  ("û" "\\^u")
-  ("Û" "\\^U")
-  ("ý" "\\'y")
-  ("Ý" "\\'Y")
-  ("ÿ" "\\\"y")
-  ("¾" "\\\"Y")
-  ("¡" "!`")
-  ("" "?`")
-  ("¿" "?`"))
+(drd-table corkT1-to-latex-catcodes%
+  ("\x00" "\\`{ }")
+  ("\x01" "\\'{ }")
+  ("\x02" "\\^{ }")
+  ("\x03" "\\~{ }")
+  ("\x04" "\\\"{ }")
+  ("\x05" "\\H{ }")
+  ("\x06" "\\r{ }")
+  ("\x07" "\\v{ }")
+  ("\x08" "\\u{ }")
+  ("\x09" "\\b{ }")
+;  ("\x0A" "\\.{ }") ; newline may still be present in strings!!!
+  ("\x0B" "\\c{ }")
+  ("\x0C" "\\k{ }")
+  ("\x0D" ",")
+  ("\x0E" "{\\guilsinglleft}")
+  ("\x0F" "{\\guilsinglright}")
+  ("\x10" "``")
+  ("\x11" "''")
+  ("\x12" ",,")
+  ("\x13" "<<")
+  ("\x14" ">>")
+  ("\x15" "--")
+  ("\x16" "---")
+  ("\x17" "{}")
+  ("\x18" "{}")
+  ("\x19" "\\i")
+  ("\x1A" "\\j")
+  ("\x1B" "ff")
+  ("\x1C" "fi")
+  ("\x1D" "fl")
+  ("\x1E" "ffi")
+  ("\x1F" "ffl")
+  ("\x80" "\\u{A}")
+  ("\x81" "\\k{A}")
+  ("\x82" "\\'C")
+  ("\x83" "\\v{C}")
+  ("\x84" "\\v{D}")
+  ("\x85" "\\v{E}")
+  ("\x86" "\\k{E}")
+  ("\x87" "\\u{G}")
+  ("\x88" "\\'L")
+  ("\x89" "\\v{L}")
+  ("\x8A" "\\L")
+  ("\x8B" "\\'N")
+  ("\x8C" "\\v{N}")
+  ("\x8D" "{\\NG}")
+  ("\x8E" "\\H{O}")
+  ("\x8F" "\\'R")
+  ("\x90" "\\v{R}")
+  ("\x91" "\\'S")
+  ("\x92" "\\v{S}")
+  ("\x93" "\\c{S}")
+  ("\x94" "\\v{T}")
+  ("\x95" "\\c{T}")
+  ("\x96" "\\H{U}")
+  ("\x97" "\\r{U}")
+  ("\x98" "\\\"Y")
+  ("\x99" "\\'Z")
+  ("\x9A" "\\v{Z}")
+  ("\x9B" "\\.Z")
+  ("\x9C" "IJ")
+  ("\x9D" "\\.I")
+  ("\x9E" "{\\dj}")
+  ("\x9F" "{\\S}")
+  ("\xA0" "\\u{a}")
+  ("\xA1" "\\k{a}")
+  ("\xA2" "\\'c")
+  ("\xA3" "\\v{c}")
+  ("\xA4" "\\v{d}")
+  ("\xA5" "\\v{e}")
+  ("\xA6" "\\k{e}")
+  ("\xA7" "\\u{g}")
+  ("\xA8" "\\'l")
+  ("\xA9" "\\v{l}")
+  ("\xAA" "{\\l}")
+  ("\xAB" "\\'n")
+  ("\xAC" "\\v{n}")
+  ("\xAD" "{\\ng}")
+  ("\xAE" "\\H{o}")
+  ("\xAF" "\\'r")
+  ("\xB0" "\\v{r}")
+  ("\xB1" "\\'s")
+  ("\xB2" "\\v{s}")
+  ("\xB3" "\\c{s}")
+  ("\xB4" "\\v{t}")
+  ("\xB5" "\\c{t}")
+  ("\xB6" "\\H{u}")
+  ("\xB7" "\\r{u}")
+  ("\xB8" "\\\"y")
+  ("\xB9" "\\'z")
+  ("\xBA" "\\v{z}")
+  ("\xBB" "\\.z")
+  ("\xBC" "ij")
+  ("\xBD" "!`")
+  ("\xBE" "?`")
+  ("\xBF" "{\\pounds}")
+  ("\xC0" "\\`A")
+  ("\xC1" "\\'A")
+  ("\xC2" "\\^A")
+  ("\xC3" "\\~A")
+  ("\xC4" "\\\"A")
+  ("\xC5" "{\\AA}")
+  ("\xC6" "{\\AE}")
+  ("\xC7" "\\c{C}")
+  ("\xC8" "\\`E")
+  ("\xC9" "\\'E")
+  ("\xCA" "\\^E")
+  ("\xCB" "\\\"E")
+  ("\xCC" "\\`I")
+  ("\xCD" "\\'I")
+  ("\xCE" "\\^I")
+  ("\xCF" "\\\"I")
+  ("\xD0" "{\\DH}")
+  ("\xD1" "\\~N")
+  ("\xD2" "\\`O")
+  ("\xD3" "\\'O")
+  ("\xD4" "\\^O")
+  ("\xD5" "\\~O")
+  ("\xD6" "\\\"O")
+  ("\xD7" "{\\OE}")
+  ("\xD8" "{\\O}")
+  ("\xD9" "\\`U")
+  ("\xDA" "\\'U")
+  ("\xDB" "\\^U")
+  ("\xDC" "\\\"U")
+  ("\xDD" "\\'Y")
+  ("\xDE" "{\\TH}")
+  ("\xDF" "{\\SS}")
+  ("\xE0" "\\`a")
+  ("\xE1" "\\'a")
+  ("\xE2" "\\^a")
+  ("\xE3" "\\~a")
+  ("\xE4" "\\\"a")
+  ("\xE5" "{\\aa}")
+  ("\xE6" "{\\ae}")
+  ("\xE7" "\\c{c}")
+  ("\xE8" "\\`e")
+  ("\xE9" "\\'e")
+  ("\xEA" "\\^e")
+  ("\xEB" "\\\"e")
+  ("\xEC" "\\`{\\i}")
+  ("\xED" "\\'{\\i}")
+  ("\xEE" "\\^{\\i}")
+  ("\xEF" "\\\"{\\i}")
+  ("\xF0" "{\\dh}")
+  ("\xF1" "\\~n")
+  ("\xF2" "\\`o")
+  ("\xF3" "\\'o")
+  ("\xF4" "\\^o")
+  ("\xF5" "\\~o")
+  ("\xF6" "\\\"o")
+  ("\xF7" "{\\oe}")
+  ("\xF8" "{\\o}")
+  ("\xF9" "\\`u")
+  ("\xFA" "\\'u")
+  ("\xFB" "\\^u")
+  ("\xFC" "\\\"u")
+  ("\xFD" "\\'y")
+  ("\xFE" "{\\th}")
+  ("\xFF" "{\\ss}"))
 
 (drd-table cyrillic-catcodes%
   ("À" "\\CYRA")
diff --git a/src/TeXmacs/progs/convert/latex/latex-tools.scm 
b/src/TeXmacs/progs/convert/latex/latex-tools.scm
index 12f3bf8..7b4e610 100644
--- a/src/TeXmacs/progs/convert/latex/latex-tools.scm
+++ b/src/TeXmacs/progs/convert/latex/latex-tools.scm
@@ -54,7 +54,7 @@
 (define (latex-replace-catcode s)
   (or (if latex-cyrillic-catcode?
          (drd-ref cyrillic-catcodes% s)
-         (drd-ref iso-latin-catcodes% s))
+         (drd-ref corkT1-to-latex-catcodes% s))
       s))
 
 (tm-define (latex-expand-catcodes t)
@@ -285,8 +285,9 @@
         (pre-page     (latex-serialize-preamble Page))
         (pre-macro    (latex-serialize-preamble Macro))
         (pre-catcode  (latex-catcode-defs Text))
+        (pre-fontenc  "\\usepackage[T1]{fontenc}\n")
         (pre-uses     (latex-use-package-command Text)))
     (values
-      (string-append pre-uses)
+      (string-append pre-uses pre-fontenc)
       (string-append pre-page)
       (string-append pre-language pre-catcode pre-macro))))
diff --git a/src/TeXmacs/progs/convert/latex/tmtex.scm 
b/src/TeXmacs/progs/convert/latex/tmtex.scm
index 1cd8127..0e622ac 100644
--- a/src/TeXmacs/progs/convert/latex/tmtex.scm
+++ b/src/TeXmacs/progs/convert/latex/tmtex.scm
@@ -316,9 +316,6 @@
              ((== c #\22) (tmtex-text-sub ",," l))
              ((== c #\25) (tmtex-text-sub "--" l))
              ((== c #\26) (tmtex-text-sub "---" l))
-             ((== c #\237) (tmtex-text-sub "\\S" l))
-             ((== c #\337) (tmtex-text-sub "SS" l))
-             ((== c #\377) (tmtex-text-sub "ß" l))
              (else (cons c (tmtex-text-list (cdr l))))))))
 
 (define (tmtex-math-operator l)
-- 
1.6.3.3

>From 03bf57f87573c4d845946738023f0ba97f16def5 Mon Sep 17 00:00:00 2001
From: Norbert Nemec <address@hidden>
Date: Wed, 7 Oct 2009 12:16:56 +0100
Subject: [PATCH 04/11] Fix occasional crash when ci->nr is zero. (Probably 
should never happen, but Qt seems to handle counter incorrectly.)

---
 src/src/Graphics/Renderer/basic_renderer.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/src/Graphics/Renderer/basic_renderer.cpp 
b/src/src/Graphics/Renderer/basic_renderer.cpp
index de681bd..71ad4f2 100755
--- a/src/src/Graphics/Renderer/basic_renderer.cpp
+++ b/src/src/Graphics/Renderer/basic_renderer.cpp
@@ -379,7 +379,7 @@ void basic_renderer_rep::image_auto_gc () {
     fact= fact * fact * fact;
     if ((ci->w * ci->h) < 400) fact= fact * 5;
     if ((ci->w * ci->h)  < 6400) fact= fact * 5;
-    if (diff/fact > 60000) {
+    if (diff > 60000*fact) {
       cache_image->reset (lookup);
       ps_bbox->reset (lookup[0]);
     }
-- 
1.6.3.3


reply via email to

[Prev in Thread] Current Thread [Next in Thread]