Fix reading of UTF-16 characters from files.

pull/193/head
Michael R Sweet 11 years ago
parent b6c73fe01c
commit ace5aa8686
  1. 3
      CHANGES
  2. 43
      mxml-file.c

@ -3,11 +3,12 @@ CHANGES - 2013-11-11
CHANGES IN Mini-XML 2.8
- Now call docsetutil using xcrun on OS X.
- Now call docsetutil using xcrun on OS X (Bug #458)
- mxmldoc did not escape special HTML characters inside @code foo@
comments.
- Fixed a memory leak in mxmlElementDeleteAttr (Bug #452)
- Added MXML_MAJOR/MINOR_VERSION definitions to mxml.h (Bug $461)
- Fixed a bug reading UTF-16 characters from a file (Bug #454)
CHANGES IN Mini-XML 2.7

@ -3,7 +3,7 @@
*
* File loading code for Mini-XML, a small XML-like file parsing library.
*
* Copyright 2003-2011 by Michael R Sweet.
* Copyright 2003-2013 by Michael R Sweet.
*
* These coded instructions, statements, and computer programs are the
* property of Michael R Sweet and are protected by Federal copyright
@ -12,41 +12,6 @@
* missing or damaged, see the license at:
*
* http://www.minixml.org/
*
* Contents:
*
* mxmlLoadFd() - Load a file descriptor into an XML node tree.
* mxmlLoadFile() - Load a file into an XML node tree.
* mxmlLoadString() - Load a string into an XML node tree.
* mxmlSaveAllocString() - Save an XML tree to an allocated string.
* mxmlSaveFd() - Save an XML tree to a file descriptor.
* mxmlSaveFile() - Save an XML tree to a file.
* mxmlSaveString() - Save an XML node tree to a string.
* mxmlSAXLoadFd() - Load a file descriptor into an XML node tree
* using a SAX callback.
* mxmlSAXLoadFile() - Load a file into an XML node tree
* using a SAX callback.
* mxmlSAXLoadString() - Load a string into an XML node tree
* using a SAX callback.
* mxmlSetCustomHandlers() - Set the handling functions for custom data.
* mxmlSetErrorCallback() - Set the error message callback.
* mxmlSetWrapMargin() - Set the wrap margin when saving XML data.
* mxml_add_char() - Add a character to a buffer, expanding as needed.
* mxml_fd_getc() - Read a character from a file descriptor.
* mxml_fd_putc() - Write a character to a file descriptor.
* mxml_fd_read() - Read a buffer of data from a file descriptor.
* mxml_fd_write() - Write a buffer of data to a file descriptor.
* mxml_file_getc() - Get a character from a file.
* mxml_file_putc() - Write a character to a file.
* mxml_get_entity() - Get the character corresponding to an entity...
* mxml_load_data() - Load data into an XML node tree.
* mxml_parse_element() - Parse an element for any attributes...
* mxml_string_getc() - Get a character from a string.
* mxml_string_putc() - Write a character to a string.
* mxml_write_name() - Write a name string.
* mxml_write_node() - Save an XML node to a file.
* mxml_write_string() - Write a string, escaping & and < as needed.
* mxml_write_ws() - Do whitespace callback...
*/
/*
@ -1287,7 +1252,8 @@ mxml_file_getc(void *p, /* I - Pointer to file */
* Multi-word UTF-16 char...
*/
int lch = (getc(fp) << 8) | getc(fp);
int lch = getc(fp);
lch = (lch << 8) | getc(fp);
if (lch < 0xdc00 || lch >= 0xdfff)
return (EOF);
@ -1315,7 +1281,8 @@ mxml_file_getc(void *p, /* I - Pointer to file */
* Multi-word UTF-16 char...
*/
int lch = getc(fp) | (getc(fp) << 8);
int lch = getc(fp);
lch |= (getc(fp) << 8);
if (lch < 0xdc00 || lch >= 0xdfff)
return (EOF);

Loading…
Cancel
Save