From 71548b81cd65687f53ecb2abcf14807d488d7af5 Mon Sep 17 00:00:00 2001 From: Adrian Thurston Date: Sat, 14 Mar 2015 15:07:54 -0400 Subject: added string.atoo (octal version of atoi) Need to clean up these function names and make them global. --- src/string.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/string.c') 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]; -- cgit v1.2.1