~ubuntu-branches/ubuntu/trusty/aria2/trusty

« back to all changes in this revision

Viewing changes to src/ExpatXmlParser.cc

  • Committer: Package Import Robot
  • Author(s): Kartik Mistry
  • Date: 2013-12-16 18:41:03 UTC
  • mfrom: (2.5.21 sid)
  • Revision ID: package-import@ubuntu.com-20131216184103-xzah3019zwut429g
Tags: 1.18.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
  if(sep) {
55
55
    *localname = sep+1;
56
56
    size_t nsUriLen = sep-src;
57
 
    char* temp = new char[nsUriLen+1];
 
57
    auto temp = new char[nsUriLen + 1];
58
58
    memcpy(temp, src, nsUriLen);
59
59
    temp[nsUriLen] = '\0';
60
60
    *nsUri = temp;
71
71
  std::vector<XmlAttr> xmlAttrs;
72
72
  if(attrs) {
73
73
    const char** p = attrs;
74
 
    while(*p != 0) {
 
74
    while(*p) {
75
75
      XmlAttr xa;
76
76
      const char* attrNsName = *p++;
77
 
      if(*p == 0) {
 
77
      if(!*p) {
78
78
        break;
79
79
      }
80
80
      splitNsName(&xa.localname, &xa.nsUri, attrNsName);
84
84
      xmlAttrs.push_back(xa);
85
85
    }
86
86
  }
87
 
  const char* localname = 0;
88
 
  const char* prefix = 0;
89
 
  const char* nsUri = 0;
 
87
  const char* localname = nullptr;
 
88
  const char* prefix = nullptr;
 
89
  const char* nsUri = nullptr;
90
90
  splitNsName(&localname, &nsUri, nsName);
91
91
  sd->psm->beginElement(localname, prefix, nsUri, xmlAttrs);
92
92
  delete [] nsUri;
93
 
  for(std::vector<XmlAttr>::iterator i = xmlAttrs.begin(),
94
 
        eoi = xmlAttrs.end(); i != eoi; ++i) {
95
 
    delete [] (*i).nsUri;
 
93
  for(auto& a: xmlAttrs) {
 
94
    delete [] a.nsUri;
96
95
  }
97
96
  if(sd->psm->needsCharactersBuffering()) {
98
97
    sd->charactersStack.push_front(A2STR::NIL);
103
102
namespace {
104
103
void mlEndElement(void* userData, const char* nsName)
105
104
{
106
 
  const char* localname = 0;
107
 
  const char* prefix = 0;
108
 
  const char* nsUri = 0;
 
105
  const char* localname = nullptr;
 
106
  const char* prefix = nullptr;
 
107
  const char* nsUri = nullptr;
109
108
  splitNsName(&localname, &nsUri, nsName);
110
109
  SessionData* sd = reinterpret_cast<SessionData*>(userData);
111
110
  std::string characters;
140
139
XmlParser::XmlParser(ParserStateMachine* psm)
141
140
  : psm_(psm),
142
141
    sessionData_(psm_),
143
 
    ctx_(XML_ParserCreateNS(0, static_cast<const XML_Char>('\t'))),
 
142
    ctx_(XML_ParserCreateNS(nullptr, static_cast<const XML_Char>('\t'))),
144
143
    lastError_(0)
145
144
{
146
145
  setupParser(ctx_, &sessionData_);
181
180
{
182
181
  psm_->reset();
183
182
  sessionData_.reset();
184
 
  XML_Bool rv = XML_ParserReset(ctx_, 0);
 
183
  XML_Bool rv = XML_ParserReset(ctx_, nullptr);
185
184
  if(rv == XML_FALSE) {
186
185
    return lastError_ = ERR_RESET;
187
186
  } else {