reverted state to use long type

This commit is contained in:
Daniel Holden
2014-10-17 15:32:00 +01:00
parent 5094d2c015
commit f6d7d87b8b
3 changed files with 15 additions and 12 deletions

View File

@@ -1,3 +1,10 @@
# Oct. 17, 2014; Daniel Holden
- Reverted state to use long type
# Oct. 16, 2014; Daniel Holden
- Removed comments describing changes
- Fixed warnings reported by gcc in test suite under the new compilation flags
# Oct. 14, 2014; Dalton Woodard
- Fixed all compilation warnings in `mpc.h` and `mpc.c`; both now compile successfully on OS X under clang-600.0.51
and gcc 4.9.1 with the following flags:

10
mpc.c
View File

@@ -6,9 +6,9 @@
static mpc_state_t mpc_state_invalid(void) {
mpc_state_t s;
s.pos = SIZE_MAX;
s.row = SIZE_MAX;
s.col = SIZE_MAX;
s.pos = -1;
s.row = -1;
s.col = -1;
return s;
}
@@ -465,7 +465,7 @@ static void mpc_input_rewind(mpc_input_t *i) {
}
static int mpc_input_buffer_in_range(mpc_input_t *i) {
return i->state.pos < (strlen(i->buffer) + i->marks[0].pos);
return i->state.pos < (long)(strlen(i->buffer) + i->marks[0].pos);
}
static char mpc_input_buffer_get(mpc_input_t *i) {
@@ -473,7 +473,7 @@ static char mpc_input_buffer_get(mpc_input_t *i) {
}
static int mpc_input_terminated(mpc_input_t *i) {
if (i->type == MPC_INPUT_STRING && i->state.pos == strlen(i->string)) { return 1; }
if (i->type == MPC_INPUT_STRING && i->state.pos == (long)strlen(i->string)) { return 1; }
if (i->type == MPC_INPUT_FILE && feof(i->file)) { return 1; }
if (i->type == MPC_INPUT_PIPE && feof(i->file)) { return 1; }
return 0;

10
mpc.h
View File

@@ -21,14 +21,10 @@
** State Type
*/
/*
** changed to unsigned values for indexing in state,
** invalid is now signified by SIZE_MAX.
*/
typedef struct {
size_t pos;
size_t row;
size_t col;
long pos;
long row;
long col;
} mpc_state_t;
/*