featureProcessorPtr* ptrs;
int count;
+ const char* f_QuaddingString;
+
const Element* f_element;
const FeatureSet* f_local;
const FeatureSet* f_complete;
const FeatureSet* f_parent;
-
- const char* f_QuaddingString;
};
#endif
char*
loutFeatureProcessor::prepend(const char* header, const char* body)
{
- char* x = new char[strlen(header)+strlen(body)+1];
- strcpy(x, header);
- strcat(x, body);
+ int hlen = strlen(header);
+ int blen = strlen(body);
+
+ char* x = new char[hlen + blen + 1];
+
+ *((char *) memcpy (x, header, hlen) + hlen) = '\0';
+ *((char *) memcpy (x + hlen, body, blen) + blen) = '\0';
return x;
}
void
loutFeatureProcessor::handleData(const char *data, unsigned int size, ostream& out)
{
- for (int i=0; i<size; i++ )
+ for (unsigned int i=0; i<size; i++ )
out << data[i];
}
if ( dimensionToFloat(y, unitOfY, f, u) ) {
- FeatureValueDimension::Unit unit;
-
if ( u != FeatureValueDimension::NONE ) {
unitOfY = u;
}
switch ( unitOfY ) {
case FeatureValueDimension::INCH:
- sprintf(dBuf, "%.2fi", y);
+ snprintf(dBuf, sizeof(dBuf), "%.2fi", y);
break;
case FeatureValueDimension::PICA:
break;
case FeatureValueDimension::POINT:
- sprintf(dBuf, "%.2fp", y);
+ snprintf(dBuf, sizeof(dBuf), "%.2fp", y);
break;
case FeatureValueDimension::CM:
- sprintf(dBuf, "%.2fc", y);
+ snprintf(dBuf, sizeof(dBuf), "%.2fc", y);
break;
case FeatureValueDimension::PIXEL:
public:
loutFeatureProcessor(loutFeatureProcessor& x) :
- f_change(x.f_change), featureProcessor(x) {};
+ featureProcessor(x), f_change(x.f_change) {};
loutFeatureProcessor(const char* name) :
featureProcessor(name), f_change(false) {};
autoNumberNumeric::getValue()
{
char* ptr = f_buf.get_base();
+ int ptrlen = f_buf.buf_sz();
if (f_values.entries())
- sprintf(ptr, "%s", form("%s%d%s", f_prefix, f_values.top(), f_postfix));
+ snprintf(ptr, ptrlen, "%s",
+ form("%s%d%s", f_prefix, f_values.top(), f_postfix));
else
*ptr = 0;
autoNumberCased::autoNumberCased(const char* nm, autoNumberType an_t,
int delta, enum CaseType ct, const char* prefix, const char* postfix) :
- f_case(ct), autoNumber(nm, an_t, delta, prefix, postfix)
+ autoNumber(nm, an_t, delta, prefix, postfix), f_case(ct)
{
}
{
int digits = strlen(alpha);
int i;
- int offset;
+ int offset = 0;
switch ( a_case ) {
case UPPER:
const char* autoNumberAlphabetic::getValue()
{
char* ptr = f_buf.get_base();
+ int ptrlen = f_buf.buf_sz();
if (f_values.entries())
- sprintf(ptr, "%s", form("%s%s%s", f_prefix,
+ snprintf(ptr, ptrlen, "%s", form("%s%s%s", f_prefix,
intToAlpha(f_values.top(), f_case), f_postfix));
else
*ptr = 0;
const char*
autoNumberRoman::ArabicToRoman(int x)
{
+ unsigned int len, slen;
+
RomanNumberBuf[0] = 0;
if ( x > 3999 ) {
MESSAGE(cerr, "Value too large.");
char* buf = form("%d", x);
int j=strlen(buf)-1;
- for ( int i=0; i<strlen(buf); i++ ) {
+ for ( unsigned int i=0; i<strlen(buf); i++ ) {
if ( buf[i] != '0' )
{
const char* romanCardinal = romanCardinals[j][buf[i]-'1'];
precise_romanCardinal[k] = tolower(romanCardinal[k]);
precise_romanCardinal[k] = 0;
}
- strcat(RomanNumberBuf, precise_romanCardinal);
+
+ slen = strlen(RomanNumberBuf);
+ len = MIN(strlen(precise_romanCardinal), 256 - 1 - slen);
+ *((char *) memcpy(RomanNumberBuf + slen,
+ precise_romanCardinal, len) + len) = '\0';
}
j--;
}
enum autoNumberType { NUMERIC, ALPHABETIC, ROMAN };
autoNumber(const char* nm, enum autoNumberType, int delta, const char* prefix, const char* postfix);
- ~autoNumber();
+ virtual ~autoNumber();
void setNumTagsSeen();
protected:
static buffer f_buf;
+ char* f_name;
+ enum autoNumberType f_type;
int f_delta;
char* f_prefix;
char* f_postfix;
- char* f_name;
- enum autoNumberType f_type;
int f_initialValue;
Stack<int> f_values;
{
public:
autoNumberListT() {};
- ~autoNumberListT() {};
+ virtual ~autoNumberListT() {};
unsigned int operator==(const autoNumberListT&);
} ;
const char* gi = 0;
autoNumberListT* anList = 0;
- int i;
+ unsigned int i;
for (i=0; i<controlList -> length(); i++ ) {
gi = stringToCharPtr((*controlList)[i]);
XCOMM redefine TopLevelProject to build DtInfo with standard CDE config dir
#undef TopLevelProject
#define TopLevelProject DtInfo
-IMAKE_DEFINES = -DTopLevelProject=TopLevelProject \
- -DProjectTmplFile='<DtInfo.tmpl>' \
- -DProjectRulesFile='<DtInfo.rules>'
+IMAKE_DEF_DTINFO = -DTopLevelProject=TopLevelProject \
+ -DProjectTmplFile='<DtInfo.tmpl>' \
+ -DProjectRulesFile='<DtInfo.rules>'
MakeSubdirs($(SUBDIRS))
ForceSubdirs($(SUBDIRS))
{
public:
AttributeList();
- ~AttributeList();
+ virtual ~AttributeList();
void add(Attribute *);
{
unsigned int fill = ( initValue == 0 ) ? 0x0 : ~0x0;
- for ( int i=0; i<f_words; i++ )
+ for ( unsigned int i=0; i<f_words; i++ )
f_array[i]=fill;
}
f_bits = v.f_bits;
f_words = v.f_words;
- for ( int i=0; i<f_words; i++ )
+ for ( unsigned int i=0; i<f_words; i++ )
f_array[i]=v.f_array[i];
}
void BitVector::setBitTo(int i, unsigned int x)
{
- int wordIndex = i / WORD_SIZE;
- int bitIndex = i % WORD_SIZE;
+ unsigned int wordIndex = i / WORD_SIZE;
+ unsigned int bitIndex = i % WORD_SIZE;
if ( x == 1 ) {
if ( wordIndex < f_words - 1 )
unsigned int BitVector::getBit(int i)
{
- int wordIndex = i / WORD_SIZE;
- int bitIndex = i % WORD_SIZE;
+ unsigned int wordIndex = i / WORD_SIZE;
+ unsigned int bitIndex = i % WORD_SIZE;
if ( wordIndex < f_words - 1 )
- return BIT_TEST(f_array[wordIndex], (0x1 << bitIndex)) ? 1 : 0;
+ return BIT_TEST((int)f_array[wordIndex], (0x1 << bitIndex)) ? 1 : 0;
else
- return BIT_TEST(f_array[wordIndex],
+ return BIT_TEST((int)f_array[wordIndex],
(0x1 << (WORD_SIZE - f_bits % WORD_SIZE + bitIndex))
) ? 1 : 0;
}
BitVector& BitVector::operator &=(BitVector& b)
{
- for ( int i=0; i<f_words; i++ )
+ for ( unsigned int i=0; i<f_words; i++ )
f_array[i] &= b.f_array[i];
return *this;
BitVector& BitVector::operator ^=(BitVector& b)
{
- for ( int i=0; i<f_words; i++ )
+ for ( unsigned int i=0; i<f_words; i++ )
f_array[i] ^= b.f_array[i];
return *this;
BitVector& BitVector::operator |=(BitVector& b)
{
- for ( int i=0; i<f_words; i++ )
+ for ( unsigned int i=0; i<f_words; i++ )
f_array[i] |= b.f_array[i];
return *this;
unsigned int msb = 0;
unsigned int lsb = 0;
- for ( int i=0; i<f_words; i++ ) {
+ for ( unsigned int i=0; i<f_words; i++ ) {
lsb = ( BIT_TEST(f_array[i], 0x1) ) ? 0x1 : 0x0;
f_array[i] = f_array[i] >> 1;
f_array[i] |= msb;
unsigned int lsb = 0;
- for ( int i=f_words-1; i>=0; i++ ) {
- msb = ( BIT_TEST(f_array[i], wordWithMSBSet) ) ? wordWithMSBSet : 0x0;
+ for ( unsigned int i=f_words-1; i>=0; i++ ) {
+ msb = (BIT_TEST((int)f_array[i], wordWithMSBSet)) ? wordWithMSBSet : 0x0;
f_array[i] = f_array[i] << 1;
f_array[i] |= lsb;
lsb = msb;
///////////////////////////////////////////////////////
class BitVector
{
- positionArrayT *f_positionArray;
unsigned int *f_array;
unsigned int f_bits;
unsigned int f_words;
+ positionArrayT *f_positionArray;
public:
BitVector(int bits, unsigned int initValue);
#if defined(SC3) || defined(__osf__)
static ostrstream& terminate(ostrstream& ost)
{
- char* string = ost.str();
- *(string + ost.pcount()) = 0;
+ char* pstring = ost.str();
+ *(pstring + ost.pcount()) = '\0';
return ost;
}
f_output(f_buffer, DATA_BUF_SIZ)
#else
f_streambuf(new stringbuf()),
- f_output(f_streambuf)
+ f_output()
#endif
{
}
unsigned int
DocParser::rawParse(istream &input)
{
+ string data;
+
input.unsetf(ios::skipws);
f_ignoring_element = 0 ;
Symbol name(gElemSymTab->intern(terminate(f_output).str()));
f_output.rdbuf()->freeze(0);
#else
- char *data = (char *)f_streambuf->str().c_str();
+ data = f_output.str().c_str();
/*
MESSAGE(cerr, "StartTag case:");
-debug(cerr, f_streambuf->pcount());
-debug(cerr, data);
+debug(cerr, f_output.str().size());
+debug(cerr, data.c_str());
*/
-#if !defined(SC3) && !defined(__osf__)
- data[f_streambuf->str().size()] = 0;
-#endif
- Symbol name(gElemSymTab->intern(data));
+ Symbol name(gElemSymTab->intern(data.c_str()));
#endif
process(input, f_output, name, 1, 1);
}
}
void
-DocParser::process(istream &input, ostream &output,
+DocParser::process(istream &input, ostringstream &output,
const Symbol &name,
unsigned int sibling_number, unsigned int this_sibling_number)
{
unsigned int child = 1 ; // sibling numbers for child elements
+#if !defined(SC3) && !defined(__osf__)
+ string pstring;
+#endif
+ string data;
+
char c ;
while ((input >> c) && (c == '\n'));
input.putback(c);
process(input, output, name, child++, child_relative_sibling_number);
#else
- char *data = (char *)f_streambuf->str().c_str();
-#if !defined(SC3) && !defined(__osf__)
- data[f_streambuf->str().size()] = 0;
-#endif
- Symbol name(gElemSymTab->intern(data));
+ data = f_output.str().c_str();
+//#if !defined(SC3) && !defined(__osf__)
+// data[f_output.str().size()] = '\0';
+//#endif
+ Symbol name(gElemSymTab->intern(data.c_str()));
update_last_seen_child_name(last_seen_child_name,
child_relative_sibling_number, name);
#ifdef DEBUG
{
#if defined(SC3) || defined(__osf__)
- char *data = terminate(f_output).str();
+ data = terminate(f_output).str();
f_output.rdbuf()->freeze(0);
#else
- char *data = (char*)f_streambuf->str().c_str();
+ data = f_output.str().c_str();
//#ifdef _IBMR2
-#if !defined(SC3) && !defined(__osf__)
- data[f_streambuf->str().size()] = 0;
-#endif
+//#if !defined(SC3) && !defined(__osf__)
+// data[f_output.str().size()] = '\0';
+//#endif
#endif
- cerr << "EndTag: " << data << endl;
- assert(gElemSymTab->intern(data) == name);
+ cerr << "EndTag: " << data.c_str() << endl;
+ assert(gElemSymTab->intern(data.c_str()) == name);
}
#endif
// and increment the pcount, so we must make sure it gets
// called first
#if defined(SC3) || defined(__osf__)
- char *string = terminate(f_output).str();
+ char *pstring = terminate(f_output).str();
int size = f_output.pcount();
- f_resolver.data(string, size);
+ f_resolver.data(pstring, size);
f_output.rdbuf()->freeze(0);
#else
- char *string = (char *)f_streambuf->str().c_str();
-//#ifdef _IBMR2
-#if !defined(SC3) && !defined(__osf__)
- string[f_streambuf->str().size()] = 0;
- int size = f_streambuf->str().size() ;
-#else
- int size = f_streambuf->pcount() - 1 ;
-#endif
- f_resolver.data(string, size);
+ pstring = f_output.str().c_str();
+ int size = pstring.size() + 1;
+ f_resolver.data(pstring.c_str(), size);
#endif
}
}
/////////////////////////////
// second child and beyond.
/////////////////////////////
+ data = f_output.str().c_str();
#if defined(SC3) || defined(__osf__)
- char *data = f_output.str();
- *(data + f_output.pcount()) = 0;
f_output.rdbuf()->freeze(0);
-#else
- char *data = (char *)f_streambuf->str().c_str();
-//#ifdef _IBMR2
-#if !defined(SC3) && !defined(__osf__)
- data[f_streambuf->str().size()] = 0;
-#endif
#endif
/*
MESSAGE(cerr, "StartTag case2");
debug(cerr, data);
-debug(cerr, f_streambuf->pcount ());
+debug(cerr, f_output.str().size());
*/
- Symbol name(gElemSymTab->intern(data));
+ Symbol name(gElemSymTab->intern(data.c_str()));
update_last_seen_child_name(last_seen_child_name,
child_relative_sibling_number, name);
// and increment the pcount, so we must make sure it gets
// called first
#if defined(SC3) || defined(__osf__)
- char *string = f_output.str();
+ char *pstring = f_output.str();
int size = f_output.pcount();
- *(string + size) = 0;
- f_resolver.data(string, size);
+ *(pstring + size) = 0;
+ f_resolver.data(pstring, size);
f_output.rdbuf()->freeze(0);
#else
- char *string = (char *)f_streambuf->str().c_str();
-//#ifdef _IBMR2
-#if !defined(SC3) && !defined(__osf__)
- string[f_streambuf->str().size()] = 0;
- int size = f_streambuf->str().size() ;
-#else
- int size = f_streambuf->pcount() - 1 ;
-#endif
- f_resolver.data(string, size);
+ pstring = f_output.str().c_str();
+ int size = pstring.size() + 1;
+ f_resolver.data(pstring.c_str(), size);
#endif
}
}
#ifdef DEBUG
{
#if defined(SC3) || defined(__osf__)
- char *data = terminate(f_output).str();
+ data = terminate(f_output).str();
f_output.rdbuf()->freeze(0);
#else
- char *data = (char*)f_streambuf->str().c_str();
-//#ifdef _IBMR2
-#if !defined(SC3) && !defined(__osf__)
- data[f_streambuf->str().size()] = 0;
+ data = f_output.str().c_str();
#endif
-#endif
- cerr << "EndTag: " << data << endl;
- assert(gElemSymTab->intern(data) == name);
+ cerr << "EndTag: " << data.c_str() << endl;
+ assert(gElemSymTab->intern(data.c_str()) == name);
}
#endif
// hit end tag, end processing
void
-DocParser::process_attributes(istream &input, ostream &output,
+DocParser::process_attributes(istream &input, ostringstream &output,
AttributeList *&attrs,
AttributeList *&olias_attrs)
{
+#if !defined(SC3) && !defined(__osf__)
+ string theData;
+#endif
TagType tt ;
Attribute* newAttribute = 0;
AttributeList* orig_attrs = attrs;
AttributeList* orig_olias_attrs = olias_attrs;
- char *theData = 0;
-
mtry {
while ((tt = read_tag(input,output)) != NoTag)
{
{
case StartTag:
{
-//#ifdef _IBMR2
#if !defined(SC3) && !defined(__osf__)
- theData = (char *)f_streambuf->str().c_str();
- theData[f_streambuf->str().size()] = 0;
+ theData = f_output.str().c_str();
#endif
if (!attrs)
attrs = new AttributeList ;
process_attribute(input, output,
#if defined(SC3) || defined(__osf__)
gSymTab->intern(terminate(f_output).str()),
-#else
-//#ifdef _IBMR2
-#if !defined(SC3) && !defined(__osf__)
- gSymTab->intern(theData),
-#else
gSymTab->intern(f_streambuf->str()),
-#endif
+#else
+ gSymTab->intern(theData.c_str()),
#endif
StartTag
);
throw(CASTDPUTEXCEPT docParserUnexpectedTag());
break;
case OliasAttribute:
-//#ifdef _IBMR2
#if !defined(SC3) && !defined(__osf__)
- theData = (char *)f_streambuf->str().c_str();
- theData[f_streambuf->str().size()] = 0;
+ theData = f_output.str().c_str();
#endif
// mirrors attribute
if (!olias_attrs)
process_attribute(input, output,
#if defined(SC3) || defined(__osf__)
gSymTab->intern(terminate(f_output).str()),
-#else
-//#ifdef _IBMR2
-#if !defined(SC3) && !defined(__osf__)
- gSymTab->intern(theData),
-#else
gSymTab->intern(f_streambuf->str()),
-#endif
+#else
+ gSymTab->intern(theData.c_str()),
#endif
OliasAttribute
);
}
Attribute *
-DocParser::process_attribute(istream &input, ostream &output,
+DocParser::process_attribute(istream &input, ostringstream &output,
const Symbol &name, TagType tt)
{
+ string data;
+
//ON_DEBUG(cerr << "process_attribute: " << name << endl);
// If the attribute is OLIAS internal, we use DocParser's
char *data = f_output.str();
*(data + f_output.pcount()) = 0;
f_output.rdbuf()->freeze(0);
+ Attribute *attr = new Attribute(name, strdup(data));
#else
- char *data = (char *)f_streambuf->str().c_str();
-//#ifdef _IBMR2
-#if !defined(SC3) && !defined(__osf__)
- data[f_streambuf->str().size()] = 0;
-#endif
+ data = f_output.str().c_str();
+ Attribute *attr = new Attribute(name, strdup(data.c_str()));
#endif
- Attribute *attr = new Attribute(name, strdup(data));
switch (read_tag(input, output))
{
DocParser::TagType
-DocParser::read_tag(istream &input, ostream &output)
+DocParser::read_tag(istream &input, ostringstream &output)
{
output.seekp(streampos(0));
// get (remainder of) tag name
while ((input >> c) && (c != '>'))
output << c ;
+ output << ends;
return tt ;
}
void
-DocParser::read_data(istream &input, ostream &output)
+DocParser::read_data(istream &input, ostringstream &output)
{
char c ;
output << c;
}
+ output << ends;
+
// can never run out of input while reading data, tags must be balanced
if (input.eof())
throw(CASTDPUEEXCEPT docParserUnexpectedEof());
unsigned int rawParse(istream &);
protected:
- virtual void read_data(istream &, ostream &);
+ virtual void read_data(istream &, ostringstream &);
private:
- void process(istream &, ostream &, const Symbol &tagname,
+ void process(istream &, ostringstream &, const Symbol &tagname,
unsigned int sibling_number,
unsigned int relative_sibling_number);
- TagType read_tag(istream &, ostream &);
- void process_entity(istream &, ostream &);
+ TagType read_tag(istream &, ostringstream &);
+ void process_entity(istream &, ostringstream &);
- void process_attributes(istream &, ostream &,
+ void process_attributes(istream &, ostringstream &,
AttributeList *&attrs,
AttributeList *&olias_attrs);
- Attribute *process_attribute(istream &, ostream &, const Symbol &name, TagType);
+ Attribute *process_attribute(istream &, ostringstream &, const Symbol &name, TagType);
private:
unsigned int f_ignoring_element ;
+ Resolver &f_resolver;
#if defined(SC3) || defined(__osf__)
char* const f_buffer;
ostrstream f_output;
#else
stringbuf *f_streambuf;
- ostream f_output;
+ ostringstream f_output;
#endif
- Resolver &f_resolver;
};
ostream &print(ostream &) const ;
private:
- unsigned int f_freeAttrLists;
+ Symbol f_gi ;
unsigned int f_sibling_number ; // counting all children of a parent
+ AttributeList *f_attributes;
+ AttributeList *f_olias_attributes;
+ unsigned int f_freeAttrLists;
unsigned int f_relative_sibling_number ; // counting all
// consecutive children
// of same types of a
// parent
int f_last_child;
int f_relatively_last_child;
- Symbol f_gi ;
- AttributeList *f_attributes;
- AttributeList *f_olias_attributes;
};
inline
public:
Expression(TermNode *root);
Expression(const Expression&);
- ~Expression();
+ virtual ~Expression();
virtual FeatureValue *evaluate() const;
ostream &print(ostream &) const;
FeatureSet(const FeatureSet &); /* copy */
FeatureSet(const FeatureSet &,
const FeatureSet &); /* merge */
- ~FeatureSet();
+ virtual ~FeatureSet();
void add(Feature *);
const Feature *lookup(const Symbol *) const ;
// cast to non-const to get iterator
CC_TPtrSlistIterator<Feature> next(*(CC_TPtrSlist<Feature>*)this);
- int i;
+ unsigned int i;
for (i = 0 ; i < f_print_indent_level; i++)
o << " " ;
while (++next)
{
- for (int i = 0 ; i < f_print_indent_level; i++)
+ for (unsigned int i = 0 ; i < f_print_indent_level; i++)
o << " " ;
o << *next.key() << endl ;
}
///////////////////////////////////////////////////
FeatureValueArray::FeatureValueArray(const char* nm, int size) :
- f_name(strdup(nm)), FeatureValue(array), pointer_vector<FeatureValue>(size, 0)
+ FeatureValue(array), pointer_vector<FeatureValue>(size, 0), f_name(strdup(nm))
{
}
FeatureValueArray::FeatureValueArray(const FeatureValueArray& x) :
- f_name(strdup(x.f_name)), FeatureValue(array),
- pointer_vector<FeatureValue>(x.length(), 0)
+ FeatureValue(array), pointer_vector<FeatureValue>(x.length(), 0),
+ f_name(strdup(x.f_name))
{
mtry
{
- for ( int i=0; i<length(); i++ )
+ for ( unsigned int i=0; i<length(); i++ )
(*this)[i] = x[i] -> clone();
return;
}
mcatch_any()
{
- for ( int i=0; i<length(); i++ )
+ for ( unsigned int i=0; i<length(); i++ )
delete (*this)[i];
rethrow;
}
FeatureValueArray::~FeatureValueArray()
{
- for ( int i=0; i<length(); i++ )
+ for ( unsigned int i=0; i<length(); i++ )
delete (*this)[i];
delete f_name;
mtry
{
- for ( int i=0; i<length(); i++ ) {
+ for ( unsigned int i=0; i<length(); i++ ) {
(*result)[i] = (*this)[i] -> evaluate();
}
return result;
{
out << f_name << "[\n";
- for ( int i=0; i<length(); i++ ) {
+ for ( unsigned int i=0; i<length(); i++ ) {
if ( (*this)[i] == 0 ) {
MESSAGE(cerr, form("%d is a null slot", i));
private:
FeatureValue *f_value ;
- Unit f_unit ;
float f_cachedValue;
+ Unit f_unit ;
private:
float convert(float y, Unit dimensionOfy, Unit dimensionOfReturn);
{
switch ( f_optype ) {
case PQEqual:
- if ( f_position == element.sibling_number() ||
+ if ( f_position == (int) element.sibling_number() ||
( f_position==-1 && element.last_child() )
)
return PQTrue;
else
return PQFalse;
} else
- if ( f_position != element.sibling_number() )
+ if ( f_position != (int) element.sibling_number() )
return PQTrue;
else
return PQFalse;
{
switch ( f_optype ) {
case PQEqual:
- if ( f_sibling == element.relative_sibling_number() ||
+ if ( f_sibling == (int) element.relative_sibling_number() ||
( f_sibling ==-1 && element.relatively_last_child() )
)
return PQTrue;
else
return PQFalse;
} else
- if ( f_sibling != element.relative_sibling_number() )
+ if ( f_sibling != (int) element.relative_sibling_number() )
return PQTrue;
else
return PQFalse;
virtual PQBoolean evaluate(const Element &);
private:
- int f_position ;
PQEqOp f_optype;
+ int f_position ;
};
class PQSibling: public PQExpr
virtual PQBoolean evaluate(const Element &);
private:
- int f_sibling;
PQEqOp f_optype;
+ int f_sibling;
};
class PQAttributeSelector : public PQExpr
}
EncodedPath::EncodedPath(SSPath* p, unsigned int asPattern) :
- f_size(p -> entries()), f_SVectors(letterHash), f_patternSize(0),
+ f_size(p -> entries()), f_patternSize(0), f_SVectors(letterHash),
f_wildCard(gElemSymTab -> wildCardId()),
f_unlimitedWildCard(gElemSymTab -> unlimitedWildCardId()),
f_copyOfS(new BitVector(WORD_SIZE, 0))
{
f_lastSymIndexCount = gElemSymTab -> IdsAssigned()+1;
f_lastSymIndex = new CC_TPtrDlist_PathFeature_Ptr_T[f_lastSymIndexCount];
- for (int i=0; i<f_lastSymIndexCount; i++)
+ for (unsigned int i=0; i<f_lastSymIndexCount; i++)
f_lastSymIndex[i] = new CC_TPtrDlist<PathFeature>;
class EncodedPath
{
- int f_patternSize;
int f_size;
+ int f_patternSize;
LetterType* f_array;
+ hashTable<LetterType, BitVector> f_SVectors;
+
LetterType f_wildCard;
LetterType f_unlimitedWildCard;
- hashTable<LetterType, BitVector> f_SVectors;
-
BitVector* f_copyOfS; // copy of S vector, used in match()
public:
public:
PathFeature(SSPath* p,FeatureSet* f,EncodedPath* e=0, unsigned int id=0):
- f_encodedPath(e), f_id(id), basePathFeature(p, f) {};
+ basePathFeature(p, f), f_id(id), f_encodedPath(e) {};
~PathFeature();
EncodedPath* encodedPath() { return f_encodedPath; };
public:
PathFeatureList() {};
- ~PathFeatureList();
+ virtual ~PathFeatureList();
void appendList(PathFeatureList&);
};
{
public:
Renderer() {};
- ~Renderer() {};
+ virtual ~Renderer() {};
virtual FeatureSet *initialize() = 0; /* return default feature set */
private:
SSPath f_path ;
- ResolverStack f_resolverStack;
PathTable &f_pathTable;
// NOTE: this one could be a pointer so we can change them on the fly
Renderer &f_Renderer;
+ ResolverStack f_resolverStack;
};
#endif /* _Resolver_h */
public:
SSPath(char*, unsigned int assignId); // for test purpose
SSPath();
- ~SSPath();
+ virtual ~SSPath();
// this call update f_containPathQualifier field
void appendPathTerm(PathTerm*);
*/
// $TOG: defParser.C /main/5 1997/12/23 11:16:25 bill $
#ifndef lint
-static char defParsersccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
+static const char defParsersccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
#endif
#define defParserBYACC 1
#include <stdio.h>
*defParserssp = defParserstate = 0;
defParserloop:
- if (defParsern = defParserdefred[defParserstate]) goto defParserreduce;
+ if ((defParsern = defParserdefred[defParserstate])) goto defParserreduce;
if (defParserchar < 0)
{
if ((defParserchar = defParserlex()) < 0) defParserchar = 0;
static defParser_state_type defParser_get_previous_state defParser_PROTO(( void ));
static defParser_state_type defParser_try_NUL_trans defParser_PROTO(( defParser_state_type current_state ));
static int defParser_get_next_buffer defParser_PROTO(( void ));
+#if 0
static void defParserunput defParser_PROTO(( defParser_CHAR c, defParser_CHAR *buf_ptr ));
+#endif
void defParserrestart defParser_PROTO(( FILE *input_file ));
void defParser_switch_to_buffer defParser_PROTO(( defParser_BUFFER_STATE new_buffer ));
void defParser_load_buffer_state defParser_PROTO(( void ));
}
+#if 0
#ifdef defParser_USE_PROTOS
static void defParserunput( defParser_CHAR c, register defParser_CHAR *defParser_bp )
#else
*/
defParser_DO_BEFORE_ACTION; /* set up defParsertext again */
}
+#endif
#ifdef __cplusplus
*/
// $TOG: style.C /main/6 1998/04/17 11:51:49 mgreess $
#ifndef lint
-static char stylesccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
+static const char stylesccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
#endif
#define styleBYACC 1
#include <stdio.h>
{
static char buffer[512];
int j=0;
- for ( int i=0; i<strlen((const char*)string); i++ )
+ for ( unsigned int i=0; i<strlen((const char*)string); i++ )
{
if (islower(string[i]))
buffer[j] = toupper(string[i]) ;
*stylessp = stylestate = 0;
styleloop:
- if (stylen = styledefred[stylestate]) goto stylereduce;
+ if ((stylen = styledefred[stylestate])) goto stylereduce;
if (stylechar < 0)
{
if ((stylechar = stylelex()) < 0) stylechar = 0;
/* char handling better too? */
if ( gGI_CASE_SENSITIVE == false )
{
- for (int i=0; i<strlen((const char*)stylevsp[0].charPtrData); i++)
+ for (unsigned int i=0; i<strlen((const char*)stylevsp[0].charPtrData); i++)
if ( islower(stylevsp[0].charPtrData[i]) )
stylevsp[0].charPtrData[i] = toupper(stylevsp[0].charPtrData[i]);
}
break;
case 65:
{
- int l = strlen((char*)stylevsp[-3].charPtrData) + strlen((char*)stylevsp[0].charPtrData) + 2;
+ int l3 = strlen((char*)stylevsp[-3].charPtrData);
+ int l0 = strlen((char*)stylevsp[0].charPtrData);
+ int l = l3 + l0 + 2;
styleval.charPtrData=new unsigned char[l];
- strcpy((char*)styleval.charPtrData, (char*)stylevsp[-3].charPtrData);
- strcat((char*)styleval.charPtrData, ".");
- strcat((char*)styleval.charPtrData, (char*)stylevsp[0].charPtrData);
+
+ *((char *) memcpy((char*)styleval.charPtrData,
+ (char*)stylevsp[-3].charPtrData, l3) + l3) = '\0';
+ *((char *) memcpy((char*)(styleval.charPtrData + l3),
+ ".", 1) + 1) = '\0';
+ *((char *) memcpy((char*)(styleval.charPtrData + l3 + 1),
+ (char*)stylevsp[0].charPtrData, l0) + l0) = '\0';
+
delete stylevsp[-3].charPtrData;
delete stylevsp[0].charPtrData;
}
break;
case 66:
{
- int l = strlen((char*)stylevsp[-1].charPtrData) + 2;
+ int l1 = strlen((char*)stylevsp[-1].charPtrData);
+ int l = l1 + 2;
styleval.charPtrData=new unsigned char[l];
- strcpy((char*)styleval.charPtrData, (char*)stylevsp[-1].charPtrData);
- strcat((char*)styleval.charPtrData, ".");
+
+ *((char *) memcpy((char*)styleval.charPtrData,
+ (char*)stylevsp[-1].charPtrData, l1) + l1) = '\0';
+ *((char *) memcpy((char*)styleval.charPtrData + l1,
+ ".", 1) + 1) = '\0';
+
delete stylevsp[-1].charPtrData;
}
break;
break;
case 68:
{
- int i;
+ unsigned int i;
for (i=0; i<strlen((const char*)stylevsp[0].charPtrData); i++) {
static style_state_type style_get_previous_state style_PROTO(( void ));
static style_state_type style_try_NUL_trans style_PROTO(( style_state_type current_state ));
static int style_get_next_buffer style_PROTO(( void ));
+#if 0
static void styleunput style_PROTO(( style_CHAR c, style_CHAR *buf_ptr ));
+#endif
void stylerestart style_PROTO(( FILE *input_file ));
void style_switch_to_buffer style_PROTO(( style_BUFFER_STATE new_buffer ));
void style_load_buffer_state style_PROTO(( void ));
}
+#if 0
#ifdef style_USE_PROTOS
static void styleunput( style_CHAR c, register style_CHAR *style_bp )
#else
*/
style_DO_BEFORE_ACTION; /* set up styletext again */
}
+#endif
#ifdef __cplusplus
num_cset_ptrs(0), num_list_ptrs(0),
f_obj_dict(obj_dict)
{
+ int len = MIN(strlen(base_dir), PATHSIZ - 1);
if ( base_dir )
- strcpy(base_path, base_dir);
+ *((char *) memcpy (base_path, base_dir, len) + len) = '\0';
else
base_path[0] = 0;
+ len = MIN(strlen(base_nm), PATHSIZ - 1);
if ( base_nm )
- strcpy(base_name, base_nm);
+ *((char *) memcpy (base_name, base_nm, len) + len) = '\0';
else
base_name[0] = 0;
+ len = MIN(strlen(base_ds), PATHSIZ - 1);
if ( base_ds )
- strcpy(base_desc, base_ds);
+ *((char *) memcpy (base_desc, base_ds, len) + len) = '\0';
else
base_desc[0] = 0;
+ len = MIN(strlen(base_uid_str), UIDSIZ - 1);
if ( base_uid_str )
- strcpy(base_uid, base_uid_str);
+ *((char *) memcpy (base_uid, base_uid_str, len) + len) = '\0';
else
base_uid[0] = 0;
protected:
- object_dict* f_obj_dict;
-
-
char base_path[PATHSIZ];
char base_name[PATHSIZ];
char base_desc[PATHSIZ];
char base_uid[UIDSIZ];
- int num_cset_ptrs;
- int num_list_ptrs;
char** info_base_set_names;
char** info_base_list_names;
+ int num_cset_ptrs;
+ int num_list_ptrs;
+
+ object_dict* f_obj_dict;
};
typedef base* basePtr;
debug(cerr, base_nm);
debug(cerr, base_ds);
*/
+ int len = MIN(strlen(base_locale), PATHSIZ - 1);
if (base_locale)
- strcpy(info_base_locale, base_locale);
+ *((char *) memcpy (info_base_locale, base_locale, len) + len) = '\0';
else
*info_base_locale = 0;
int info_base::get_set_pos(const char* set_nm)
{
- char* nm = 0;
for ( int i=0; i<num_cset_ptrs; i++ ) {
if ( strcmp(set_nm, info_base_set_names[i]) == 0 )
return i;
handler* x = get_set(col_nm);
if ( x == 0 ) {
- handler* x = get_list(col_nm);
+ x = get_list(col_nm);
}
if ( x == 0 ) {
chars_to_read = MIN(max_sz, remain_chars);
- if ( fread((char*)buf, 1, chars_to_read, stdin) != chars_to_read ) {
+ if ( (int)fread((char*)buf, 1, chars_to_read, stdin) != chars_to_read ) {
throw(stringException("sgml_data_getchar(): fread() failed"));
}
//debug(cerr, info_lib_dir);
//debug(cerr, infoLibName);
+ int len;
+
f_obj_dict = new object_dict;
if ( info_lib_dir == 0 ) {
)
);
- strcpy(info_lib_path, info_lib_dir);
- strcpy(info_lib_name, infoLibName);
+ len = MIN(strlen(info_lib_dir), PATHSIZ -1);
+ *((char *) memcpy (info_lib_path, info_lib_dir, len) + len) = '\0';
+ len = MIN(strlen(infoLibName), PATHSIZ -1);
+ *((char *) memcpy (info_lib_name, infoLibName, len) + len) = '\0';
fstream *map_in = 0;
strcmp("C.ISO-8859-1", base_locale) == 0))
{
- strcpy(db_path_name,
- form("%s/%s", info_lib_dir, base_name)
- );
+ len = MIN(strlen(info_lib_dir) + strlen(base_name) +1, PATHSIZ -1);
+ *((char *) memcpy (db_path_name,
+ form("%s/%s", info_lib_dir, base_name),
+ len) + len) = '\0';
mm_version mmv_code(MAJOR, MINOR);
mm_version mmv_base_data(2, 1);
char new_db_path[PATHSIZ];
char f_name[PATHSIZ];
char base_uid[UIDSIZ];
+ int len;
+ const char* uid;
- strcpy(new_db_path, form("%s/%s", info_lib_path, base_name));
+ len = MIN(strlen(info_lib_path) + strlen(base_name) + 1, PATHSIZ -1);
+ *((char *) memcpy (new_db_path,
+ form("%s/%s", info_lib_path, base_name),
+ len) + len) = '\0';
- strcpy(base_uid, unique_id());
+ uid = unique_id();
+ len = MIN(strlen(uid), UIDSIZ -1);
+ *((char *) memcpy(base_uid, uid, len) + len) = '\0';
g_mode_8_3 = 1;
// remove any old files
//////////////////////////
- strcpy(f_name, form("%s.%s", base_name, DATA_FILE_SUFFIX));
+ len = MIN(strlen(base_name) + strlen(DATA_FILE_SUFFIX) +1, PATHSIZ -1);
+ *((char *) memcpy(f_name,
+ form("%s.%s", base_name, DATA_FILE_SUFFIX),
+ len) + len) = '\0';
if ( exist_file(f_name, new_db_path) == true )
del_file(f_name, new_db_path);
- strcpy(f_name, form("%s.%s", base_name, INDEX_FILE_SUFFIX));
+ len = MIN(strlen(base_name) + strlen(INDEX_FILE_SUFFIX) + 1, PATHSIZ -1);
+ *((char *) memcpy(f_name,
+ form("%s.%s", base_name, INDEX_FILE_SUFFIX),
+ len) + len) = '\0';
if ( exist_file(f_name, new_db_path) == true )
del_file(f_name, new_db_path);
- strcpy(f_name, form("%s.%s", base_name, SCHEMA_FILE_SUFFIX));
+ len = MIN(strlen(base_name) + strlen(SCHEMA_FILE_SUFFIX) +1, PATHSIZ -1);
+ *((char *) memcpy(f_name,
+ form("%s.%s", base_name, SCHEMA_FILE_SUFFIX),
+ len) + len) = '\0';
if ( exist_file(f_name, new_db_path) == true )
del_file(f_name, new_db_path);
int f_bad_base_array_size;
int f_bad_info_bases;
- char** f_bad_info_base_paths;
char** f_bad_info_base_names;
+ char** f_bad_info_base_paths;
int f_descriptor;
)
);
- strcpy(info_lib_dir, x_infolib_path);
+ int len = MIN(strlen(x_infolib_path), PATHSIZ - 1);
+ *((char *) memcpy(info_lib_dir, x_infolib_path, len) + len) = '\0';
}
handler* z = get_handler(i, OID_CODE);
oid_handler* y = (oid_handler*)z;
- sprintf(buf, "%d.%d\n", x.ccode(), (int)x.icode());
+ snprintf(buf, sizeof(buf), "%d.%d\n", x.ccode(), (int)x.icode());
istringstream in(buf);
(*y) -> asciiIn(in);
io_status ok;
switch ( x -> its_oid().ccode() ) {
case STRING_CODE:
- ok = (*(pstring_handler*)x) -> asciiIn(in);
+ ok =(*(pstring_handler*)x) -> asciiIn(in);
break;
case COMPRESSED_STRING_CODE:
- ok = (*(compressed_pstring_handler*)x) -> _asciiIn(in);
+ ok =(*(compressed_pstring_handler*)x) -> _asciiIn(in);
break;
default:
throw(stringException("invalid node data class code"));
}
+
+ if(ok) { ; }
delete x;
}
case RET_SUCCESS:
return true;
}
+
+ return false;
}
Boolean btree::remove(data_t& w)
case RET_SUCCESS:
return true;
}
+
+ return false;
}
Boolean btree::member(data_t& w)
memcpy((char*)&w.dt, data_DBT.data, data_DBT.size);
return true;
}
+
+ return false;
}
ostream& btree::asciiOut(ostream& out)
BTREE *t;
int status;
PAGE *h;
- void *p;
+ void *p = NULL;
t = dbp->internal;
*/
if (b.psize &&
(b.psize < MINPSIZE || b.psize > MAX_PAGE_OFFSET + 1 ||
- b.psize & sizeof(indx_t) - 1))
+ b.psize & (sizeof(indx_t) - 1)))
goto einval;
/* Minimum number of keys per page; absolute minimum is 2. */
if (m.m_magic != BTREEMAGIC || m.m_version != BTREEVERSION)
goto eftype;
if (m.m_psize < MINPSIZE || m.m_psize > MAX_PAGE_OFFSET + 1 ||
- m.m_psize & sizeof(indx_t) - 1)
+ m.m_psize & (sizeof(indx_t) - 1))
goto eftype;
if (m.m_flags & ~SAVEMETA)
goto eftype;
t->bt_psize = b.psize;
/* Set the cache size; must be a multiple of the page size. */
- if (b.cachesize && b.cachesize & b.psize - 1)
- b.cachesize += (~b.cachesize & b.psize - 1) + 1;
+ if (b.cachesize && b.cachesize & (b.psize - 1))
+ b.cachesize += (~b.cachesize & (b.psize - 1)) + 1;
if (b.cachesize < b.psize * MINCACHE)
b.cachesize = b.psize * MINCACHE;
{
BTREE *t;
DBT tkey, tdata;
- EPG *e;
+ EPG *e = NULL;
PAGE *h;
indx_t index, nxtindex;
pgno_t pg;
dest = (char *)h + h->upper;
WR_BLEAF(dest, key, data, dflags);
- if (t->bt_order == NOT)
+ if (t->bt_order == NOT) {
if (h->nextpg == P_INVALID) {
if (index == NEXTINDEX(h) - 1) {
t->bt_order = FORWARD;
t->bt_last.pgno = h->pgno;
}
}
+ }
mpool_put(t->bt_mp, h, MPOOL_DIRTY);
size_t ilen;
u_int skip;
{
- BINTERNAL *bi;
- BLEAF *bl, *tbl;
+ BINTERNAL *bi = NULL;
+ BLEAF *bl = NULL;
+ BLEAF *tbl;
DBT a, b;
EPGNO *parent;
PAGE *h, *l, *r, *lchild, *rchild;
indx_t nxtindex;
- size_t n, nbytes, nksize;
+ size_t n, nbytes;
+ size_t nksize = 0;
int parentsplit;
char *dest;
RLEAF *rl;
EPGNO *c;
PAGE *rval;
- void *src;
+ void *src = NULL;
indx_t full, half, nxt, off, skip, top, used;
size_t nbytes;
int bigkeycnt, isbigkey;
len = MIN(a->size, b->size);
for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2)
- if (diff = *p1 - *p2)
+ if ((diff = *p1 - *p2))
return (diff);
return (a->size - b->size);
}
#define __END_DECLS };
#endif
#else
+#undef __BEGIN_DECLS
#define __BEGIN_DECLS
+#undef __END_DECLS
#define __END_DECLS
#endif
* define them only if compiling without this.
*/
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+#undef __dead
#define __dead __volatile
#ifndef __pure
#define __pure __const
#endif
/*
- * If your system's vsprintf returns a char *, not an int,
+ * If your system's vsnprintf returns a char *, not an int,
* change the 0 to a 1.
*/
-#if !defined(_AIX) && !defined(__osf__)
+#if !defined(_AIX) && !defined(__osf__) && !defined(linux) && !defined(CSRG_BASED)
#define VSPRINTF_CHARSTAR
#endif
return (__rec_open(fname, flags & USE_OPEN_FLAGS,
mode, openinfo, flags & DB_FLAGS));
*/
+ default:
+ break;
}
errno = EINVAL;
return (NULL);
#include <sys/types.h>
#include <sys/stat.h>
+#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
static int _gettemp();
-mkstemp(path)
+int mkstemp(path)
char *path;
{
int fd;
return(_gettemp(path, (int *)NULL) ? path : (char *)NULL);
}
-static
+static int
_gettemp(path, doopen)
char *path;
register int *doopen;
* If asking for a specific page that is already in the cache, find
* it and return it.
*/
- if (b = mpool_look(mp, pgno)) {
+ if ((b = mpool_look(mp, pgno))) {
#ifdef STATISTICS
++mp->pageget;
#endif
#include <compat.h>
#include <string.h>
+#include <stdio.h>
#ifdef __STDC__
#include <stdarg.h>
#endif
{
va_list ap;
+#ifdef VSPRINTF_CHARSTAR
char *rp;
+#else
int rval;
+#endif
+
#ifdef __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
+
#ifdef VSPRINTF_CHARSTAR
- rp = (char*)(size_t)vsprintf(str, fmt, ap);
+ rp = (char*)(size_t)vsnprintf(str, n, fmt, ap);
va_end(ap);
return (strlen(rp));
#else
- rval = vsprintf(str, fmt, ap);
+ rval = vsnprintf(str, n, fmt, ap);
va_end(ap);
return (rval);
#endif
}
+#if 0
int
vsnprintf(str, n, fmt, ap)
char *str;
va_list ap;
{
#ifdef VSPRINTF_CHARSTAR
- return (strlen((char*)(size_t)vsprintf(str, fmt, ap)));
+ return (strlen((char*)(size_t)vsnprintf(str, fmt, ap)));
#else
- return (vsprintf(str, fmt, ap));
+ return (vsnprintf(str, fmt, ap));
#endif
}
+#endif
public:
ostring* word;
int bits;
- unsigned int code;
unsigned int freq;
+ unsigned int code;
htr_node* leaf_htr_node;
public:
heap htr_node_set(htr_eq, htr_ls, cts);
htr_node* x ;
- for (int i=0; i<cts; i++ ) {
+ for (unsigned int i=0; i<cts; i++ ) {
if ( e_units[i] ) {
x = new htr_node(e_units[i]);
e_units[i] -> leaf_htr_node = x;
htr_node* x ;
htr_node* parent;
- for (int i=0; i<cts; i++ ) {
+ for (unsigned int i=0; i<cts; i++ ) {
if ( e_units[i] == 0 )
continue;
x = parent;
e_units[i] -> bits++;
- if ( e_units[i] -> bits > BITS_IN(unsigned long) ) {
+ if ( e_units[i] -> bits > (int) BITS_IN(unsigned long) ) {
debug(cerr, e_units[i] -> bits);
throw(stringException("huffman tree too deep"));
}
unsigned long total_uncmp = 0;
unsigned long int total_cmp = 0;
- for (int i=0; i<cts; i++ ) {
+ for (unsigned int i=0; i<cts; i++ ) {
if ( e_units[i] == 0 )
continue;
//MESSAGE(cerr, "huff::cdrOut");
//debug(cerr, my_oid());
static buffer v_out_buf(LBUFSIZ);
- int i;
+ unsigned int i;
if ( cts > 0 ) {
//MESSAGE(cerr, "huff::cdrOut: dict out");
unsigned int word_freq;
//ostring *z = 0;
- for ( int i=0; i<cts; i++ ) {
+ for ( unsigned int i=0; i<cts; i++ ) {
v_in_buf.get(word_sz);
v_in_buf.get(word_buf, int(word_sz));
class htr_node
{
public:
- htr_node* parent;
htr_node* left;
htr_node* right;
- unsigned long freq;
encoding_unit* eu;
+ unsigned long freq;
+ htr_node* parent;
public:
htr_node(encoding_unit* eu, htr_node* lt = 0, htr_node* rt = 0);
{
protected:
- htr_node* htr_root;
encoding_unit** e_units;
- trie* tri;
unsigned int cts ;
+ trie* tri;
+ htr_node* htr_root;
protected:
void build_tree();
static ps_state_type ps_get_previous_state ps_PROTO(( void ));
static ps_state_type ps_try_NUL_trans ps_PROTO(( ps_state_type current_state ));
static int ps_get_next_buffer ps_PROTO(( void ));
+#if 0
static void psunput ps_PROTO(( ps_CHAR c, ps_CHAR *buf_ptr ));
+#endif
void psrestart ps_PROTO(( FILE *input_file ));
void ps_switch_to_buffer ps_PROTO(( ps_BUFFER_STATE new_buffer ));
void ps_load_buffer_state ps_PROTO(( void ));
}
+#if 0
#ifdef ps_USE_PROTOS
static void psunput( ps_CHAR c, register ps_CHAR *ps_bp )
#else
*/
ps_DO_BEFORE_ACTION; /* set up pstext again */
}
+#endif
#ifdef __cplusplus
static sgml_state_type sgml_get_previous_state sgml_PROTO(( void ));
static sgml_state_type sgml_try_NUL_trans sgml_PROTO(( sgml_state_type current_state ));
static int sgml_get_next_buffer sgml_PROTO(( void ));
+#if 0
static void sgmlunput sgml_PROTO(( sgml_CHAR c, sgml_CHAR *buf_ptr ));
+#endif
void sgmlrestart sgml_PROTO(( FILE *input_file ));
void sgml_switch_to_buffer sgml_PROTO(( sgml_BUFFER_STATE new_buffer ));
void sgml_load_buffer_state sgml_PROTO(( void ));
}
+#if 0
#ifdef sgml_USE_PROTOS
static void sgmlunput( sgml_CHAR c, register sgml_CHAR *sgml_bp )
#else
*/
sgml_DO_BEFORE_ACTION; /* set up sgmltext again */
}
+#endif
#ifdef __cplusplus
delete root;
delete sorted_freqs;
- for ( int i=0; i<alphabet_sz; i++ )
+ for ( unsigned int i=0; i<alphabet_sz; i++ )
delete alphabet[i];
delete alphabet;
void trie::extend_alphabet()
{
- if ( alphabet_sz >= estimated_sz ) {
+ if ( (int) alphabet_sz >= estimated_sz ) {
encoding_unitPtr* new_alphabet = new encoding_unitPtr[2* estimated_sz];
for ( int k=0; k< estimated_sz; k++ ) {
// cerr << word[k];
//cerr << "\n";
- static int j, level = 0;
+ static int j;
static trie_node* x = 0;
static trie_node_info* y = 0;
- static char buf[1];
- static ostring *z;
-
if ( root == 0 )
root = new trie_node(0);
{
protected:
+ trie_node* root;
int max_trie_level;
int total_nodes;
int level_sz[MAX_LEVELS];
- trie_node* root;
heap* sorted_freqs;
- int estimated_sz;
encoding_unit** alphabet;
unsigned int alphabet_sz;
+ int estimated_sz;
protected:
void collect_freqs(trie_node* rt, int level);
out.close();
ret = system(form("gzip -c %s > %s", (char*)UNCOMPRESSED,(char*)COMPRESSED));
+ if(ret != 0) throw(systemException(ret));
fstream in(COMPRESSED, ios::in);
out.close();
ret = system(form("gzip -cd %s > %s",(char*)COMPRESSED,(char*)UNCOMPRESSED));
+ if(ret != 0) throw(systemException(ret));
fstream in(UNCOMPRESSED, ios::in);
protected:
int v_buckets;
- disk_bucket* v_cached_bucket_ptr;
page_storage* v_key_store;
+ disk_bucket* v_cached_bucket_ptr;
};
typedef bucket_array* bucket_arrayPtr;
page* bucket_page();
protected:
+ int v_bucket_num;
+ page_storage* v_key_store;
+
Boolean v_overflowed;
//unsigned int v_k;
//unsigned int v_r;
- int v_bucket_num;
- page_storage* v_key_store;
buffer& buf;
};
init_params(prime, expected_n);
bucket_vector = new bucket_array(M+v, store);
- hash_vector = new void_ptr_array(2*MAX(expected_n, n));
+ hash_vector = new void_ptr_array(2*MAX(expected_n, (int) n));
k_vector = new void_ptr_array(M+v);
r_vector = new void_ptr_array(M+v);
{
//MESSAGE(cerr, "REHASH:");
char tmp_name[PATHSIZ];
- sprintf(tmp_name, "%s.tmp", key_store -> my_name());
+ snprintf(tmp_name, sizeof(tmp_name), "%s.tmp", key_store -> my_name());
fstream pool(form("%s/%s", key_store -> my_path(), tmp_name),
ios::in | ios::out
//MESSAGE(cerr, "INSERT to overflow buckets");
//debug(cerr, hash);
- for ( hash %= v; hash < v; hash++ ) {
+ for ( hash %= v; hash < (int) v; hash++ ) {
disk_bucket& overflowb = bucket_vector -> get_bucket(hash+M);
if ( b -> overflow() == true ) {
- for ( hash %= v; hash<v; hash++ ) {
+ for ( hash %= v; hash < (int) v; hash++ ) {
b = &bucket_vector -> get_bucket(hash+M);
void disk_hash::next_bucket(int& ind)
{
- ind = ( ind >= M+v-1 ) ? -1 : (ind+1);
+ ind = ( ind >= (int)(M+v-1) ) ? -1 : (ind+1);
}
unsigned int k; // parameter used in the 1st level hash function
unsigned int p; // prime number p
- //unsigned int n; // current key set size
+ unsigned int n; // current key set size
bucket_array* bucket_vector; // bucket array
//**************************************************************
-bset::bset(cmp_func_ptr_t eq, cmp_func_ptr_t ls): v_setroot(0), set(eq, ls)
+bset::bset(cmp_func_ptr_t eq, cmp_func_ptr_t ls): set(eq, ls), v_setroot(0)
{
//assert ( eq && ls );
}
long last(); // 0 if the list is empty
protected:
+ int v_ct; // cell in the list
dlist_cell *v_head; // head pointer
dlist_cell *v_tail; // tail pointer
- int v_ct; // cell in the list
int remove_cells_when_done;
};
Boolean heap::insert(voidPtr elm)
{
- if ( buf_sz() < content_sz() + 2*sizeof(voidPtr) )
+ if ( buf_sz() < (int)(content_sz() + 2*sizeof(voidPtr)) )
buffer::expand_chunk(2*buf_sz()) ;
long x = long(elm);
long last(); // 0 if the list is empty
protected:
+ int v_ct; // cell in the list
slist_cell *v_head; // head pointer
slist_cell *v_tail; // tail pointer
- int v_ct; // cell in the list
};
void token_stack::add_partial_token(char* x)
{
- if ( v_curr_token_buf -> remaining_sz() < strlen(x) + 1) {
+ if ( v_curr_token_buf -> remaining_sz() < (int)(strlen(x) + 1) ) {
int partial_str_len = curr_token_start ? strlen(curr_token_start) : 0;
template <class T>
CC_Boolean CC_TPtrDlistIterator<T>::operator+=(size_t n)
{
- for ( int i = 0; i < n ; i++ ) {
+ for ( size_t i = 0; i < n ; i++ ) {
if ( !(++(*this)) ) {
return (FALSE);
}
T *CC_TPtrSlist<T>::removeAt(size_t pos) {
CC_TPtrSlistIterator<T> iter( *this );
- for( int i = 0; i <= pos; i++ ) {
+ for( size_t i = 0; i <= pos; i++ ) {
if ( !(++iter) ) {
throw(CASTCCBEXCEPT ccBoundaryException(0,0,i));
}
CC_TPtrSlist(const CC_TPtrSlist<T> &);
CC_TPtrSlist() { destructed = FALSE; }
- ~CC_TPtrSlist();
+ virtual ~CC_TPtrSlist();
virtual void clearAndDestroy();
virtual void clear(); /* clear only removes item, but not calling
{
// Hack to get it passed to iter
CC_TPtrSlistIterator<T> iter( *(CC_TPtrSlist<T> *)this );
- for ( int i = 0; i <=pos; i++ ) {
+ for ( size_t i = 0; i <=pos; i++ ) {
if ( !(++iter) ) {
throw(CASTCCBEXCEPT ccBoundaryException(0,0,i));
}
CC_Boolean get_destructed() const
{ return (destructed); }
- CC_Boolean set_destructed(CC_Boolean what)
+ void set_destructed(CC_Boolean what)
{ destructed = what; }
};
CC_String (const char *string)
{
- f_string = new char[strlen(string) + 1];
- strcpy (f_string, string);
+ int len = strlen(string);
+ f_string = new char[len + 1];
+ *((char *) memcpy(f_string, string, len) + len) = '\0';
}
CC_String()
//--------------------------------------------------------------
CC_Tokenizer::CC_Tokenizer( const CC_String &s )
{
- str_ = new char [s.length()+1];
- strcpy(str_, s.data() );
+ int len = s.length();
+ str_ = new char [len + 1];
+ *((char *) memcpy(str_, s.data(), len) + len) = '\0';
current_ptr = str_;
touched = FALSE;
}
CC_TPtrSlist<kv_pair<K, V> > * b = 0;
kv_pair<K, V> * r = 0;
- for (int i=0; i<f_buckets.length(); i++ ) {
+ for (size_t i=0; i<f_buckets.length(); i++ ) {
b = f_buckets[i];
CC_TPtrSlist<kv_pair<K, V> >* b = 0;
- for (int i=0; i<f_buckets.length(); i++ ) {
+ for (size_t i=0; i<f_buckets.length(); i++ ) {
b = f_buckets[i];
if ( b ) {
friend class hashTableIterator<K, V>;
protected:
- pointer_vector<CC_TPtrSlist<kv_pair<K, V> > > f_buckets;
unsigned (*f_hash_func_ptr)(const K&);
+ pointer_vector<CC_TPtrSlist<kv_pair<K, V> > > f_buckets;
size_t f_items;
protected:
{
// Hack to get it passed to iter
CC_TPtrSlistIterator<T> iter( *(CC_TPtrSlist<T> *)this );
- for ( int i = 0; i <=pos; i++ ) {
+ for ( size_t i = 0; i <=pos; i++ ) {
if ( !(++iter) ) {
throw(CASTCCBEXCEPT ccBoundaryException(0,0,i));
}
pointer_vector<T>::pointer_vector(size_t n, T* t)
: f_array(new Tptr[n]), f_size(n), f_items(0)
{
- for ( int i=0; i<f_size; i++ )
+ for ( size_t i=0; i<f_size; i++ )
f_array[i] = t;
}
template <class T>
T* pointer_vector<T>::operator[](ptrdiff_t i) const
{
- if ( i<0 || i>= f_size )
+ if ( i < 0 || i >= (ptrdiff_t)f_size )
throw(CASTCCBEXCEPT ccBoundaryException(0, f_size-1, i));
else
return f_array[i];
template <class T>
T*& pointer_vector<T>::operator[](ptrdiff_t i)
{
- if ( i<0 || i>= f_size )
+ if ( i < 0 || i >= (ptrdiff_t)f_size )
throw(CASTCCBEXCEPT ccBoundaryException(0, f_size-1, i));
else
return f_array[i];
#define TRUE 1
#define FALSE 0
+#undef MIN
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
+
#endif
// /////////////////////////////////////////////////////////////////
Exception::Exception()
-: f_line(0), f_thrown_as_pointer(1), f_thrown(0), f_temporary(0)
+: f_thrown(0), f_thrown_as_pointer(1), f_temporary(0), f_line(0)
{
PRINTF (("Constructed Exception obj @ %p\n", this));
}
void *
Exception::operator new (size_t size, int)
{
- if (g_next_avail + size <= g_temp_space + G_TEMP_SPACE_SIZE)
- {
- void *p = g_next_avail;
- g_next_avail += size;
- PRINTF (("Allocate EXC @ %p, size = %ld\n", p, (long)size));
- return (p);
- }
- else
+ if (g_next_avail + size > g_temp_space + G_TEMP_SPACE_SIZE)
{
Exceptions::error (Exceptions::f_msg_out_of_exception_memory,
Exceptions::INTERNAL_ERROR);
terminate();
}
+
+ void *p = g_next_avail;
+ g_next_avail += size;
+ PRINTF (("Allocate EXC @ %p, size = %ld\n", p, (long)size));
+ return (p);
}
PRINTF ((" var part is <%s>\n", type));
// See if one's a pointer and the other isn't.
- if (*type == '*' && !f_thrown_as_pointer ||
- *type != '*' && f_thrown_as_pointer)
+ if ((*type == '*' && !f_thrown_as_pointer) ||
+ (*type != '*' && f_thrown_as_pointer))
return (0);
// Otherwise they are either both pointers or both objects/references.
return (1);
void
Exceptions::error (const char *message, error_type_t error_type)
{
- static char buffer[3][100];
+ unsigned int bufferlen = 100;
+ char buffer[3][bufferlen];
static char *lines[3] = { buffer[0], buffer[1], buffer[2] };
- int count = 0;
-
- if (error_type == INTERNAL_ERROR)
- strcpy (buffer[count++], f_msg_internal_error);
- else if (error_type == APPLICATION_ERROR)
- strcpy (buffer[count++], f_msg_application_error);
- else
- strcpy (buffer[count++], f_msg_throw_message);
+ int len, count = 0;
+
+ if (error_type == INTERNAL_ERROR) {
+ len = MIN(strlen(f_msg_internal_error), bufferlen - 1);
+ *((char *) memcpy(buffer[count++], f_msg_internal_error, len) + len) = '\0';
+ }
+ else if (error_type == APPLICATION_ERROR) {
+ len = MIN(strlen(f_msg_application_error), bufferlen - 1);
+ *((char *) memcpy(buffer[count++], f_msg_application_error,len)+len) = '\0';
+ }
+ else {
+ len = MIN(strlen(f_msg_throw_message), bufferlen - 1);
+ *((char *) memcpy(buffer[count++], f_msg_throw_message, len) + len) = '\0';
+ }
// Don't use fprintf because it may try to allocate memory.
if (Exception::g_current_exception != NULL)
{
- sprintf (buffer[count++],
+ snprintf (buffer[count++], bufferlen,
" In exception thrown in file \"%s\", line %d,",
Exception::g_current_exception->f_file,
Exception::g_current_exception->f_line);
}
if (message != NULL)
- sprintf (buffer[count++], " %s", message);
+ snprintf (buffer[count++], bufferlen, " %s", message);
// Call user print function if set, otherwise just dump lines.
if (g_error_handler != NULL)
#define _Exceptions_hh_active
+#undef MIN
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
+
#ifndef C_API
#ifndef NATIVE_EXCEPTIONS
#define NATIVE_EXCEPTIONS
#endif
#endif
+#ifndef UNUSED_VARIABLE
+# if defined(__GNUC__)
+# define UNUSED_VARIABLE(x) x __attribute__((unused))
+# elif defined(__LCLINT__)
+# define UNUSED_VARIABLE(x) /*@unused@*/ x
+# else
+# define UNUSED_VARIABLE(x) x
+# endif
+#endif
+
#endif /* NATIVE_EXCEPTIONS */
#include "terminate.hh"
#define mcatch(TYPE,OBJ) \
mcatch_noarg (TYPE) \
- TYPE OBJ = (TYPE) Exception::current_exception();
+ TYPE UNUSED_VARIABLE(OBJ) = (TYPE) Exception::current_exception();
#define end_try \
} else { \
// /////////////////////////////////////////////////////////////////
Jump_Environment::Jump_Environment()
-: f_unwinding (0), f_active_exception (NULL)
+: f_active_exception (NULL), f_unwinding (0)
{
PRINTF (("<%d> New Jump_Environment @ %p\n", ++g_level, this));
// Push this on to the top of the jump env stack.
{
int sz = strlen(d.key.str_key);
key.str_key = new char[sz+1];
- strcpy(key.str_key, d.key.str_key);
+ *((char *) memcpy(key.str_key, d.key.str_key, sz) + sz) = '\0';
key.str_key[sz] = 0;
flag = STRING;
key.str_key = new char[sz+1];
- if ( sz > 0 )
- strcpy(key.str_key, str);
+ if ( sz > 0 ) {
+ int len = MIN(strlen(str), (unsigned int) sz);
+ *((char *) memcpy(key.str_key, str, len) + len) = '\0';
+ }
key.str_key[sz] = 0;
}
case VOID:
throw(stringException("VOID type in operator==()"));
}
+
+ return 0;
}
data_t& data_t::operator =(data_t& d)
case STRING:
{
- int d_sz = strlen(d.key.str_key);
+ unsigned int d_sz = strlen(d.key.str_key);
if ( strlen(key.str_key) < d_sz ) {
delete key.str_key;
key.str_key = new char[d_sz+1];
}
- strcpy(key.str_key, d.key.str_key);
- key.str_key[d_sz] = 0;
+ *((char *) memcpy(key.str_key, d.key.str_key, d_sz) + d_sz) = '\0';
flag = STRING;
break;
}
if ( d.flag == data_t::STRING ) {
int sz = strlen(key_ptr);
d.key.str_key = new char[sz+1];
- strcpy(d.key.str_key, key_ptr);
- d.key.str_key[sz] = 0;
+ *((char *) memcpy(d.key.str_key, key_ptr, sz) + sz) = '\0';
}
return i;
case data_t::STRING:
o << d.key.str_key;
break;
+ default:
+ break;
}
o << " " << (long)(d.dt);
public:
enum flag_type { INT=0, STRING=1, VOID=2 };
+ voidPtr dt; // rest of information in the record
flag_type flag;
union {
int int_key;
char* str_key;
} key;
- voidPtr dt; // rest of information in the record
data_t(): dt(0), flag(data_t::VOID) {} ;
data_t(data_t&) ;
int k; // parameter used in the 1st level hash function
int p; // prime number p
- int n; // current key set size
int H; // current hash table size
int B; // current bucket table size
+ int n; // current key set size
- data_tPtr* hash_table; // the hash table
imp_bucketPtr* bucket_array; // bucket array
+ data_tPtr* hash_table; // the hash table
bucket_holder* free_list_head ; // free bucket holder list head
bucket_holder* collected_records; // collected bucket list head
{
char* x = 0;
+ int len;
switch (copy) {
case true:
- x = new char[strlen(key)+1];
- strcpy(x, key);
- x[strlen(key)] = 0;
+ len = strlen(key);
+ x = new char[len + 1];
+ *((char *) memcpy(x, key, len) + len) = '\0';
break;
case false:
x = key;
int bucket::add_key(char* key, Boolean copy)
{
char *x = 0;
+ int len;
switch (copy) {
case true:
- x = new char[strlen(key)+1];
- strcpy(x, key);
- x[strlen(key)] = 0;
+ len = strlen(key);
+ x = new char[len + 1];
+ *((char *) memcpy(x, key, len) + len) = '\0';
break;
case false:
x = key;
{
v_bucket_array = new bucketPtr[v_no_buckets];
- int i;
- for ( i=0; i<v_no_buckets; v_bucket_array[i++] = 0);
+ unsigned int i;
+ for ( i=0; i < (unsigned int) v_no_buckets; v_bucket_array[i++] = 0);
//debug(cerr, pms);
//debug(cerr, sum);
- if ( sum < pms.v_p1 ) {
+ if ( sum < (int) pms.v_p1 ) {
sum %= pms.v_p2;
} else {
sum %= (pms.v_b - pms.v_p2);
protected:
short v_no_keys;
- int v_orig_pos;
+ int v_count;
int v_control_bit;
int v_g_value;
- int v_count;
+ int v_orig_pos;
slist_void_ptr_cell* key_ptr;
friend class buckets;
int compact(buckets& bs, unsigned s[], int t, Boolean swap)
{
int target, k, i, remaining_bits, branch;
- unsigned unsigned_g, high_part_bits, lower_part_bits;
+ unsigned unsigned_g, high_part_bits;
+ unsigned lower_part_bits = 0;
remaining_bits = BITS_IN(unsigned);
k = target = 0;
branch = 0;
} else {
high_part_bits = getbits(unsigned_g,t,remaining_bits);
- lower_part_bits = unsigned_g & ~(~0 << t-remaining_bits);
+ lower_part_bits = unsigned_g & ~(~0 << (t-remaining_bits));
lower_part_bits <<= (BITS_IN(unsigned)- (t-remaining_bits));
s[k++] = target | high_part_bits;
void params::select_value(float bts)
{
- int i;
+ unsigned int i;
for ( i=0; ; i++ ) {
- if ( v_n <= partition_tbl[i].upper_bound )
+ if ( (int)v_n <= partition_tbl[i].upper_bound )
break;
}
my_oid().asciiOut(oid_t_out);
*/
- abs_storage* x = get_store();
+ get_store();
fstream out(
form("%s.%s", storage_ptr->my_path(), storage_ptr->my_name()),
ios::out
int fast_mphf::hashTo(const key_type& k)
{
+ unsigned int i;
+
if ( v_long_string_core_indexed == false ) {
v_long_string_core_indexed = true;
}
throw(stringException("hash table empty"));
}
- int i = v_tbl0 -> atoi(k.get(), k.size(), r, v_key_set_sz); // for halmphf
+ i = v_tbl0 -> atoi(k.get(), k.size(), r, v_key_set_sz); // for halmphf
if ( i < v_p1 ) {
int fast_mphf::gValue(int i, int& gvalue, int& ctl_bit)
{
- if ( !INRANGE(i, 0, v_no_ps-1) ) {
+ if ( !INRANGE(i, 0, (int) v_no_ps-1) ) {
throw(boundaryException(0, v_no_ps-1, i));
}
}
char *hash_table = new char[v_hash_tbl_sz];
- for (int i = 0; i < v_hash_tbl_sz; hash_table[i++] = 0 );
+ for (unsigned int i = 0; i < v_hash_tbl_sz; hash_table[i++] = 0 );
ostring lbuf(LBUFSIZ);
void fast_mphf::print_gvalues(ostream& out)
{
int gv, cbit;
- for (int i = 0; i<v_no_ps; i++ ) {
+ for (unsigned int i = 0; i<v_no_ps; i++ ) {
out << i;
gValue(i, gv, cbit);
out << " " << gv << " " << cbit << "\n";
int fast_mphf::print_bits(unsigned x, ostream& out)
{
- for ( int i=0; i<8*sizeof(unsigned); i++ ) {
+ for ( unsigned int i=0; i<8*sizeof(unsigned); i++ ) {
if ( BIT_TEST(x, 0x80000000) )
out << "1";
else
Boolean c_index::get_key_string(const handler& t) const
{
- ostringstream out(v_static_key.get());
+ ostringstream out;
+ int len;
((handler&)t) -> asciiOut(out);
- v_static_key.set_size(out.str().size());
- strcpy(v_static_key.get(), out.str().c_str());
+ len = out.str().size();
+ v_static_key.set_size(len);
+ *((char *) memcpy(v_static_key.get(), out.str().c_str(), len) + len) = '\0';
return true;
}
Boolean c_index::get_key_string(const oid_t& t) const
{
v_static_key.reset();
+ int len;
ostringstream out(v_static_key.get());
t.asciiOut(out);
- v_static_key.set_size(out.str().size());
- strcpy(v_static_key.get(), out.str().c_str());
+ len = out.str().size();
+ v_static_key.set_size(len);
+ *((char *) memcpy(v_static_key.get(), out.str().c_str(), len) + len) = '\0';
return true;
}
void inv_lists::insert_to_list(int index, oid_t& id)
{
- if ( !INRANGE(index, 1, v_sz) ) {
+ if ( !INRANGE(index, 1, (int) v_sz) ) {
throw(boundaryException(1, v_sz, index));
}
{
char c ;
char* ptr = m.get();
- int count = m.size();
Boolean read_marks = false;
while ( in && in.get(c) ) {
*/
- if ( len < CLASS_CODE_BYTES || z == 0 )
+ if ( len < (int) CLASS_CODE_BYTES || z == 0 )
throw(stringException("_peek_obj(): corrupted data"));
c_code_t class_code;
object_template -> set_cdr_size(cdr_io_buf.content_sz());
}
- int cdr_sz = object_template -> get_cdr_size();
-
/////////////////
// safety check
/////////////////
#ifdef DEBUG
+ int cdr_sz = object_template -> get_cdr_size();
+
if ( obj_len != cdr_sz ) {
debug(cerr, obj_len);
debug(cerr, cdr_sz);
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <ctype.h>
#ifdef SVR4
#include <sys/systeminfo.h>
const char *
unique_id (void)
{
- static unsigned int info[4];
static char buf[16];
static unsigned int hostid;
static struct timeval cur_time, old_time;
printf ("%2d 0x%02x ", i, ch);
PRINT_BITS (ch);
#endif
- buf[i] = mapping[buf[i]];
+ buf[i] = mapping[(int)buf[i]];
}
} while (!isalnum (buf[0]));
void composite::next(int& index) const
{
- if INRANGE( index, 1, v_sz - 1 )
+ if INRANGE( index, 1, (int) v_sz - 1 )
index ++;
else
index = 0;
oid_t compress_agent_id;
- unsigned int v_uncompressed_sz;
-
compress_agent_handler* agent;
+ unsigned int v_uncompressed_sz;
+
protected:
void _compress();
oid_list_handler* cset::get_locs(handler& query, int index)
{
- if ( !INRANGE(index, 0, num_indices-1) ) {
+ if ( !INRANGE(index, 0, (int) num_indices-1) ) {
MESSAGE(cerr, "cset::get_locs(): invalid index");
throw(boundaryException(0, num_indices-1, index));
}
oid_t cset::get_first_oid(const handler& query, int index)
{
- if ( !INRANGE(index, 0, num_indices-1) ) {
+ if ( !INRANGE(index, 0, (int) num_indices-1) ) {
MESSAGE(cerr, "cset::get_first_oid(): invalid index");
throw(boundaryException(0, num_indices-1, index));
}
c_index_handler* cset::get_index_ptr(int index)
{
- if ( !INRANGE(index, 0, num_indices-1) ) {
+ if ( !INRANGE(index, 0, (int) num_indices-1) ) {
MESSAGE(cerr, "cset::get_index_ptr(): invalid index");
throw(boundaryException(0, num_indices-1, index));
}
void cset::batch_index_begin()
{
- for ( int i=0; i<num_indices; i++ ) {
+ for ( unsigned int i=0; i<num_indices; i++ ) {
if ( indices[i] != 0 ) {
(*indices[i]) -> batch_index_begin();
}
void cset::batch_index_end()
{
- for ( int i=0; i<num_indices; i++ ) {
+ for ( unsigned int i=0; i<num_indices; i++ ) {
if ( indices[i] != 0 ) {
(*indices[i]) -> batch_index_end();
}
#endif
}
- for ( int i = 1; i < num_indices; i++ ) {
+ for ( unsigned int i = 1; i < num_indices; i++ ) {
if ( indices[i] == 0 )
continue;
{
handler* x = new handler(x_oid, storage_ptr);
- for ( int i = 1; i < num_indices; i++ ) {
+ for ( unsigned int i = 1; i < num_indices; i++ ) {
if ( indices[i] == 0 )
continue;
oid_t& main_obj_oid)
{
- if ( !INRANGE(index, 1, num_indices-1) ) {
+ if ( !INRANGE(index, 1, (int) num_indices-1) ) {
throw(boundaryException(1, num_indices-1, index));
}
void cset::commit()
{
- for ( int i = 1; i < num_indices; i++ ) {
+ for ( unsigned int i = 1; i < num_indices; i++ ) {
if ( indices[i] )
indices[i] -> commit();
oid_list_handler* dl_list::get_locs(handler& query, int index)
{
- if ( !INRANGE(index, 0, v_num_indices-1) )
+ if ( !INRANGE(index, 0, (int) v_num_indices-1) )
throw(boundaryException(0, v_num_indices-1, index));
if ( v_indices[index] == 0 )
oid_t* cell_ptr = &v_dl_list_head;
- for ( int i=1; i<=v_sz; i++ ) {
+ for ( unsigned int i=1; i<=v_sz; i++ ) {
if ( cell_ptr == 0 ) {
throw(stringException("broken chain"));
void dl_list::batch_index_begin()
{
- for ( int i=0; i<v_num_indices; i++ ) {
+ for ( unsigned int i=0; i<v_num_indices; i++ ) {
if ( v_indices[i] != 0 ) {
(*v_indices[i]) -> batch_index_begin();
}
void dl_list::batch_index_end()
{
- for ( int i=0; i<v_num_indices; i++ ) {
+ for ( unsigned int i=0; i<v_num_indices; i++ ) {
if ( v_indices[i] != 0 ) {
(*v_indices[i]) -> batch_index_end();
}
}
- for ( int i = 1; i < v_num_indices; i++ ) {
+ for ( unsigned int i = 1; i < v_num_indices; i++ ) {
if ( v_indices[i] == 0 ) continue;
oid_t dl_list::get_first_oid(const handler& query, int index)
{
- if ( !INRANGE(index, 0, v_num_indices-1) ) {
+ if ( !INRANGE(index, 0, (int) v_num_indices-1) ) {
MESSAGE(cerr, "cset::get_first_oid(): invalid index");
throw(boundaryException(0, v_num_indices-1, index));
}
void dl_list::commit()
{
- for ( int i = 1; i < v_num_indices; i++ )
+ for ( unsigned int i = 1; i < v_num_indices; i++ )
{
if ( v_indices[i] )
v_indices[i] -> commit() ;
//static memory_pool handler_space_pool;
protected:
- rootPtr obj_ptr;
abs_storage* store;
oid_t obj_id;
+ rootPtr obj_ptr;
};
//debug(cerr, right);
//debug(cerr, int(v_str_ptr.loc));
- if ( left > right || right - left > v_sz ) {
+ if ( left > right || right - left > (int) v_sz ) {
throw(boundaryException(left, right, v_sz));
}
list_ptr.loc = 0;
init_data_member(x.v_sz);
- for ( int i=1; i<=v_sz; i++ )
+ for ( unsigned int i=1; i<=v_sz; i++ )
update_component(i, x(i));
}
debug(cerr, int(list_ptr.p));
*/
- if ( !INRANGE(ind, 1, v_sz) ) {
+ if ( !INRANGE(ind, 1, (int) v_sz) ) {
MESSAGE(cerr, "oid_list::opeartor(): out of range");
throw(boundaryException(1, v_sz, ind));
}
{
//MESSAGE(cerr, "oid_list::update_component()");
//debug(cerr, my_oid());
- if ( !INRANGE(index, 1, v_sz) ) {
+ if ( !INRANGE(index, 1, (int) v_sz) ) {
MESSAGE(cerr, "oid_list update(): out of range");
throw(boundaryException(1, v_sz, index));
}
if ( in.get() != '\n' )
throw(formatException("should be a \n"));
- handler* hd_ptr = 0;
-
dlist temp_list;
dlist_void_ptr_cell* y = 0;
class oid_list: public composite
{
protected:
- chunks_index* chk_index;
Boolean f_internal_index;
+ chunks_index* chk_index;
union {
mmdb_pos_t loc;
/*
MESSAGE(cerr, "constr oid_t using a string");
-debug(cerr, c_code);
-debug(cerr, i_code);
+debug(cerr, v_c_code);
+debug(cerr, v_i_code);
*/
}
oid_t(c_code_t c, i_code_t i) : v_c_code(c), v_i_code(i), v_e_code(0) {};
oid_t(const char* source, Boolean ascii_format, Boolean swap_order);
oid_t(const oid_t& x) :
- v_e_code(x.v_e_code), v_c_code(x.v_c_code), v_i_code(x.v_i_code) {};
+ v_c_code(x.v_c_code), v_i_code(x.v_i_code), v_e_code(x.v_e_code) {};
~oid_t() {};
// oid_t equal and less test
}
protected:
- e_code_t v_e_code; // extended code. Not used within this class.
- // for using extra space purpose.
c_code_t v_c_code; // class code
i_code_t v_i_code; // instance code
+ e_code_t v_e_code; // extended code. Not used within this class.
+ // for using extra space purpose.
};
typedef oid_t* oid_tPtr;
out << v_sz << '\t';
- for ( int i=0; i<v_sz; i++ )
+ for ( unsigned int i=0; i<v_sz; i++ )
out << x[i];
return done;
v_str_ptr.p = new char[v_sz+1];
}
memcpy(v_str_ptr.p, new_value, v_sz);
-
+ *(v_str_ptr.p + v_sz) = '\0';
}
set_mode(UPDATE, true);
/***************************/
// instance-wise data
/***************************/
- status_t status;
oid_t f_oid;
+ status_t status;
abs_storage* storage_ptr;
virtual void init_persistent_info(persistent_info* = &transient_info);
handler* short_list::get_component(int index)
{
- if ( !INRANGE(index, 1, v_sz) ) {
+ if ( !INRANGE(index, 1, (int) v_sz) ) {
MESSAGE(cerr, "out of range in short_list::get_component()");
throw(boundaryException(1, v_sz, index));
}
my_oid().asciiOut(out);
out << "\n";
- for ( int i=1; i<=v_sz; i++ ) {
+ for ( unsigned int i=1; i<=v_sz; i++ ) {
handler* hd_ptr = get_component(i);
#ifndef C_API
oid_t oid_buffer[OID_BUFFER_SIZE];
int oid_buffer_level = 0;
+ int ct = 0;
#endif
char c;
- int ct = 0;
while ( (c = in.get()) != LIST_MARK_CHAR ) {
in.putback(c);
//debug(cerr, int(storage_ptr));
- if (!INRANGE(index, 1, v_sz)) {
+ if (!INRANGE(index, 1, (int) v_sz)) {
MESSAGE(cerr, "out of range in tuple::get_component()");
throw( boundaryException(1, v_sz, index) );
}
out << "\n";
// debug(cerr, v_sz);
- for ( int i=1; i<=v_sz; i++ ) {
+ for ( unsigned int i=1; i<=v_sz; i++ ) {
handler* hd_ptr = get_component(i);
throw(stringException("'\\n' expected"));
}
- if ( comps > v_sz ) {
+ if ( comps > (int) v_sz ) {
MESSAGE(cerr, "tuple asciiIn(): to expand space");
debug(cerr, comps);
debug(cerr, v_sz);
if ( strcmp( this_node_locator, locator) == 0 ) {
ostringstream strout(oid_in_string_buf, ios::out);
x.its_oid().asciiOut(strout);
- strcpy(oid_in_string_buf, strout.str().c_str());
+ int len = strout.str().size();
+ *((char *) memcpy(oid_in_string_buf,
+ strout.str().c_str(), len) + len) = '\0';
} else {
cerr << "dangling locator " << locator << "\n"
<< "mismatches with " << this_node_locator << "\n"
void showBook(DtMmdbInfoRequest* req)
{
const char* str = 0;
- int size = 0;
DtMmdbHandle* id = 0;
unsigned int l;
int x ;
ids = DtMmdbBookGetTabList(req, &l);
if (ids) {
- for ( x=0; x<l; x++ )
+ for ( x=0; x<(int)l; x++ )
fprintf(stderr, " bookInfo: tab section id=%s\n", DtMmdbHandleToString(ids[x]));
}
DtMmdbFreeHandleList(ids);
int test_book1(int argc, char** argv)
{
int j = 0;
- int n = 0;
int i = -1;
- const char* str;
DtMmdbInfoRequest* req = 0;
switch ( argc ) {
int test_book2(int argc, char** argv)
{
int j = 0;
- int n = 0;
int i = -1;
- const char* str;
DtMmdbInfoRequest* req = 0;
+
switch ( argc ) {
case 5:
{
int test_book3(int argc, char** argv)
{
int j = 0;
- int n = 0;
int i = -1;
- const char* str;
DtMmdbInfoRequest* req = 0;
+
switch ( argc ) {
case 5:
{
return -1;
}
end_try;
+
+ return -1;
}
static char buf[100];
if ( x -> oid_ptr) {
oid_t *z = (oid_t*)(x -> oid_ptr);
- sprintf(buf, "%d.%d", z -> ccode(), (int)z -> icode());
+ snprintf(buf, sizeof(buf), "%d.%d", z -> ccode(), (int)z -> icode());
} else
buf[0] = 0;
{
int j = 0;
int i = 0;
- const char* str;
DtMmdbInfoRequest* req ;
switch ( argc ) {
{
const char* str;
unsigned int l;
- int i;
+ unsigned int i;
DtMmdbGraphicInfo* info ;
if ( req == 0 ) return ;
{
int j = 0;
int i = 0;
- const char* str;
DtMmdbInfoRequest* req;
switch ( argc ) {
{
int j = 0;
int i = 0;
- const char* str;
DtMmdbInfoRequest* req;
switch ( argc ) {
{
mtry {
- Boolean option = (delayed_infolib_init == DtMmdbTrue) ? true : false;
-
mmdb_ptr = new OLIAS_DB;
info_lib* x = mmdb_ptr -> openInfoLib(infolib_path, selected_base_name);
{
int j = 0;
int i = 0;
- const char* str;
DtMmdbInfoRequest* req;
switch ( argc ) {
{
int j = 0;
int i = 0;
- const char* str;
DtMmdbInfoRequest* req ;
switch ( argc ) {
int test2(int argc, char** argv)
{
int j = 0;
- int n = 0;
int i = -1;
- const char* str;
DtMmdbInfoRequest* req = 0;
switch ( argc ) {
int test3(int argc, char** argv)
{
int j = 0;
- int n = 0;
int i = -1;
- const char* str;
DtMmdbInfoRequest* req = 0;
+
switch ( argc ) {
case 5:
{
{
int j = 0;
int i = 0;
- const char* str;
DtMmdbInfoRequest* req ;
switch ( argc ) {
{
int j = 0;
int i = 0;
- const char* str;
DtMmdbInfoRequest* req ;
switch ( argc ) {
static char buf[100];
if ( x -> oid_ptr) {
oid_t *z = (oid_t*)(x -> oid_ptr);
- sprintf(buf, "%d.%d", z -> ccode(), z -> icode());
+ snprintf(buf, sizeof(buf), "%d.%d", z -> ccode(), z -> icode());
} else
buf[0] = 0;
{
DtMmdbHandle* id = 0;
unsigned int ct = 0;
- int i = 0;
+ unsigned int i = 0;
DtMmdbHandle** ids = 0;
if ( req == 0 ) return ;
{
int j = 0;
int i = 0;
- const char* str;
DtMmdbInfoRequest* req = 0;
switch ( argc ) {
oid_t get_oid(int index);
protected:
- int f_index;
cset_handler* f_set_ptr;
info_base* f_base;
+ int f_index;
};
// iterator over node set
return 0;
}
end_try;
+
+ return 0;
}
int graphic_smart_ptr::type() const
print_graphic(pattern, pattern_out, false);
char loc[BUFSIZ];
- strcpy(loc, pattern.locator());
+ int len = MIN(strlen(pattern.locator()), BUFSIZ -1);
+ *((char *) memcpy(loc, pattern.locator(), len) + len) = '\0';
graphic_smart_ptr x( base_ptr, loc );
char db_buf[LARGE_BUFSIZ];
);
}
- catch (mmdbException &,e)
+ catch (MMDBeXCEPtion &,e)
{
return 0;
} end_try;
int major_mm_version = 0;
int minor_mm_version = 0;
- sprintf(buf, "%s/%s", infoLibPath, MAP_FILE_8_3);
+ snprintf(buf, sizeof(buf), "%s/%s", infoLibPath, MAP_FILE_8_3);
fstream in(buf, ios::in);
while ( in.getline(base_name, PATHSIZ, '\t') ) {
print_node(pattern, pattern_out, false, false);
char loc[BUFSIZ];
- strcpy(loc, pattern.locator());
+ int len = MIN(strlen(pattern.locator()), BUFSIZ - 1);
+ *((char *) memcpy(loc, pattern.locator(), len) + len) = '\0';
node_smart_ptr x( base_ptr, loc );
char db_buf[LARGE_BUFSIZ];
coll_type obj_type = VOID;
abs_storage* store = 0;
- handler* hd = 0;
+// handler* hd = 0;
int i;
for ( i = 0; i<SET_MAP_SZ ; i++ ) {
if ( set_map[i].instance_class_code == ccode ) {
obj_type = SET;
store = set_map[i].collection_hd -> its_store();
- hd = set_map[i].collection_hd;
+// hd = set_map[i].collection_hd;
break;
}
}
if ( list_map[i].instance_class_code == ccode ) {
obj_type = LIST;
store = list_map[i].collection_hd -> its_store();
- hd = set_map[i].collection_hd;
+// hd = set_map[i].collection_hd;
break;
}
}
int stylesheets = x.pick_a_value(5, 20); // assume [5, 20] is the range
char buf[BUFSIZ];
- sprintf(buf, "%s/%s", path, TEST_STY_FILE);
+ snprintf(buf, sizeof(buf), "%s/%s", path, TEST_STY_FILE);
fstream stylesheet_stream(buf, ios::out);
if ( !stylesheet_stream )
cerr << " sections ..." << endl;
- sprintf(buf, "%s/%s", path, TEST_SEC_FILE);
+ snprintf(buf, sizeof(buf), "%s/%s", path, TEST_SEC_FILE);
fstream section_stream(buf, ios::out);
if ( !section_stream ) return -1;
// prepare mixed stream
- sprintf(buf, "%s/%s", path, TEST_MIX_FILE);
+ snprintf(buf, sizeof(buf), "%s/%s", path, TEST_MIX_FILE);
fstream mix_stream(buf, ios::out);
if ( !mix_stream ) return -1;
cerr << " loading stylesheets ..." << endl;
char buf[256];
char file_name[256];
- sprintf(buf, "%s.stylesheet", argv[4]);
- sprintf(file_name, "%s/%s", argv[2], TEST_STY_FILE);
+ snprintf(buf, sizeof(buf), "%s.stylesheet", argv[4]);
+ snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_STY_FILE);
infolib_ptr = db.openInfoLib(argv[2]);
base_ptr = infolib_ptr -> get_info_base(argv[4]);
// load sections (small component)
cerr << " loading sections ..." << endl;
- sprintf(buf, "%s.node", argv[4]);
- sprintf(file_name, "%s/%s", argv[2], TEST_SEC_FILE);
+ snprintf(buf, sizeof(buf), "%s.node", argv[4]);
+ snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_SEC_FILE);
infolib_ptr = db.openInfoLib(argv[2]);
base_ptr = infolib_ptr -> get_info_base(argv[4]);
// load all other objects
cerr << " loading all other objects ..." << endl;
- sprintf(file_name, "%s/%s", argv[2], TEST_MIX_FILE);
+ snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_MIX_FILE);
fstream in(file_name, ios::in);
if ( !in ) return -1;
base_ptr = infolib_ptr -> get_info_base(argv[4]);
// stylesheet
- sprintf(file_name, "%s/%s", argv[2], TEST_STY_FILE);
+ snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_STY_FILE);
fstream ss_in(file_name, ios::in);
if ( !ss_in ) return -1;
STDERR_MESSAGE("testing stylesheet data done\n");
// node
- sprintf(file_name, "%s/%s", argv[2], TEST_SEC_FILE);
+ snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_SEC_FILE);
fstream nd_in(file_name, ios::in);
if ( !nd_in ) return -1;
STDERR_MESSAGE("testing section done\n");
// all other
- sprintf(file_name, "%s/%s", argv[2], TEST_MIX_FILE);
+ snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_MIX_FILE);
fstream all_in(file_name, ios::in);
if ( !all_in ) return -1;
print_stylesheet(pattern, pattern_out);
char loc[BUFSIZ];
- strcpy(loc, pattern.name());
+ int len = MIN(strlen(pattern.name()), BUFSIZ - 1);
+ *((char *) memcpy(loc, pattern.name(), len) + len) = '\0';
stylesheet_smart_ptr x( base_ptr, loc );
char db_buf[LARGE_BUFSIZ];
fstream in(filename, ios::in);
while (in) {
in.getline(buf, LBUFSIZ);
- strcat(st_buf, buf);
+ int slen = strlen(st_buf);
+ int len = MIN(strlen(buf), LBUFSIZ - 1 - slen);
+ *((char *) memcpy(st_buf + slen, buf, len) + len) = '\0';
}
stylesheet_smart_ptr st(base_ptr, locator);
st.update_online_data(st_buf, strlen(st_buf));
extern int g_mode_8_3;
user_base::user_base( const char* spec_path, rw_flag_t rw) :
- spec_name(spec_path), backup_file(0), rw_flag(rw), first_desc_ptr(0),
- base(0)
+ base(0), backup_file(0), rw_flag(rw), first_desc_ptr(0),
+ spec_name(spec_path)
{
g_mode_8_3 = 1;
+ int len;
f_obj_dict = new object_dict;
if ( name == 0 )
name = (char*)"";
- strcpy(base_path, path);
- strcpy(base_name, name);
- strcpy(base_desc, "");
+ len = MIN(strlen(path), PATHSIZ - 1);
+ *((char *) memcpy(base_path, path, len) + len) = '\0';
+ len = MIN(strlen(name), PATHSIZ - 1);
+ *((char *) memcpy(base_name, name, len) + len) = '\0';
+ len = MIN(strlen(""), PATHSIZ - 1);
+ *((char *) memcpy(base_desc, "", len) + len) = '\0';
_init();
const char* spec_path,
rw_flag_t rw
) :
- base(0, 0, 0, base_dir, base_nm, base_ds, ""), first_desc_ptr(0),
- backup_file(0), rw_flag(rw), checking_status(SUCC),
- spec_name(spec_path)
+ base(0, 0, 0, base_dir, base_nm, base_ds, ""), backup_file(0),
+ rw_flag(rw), checking_status(SUCC), first_desc_ptr(0),
+ spec_name(spec_path)
{
g_mode_8_3 = 1;
user_base::checking_status_t user_base::check_lock()
{
char lock_dir[PATHSIZ];
+ int len;
- sprintf(lock_dir, "%s/%s", base_path, LOCK_DIR);
+ snprintf(lock_dir, sizeof(lock_dir), "%s/%s", base_path, LOCK_DIR);
if ( check_and_create_dir(lock_dir) == false ) {
MESSAGE(cerr, form("no write permission to %s", lock_dir));
return user_base::CREATE_LOCKFILE_FAIL;
}
- strcpy(atomic_lock_path, form("%s/%s", lock_dir, AT_LOCK));
- strcpy(write_lock_path, form("%s/%s", lock_dir, W_LOCK));
- strcpy(ai_path, form("%s/%s", lock_dir, ACCESS_INFO));
+ len = MIN(strlen(atomic_lock_path), strlen(lock_dir) + strlen(AT_LOCK) + 1);
+ *((char *) memcpy(atomic_lock_path,
+ form("%s/%s", lock_dir, AT_LOCK), len) + len) = '\0';
+ len = MIN(strlen(write_lock_path), strlen(lock_dir) + strlen(W_LOCK) + 1);
+ *((char *) memcpy(write_lock_path,
+ form("%s/%s", lock_dir, W_LOCK), len) + len) = '\0';
+ len = MIN(strlen(ai_path), strlen(lock_dir) + strlen(ACCESS_INFO) + 1);
+ *((char *) memcpy(ai_path,
+ form("%s/%s", lock_dir, ACCESS_INFO), len) + len) = '\0';
char* ai_info = 0;
Boolean user_base::define()
{
+ int len;
+
if ( check_and_create_dir(base_path) == false ) {
throw(stringException(form("can't create %s", base_path)));
}
char* x = getenv("DTINFO_MARKSPECPATH");
if ( x == 0 ) {
- strcpy(spec_file_path, spec_name);
+ len = MIN(strlen(spec_name), PATHSIZ - 1);
+ *((char *) memcpy(spec_file_path, spec_name, len) + len) = '\0';
}
- else
- strcpy(spec_file_path, form("%s/%s", x, spec_name));
+ else {
+ len = MIN(strlen(x) + strlen(spec_name) + 1, PATHSIZ - 1);
+ *((char *) memcpy(spec_file_path,
+ form("%s/%s", x, spec_name), len) + len) = '\0';
+ }
if (exist_file(spec_file_path) == false) {
/*
char unique_nm[PATHSIZ];
- strcpy(unique_nm, form("%s.%s", base_name, unique_id()));
+ const char* uid;
+ uid = unique_id();
+ len = MIN(strlen(base_name) + strlen(uid) + 1, PATHSIZ - 1);
+ *((char *) memcpy(unique_nm,
+ form("%s.%s", base_name, uid), len) + len) = '\0';
*/
first_desc_ptr =
#include "schema/container_desc.h"
container_desc::container_desc(int code, const char* comment) :
- index_nms(10), stored_object_desc(code, comment)
+ stored_object_desc(code, comment), index_nms(10)
{
}
#include "index/btree_index.h"
-index_desc::index_desc(int class_code, const char* comment) : position(0),
- stored_object_desc(class_code, comment)
+index_desc::index_desc(int class_code, const char* comment) :
+ stored_object_desc(class_code, comment), position(0)
{
inv_nm = strdup("");
agent_nm = strdup("");
{
delete inv_nm;
inv_nm = strdup(str);
-
- //strncpy(inv_nm, str, NAMESIZ-1);
- //inv_nm[strlen(str)] = 0;
}
void index_desc::set_agent_nm(const char* str)
{
delete agent_nm;
agent_nm = strdup(str);
-
- //strncpy(agent_nm, str, NAMESIZ-1);
- //agent_nm[strlen(str)] = 0;
}
ostream& index_desc::asciiOut(ostream& out, Boolean last)
{
//MESSAGE(cerr, "object_dict::init_a_base()");
//debug(cerr, db_path);
- strcpy(v_db_path, db_path);
+
+ int len = MIN(strlen(db_path), PATHSIZ - 1);
+ *((char *) memcpy(v_db_path, db_path, len) + len) = '\0';
desc* x = 0;
x = parse(schema_path);
} else {
- int sz = bytes(schema_path) - strlen(schema_header) - 1;
+ unsigned int sz = bytes(schema_path) - strlen(schema_header) - 1;
char* buf = new char[sz];
if ( !in.read(buf, sz) )
//debug(cerr, db_path);
//debug(cerr, db_name);
- strcpy(v_db_path, db_path);
+ int len;
+
+ len = MIN(strlen(db_path), PATHSIZ - 1);
+ *((char *) memcpy(v_db_path, db_path, len) + len) = '\0';
if ( db_name ) {
- strcpy(replace_string, db_name);
+ len = MIN(strlen(db_name), PATHSIZ - 1);
+ *((char *) memcpy(replace_string, db_name, len) + len) = '\0';
replace_string_len = strlen(replace_string);
} else {
replace_string[0] = 0;
throw(stringException(form("%s does not exist.", define_desc_path)));
}
- unsigned long len = bytes(define_desc_path)*4;
+ unsigned long llen = bytes(define_desc_path)*4;
in_test.close();
- if ( disk_space(v_db_path) < len ) {
+ if ( disk_space(v_db_path) < llen ) {
throw(stringException(form("no enough space on %s", v_db_path)));
}
throw(streamException(in.rdstate()));
}
- int sz = bytes(define_desc_path);
+ unsigned int sz = bytes(define_desc_path);
in.close();
char* schema_buf = new char[sz*3];
x -> asciiOutList(*string_out);
- strcpy(schema_buf, string_out->str().c_str());
+ len = MIN((unsigned int) string_out->str().size(), sz*3 - 1);
+ *((char *) memcpy(schema_buf, string_out->str().c_str(), len) + len) = '\0';
delete string_out;
sz = strlen(schema_buf);
void _quit_descs(desc* start_ptr, desc* end_ptr = 0);
protected:
+ bset v_dict; // name to oid mapping
desc * v_desc_ptr; // list of stored object desc cells
desc * v_last_desc_ptr; // tail cell
char v_db_path[PATHSIZ]; // db_path
- bset v_dict; // name to oid mapping
};
#endif
*/
// $TOG: sheet.C /main/4 1997/12/23 11:20:35 bill $
#ifndef lint
-static char schemasccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
+static const char schemasccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
#endif
#define schemaBYACC 1
* schemassp = schemastate = 0;
schemaloop:
- if ( scheman = schemadefred[ schemastate]) goto schemareduce;
+ if ( (scheman = schemadefred[ schemastate])) goto schemareduce;
if ( schemachar < 0)
{
if (( schemachar = schemalex()) < 0) schemachar = 0;
delete mode_str;
mode_str = strdup(str);
- //strncpy(mode_str, str, NAMESIZ-1);
-
get_mode(); // check
}
int store_desc::get_mode()
{
int mode = 0;
- for ( int i=0; i<strlen(mode_str); i++ ) {
+ for ( unsigned int i=0; i<strlen(mode_str); i++ ) {
switch ( mode_str[i] ) {
case 'r':
mode |= ios::in;
static schema_state_type schema_get_previous_state schema_PROTO(( void ));
static schema_state_type schema_try_NUL_trans schema_PROTO(( schema_state_type current_state ));
static int schema_get_next_buffer schema_PROTO(( void ));
+#if 0
static void schemaunput schema_PROTO(( schema_CHAR c, schema_CHAR *buf_ptr ));
+#endif
void schemarestart schema_PROTO(( FILE *input_file ));
void schema_switch_to_buffer schema_PROTO(( schema_BUFFER_STATE new_buffer ));
void schema_load_buffer_state schema_PROTO(( void ));
case 35:
{
if ( replace_string[0] != 0 && schematext[0] == '$' ) {
- strcpy(replace_string + replace_string_len, (char*) schematext+1);
+ int len = MIN(strlen((char*) schematext+1),
+ (unsigned int)(PATHSIZ - replace_string_len - 1));
+ *((char *) memcpy(replace_string + replace_string_len,
+ (char*) schematext+1, len) + len) = '\0';
schemalval.string = replace_string;
} else
schemalval.string = (char*) schematext;
}
+#if 0
#ifdef schema_USE_PROTOS
static void schemaunput( schema_CHAR c, register schema_CHAR * schema_bp )
#else
*/
schema_DO_BEFORE_ACTION; /* set up schematext again */
}
+#endif
#ifdef __cplusplus
abs_storage::abs_storage( char* file_path, char* file_name,
c_code_t c_id, rep_policy* p ) :
-policy(p), root(c_id), index_num(-1), v_swap_order(false)
+root(c_id), index_num(-1), policy(p), v_swap_order(false)
{
- strcpy(path, file_path);
- strcpy(name, file_name);
+ int len = MIN(strlen(file_path), PATHSIZ - 1);
+ *((char *) memcpy(path, file_path, len) + len) = '\0';
+ len = MIN(strlen(file_name), PATHSIZ - 1);
+ *((char *) memcpy(name, file_name, len) + len) = '\0';
}
abs_storage::~abs_storage()
int left, int right);
protected:
+ bset v_index_imp;
abs_storage* v_storage_ptr;
mmdb_pos_t v_initial_loc;
- bset v_index_imp;
};
replaced = 0;
- Boolean ok = true;
switch (x.get_position()) {
case ACTIVE:
Boolean lru::derank(rep_cell& x, position_t opt)
{
- Boolean ok = true;
-
switch (x.get_position()) {
case ACTIVE:
//MESSAGE(cerr, "active status to derank");
inactive_list.insert_as_tail(&x);
x.set_position(INACTIVE);
break;
+ default:
+ break;
}
return true;
case NOWHERE:
throw(stringException("lru::last(): bad option"));
}
+
+ return false;
}
void lru::remove()
new_blank_len -= size;
//debug(cerr, new_blank_len);
- if ( new_blank_len < 2*SLOT_HEADER_SIZE + 10 )
+ if ( new_blank_len < (int)(2*SLOT_HEADER_SIZE + 10) )
new_blank_len = 0;
else
new_blank_len -= SLOT_HEADER_SIZE; // space allocated for new
void _swap_order(Boolean swap_count_field_first);
protected:
- int num_locks; // no. of locks
- unsigned int pageid ; // page id
+ unsigned int pageid ; // page id
Boolean dirty ; // = false: page has not been written;
+ int num_locks; // no. of locks
int v_memalign_offset; // align offset of the memory
// chunk for this page
{
lru_pagePtr p = 0;
- if ( f_replace_policy.active_elmts() < f_total_allowed_pages ) {
+ if ( f_replace_policy.active_elmts() < (int) f_total_allowed_pages ) {
/*
debug(cerr, page_cache -> active_elmts());
debug(cerr, str_offset);
*/
- Boolean ok = false;
-
buffer in_cache(0);
in_cache.set_chunk(base, len);
debug(cerr, loc);
*/
- int page_num ;
- int slot_num ;
+ int page_num =0;
+ int slot_num =0;
int offset = 0;
page* y = 0;
spointer_t *x = 0;
#endif
- int u1 = PAGE_ID( loc, page_sz );
- int u2 = PAGE_IDX( loc, page_sz );
-//cerr << "Allocated ID=" << u1 << "." << u2 << " " << len << "\n";
+// int u1 = PAGE_ID( loc, page_sz );
+// int u2 = PAGE_IDX( loc, page_sz );
+// cerr << "Allocated ID=" << u1 << "." << u2 << " " << len << "\n";
return 0;
}
- int page_num ;
- int slot_num ;
+ int page_num = 0;
+ int slot_num = 0;
page* y;
spointer_t *x;
{
int ind = first();
while ( ind != 0 ) {
+#ifdef DEBUG
page* p = (*this)(ind, READ);
debug(out, *p);
+#endif
next(ind);
}
return done;
// verify the log is in good shape
//////////////////////////////////
int m;
- int log_bytes = trans_info.log_store -> bytes();
+ unsigned int log_bytes = trans_info.log_store -> bytes();
if ( trans_info.log_store &&
(*trans_info.log_store) &&
protected:
enum trans_t { ENABLED, DISABLED };
- int page_sz;
- int max_pages;
+ char* path;
+ char* name;
+
trans_t status;
unixf_storage* log_store;
imp_die* log_index;
-
- char* path;
- char* name;
+ int max_pages;
+ int page_sz;
public:
store_trans(char* path, char*name, int page_sz);
{
protected:
- buffer* v_buf; // aux. buf.
+ store_trans trans_info;
int page_sz ; // page size
int total_pages;
- int pagings ;
- int total_page_access;
-
- store_trans trans_info;
-
// byte order
int v_server_order;
int v_db_order;
+ buffer* v_buf; // aux. buf.
+
+ int pagings ;
+ int total_page_access;
+
protected:
Boolean seek_loc_negative(mmdb_pos_t& loc, int smd);
header.int_view |= (HEADER_MASK & m);
set_mode(UPDATED, true);
};
- Boolean test_mode(int m) {
+ Boolean test_mode(unsigned int m) {
return ( (header.int_view & HEADER_MASK & m) == m ) ? true : false;
};
unsigned int j, k;
page_storage::access_t l;
- for ( int i=0; i< no_access; i++)
+ for ( unsigned int i=0; i< no_access; i++)
{
j = rand_gen.rand() % ct; // pick the store
page_storage** x = new page_storagePtr[ct];
unixf_storage* unix_file = 0;
- for ( int i=0; i<ct; i++) {
+ for ( unsigned int i=0; i<ct; i++) {
int pages = rand_gen.rand() % (high-low) + low;
/*
pages = 17;
*/
- sprintf(name, "test.%d", i);
+ snprintf(name, sizeof(name), "test.%d", i);
if ( exist_file(name) == true )
del_file(name);
void quit_store(page_storage** st, unsigned int ct)
{
- for ( int i=0; i<ct; i++) {
+ for ( unsigned int i=0; i<ct; i++) {
delete st[i];
}
delete st;
rep_policy* rep_p, int m
) :
abs_storage( file_path, file_name, UNIX_STORAGE_CODE, rep_p ),
-mode(m), fstream(),
+fstream(), mode(m),
total_bytes(-1), v_file_exist(exist_file(file_name, file_path))
{
}
}
if ( v_file_exist == false ) {
- SET_BIT(new_mode, ios::out | ios::app);
+ SET_BIT(new_mode, ios::out | ios::trunc);
v_file_exist = true;
}
#ifndef C_API
{
char fname[64];
- sprintf(fname, "%s.%ld-%d", name, loc+string_ofst, len);
+ snprintf(fname, sizeof(fname), "%s.%ld-%d", name, loc+string_ofst, len);
ofstream output(fname);
output.write(base, len);
output.flush();
{
if ( total_bytes == -1 ) {
- char* info_lib_file = form("%s/%s", path, name);
-
+#ifdef C_API
_open(ios::in);
if ( !good() )
clear();
-#ifdef C_API
total_bytes = ::bytes(rdbuf() -> fd());
#else
+ char* info_lib_file = form("%s/%s", path, name);
+
total_bytes = ::bytes(info_lib_file);
#endif
}
v_tbl = new char[v_entries];
- int i;
- for ( i = 0; i < v_entries; i++ )
+ unsigned int i;
+ for ( unsigned i = 0; i < v_entries; i++ )
v_tbl[i] = i;
for ( i = 0; i < v_entries - 1; i++ ) {
case 0:
break;
case 1:
- reg.chars_val.b1 = v_tbl[string[0]] ;
+ reg.chars_val.b1 = v_tbl[(unsigned int)string[0]] ;
break;
case 2:
- reg.chars_val.b1 = v_tbl[string[0]] ;
- reg.chars_val.b2 = v_tbl[string[1]] ;
+ reg.chars_val.b1 = v_tbl[(unsigned int)string[0]] ;
+ reg.chars_val.b2 = v_tbl[(unsigned int)string[1]] ;
break;
case 3:
- reg.chars_val.b1 = v_tbl[string[0]] ;
- reg.chars_val.b2 = v_tbl[string[1]] ;
- reg.chars_val.b3 = v_tbl[string[2]] ;
+ reg.chars_val.b1 = v_tbl[(unsigned int)string[0]] ;
+ reg.chars_val.b2 = v_tbl[(unsigned int)string[1]] ;
+ reg.chars_val.b3 = v_tbl[(unsigned int)string[2]] ;
break;
default:
- reg.chars_val.b1 = v_tbl[string[0]] ;
- reg.chars_val.b2 = v_tbl[string[1]] ;
- reg.chars_val.b3 = v_tbl[string[2]] ;
- reg.chars_val.b4 = v_tbl[string[3]] ;
+ reg.chars_val.b1 = v_tbl[(unsigned int)string[0]] ;
+ reg.chars_val.b2 = v_tbl[(unsigned int)string[1]] ;
+ reg.chars_val.b3 = v_tbl[(unsigned int)string[2]] ;
+ reg.chars_val.b4 = v_tbl[(unsigned int)string[3]] ;
}
int x = 0;
ostream& operator<<(ostream& s, atoi_fast& p)
{
- for ( int i = 0; i < p.v_entries ; i++ )
+ for ( unsigned int i = 0; i < p.v_entries ; i++ )
s << int(p.v_tbl[i]) << " ";
return s;
}
v_tbl = new char[v_entries];
- int i;
+ unsigned int i;
for ( i = 0; i < v_entries; i++ )
v_tbl[i] = i;
ostream& operator<<(ostream& s, atoi_pearson& p)
{
- for ( int i = 0; i < p.v_entries ; i++ )
+ for ( unsigned int i = 0; i < p.v_entries ; i++ )
s << int(p.v_tbl[i]) << " ";
return s;
}
void init(int _range, int _entries, pm_random&);
protected:
- char *v_tbl;
- Boolean v_shared;
-
- unsigned v_mask;
unsigned int v_entries;
unsigned int v_range;
+ unsigned v_mask;
+
unsigned int v_no_bytes;
+ char *v_tbl;
+ Boolean v_shared;
};
atomic_lock::atomic_lock(const char* p)
{
- strcpy(v_path, p);
+ int len = MIN(strlen(p), PATHSIZ - 1);
+ *((char *) memcpy(v_path, p, len) + len) = '\0';
}
atomic_lock::~atomic_lock()
{
//return put((char*)&content, sizeof(content));
- if ( v_bufsz == content_sz() )
+ if ( (int) v_bufsz == content_sz() )
{
if ( exp_buf == true )
expand_chunk(v_bufsz + 10);
/***********************************************************/
buffer& buffer::put(const char* content, int sz, Boolean exp_buf)
{
- if ( sz > v_bufsz - content_sz() ) {
+ if ( sz > (int)(v_bufsz - content_sz()) ) {
if ( exp_buf == true )
expand_chunk(v_bufsz + sz);
else {
class ios
{
protected:
- int f_state;
streambuf* sbuf; // buffer that provides char sequence read/write
+ int f_state;
public:
protected:
char* base;
char* end;
- char* get_ptr;
char* put_ptr;
+ char* get_ptr;
- int _gcount;
- int _pcount;
-
- int _capacity;
int _size;
+ int _capacity;
int _alloc;
+ int _pcount;
+ int _gcount;
+
protected:
enum notify_action_t { GET, PUT };
virtual void notify(int) {};
/////////////////////////////////////////////
filebuf::filebuf(int __fd) :
- new_pos(0), default_new_pos(0), _fd(__fd), current_pos(0),
- _prev_action(-1), _name(0)
+ _fd(__fd), _prev_action(-1), _name(0),
+ current_pos(0), new_pos(0), default_new_pos(0)
{
_mode = 0;
}
filebuf::filebuf(const char* name, int mode, int protect) :
- new_pos(0), default_new_pos(0), current_pos(0),
- _fd(-1), _prev_action(-1), _name(strdup(name))
+ _fd(-1), _prev_action(-1), _name(strdup(name)),
+ current_pos(0), new_pos(0), default_new_pos(0)
{
open(name, mode, protect);
}
#endif /* __osf__ */
#include <sys/stat.h>
+#define BUFLEN 512
+
#ifdef USL
int _DtMmdbStrcasecmp(register const char* s1, register const char* s2)
{
switch (y) {
- case 8192: return 14;
- case 1024: return 11;
+ case 8192: return 13;
+ case 1024: return 10;
default:
{
//debug(cerr, x);
//debug(cerr, hex(x));
- int i;
- for ( int i =0; i<sizeof(x); i++ ) {
+ unsigned int i;
+ for ( i =0; i<sizeof(x); i++ ) {
if ( ( 0x000000ff & x) == 0 )
x >>= 8;
else
int del_file(const char* filename, const char* pathname)
{
- static char buf[512];
+ unsigned int len, slen;
+ static char buf[BUFLEN];
int ok;
ok = unlink(filename);
else {
- if ( strlen(filename) + strlen(pathname) > 511 )
- throw(boundaryException(1, 512, strlen(filename) + strlen(pathname)));
+ if ( strlen(filename) + strlen(pathname) > (BUFLEN - 1) )
+ throw(boundaryException(1, BUFLEN,
+ strlen(filename) + strlen(pathname)));
buf[0] = 0;
- strcpy(buf, pathname);
- strcat(buf, "/");
- strcat(buf, filename);
+ len = MIN(strlen(pathname), BUFLEN - 1);
+ *((char *) memcpy(buf, pathname, len) + len) = '\0';
+ slen = len;
+ len = MIN(1, BUFLEN - 1 - slen);
+ *((char *) memcpy(buf + slen, "/", len) + len) = '\0';
+ slen += len;
+ len = MIN(strlen(filename), BUFLEN - 1 - slen);
+ *((char *) memcpy(buf + slen, filename, len) + len) = '\0';
ok = unlink(buf);
}
char source[PATHSIZ];
char target[PATHSIZ];
- sprintf(source, "%s/%s.%s", path, file, source_ext);
- sprintf(target, "%s/%s.%s", path, file, target_ext);
+ snprintf(source, sizeof(source), "%s/%s.%s", path, file, source_ext);
+ snprintf(target, sizeof(target), "%s/%s.%s", path, file, target_ext);
return copy_file(source, target) ;
}
static char formbuf[BUFSIZ];
char tempbuf[BUFSIZ];
va_list args;
+ int len;
va_start(args, fmt);
- strcpy(tempbuf, formbuf);
- (void) vsprintf(tempbuf, fmt, args);
+ len = MIN(strlen(formbuf), BUFSIZ - 1);
+ *((char *) memcpy(tempbuf, formbuf, len) + len) = '\0';
+ (void) vsnprintf(tempbuf, sizeof(tempbuf), fmt, args);
va_end(args);
- strcpy(formbuf, tempbuf);
+ len = MIN(strlen(tempbuf), BUFSIZ - 1);
+ *((char *) memcpy(formbuf, tempbuf, len) + len) = '\0';
return formbuf;
}
char* x = time_stamp(&ctime_buf);
x[strlen(x)-1] = 0;
- char userid[L_cuserid];
-
#ifndef SVR4
- sprintf(info_buf, "%s-%s-%ld-%s-%s",
+ snprintf(info_buf, sizeof(info_buf), "%s-%s-%ld-%s-%s",
host_name, dm_name,
/* getenv("USER"), */
(long)getpid(), x, request
);
#else
- sprintf(info_buf, "%s-%s-%ld-%s-%s",
+ char userid[L_cuserid];
+ snprintf(info_buf, sizeof(info_buf), "%s-%s-%ld-%s-%s",
name.nodename,
( cuserid(userid)[0] == 0 ) ? "???" : userid,
/* getenv("USER"), */
Boolean ok = false;
fstream *out = 0;
char* tmp_dir_tbl[4];
+ int len;
tmp_dir_tbl[0] = getenv("TMPDIR");
tmp_dir_tbl[1] = (char*)"/tmp";
tmp_dir_tbl[2] = (char*)"/usr/tmp";
if ( tmp_dir_tbl[i] == 0 )
continue;
- strcpy(unique_nm, form("%s/tmp.%s", tmp_dir_tbl[i], uid));
+ len = MIN(strlen(tmp_dir_tbl[i]) + strlen(uid) + 5, PATHSIZ - 1);
+ *((char *) memcpy(unique_nm,
+ form("%s/tmp.%s", tmp_dir_tbl[i], uid),
+ len) + len) = '\0';
mtry {
//debug(cerr, tmp_dir_tbl[i]);
//debug(cerr, disk_space(tmp_dir_tbl[i]));
- if ( disk_space(tmp_dir_tbl[i]) <= size )
+ if ( disk_space(tmp_dir_tbl[i]) <= (unsigned long) size )
continue;
out = new fstream(unique_nm, ios::out);
#define TOBOOLEAN(x) ( ((x) == 1 ) ? true : false )
#define TOBIT(x) ( ((x) == true ) ? 1 : 0 )
+/* secure XtNewString macro */
+#define XtsNewString(str) \
+ ((str) != NULL ? (char *)(memcpy(XtMalloc((unsigned)strlen(str) + 1), \
+ str, (unsigned)strlen(str) + 1)) : NULL)
+
/* little endian to/from big endian swap macros. */
#ifndef __osf__
char*& ai_info
)
{
- int ret;
+ unsigned int len, slen;
atomic_lock l(lock_file_path);
if ( l.lock() == false ) {
while ( x.getline(buf, BUFSIZ) ) {
if ( buf[0] == 'A' ) {
ok = false;
- strcat(ai_info, buf+1);
- strcat(ai_info, "\n");
+
+ slen = strlen(ai_info);
+ len = MIN(strlen(buf+1), BUFSIZ - 1 - slen);
+ *((char *) memcpy(ai_info + slen, buf+1, len) + len) = '\0';
+
+ slen = strlen(ai_info);
+ len = MIN(1, BUFSIZ - 1 - slen);
+ *((char *) memcpy(ai_info + slen, "\n", len) + len) = '\0';
}
}
/////////////////////////////////////////
// create the access info file
/////////////////////////////////////////
- ret = truncate(ai_path, 0);
+ if(truncate(ai_path, 0) != 0 ) {
+ throw(systemException(errno));
+ }
fstream x(ai_path, ios::out);
x << "A-" << writer_info << "\n";
va_start(args, fmt);
- (void) vsprintf(buf, fmt, args);
+ (void) vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
//enum Boolean { true, false };
-#ifndef __osf__
+#if !defined(__osf__) && !defined(linux) && !defined(CSRG_BASED)
typedef long mmdb_pos_t;
#else
typedef int mmdb_pos_t;