diff --git a/mio/lib/fmt.c b/mio/lib/fmt.c index 6000338..2ca4e82 100644 --- a/mio/lib/fmt.c +++ b/mio/lib/fmt.c @@ -1393,10 +1393,10 @@ static int log_oocs (mio_fmtout_t* fmtout, const mio_ooch_t* ptr, mio_oow_t len) { /* the mask has changed. commit the buffered text */ /* TODO: HANDLE LINE ENDING CONVENTION BETTER... */ - if (mio->log.ptr[mio->log.len - 1] != '\n') + if (mio->log.ptr[mio->log.len - 1] != MIO_EOL) { /* no line ending - append a line terminator */ - mio->log.ptr[mio->log.len++] = '\n'; + mio->log.ptr[mio->log.len++] = MIO_EOL; } MIO_SYS_WRITE_LOG (mio, mio->log.last_mask, mio->log.ptr, mio->log.len); @@ -1438,10 +1438,10 @@ redo: { /* can't expand the buffer. just flush the existing contents */ /* TODO: HANDLE LINE ENDING CONVENTION BETTER... */ - if (mio->log.ptr[mio->log.len - 1] != '\n') + if (mio->log.ptr[mio->log.len - 1] != MIO_EOL) { /* no line ending - append a line terminator */ - mio->log.ptr[mio->log.len++] = '\n'; + mio->log.ptr[mio->log.len++] = MIO_EOL; } MIO_SYS_WRITE_LOG (mio, mio->log.last_mask, mio->log.ptr, mio->log.len); mio->log.len = 0; @@ -1555,7 +1555,7 @@ mio_ooi_t mio_logbfmtv (mio_t* mio, mio_bitmask_t mask, const mio_bch_t* fmt, va x = fmt_outv(&fo, ap); - if (mio->log.len > 0 && mio->log.ptr[mio->log.len - 1] == '\n') + if (mio->log.len > 0 && mio->log.ptr[mio->log.len - 1] == MIO_EOL) { MIO_SYS_WRITE_LOG (mio, mio->log.last_mask, mio->log.ptr, mio->log.len); mio->log.len = 0; @@ -1609,7 +1609,7 @@ mio_ooi_t mio_logufmtv (mio_t* mio, mio_bitmask_t mask, const mio_uch_t* fmt, va x = fmt_outv(&fo, ap); - if (mio->log.len > 0 && mio->log.ptr[mio->log.len - 1] == '\n') + if (mio->log.len > 0 && mio->log.ptr[mio->log.len - 1] == MIO_EOL) { MIO_SYS_WRITE_LOG (mio, mio->log.last_mask, mio->log.ptr, mio->log.len); mio->log.len = 0; diff --git a/mio/lib/json.c b/mio/lib/json.c index 45e033b..63c2567 100644 --- a/mio/lib/json.c +++ b/mio/lib/json.c @@ -800,7 +800,7 @@ static int feed_json_data (mio_json_t* json, const mio_bch_t* data, mio_oow_t le c = *ptr++; #endif - if (c == '\n') + if (c == MIO_EOL) { json->c_col = 0; json->c_line++; @@ -812,7 +812,7 @@ static int feed_json_data (mio_json_t* json, const mio_bch_t* data, mio_oow_t le if (json->state_stack->in_comment) { - if (c == '\n') json->state_stack->in_comment = 0; + if (c == MIO_EOL) json->state_stack->in_comment = 0; continue; } if (json->state_stack->state == MIO_JSON_STATE_START && mio_is_ooch_space(c)) continue; /* skip white space */ diff --git a/mio/lib/mio-cmn.h b/mio/lib/mio-cmn.h index 1a8126a..f6b76fa 100644 --- a/mio/lib/mio-cmn.h +++ b/mio/lib/mio-cmn.h @@ -588,6 +588,9 @@ struct mio_ntime_t #define MIO_COUNTOF(x) (sizeof(x) / sizeof(x[0])) #define MIO_BITSOF(x) (sizeof(x) * MIO_BITS_PER_BYTE) + +#define MIO_EOL ('\n') + /** * The MIO_OFFSETOF() macro returns the offset of a field from the beginning * of a structure.