From: uz Date: Sat, 10 Oct 2009 20:51:52 +0000 (+0000) Subject: New function SB_SkipMultiple(). X-Git-Tag: V2.13.1~165 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e623c87d63b458079ea66c3ef41080f7cb52c2ad;p=cc65 New function SB_SkipMultiple(). git-svn-id: svn://svn.cc65.org/cc65/trunk@4358 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/common/strbuf.h b/src/common/strbuf.h index fc904a1d2..8e3fc8863 100644 --- a/src/common/strbuf.h +++ b/src/common/strbuf.h @@ -286,6 +286,18 @@ INLINE void SB_Skip (StrBuf* B) # 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) +/* 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) 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. */