ref: 953387d7ba137ebd25a120e2ce2fd1a61f2d455d
parent: 2ef29e10f4157b90f0f4b5ce7f3bca551231ce02
author: cinap_lenrek <[email protected]>
date: Mon Aug 3 13:08:33 EDT 2015
bitsy: replace atoi() calls with strtol() when hex can be expcted
--- a/sys/src/9/bitsy/devuda1341.c
+++ b/sys/src/9/bitsy/devuda1341.c
@@ -1326,7 +1326,8 @@
if(strcmp(cb->f[i], "reg") == 0) {
if(cb->nf < 3)
error(Evolume);
- setreg(cb->f[1], atoi(cb->f[2]), cb->nf == 4 ? atoi(cb->f[3]):1);
+ setreg(cb->f[1], strtol(cb->f[2], 0, 0),
+ cb->nf == 4 ? strtol(cb->f[3], 0, 0):1);
return n0;
}
error(Evolume);
--- a/sys/src/9/bitsy/devµc.c
+++ b/sys/src/9/bitsy/devµc.c
@@ -349,7 +349,7 @@
if(cmd->nf > 15)
error(Ebadarg);
for(i = 0; i < cmd->nf; i++)
- data[i] = atoi(cmd->f[i]);
+ data[i] = strtol(cmd->f[i], 0, 0);
switch((ulong)c->qid.path){
case Qled:
--- a/sys/src/9/bitsy/screen.c
+++ b/sys/src/9/bitsy/screen.c
@@ -194,14 +194,14 @@
return;
if(*cmd->f[0] == 'h')
lcd->lccr1 = ((Ht-16)<<PPL)
- | (atoi(cmd->f[1])<<HSW)
- | (atoi(cmd->f[2])<<ELW)
- | (atoi(cmd->f[3])<<BLW);
+ | (strtol(cmd->f[1], 0, 0)<<HSW)
+ | (strtol(cmd->f[2], 0, 0)<<ELW)
+ | (strtol(cmd->f[3], 0, 0)<<BLW);
if(*cmd->f[0] == 'v')
lcd->lccr2 = ((Wid-1)<<LPP)
- | (atoi(cmd->f[1])<<VSW)
- | (atoi(cmd->f[2])<<EFW)
- | (atoi(cmd->f[3])<<BFW);
+ | (strtol(cmd->f[1], 0, 0)<<VSW)
+ | (strtol(cmd->f[2], 0, 0)<<EFW)
+ | (strtol(cmd->f[3], 0, 0)<<BFW);
}
void