mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 06:03:02 +01:00
Fix the most obvioius problems:
- style (few fixes only) - constness - total lack of encapsulation (all data members exposed in the interface).
This commit is contained in:
parent
67e68fd8ed
commit
60802a9d77
@ -54,16 +54,16 @@ AdminException::AdminException(const char *txt, ...)
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
int l = sizeof (temp) * 2;
|
||||
char *buffer = new char [l];
|
||||
const int l = sizeof (temp) * 2;
|
||||
char* const buffer = new char [l];
|
||||
vsnprintf (buffer, l, txt, args);
|
||||
text = buffer;
|
||||
delete [] buffer;
|
||||
}
|
||||
else if (static_cast<unsigned>(ret) >= sizeof (temp))
|
||||
{
|
||||
int l = ret + 1;
|
||||
char *buffer = new char [l];
|
||||
const int l = ret + 1;
|
||||
char* const buffer = new char [l];
|
||||
vsnprintf (buffer, l, txt, args);
|
||||
text = buffer;
|
||||
delete [] buffer;
|
||||
@ -79,7 +79,7 @@ AdminException::~AdminException()
|
||||
|
||||
}
|
||||
|
||||
const char* AdminException::getText()
|
||||
const char* AdminException::getText() const
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
@ -41,10 +41,11 @@ class AdminException
|
||||
{
|
||||
public:
|
||||
void setLocation (JString fileName, int lineNumber);
|
||||
const char* getText();
|
||||
const char* getText() const;
|
||||
AdminException(const char *txt, ...);
|
||||
virtual ~AdminException();
|
||||
|
||||
private:
|
||||
JString text;
|
||||
JString fileName;
|
||||
};
|
||||
|
@ -59,7 +59,7 @@ void Args::parse(const Switches *switches, int argc, char **argv)
|
||||
{
|
||||
for (char **arg = argv, **end = arg + argc; arg < end;)
|
||||
{
|
||||
char *p = *arg++;
|
||||
const char *p = *arg++;
|
||||
const Switches *parameter = NULL;
|
||||
bool hit = false;
|
||||
for (const Switches *sw = switches; sw->string; ++sw)
|
||||
@ -114,6 +114,7 @@ void Args::printHelp(const char *helpText, const Switches *switches)
|
||||
const Switches *sw;
|
||||
|
||||
for (sw = switches; sw->string; ++sw)
|
||||
{
|
||||
if (sw->description)
|
||||
{
|
||||
int l = (int) strlen (sw->string);
|
||||
@ -126,6 +127,7 @@ void Args::printHelp(const char *helpText, const Switches *switches)
|
||||
argLength = l;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (helpText)
|
||||
printf (helpText);
|
||||
@ -133,11 +135,13 @@ void Args::printHelp(const char *helpText, const Switches *switches)
|
||||
printf ("Options are:\n");
|
||||
|
||||
for (sw = switches; sw->string; ++sw)
|
||||
{
|
||||
if (sw->description)
|
||||
{
|
||||
const char *arg = (sw->argName) ? sw->argName : "";
|
||||
printf (" %-*s %-*s %s\n", switchLength, sw->string, argLength, arg, sw->description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Args::readPasswords(const char *msg, char *pw1, int length)
|
||||
|
@ -39,7 +39,7 @@ struct Switches
|
||||
{
|
||||
const char *string;
|
||||
bool *boolean;
|
||||
char **argument;
|
||||
const char* *argument;
|
||||
const char *argName;
|
||||
const char *description;
|
||||
};
|
||||
|
@ -60,7 +60,7 @@ ArgsException::~ArgsException()
|
||||
|
||||
}
|
||||
|
||||
const char* ArgsException::getText()
|
||||
const char* ArgsException::getText() const
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
@ -39,10 +39,11 @@
|
||||
class ArgsException
|
||||
{
|
||||
public:
|
||||
const char* getText();
|
||||
const char* getText() const;
|
||||
ArgsException(const char * txt, ...);
|
||||
virtual ~ArgsException();
|
||||
|
||||
private:
|
||||
JString text;
|
||||
};
|
||||
|
||||
|
@ -40,21 +40,18 @@ ConfObj::ConfObj(ConfObject *confObject)
|
||||
object->addRef();
|
||||
}
|
||||
|
||||
ConfObj::ConfObj(ConfObj& source)
|
||||
{
|
||||
if (object = source.object)
|
||||
object->addRef();
|
||||
}
|
||||
|
||||
ConfObj::~ConfObj()
|
||||
{
|
||||
if (object)
|
||||
object->release();
|
||||
}
|
||||
|
||||
ConfObj::ConfObj(const ConfObj& source)
|
||||
{
|
||||
if (object)
|
||||
object->release();
|
||||
|
||||
if (object = source.object)
|
||||
object->addRef();
|
||||
}
|
||||
|
||||
bool ConfObj::hasObject() const
|
||||
{
|
||||
return object != NULL;
|
||||
|
@ -34,7 +34,9 @@ class ConfObject;
|
||||
class ConfObj
|
||||
{
|
||||
public:
|
||||
ConfObj();
|
||||
explicit ConfObj(ConfObject *confObject);
|
||||
ConfObj(ConfObj& source);
|
||||
~ConfObj();
|
||||
|
||||
operator ConfObject*() { return object; }
|
||||
@ -42,10 +44,10 @@ public:
|
||||
const ConfObject* operator -> () const { return object; }
|
||||
ConfObject* operator = (ConfObject *source);
|
||||
|
||||
ConfObject *object;
|
||||
ConfObj(const ConfObj& source);
|
||||
ConfObj();
|
||||
bool hasObject() const;
|
||||
|
||||
private:
|
||||
ConfObject *object;
|
||||
};
|
||||
|
||||
END_NAMESPACE
|
||||
|
@ -74,7 +74,7 @@ ConfObject::~ConfObject()
|
||||
chain->release();
|
||||
}
|
||||
|
||||
bool ConfObject::matches(Element *element, const char* type, const char* string)
|
||||
bool ConfObject::matches(Element* element, const char* type, const char* string)
|
||||
{
|
||||
if (element->name != type)
|
||||
return false;
|
||||
@ -123,25 +123,30 @@ bool ConfObject::match(int position, const char* pattern, const char* string)
|
||||
const char *s = string;
|
||||
|
||||
for (const char *p = pattern; (c = *p++); ++s)
|
||||
{
|
||||
if (c == '*')
|
||||
{
|
||||
{
|
||||
if (!*p)
|
||||
{
|
||||
{
|
||||
putString (position, string, (int) strlen (string));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (; *s; ++s)
|
||||
{
|
||||
if (match (position + 1, pattern + 1, s))
|
||||
{
|
||||
{
|
||||
putString (position, string, (int) (s - string));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!*s)
|
||||
return false;
|
||||
else if (c != '%' && c != *s)
|
||||
{
|
||||
}
|
||||
|
||||
if (!*s)
|
||||
return false;
|
||||
|
||||
if (c != '%' && c != *s)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (UPPER (c) == UPPER (*s))
|
||||
continue;
|
||||
@ -149,7 +154,8 @@ bool ConfObject::match(int position, const char* pattern, const char* string)
|
||||
continue;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (c || *s)
|
||||
return false;
|
||||
|
@ -41,12 +41,14 @@ class ConfigFile;
|
||||
class ConfObject : public RefObject
|
||||
{
|
||||
public:
|
||||
ConfObject(ConfigFile *confFile);
|
||||
explicit ConfObject(ConfigFile *confFile);
|
||||
virtual ~ConfObject();
|
||||
|
||||
virtual const char* getValue(const char* option, const char *defaultValue);
|
||||
virtual int getValue(const char* option, int defaultValue);
|
||||
virtual bool getValue(const char* option, bool defaultValue);
|
||||
virtual const char* getValue(int instanceNumber, const char* attributeName);
|
||||
virtual bool matches(Element *element, const char* type, const char* string);
|
||||
virtual bool matches(Element* element, const char* type, const char* string);
|
||||
virtual void setChain(ConfObject* object);
|
||||
virtual const char* getName();
|
||||
virtual const char* getConcatenatedValues(const char* attributeName);
|
||||
@ -61,8 +63,6 @@ protected:
|
||||
virtual Element* findAttribute(const char* attributeName);
|
||||
virtual const char* getValue(const Element* attribute);
|
||||
|
||||
virtual ~ConfObject();
|
||||
|
||||
public:
|
||||
Element *object;
|
||||
|
||||
|
@ -96,20 +96,22 @@ void ConfigFile::init(int configFlags)
|
||||
memset (hashTable, 0, sizeof (hashTable));
|
||||
}
|
||||
|
||||
ConfigFile::~ConfigFile(void)
|
||||
ConfigFile::~ConfigFile()
|
||||
{
|
||||
if (objects)
|
||||
delete objects;
|
||||
|
||||
for (int n = 0; n < HASH_SIZE; ++n)
|
||||
{
|
||||
for (Element *element; element = hashTable [n];)
|
||||
{
|
||||
{
|
||||
hashTable [n] = element->sibling;
|
||||
delete element;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InputFile* ConfigFile::openConfigFile(void)
|
||||
InputFile* ConfigFile::openConfigFile()
|
||||
{
|
||||
fb_assert(false);
|
||||
// Vulcan specific code removed
|
||||
@ -137,7 +139,7 @@ void ConfigFile::parse(void)
|
||||
else
|
||||
{
|
||||
Element *element = parseAttribute();
|
||||
int slot = element->name.hash (HASH_SIZE);
|
||||
const int slot = element->name.hash (HASH_SIZE);
|
||||
element->sibling = hashTable [slot];
|
||||
hashTable [slot] = element;
|
||||
}
|
||||
@ -202,8 +204,10 @@ ConfObject* ConfigFile::findObject(const char* objectType, const char* objectNam
|
||||
ConfObject *object = new ConfObject (this);
|
||||
|
||||
for (Element *child = objects->children; child; child = child->sibling)
|
||||
{
|
||||
if (object->matches (child, objectType, objectName))
|
||||
return object;
|
||||
}
|
||||
|
||||
object->release();
|
||||
|
||||
|
@ -45,6 +45,7 @@ class ConfigFile : public Lex, public RefObject
|
||||
{
|
||||
public:
|
||||
explicit ConfigFile(int configFlags);
|
||||
ConfigFile(const char* configFile, int configFlags);
|
||||
|
||||
//protected:
|
||||
virtual ~ConfigFile();
|
||||
@ -64,12 +65,11 @@ public:
|
||||
|
||||
const char* translate(const char *value, Element *object);
|
||||
void init(int configFlags);
|
||||
ConfigFile(const char* configFile, int configFlags);
|
||||
void wildCardInclude(const char* fileName);
|
||||
|
||||
Element* objects;
|
||||
const Element* getObjects() const { return objects; }
|
||||
|
||||
private:
|
||||
Element* objects;
|
||||
JString rootDirectory;
|
||||
JString installDirectory;
|
||||
JString currentDirectory;
|
||||
|
@ -31,12 +31,12 @@
|
||||
|
||||
static ConfigFile *configFile;
|
||||
|
||||
Configuration::Configuration(void)
|
||||
Configuration::Configuration()
|
||||
{
|
||||
configFile = NULL;
|
||||
}
|
||||
|
||||
Configuration::~Configuration(void)
|
||||
Configuration::~Configuration()
|
||||
{
|
||||
if (configFile)
|
||||
configFile->release();
|
||||
@ -50,7 +50,7 @@ ConfObject* Configuration::findObject(const char* objectType, const char* object
|
||||
return configFile->findObject (objectType, objectName);
|
||||
}
|
||||
|
||||
const char* Configuration::getRootDirectory(void)
|
||||
const char* Configuration::getRootDirectory()
|
||||
{
|
||||
if (!configFile)
|
||||
loadConfigFile();
|
||||
@ -58,7 +58,7 @@ const char* Configuration::getRootDirectory(void)
|
||||
return configFile->getRootDirectory();
|
||||
}
|
||||
|
||||
void Configuration::loadConfigFile(void)
|
||||
void Configuration::loadConfigFile()
|
||||
{
|
||||
if (!configFile)
|
||||
configFile = new ConfigFile (0);
|
||||
|
@ -35,12 +35,12 @@ class ConfObject;
|
||||
class Configuration
|
||||
{
|
||||
public:
|
||||
Configuration(void);
|
||||
virtual ~Configuration(void);
|
||||
Configuration();
|
||||
virtual ~Configuration();
|
||||
|
||||
static ConfObject* findObject(const char* objectType, const char* objectName);
|
||||
static const char* getRootDirectory(void);
|
||||
static void loadConfigFile(void);
|
||||
static const char* getRootDirectory();
|
||||
static void loadConfigFile();
|
||||
static void setConfigFilePath(const char* filename);
|
||||
static ConfObject* getObject(const char* objectType);
|
||||
static ConfObject* getObject(const char* objectType, const char* objectName);
|
||||
|
@ -17,10 +17,12 @@ FileName::FileName(JString name)
|
||||
absolute = IS_SLASH (start [0]);
|
||||
|
||||
for (const char *p = start; *p; ++p)
|
||||
{
|
||||
if (!dot && IS_SLASH (*p))
|
||||
slash = p;
|
||||
else if (*p == '.')
|
||||
dot = p;
|
||||
}
|
||||
|
||||
|
||||
if (slash)
|
||||
@ -38,6 +40,6 @@ FileName::FileName(JString name)
|
||||
root = rootName;
|
||||
}
|
||||
|
||||
FileName::~FileName(void)
|
||||
FileName::~FileName()
|
||||
{
|
||||
}
|
||||
|
@ -7,13 +7,16 @@ class FileName
|
||||
{
|
||||
public:
|
||||
FileName(JString name);
|
||||
~FileName(void);
|
||||
~FileName();
|
||||
|
||||
JString pathName;
|
||||
JString directory;
|
||||
JString root;
|
||||
JString extension;
|
||||
bool isAbsolute() const { return absolute; }
|
||||
private:
|
||||
bool absolute;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -64,7 +64,7 @@ InputFile::InputFile(const char *name)
|
||||
throw AdminException ("can't open file \"%s\"", name);
|
||||
}
|
||||
|
||||
InputFile::InputFile(void)
|
||||
InputFile::InputFile()
|
||||
{
|
||||
changes = NULL;
|
||||
}
|
||||
@ -137,10 +137,10 @@ void InputFile::rewrite()
|
||||
FILE *input = fopen (fileName, "r");
|
||||
|
||||
if (!input)
|
||||
throw AdminException ("can't open \"%s\" for input", (const char*) fileName);
|
||||
throw AdminException ("can't open \"%s\" for input", fileName.getString());
|
||||
|
||||
char tempName [MAX_FILE_NAME];
|
||||
sprintf (tempName, "%s.tmp", (const char*) fileName);
|
||||
sprintf (tempName, "%.*s.tmp", sizeof(tempName) - 5, fileName.getString());
|
||||
FILE *output = fopen (tempName,"w");
|
||||
|
||||
if (!output)
|
||||
@ -152,8 +152,10 @@ void InputFile::rewrite()
|
||||
for (FileChange *change = changes; change; change = change->next)
|
||||
{
|
||||
for (; line < change->lineNumber; ++line)
|
||||
{
|
||||
if (fgets (temp, sizeof (temp), input))
|
||||
fputs (temp, output);
|
||||
}
|
||||
//fputs ("#insertion starts here\n", output);
|
||||
fputs (change->insertion, output);
|
||||
//fputs ("#insertion end here\n", output);
|
||||
@ -170,11 +172,13 @@ void InputFile::rewrite()
|
||||
char filename1 [MAX_FILE_NAME];
|
||||
char filename2 [MAX_FILE_NAME];
|
||||
|
||||
fb_assert(BACKUP_FILES < 10); // assumption to avoid B.O.
|
||||
|
||||
for (int n = BACKUP_FILES; n >= 0; --n)
|
||||
{
|
||||
sprintf (filename1, "%s.%d", (const char*) fileName, n);
|
||||
sprintf (filename1, "%.*s.%d", sizeof(filename1) - 3, (const char*) fileName, n);
|
||||
if (n)
|
||||
sprintf (filename2, "%s.%d", (const char*) fileName, n - 1);
|
||||
sprintf (filename2, "%.*s.%d", sizeof(filename2) - 3, (const char*) fileName, n - 1);
|
||||
else
|
||||
strcpy (filename2, fileName);
|
||||
if (n == BACKUP_FILES)
|
||||
@ -190,15 +194,19 @@ bool InputFile::pathEqual(const char *path1, const char *path2)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
for (; *path1 && *path2; ++path1, ++path2)
|
||||
{
|
||||
if (*path1 != *path2 &&
|
||||
UPPER (*path1) != UPPER (*path2) &&
|
||||
!((*path1 == '/' || *path1 == '\\') &&
|
||||
(*path2 == '/' || *path2 == '\\')))
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
for (; *path1 && *path2; ++path1, ++path2)
|
||||
{
|
||||
if (*path1 != *path2)
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return *path1 == 0 && *path2 == 0;
|
||||
|
@ -42,16 +42,13 @@
|
||||
|
||||
START_NAMESPACE
|
||||
|
||||
struct FileChange {
|
||||
FileChange *next;
|
||||
int lineNumber;
|
||||
int linesSkipped;
|
||||
JString insertion;
|
||||
};
|
||||
|
||||
class InputFile : public InputStream
|
||||
{
|
||||
public:
|
||||
explicit InputFile(const char* fileName);
|
||||
InputFile();
|
||||
virtual ~InputFile();
|
||||
|
||||
static bool pathEqual(const char *path1, const char *path2);
|
||||
void rewrite();
|
||||
void postChange (int lineNumber, int skip, JString insertion);
|
||||
@ -59,15 +56,21 @@ public:
|
||||
virtual const char* getFileName();
|
||||
virtual const char* getSegment();
|
||||
virtual void close();
|
||||
InputFile(const char *fileName);
|
||||
virtual ~InputFile();
|
||||
|
||||
JString fileName;
|
||||
bool openInputFile(const char* fileName);
|
||||
private:
|
||||
struct FileChange
|
||||
{
|
||||
FileChange *next;
|
||||
int lineNumber;
|
||||
int linesSkipped;
|
||||
JString insertion;
|
||||
};
|
||||
|
||||
void *file;
|
||||
char buffer [1024];
|
||||
FileChange *changes;
|
||||
InputFile(void);
|
||||
bool openInputFile(const char* fileName);
|
||||
JString fileName;
|
||||
FileChange* changes;
|
||||
};
|
||||
|
||||
END_NAMESPACE
|
||||
|
@ -42,25 +42,29 @@ class InputFile;
|
||||
class InputStream
|
||||
{
|
||||
public:
|
||||
explicit InputStream (const char* stuff);
|
||||
InputStream();
|
||||
virtual ~InputStream();
|
||||
|
||||
virtual InputFile* getInputFile();
|
||||
virtual const char* getFileName();
|
||||
void init();
|
||||
void release();
|
||||
virtual void addRef();
|
||||
InputStream (const char *stuff);
|
||||
|
||||
virtual void close();
|
||||
virtual const char* getEnd();
|
||||
virtual int getOffset (const char *ptr);
|
||||
virtual const char* getSegment();
|
||||
InputStream();
|
||||
virtual ~InputStream();
|
||||
|
||||
int segmentLength;
|
||||
int segmentOffset;
|
||||
int lineNumber;
|
||||
const char *segment;
|
||||
const char *ptr;
|
||||
InputStream *prior;
|
||||
protected:
|
||||
int segmentLength; // used by InputFile
|
||||
private:
|
||||
int segmentOffset;
|
||||
int useCount;
|
||||
};
|
||||
|
||||
|
@ -79,11 +79,14 @@ Lex::~Lex()
|
||||
void Lex::skipWhite()
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
{
|
||||
while (ptr >= end)
|
||||
{
|
||||
if (!getSegment())
|
||||
return;
|
||||
}
|
||||
while (ptr < end)
|
||||
{
|
||||
if (lineComment && lineComment [0] == *ptr && match (lineComment, ptr))
|
||||
{
|
||||
while (ptr < end && *ptr++ != '\n')
|
||||
@ -118,7 +121,7 @@ void Lex::skipWhite()
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Just another custom memcmp-like routine.
|
||||
|
@ -68,6 +68,9 @@ class Stream;
|
||||
class Lex
|
||||
{
|
||||
public:
|
||||
Lex(const char *punctuation, int debugFlags);
|
||||
virtual ~Lex();
|
||||
|
||||
void captureStuff();
|
||||
char& charTable(int ch);
|
||||
bool getSegment();
|
||||
@ -84,16 +87,13 @@ public:
|
||||
void getToken();
|
||||
static bool match (const char *pattern, const char *string);
|
||||
void skipWhite();
|
||||
Lex(const char *punctuation, int debugFlags);
|
||||
virtual ~Lex();
|
||||
|
||||
protected:
|
||||
int flags;
|
||||
int tokenType;
|
||||
int priorLineNumber;
|
||||
bool eol;
|
||||
InputStream *inputStream;
|
||||
InputStream *priorInputStream;
|
||||
|
||||
private:
|
||||
InputStream *tokenInputStream;
|
||||
Stream stuff;
|
||||
|
@ -127,8 +127,10 @@ bool ScanDir::match(const char *pattern, const char *name)
|
||||
if (!pattern [1])
|
||||
return true;
|
||||
for (const char *p = name; *p; ++p)
|
||||
{
|
||||
if (match (pattern + 1, p))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -50,19 +50,21 @@
|
||||
class ScanDir
|
||||
{
|
||||
public:
|
||||
ScanDir(const char *dir, const char *pattern);
|
||||
virtual ~ScanDir();
|
||||
|
||||
bool isDots();
|
||||
const char* getFilePath();
|
||||
bool isDirectory();
|
||||
static bool match (const char *pattern, const char *name);
|
||||
const char* getFileName();
|
||||
bool next();
|
||||
ScanDir(const char *dir, const char *pattern);
|
||||
virtual ~ScanDir();
|
||||
|
||||
JString directory;
|
||||
JString pattern;
|
||||
JString fileName;
|
||||
JString filePath;
|
||||
private:
|
||||
#ifdef _WIN32
|
||||
WIN32_FIND_DATA data;
|
||||
HANDLE handle;
|
||||
|
@ -37,6 +37,10 @@
|
||||
#include "Stream.h"
|
||||
#include "StreamSegment.h"
|
||||
|
||||
|
||||
// CVC: The logic in this module seems to overwrite constant params passed into the
|
||||
// address field of the Segment structure. This includes literal strings (see Element.cpp).
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((a > b) ? a : b)
|
||||
#define MIN(a,b) ((a < b) ? a : b)
|
||||
@ -112,7 +116,7 @@ void Stream::putSegment(int length, const char *ptr, bool copy)
|
||||
int l = currentLength - current->length;
|
||||
if (l > 0)
|
||||
{
|
||||
int l2 = MIN (l, length);
|
||||
const int l2 = MIN (l, length);
|
||||
memcpy (current->address + current->length, address, l2);
|
||||
current->length += l2;
|
||||
length -= l2;
|
||||
@ -505,7 +509,7 @@ void Stream::putSegment(Stream * stream)
|
||||
if (stream->totalLength == 0)
|
||||
return;
|
||||
|
||||
StreamSegment seg = stream;
|
||||
StreamSegment seg(stream);
|
||||
|
||||
if (current)
|
||||
for (int len = currentLength - current->length; len && seg.available;)
|
||||
@ -545,7 +549,7 @@ char* Stream::alloc(int length)
|
||||
if (!current || length > currentLength - current->length)
|
||||
allocSegment (length);
|
||||
|
||||
char *p = current->tail + current->length;
|
||||
char* const p = current->tail + current->length;
|
||||
current->length += length;
|
||||
|
||||
return p;
|
||||
@ -592,8 +596,8 @@ int Stream::compare(const Stream *stream) const
|
||||
{
|
||||
for (int offset = 0;;)
|
||||
{
|
||||
int length1 = getSegmentLength(offset);
|
||||
int length2 = stream->getSegmentLength(offset);
|
||||
const int length1 = getSegmentLength(offset);
|
||||
const int length2 = stream->getSegmentLength(offset);
|
||||
if (length1 == 0)
|
||||
{
|
||||
if (length2)
|
||||
|
@ -53,6 +53,9 @@ struct Segment
|
||||
class Stream
|
||||
{
|
||||
public:
|
||||
explicit Stream (int minSegmentSize = FIXED_SEGMENT_SIZE);
|
||||
virtual ~Stream();
|
||||
|
||||
int compare (const Stream *stream) const;
|
||||
void truncate (int length);
|
||||
void format (const char *pattern, ...);
|
||||
@ -78,18 +81,15 @@ public:
|
||||
Segment* allocSegment (int tail);
|
||||
void setMinSegment (int length);
|
||||
|
||||
|
||||
explicit Stream (int minSegmentSize = FIXED_SEGMENT_SIZE);
|
||||
virtual ~Stream();
|
||||
|
||||
int totalLength;
|
||||
//int useCount;
|
||||
Segment *segments; // used by StreamSegment::setStream
|
||||
private:
|
||||
int minSegment;
|
||||
int currentLength;
|
||||
int decompressedLength;
|
||||
int useCount;
|
||||
bool copyFlag;
|
||||
Segment first;
|
||||
Segment *segments;
|
||||
Segment *current;
|
||||
};
|
||||
|
||||
|
@ -77,7 +77,7 @@ void StreamSegment::advance(int size)
|
||||
{
|
||||
for (int len = size; len;)
|
||||
{
|
||||
int l = MIN (available, len);
|
||||
const int l = MIN (available, len);
|
||||
available -= l;
|
||||
remaining -= l;
|
||||
len -= size;
|
||||
@ -100,7 +100,7 @@ char* StreamSegment::copy(void *target, int length)
|
||||
|
||||
for (int len = length; len;)
|
||||
{
|
||||
int l = MIN (len, available);
|
||||
const int l = MIN (len, available);
|
||||
memcpy (targ, data, l);
|
||||
targ += l;
|
||||
len -= l;
|
||||
|
@ -44,13 +44,16 @@ struct Segment;
|
||||
class StreamSegment
|
||||
{
|
||||
public:
|
||||
explicit StreamSegment(Stream *stream);
|
||||
virtual ~StreamSegment();
|
||||
|
||||
char* copy (void *target, int length);
|
||||
void advance (int size);
|
||||
void advance();
|
||||
void setStream (Stream *stream);
|
||||
StreamSegment(Stream *stream);
|
||||
virtual ~StreamSegment();
|
||||
|
||||
private:
|
||||
friend class Stream; // for "available" and "remaining"
|
||||
int available;
|
||||
int remaining;
|
||||
char *data;
|
||||
|
@ -417,7 +417,7 @@ bool IntlManager::initialize()
|
||||
if (s.hasData())
|
||||
builtinConfig = s;
|
||||
|
||||
for (const Element* el = configFile.objects->children; el; el = el->sibling)
|
||||
for (const Element* el = configFile.getObjects()->children; el; el = el->sibling)
|
||||
{
|
||||
if (el->name == "charset")
|
||||
{
|
||||
|
@ -45,7 +45,7 @@
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
JString::JString ()
|
||||
{
|
||||
/**************************************
|
||||
@ -61,7 +61,7 @@ JString::JString ()
|
||||
|
||||
string = NULL;
|
||||
}
|
||||
|
||||
|
||||
JString::JString (const char *stuff)
|
||||
{
|
||||
/**************************************
|
||||
@ -79,6 +79,12 @@ JString::JString (const char *stuff)
|
||||
setString (stuff);
|
||||
}
|
||||
|
||||
JString::JString(const char * source, int len)
|
||||
{
|
||||
string = NULL;
|
||||
setString (source, len);
|
||||
}
|
||||
|
||||
JString::JString (const JString& source)
|
||||
{
|
||||
/**************************************
|
||||
@ -145,7 +151,7 @@ void JString::append (const char* stuff)
|
||||
if (--((int*) temp)[0] == 0)
|
||||
delete [] temp;
|
||||
}
|
||||
|
||||
|
||||
void JString::setString (const char* stuff)
|
||||
{
|
||||
/**************************************
|
||||
@ -457,7 +463,8 @@ JString& JString::operator =(const WCHAR * wString)
|
||||
|
||||
void JString::setString(const char * source, int len)
|
||||
{
|
||||
char *old = string;
|
||||
fb_assert(len >= 0);
|
||||
char* const old = string;
|
||||
allocSpace (len);
|
||||
memcpy (string, source, len);
|
||||
string[len] = 0;
|
||||
@ -483,7 +490,7 @@ int JString::findSubstring(const char * string, const char * sub)
|
||||
JString JString::upcase(const char * source)
|
||||
{
|
||||
JString string;
|
||||
int len = (int) strlen (source);
|
||||
const int len = (int) strlen (source);
|
||||
string.alloc (len);
|
||||
|
||||
for (int n = 0; n < len; ++n)
|
||||
@ -512,8 +519,10 @@ bool JString::equalsNoCase(const char * string2) const
|
||||
const char *p;
|
||||
|
||||
for (p = string; *p && *string2; ++p, ++string2)
|
||||
{
|
||||
if (UPPER (*p) != UPPER (*string2))
|
||||
return false;
|
||||
}
|
||||
|
||||
return *p == *string2;
|
||||
}
|
||||
@ -523,20 +532,13 @@ int JString::length() const
|
||||
if (!string)
|
||||
return 0;
|
||||
|
||||
const char *p;
|
||||
|
||||
for (p = string; *p; ++p)
|
||||
;
|
||||
const char* p = string;
|
||||
while (*p)
|
||||
++p;
|
||||
|
||||
return (int) (p - string);
|
||||
}
|
||||
|
||||
JString::JString(const char * source, int len)
|
||||
{
|
||||
string = NULL;
|
||||
setString (source, len);
|
||||
}
|
||||
|
||||
char* JString::getBuffer(int len)
|
||||
{
|
||||
alloc (len);
|
||||
|
@ -34,10 +34,10 @@ START_NAMESPACE
|
||||
class JString
|
||||
{
|
||||
public:
|
||||
JString (const char *source, int length);
|
||||
JString();
|
||||
JString (const char *string);
|
||||
JString(const JString& stringSrc);
|
||||
JString (const char *stuff);
|
||||
JString (const char *source, int length);
|
||||
JString(const JString& source);
|
||||
~JString();
|
||||
|
||||
//JString& operator = (const WCHAR *wString);
|
||||
|
@ -53,15 +53,15 @@
|
||||
#define IS_LETTER(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
||||
//#define UPPER(c) ((c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c)
|
||||
|
||||
PathName::PathName(void)
|
||||
PathName::PathName()
|
||||
{
|
||||
}
|
||||
|
||||
PathName::~PathName(void)
|
||||
PathName::~PathName()
|
||||
{
|
||||
}
|
||||
|
||||
const char* PathName::getWorkingDirectory(void)
|
||||
const char* PathName::getWorkingDirectory()
|
||||
{
|
||||
static char workingDirectory [MAXPATHLEN];
|
||||
|
||||
@ -85,11 +85,11 @@ const char* PathName::getWorkingDirectory(void)
|
||||
int PathName::findWorkingDirectory(int dpbLength, const UCHAR* dpb, int bufferLength, char* buffer)
|
||||
{
|
||||
const UCHAR *p = dpb, *end = dpb + dpbLength;
|
||||
int length;
|
||||
|
||||
if (dpbLength <= 0 || *p++ != isc_dpb_version1)
|
||||
return 0;
|
||||
|
||||
int length = 0;
|
||||
for (; p < end; p += length)
|
||||
{
|
||||
const UCHAR verb = *p++;
|
||||
@ -98,7 +98,7 @@ int PathName::findWorkingDirectory(int dpbLength, const UCHAR* dpb, int bufferLe
|
||||
|
||||
if (verb == isc_dpb_working_directory)
|
||||
{
|
||||
int l = MIN (bufferLength - 1, length);
|
||||
const int l = MIN (bufferLength - 1, length);
|
||||
memcpy (buffer, p, l);
|
||||
buffer [l] = 0;
|
||||
return length;
|
||||
@ -128,8 +128,10 @@ JString PathName::expandFilename(const char* fileName, const char* workingDirect
|
||||
|
||||
#ifdef _WIN32
|
||||
for (char *p = buffer; *p; ++p)
|
||||
{
|
||||
if (*p == '/')
|
||||
*p = SEPARATOR;
|
||||
}
|
||||
#endif
|
||||
|
||||
return JString (buffer, length);
|
||||
@ -249,8 +251,10 @@ JString PathName::expandFilename(const char* fileName)
|
||||
bool PathName::hasDirectory(const char* fileName)
|
||||
{
|
||||
for (const char *p = fileName; *p; ++p)
|
||||
{
|
||||
if (IS_SEPARATOR (*p))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -36,9 +36,10 @@
|
||||
class PathName
|
||||
{
|
||||
public:
|
||||
PathName(void);
|
||||
virtual ~PathName(void);
|
||||
static const char* getWorkingDirectory(void);
|
||||
PathName();
|
||||
virtual ~PathName();
|
||||
|
||||
static const char* getWorkingDirectory();
|
||||
static int findWorkingDirectory(int dpbLength, const UCHAR* dpb, int bufferLength, char* buffer);
|
||||
static JString expandFilename(const char* fileName, int dpbLength, const UCHAR* dpb);
|
||||
static JString expandFilename(const char* fileName, const char* workingDirectory);
|
||||
|
@ -38,10 +38,10 @@
|
||||
class RefObject
|
||||
{
|
||||
public:
|
||||
virtual void release();
|
||||
virtual void addRef();
|
||||
RefObject();
|
||||
virtual ~RefObject();
|
||||
virtual void addRef();
|
||||
virtual void release();
|
||||
private:
|
||||
int useCount;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user