~ubuntu-branches/ubuntu/quantal/muse/quantal

« back to all changes in this revision

Viewing changes to muse/xml.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Eric Hedekar, Eric Hedekar, Fabrice Coutadeur
  • Date: 2010-01-26 02:32:14 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100126023214-8ez2g5d26d9p584j
Tags: 1.0.1-0ubuntu1
[ Eric Hedekar ]
* New upstream version (LP: #479688)
* Removed patches that were fixed in upstream source
  -[10_64bit_memcorruption_fix]
  -[10_gcc43_build_fixes]
  -[10_lash_private_api_fix]
  -[10_log2f_aliasing_fix]
  -[10_vamgui_init_fix]
  -[20_fix_const]

[ Fabrice Coutadeur ]
* debian/watch: added watch file
* debian/muse.desktop: deleted deprecated Encoding key, Application category
  and icon extension. This fix several warning with lintian and
  desktop-file-validate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//=========================================================
2
2
//  MusE
3
3
//  Linux Music Editor
4
 
//  $Id: xml.cpp,v 1.17.2.1 2005/07/13 18:59:14 spamatica Exp $
 
4
//  $Id: xml.cpp,v 1.17.2.6 2009/12/07 20:48:45 spamatica Exp $
5
5
//
6
6
//  (C) Copyright 2000 Werner Schweer (ws@seh.de)
7
7
//=========================================================
137
137
                                    c = '"';
138
138
                              else if (strcmp(entity, "amp") == 0)
139
139
                                    c = '&';
 
140
                              else if (strcmp(entity, "lt") == 0)
 
141
                                    c = '<';
 
142
                              else if (strcmp(entity, "gt") == 0)
 
143
                                    c = '>';
 
144
                              else if (strcmp(entity, "apos") == 0)
 
145
                                    c = '\\';
140
146
                              else
141
147
                                    entity[k] = c;
142
148
                              break;
154
160
                  else
155
161
                        buffer[i++] = c;
156
162
                  }
 
163
            else if(c != EOF)
 
164
              buffer[i++] = c;
157
165
            if (c == EOF)
158
166
                  break;
159
 
            buffer[i++] = c;
160
167
            next();
161
168
            }
162
169
      buffer[i] = 0;
182
189
 
183
190
Xml::Token Xml::parse()
184
191
      {
185
 
      char buffer[1024*32];   // TODO handle overflow
 
192
      char buffer[1024*1024];   // increase buffer -rj
186
193
      char* p;
187
194
 
188
195
 again:
352
359
                        *dp = 0;
353
360
                        if (strcmp(name, "lt") == 0)
354
361
                              c = '<';
 
362
                        else if (strcmp(name, "gt") == 0)
 
363
                              c = '>';
 
364
                        else if (strcmp(name, "apos") == 0)
 
365
                              c = '\\';
 
366
                        else if (strcmp(name, "quot") == 0)
 
367
                              c = '"';
355
368
                        else if (strcmp(name, "amp") == 0)
356
369
                              c = '&';
357
370
                        else
428
441
      }
429
442
 
430
443
//---------------------------------------------------------
 
444
//   parseUInt
 
445
//---------------------------------------------------------
 
446
// Added by Tim. p3.3.8
 
447
 
 
448
unsigned int Xml::parseUInt()
 
449
      {
 
450
      QString s(parse1().simplifyWhiteSpace());
 
451
      bool ok;
 
452
      int base = 10;
 
453
      if (s.startsWith("0x") || s.startsWith("0X")) {
 
454
            base = 16;
 
455
            s = s.mid(2);
 
456
            }
 
457
      unsigned int n = s.toUInt(&ok, base);
 
458
      return n;
 
459
      }
 
460
 
 
461
//---------------------------------------------------------
431
462
//   parseFloat
432
463
//---------------------------------------------------------
433
464
 
557
588
      fprintf(f, "<%s>%d</%s>\n", name, val, name);
558
589
      }
559
590
 
 
591
void Xml::uintTag(int level, const char* name, unsigned int val)
 
592
      {
 
593
      putLevel(level);
 
594
      fprintf(f, "<%s>%u</%s>\n", name, val, name);
 
595
      }
 
596
 
560
597
void Xml::floatTag(int level, const char* name, float val)
561
598
      {
562
599
      putLevel(level);
580
617
                  switch(*val) {
581
618
                        case '&': fprintf(f, "&amp;"); break;
582
619
                        case '<': fprintf(f, "&lt;"); break;
 
620
                        case '>': fprintf(f, "&gt;"); break;
 
621
                        case '\\': fprintf(f, "&apos;"); break;
 
622
                        case '"': fprintf(f, "&quot;"); break;
583
623
                        default: fputc(*val, f); break;
584
624
                        }
585
625
                  ++val;
656
696
            }
657
697
      }
658
698
 
 
699
//---------------------------------------------------------
 
700
//   xmlString
 
701
//---------------------------------------------------------
 
702
 
 
703
QString Xml::xmlString(const QString& ss)
 
704
      {
 
705
      QString s(ss);
 
706
      s.replace('&', "&amp;");
 
707
      s.replace('<', "&lt;");
 
708
      s.replace('>', "&gt;");
 
709
      s.replace('\'', "&apos;");
 
710
      s.replace('"', "&quot;");
 
711
      return s;
 
712
      }
 
713
 
659
714
void Xml::dump(QString &dump)
660
715
      {
661
716
      if (f == 0)