aboutsummaryrefslogtreecommitdiff
path: root/ch2/2-03_hex-to-int.c
diff options
context:
space:
mode:
authorzlg <zlg@zlg.space>2016-06-16 10:15:33 -0700
committerzlg <zlg@zlg.space>2016-06-16 10:15:33 -0700
commitf8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7 (patch)
treee37b327d7f93435e93a57427600d2b91fbb0cd87 /ch2/2-03_hex-to-int.c
parentSolve Exercise 7-2: Format arbitrary input (diff)
downloadknr-f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7.tar.gz
knr-f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7.tar.bz2
knr-f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7.tar.xz
knr-f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7.zip
The massive astyle sweep!
Code style should be consistent now. All future commits will be run through astyle or they will be amended.
Diffstat (limited to '')
-rw-r--r--ch2/2-03_hex-to-int.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/ch2/2-03_hex-to-int.c b/ch2/2-03_hex-to-int.c
index 566bd75..4985bc5 100644
--- a/ch2/2-03_hex-to-int.c
+++ b/ch2/2-03_hex-to-int.c
@@ -25,16 +25,15 @@
int htoi(char s[]) {
int i, val;
-
for (i = val = 0; isxdigit(s[i]) || toupper(s[i]) == 'X'; ++i) {
if (toupper(s[i]) == 'X') {
continue;
}
if (s[i] > '9') {
val = 16 * val + (toupper(s[i]) - '7');
- // The 7 is because 'A' is 7 higher than '9' in ASCII and thus only needs
- // to be knocked down by that much to fall in line with the normal integer
- // conversion
+ /* The 7 is because 'A' is 7 higher than '9' in ASCII and thus only needs */
+ /* to be knocked down by that much to fall in line with the normal integer */
+ /* conversion */
} else {
val = 16 * val + (s[i] - '0');
}