diff options
author | Adrian Thurston <thurston@complang.org> | 2015-03-14 15:07:54 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2015-03-14 15:07:54 -0400 |
commit | 71548b81cd65687f53ecb2abcf14807d488d7af5 (patch) | |
tree | 7cfade7a4cd01a201fbd6875e273ffb8b232a10a /src/string.c | |
parent | b2a6b17f584b4bfcedbb405a65d020506cd82458 (diff) | |
download | colm-71548b81cd65687f53ecb2abcf14807d488d7af5.tar.gz |
added string.atoo (octal version of atoi)
Need to clean up these function names and make them global.
Diffstat (limited to 'src/string.c')
-rw-r--r-- | src/string.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c index ba55923c..0c69d1b2 100644 --- a/src/string.c +++ b/src/string.c @@ -228,6 +228,17 @@ Word strAtoi( Head *str ) return res; } +Word strAtoo( Head *str ) +{ + /* FIXME: need to implement this by hand. There is no null terminator. */ + char *nulled = (char*)malloc( str->length + 1 ); + memcpy( nulled, str->data, str->length ); + nulled[str->length] = 0; + int res = strtol( nulled, 0, 8 ); + free( nulled ); + return res; +} + Head *intToStr( Program *prg, Word i ) { char data[20]; |