Skip to content

Commit

Permalink
updated pugixml to version 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
plc-user committed Nov 13, 2022
1 parent b8884c0 commit 2989050
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 16 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ QET_ElementScaler is a commandline-tool to scale QElectroTech-Elements with cons
With the optional parameter "-o" or "--stdout" the changed data is written to stdout and no new file is created.


It compiles with C++17 activated on Debian/GNU Linux (unstable), ReactOS (0.4.15-dev-5153) and macOS (darwin 21.6.0.0).
It compiles with C++17 activated on Debian/GNU Linux (unstable), ReactOS (0.4.15-dev-5359) and macOS (darwin 21.6.0.0).
The ReactOS-Build can also be used with Win in a cmd-window.<br>

QET_ElementScaler can process one file at a time.
Expand Down Expand Up @@ -65,7 +65,6 @@ QET_ElementScaler -i -x 2 -y 3 &lt; ElementToScale.elmt &gt; ScaledElement.e
<br>
<br>

QET_ElementScaler uses Arseny Kapoulkine's &quot;pugixml&quot; (https://pugixml.org)
to handle the content of the Element-File. <br>
Thank you, Arseny! <br>
QET_ElementScaler uses Arseny Kapoulkine's &quot;pugixml&quot; (/~https://github.com/zeux/pugixml)
to handle the content of the Element-File. Thank you, Arseny! <br>
<br>
2 changes: 1 addition & 1 deletion inc/pugixml/pugiconfig.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* pugixml parser - version 1.12
* pugixml parser - version 1.13
* --------------------------------------------------------
* Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
Expand Down
32 changes: 28 additions & 4 deletions inc/pugixml/pugixml.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* pugixml parser - version 1.12
* pugixml parser - version 1.13
* --------------------------------------------------------
* Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
Expand Down Expand Up @@ -5070,7 +5070,7 @@ PUGI__NS_BEGIN
xml_writer_file writer(file);
doc.save(writer, indent, flags, encoding);

return ferror(file) == 0;
return fflush(file) == 0 && ferror(file) == 0;
}

struct name_null_sentry
Expand Down Expand Up @@ -5372,6 +5372,13 @@ namespace pugi
return impl::strcpy_insitu(_attr->name, _attr->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs));
}

PUGI__FN bool xml_attribute::set_value(const char_t* rhs, size_t sz)
{
if (!_attr) return false;

return impl::strcpy_insitu(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs, sz);
}

PUGI__FN bool xml_attribute::set_value(const char_t* rhs)
{
if (!_attr) return false;
Expand Down Expand Up @@ -5762,6 +5769,16 @@ namespace pugi
return impl::strcpy_insitu(_root->name, _root->header, impl::xml_memory_page_name_allocated_mask, rhs, impl::strlength(rhs));
}

PUGI__FN bool xml_node::set_value(const char_t* rhs, size_t sz)
{
xml_node_type type_ = _root ? PUGI__NODETYPE(_root) : node_null;

if (type_ != node_pcdata && type_ != node_cdata && type_ != node_comment && type_ != node_pi && type_ != node_doctype)
return false;

return impl::strcpy_insitu(_root->value, _root->header, impl::xml_memory_page_value_allocated_mask, rhs, sz);
}

PUGI__FN bool xml_node::set_value(const char_t* rhs)
{
xml_node_type type_ = _root ? PUGI__NODETYPE(_root) : node_null;
Expand Down Expand Up @@ -6644,6 +6661,13 @@ namespace pugi
}
#endif

PUGI__FN bool xml_text::set(const char_t* rhs, size_t sz)
{
xml_node_struct* dn = _data_new();

return dn ? impl::strcpy_insitu(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs, sz) : false;
}

PUGI__FN bool xml_text::set(const char_t* rhs)
{
xml_node_struct* dn = _data_new();
Expand Down Expand Up @@ -7399,15 +7423,15 @@ namespace pugi
using impl::auto_deleter; // MSVC7 workaround
auto_deleter<FILE> file(impl::open_file(path_, (flags & format_save_file_text) ? "w" : "wb"), impl::close_file);

return impl::save_file_impl(*this, file.data, indent, flags, encoding);
return impl::save_file_impl(*this, file.data, indent, flags, encoding) && fclose(file.release()) == 0;
}

PUGI__FN bool xml_document::save_file(const wchar_t* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const
{
using impl::auto_deleter; // MSVC7 workaround
auto_deleter<FILE> file(impl::open_file_wide(path_, (flags & format_save_file_text) ? L"w" : L"wb"), impl::close_file);

return impl::save_file_impl(*this, file.data, indent, flags, encoding);
return impl::save_file_impl(*this, file.data, indent, flags, encoding) && fclose(file.release()) == 0;
}

PUGI__FN xml_node xml_document::document_element() const
Expand Down
7 changes: 5 additions & 2 deletions inc/pugixml/pugixml.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* pugixml parser - version 1.12
* pugixml parser - version 1.13
* --------------------------------------------------------
* Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
* Report bugs and download new versions at https://pugixml.org/
Expand All @@ -14,7 +14,7 @@
// Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons
// Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits
#ifndef PUGIXML_VERSION
# define PUGIXML_VERSION 1120 // 1.12
# define PUGIXML_VERSION 1130 // 1.13
#endif

// Include user configuration file (this can define various configuration macros)
Expand Down Expand Up @@ -418,6 +418,7 @@ namespace pugi

// Set attribute name/value (returns false if attribute is empty or there is not enough memory)
bool set_name(const char_t* rhs);
bool set_value(const char_t* rhs, size_t sz);
bool set_value(const char_t* rhs);

// Set attribute value with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
Expand Down Expand Up @@ -552,6 +553,7 @@ namespace pugi

// Set node name/value (returns false if node is empty, there is not enough memory, or node can not have name/value)
bool set_name(const char_t* rhs);
bool set_value(const char_t* rhs, size_t sz);
bool set_value(const char_t* rhs);

// Add attribute with specified name. Returns added attribute, or empty attribute on errors.
Expand Down Expand Up @@ -777,6 +779,7 @@ namespace pugi
bool as_bool(bool def = false) const;

// Set text (returns false if object is empty or there is not enough memory)
bool set(const char_t* rhs, size_t sz);
bool set(const char_t* rhs);

// Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false")
Expand Down
13 changes: 8 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// - macOS Monterey 12.6 (darwin21.6.0)
//
// to compile the code with GCC on Linux use these commands:
// g++ -Wall -O2 std=c++17 -c inc/pugixml/pugixml.cpp -o obj/inc/pugixml/pugixml.o
// g++ -Wall -O2 std=c++17 -c main.cpp -o obj/main.o
// g++ -Wall -O2 -std=c++17 -c inc/pugixml/pugixml.cpp -o obj/inc/pugixml/pugixml.o
// g++ -Wall -O2 -std=c++17 -c main.cpp -o obj/main.o
// g++ -o QET_ElementScaler obj/inc/pugixml/pugixml.o obj/main.o -s
//
// these commands work (TDM-GCC 10.3.0) on ReactOS to compile:
Expand All @@ -18,8 +18,8 @@
// g++.exe -o QET_ElementScaler.exe obj\inc\pugixml\pugixml.o obj\main.o -s
//
// compile for macOS (clang 14.0.0 / Monterey 12.6 / x86_64-apple-darwin21.6.0):
// g++ -Wall -O2 std=c++17 -c inc/pugixml/pugixml.cpp -o obj/inc/pugixml/pugixml.o
// g++ -Wall -O2 std=c++17 -c main.cpp -o obj/main.o
// g++ -Wall -O2 -std=c++17 -c inc/pugixml/pugixml.cpp -o obj/inc/pugixml/pugixml.o
// g++ -Wall -O2 -std=c++17 -c main.cpp -o obj/main.o
// g++ -o QET_ElementScaler obj/inc/pugixml/pugixml.o obj/main.o
//
//
Expand All @@ -33,6 +33,9 @@
// Result is a new file "FILENAME.SCALED.elmt" or output on stdout
// in both cases without the XML declaration-line
//
// Change(s) for 0.4beta4
// - updated PugiXML to version 1.13
//
// Change(s) for 0.4beta3
// - added values "start" and "angle" of "arc" for rounding to ... decimals
//
Expand Down Expand Up @@ -83,7 +86,7 @@
#include "inc/pugixml/pugixml.hpp"
#include "main.h"

const string sVersion = "0.4beta3";
const string sVersion = "0.4beta4";

const int _debug_ = 0;
const int _debug_points_ = 0;
Expand Down

0 comments on commit 2989050

Please sign in to comment.