1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- MakeString() did not clear the ns->ns_Ivalue field and did not NUL-terminate

the copied string either. Fixed.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15185 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2008-04-15 09:33:06 +00:00
parent ca20eeab97
commit f0503cd915

View File

@ -1,5 +1,5 @@
/*
* $Id: amiga_rexxvars.c,v 1.14 2008-04-14 15:16:03 obarthel Exp $
* $Id: amiga_rexxvars.c,v 1.15 2008-04-15 09:33:06 obarthel Exp $
*
* :ts=4
*
@ -53,6 +53,8 @@
/****************************************************************************/
/* This is used by the stub function prototypes. The ARexx header files
do not define it, though. */
struct Environment;
/****************************************************************************/
@ -62,60 +64,6 @@ struct Environment;
/****************************************************************************/
/* This side-steps issues with very old inline header files, predating the
OS 3.5 SDK, when the library is built for the 68k platform. */
#if defined(__GNUC__) && !defined(__amigaos4__)
#define __GetRexxVarFromMsg(name, buffer, message) ({ \
STRPTR _GetRexxVarFromMsg_name = (name); \
STRPTR _GetRexxVarFromMsg_buffer = (buffer); \
struct RexxMsg * _GetRexxVarFromMsg_message = (message); \
LONG _GetRexxVarFromMsg__re = \
({ \
register struct RxsLib * const __GetRexxVarFromMsg__bn __asm("a6") = (struct RxsLib *) (RexxSysBase);\
register LONG __GetRexxVarFromMsg__re __asm("d0"); \
register STRPTR __GetRexxVarFromMsg_name __asm("a0") = (_GetRexxVarFromMsg_name); \
register STRPTR __GetRexxVarFromMsg_buffer __asm("a1") = (_GetRexxVarFromMsg_buffer); \
register struct RexxMsg * __GetRexxVarFromMsg_message __asm("a2") = (_GetRexxVarFromMsg_message); \
__asm volatile ("jsr a6@(-492:W)" \
: "=r"(__GetRexxVarFromMsg__re) \
: "r"(__GetRexxVarFromMsg__bn), "r"(__GetRexxVarFromMsg_name), "r"(__GetRexxVarFromMsg_buffer), "r"(__GetRexxVarFromMsg_message) \
: "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
__GetRexxVarFromMsg__re; \
}); \
_GetRexxVarFromMsg__re; \
})
#undef GetRexxVarFromMsg
#define GetRexxVarFromMsg(name, buffer, message) __GetRexxVarFromMsg(name, buffer, message)
#define __SetRexxVarFromMsg(name, value, message) ({ \
STRPTR _SetRexxVarFromMsg_name = (name); \
STRPTR _SetRexxVarFromMsg_value = (value); \
struct RexxMsg * _SetRexxVarFromMsg_message = (message); \
LONG _SetRexxVarFromMsg__re = \
({ \
register struct RxsLib * const __SetRexxVarFromMsg__bn __asm("a6") = (struct RxsLib *) (RexxSysBase);\
register LONG __SetRexxVarFromMsg__re __asm("d0"); \
register STRPTR __SetRexxVarFromMsg_name __asm("a0") = (_SetRexxVarFromMsg_name); \
register STRPTR __SetRexxVarFromMsg_value __asm("a1") = (_SetRexxVarFromMsg_value); \
register struct RexxMsg * __SetRexxVarFromMsg_message __asm("a2") = (_SetRexxVarFromMsg_message); \
__asm volatile ("jsr a6@(-498:W)" \
: "=r"(__SetRexxVarFromMsg__re) \
: "r"(__SetRexxVarFromMsg__bn), "r"(__SetRexxVarFromMsg_name), "r"(__SetRexxVarFromMsg_value), "r"(__SetRexxVarFromMsg_message) \
: "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
__SetRexxVarFromMsg__re; \
}); \
_SetRexxVarFromMsg__re; \
})
#undef SetRexxVarFromMsg
#define SetRexxVarFromMsg(name, value, message) __SetRexxVarFromMsg(name, value, message)
#endif /* __GNUC__ && !__amigaos4__ */
/****************************************************************************/
static struct Library * RexxSysBase;
/****************************************************************************/
@ -212,7 +160,7 @@ CheckRexxMsg(struct RexxMsg *message)
/****************************************************************************/
#if 1
#if defined(__amigaos4__)
/****************************************************************************/
@ -272,17 +220,13 @@ SetRexxVar(struct RexxMsg *message,STRPTR variable_name,STRPTR value,ULONG lengt
/****************************************************************************/
#else
/****************************************************************************/
#if defined(__GNUC__) && !defined(__amigaos4__)
#elif defined(__GNUC__) && !defined(__amigaos4__)
/****************************************************************************/
/* A selection of lovingly hand-crafted 68k stub functions which call
into rexxsyslib.library LVOs that still used to be documented back
in 1987. */
into rexxsyslib.library LVOs that still used to be documented back
in 1987. */
/****************************************************************************/
@ -301,7 +245,6 @@ asm("
.text
.even
.globl _RexxSysBase
.globl __FreeSpace
__FreeSpace:
@ -326,7 +269,6 @@ asm("
.text
.even
.globl _RexxSysBase
.globl __GetSpace
__GetSpace:
@ -350,7 +292,6 @@ asm("
.text
.even
.globl _RexxSysBase
.globl __IsSymbol
__IsSymbol:
@ -375,7 +316,6 @@ asm("
.text
.even
.globl _RexxSysBase
.globl __CurrentEnv
__CurrentEnv:
@ -400,7 +340,6 @@ asm("
.text
.even
.globl _RexxSysBase
.globl __FetchValue
__FetchValue:
@ -430,7 +369,6 @@ asm("
.text
.even
.globl _RexxSysBase
.globl __EnterSymbol
__EnterSymbol:
@ -454,7 +392,6 @@ asm("
.text
.even
.globl _RexxSysBase
.globl __FreeSpace
__SetValue:
@ -478,7 +415,6 @@ asm("
.text
.even
.globl _RexxSysBase
.globl __FreeSpace
__StrcpyN:
@ -500,10 +436,6 @@ __StrcpyN:
/****************************************************************************/
#endif /* __GNUC__ && !__amigaos4__ */
/****************************************************************************/
/* Function prototypes for the 68k stubs. */
extern VOID _FreeSpace(struct Environment * env,APTR mem,LONG size);
extern APTR _GetSpace(struct Environment * env,LONG size);
@ -540,10 +472,14 @@ MakeString(struct Environment * environment,STRPTR value,LONG length)
goto out;
/* Fill in the NexxStr structure, copy the string and remember the hash value for it. */
ns->ns_Ivalue = 0;
ns->ns_Length = length;
ns->ns_Flags = NSF_STRING;
ns->ns_Hash = _StrcpyN((STRPTR)ns->ns_Buff,value,length); /* STRPTR a0,STRPTR a1,LONG d0 : ULONG d0 */
/* Copying the string did not NUL-terminate it. */
ns->ns_Buff[length] = '\0';
result = ns;
out:
@ -568,14 +504,14 @@ TypeString(STRPTR variable_name,struct Environment * environment,struct NexxStr
(*stem_ptr) = NULL;
/* The 'compound' part is the entire variable name, including all dots and
what's in between them. */
what's in between them. */
compound = MakeString(environment,variable_name,strlen(variable_name));
if(compound == NULL)
goto out;
/* Find the first dot in the variable name. Everything in front of it
constitutes the 'stem' part. If there is no dot in the name, then
the 'compound' and 'stem' parts are identical. */
constitutes the 'stem' part. If there is no dot in the name, then
the 'compound' and 'stem' parts are identical. */
dot = memchr(compound->ns_Buff,'.',compound->ns_Length);
if(dot != NULL)
stem_length = ((char *)dot - (char *)compound->ns_Buff) + 1;
@ -694,7 +630,7 @@ SetRexxVar(struct RexxMsg *context,STRPTR variable_name,STRPTR value,LONG length
goto out;
/* Locate or create the symbol node. NOTE: _EnterSymbol() will put the two 'struct NexxStr *' into
the symbol table. It is not nececessary to free them. */
the symbol table. It is not nececessary to free them. */
symbol_table_node = _EnterSymbol(environment,stem_string,compound_string); /* struct Environment a0, struct NexxStr *a1, struct NexxStr * d0 : struct Node * d0 */
if(symbol_table_node == NULL)
{
@ -722,4 +658,4 @@ out:
/****************************************************************************/
#endif
#endif /* __GNUC__ && !__amigaos4__ */