diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-04 15:24:23 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-04 15:24:23 +0100 |
commit | 55c894778414d0be0a04929770bc7d4862d416d0 (patch) | |
tree | 304135621d7b73b295e95fc7031fdfb0756bcf60 /monitor/mon.c | |
parent | 646720fdd975f30d7d1ef076feeda7b0d9b18c9a (diff) | |
download | SystDigit-Projet-55c894778414d0be0a04929770bc7d4862d416d0.tar.gz SystDigit-Projet-55c894778414d0be0a04929770bc7d4862d416d0.zip |
Nothingness...
Diffstat (limited to 'monitor/mon.c')
-rw-r--r-- | monitor/mon.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/monitor/mon.c b/monitor/mon.c index 22197e9..19259a1 100644 --- a/monitor/mon.c +++ b/monitor/mon.c @@ -167,21 +167,32 @@ void mon_handle_command(t_mon *mon, const char *c) { if (c[1] == 0) { mon->ser_in_in = mon->ser_in_busy_out = mon->ser_out = -1; } else { - int u = 0, v = 0, w = 0; + int u = -1, v = -1, w = -1; const char *p = c + 1; while (isspace(*p)) p++; - while (isdigit(*p)) u = u * 10 + (*(p++) - '0'); + if (*p == '-') { + p++; + } else if (*p != 0) { + u = 0; + while (isdigit(*p)) u = u * 10 + (*(p++) - '0'); + } while (isspace(*p)) p++; - while (isdigit(*p)) v = v * 10 + (*(p++) - '0'); + if (*p == '-') { + p++; + } else if (*p != 0) { + v = 0; + while (isdigit(*p)) v = v * 10 + (*(p++) - '0'); + } while (isspace(*p)) p++; - while (isdigit(*p)) w = w * 10 + (*(p++) - '0'); - if (u >= 0 && u < mon->n_inputs && - v >= 0 && v < mon->n_outputs && - w >= 0 && w < mon->n_outputs) { - mon->ser_in_in = u; - mon->ser_in_busy_out = v; - mon->ser_out = w; + if (*p == '-') { + p++; + } else if (*p != 0) { + w = 0; + while (isdigit(*p)) w = w * 10 + (*(p++) - '0'); } + if (u < mon->n_inputs) mon->ser_in_in = u; + if (v < mon->n_outputs) mon->ser_in_busy_out = v; + if (w < mon->n_outputs) mon->ser_out = w; } } else if (c[0] == ':') { |