projects
/
u
/
mdw
/
catacomb
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6ea6fe5
)
Allow `0o' and `0b' prefixes for octal and binary (from Haskell)
author
mdw
<mdw>
Wed, 9 Oct 2002 00:33:44 +0000
(
00:33
+0000)
committer
mdw
<mdw>
Wed, 9 Oct 2002 00:33:44 +0000
(
00:33
+0000)
mptext.c
patch
|
blob
|
blame
|
history
diff --git
a/mptext.c
b/mptext.c
index
84056e6
..
565322d
100644
(file)
--- a/
mptext.c
+++ b/
mptext.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: mptext.c,v 1.1
3 2002/10/09 00:21:06
mdw Exp $
+ * $Id: mptext.c,v 1.1
4 2002/10/09 00:33:44
mdw Exp $
*
* Textual representation of multiprecision numbers
*
*
* Textual representation of multiprecision numbers
*
@@
-30,6
+30,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: mptext.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: mptext.c,v $
+ * Revision 1.14 2002/10/09 00:33:44 mdw
+ * Allow `0o' and `0b' prefixes for octal and binary (from Haskell)
+ *
* Revision 1.13 2002/10/09 00:21:06 mdw
* Allow user-specified `r_xx' bases to be up to 62.
*
* Revision 1.13 2002/10/09 00:21:06 mdw
* Allow user-specified `r_xx' bases to be up to 62.
*
@@
-210,12
+213,22
@@
mp *mp_read(mp *m, int radix, const mptext_ops *ops, void *p)
r = 0;
} else {
ch = ops->get(p);
r = 0;
} else {
ch = ops->get(p);
- if (ch == 'x') {
- ch = ops->get(p);
- rd = 16;
- } else {
- rd = 8;
- f |= f_ok;
+ switch (ch) {
+ case 'x':
+ rd = 16;
+ goto prefix;
+ case 'o':
+ rd = 8;
+ goto prefix;
+ case 'b':
+ rd = 2;
+ goto prefix;
+ prefix:
+ ch = ops->get(p);
+ break;
+ default:
+ rd = 8;
+ f |= f_ok;
}
r = -1;
}
}
r = -1;
}