dasher r3645 - in trunk: . Src/DasherCore Src/DasherCore/Alphabet



Author: pwelche
Date: Tue Mar  3 17:20:33 2009
New Revision: 3645
URL: http://svn.gnome.org/viewvc/dasher?rev=3645&view=rev

Log:
The code in LoadPlain used to check for char*filename="", so
this is the equivalent. I'm not sure it is necessary at all
though.


Modified:
   trunk/ChangeLog
   trunk/Src/DasherCore/Alphabet/Alphabet.cpp
   trunk/Src/DasherCore/TrainingHelper.cpp

Modified: trunk/Src/DasherCore/Alphabet/Alphabet.cpp
==============================================================================
--- trunk/Src/DasherCore/Alphabet/Alphabet.cpp	(original)
+++ trunk/Src/DasherCore/Alphabet/Alphabet.cpp	Tue Mar  3 17:20:33 2009
@@ -377,17 +377,27 @@
 
   std::string strTrainingFile = GetTrainingFile();
 
-  std::string strUserPathFull = strUserLoc + strTrainingFile;
-
-  m_pTrainingHelper->LoadFile(strUserPathFull, pTrainer, this);
-  m_pTrainingHelper->LoadFile(strSystemLoc + strTrainingFile, pTrainer, this);
+  if (strTrainingFile.empty()) {
+#ifdef DEBUG
+    std::cerr << "Trying to load empty training file (location)" << std::endl;
+#endif
+  } else {
+    m_pTrainingHelper->LoadFile(strUserLoc   + strTrainingFile, pTrainer, this);
+    m_pTrainingHelper->LoadFile(strSystemLoc + strTrainingFile, pTrainer, this);
+  }
 }
 
 void 
 CAlphabet::Train(const std::string &strPath, 
       CTrainer *pTrainer) {
   
-  m_pTrainingHelper->LoadFile(strPath, pTrainer, this);
+  if (strPath.empty()) {
+#ifdef DEBUG
+    std::cerr << "Trying to load empty training file (path)" << std::endl;
+#endif
+  } else {
+    m_pTrainingHelper->LoadFile(strPath, pTrainer, this);
+  }
 }
 
 int 

Modified: trunk/Src/DasherCore/TrainingHelper.cpp
==============================================================================
--- trunk/Src/DasherCore/TrainingHelper.cpp	(original)
+++ trunk/Src/DasherCore/TrainingHelper.cpp	Tue Mar  3 17:20:33 2009
@@ -66,14 +66,8 @@
 			   Dasher::CTrainer *pTrainer, 
 			   const Dasher::CAlphabet *pAlphabet) {
   
-  if (strFileName.empty())
-    {
-      std::cerr << "LoadPlain called with empty filename" << std::endl;
-      return;
-    }
-
   std::ifstream in(strFileName.c_str(), std::ios::binary);
-  if (in.bad())
+  if (in.fail())
     {
       std::cerr << "Unable to open file \"" << strFileName << "\" for reading"
                 << std::endl;



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