]> git.lyx.org Git - features.git/commitdiff
remove out-commented code
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 5 Dec 2001 08:50:13 +0000 (08:50 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 5 Dec 2001 08:50:13 +0000 (08:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3150 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxgluelength.C
src/lyxlength.C
src/trans.C
src/trans.h
src/trans_decl.h
src/trans_mgr.C
src/trans_mgr.h

index 0d957c21868fd0d3bffc35e88fa4a4e88da7fec2..b0aa51df7b34bc455a2903f7cae9cee8c2fb5f30 100644 (file)
@@ -1,5 +1,11 @@
 2001-12-05  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
+       * trans_decl.h:
+       * trans_mgr.[Ch]:
+       * trans.[Ch]:
+       * lyxgluelength.C:
+       * lyxlength.C: remove out-commented code.
+
        * BufferView_pimpl:
        * CutAndPaste.C: 
        * DepTable.C:
index 1342bbf7dbf8acbaae124b3505c3de8e3805f3e3..d5add58afc938c1ad35dc83346292689be38aee2 100644 (file)
 
 #include "Lsstream.h"
 
-#if 0
-namespace {
-// this is now here and in lyxlenght.h
-
-int const num_units = LyXLength::UNIT_NONE;
-
-// I am not sure if "mu" should be possible to select (Lgb)
-char const * unit_name[num_units] = { "sp", "pt", "bp", "dd",
-                                     "mm", "pc", "cc", "cm",
-                                     "in", "ex", "em", "mu",
-                                     "%",  "c%", "p%", "l%" };
-
-}
-#endif
 
 LyXGlueLength::LyXGlueLength(LyXLength const & len)
        : len_(len)
index de47765b932238ab903ad595036697c58ba19eac..477f8a1050de08d042a9a3e64fbc71060f584690 100644 (file)
 
 #include <cstdlib>
 
-#if 0
-namespace {
-// this is now here and in lyxgluelength.C
-
-int const num_units = LyXLength::UNIT_NONE;
-
-// I am not sure if "mu" should be possible to select (Lgb)
-char const * unit_name[num_units] = { "sp", "pt", "bp", "dd",
-                                     "mm", "pc", "cc", "cm",
-                                     "in", "ex", "em", "mu",
-                                     "%",  "c%", "p%", "l%" };
-
-
-LyXLength::UNIT unitFromString(string const & data)
-{
-       int i = 0;
-       while (i < num_units && data != unit_name[i])
-               ++i;
-       return static_cast<LyXLength::UNIT>(i);
-}
-
-}
-#endif
-
 
 LyXLength::LyXLength()
        : val_(0), unit_(LyXLength::PT)
index 6f1e3809f7461ba87cb56d4360c1eef60c64f004..d9a9529279460b785e5715e305a47a976d2c98d2 100644 (file)
@@ -19,50 +19,13 @@ using std::endl;
 // KmodInfo
 KmodInfo::KmodInfo()
 {
-#if 0
-       exception_list = 0;
-#endif
-}
-
-
-#if 0
-// Default Trans
-bool DefaultTrans::init_ = false;
-
-
-DefaultTrans::DefaultTrans()
-{
-       if (init_ == false) {
-               // Do initialization
-               init_ = true;
-       }
 }
 
 
-#if 0
-string const DefaultTrans::process(char c, TransManager & k)
-{
-       char dummy[2] = "?";
-       dummy[0] = c;
-    
-       return k.normalkey(c, dummy);
-}
-#else
-string const DefaultTrans::process(char c, TransManager & k)
-{
-       return k.normalkey(c);
-}
-#endif
-#endif
-
 // Trans class
 
 Trans::Trans()
 {
-#if 0
-       for (int i = 0; i < TEX_MAX_ACCENT + 1; ++i)
-               kmod_list_[i] = 0;
-#endif
 }
 
 
@@ -75,17 +38,6 @@ Trans::~Trans()
 void Trans::InsertException(KmodException & exclist, char c,
                            string const & data, bool flag, tex_accent accent)
 {
-#if 0
-       keyexc p = new Keyexc; 
-       p->next = exclist;
-       p->c = c;
-
-       p->data = data;
-       p->combined = flag;
-       p->accent = accent;
-
-       exclist = p;
-#else
        Keyexc p;
        p.c = c;
        p.data = data;
@@ -94,42 +46,19 @@ void Trans::InsertException(KmodException & exclist, char c,
        exclist.insert(exclist.begin(), p);
        // or just
        // exclist.push_back(p);
-#endif
 }
 
 
 void Trans::FreeException(KmodException & exclist)
 {
-#if 0
-       Trans::keyexc p = exclist;
-       while (p) {
-               p = exclist->next;
-               delete exclist;
-               exclist = p;
-       }
-#else
        exclist.clear();
-#endif
 }
 
 
 void Trans::FreeKeymap()
 {
-#if 0
-       for (int i = 0; i < 256; ++i)
-               if (!keymap_[i].empty()) {
-                       keymap_[i].erase();
-               }
-       for (int i = 0; i < TEX_MAX_ACCENT + 1; ++i)
-               if (kmod_list_[i]) {
-                       FreeException(kmod_list_[i]->exception_list);
-                       delete kmod_list_[i];
-                       kmod_list_[i] = 0;
-               }
-#else
        kmod_list_.clear();
        keymap_.clear();
-#endif
 }
 
 
@@ -165,59 +94,19 @@ struct keyword_item kmapTags[K_LAST - 1] = {
 tex_accent getkeymod(string const &);
 
 
-#if 0
-void Trans::AddDeadkey(tex_accent accent, string const & keys,
-                      string const & allowed)
-#else
 void Trans::AddDeadkey(tex_accent accent, string const & keys)
-#endif
 {
-#if 0
-       if (kmod_list_[accent]) {
-               FreeException(kmod_list_[accent]->exception_list);
-               
-               delete kmod_list_[accent];
-       }
-       
-       kmod_list_[accent] = new KmodInfo;
-       kmod_list_[accent]->data = keys;
-       kmod_list_[accent]->accent = accent;
-#else
        KmodInfo tmp;
        tmp.data = keys;
        tmp.accent = accent;
        kmod_list_[accent] = tmp;
-#endif
-#if 0
-       if (allowed == "native") { 
-               kmod_list_[accent]->allowed= lyx_accent_table[accent].native;
-       } else {
-               kmod_list_[accent]->allowed = allowed;
-       }
 
-       for (string::size_type i = 0; i < keys.length(); ++i) {
-               string & temp =
-                       keymap_[static_cast<unsigned char>(keys[i])];
-               if (!temp.empty())
-                       temp.erase();
-
-               // But the question remains: "Should we be allowed
-               // to change bindings, without unbinding first?"
-               // Lgb
-               temp += char(0);
-               temp += char(accent);
-       }
-#else
        for (string::size_type i = 0; i < keys.length(); ++i) {
                string tmp;
                tmp += char(0);
                tmp += char(accent);
                keymap_[keys[i]] = tmp;
        }
-#endif
-#if 0
-       kmod_list_[accent]->exception_list = 0;
-#endif
 }
 
 
@@ -292,11 +181,6 @@ int Trans::Load(LyXLex & lex)
                        tex_accent accent_2= getkeymod(str);
                        if (accent_2 == TEX_NOACCENT) return -1;
 
-#if 0
-                       if (kmod_list_[accent_1] == 0
-                           || kmod_list_[accent_2] == 0)
-                               return -1;
-#else
                        std::map<int, KmodInfo>::iterator it1 =
                                kmod_list_.find(accent_1);
                        std::map<int, KmodInfo>::iterator it2 =
@@ -305,31 +189,9 @@ int Trans::Load(LyXLex & lex)
                            || it2 == kmod_list_.end()) {
                                return -1;
                        }
-#endif
 
                        // Find what key accent_2 is on - should
                        // check about accent_1 also
-#if 0
-                       int key = 0;
-                       for (; key < 256; ++key) {
-                               if (!keymap_[key].empty()
-                                   && keymap_[key][0] == 0
-                                   && keymap_[key][1] == accent_2)
-                                       break;
-                       }
-                       string allowed;
-
-                       if (lex.next()) {
-                               allowed = lex.GetString();
-                               lyxerr[Debug::KBMAP] << "allowed: "
-                                                    << allowed << endl;
-                       } else
-                               return -1;
-
-                       InsertException(kmod_list_[accent_1].exception_list,
-                                       static_cast<char>(key), allowed,
-                                       true, accent_2);
-#else
                        std::map<int, string>::iterator it = keymap_.begin();
                        std::map<int, string>::iterator end = keymap_.end();
                        for (; it != end; ++it) {
@@ -350,7 +212,6 @@ int Trans::Load(LyXLex & lex)
                        InsertException(kmod_list_[accent_1].exception_list,
                                        static_cast<char>(it->first), allowed,
                                        true, accent_2);
-#endif
                }
                break;
                case KMAP: {
@@ -427,41 +288,15 @@ int Trans::Load(LyXLex & lex)
 
 bool Trans::isAccentDefined(tex_accent accent, KmodInfo & i) const
 {
-#if 0
-       if (kmod_list_[accent] != 0) {
-               i = *kmod_list_[accent];
-               return true;
-       }
-       return false;
-#else
        std::map<int, KmodInfo>::const_iterator cit = kmod_list_.find(accent);
        if (cit != kmod_list_.end()) {
                i = cit->second;
                return true;
        }
        return false;
-#endif
 }
 
 
-#if 0
-string const Trans::process(char c, TransManager & k)
-{
-       string dt("?");
-       string const t = Match(static_cast<unsigned char>(c));
-
-       if (t.empty() && c != 0) {
-               dt[0] = c;
-               return k.normalkey(c, dt);
-       } else if (!t.empty() && t[0] != char(0)) {
-               dt = t;
-               return k.normalkey(c, dt);
-       } else {
-               return k.deadkey(c,
-                                *kmod_list_[static_cast<tex_accent>(t[1])]);
-       }
-}
-#else
 string const Trans::process(char c, TransManager & k)
 {
        string const t = Match(static_cast<unsigned char>(c));
@@ -472,16 +307,10 @@ string const Trans::process(char c, TransManager & k)
                //return k.normalkey(c);
                return t;
        } else {
-#if 0
-               return k.deadkey(c,
-                                *kmod_list_[static_cast<tex_accent>(t[1])]);
-#else
                return k.deadkey(c,
                                 kmod_list_[static_cast<tex_accent>(t[1])]);
-#endif
        }
 }
-#endif
 
 
 int Trans::Load(string const & language)
index 4b923e87e6e35289f9b986e4bef1dddb34955ef2..8cb068d90f575367d5bdf5f3592f00631df303fc 100644 (file)
@@ -16,36 +16,6 @@ class LyXLex;
 
 class TransManager;
 
-#if 0
-/**
-  TransInterface: the interface that every translation class
-  should obey too.
-  Visitor pattern applied here
-  */
-class TransInterface {
-public:
-       ///
-       virtual string const process(char, TransManager &) = 0;
-       ///
-       virtual bool isAccentDefined(tex_accent, KmodInfo &) const = 0;
-};
-
-/**
-  DefaultTrans: the default translation class. Holds info
-  on tex-accents. Monostate
-  */
-class DefaultTrans : public TransInterface {
-public:
-       ///
-       DefaultTrans();
-       ///
-       virtual string const process(char, TransManager &);
-private:
-       ///
-       static bool init_;
-};
-#endif
-
 /**
   Trans: holds a .kmap file 
   */
@@ -69,25 +39,14 @@ public:
        bool isAccentDefined(tex_accent, KmodInfo &) const;
     
 private:
-#if 0
-       ///
-       typedef KmodInfo kmod_list_decl;
-       ///
-       typedef KmodException keyexc;
-#endif
-#if 0
-       ///
-       void AddDeadkey(tex_accent, string const &, string const &);
-#else
        ///
        void AddDeadkey(tex_accent, string const &);
-#endif
        ///
        void FreeKeymap();
        ///
        int Load(LyXLex &);
        ///
-       inline string const & Match(unsigned char c);
+       string const & Match(unsigned char c);
        ///
        void InsertException(KmodException & exclist, char c,
                             string const & data, bool = false,
@@ -97,36 +56,23 @@ private:
 
        ///
        string name_;
-#if 0
        ///
-       string keymap_[256];
-#else
        std::map<int, string> keymap_;
-#endif
-#if 0
        ///
-       kmod_list_decl * kmod_list_[TEX_MAX_ACCENT+1];
-#else
-       ///
-       //KmodInfo * kmod_list_[TEX_MAX_ACCENT+1];
        std::map<int, KmodInfo> kmod_list_;
-#endif
 };
 
 
 ///
+inline
 string const & Trans::Match(unsigned char c)
 {
-#if 0
-       return keymap_[c];
-#else
        std::map<int, string>::iterator it = keymap_.find(c);
        if (it != keymap_.end()) {
                return it->second;
        }
        static string dummy;
        return dummy;
-#endif
 }
 
 #endif 
index 71ab9d5d59689ed013ac5a812b1a630484367665..a9b6de44e55f1faaf3bd33771120a426abd3b237 100644 (file)
@@ -2,34 +2,26 @@
 #ifndef Trans_Decl_h
 #define Trans_Decl_h
 
-#include <list>
-
 #include "LString.h"
 #include "tex-accent.h"
 
+#include <list>
+
+
 ///
 struct Keyexc {
        /// character to make exception
        char c;
        /// exception data
        string data;
-#if 0
-       ///
-       Keyexc * next;
-#endif
        /// Combination with another deadkey
        bool combined;
        /// The accent comined with
        tex_accent accent;
 };
 
-#if 0
-///
-typedef Keyexc * KmodException;
-#else
 ///
 typedef std::list<Keyexc> KmodException;
-#endif
 
 ///
 struct KmodInfo {
@@ -37,10 +29,6 @@ struct KmodInfo {
        string data;
        ///
        tex_accent accent;
-#if 0
-       ///
-       string allowed;
-#endif
        ///
        KmodException exception_list;
        ///
index c6f5bd7ab6158f531710ab96d043d447f50736a4..fa077ce907cd9284c88f69a83542b812ea8f0fec 100644 (file)
@@ -29,9 +29,6 @@ TransFSMData::TransFSMData()
 {
        deadkey_ = deadkey2_ = 0;
        deadkey_info_.accent = deadkey2_info_.accent = TEX_NOACCENT;
-#if 0
-       comb_info_ = 0;
-#endif
 }
 
 
@@ -46,23 +43,12 @@ TransInitState::TransInitState()
 }
 
 
-#if 0
-string const TransInitState::normalkey(char c, string const & t)
-{
-       string res;
-       if (!t.empty()) res = t;
-       else res = c;
-       
-       return res;
-}
-#else
 string const TransInitState::normalkey(char c)
 {
        string res;
        res = c;
        return res;
 }
-#endif
 
 
 string const TransInitState::deadkey(char c, KmodInfo d)
@@ -81,56 +67,8 @@ TransDeadkeyState::TransDeadkeyState()
 }
 
 
-#if 0
-string const TransDeadkeyState::normalkey(char c, string const & trans)
-{
-       string res;
-       
-       // Check if it is an exception
-       KmodException l = deadkey_info_.exception_list;
-       while (l != 0) {
-               if (l->c == c) {
-                       res = l->data;
-                       break;
-               }
-               l = l->next;
-       }
-       if (l == 0) {
-               // Not an exception. Check if it allowed
-               if (countChar(deadkey_info_.allowed, c) > 0) {
-                       res = DoAccent(c, deadkey_info_.accent);
-               } else {
-                       // Not allowed
-                       if (deadkey_!= 0)
-                               res = deadkey_;
-                       res+= TOKEN_SEP;
-                       res+= trans;
-               }
-       }
-       currentState = init_state_;
-       return res;
-}
-#else
 string const TransDeadkeyState::normalkey(char c)
 {
-#if 0
-       string res;
-       
-       // Check if it is an exception
-       KmodException l = deadkey_info_.exception_list;
-       while (l != 0) {
-               if (l->c == c) {
-                       res = l->data;
-                       break;
-               }
-               l = l->next;
-       }
-       if (l == 0) {
-                       res = DoAccent(c, deadkey_info_.accent);
-       }
-       currentState = init_state_;
-       return res;
-#else
        string res;
        
        KmodException::iterator it = deadkey_info_.exception_list.begin();
@@ -147,9 +85,7 @@ string const TransDeadkeyState::normalkey(char c)
        }
        currentState = init_state_;
        return res;
-#endif
 }
-#endif
 
 
 string const TransDeadkeyState::deadkey(char c, KmodInfo d)
@@ -166,28 +102,6 @@ string const TransDeadkeyState::deadkey(char c, KmodInfo d)
        }
        
        // Check if it is a combination or an exception
-#if 0
-       KmodException l;
-       l = deadkey_info_.exception_list;
-       
-       while (l) {
-               if (l->combined == true && l->accent == d.accent) {
-                       deadkey2_ = c;
-                       deadkey2_info_ = d;
-                       comb_info_ = l;
-                       currentState = combined_state_;
-                       return string();
-               }
-               if (l->c == c) {
-                       res = l->data;
-                       deadkey_ = 0;
-                       deadkey_info_.accent = TEX_NOACCENT;
-                       currentState = init_state_;
-                       return res;
-               }
-               l = l->next;
-       }
-#else
        KmodException::const_iterator cit = deadkey_info_.exception_list.begin();
        KmodException::const_iterator end = deadkey_info_.exception_list.end();
        for (; cit != end; ++cit) {
@@ -206,7 +120,7 @@ string const TransDeadkeyState::deadkey(char c, KmodInfo d)
                        return res;
                }
        }
-#endif
+
        // Not a combination or an exception. 
        // Output deadkey1 and keep deadkey2
        
@@ -225,39 +139,13 @@ TransCombinedState::TransCombinedState()
 }
 
 
-#if 0
-string const TransCombinedState::normalkey(char c, string const & trans)
-{
-       string res;
-
-       // Check if the key is allowed on the combination
-       if (countChar(comb_info_->data, c) > 0) {
-               string const temp = DoAccent(c, deadkey2_info_.accent);
-               res = DoAccent(temp, deadkey_info_.accent);
-               currentState = init_state_;
-       } else {
-               // Not allowed. Output deadkey1 and check deadkey2 + c
-               if (deadkey_ != 0)
-                       res += deadkey_;
-               res += TOKEN_SEP;
-               deadkey_ = deadkey2_;
-               deadkey_info_ = deadkey2_info_;
-               // Call deadkey state and leave it to setup the FSM
-               res += deadkey_state_->normalkey(c, trans);
-       }
-       return res;
-}
-#else
 string const TransCombinedState::normalkey(char c)
 {
-       string res;
-
        string const temp = DoAccent(c, deadkey2_info_.accent);
-       res = DoAccent(temp, deadkey_info_.accent);
+       string const res = DoAccent(temp, deadkey_info_.accent);
        currentState = init_state_;
        return res;
 }
-#endif
 
 
 string const TransCombinedState::deadkey(char c, KmodInfo d)
@@ -420,13 +308,7 @@ void TransManager::deadkey(char c, tex_accent accent, LyXText * t)
        if (active_ == &default_ || c == 0) {
                KmodInfo i;
                i.accent = accent;
-#if 0
-               i.allowed = lyx_accent_table[accent].native;
-#endif
                i.data.erase();
-#if 0
-               i.exception_list = 0;
-#endif 
                string res = trans_fsm_.currentState->deadkey(c, i);
                insert(res, t);
        } else {
index 7b7e812c328baf60eabdbacafacd89ed0fcd40fb..1864bc80e3b0703668c4bf50bcb610d6141d718c 100644 (file)
@@ -19,13 +19,8 @@ class TransState {
 public:
        ///
        virtual ~TransState() {}
-#if 0
-       ///
-       virtual string const normalkey(char, string const &) = 0;
-#else
        ///
        virtual string const normalkey(char) = 0;
-#endif
        ///
        virtual bool backspace() = 0;
        ///
@@ -48,13 +43,8 @@ protected:
        char deadkey2_;
        ///
        KmodInfo deadkey2_info_;
-#if 0
-       ///
-       KmodException comb_info_;
-#else
        ///
        Keyexc comb_info_;
-#endif
        ///
        TransState * init_state_;
        ///
@@ -75,13 +65,8 @@ class TransInitState :       virtual public TransFSMData, public TransState {
 public:
        ///
        TransInitState();
-#if 0
-       ///
-       virtual string const normalkey(char, string const &);
-#else
        ///
        virtual string const normalkey(char);
-#endif
        ///
        virtual bool backspace() { return true; }
        ///
@@ -94,13 +79,8 @@ class TransDeadkeyState : virtual public TransFSMData, public TransState {
 public:
        ///
        TransDeadkeyState();
-#if 0
-       ///
-       virtual string const normalkey(char, string const &);
-#else
        ///
        virtual string const normalkey(char);
-#endif
        ///
        virtual bool backspace() {
                currentState = init_state_;
@@ -116,13 +96,8 @@ class TransCombinedState : virtual public TransFSMData, public TransState {
 public:
        ///
        TransCombinedState();
-#if 0
-       ///
-       virtual string const normalkey(char, string const &);
-#else
        ///
        virtual string const normalkey(char);
-#endif
        ///
        virtual bool backspace() {
                // cancel the second deadkey
@@ -192,31 +167,18 @@ public:
        void TranslateAndInsert(char, LyXText *);
        ///
        string const deadkey(char, KmodInfo);
-#if 0
-       ///
-       string const normalkey(char, string const &);
-#else
        ///
        string const normalkey(char);
-#endif
        ///
        void deadkey(char, tex_accent, LyXText *);
 };
 
 
-#if 0
-inline
-string const TransManager::normalkey(char c, string const & t)
-{
-       return trans_fsm_.currentState->normalkey(c, t);
-}
-#else
 inline
 string const TransManager::normalkey(char c)
 {
        return trans_fsm_.currentState->normalkey(c);
 }
-#endif
 
 
 inline