Skip to content

Commit

Permalink
Fix Windows compile errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Mar 19, 2024
1 parent e676eb3 commit 528c89e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
8 changes: 4 additions & 4 deletions mxml-attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ mxmlElementGetAttr(mxml_node_t *node, // I - Element node

const char * // O - Attribute value
mxmlElementGetAttrByIndex(
mxml_node_t *node, // I - Node
int idx, // I - Attribute index, starting at `0`
const char **name) // O - Attribute name or `NULL` to not return it
mxml_node_t *node, // I - Node
size_t idx, // I - Attribute index, starting at `0`
const char **name) // O - Attribute name or `NULL` to not return it
{
if (!node || node->type != MXML_TYPE_ELEMENT || idx < 0 || idx >= node->value.element.num_attrs)
if (!node || node->type != MXML_TYPE_ELEMENT || idx >= node->value.element.num_attrs)
return (NULL);

if (name)
Expand Down
30 changes: 19 additions & 11 deletions mxml-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ mxmlLoadFilename(
// for example:
//
// ```c
// ssize_t my_io_cb(void *cbdata, void *buffer, size_t bytes)
// size_t my_io_cb(void *cbdata, void *buffer, size_t bytes)
// {
// ... copy up to "bytes" bytes into buffer ...
// ... return the number of bytes "read" or -1 on error ...
// ... return the number of bytes "read" or 0 on error ...
// }
// ```
//
Expand Down Expand Up @@ -511,10 +511,10 @@ mxmlSaveFilename(
// example:
//
// ```c
// ssize_t my_io_cb(void *cbdata, const void *buffer, size_t bytes)
// size_t my_io_cb(void *cbdata, const void *buffer, size_t bytes)
// {
// ... write/copy bytes from buffer to the output ...
// ... return the number of bytes written/copied or -1 on error ...
// ... return the number of bytes written/copied or 0 on error ...
// }
// ```
//
Expand Down Expand Up @@ -1858,12 +1858,16 @@ mxml_read_cb_fd(int *fd, // I - File descriptor
void *buffer, // I - Buffer
size_t bytes) // I - Bytes to read
{
ssize_t rbytes; // Bytes read
#if _WIN32
int rbytes; // Bytes read


#if _WIN32
rbytes = read(*fd, buffer, buffer);
rbytes = read(*fd, buffer, bytes);

#else
ssize_t rbytes; // Bytes read


while ((rbytes = read(*fd, buffer, bytes)) < 0)
{
if (errno != EINTR && errno != EAGAIN)
Expand Down Expand Up @@ -1917,7 +1921,7 @@ mxml_read_cb_string(
sb->bufptr += bytes;
}

return ((ssize_t)bytes);
return (bytes);
}


Expand Down Expand Up @@ -2009,12 +2013,16 @@ mxml_io_cb_fd(int *fd, // I - File descriptor
void *buffer, // I - Buffer
size_t bytes) // I - Bytes to write
{
ssize_t wbytes; // Bytes written
#if _WIN32
int wbytes; // Bytes written


#if _WIN32
wbytes = write(*fd, buffer, bytes);

#else
ssize_t wbytes; // Bytes written


while ((wbytes = write(*fd, buffer, bytes)) < 0)
{
if (errno != EINTR && errno != EAGAIN)
Expand Down Expand Up @@ -2159,7 +2167,7 @@ mxml_write_node(
if (attr->value)
width += strlen(attr->value) + 3;

if (options && options->wrap > 0 && (col + width) > options->wrap)
if (options && options->wrap > 0 && (col + (int)width) > options->wrap)
col = mxml_write_string("\n", io_cb, io_cbdata, /*use_entities*/false, col);
else
col = mxml_write_string(" ", io_cb, io_cbdata, /*use_entities*/false, col);
Expand Down
2 changes: 1 addition & 1 deletion mxml-node.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ mxmlRetain(mxml_node_t *node) // I - Node
static void
mxml_free(mxml_node_t *node) // I - Node
{
int i; // Looping var
size_t i; // Looping var


switch (node->type)
Expand Down
2 changes: 1 addition & 1 deletion mxml.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ extern void mxmlDelete(mxml_node_t *node);

extern void mxmlElementClearAttr(mxml_node_t *node, const char *name);
extern const char *mxmlElementGetAttr(mxml_node_t *node, const char *name);
extern const char *mxmlElementGetAttrByIndex(mxml_node_t *node, int idx, const char **name);
extern const char *mxmlElementGetAttrByIndex(mxml_node_t *node, size_t idx, const char **name);
extern size_t mxmlElementGetAttrCount(mxml_node_t *node);
extern void mxmlElementSetAttr(mxml_node_t *node, const char *name, const char *value);
extern void mxmlElementSetAttrf(mxml_node_t *node, const char *name, const char *format, ...) MXML_FORMAT(3,4);
Expand Down

0 comments on commit 528c89e

Please sign in to comment.