summaryrefslogtreecommitdiff
path: root/lib/numbers.c
diff options
context:
space:
mode:
authorPixel <>2001-04-17 04:05:52 +0000
committerPixel <>2001-04-17 04:05:52 +0000
commit5aed7634c8993e3366817c4b20fca1aa18eacf21 (patch)
treecfb6c00a13b8f213255ea231a3d814f61ab2964b /lib/numbers.c
parent55f981c9fca048fba18d0538be4ed5dc1cc3fe11 (diff)
Indentation plus faible
Diffstat (limited to 'lib/numbers.c')
-rw-r--r--lib/numbers.c95
1 files changed, 48 insertions, 47 deletions
diff --git a/lib/numbers.c b/lib/numbers.c
index 9f032b5..02cb536 100644
--- a/lib/numbers.c
+++ b/lib/numbers.c
@@ -6,57 +6,58 @@ en octal préfixés avec 0 et les nombres en hexadécimal préfixés avec 0x. */
int char_to_number(char *st, int *valid)
{
- int whattype = 0, result = 0;
+ int whattype = 0, result = 0;
- *valid = 0;
+ *valid = 0;
- if (*st == '0') {
- st++;
- if (*st == 'x') {
- whattype = 1;
- st++;
- } else if (*st) {
- whattype = 2;
- } else {
- *valid = 1;
- return 0;
- }
+ if (*st == '0') {
+ st++;
+ if (*st == 'x') {
+ whattype = 1;
+ st++;
+ } else if (*st) {
+ whattype = 2;
+ } else {
+ *valid = 1;
+ return 0;
}
+ }
- while (*st) {
- switch (whattype) {
- case 0:
- if ((*st < '0') || (*st > '9')) {
- return 0;
- }
- result *= 10;
- result += *st - '0';
- break;
- case 1:
- if (((*st < '0') || (*st > '9')) && ((*st < 'A') || (*st > 'F'))
- && ((*st < 'a') || (*st > 'f'))) {
- return 0;
- }
- result *= 16;
- if ((*st >= '0') && (*st <= '9')) {
- result += *st - '0';
- } else if ((*st >= 'A') && (*st <= 'F')) {
- result += *st - 'A' + 10;
- } else {
- result += *st - 'a' + 10;
- }
- break;
- case 2:
- if ((*st < '0') || (*st > '7')) {
- return 0;
- }
- result *= 8;
- result += *st - '0';
- break;
- }
- st++;
+ while (*st) {
+ switch (whattype) {
+ case 0:
+ if ((*st < '0') || (*st > '9')) {
+ return 0;
+ }
+ result *= 10;
+ result += *st - '0';
+ break;
+ case 1:
+ if (((*st < '0') || (*st > '9'))
+ && ((*st < 'A') || (*st > 'F'))
+ && ((*st < 'a') || (*st > 'f'))) {
+ return 0;
+ }
+ result *= 16;
+ if ((*st >= '0') && (*st <= '9')) {
+ result += *st - '0';
+ } else if ((*st >= 'A') && (*st <= 'F')) {
+ result += *st - 'A' + 10;
+ } else {
+ result += *st - 'a' + 10;
+ }
+ break;
+ case 2:
+ if ((*st < '0') || (*st > '7')) {
+ return 0;
+ }
+ result *= 8;
+ result += *st - '0';
+ break;
}
+ st++;
+ }
- *valid = 1;
- return result;
+ *valid = 1;
+ return result;
}