From 1301bcd9b7d7170b20cc3315da8b0b6d720b139e Mon Sep 17 00:00:00 2001 From: neil Date: Sat, 20 Feb 2016 04:21:02 +0000 Subject: [PATCH] Removed usage of clib functions in alib. strlen() was replaced with a macro, and atoi() was replaced with StrToLong(). The replacements were respectively tested with RX (through StrDup()) and Blanker (through ArgInt()). git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@51504 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- compiler/alib/acrypt.c | 2 -- compiler/alib/alib_intern.h | 9 ++++++++- compiler/alib/argint.c | 10 +++++----- compiler/alib/newlist.c | 7 +------ compiler/alib/setrexxvar.c | 15 ++++++++------- compiler/alib/strdup.c | 5 ++--- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/compiler/alib/acrypt.c b/compiler/alib/acrypt.c index 1f98a8d5b7..e23d7ceca1 100644 --- a/compiler/alib/acrypt.c +++ b/compiler/alib/acrypt.c @@ -34,14 +34,12 @@ #define ACrypt __ACrypt #include -#include #include #undef ACrypt /****************************************************************************/ -//#include "debug.h" #include /****************************************************************************/ diff --git a/compiler/alib/alib_intern.h b/compiler/alib/alib_intern.h index 4d40fa02dc..3d3cdc433c 100644 --- a/compiler/alib/alib_intern.h +++ b/compiler/alib/alib_intern.h @@ -2,7 +2,7 @@ #define _ALIB_INTERN_H /* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. + Copyright © 1995-2016, The AROS Development Team. All rights reserved. $Id$ */ @@ -19,4 +19,11 @@ # include #endif +#define STRLEN(s) \ +({ \ + CONST_STRPTR _s = s; \ + while (*_s++ != '\0'); \ + _s - s - 1; \ +}) + #endif /* _ALIB_INTERN_H */ diff --git a/compiler/alib/argint.c b/compiler/alib/argint.c index 11e42e9ec9..63f3cad250 100644 --- a/compiler/alib/argint.c +++ b/compiler/alib/argint.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. + Copyright © 1995-2016, The AROS Development Team. All rights reserved. $Id$ */ @@ -9,6 +9,7 @@ #include #include +#include #include extern struct Library *IconBase; @@ -48,16 +49,15 @@ extern struct Library *IconBase; The Amiga documentation says "requires that dos.library V36 or higher is opened". I can't see why. - HISTORY - 29.04.98 SDuvan implemented - *****************************************************************************/ { STRPTR match; + LONG result = defaultval; if((match = FindToolType(tt, entry)) == NULL) return defaultval; - return atoi(match); + StrToLong(match, &result); + return result; } /* ArgArrayInt */ diff --git a/compiler/alib/newlist.c b/compiler/alib/newlist.c index 0ff0bef8a6..72d8f2c25d 100644 --- a/compiler/alib/newlist.c +++ b/compiler/alib/newlist.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2001, The AROS Development Team. All rights reserved. + Copyright © 1995-2016, The AROS Development Team. All rights reserved. $Id$ Desc: Initialize a list @@ -42,17 +42,12 @@ INTERNALS - HISTORY - 28.11.96 digulla written - ******************************************************************************/ { NEWLIST(list); } /* NewList */ #ifdef TEST -#include - int main (int argc, char ** argv) { struct List list; diff --git a/compiler/alib/setrexxvar.c b/compiler/alib/setrexxvar.c index bdb161cf24..1b4e6d412b 100644 --- a/compiler/alib/setrexxvar.c +++ b/compiler/alib/setrexxvar.c @@ -1,17 +1,18 @@ /* - Copyright © 1995-2007, The AROS Development Team. All rights reserved. + Copyright © 1995-2016, The AROS Development Team. All rights reserved. $Id$ Desc: Lang: english */ + #include #include #include #include #include -#include +#include "alib_intern.h" /***************************************************************************** @@ -25,16 +26,16 @@ ULONG length) /* FUNCTION - Set a the value of the name rexx variable. + Set the value of the named Rexx variable. INPUTS - msg - A rexx message generated from a running rexx script + msg - A Rexx message generated from a running Rexx script varname - The name of the variable to set the value value - a pointer to the beginning of the value to set length - the length of the value argument RESULT - 0 when succes, otherwise a rexx error value is returned. + 0 when success, otherwise a Rexx error value is returned. NOTES @@ -46,7 +47,7 @@ CheckRexxMsg(), GetRexxVar() INTERNALS - This function creates a rexx message that is sent to the AREXX + This function creates a Rexx message that is sent to the AREXX port with a RXSETVAR command. @@ -80,7 +81,7 @@ msg2->rm_Private1 = msg->rm_Private1; msg2->rm_Private2 = msg->rm_Private2; msg2->rm_Action = RXSETVAR | 2; - msg2->rm_Args[0] = (IPTR)CreateArgstring(varname, strlen(varname)); + msg2->rm_Args[0] = (IPTR)CreateArgstring(varname, STRLEN(varname)); msg2->rm_Args[1] = (IPTR)CreateArgstring(value, length); if (msg2->rm_Args[0]==0 || msg2->rm_Args[1]==0) goto cleanup; diff --git a/compiler/alib/strdup.c b/compiler/alib/strdup.c index 1486ddd0d9..00926630f9 100644 --- a/compiler/alib/strdup.c +++ b/compiler/alib/strdup.c @@ -1,5 +1,5 @@ /* - Copyright © 2002-2003, The AROS Development Team. All rights reserved. + Copyright © 2002-2016, The AROS Development Team. All rights reserved. $Id$ AllocVec-based string duplication. @@ -7,7 +7,6 @@ #include "alib_intern.h" #include -#include /***************************************************************************** @@ -51,7 +50,7 @@ if (str == NULL) return NULL; - len = strlen(str); + len = STRLEN(str); dup = AllocVec(len + 1, MEMF_PUBLIC); if (dup != NULL) CopyMem(str, dup, len + 1); -- 2.11.4.GIT