Skip to content
Browse files

fixed a bug in the SAX sliding read window that was off by 1

  • Loading branch information...
1 parent fb0f61b commit 3169f0ae908466008e40dc8b8c093e427d5a3d69 @ohler55 committed Jun 7, 2013
Showing with 14 additions and 14 deletions.
  1. +2 −10 README.md
  2. +9 −0 ext/ox/ox.c
  3. +2 −2 ext/ox/sax_buf.c
  4. +0 −1 ext/ox/sax_buf.h
  5. +1 −1 lib/ox/version.rb
View
12 README.md
@@ -34,17 +34,9 @@ A fast XML parser and Object marshaller as a Ruby gem.
## <a name="release">Release Notes</a>
-### Release 2.0.1
+### Release 2.0.2
- - Added an attrs_done callback to the sax parser that will be called when all
- attributes for an element have been read.
-
- - Fixed bug in SAX parser where raising an exception in the handler routines
- would not cleanup. The test put together by griffinmyers was a huge help.
-
- - Reduced stack use in a several places to improve fiber support.
-
- - Changed exception handling to assure proper cleanup with new stack minimizing.
+ - Fixed buffer sliding window off by 1 error in the SAX parser.
## <a name="description">Description</a>
View
9 ext/ox/ox.c
@@ -238,6 +238,9 @@ defuse_bom(char *xml, Options options) {
* - effort: [:strict|:tolerant|:auto_define] set the tolerance level for loading
* - symbolize_keys: [true|false|nil] symbolize element attribute keys or leave as Strings
* @return [Hash] all current option settings.
+ *
+ * Note that an indent of less than zero will result in a tight one line output
+ * unless the text in the XML fields contain new line characters.
*/
static VALUE
get_def_opts(VALUE self) {
@@ -755,6 +758,9 @@ parse_dump_options(VALUE ropts, Options copts) {
* @param [:strict|:tolerant] :effort effort to use when an undumpable object (e.g., IO) is encountered, default: :strict
* - *:strict* - raise an NotImplementedError if an undumpable object is encountered
* - *:tolerant* - replaces undumplable objects with nil
+ *
+ * Note that an indent of less than zero will result in a tight one line output
+ * unless the text in the XML fields contain new line characters.
*/
static VALUE
dump(int argc, VALUE *argv, VALUE self) {
@@ -795,6 +801,9 @@ dump(int argc, VALUE *argv, VALUE self) {
* @param [:strict|:tolerant] :effort effort to use when an undumpable object (e.g., IO) is encountered, default: :strict
* - *:strict* - raise an NotImplementedError if an undumpable object is encountered
* - *:tolerant* - replaces undumplable objects with nil
+ *
+ * Note that an indent of less than zero will result in a tight one line output
+ * unless the text in the XML fields contain new line characters.
*/
static VALUE
to_file(int argc, VALUE *argv, VALUE self) {
View
4 ext/ox/sax_buf.c
@@ -118,9 +118,9 @@ ox_sax_buf_read(Buf buf) {
if (0 == buf->pro) {
shift = buf->tail - buf->head;
} else {
- shift = buf->pro - buf->head;
+ shift = buf->pro - buf->head - 1; // leave one character so we cab backup one
}
- if (0 == shift) { /* no space left so allocate more */
+ if (0 >= shift) { /* no space left so allocate more */
char *old = buf->head;
size_t size = buf->end - buf->head + BUF_PAD;
View
1 ext/ox/sax_buf.h
@@ -194,5 +194,4 @@ buf_checkback(Buf buf, CheckPt cp) {
return cp->c;
}
-
#endif /* __OX_SAX_BUF_H__ */
View
2 lib/ox/version.rb
@@ -1,5 +1,5 @@
module Ox
# Current version of the module.
- VERSION = '2.0.1'
+ VERSION = '2.0.2'
end

0 comments on commit 3169f0a

Please sign in to comment.
Something went wrong with that request. Please try again.