Get rid of size_t usage

This commit is contained in:
James Clark 1998-02-04 07:20:46 +00:00
parent 870e3a8d7e
commit 41400fe1ed
3 changed files with 20 additions and 32 deletions

View File

@ -15,7 +15,7 @@
typedef struct tag {
struct tag *parent;
const char *rawName;
size_t rawNameLength;
int rawNameLength;
const char *name;
char *buf;
char *bufEnd;
@ -24,7 +24,7 @@ typedef struct tag {
typedef struct {
const char *name;
const char *textPtr;
size_t textLen;
int textLen;
const char *systemId;
const char *publicId;
const char *notation;
@ -85,19 +85,9 @@ static Processor prologProcessor;
static Processor contentProcessor;
static Processor epilogProcessor;
static
int doContent(XML_Parser parser,
int startTagLevel,
const ENCODING *enc,
const char *start,
const char *end,
const char **endPtr);
static enum XML_Error
checkGeneralTextEntity(XML_Parser parser,
const char *s, const char *end,
const char **nextPtr,
const ENCODING **enc);
doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
const char *start, const char *end, const char **endPtr);
static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *, const char *tagName, const char *s);
static int
defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, int isCdata, const char *dfltValue);
@ -174,7 +164,7 @@ typedef struct {
STRING_POOL tempPool;
STRING_POOL temp2Pool;
char *groupConnector;
size_t groupSize;
unsigned groupSize;
} Parser;
#define userData (((Parser *)parser)->userData)
@ -305,7 +295,7 @@ void XML_SetProcessingInstructionHandler(XML_Parser parser,
processingInstructionHandler = handler;
}
int XML_Parse(XML_Parser parser, const char *s, size_t len, int isFinal)
int XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
{
bufferEndByteIndex += len;
if (len == 0) {
@ -359,7 +349,7 @@ int XML_Parse(XML_Parser parser, const char *s, size_t len, int isFinal)
}
}
int XML_ParseBuffer(XML_Parser parser, size_t len, int isFinal)
int XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
{
const char *start = bufferPtr;
bufferEnd += len;
@ -379,7 +369,7 @@ int XML_ParseBuffer(XML_Parser parser, size_t len, int isFinal)
}
}
void *XML_GetBuffer(XML_Parser parser, size_t len)
void *XML_GetBuffer(XML_Parser parser, int len)
{
if (len > bufferLim - bufferEnd) {
/* FIXME avoid integer overflow */
@ -391,7 +381,7 @@ void *XML_GetBuffer(XML_Parser parser, size_t len)
}
else {
char *newBuf;
size_t bufferSize = bufferLim - bufferPtr;
int bufferSize = bufferLim - bufferPtr;
if (bufferSize == 0)
bufferSize = INIT_BUFFER_SIZE;
do {
@ -464,7 +454,7 @@ const char *XML_ErrorString(int code)
}
static
enum XML_ERROR contentProcessor(XML_Parser parser,
enum XML_Error contentProcessor(XML_Parser parser,
const char *start,
const char *end,
const char **endPtr)
@ -480,7 +470,6 @@ doContent(XML_Parser parser,
const char *end,
const char **nextPtr)
{
static const char *nullPtr = 0;
const ENCODING *utf8 = XmlGetInternalEncoding(XML_UTF8_ENCODING);
for (;;) {
const char *next;
@ -596,7 +585,7 @@ doContent(XML_Parser parser,
tag->rawNameLength = XmlNameLength(enc, tag->rawName);
if (nextPtr) {
if (tag->rawNameLength > tag->bufEnd - tag->buf) {
size_t bufSize = tag->rawNameLength * 4;
int bufSize = tag->rawNameLength * 4;
tag->buf = realloc(tag->buf, bufSize);
if (!tag->buf)
return XML_ERROR_NO_MEMORY;
@ -674,7 +663,7 @@ doContent(XML_Parser parser,
return XML_ERROR_ASYNC_ENTITY;
}
else {
size_t len;
int len;
const char *rawName;
TAG *tag = tagStack;
tagStack = tag->parent;
@ -1554,7 +1543,7 @@ int poolGrow(STRING_POOL *pool)
}
}
if (pool->blocks && pool->start == pool->blocks->s) {
size_t blockSize = (pool->end - pool->start)*2;
int blockSize = (pool->end - pool->start)*2;
pool->blocks = realloc(pool->blocks, offsetof(BLOCK, s) + blockSize);
if (!pool->blocks)
return 0;
@ -1565,7 +1554,7 @@ int poolGrow(STRING_POOL *pool)
}
else {
BLOCK *tem;
size_t blockSize = pool->end - pool->start;
int blockSize = pool->end - pool->start;
if (blockSize < INIT_BLOCK_SIZE)
blockSize = INIT_BLOCK_SIZE;
else

View File

@ -1,8 +1,6 @@
#ifndef XmlParse_INCLUDED
#define XmlParse_INCLUDED 1
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -33,7 +31,7 @@ typedef void (*XML_EndElementHandler)(void *userData,
typedef void (*XML_CharacterDataHandler)(void *userData,
const char *s,
size_t len);
int len);
/* target and data are '\0' terminated */
typedef void (*XML_ProcessingInstructionHandler)(void *userData,
@ -61,13 +59,13 @@ XML_SetUserData(XML_Parser parser, void *userData);
The last call to XML_Parse must have isFinal true;
len may be zero for this call (or any other). */
int XMLPARSEAPI
XML_Parse(XML_Parser parser, const char *s, size_t len, int isFinal);
XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
void XMLPARSEAPI *
XML_GetBuffer(XML_Parser parser, size_t len);
XML_GetBuffer(XML_Parser parser, int len);
int XMLPARSEAPI
XML_ParseBuffer(XML_Parser parser, size_t len, int isFinal);
XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
/* If XML_Parser or XML_ParseEnd have returned 0, then XML_GetError*
returns information about the error. */

View File

@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <fcntl.h>
@ -28,7 +29,7 @@
#define READ_SIZE (1024*8)
#endif
static void characterData(void *userData, const char *s, size_t len)
static void characterData(void *userData, const char *s, int len)
{
FILE *fp = userData;
for (; len > 0; --len, ++s) {