summaryrefslogtreecommitdiffstats
path: root/ue2/imgsynth2/cpixmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ue2/imgsynth2/cpixmap.cpp')
-rw-r--r--ue2/imgsynth2/cpixmap.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/ue2/imgsynth2/cpixmap.cpp b/ue2/imgsynth2/cpixmap.cpp
index 94f0310..52f9825 100644
--- a/ue2/imgsynth2/cpixmap.cpp
+++ b/ue2/imgsynth2/cpixmap.cpp
@@ -11,6 +11,7 @@
11#include <boost/algorithm/string/split.hpp> 11#include <boost/algorithm/string/split.hpp>
12#include <boost/algorithm/string.hpp> 12#include <boost/algorithm/string.hpp>
13#include <boost/lexical_cast.hpp> 13#include <boost/lexical_cast.hpp>
14#include <assert.h>
14#ifdef DEBUG 15#ifdef DEBUG
15# include <iostream> 16# include <iostream>
16#endif 17#endif
@@ -123,6 +124,7 @@ void CPixmap::read(std::ifstream& in)
123 throw FileError("Pixmap has no imagename."); 124 throw FileError("Pixmap has no imagename.");
124 125
125 /* additional: check "{" exists */ 126 /* additional: check "{" exists */
127 assert(!line.empty());
126 if (line[line.length() - 1] != '{') 128 if (line[line.length() - 1] != '{')
127 throw FileError("Pixmap array has no opening bracket."); 129 throw FileError("Pixmap array has no opening bracket.");
128 130
@@ -236,6 +238,7 @@ void CPixmap::read(std::ifstream& in)
236 for(uint32_t x = 0; x < getWidth(); x++) 238 for(uint32_t x = 0; x < getWidth(); x++)
237 { 239 {
238 character = line.substr(x * m_fileheader.nChar, m_fileheader.nChar); 240 character = line.substr(x * m_fileheader.nChar, m_fileheader.nChar);
241 assert(!character.empty());
239 if (colornr.find(character) == colornr.end()) 242 if (colornr.find(character) == colornr.end())
240 throw FileError("Pixel has no reference in colortable."); 243 throw FileError("Pixel has no reference in colortable.");
241 244
@@ -265,6 +268,7 @@ void CPixmap::read(std::ifstream& in)
265const std::string CPixmap::getXPMColorID(unsigned int index, unsigned int length) 268const std::string CPixmap::getXPMColorID(unsigned int index, unsigned int length)
266{ 269{
267 static const char code[] = PIXMAP_COLORCHARS; 270 static const char code[] = PIXMAP_COLORCHARS;
271 assert(strlen(code) > 0);
268 string str(""); 272 string str("");
269 for(unsigned int i = length - 1; i > 0; i--) 273 for(unsigned int i = length - 1; i > 0; i--)
270 { 274 {
@@ -272,6 +276,7 @@ const std::string CPixmap::getXPMColorID(unsigned int index, unsigned int length
272 index /= strlen(code); 276 index /= strlen(code);
273 } 277 }
274 str += code[index]; 278 str += code[index];
279 assert(!str.empty());
275 return str; 280 return str;
276} 281}
277 282
@@ -286,6 +291,7 @@ void CPixmap::write(std::ofstream& out)
286 out << PIXMAP_IDENTIFIER << endl; 291 out << PIXMAP_IDENTIFIER << endl;
287 292
288 /* variables*/ 293 /* variables*/
294 assert(!m_imagename.empty());
289 out << "static char * " << m_imagename << "[] = {" << endl; 295 out << "static char * " << m_imagename << "[] = {" << endl;
290 out << "\"" << m_fileheader.width << " " << m_fileheader.height 296 out << "\"" << m_fileheader.width << " " << m_fileheader.height
291 << " " << m_fileheader.nColor << " " << m_fileheader.nChar; 297 << " " << m_fileheader.nColor << " " << m_fileheader.nChar;