Removed the inline.h module and removed the use of macros instead of "static
inline".
This commit is contained in:
@@ -44,7 +44,6 @@
|
||||
/* common */
|
||||
#include "attrib.h"
|
||||
#include "check.h"
|
||||
#include "inline.h"
|
||||
|
||||
|
||||
|
||||
@@ -89,16 +88,12 @@ extern const StrBuf EmptyStrBuf;
|
||||
|
||||
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE StrBuf* SB_Init (StrBuf* B)
|
||||
static inline StrBuf* SB_Init (StrBuf* B)
|
||||
/* Initialize a string buffer */
|
||||
{
|
||||
*B = EmptyStrBuf;
|
||||
return B;
|
||||
}
|
||||
#else
|
||||
StrBuf* SB_Init (StrBuf* B);
|
||||
#endif
|
||||
|
||||
StrBuf* SB_InitFromString (StrBuf* B, const char* S);
|
||||
/* Initialize a string buffer from a literal string. Beware: The buffer won't
|
||||
@@ -121,200 +116,126 @@ void SB_Realloc (StrBuf* B, unsigned NewSize);
|
||||
** available.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE unsigned SB_GetLen (const StrBuf* B)
|
||||
static inline unsigned SB_GetLen (const StrBuf* B)
|
||||
/* Return the length of the buffer contents */
|
||||
{
|
||||
return B->Len;
|
||||
}
|
||||
#else
|
||||
# define SB_GetLen(B) (B)->Len
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE unsigned SB_GetIndex (const StrBuf* B)
|
||||
static inline unsigned SB_GetIndex (const StrBuf* B)
|
||||
/* Return the user index of the string buffer */
|
||||
{
|
||||
return B->Index;
|
||||
}
|
||||
#else
|
||||
# define SB_GetIndex(B) (B)->Index
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void SB_SetIndex (StrBuf* B, unsigned Index)
|
||||
static inline void SB_SetIndex (StrBuf* B, unsigned Index)
|
||||
/* Set the user index of the string buffer */
|
||||
{
|
||||
B->Index = Index;
|
||||
}
|
||||
#else
|
||||
# define SB_SetIndex(B, Idx) ((B)->Index = (Idx))
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE const char* SB_GetConstBuf (const StrBuf* B)
|
||||
static inline const char* SB_GetConstBuf (const StrBuf* B)
|
||||
/* Return a buffer pointer */
|
||||
{
|
||||
return B->Buf;
|
||||
}
|
||||
#else
|
||||
# define SB_GetConstBuf(B) (B)->Buf
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE char* SB_GetBuf (StrBuf* B)
|
||||
static inline char* SB_GetBuf (StrBuf* B)
|
||||
/* Return a buffer pointer */
|
||||
{
|
||||
return B->Buf;
|
||||
}
|
||||
#else
|
||||
# define SB_GetBuf(B) (B)->Buf
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE char* SB_GetCooked (StrBuf* B)
|
||||
static inline char* SB_GetCooked (StrBuf* B)
|
||||
/* Return a cooked pointer */
|
||||
{
|
||||
return B->Cooked;
|
||||
}
|
||||
#else
|
||||
# define SB_GetCooked(B) (B)->Cooked
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE char SB_At (const StrBuf* B, unsigned Index)
|
||||
static inline char SB_At (const StrBuf* B, unsigned Index)
|
||||
/* Get a character from the buffer */
|
||||
{
|
||||
PRECONDITION (Index < B->Len);
|
||||
return B->Buf[Index];
|
||||
}
|
||||
#else
|
||||
char SB_At (const StrBuf* B, unsigned Index);
|
||||
/* Get a character from the buffer */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE char SB_AtUnchecked (const StrBuf* B, unsigned Index)
|
||||
static inline char SB_AtUnchecked (const StrBuf* B, unsigned Index)
|
||||
/* Get a character from the buffer */
|
||||
{
|
||||
return B->Buf[Index];
|
||||
}
|
||||
#else
|
||||
# define SB_AtUnchecked(B, Index) ((B)->Buf[Index])
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE int SB_IsEmpty (const StrBuf* B)
|
||||
static inline int SB_IsEmpty (const StrBuf* B)
|
||||
/* Return true if the string buffer is empty */
|
||||
{
|
||||
return (B->Len == 0);
|
||||
}
|
||||
#else
|
||||
# define SB_IsEmpty(B) ((B)->Len == 0)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE int SB_NotEmpty (const StrBuf* B)
|
||||
static inline int SB_NotEmpty (const StrBuf* B)
|
||||
/* Return true if the string buffer is not empty */
|
||||
{
|
||||
return (B->Len > 0);
|
||||
}
|
||||
#else
|
||||
# define SB_NotEmpty(B) ((B)->Len > 0)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void SB_Clear (StrBuf* B)
|
||||
static inline void SB_Clear (StrBuf* B)
|
||||
/* Clear the string buffer (make it empty) */
|
||||
{
|
||||
B->Len = B->Index = 0;
|
||||
}
|
||||
#else
|
||||
# define SB_Clear(B) ((B)->Len = (B)->Index = 0)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void SB_Reset (StrBuf* B)
|
||||
static inline void SB_Reset (StrBuf* B)
|
||||
/* Reset the string buffer index to zero */
|
||||
{
|
||||
B->Index = 0;
|
||||
}
|
||||
#else
|
||||
# define SB_Reset(B) ((B)->Index = 0)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE char SB_Get (StrBuf* B)
|
||||
static inline char SB_Get (StrBuf* B)
|
||||
/* Return the next character from the string incrementing Index. Returns NUL
|
||||
** if the end of the string is reached.
|
||||
*/
|
||||
{
|
||||
return (B->Index < B->Len)? B->Buf[B->Index++] : '\0';
|
||||
}
|
||||
#else
|
||||
# define SB_Get(B) (((B)->Index < (B)->Len)? (B)->Buf[(B)->Index++] : '\0')
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE char SB_Peek (const StrBuf* B)
|
||||
static inline char SB_Peek (const StrBuf* B)
|
||||
/* Look at the next character from the string without incrementing Index.
|
||||
** Returns NUL if the end of the string is reached.
|
||||
*/
|
||||
{
|
||||
return (B->Index < B->Len)? B->Buf[B->Index] : '\0';
|
||||
}
|
||||
#else
|
||||
# define SB_Peek(B) (((B)->Index < (B)->Len)? (B)->Buf[(B)->Index] : '\0')
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE char SB_LookAt (const StrBuf* B, unsigned Index)
|
||||
static inline char SB_LookAt (const StrBuf* B, unsigned Index)
|
||||
/* Look at a specific character from the string. Returns NUL if the given
|
||||
** index is greater than the size of the string.
|
||||
*/
|
||||
{
|
||||
return (Index < B->Len)? B->Buf[Index] : '\0';
|
||||
}
|
||||
#else
|
||||
# define SB_LookAt(B,Index) (((Index) < (B)->Len)? (B)->Buf[(Index)] : '\0')
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE char SB_LookAtLast (const StrBuf* B)
|
||||
static inline char SB_LookAtLast (const StrBuf* B)
|
||||
/* Look at the last character from the string. Returns NUL if the string buffer
|
||||
** is empty.
|
||||
*/
|
||||
{
|
||||
return (B->Len > 0)? B->Buf[B->Len-1] : '\0';
|
||||
}
|
||||
#else
|
||||
# define SB_LookAtLast(B) (((B)->Len > 0)? (B)->Buf[(B)->Len-1] : '\0')
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void SB_Skip (StrBuf* B)
|
||||
static inline void SB_Skip (StrBuf* B)
|
||||
/* Skip the next character in the string buffer if this is possible. */
|
||||
{
|
||||
if (B->Index < B->Len) {
|
||||
++B->Index;
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define SB_Skip(B) do { if ((B)->Index < (B)->Len) ++(B)->Index; } while (0)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void SB_SkipMultiple (StrBuf* B, unsigned Count)
|
||||
static inline void SB_SkipMultiple (StrBuf* B, unsigned Count)
|
||||
/* Skip a number of characters in the string buffer if this is possible. */
|
||||
{
|
||||
if ((B->Index += Count) > B->Len) {
|
||||
B->Index = B->Len;
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define SB_SkipMultiple(B, Count) \
|
||||
do { if (((B)->Index += (Count)) > (B)->Len) (B)->Index = (B)->Len; } while (0)
|
||||
#endif
|
||||
|
||||
void SB_Drop (StrBuf* B, unsigned Count);
|
||||
/* Drop characters from the end of the string. */
|
||||
@@ -330,28 +251,18 @@ void SB_CopyBuf (StrBuf* Target, const char* Buf, unsigned Size);
|
||||
void SB_CopyBufCooked (StrBuf* Target, const char* Buf, const char *Cooked, unsigned Size);
|
||||
/* Copy Buf and Cooked to Target, discarding the old contents of Target */
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void SB_CopyStr (StrBuf* Target, const char* S)
|
||||
static inline void SB_CopyStr (StrBuf* Target, const char* S)
|
||||
/* Copy S to Target, discarding the old contents of Target */
|
||||
{
|
||||
SB_CopyBuf (Target, S, strlen (S));
|
||||
SB_CopyBuf (Target, S, (unsigned)strlen (S));
|
||||
}
|
||||
#else
|
||||
void SB_CopyStr (StrBuf* Target, const char* S);
|
||||
/* Copy S to Target, discarding the old contents of Target */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void SB_Copy (StrBuf* Target, const StrBuf* Source)
|
||||
static inline void SB_Copy (StrBuf* Target, const StrBuf* Source)
|
||||
/* Copy Source to Target, discarding the old contents of Target */
|
||||
{
|
||||
SB_CopyBufCooked (Target, Source->Buf, Source->Cooked, Source->Len);
|
||||
Target->Index = Source->Index;
|
||||
}
|
||||
#else
|
||||
void SB_Copy (StrBuf* Target, const StrBuf* Source);
|
||||
/* Copy Source to Target, discarding the old contents of Target */
|
||||
#endif
|
||||
|
||||
void SB_AppendChar (StrBuf* B, int C);
|
||||
/* Append a character to a string buffer */
|
||||
@@ -362,19 +273,13 @@ void SB_AppendCharCooked (StrBuf* B, int C, int Cooked);
|
||||
void SB_AppendBuf (StrBuf* B, const char* S, unsigned Size);
|
||||
/* Append a character buffer to the end of the string buffer */
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void SB_AppendStr (StrBuf* B, const char* S)
|
||||
static inline void SB_AppendStr (StrBuf* B, const char* S)
|
||||
/* Append a string to the end of the string buffer */
|
||||
{
|
||||
SB_AppendBuf (B, S, strlen (S));
|
||||
SB_AppendBuf (B, S, (unsigned)strlen (S));
|
||||
}
|
||||
#else
|
||||
void SB_AppendStr (StrBuf* B, const char* S);
|
||||
/* Append a string to the end of the string buffer */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void SB_Append (StrBuf* Target, const StrBuf* Source)
|
||||
static inline void SB_Append (StrBuf* Target, const StrBuf* Source)
|
||||
/* Append the contents of Source to Target */
|
||||
{
|
||||
unsigned NewLen = Target->Len + Source->Len;
|
||||
@@ -385,13 +290,8 @@ INLINE void SB_Append (StrBuf* Target, const StrBuf* Source)
|
||||
memcpy (Target->Cooked + Target->Len, Source->Cooked, Source->Len);
|
||||
Target->Len = NewLen;
|
||||
}
|
||||
#else
|
||||
void SB_Append (StrBuf* Target, const StrBuf* Source);
|
||||
/* Append the contents of Source to Target */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void SB_Cut (StrBuf* B, unsigned Len)
|
||||
static inline void SB_Cut (StrBuf* B, unsigned Len)
|
||||
/* Cut the contents of B at the given length. If the current length of the
|
||||
** buffer is smaller than Len, nothing will happen.
|
||||
*/
|
||||
@@ -400,12 +300,6 @@ INLINE void SB_Cut (StrBuf* B, unsigned Len)
|
||||
B->Len = Len;
|
||||
}
|
||||
}
|
||||
#else
|
||||
void SB_Cut (StrBuf* B, unsigned Len);
|
||||
/* Cut the contents of B at the given length. If the current length of the
|
||||
** buffer is smaller than Len, nothing will happen.
|
||||
*/
|
||||
#endif
|
||||
|
||||
void SB_Slice (StrBuf* Target, const StrBuf* Source, unsigned Start, unsigned Len);
|
||||
/* Copy a slice from Source into Target. The current contents of Target are
|
||||
|
||||
Reference in New Issue
Block a user