summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate
authorerik <erik>2007-01-19 01:12:38 (UTC)
committer erik <erik>2007-01-19 01:12:38 (UTC)
commit1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7 (patch) (unidiff)
treeaf4a12bc46e25853386dc53868b869e1bf05d863 /noncore/apps/tinykate/libkate
parent2b45dc71e79a3eb7d4e8553273c9bc4f4282d50a (diff)
downloadopie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.zip
opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.tar.gz
opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.tar.bz2
Every single file in this commit had a memory leak where a resource is
allocated in the constructor but not de-allocated in the destructor. This commit fixes that.
Diffstat (limited to 'noncore/apps/tinykate/libkate') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.cpp7
-rw-r--r--noncore/apps/tinykate/libkate/document/katehighlight.h2
2 files changed, 7 insertions, 2 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
index 539d356..89024f7 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp
@@ -344,103 +344,108 @@ const QChar *HlCHex::checkHgl(const QChar *str, int len, bool) {
344#if 0 344#if 0
345 int i; 345 int i;
346 for (i=0;(*s)!='\0';s++,i++); 346 for (i=0;(*s)!='\0';s++,i++);
347 QString line(str,i); 347 QString line(str,i);
348 QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis 348 QRegExp3 rx("0[xX][a-fA-F\\d]+[UuLl]?"); // this matches but is also matching parenthesis
349 int pos=rx.search(line,0); 349 int pos=rx.search(line,0);
350 if(pos > -1) return str+rx.matchedLength(); 350 if(pos > -1) return str+rx.matchedLength();
351 else 351 else
352 return 0L; 352 return 0L;
353 353
354#else 354#else
355 if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) { 355 if (str[0] == '0' && ((str[1]&0xdf) == 'X' )) {
356 str += 2; 356 str += 2;
357 s = str; 357 s = str;
358 while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++; 358 while (s->isDigit() || ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') /*|| (*s >= 'a' && *s <= 'f')*/) s++;
359 if (s > str) { 359 if (s > str) {
360 if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++; 360 if ((*s&0xdf) == 'L' || (*s&0xdf) == 'U' ) s++;
361 return s; 361 return s;
362 } 362 }
363 } 363 }
364 return 0L; 364 return 0L;
365#endif 365#endif
366} 366}
367 367
368HlCFloat::HlCFloat(int attribute, int context) 368HlCFloat::HlCFloat(int attribute, int context)
369 : HlFloat(attribute,context) { 369 : HlFloat(attribute,context) {
370} 370}
371 371
372const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) { 372const QChar *HlCFloat::checkHgl(const QChar *s, int len, bool lineStart) {
373 373
374 s = HlFloat::checkHgl(s, len, lineStart); 374 s = HlFloat::checkHgl(s, len, lineStart);
375 if (s && ((*s&0xdf) == 'F' )) s++; 375 if (s && ((*s&0xdf) == 'F' )) s++;
376 return s; 376 return s;
377} 377}
378 378
379HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len) 379HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len)
380 : HlItem(attribute, context) { 380 : HlItem(attribute, context) {
381 _charList=charList; 381 _charList=charList;
382 _charListLen=len; 382 _charListLen=len;
383} 383}
384 384
385const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool) 385const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool)
386{ 386{
387 if (ustrchr(_charList, _charListLen, *s)) return s +1; 387 if (ustrchr(_charList, _charListLen, *s)) return s +1;
388 return 0L; 388 return 0L;
389} 389}
390 390
391HlRegExpr::HlRegExpr(int attribute, int context,QString regexp) 391HlRegExpr::HlRegExpr(int attribute, int context,QString regexp)
392 : HlItem(attribute, context) { 392 : HlItem(attribute, context), Expr(0) {
393 393
394 handlesLinestart=regexp.startsWith("^"); 394 handlesLinestart=regexp.startsWith("^");
395 if(!handlesLinestart) regexp.prepend("^"); 395 if(!handlesLinestart) regexp.prepend("^");
396 Expr=new QRegExp3(regexp); 396 Expr=new QRegExp3(regexp);
397} 397}
398 398
399HlRegExpr::~HlRegExpr()
400{
401 delete Expr;
402}
403
399const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart) 404const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart)
400{ 405{
401 if ((!lineStart) && handlesLinestart) return 0; 406 if ((!lineStart) && handlesLinestart) return 0;
402 407
403 QString line(s,len); 408 QString line(s,len);
404 int pos = Expr->search( line, 0 ); 409 int pos = Expr->search( line, 0 );
405 if (pos==-1) return 0L; 410 if (pos==-1) return 0L;
406 else 411 else
407 return (s+Expr->matchedLength()); 412 return (s+Expr->matchedLength());
408}; 413};
409 414
410 415
411HlLineContinue::HlLineContinue(int attribute, int context) 416HlLineContinue::HlLineContinue(int attribute, int context)
412 : HlItem(attribute,context) { 417 : HlItem(attribute,context) {
413} 418}
414 419
415const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) { 420const QChar *HlLineContinue::checkHgl(const QChar *s, int len, bool) {
416 421
417 if ((s[0].latin1() == '\\') && (len == 1)) 422 if ((s[0].latin1() == '\\') && (len == 1))
418 { 423 {
419 return s + 1; 424 return s + 1;
420 } 425 }
421 return 0L; 426 return 0L;
422} 427}
423 428
424 429
425HlCStringChar::HlCStringChar(int attribute, int context) 430HlCStringChar::HlCStringChar(int attribute, int context)
426 : HlItem(attribute,context) { 431 : HlItem(attribute,context) {
427} 432}
428 433
429//checks for hex and oct (for example \x1b or \033) 434//checks for hex and oct (for example \x1b or \033)
430const QChar *checkCharHexOct(const QChar *str) { 435const QChar *checkCharHexOct(const QChar *str) {
431 const QChar *s; 436 const QChar *s;
432 s=str; 437 s=str;
433 int n; 438 int n;
434 if (*s == 'x') { 439 if (*s == 'x') {
435 n = 0; 440 n = 0;
436 do { 441 do {
437 s++; 442 s++;
438 n *= 16; 443 n *= 16;
439 if (s->isDigit()) n += *s - '0'; 444 if (s->isDigit()) n += *s - '0';
440 else if ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') n += (*s&0xdf) - 'A' + 10; 445 else if ((*s&0xdf) >= 'A' && (*s&0xdf) <= 'F') n += (*s&0xdf) - 'A' + 10;
441// else if (*s >= 'a' && *s <= 'f') n += *s - 'a' + 10; 446// else if (*s >= 'a' && *s <= 'f') n += *s - 'a' + 10;
442 else break; 447 else break;
443 if (n >= 256) return 0L; 448 if (n >= 256) return 0L;
444 } while (true); 449 } while (true);
445 if (s - str == 1) return 0L; 450 if (s - str == 1) return 0L;
446 } else { 451 } else {
diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.h b/noncore/apps/tinykate/libkate/document/katehighlight.h
index fddf585..f0be27b 100644
--- a/noncore/apps/tinykate/libkate/document/katehighlight.h
+++ b/noncore/apps/tinykate/libkate/document/katehighlight.h
@@ -139,97 +139,97 @@ class HlCInt : public HlInt {
139class HlCOct : public HlItem { 139class HlCOct : public HlItem {
140 public: 140 public:
141 HlCOct(int attribute, int context); 141 HlCOct(int attribute, int context);
142 virtual const QChar *checkHgl(const QChar *, int len, bool); 142 virtual const QChar *checkHgl(const QChar *, int len, bool);
143}; 143};
144 144
145class HlCHex : public HlItem { 145class HlCHex : public HlItem {
146 public: 146 public:
147 HlCHex(int attribute, int context); 147 HlCHex(int attribute, int context);
148 virtual const QChar *checkHgl(const QChar *, int len, bool); 148 virtual const QChar *checkHgl(const QChar *, int len, bool);
149}; 149};
150 150
151class HlCFloat : public HlFloat { 151class HlCFloat : public HlFloat {
152 public: 152 public:
153 HlCFloat(int attribute, int context); 153 HlCFloat(int attribute, int context);
154 virtual const QChar *checkHgl(const QChar *, int len, bool); 154 virtual const QChar *checkHgl(const QChar *, int len, bool);
155}; 155};
156 156
157class HlLineContinue : public HlItem { 157class HlLineContinue : public HlItem {
158 public: 158 public:
159 HlLineContinue(int attribute, int context); 159 HlLineContinue(int attribute, int context);
160 virtual bool endEnable(QChar c) {return c == '\0';} 160 virtual bool endEnable(QChar c) {return c == '\0';}
161 virtual const QChar *checkHgl(const QChar *, int len, bool); 161 virtual const QChar *checkHgl(const QChar *, int len, bool);
162}; 162};
163 163
164class HlCStringChar : public HlItem { 164class HlCStringChar : public HlItem {
165 public: 165 public:
166 HlCStringChar(int attribute, int context); 166 HlCStringChar(int attribute, int context);
167 virtual const QChar *checkHgl(const QChar *, int len, bool); 167 virtual const QChar *checkHgl(const QChar *, int len, bool);
168}; 168};
169 169
170class HlCChar : public HlItem { 170class HlCChar : public HlItem {
171 public: 171 public:
172 HlCChar(int attribute, int context); 172 HlCChar(int attribute, int context);
173 virtual const QChar *checkHgl(const QChar *, int len, bool); 173 virtual const QChar *checkHgl(const QChar *, int len, bool);
174}; 174};
175 175
176class HlAnyChar : public HlItem { 176class HlAnyChar : public HlItem {
177 public: 177 public:
178 HlAnyChar(int attribute, int context, const QChar* charList, uint len); 178 HlAnyChar(int attribute, int context, const QChar* charList, uint len);
179 virtual const QChar *checkHgl(const QChar *, int len, bool); 179 virtual const QChar *checkHgl(const QChar *, int len, bool);
180 const QChar* _charList; 180 const QChar* _charList;
181 uint _charListLen; 181 uint _charListLen;
182}; 182};
183 183
184class HlRegExpr : public HlItem { 184class HlRegExpr : public HlItem {
185 public: 185 public:
186 HlRegExpr(int attribute, int context,QString expr); 186 HlRegExpr(int attribute, int context,QString expr);
187 ~HlRegExpr(){delete Expr;}; 187 ~HlRegExpr();
188 virtual const QChar *checkHgl(const QChar *, int len, bool); 188 virtual const QChar *checkHgl(const QChar *, int len, bool);
189 QRegExp3 *Expr; 189 QRegExp3 *Expr;
190 bool handlesLinestart; 190 bool handlesLinestart;
191}; 191};
192 192
193//-------- 193//--------
194 194
195 195
196//Item Style: color, selected color, bold, italic 196//Item Style: color, selected color, bold, italic
197class ItemStyle { 197class ItemStyle {
198 public: 198 public:
199 ItemStyle(); 199 ItemStyle();
200// ItemStyle(const ItemStyle &); 200// ItemStyle(const ItemStyle &);
201 ItemStyle(const QColor &, const QColor &, bool bold, bool italic); 201 ItemStyle(const QColor &, const QColor &, bool bold, bool italic);
202 ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;} 202 ItemStyle(ItemStyle *its){col=its->col;selCol=its->selCol; bold=its->bold; italic=its->italic;}
203// void setData(const ItemStyle &); 203// void setData(const ItemStyle &);
204 QColor col; 204 QColor col;
205 QColor selCol; 205 QColor selCol;
206 int bold; //boolean value 206 int bold; //boolean value
207 int italic; //boolean value 207 int italic; //boolean value
208}; 208};
209 209
210typedef QList<ItemStyle> ItemStyleList; 210typedef QList<ItemStyle> ItemStyleList;
211 211
212//Item Properties: name, Item Style, Item Font 212//Item Properties: name, Item Style, Item Font
213class ItemData : public ItemStyle { 213class ItemData : public ItemStyle {
214 public: 214 public:
215 ItemData(const QString name, int defStyleNum); 215 ItemData(const QString name, int defStyleNum);
216 ItemData(const QString name, int defStyleNum, 216 ItemData(const QString name, int defStyleNum,
217 const QColor&, const QColor&, bool bold, bool italic); 217 const QColor&, const QColor&, bool bold, bool italic);
218 ItemData(ItemData 218 ItemData(ItemData
219*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;} 219*itd):ItemStyle((ItemStyle*)itd),name(itd->name),defStyleNum(itd->defStyleNum),defStyle(itd->defStyle){;}
220 const QString name; 220 const QString name;
221 int defStyleNum; 221 int defStyleNum;
222 int defStyle; //boolean value 222 int defStyle; //boolean value
223}; 223};
224 224
225typedef QList<ItemData> ItemDataList; 225typedef QList<ItemData> ItemDataList;
226 226
227class HlData { 227class HlData {
228 public: 228 public:
229 HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier); 229 HlData(const QString &wildcards, const QString &mimetypes,const QString &identifier);
230 ItemDataList itemDataList; 230 ItemDataList itemDataList;
231 QString wildcards; 231 QString wildcards;
232 QString mimetypes; 232 QString mimetypes;
233 QString identifier; 233 QString identifier;
234}; 234};
235 235