PERFORCE change 49858 for review
Marcel Moolenaar
marcel at FreeBSD.org
Sun Mar 28 16:58:29 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=49858
Change 49858 by marcel at marcel_nfs on 2004/03/28 16:57:53
Fix gdb_rx_varhex(): make sure the rx pointer is moved back
correctly in all cases when we fetch a non-hex digit.
Affected files ...
.. //depot/projects/gdb/sys/gdb/gdb_packet.c#8 edit
Differences ...
==== //depot/projects/gdb/sys/gdb/gdb_packet.c#8 (text+ko) ====
@@ -114,29 +114,29 @@
gdb_rx_varhex(uintmax_t *vp)
{
uintmax_t v;
- int c, neg, valid;
+ int c, neg;
c = gdb_rx_char();
- if (c == -1)
- return (-1);
neg = (c == '-') ? 1 : 0;
if (neg == 1)
c = gdb_rx_char();
+ if (!isxdigit(c)) {
+ gdb_rxp -= ((c == -1) ? 0 : 1) + neg;
+ gdb_rxsz += ((c == -1) ? 0 : 1) + neg;
+ return (-1);
+ }
v = 0;
- valid = (isxdigit(c)) ? 1 : 0;
- while (valid) {
+ do {
v <<= 4;
v += C2N(c);
c = gdb_rx_char();
- if (!isxdigit(c))
- break;
+ } while (isxdigit(c));
+ if (c != -1) {
+ gdb_rxp--;
+ gdb_rxsz++;
}
- if (!valid || c != -1) {
- gdb_rxp -= 1 + neg - valid;
- gdb_rxsz += 1 + neg - valid;
- }
*vp = (neg) ? -v : v;
- return ((valid) ? 0 : -1);
+ return (0);
}
/*
More information about the p4-projects
mailing list