version 1.19, 2003/06/03 02:56:11 |
version 1.20, 2004/04/07 13:11:35 |
|
|
|
|
/*- |
/*- |
* buf.c -- |
* buf.c -- |
* Functions for automatically-expanded buffers. |
* Functions for automatically expanded buffers. |
*/ |
*/ |
|
|
#include <ctype.h> |
#include <ctype.h> |
|
|
/* the hard case for Buf_AddChar: buffer must be expanded to accommodate |
/* the hard case for Buf_AddChar: buffer must be expanded to accommodate |
* one more char. */ |
* one more char. */ |
void |
void |
BufOverflow(bp) |
BufOverflow(Buffer bp) |
Buffer bp; |
|
{ |
{ |
BufExpand(bp, 1); |
BufExpand(bp, 1); |
} |
} |
|
|
|
|
void |
void |
Buf_AddChars(bp, numBytes, bytesPtr) |
Buf_AddChars(Buffer bp, size_t numBytes, const char *bytesPtr) |
Buffer bp; |
|
size_t numBytes; |
|
const char *bytesPtr; |
|
{ |
{ |
|
|
if ((size_t)(bp->endPtr - bp->inPtr) < numBytes+1) |
if ((size_t)(bp->endPtr - bp->inPtr) < numBytes+1) |
|
|
|
|
|
|
void |
void |
Buf_Init(bp, size) |
Buf_Init(Buffer bp, size_t size) |
Buffer bp; |
|
size_t size; |
|
{ |
{ |
#ifdef STATS_BUF |
#ifdef STATS_BUF |
STAT_TOTAL_BUFS++; |
STAT_TOTAL_BUFS++; |
|
|
} |
} |
|
|
void |
void |
Buf_KillTrailingSpaces(bp) |
Buf_KillTrailingSpaces(Buffer bp) |
Buffer bp; |
|
{ |
{ |
while (bp->inPtr > bp->buffer + 1 && isspace(bp->inPtr[-1])) { |
while (bp->inPtr > bp->buffer + 1 && isspace(bp->inPtr[-1])) { |
if (bp->inPtr[-2] == '\\') |
if (bp->inPtr[-2] == '\\') |