From fbd81ef151e6de4d95d6a13ce802a9a858cbeb27 Mon Sep 17 00:00:00 2001 From: Ulrich Wilkens Date: Wed, 28 Aug 2013 19:16:37 +0200 Subject: [PATCH] dtinfo subdirectory DtMmdb --- cde/programs/dtinfo/DtMmdb/HardCopy/FPset.h | 4 +- .../dtinfo/DtMmdb/HardCopy/HardCopyFP.C | 20 ++- .../dtinfo/DtMmdb/HardCopy/HardCopyFP.h | 2 +- .../dtinfo/DtMmdb/HardCopy/autoNumber.C | 21 ++- .../dtinfo/DtMmdb/HardCopy/autoNumber.h | 8 +- .../dtinfo/DtMmdb/HardCopy/autoNumberFP.C | 2 +- cde/programs/dtinfo/DtMmdb/Imakefile | 6 +- .../dtinfo/DtMmdb/StyleSheet/AttributeList.h | 2 +- .../dtinfo/DtMmdb/StyleSheet/BitVector.C | 28 +-- .../dtinfo/DtMmdb/StyleSheet/BitVector.h | 2 +- .../dtinfo/DtMmdb/StyleSheet/DocParser.C | 160 ++++++++---------- .../dtinfo/DtMmdb/StyleSheet/DocParser.h | 16 +- .../dtinfo/DtMmdb/StyleSheet/Element.h | 8 +- .../dtinfo/DtMmdb/StyleSheet/Expression.h | 2 +- .../dtinfo/DtMmdb/StyleSheet/Feature.h | 2 +- .../dtinfo/DtMmdb/StyleSheet/FeatureSet.C | 4 +- .../dtinfo/DtMmdb/StyleSheet/FeatureValue.C | 16 +- .../dtinfo/DtMmdb/StyleSheet/FeatureValue.h | 2 +- .../dtinfo/DtMmdb/StyleSheet/PathQualifier.C | 8 +- .../dtinfo/DtMmdb/StyleSheet/PathQualifier.h | 4 +- .../dtinfo/DtMmdb/StyleSheet/PathTable.C | 4 +- .../dtinfo/DtMmdb/StyleSheet/PathTable.h | 10 +- .../dtinfo/DtMmdb/StyleSheet/Renderer.h | 2 +- .../dtinfo/DtMmdb/StyleSheet/Resolver.h | 2 +- .../dtinfo/DtMmdb/StyleSheet/SSPath.h | 2 +- .../dtinfo/DtMmdb/StyleSheet/defParser.C | 4 +- .../dtinfo/DtMmdb/StyleSheet/defToken.C | 4 + cde/programs/dtinfo/DtMmdb/StyleSheet/style.C | 36 ++-- .../dtinfo/DtMmdb/StyleSheet/tokenStyle.C | 4 + cde/programs/dtinfo/DtMmdb/api/base.C | 12 +- cde/programs/dtinfo/DtMmdb/api/base.h | 9 +- cde/programs/dtinfo/DtMmdb/api/info_base.C | 8 +- cde/programs/dtinfo/DtMmdb/api/info_lib.C | 41 +++-- cde/programs/dtinfo/DtMmdb/api/info_lib.h | 2 +- cde/programs/dtinfo/DtMmdb/api/server.C | 3 +- cde/programs/dtinfo/DtMmdb/api/smart_ptr.C | 8 +- cde/programs/dtinfo/DtMmdb/btree/mmdb_btree.C | 6 + .../dtinfo/DtMmdb/btree_berkeley/bt_close.c | 2 +- .../dtinfo/DtMmdb/btree_berkeley/bt_open.c | 8 +- .../dtinfo/DtMmdb/btree_berkeley/bt_put.c | 5 +- .../dtinfo/DtMmdb/btree_berkeley/bt_split.c | 10 +- .../dtinfo/DtMmdb/btree_berkeley/bt_utils.c | 2 +- .../dtinfo/DtMmdb/btree_berkeley/cdefs.h | 3 + .../dtinfo/DtMmdb/btree_berkeley/compat.h | 4 +- .../dtinfo/DtMmdb/btree_berkeley/db.c | 2 + .../dtinfo/DtMmdb/btree_berkeley/mktemp.c | 5 +- .../dtinfo/DtMmdb/btree_berkeley/mpool.c | 2 +- .../dtinfo/DtMmdb/btree_berkeley/snprintf.c | 16 +- cde/programs/dtinfo/DtMmdb/compression/code.h | 2 +- .../dtinfo/DtMmdb/compression/huffman.C | 12 +- .../dtinfo/DtMmdb/compression/huffman.h | 8 +- cde/programs/dtinfo/DtMmdb/compression/ps.C | 4 + cde/programs/dtinfo/DtMmdb/compression/sgml.C | 4 + cde/programs/dtinfo/DtMmdb/compression/trie.C | 9 +- cde/programs/dtinfo/DtMmdb/compression/trie.h | 4 +- cde/programs/dtinfo/DtMmdb/compression/zip.C | 2 + .../dtinfo/DtMmdb/diskhash/bucket_array.h | 2 +- .../dtinfo/DtMmdb/diskhash/disk_bucket.h | 5 +- .../dtinfo/DtMmdb/diskhash/disk_hash.C | 10 +- .../dtinfo/DtMmdb/diskhash/disk_hash.h | 2 +- cde/programs/dtinfo/DtMmdb/dstr/bset.C | 2 +- cde/programs/dtinfo/DtMmdb/dstr/dlist.h | 2 +- cde/programs/dtinfo/DtMmdb/dstr/heap.C | 2 +- cde/programs/dtinfo/DtMmdb/dstr/slist.h | 2 +- cde/programs/dtinfo/DtMmdb/dstr/token_stack.C | 2 +- cde/programs/dtinfo/DtMmdb/dti_cc/CC_Dlist.C | 2 +- cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.C | 2 +- cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.h | 6 +- cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h | 5 +- .../dtinfo/DtMmdb/dti_cc/CC_Tokenizer.C | 5 +- cde/programs/dtinfo/DtMmdb/dti_cc/cc_hdict.C | 4 +- cde/programs/dtinfo/DtMmdb/dti_cc/cc_hdict.h | 2 +- cde/programs/dtinfo/DtMmdb/dti_cc/cc_povec.h | 2 +- cde/programs/dtinfo/DtMmdb/dti_cc/cc_pvect.C | 6 +- cde/programs/dtinfo/DtMmdb/dti_cc/types.h | 3 + .../dtinfo/DtMmdb/dti_excs/Exception.C | 20 +-- .../dtinfo/DtMmdb/dti_excs/Exceptions.C | 29 ++-- .../dtinfo/DtMmdb/dti_excs/Exceptions.hh | 15 +- .../dtinfo/DtMmdb/dti_excs/Jump_Environment.C | 2 +- cde/programs/dtinfo/DtMmdb/dynhash/data_t.C | 20 ++- cde/programs/dtinfo/DtMmdb/dynhash/data_t.h | 2 +- cde/programs/dtinfo/DtMmdb/dynhash/imp_die.h | 4 +- cde/programs/dtinfo/DtMmdb/hmphf/buckets.C | 20 ++- cde/programs/dtinfo/DtMmdb/hmphf/buckets.h | 4 +- cde/programs/dtinfo/DtMmdb/hmphf/mphf_funcs.C | 5 +- cde/programs/dtinfo/DtMmdb/hmphf/params.C | 4 +- .../dtinfo/DtMmdb/index/dyn_memory_index.C | 2 +- cde/programs/dtinfo/DtMmdb/index/fast_mphf.C | 12 +- cde/programs/dtinfo/DtMmdb/index/index.C | 14 +- cde/programs/dtinfo/DtMmdb/index/inv_lists.C | 2 +- cde/programs/dtinfo/DtMmdb/mgrs/misc.C | 1 - .../dtinfo/DtMmdb/mgrs/template_mgr.C | 6 +- cde/programs/dtinfo/DtMmdb/misc/unique_id.c | 5 +- cde/programs/dtinfo/DtMmdb/object/composite.C | 2 +- .../dtinfo/DtMmdb/object/compressed_pstring.h | 4 +- cde/programs/dtinfo/DtMmdb/object/cset.C | 18 +- cde/programs/dtinfo/DtMmdb/object/dl_list.C | 14 +- cde/programs/dtinfo/DtMmdb/object/handler.h | 2 +- .../dtinfo/DtMmdb/object/long_pstring.C | 2 +- cde/programs/dtinfo/DtMmdb/object/oid_list.C | 8 +- cde/programs/dtinfo/DtMmdb/object/oid_list.h | 2 +- cde/programs/dtinfo/DtMmdb/object/oid_t.C | 4 +- cde/programs/dtinfo/DtMmdb/object/oid_t.h | 6 +- cde/programs/dtinfo/DtMmdb/object/pstring.C | 4 +- cde/programs/dtinfo/DtMmdb/object/root.h | 2 +- .../dtinfo/DtMmdb/object/short_list.C | 6 +- cde/programs/dtinfo/DtMmdb/object/tuple.C | 6 +- .../dtinfo/DtMmdb/oliasdb/asciiIn_filters.C | 4 +- .../dtinfo/DtMmdb/oliasdb/c_api_book_test.C | 11 +- .../dtinfo/DtMmdb/oliasdb/c_api_common.C | 4 +- .../dtinfo/DtMmdb/oliasdb/c_api_dlp_test.C | 1 - .../DtMmdb/oliasdb/c_api_graphic_test.C | 4 +- .../dtinfo/DtMmdb/oliasdb/c_api_infolib.C | 2 - .../DtMmdb/oliasdb/c_api_locator_test.C | 2 - .../DtMmdb/oliasdb/c_api_section_test.C | 5 +- .../DtMmdb/oliasdb/c_api_stylesheet_test.C | 2 - .../dtinfo/DtMmdb/oliasdb/c_api_test.C | 2 +- .../dtinfo/DtMmdb/oliasdb/c_api_toc_test.C | 3 +- .../DtMmdb/oliasdb/collectionIterator.h | 2 +- .../dtinfo/DtMmdb/oliasdb/graphic_hd.C | 2 + .../dtinfo/DtMmdb/oliasdb/graphic_test.C | 3 +- .../dtinfo/DtMmdb/oliasdb/mark_test.C | 2 +- cde/programs/dtinfo/DtMmdb/oliasdb/mmdb.C | 2 +- .../dtinfo/DtMmdb/oliasdb/node_test.C | 3 +- .../dtinfo/DtMmdb/oliasdb/olias_funcs.C | 6 +- .../dtinfo/DtMmdb/oliasdb/olias_test.C | 22 +-- .../dtinfo/DtMmdb/oliasdb/stylesheet_test.C | 7 +- .../dtinfo/DtMmdb/oliasdb/user_base.C | 53 ++++-- .../dtinfo/DtMmdb/schema/container_desc.C | 2 +- .../dtinfo/DtMmdb/schema/index_desc.C | 10 +- .../dtinfo/DtMmdb/schema/object_dict.C | 23 ++- .../dtinfo/DtMmdb/schema/object_dict.h | 2 +- cde/programs/dtinfo/DtMmdb/schema/sheet.C | 4 +- .../dtinfo/DtMmdb/schema/store_desc.C | 4 +- cde/programs/dtinfo/DtMmdb/schema/token.C | 9 +- .../dtinfo/DtMmdb/storage/abs_storage.C | 8 +- .../dtinfo/DtMmdb/storage/chunks_index.h | 2 +- cde/programs/dtinfo/DtMmdb/storage/lru.C | 7 +- cde/programs/dtinfo/DtMmdb/storage/page.C | 2 +- cde/programs/dtinfo/DtMmdb/storage/page.h | 4 +- .../dtinfo/DtMmdb/storage/page_cache.C | 2 +- .../dtinfo/DtMmdb/storage/page_storage.C | 20 +-- .../dtinfo/DtMmdb/storage/page_storage.h | 22 +-- cde/programs/dtinfo/DtMmdb/storage/spointer.h | 2 +- .../dtinfo/DtMmdb/storage/store_test.C | 8 +- .../dtinfo/DtMmdb/storage/unixf_storage.C | 12 +- .../dtinfo/DtMmdb/utility/atoi_fast.C | 26 +-- .../dtinfo/DtMmdb/utility/atoi_pearson.C | 4 +- .../dtinfo/DtMmdb/utility/atoi_pearson.h | 8 +- .../dtinfo/DtMmdb/utility/atomic_lock.C | 3 +- cde/programs/dtinfo/DtMmdb/utility/buffer.C | 4 +- cde/programs/dtinfo/DtMmdb/utility/c_ios.h | 2 +- .../dtinfo/DtMmdb/utility/c_streambuf.h | 10 +- cde/programs/dtinfo/DtMmdb/utility/filebuf.C | 8 +- cde/programs/dtinfo/DtMmdb/utility/funcs.C | 57 ++++--- cde/programs/dtinfo/DtMmdb/utility/macro.h | 5 + cde/programs/dtinfo/DtMmdb/utility/rw_lock.C | 16 +- cde/programs/dtinfo/DtMmdb/utility/stream.C | 2 +- cde/programs/dtinfo/DtMmdb/utility/types.h | 2 +- 159 files changed, 735 insertions(+), 588 deletions(-) diff --git a/cde/programs/dtinfo/DtMmdb/HardCopy/FPset.h b/cde/programs/dtinfo/DtMmdb/HardCopy/FPset.h index e7a84373..42fe3fe0 100644 --- a/cde/programs/dtinfo/DtMmdb/HardCopy/FPset.h +++ b/cde/programs/dtinfo/DtMmdb/HardCopy/FPset.h @@ -55,12 +55,12 @@ public: 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 diff --git a/cde/programs/dtinfo/DtMmdb/HardCopy/HardCopyFP.C b/cde/programs/dtinfo/DtMmdb/HardCopy/HardCopyFP.C index 61d490a6..b3354f2f 100644 --- a/cde/programs/dtinfo/DtMmdb/HardCopy/HardCopyFP.C +++ b/cde/programs/dtinfo/DtMmdb/HardCopy/HardCopyFP.C @@ -34,16 +34,20 @@ char* loutFeatureProcessor::empty_string() 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 3999 ) { MESSAGE(cerr, "Value too large."); @@ -481,7 +486,7 @@ autoNumberRoman::ArabicToRoman(int x) char* buf = form("%d", x); int j=strlen(buf)-1; - for ( int i=0; i f_values; @@ -179,7 +179,7 @@ class autoNumberListT : public CC_TPtrSlist { public: autoNumberListT() {}; - ~autoNumberListT() {}; + virtual ~autoNumberListT() {}; unsigned int operator==(const autoNumberListT&); } ; diff --git a/cde/programs/dtinfo/DtMmdb/HardCopy/autoNumberFP.C b/cde/programs/dtinfo/DtMmdb/HardCopy/autoNumberFP.C index bc7d212f..ca20852b 100644 --- a/cde/programs/dtinfo/DtMmdb/HardCopy/autoNumberFP.C +++ b/cde/programs/dtinfo/DtMmdb/HardCopy/autoNumberFP.C @@ -284,7 +284,7 @@ autoNumberFP::defineAutoNumber(const char* nm, const FeatureValue* f) const char* gi = 0; autoNumberListT* anList = 0; - int i; + unsigned int i; for (i=0; i length(); i++ ) { gi = stringToCharPtr((*controlList)[i]); diff --git a/cde/programs/dtinfo/DtMmdb/Imakefile b/cde/programs/dtinfo/DtMmdb/Imakefile index 93477866..bab0bf03 100644 --- a/cde/programs/dtinfo/DtMmdb/Imakefile +++ b/cde/programs/dtinfo/DtMmdb/Imakefile @@ -57,9 +57,9 @@ EXTRALIBRARYDEPS = $(DONES) XCOMM redefine TopLevelProject to build DtInfo with standard CDE config dir #undef TopLevelProject #define TopLevelProject DtInfo -IMAKE_DEFINES = -DTopLevelProject=TopLevelProject \ - -DProjectTmplFile='' \ - -DProjectRulesFile='' +IMAKE_DEF_DTINFO = -DTopLevelProject=TopLevelProject \ + -DProjectTmplFile='' \ + -DProjectRulesFile='' MakeSubdirs($(SUBDIRS)) ForceSubdirs($(SUBDIRS)) diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/AttributeList.h b/cde/programs/dtinfo/DtMmdb/StyleSheet/AttributeList.h index d9b2460d..b39cced9 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/AttributeList.h +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/AttributeList.h @@ -38,7 +38,7 @@ class AttributeList : private CC_TPtrSlist { public: AttributeList(); - ~AttributeList(); + virtual ~AttributeList(); void add(Attribute *); diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.C b/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.C index ca642f0f..bc267f2d 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.C +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.C @@ -51,7 +51,7 @@ void BitVector::setAllBitsTo(unsigned int initValue) { unsigned int fill = ( initValue == 0 ) ? 0x0 : ~0x0; - for ( int i=0; i> 1; f_array[i] |= msb; @@ -164,8 +164,8 @@ BitVector& BitVector::shiftLeftOneBit() 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; diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.h b/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.h index 2579e26d..36249691 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.h +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/BitVector.h @@ -60,10 +60,10 @@ typedef CC_TValSlistIterator positionArrayIteratorT; /////////////////////////////////////////////////////// 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); diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/DocParser.C b/cde/programs/dtinfo/DtMmdb/StyleSheet/DocParser.C index d3f9f59c..57142d11 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/DocParser.C +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/DocParser.C @@ -39,8 +39,8 @@ #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; } @@ -53,7 +53,7 @@ DocParser::DocParser(Resolver &r) f_output(f_buffer, DATA_BUF_SIZ) #else f_streambuf(new stringbuf()), - f_output(f_streambuf) + f_output() #endif { } @@ -81,6 +81,8 @@ DocParser::parse(istream &input) unsigned int DocParser::rawParse(istream &input) { + string data; + input.unsetf(ios::skipws); f_ignoring_element = 0 ; @@ -93,18 +95,15 @@ DocParser::rawParse(istream &input) 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); } @@ -139,7 +138,7 @@ update_last_seen_child_name(Symbol*& last_seen_child_name, unsigned int& child_r } 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) { @@ -151,6 +150,11 @@ DocParser::process(istream &input, ostream &output, 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); @@ -193,11 +197,11 @@ DocParser::process(istream &input, ostream &output, 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); @@ -211,17 +215,17 @@ DocParser::process(istream &input, ostream &output, #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 @@ -312,20 +316,14 @@ DocParser::process(istream &input, ostream &output, // 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 } } @@ -340,25 +338,18 @@ DocParser::process(istream &input, ostream &output, ///////////////////////////// // 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); @@ -382,21 +373,15 @@ debug(cerr, f_streambuf->pcount ()); // 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 } } @@ -404,17 +389,13 @@ debug(cerr, f_streambuf->pcount ()); #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 @@ -436,10 +417,13 @@ debug(cerr, f_streambuf->pcount ()); 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; @@ -447,8 +431,6 @@ DocParser::process_attributes(istream &input, ostream &output, AttributeList* orig_attrs = attrs; AttributeList* orig_olias_attrs = olias_attrs; - char *theData = 0; - mtry { while ((tt = read_tag(input,output)) != NoTag) { @@ -456,10 +438,8 @@ DocParser::process_attributes(istream &input, ostream &output, { 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 ; @@ -468,13 +448,9 @@ DocParser::process_attributes(istream &input, ostream &output, 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 ); @@ -488,10 +464,8 @@ DocParser::process_attributes(istream &input, ostream &output, 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) @@ -501,13 +475,9 @@ DocParser::process_attributes(istream &input, ostream &output, 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 ); @@ -540,9 +510,11 @@ DocParser::process_attributes(istream &input, ostream &output, } 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 @@ -562,14 +534,11 @@ DocParser::process_attribute(istream &input, ostream &output, 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)) { @@ -593,7 +562,7 @@ DocParser::process_attribute(istream &input, ostream &output, DocParser::TagType -DocParser::read_tag(istream &input, ostream &output) +DocParser::read_tag(istream &input, ostringstream &output) { output.seekp(streampos(0)); @@ -643,13 +612,14 @@ DocParser::read_tag(istream &input, ostream &output) // 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 ; @@ -701,6 +671,8 @@ DocParser::read_data(istream &input, ostream &output) output << c; } + output << ends; + // can never run out of input while reading data, tags must be balanced if (input.eof()) throw(CASTDPUEEXCEPT docParserUnexpectedEof()); diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/DocParser.h b/cde/programs/dtinfo/DtMmdb/StyleSheet/DocParser.h index c2ba160c..1c763311 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/DocParser.h +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/DocParser.h @@ -64,29 +64,29 @@ public: 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; }; diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/Element.h b/cde/programs/dtinfo/DtMmdb/StyleSheet/Element.h index 6ce8c61b..7a152413 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/Element.h +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/Element.h @@ -69,17 +69,17 @@ public: 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 diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/Expression.h b/cde/programs/dtinfo/DtMmdb/StyleSheet/Expression.h index 357ee204..ac7b89c5 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/Expression.h +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/Expression.h @@ -57,7 +57,7 @@ class Expression public: Expression(TermNode *root); Expression(const Expression&); - ~Expression(); + virtual ~Expression(); virtual FeatureValue *evaluate() const; ostream &print(ostream &) const; diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/Feature.h b/cde/programs/dtinfo/DtMmdb/StyleSheet/Feature.h index 67d58329..561404e5 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/Feature.h +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/Feature.h @@ -107,7 +107,7 @@ public: FeatureSet(const FeatureSet &); /* copy */ FeatureSet(const FeatureSet &, const FeatureSet &); /* merge */ - ~FeatureSet(); + virtual ~FeatureSet(); void add(Feature *); const Feature *lookup(const Symbol *) const ; diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureSet.C b/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureSet.C index 53f9efa0..0a2ca070 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureSet.C +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureSet.C @@ -143,7 +143,7 @@ FeatureSet::print(ostream &o) const // cast to non-const to get iterator CC_TPtrSlistIterator next(*(CC_TPtrSlist*)this); - int i; + unsigned int i; for (i = 0 ; i < f_print_indent_level; i++) o << " " ; @@ -153,7 +153,7 @@ FeatureSet::print(ostream &o) const 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 ; } diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureValue.C b/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureValue.C index d20c2f76..378fd3a0 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureValue.C +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/FeatureValue.C @@ -2336,23 +2336,23 @@ FeatureValueDimension::doConvert(Unit unit) const /////////////////////////////////////////////////// FeatureValueArray::FeatureValueArray(const char* nm, int size) : - f_name(strdup(nm)), FeatureValue(array), pointer_vector(size, 0) + FeatureValue(array), pointer_vector(size, 0), f_name(strdup(nm)) { } FeatureValueArray::FeatureValueArray(const FeatureValueArray& x) : - f_name(strdup(x.f_name)), FeatureValue(array), - pointer_vector(x.length(), 0) + FeatureValue(array), pointer_vector(x.length(), 0), + f_name(strdup(x.f_name)) { mtry { - for ( int i=0; i clone(); return; } mcatch_any() { - for ( int i=0; i evaluate(); } return result; @@ -2392,7 +2392,7 @@ FeatureValueArray::print(ostream& out) const { out << f_name << "[\n"; - for ( int i=0; i 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)) @@ -478,7 +478,7 @@ void PathTable::initLastSymIndex() { f_lastSymIndexCount = gElemSymTab -> IdsAssigned()+1; f_lastSymIndex = new CC_TPtrDlist_PathFeature_Ptr_T[f_lastSymIndexCount]; - for (int i=0; i; diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/PathTable.h b/cde/programs/dtinfo/DtMmdb/StyleSheet/PathTable.h index 5300b5d0..d3846f47 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/PathTable.h +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/PathTable.h @@ -47,15 +47,15 @@ typedef unsigned int LetterType; class EncodedPath { - int f_patternSize; int f_size; + int f_patternSize; LetterType* f_array; + hashTable f_SVectors; + LetterType f_wildCard; LetterType f_unlimitedWildCard; - hashTable f_SVectors; - BitVector* f_copyOfS; // copy of S vector, used in match() public: @@ -98,7 +98,7 @@ class PathFeature : public basePathFeature 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; }; @@ -117,7 +117,7 @@ class PathFeatureList : public CC_TPtrDlist public: PathFeatureList() {}; - ~PathFeatureList(); + virtual ~PathFeatureList(); void appendList(PathFeatureList&); }; diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/Renderer.h b/cde/programs/dtinfo/DtMmdb/StyleSheet/Renderer.h index b06de109..863aea11 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/Renderer.h +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/Renderer.h @@ -47,7 +47,7 @@ class Renderer : public Destructable { public: Renderer() {}; - ~Renderer() {}; + virtual ~Renderer() {}; virtual FeatureSet *initialize() = 0; /* return default feature set */ diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/Resolver.h b/cde/programs/dtinfo/DtMmdb/StyleSheet/Resolver.h index aecbb9a0..90df5e17 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/Resolver.h +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/Resolver.h @@ -71,12 +71,12 @@ public: 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 */ diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/SSPath.h b/cde/programs/dtinfo/DtMmdb/StyleSheet/SSPath.h index eaa91e8e..39258cb5 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/SSPath.h +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/SSPath.h @@ -75,7 +75,7 @@ private: public: SSPath(char*, unsigned int assignId); // for test purpose SSPath(); - ~SSPath(); + virtual ~SSPath(); // this call update f_containPathQualifier field void appendPathTerm(PathTerm*); diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/defParser.C b/cde/programs/dtinfo/DtMmdb/StyleSheet/defParser.C index f8c1d5d4..558a60eb 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/defParser.C +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/defParser.C @@ -22,7 +22,7 @@ */ // $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 @@ -230,7 +230,7 @@ defParserparse() *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; diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/defToken.C b/cde/programs/dtinfo/DtMmdb/StyleSheet/defToken.C index 67f618a6..15dae7df 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/defToken.C +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/defToken.C @@ -483,7 +483,9 @@ static int defParser_did_buffer_switch_on_eof; 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 )); @@ -1055,6 +1057,7 @@ register defParser_state_type defParser_current_state; } +#if 0 #ifdef defParser_USE_PROTOS static void defParserunput( defParser_CHAR c, register defParser_CHAR *defParser_bp ) #else @@ -1098,6 +1101,7 @@ register defParser_CHAR *defParser_bp; */ defParser_DO_BEFORE_ACTION; /* set up defParsertext again */ } +#endif #ifdef __cplusplus diff --git a/cde/programs/dtinfo/DtMmdb/StyleSheet/style.C b/cde/programs/dtinfo/DtMmdb/StyleSheet/style.C index 2605417d..deefffce 100644 --- a/cde/programs/dtinfo/DtMmdb/StyleSheet/style.C +++ b/cde/programs/dtinfo/DtMmdb/StyleSheet/style.C @@ -22,7 +22,7 @@ */ // $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 @@ -70,7 +70,7 @@ const char* toUpperCase(unsigned char* string) { static char buffer[512]; int j=0; - for ( int i=0; i asciiIn(in); @@ -305,16 +305,18 @@ void smart_ptr::update_string(int i, istream& 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; } diff --git a/cde/programs/dtinfo/DtMmdb/btree/mmdb_btree.C b/cde/programs/dtinfo/DtMmdb/btree/mmdb_btree.C index ed016d7b..5e53fb98 100644 --- a/cde/programs/dtinfo/DtMmdb/btree/mmdb_btree.C +++ b/cde/programs/dtinfo/DtMmdb/btree/mmdb_btree.C @@ -128,6 +128,8 @@ Boolean btree::insert(data_t& w) case RET_SUCCESS: return true; } + + return false; } Boolean btree::remove(data_t& w) @@ -145,6 +147,8 @@ Boolean btree::remove(data_t& w) case RET_SUCCESS: return true; } + + return false; } Boolean btree::member(data_t& w) @@ -169,6 +173,8 @@ 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) diff --git a/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_close.c b/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_close.c index 361c940e..fc87aa65 100644 --- a/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_close.c +++ b/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_close.c @@ -141,7 +141,7 @@ __bt_sync(dbp, flags) BTREE *t; int status; PAGE *h; - void *p; + void *p = NULL; t = dbp->internal; diff --git a/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_open.c b/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_open.c index 19910080..e318c72c 100644 --- a/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_open.c +++ b/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_open.c @@ -143,7 +143,7 @@ __bt_open(fname, flags, mode, openinfo, dflags) */ 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. */ @@ -268,7 +268,7 @@ __bt_open(fname, flags, mode, openinfo, dflags) 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; @@ -301,8 +301,8 @@ __bt_open(fname, flags, mode, openinfo, dflags) 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; diff --git a/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_put.c b/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_put.c index 6b34452d..8f983823 100644 --- a/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_put.c +++ b/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_put.c @@ -95,7 +95,7 @@ __bt_put(dbp, key, data, flags) { BTREE *t; DBT tkey, tdata; - EPG *e; + EPG *e = NULL; PAGE *h; indx_t index, nxtindex; pgno_t pg; @@ -243,7 +243,7 @@ delete: if (__bt_dleaf(t, h, index) == RET_ERROR) { 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; @@ -257,6 +257,7 @@ delete: if (__bt_dleaf(t, h, index) == RET_ERROR) { t->bt_last.pgno = h->pgno; } } + } mpool_put(t->bt_mp, h, MPOOL_DIRTY); diff --git a/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_split.c b/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_split.c index e6794b63..ae6a3452 100644 --- a/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_split.c +++ b/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_split.c @@ -111,13 +111,15 @@ __bt_split(t, sp, key, data, flags, ilen, skip) 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; @@ -640,7 +642,7 @@ bt_psplit(t, h, l, r, pskip, ilen) 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; diff --git a/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_utils.c b/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_utils.c index bfa93237..b16d37fa 100644 --- a/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_utils.c +++ b/cde/programs/dtinfo/DtMmdb/btree_berkeley/bt_utils.c @@ -229,7 +229,7 @@ __bt_defcmp(a, b) 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); } diff --git a/cde/programs/dtinfo/DtMmdb/btree_berkeley/cdefs.h b/cde/programs/dtinfo/DtMmdb/btree_berkeley/cdefs.h index ab698bae..c635e551 100644 --- a/cde/programs/dtinfo/DtMmdb/btree_berkeley/cdefs.h +++ b/cde/programs/dtinfo/DtMmdb/btree_berkeley/cdefs.h @@ -67,7 +67,9 @@ #define __END_DECLS }; #endif #else +#undef __BEGIN_DECLS #define __BEGIN_DECLS +#undef __END_DECLS #define __END_DECLS #endif @@ -119,6 +121,7 @@ * define them only if compiling without this. */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) +#undef __dead #define __dead __volatile #ifndef __pure #define __pure __const diff --git a/cde/programs/dtinfo/DtMmdb/btree_berkeley/compat.h b/cde/programs/dtinfo/DtMmdb/btree_berkeley/compat.h index dea9b547..a09a36dc 100644 --- a/cde/programs/dtinfo/DtMmdb/btree_berkeley/compat.h +++ b/cde/programs/dtinfo/DtMmdb/btree_berkeley/compat.h @@ -86,10 +86,10 @@ typedef unsigned int sigset_t; #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 diff --git a/cde/programs/dtinfo/DtMmdb/btree_berkeley/db.c b/cde/programs/dtinfo/DtMmdb/btree_berkeley/db.c index 79f6b5f9..46962144 100644 --- a/cde/programs/dtinfo/DtMmdb/btree_berkeley/db.c +++ b/cde/programs/dtinfo/DtMmdb/btree_berkeley/db.c @@ -94,6 +94,8 @@ dbopen(fname, flags, mode, type, openinfo) return (__rec_open(fname, flags & USE_OPEN_FLAGS, mode, openinfo, flags & DB_FLAGS)); */ + default: + break; } errno = EINVAL; return (NULL); diff --git a/cde/programs/dtinfo/DtMmdb/btree_berkeley/mktemp.c b/cde/programs/dtinfo/DtMmdb/btree_berkeley/mktemp.c index 021db5a2..434f5cec 100644 --- a/cde/programs/dtinfo/DtMmdb/btree_berkeley/mktemp.c +++ b/cde/programs/dtinfo/DtMmdb/btree_berkeley/mktemp.c @@ -60,6 +60,7 @@ static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93"; #include #include +#include #include #include #include @@ -72,7 +73,7 @@ extern int errno; static int _gettemp(); -mkstemp(path) +int mkstemp(path) char *path; { int fd; @@ -87,7 +88,7 @@ mktemp(path) return(_gettemp(path, (int *)NULL) ? path : (char *)NULL); } -static +static int _gettemp(path, doopen) char *path; register int *doopen; diff --git a/cde/programs/dtinfo/DtMmdb/btree_berkeley/mpool.c b/cde/programs/dtinfo/DtMmdb/btree_berkeley/mpool.c index e83a5721..6bac74f1 100644 --- a/cde/programs/dtinfo/DtMmdb/btree_berkeley/mpool.c +++ b/cde/programs/dtinfo/DtMmdb/btree_berkeley/mpool.c @@ -215,7 +215,7 @@ mpool_get(mp, pgno, flags) * 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 diff --git a/cde/programs/dtinfo/DtMmdb/btree_berkeley/snprintf.c b/cde/programs/dtinfo/DtMmdb/btree_berkeley/snprintf.c index bec78092..803cf863 100644 --- a/cde/programs/dtinfo/DtMmdb/btree_berkeley/snprintf.c +++ b/cde/programs/dtinfo/DtMmdb/btree_berkeley/snprintf.c @@ -26,6 +26,7 @@ #include #include +#include #ifdef __STDC__ #include @@ -45,24 +46,30 @@ snprintf(str, n, fmt, va_alist) #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; @@ -71,8 +78,9 @@ vsnprintf(str, n, fmt, ap) 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 diff --git a/cde/programs/dtinfo/DtMmdb/compression/code.h b/cde/programs/dtinfo/DtMmdb/compression/code.h index f4c5ba4e..beb53ffd 100644 --- a/cde/programs/dtinfo/DtMmdb/compression/code.h +++ b/cde/programs/dtinfo/DtMmdb/compression/code.h @@ -63,8 +63,8 @@ class encoding_unit public: ostring* word; int bits; - unsigned int code; unsigned int freq; + unsigned int code; htr_node* leaf_htr_node; public: diff --git a/cde/programs/dtinfo/DtMmdb/compression/huffman.C b/cde/programs/dtinfo/DtMmdb/compression/huffman.C index f6501bd8..48038d49 100644 --- a/cde/programs/dtinfo/DtMmdb/compression/huffman.C +++ b/cde/programs/dtinfo/DtMmdb/compression/huffman.C @@ -109,7 +109,7 @@ void huff::build_tree() heap htr_node_set(htr_eq, htr_ls, cts); htr_node* x ; - for (int i=0; i leaf_htr_node = x; @@ -146,7 +146,7 @@ void huff::calculate_code() htr_node* x ; htr_node* parent; - for (int i=0; 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")); } @@ -191,7 +191,7 @@ ostream& huff::print_alphabet(ostream& out) unsigned long total_uncmp = 0; unsigned long int total_cmp = 0; - for (int i=0; i 0 ) { //MESSAGE(cerr, "huff::cdrOut: dict out"); @@ -454,7 +454,7 @@ io_status huff::cdrIn(buffer& buf) unsigned int word_freq; //ostring *z = 0; - for ( int i=0; i= 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++ ) { @@ -175,13 +175,10 @@ void trie::add(unsigned char* word, int sz, int fq) // 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); diff --git a/cde/programs/dtinfo/DtMmdb/compression/trie.h b/cde/programs/dtinfo/DtMmdb/compression/trie.h index 7670a3af..79da3c69 100644 --- a/cde/programs/dtinfo/DtMmdb/compression/trie.h +++ b/cde/programs/dtinfo/DtMmdb/compression/trie.h @@ -117,16 +117,16 @@ class trie { 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); diff --git a/cde/programs/dtinfo/DtMmdb/compression/zip.C b/cde/programs/dtinfo/DtMmdb/compression/zip.C index 8350e863..1b8cb4f6 100644 --- a/cde/programs/dtinfo/DtMmdb/compression/zip.C +++ b/cde/programs/dtinfo/DtMmdb/compression/zip.C @@ -73,6 +73,7 @@ void zip::compress(const buffer& uncompressed, buffer& compressed) out.close(); ret = system(form("gzip -c %s > %s", (char*)UNCOMPRESSED,(char*)COMPRESSED)); + if(ret != 0) throw(systemException(ret)); fstream in(COMPRESSED, ios::in); @@ -107,6 +108,7 @@ void zip::decompress(buffer& compressed, buffer& uncompressed) out.close(); ret = system(form("gzip -cd %s > %s",(char*)COMPRESSED,(char*)UNCOMPRESSED)); + if(ret != 0) throw(systemException(ret)); fstream in(UNCOMPRESSED, ios::in); diff --git a/cde/programs/dtinfo/DtMmdb/diskhash/bucket_array.h b/cde/programs/dtinfo/DtMmdb/diskhash/bucket_array.h index 56fcb55e..a8b1f570 100644 --- a/cde/programs/dtinfo/DtMmdb/diskhash/bucket_array.h +++ b/cde/programs/dtinfo/DtMmdb/diskhash/bucket_array.h @@ -74,8 +74,8 @@ public: 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; diff --git a/cde/programs/dtinfo/DtMmdb/diskhash/disk_bucket.h b/cde/programs/dtinfo/DtMmdb/diskhash/disk_bucket.h index f5aa2bc1..e7a04e73 100644 --- a/cde/programs/dtinfo/DtMmdb/diskhash/disk_bucket.h +++ b/cde/programs/dtinfo/DtMmdb/diskhash/disk_bucket.h @@ -95,12 +95,13 @@ protected: 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; }; diff --git a/cde/programs/dtinfo/DtMmdb/diskhash/disk_hash.C b/cde/programs/dtinfo/DtMmdb/diskhash/disk_hash.C index 2b68cc8f..efcdc7c0 100644 --- a/cde/programs/dtinfo/DtMmdb/diskhash/disk_hash.C +++ b/cde/programs/dtinfo/DtMmdb/diskhash/disk_hash.C @@ -79,7 +79,7 @@ index_agent(), key_store(store), buf(store -> aux_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); @@ -159,7 +159,7 @@ Boolean disk_hash::rehash(data_t& w) { //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 @@ -271,7 +271,7 @@ Boolean disk_hash::_insert(data_t& w, Boolean rehash_if_fail) //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); @@ -386,7 +386,7 @@ Boolean disk_hash::member(data_t& w, disk_bucket*& b, int& slot_num) const if ( b -> overflow() == true ) { - for ( hash %= v; hash get_bucket(hash+M); @@ -411,7 +411,7 @@ disk_bucket* disk_hash::get_bucket(int& ind) void disk_hash::next_bucket(int& ind) { - ind = ( ind >= M+v-1 ) ? -1 : (ind+1); + ind = ( ind >= (int)(M+v-1) ) ? -1 : (ind+1); } diff --git a/cde/programs/dtinfo/DtMmdb/diskhash/disk_hash.h b/cde/programs/dtinfo/DtMmdb/diskhash/disk_hash.h index 75bf1c6d..628e04b9 100644 --- a/cde/programs/dtinfo/DtMmdb/diskhash/disk_hash.h +++ b/cde/programs/dtinfo/DtMmdb/diskhash/disk_hash.h @@ -123,7 +123,7 @@ protected: 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 diff --git a/cde/programs/dtinfo/DtMmdb/dstr/bset.C b/cde/programs/dtinfo/DtMmdb/dstr/bset.C index 5bb27a7e..59eb7230 100644 --- a/cde/programs/dtinfo/DtMmdb/dstr/bset.C +++ b/cde/programs/dtinfo/DtMmdb/dstr/bset.C @@ -67,7 +67,7 @@ Boolean void_eq(const void* o1, const void* o2) //************************************************************** -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 ); } diff --git a/cde/programs/dtinfo/DtMmdb/dstr/dlist.h b/cde/programs/dtinfo/DtMmdb/dstr/dlist.h index a1cb0494..0be2b7a5 100644 --- a/cde/programs/dtinfo/DtMmdb/dstr/dlist.h +++ b/cde/programs/dtinfo/DtMmdb/dstr/dlist.h @@ -85,9 +85,9 @@ public: 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; }; diff --git a/cde/programs/dtinfo/DtMmdb/dstr/heap.C b/cde/programs/dtinfo/DtMmdb/dstr/heap.C index eca976d1..c883e5fd 100644 --- a/cde/programs/dtinfo/DtMmdb/dstr/heap.C +++ b/cde/programs/dtinfo/DtMmdb/dstr/heap.C @@ -84,7 +84,7 @@ int heap::count() 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); diff --git a/cde/programs/dtinfo/DtMmdb/dstr/slist.h b/cde/programs/dtinfo/DtMmdb/dstr/slist.h index ea93b6f4..4ba88e71 100644 --- a/cde/programs/dtinfo/DtMmdb/dstr/slist.h +++ b/cde/programs/dtinfo/DtMmdb/dstr/slist.h @@ -93,9 +93,9 @@ public: 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 }; diff --git a/cde/programs/dtinfo/DtMmdb/dstr/token_stack.C b/cde/programs/dtinfo/DtMmdb/dstr/token_stack.C index fa9aa26a..b4664843 100644 --- a/cde/programs/dtinfo/DtMmdb/dstr/token_stack.C +++ b/cde/programs/dtinfo/DtMmdb/dstr/token_stack.C @@ -99,7 +99,7 @@ void token_stack::new_token() 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; diff --git a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Dlist.C b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Dlist.C index 793a39b0..45e4dda6 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Dlist.C +++ b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Dlist.C @@ -33,7 +33,7 @@ template CC_Boolean CC_TPtrDlistIterator::operator+=(size_t n) { - for ( int i = 0; i < n ; i++ ) { + for ( size_t i = 0; i < n ; i++ ) { if ( !(++(*this)) ) { return (FALSE); } diff --git a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.C b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.C index 48b3430f..1281fda3 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.C +++ b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.C @@ -46,7 +46,7 @@ template T *CC_TPtrSlist::removeAt(size_t pos) { CC_TPtrSlistIterator 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)); } diff --git a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.h b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.h index 5d10f66c..51dc9bf9 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.h +++ b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Slist.h @@ -82,7 +82,7 @@ public: CC_TPtrSlist(const CC_TPtrSlist &); CC_TPtrSlist() { destructed = FALSE; } - ~CC_TPtrSlist(); + virtual ~CC_TPtrSlist(); virtual void clearAndDestroy(); virtual void clear(); /* clear only removes item, but not calling @@ -104,7 +104,7 @@ public: { // Hack to get it passed to iter CC_TPtrSlistIterator iter( *(CC_TPtrSlist *)this ); - for ( int i = 0; i <=pos; i++ ) { + for ( size_t i = 0; i <=pos; i++ ) { if ( !(++iter) ) { throw(CASTCCBEXCEPT ccBoundaryException(0,0,i)); } @@ -161,7 +161,7 @@ public: CC_Boolean get_destructed() const { return (destructed); } - CC_Boolean set_destructed(CC_Boolean what) + void set_destructed(CC_Boolean what) { destructed = what; } }; diff --git a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h index d262478f..308e54fa 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h +++ b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_String.h @@ -34,8 +34,9 @@ public: // functions 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() diff --git a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.C b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.C index 5344239f..ef0f5188 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.C +++ b/cde/programs/dtinfo/DtMmdb/dti_cc/CC_Tokenizer.C @@ -27,8 +27,9 @@ //-------------------------------------------------------------- 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; } diff --git a/cde/programs/dtinfo/DtMmdb/dti_cc/cc_hdict.C b/cde/programs/dtinfo/DtMmdb/dti_cc/cc_hdict.C index 98ab4498..3a53b180 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_cc/cc_hdict.C +++ b/cde/programs/dtinfo/DtMmdb/dti_cc/cc_hdict.C @@ -58,7 +58,7 @@ hashTable::~hashTable() CC_TPtrSlist > * b = 0; kv_pair * r = 0; - for (int i=0; i::clearAndDestroy() CC_TPtrSlist >* b = 0; - for (int i=0; i class hashTable friend class hashTableIterator; protected: - pointer_vector > > f_buckets; unsigned (*f_hash_func_ptr)(const K&); + pointer_vector > > f_buckets; size_t f_items; protected: diff --git a/cde/programs/dtinfo/DtMmdb/dti_cc/cc_povec.h b/cde/programs/dtinfo/DtMmdb/dti_cc/cc_povec.h index c70da6f7..cac3a4ca 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_cc/cc_povec.h +++ b/cde/programs/dtinfo/DtMmdb/dti_cc/cc_povec.h @@ -53,7 +53,7 @@ public: { // Hack to get it passed to iter CC_TPtrSlistIterator iter( *(CC_TPtrSlist *)this ); - for ( int i = 0; i <=pos; i++ ) { + for ( size_t i = 0; i <=pos; i++ ) { if ( !(++iter) ) { throw(CASTCCBEXCEPT ccBoundaryException(0,0,i)); } diff --git a/cde/programs/dtinfo/DtMmdb/dti_cc/cc_pvect.C b/cde/programs/dtinfo/DtMmdb/dti_cc/cc_pvect.C index 47332571..a7fe11d0 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_cc/cc_pvect.C +++ b/cde/programs/dtinfo/DtMmdb/dti_cc/cc_pvect.C @@ -39,7 +39,7 @@ template pointer_vector::pointer_vector(size_t n, T* t) : f_array(new Tptr[n]), f_size(n), f_items(0) { - for ( int i=0; i::~pointer_vector() template T* pointer_vector::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]; @@ -61,7 +61,7 @@ T* pointer_vector::operator[](ptrdiff_t i) const template T*& pointer_vector::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]; diff --git a/cde/programs/dtinfo/DtMmdb/dti_cc/types.h b/cde/programs/dtinfo/DtMmdb/dti_cc/types.h index 69988a68..93182b9c 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_cc/types.h +++ b/cde/programs/dtinfo/DtMmdb/dti_cc/types.h @@ -32,4 +32,7 @@ typedef unsigned int CC_Boolean; #define TRUE 1 #define FALSE 0 +#undef MIN +#define MIN(x, y) (((x) < (y)) ? (x) : (y)) + #endif diff --git a/cde/programs/dtinfo/DtMmdb/dti_excs/Exception.C b/cde/programs/dtinfo/DtMmdb/dti_excs/Exception.C index 1a8b6bca..da289322 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_excs/Exception.C +++ b/cde/programs/dtinfo/DtMmdb/dti_excs/Exception.C @@ -40,7 +40,7 @@ char *Exception::g_next_avail = Exception::g_temp_space; // ///////////////////////////////////////////////////////////////// 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)); } @@ -76,19 +76,17 @@ Exception::operator delete (void *place) 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); } @@ -248,8 +246,8 @@ Exception::is (const char *type, const char *this_class) 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); diff --git a/cde/programs/dtinfo/DtMmdb/dti_excs/Exceptions.C b/cde/programs/dtinfo/DtMmdb/dti_excs/Exceptions.C index 79b24103..e8df9490 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_excs/Exceptions.C +++ b/cde/programs/dtinfo/DtMmdb/dti_excs/Exceptions.C @@ -162,28 +162,35 @@ Exceptions::set_error_handler (error_handler_t error_handler) 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) diff --git a/cde/programs/dtinfo/DtMmdb/dti_excs/Exceptions.hh b/cde/programs/dtinfo/DtMmdb/dti_excs/Exceptions.hh index e0e08f35..1307ebb6 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_excs/Exceptions.hh +++ b/cde/programs/dtinfo/DtMmdb/dti_excs/Exceptions.hh @@ -4,6 +4,9 @@ #define _Exceptions_hh_active +#undef MIN +#define MIN(x, y) (((x) < (y)) ? (x) : (y)) + #ifndef C_API #ifndef NATIVE_EXCEPTIONS #define NATIVE_EXCEPTIONS @@ -48,6 +51,16 @@ extern "C" { #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" @@ -130,7 +143,7 @@ extern "C" { #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 { \ diff --git a/cde/programs/dtinfo/DtMmdb/dti_excs/Jump_Environment.C b/cde/programs/dtinfo/DtMmdb/dti_excs/Jump_Environment.C index 97ce0491..ffaf6b9f 100644 --- a/cde/programs/dtinfo/DtMmdb/dti_excs/Jump_Environment.C +++ b/cde/programs/dtinfo/DtMmdb/dti_excs/Jump_Environment.C @@ -44,7 +44,7 @@ Unwind_Record Unwind_Stack::g_stack[UNWIND_STACK_SIZE]; // ///////////////////////////////////////////////////////////////// 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. diff --git a/cde/programs/dtinfo/DtMmdb/dynhash/data_t.C b/cde/programs/dtinfo/DtMmdb/dynhash/data_t.C index 99a896db..125b5825 100644 --- a/cde/programs/dtinfo/DtMmdb/dynhash/data_t.C +++ b/cde/programs/dtinfo/DtMmdb/dynhash/data_t.C @@ -78,7 +78,7 @@ data_t::data_t(data_t& d) { 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; @@ -104,8 +104,10 @@ data_t::data_t(const char* str, int sz, voidPtr d) : dt(d) 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; } @@ -146,6 +148,8 @@ int data_t::operator==(data_t& d) case VOID: throw(stringException("VOID type in operator==()")); } + + return 0; } data_t& data_t::operator =(data_t& d) @@ -161,13 +165,12 @@ 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; } @@ -222,8 +225,7 @@ istream& operator >>(istream& i, data_t& d) 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; @@ -243,6 +245,8 @@ ostream& operator <<(ostream& o, data_t& d) case data_t::STRING: o << d.key.str_key; break; + default: + break; } o << " " << (long)(d.dt); diff --git a/cde/programs/dtinfo/DtMmdb/dynhash/data_t.h b/cde/programs/dtinfo/DtMmdb/dynhash/data_t.h index 0eeba53c..de9fec0a 100644 --- a/cde/programs/dtinfo/DtMmdb/dynhash/data_t.h +++ b/cde/programs/dtinfo/DtMmdb/dynhash/data_t.h @@ -83,12 +83,12 @@ protected: 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&) ; diff --git a/cde/programs/dtinfo/DtMmdb/dynhash/imp_die.h b/cde/programs/dtinfo/DtMmdb/dynhash/imp_die.h index 934ef71d..e69fb0c5 100644 --- a/cde/programs/dtinfo/DtMmdb/dynhash/imp_die.h +++ b/cde/programs/dtinfo/DtMmdb/dynhash/imp_die.h @@ -93,12 +93,12 @@ protected: 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 diff --git a/cde/programs/dtinfo/DtMmdb/hmphf/buckets.C b/cde/programs/dtinfo/DtMmdb/hmphf/buckets.C index f67eb6b6..aa66f076 100644 --- a/cde/programs/dtinfo/DtMmdb/hmphf/buckets.C +++ b/cde/programs/dtinfo/DtMmdb/hmphf/buckets.C @@ -60,12 +60,13 @@ bucket::bucket(char* key, int orig_position, 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; @@ -90,12 +91,13 @@ bucket::~bucket() 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; @@ -140,8 +142,8 @@ h_convertor(pms.v_n, 128, rnd) { v_bucket_array = new bucketPtr[v_no_buckets]; - int i; - for ( i=0; imy_path(), storage_ptr->my_name()), ios::out diff --git a/cde/programs/dtinfo/DtMmdb/index/fast_mphf.C b/cde/programs/dtinfo/DtMmdb/index/fast_mphf.C index 87bb4a56..dbd1fb72 100644 --- a/cde/programs/dtinfo/DtMmdb/index/fast_mphf.C +++ b/cde/programs/dtinfo/DtMmdb/index/fast_mphf.C @@ -241,6 +241,8 @@ debug(cerr, t); int fast_mphf::hashTo(const key_type& k) { + unsigned int i; + if ( v_long_string_core_indexed == false ) { v_long_string_core_indexed = true; } @@ -255,7 +257,7 @@ debug(cerr, k); 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 ) { @@ -281,7 +283,7 @@ debug(cerr, k); 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)); } @@ -428,7 +430,7 @@ fast_mphf::print_mapping(const char *key_file, int option) } 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); @@ -470,7 +472,7 @@ void fast_mphf::print_tbls(ostream& out) void fast_mphf::print_gvalues(ostream& out) { int gv, cbit; - for (int i = 0; i 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; } @@ -119,12 +121,14 @@ Boolean c_index::get_key_string(const handler& t) const 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; } diff --git a/cde/programs/dtinfo/DtMmdb/index/inv_lists.C b/cde/programs/dtinfo/DtMmdb/index/inv_lists.C index f95552e9..c57034a1 100644 --- a/cde/programs/dtinfo/DtMmdb/index/inv_lists.C +++ b/cde/programs/dtinfo/DtMmdb/index/inv_lists.C @@ -140,7 +140,7 @@ ostream& operator <<(ostream&s, inv_lists& o) 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)); } diff --git a/cde/programs/dtinfo/DtMmdb/mgrs/misc.C b/cde/programs/dtinfo/DtMmdb/mgrs/misc.C index 8f061460..1a332484 100644 --- a/cde/programs/dtinfo/DtMmdb/mgrs/misc.C +++ b/cde/programs/dtinfo/DtMmdb/mgrs/misc.C @@ -154,7 +154,6 @@ istream& operator >>(istream& in, mark_t& m) { char c ; char* ptr = m.get(); - int count = m.size(); Boolean read_marks = false; while ( in && in.get(c) ) { diff --git a/cde/programs/dtinfo/DtMmdb/mgrs/template_mgr.C b/cde/programs/dtinfo/DtMmdb/mgrs/template_mgr.C index 2db64369..2820ce09 100644 --- a/cde/programs/dtinfo/DtMmdb/mgrs/template_mgr.C +++ b/cde/programs/dtinfo/DtMmdb/mgrs/template_mgr.C @@ -169,7 +169,7 @@ cerr << "\n"; */ - 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; @@ -265,13 +265,13 @@ template_mgr_t::init_obj(abs_storage* store, mmdb_pos_t pos, root*& x) 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); diff --git a/cde/programs/dtinfo/DtMmdb/misc/unique_id.c b/cde/programs/dtinfo/DtMmdb/misc/unique_id.c index 881aac50..f8f76f7f 100644 --- a/cde/programs/dtinfo/DtMmdb/misc/unique_id.c +++ b/cde/programs/dtinfo/DtMmdb/misc/unique_id.c @@ -54,6 +54,8 @@ #include #include #include +#include +#include #ifdef SVR4 #include @@ -123,7 +125,6 @@ gethostid() 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; @@ -194,7 +195,7 @@ unique_id (void) 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])); diff --git a/cde/programs/dtinfo/DtMmdb/object/composite.C b/cde/programs/dtinfo/DtMmdb/object/composite.C index 8a3e2b7e..2c832ade 100644 --- a/cde/programs/dtinfo/DtMmdb/object/composite.C +++ b/cde/programs/dtinfo/DtMmdb/object/composite.C @@ -72,7 +72,7 @@ int composite::first() const 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; diff --git a/cde/programs/dtinfo/DtMmdb/object/compressed_pstring.h b/cde/programs/dtinfo/DtMmdb/object/compressed_pstring.h index 4125e14c..81a1d799 100644 --- a/cde/programs/dtinfo/DtMmdb/object/compressed_pstring.h +++ b/cde/programs/dtinfo/DtMmdb/object/compressed_pstring.h @@ -73,10 +73,10 @@ protected: oid_t compress_agent_id; - unsigned int v_uncompressed_sz; - compress_agent_handler* agent; + unsigned int v_uncompressed_sz; + protected: void _compress(); diff --git a/cde/programs/dtinfo/DtMmdb/object/cset.C b/cde/programs/dtinfo/DtMmdb/object/cset.C index b14008c5..cb6086f0 100644 --- a/cde/programs/dtinfo/DtMmdb/object/cset.C +++ b/cde/programs/dtinfo/DtMmdb/object/cset.C @@ -100,7 +100,7 @@ handler* cset::get_component(int index) 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)); } @@ -115,7 +115,7 @@ oid_list_handler* cset::get_locs(handler& query, int 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)); } @@ -130,7 +130,7 @@ oid_t cset::get_first_oid(const handler& query, int 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)); } @@ -140,7 +140,7 @@ c_index_handler* cset::get_index_ptr(int index) void cset::batch_index_begin() { - for ( int i=0; i batch_index_begin(); } @@ -149,7 +149,7 @@ void cset::batch_index_begin() void cset::batch_index_end() { - for ( int i=0; i batch_index_end(); } @@ -255,7 +255,7 @@ new_object.its_oid().asciiOut(cerr); cerr << "\n"; #endif } - for ( int i = 1; i < num_indices; i++ ) { + for ( unsigned int i = 1; i < num_indices; i++ ) { if ( indices[i] == 0 ) continue; @@ -287,7 +287,7 @@ Boolean cset::remove_component(const oid_t& x_oid) { 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; @@ -324,7 +324,7 @@ cset::update_index(handler* old_comp_obj, handler* new_comp_obj, 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)); } @@ -364,7 +364,7 @@ io_status cset::cdrIn(buffer& buf) 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(); diff --git a/cde/programs/dtinfo/DtMmdb/object/dl_list.C b/cde/programs/dtinfo/DtMmdb/object/dl_list.C index d8a20554..b975d781 100644 --- a/cde/programs/dtinfo/DtMmdb/object/dl_list.C +++ b/cde/programs/dtinfo/DtMmdb/object/dl_list.C @@ -179,7 +179,7 @@ handler* dl_list::get_component(int index) 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 ) @@ -352,7 +352,7 @@ v_dl_list_tail.asciiOut(out); cerr << "\n"; 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")); @@ -377,7 +377,7 @@ v_dl_list_tail.asciiOut(out); cerr << "\n"; void dl_list::batch_index_begin() { - for ( int i=0; i batch_index_begin(); } @@ -386,7 +386,7 @@ void dl_list::batch_index_begin() void dl_list::batch_index_end() { - for ( int i=0; i batch_index_end(); } @@ -456,7 +456,7 @@ dl_list::insert_to_indices(const dl_list_cell_handler& new_object) } - 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; @@ -521,7 +521,7 @@ io_status dl_list::cdrIn(buffer& buf) 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)); } @@ -535,7 +535,7 @@ oid_t dl_list::get_first_oid(const handler& query, int 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() ; diff --git a/cde/programs/dtinfo/DtMmdb/object/handler.h b/cde/programs/dtinfo/DtMmdb/object/handler.h index 906ce2a6..484c773a 100644 --- a/cde/programs/dtinfo/DtMmdb/object/handler.h +++ b/cde/programs/dtinfo/DtMmdb/object/handler.h @@ -92,9 +92,9 @@ protected: //static memory_pool handler_space_pool; protected: - rootPtr obj_ptr; abs_storage* store; oid_t obj_id; + rootPtr obj_ptr; }; diff --git a/cde/programs/dtinfo/DtMmdb/object/long_pstring.C b/cde/programs/dtinfo/DtMmdb/object/long_pstring.C index e655cac2..e1568e53 100644 --- a/cde/programs/dtinfo/DtMmdb/object/long_pstring.C +++ b/cde/programs/dtinfo/DtMmdb/object/long_pstring.C @@ -85,7 +85,7 @@ long_pstring::extract(int left, int right, char* sink) //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)); } diff --git a/cde/programs/dtinfo/DtMmdb/object/oid_list.C b/cde/programs/dtinfo/DtMmdb/object/oid_list.C index 1a02df86..a277c762 100644 --- a/cde/programs/dtinfo/DtMmdb/object/oid_list.C +++ b/cde/programs/dtinfo/DtMmdb/object/oid_list.C @@ -105,7 +105,7 @@ oid_list::oid_list(oid_list& x) : 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)); } @@ -240,7 +240,7 @@ debug(cerr, int(this)); 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)); } @@ -330,7 +330,7 @@ oid_list::update_component(int index, const oid_t& new_oid) { //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)); } @@ -379,8 +379,6 @@ io_status oid_list::asciiIn(istream& in) if ( in.get() != '\n' ) throw(formatException("should be a \n")); - handler* hd_ptr = 0; - dlist temp_list; dlist_void_ptr_cell* y = 0; diff --git a/cde/programs/dtinfo/DtMmdb/object/oid_list.h b/cde/programs/dtinfo/DtMmdb/object/oid_list.h index e221ae1b..beafdaf4 100644 --- a/cde/programs/dtinfo/DtMmdb/object/oid_list.h +++ b/cde/programs/dtinfo/DtMmdb/object/oid_list.h @@ -66,8 +66,8 @@ class oid_list: public composite { protected: - chunks_index* chk_index; Boolean f_internal_index; + chunks_index* chk_index; union { mmdb_pos_t loc; diff --git a/cde/programs/dtinfo/DtMmdb/object/oid_t.C b/cde/programs/dtinfo/DtMmdb/object/oid_t.C index 98790967..c453c1d7 100644 --- a/cde/programs/dtinfo/DtMmdb/object/oid_t.C +++ b/cde/programs/dtinfo/DtMmdb/object/oid_t.C @@ -111,8 +111,8 @@ oid_t::oid_t(const char* source, Boolean ascii_format, Boolean swap_order) /* 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); */ } diff --git a/cde/programs/dtinfo/DtMmdb/object/oid_t.h b/cde/programs/dtinfo/DtMmdb/object/oid_t.h index 0c1cc147..44d21a39 100644 --- a/cde/programs/dtinfo/DtMmdb/object/oid_t.h +++ b/cde/programs/dtinfo/DtMmdb/object/oid_t.h @@ -77,7 +77,7 @@ public: 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 @@ -138,10 +138,10 @@ protected: } 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; diff --git a/cde/programs/dtinfo/DtMmdb/object/pstring.C b/cde/programs/dtinfo/DtMmdb/object/pstring.C index 784cfc6e..04bd4180 100644 --- a/cde/programs/dtinfo/DtMmdb/object/pstring.C +++ b/cde/programs/dtinfo/DtMmdb/object/pstring.C @@ -271,7 +271,7 @@ cerr << "\n"; out << v_sz << '\t'; - for ( int i=0; i v_sz ) { + if ( comps > (int) v_sz ) { MESSAGE(cerr, "tuple asciiIn(): to expand space"); debug(cerr, comps); debug(cerr, v_sz); diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/asciiIn_filters.C b/cde/programs/dtinfo/DtMmdb/oliasdb/asciiIn_filters.C index 146d0f48..6cf2be1f 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/asciiIn_filters.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/asciiIn_filters.C @@ -77,7 +77,9 @@ char* get_oid_2(info_lib* infolib_ptr, char* base_str, char* locator) 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" diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_book_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_book_test.C index 4e4d77c8..a955b21d 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_book_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_book_test.C @@ -29,7 +29,6 @@ extern "C" void showBook(DtMmdbInfoRequest* req) { const char* str = 0; - int size = 0; DtMmdbHandle* id = 0; unsigned int l; int x ; @@ -59,7 +58,7 @@ void showBook(DtMmdbInfoRequest* req) ids = DtMmdbBookGetTabList(req, &l); if (ids) { - for ( x=0; 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; diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_dlp_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_dlp_test.C index adc3b9d9..009afab3 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_dlp_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_dlp_test.C @@ -49,7 +49,6 @@ int test_dlp(int argc, char** argv) { int j = 0; int i = 0; - const char* str; DtMmdbInfoRequest* req ; switch ( argc ) { diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_graphic_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_graphic_test.C index 1f0e505f..b9bf70a4 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_graphic_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_graphic_test.C @@ -31,7 +31,7 @@ void showGraphic(DtMmdbInfoRequest* req) { const char* str; unsigned int l; - int i; + unsigned int i; DtMmdbGraphicInfo* info ; if ( req == 0 ) return ; @@ -68,7 +68,6 @@ int test_graphic1(int argc, char** argv) { int j = 0; int i = 0; - const char* str; DtMmdbInfoRequest* req; switch ( argc ) { @@ -99,7 +98,6 @@ int test_graphic2(int argc, char** argv) { int j = 0; int i = 0; - const char* str; DtMmdbInfoRequest* req; switch ( argc ) { diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_infolib.C b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_infolib.C index 8e8339a1..37f83614 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_infolib.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_infolib.C @@ -56,8 +56,6 @@ DtMmdbOpenInfoLib( { 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); diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_locator_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_locator_test.C index 9cfc7abd..b54291f3 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_locator_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_locator_test.C @@ -49,7 +49,6 @@ int test_loc1(int argc, char** argv) { int j = 0; int i = 0; - const char* str; DtMmdbInfoRequest* req; switch ( argc ) { @@ -80,7 +79,6 @@ int test_loc2(int argc, char** argv) { int j = 0; int i = 0; - const char* str; DtMmdbInfoRequest* req ; switch ( argc ) { diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_section_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_section_test.C index 19f26e2f..ff77b812 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_section_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_section_test.C @@ -75,9 +75,7 @@ extern "C" int test2(int argc, char** argv) { int j = 0; - int n = 0; int i = -1; - const char* str; DtMmdbInfoRequest* req = 0; switch ( argc ) { @@ -106,10 +104,9 @@ extern "C" 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: { diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_stylesheet_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_stylesheet_test.C index 9b66f93c..1b9d911d 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_stylesheet_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_stylesheet_test.C @@ -49,7 +49,6 @@ int test_ss1(int argc, char** argv) { int j = 0; int i = 0; - const char* str; DtMmdbInfoRequest* req ; switch ( argc ) { @@ -80,7 +79,6 @@ int test_ss2(int argc, char** argv) { int j = 0; int i = 0; - const char* str; DtMmdbInfoRequest* req ; switch ( argc ) { diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_test.C index 71850306..49673372 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_test.C @@ -156,7 +156,7 @@ char* DtMmdbHandleToString(DtMmdbHandle* x) 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; diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_toc_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_toc_test.C index c6e666cc..80e0c133 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_toc_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/c_api_toc_test.C @@ -30,7 +30,7 @@ void showTOC(DtMmdbInfoRequest* req) { DtMmdbHandle* id = 0; unsigned int ct = 0; - int i = 0; + unsigned int i = 0; DtMmdbHandle** ids = 0; if ( req == 0 ) return ; @@ -59,7 +59,6 @@ int test4(int argc, char** argv) { int j = 0; int i = 0; - const char* str; DtMmdbInfoRequest* req = 0; switch ( argc ) { diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/collectionIterator.h b/cde/programs/dtinfo/DtMmdb/oliasdb/collectionIterator.h index d8f428ef..70277c8f 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/collectionIterator.h +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/collectionIterator.h @@ -49,9 +49,9 @@ protected: 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 diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/graphic_hd.C b/cde/programs/dtinfo/DtMmdb/oliasdb/graphic_hd.C index 287a78f2..405754bb 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/graphic_hd.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/graphic_hd.C @@ -184,6 +184,8 @@ const char* graphic_smart_ptr::title() return 0; } end_try; + + return 0; } int graphic_smart_ptr::type() const diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/graphic_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/graphic_test.C index 6def80fe..50e8d8c9 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/graphic_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/graphic_test.C @@ -71,7 +71,8 @@ int compare_graphic(graphic_smart_ptr& pattern, info_base* base_ptr) 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]; diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/mark_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/mark_test.C index 27d7772b..9220f4c6 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/mark_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/mark_test.C @@ -63,7 +63,7 @@ mark_base* get_mark_base(char* path, char* name) ); } - catch (mmdbException &,e) + catch (MMDBeXCEPtion &,e) { return 0; } end_try; diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/mmdb.C b/cde/programs/dtinfo/DtMmdb/oliasdb/mmdb.C index 8d005334..ed1c9f39 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/mmdb.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/mmdb.C @@ -214,7 +214,7 @@ Boolean OLIAS_DB::real_destroy(const char* infoLibPath, const char* infoLibName) 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') ) { diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/node_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/node_test.C index 95b7eb7f..c331c0cf 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/node_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/node_test.C @@ -55,7 +55,8 @@ int compare_node(node_smart_ptr& pattern, info_base* base_ptr) 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]; diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/olias_funcs.C b/cde/programs/dtinfo/DtMmdb/oliasdb/olias_funcs.C index c5768813..ec401c55 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/olias_funcs.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/olias_funcs.C @@ -102,14 +102,14 @@ void insert_to_collection(c_code_t ccode, istream& in) coll_type obj_type = VOID; abs_storage* store = 0; - handler* hd = 0; +// handler* hd = 0; int i; for ( i = 0; i its_store(); - hd = set_map[i].collection_hd; +// hd = set_map[i].collection_hd; break; } } @@ -119,7 +119,7 @@ void insert_to_collection(c_code_t ccode, istream& in) 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; } } diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/olias_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/olias_test.C index 1874de84..fad998dd 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/olias_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/olias_test.C @@ -236,7 +236,7 @@ int generate_stream(info_base* b_ptr, char* path, int num_sections, int min, int 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 ) @@ -252,14 +252,14 @@ int generate_stream(info_base* b_ptr, char* path, int num_sections, int min, int 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; @@ -432,8 +432,8 @@ int auto_test(int argc, char** argv, OLIAS_DB& db) 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]); @@ -450,8 +450,8 @@ int auto_test(int argc, char** argv, OLIAS_DB& db) // 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]); @@ -467,7 +467,7 @@ int auto_test(int argc, char** argv, OLIAS_DB& db) // 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; @@ -490,7 +490,7 @@ int auto_test(int argc, char** argv, OLIAS_DB& db) 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; @@ -504,7 +504,7 @@ int auto_test(int argc, char** argv, OLIAS_DB& db) 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; @@ -517,7 +517,7 @@ int auto_test(int argc, char** argv, OLIAS_DB& db) 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; diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/stylesheet_test.C b/cde/programs/dtinfo/DtMmdb/oliasdb/stylesheet_test.C index 2a818b10..37911d63 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/stylesheet_test.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/stylesheet_test.C @@ -44,7 +44,8 @@ int compare_stylesheet(stylesheet_smart_ptr& pattern, info_base* base_ptr) 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]; @@ -61,7 +62,9 @@ void update_stylesheet_test(char* filename, info_base* base_ptr, char* locator) 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)); diff --git a/cde/programs/dtinfo/DtMmdb/oliasdb/user_base.C b/cde/programs/dtinfo/DtMmdb/oliasdb/user_base.C index 675bb27f..06aeb60a 100644 --- a/cde/programs/dtinfo/DtMmdb/oliasdb/user_base.C +++ b/cde/programs/dtinfo/DtMmdb/oliasdb/user_base.C @@ -65,10 +65,11 @@ extern Boolean g_transaction_on; 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; @@ -91,9 +92,12 @@ user_base::user_base( const char* spec_path, rw_flag_t rw) : 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(); @@ -106,9 +110,9 @@ user_base::user_base( const char* base_dir, 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; @@ -157,17 +161,24 @@ user_base::checking_status_t user_base::check_mode() 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; @@ -392,6 +403,8 @@ MESSAGE(cerr, store_ptr -> my_name()); Boolean user_base::define() { + int len; + if ( check_and_create_dir(base_path) == false ) { throw(stringException(form("can't create %s", base_path))); } @@ -402,10 +415,14 @@ Boolean user_base::define() 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) { @@ -419,7 +436,11 @@ Boolean user_base::define() /* 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 = diff --git a/cde/programs/dtinfo/DtMmdb/schema/container_desc.C b/cde/programs/dtinfo/DtMmdb/schema/container_desc.C index c32a9973..4cecc660 100644 --- a/cde/programs/dtinfo/DtMmdb/schema/container_desc.C +++ b/cde/programs/dtinfo/DtMmdb/schema/container_desc.C @@ -51,7 +51,7 @@ #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) { } diff --git a/cde/programs/dtinfo/DtMmdb/schema/index_desc.C b/cde/programs/dtinfo/DtMmdb/schema/index_desc.C index f58a2430..cf6fb0be 100644 --- a/cde/programs/dtinfo/DtMmdb/schema/index_desc.C +++ b/cde/programs/dtinfo/DtMmdb/schema/index_desc.C @@ -56,8 +56,8 @@ #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(""); @@ -73,18 +73,12 @@ void index_desc::set_inv_nm(const char* str) { 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) diff --git a/cde/programs/dtinfo/DtMmdb/schema/object_dict.C b/cde/programs/dtinfo/DtMmdb/schema/object_dict.C index 71c9bed5..90532875 100644 --- a/cde/programs/dtinfo/DtMmdb/schema/object_dict.C +++ b/cde/programs/dtinfo/DtMmdb/schema/object_dict.C @@ -104,7 +104,9 @@ desc* object_dict::init_a_base(char* db_path, char* db_name) { //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; @@ -131,7 +133,7 @@ desc* object_dict::init_a_base(char* db_path, char* db_name) 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) ) @@ -171,10 +173,14 @@ desc* object_dict::init_a_base(char* define_desc_path, char* db_path, //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; @@ -188,11 +194,11 @@ desc* object_dict::init_a_base(char* define_desc_path, char* db_path, 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))); } @@ -213,7 +219,7 @@ desc* object_dict::init_a_base(char* define_desc_path, char* 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]; @@ -225,7 +231,8 @@ desc* object_dict::init_a_base(char* define_desc_path, char* db_path, 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); diff --git a/cde/programs/dtinfo/DtMmdb/schema/object_dict.h b/cde/programs/dtinfo/DtMmdb/schema/object_dict.h index 9d23da8c..aa7c8095 100644 --- a/cde/programs/dtinfo/DtMmdb/schema/object_dict.h +++ b/cde/programs/dtinfo/DtMmdb/schema/object_dict.h @@ -92,10 +92,10 @@ protected: 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 diff --git a/cde/programs/dtinfo/DtMmdb/schema/sheet.C b/cde/programs/dtinfo/DtMmdb/schema/sheet.C index 1769b63e..484f23fe 100644 --- a/cde/programs/dtinfo/DtMmdb/schema/sheet.C +++ b/cde/programs/dtinfo/DtMmdb/schema/sheet.C @@ -22,7 +22,7 @@ */ // $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 @@ -370,7 +370,7 @@ int * 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; diff --git a/cde/programs/dtinfo/DtMmdb/schema/store_desc.C b/cde/programs/dtinfo/DtMmdb/schema/store_desc.C index 48a5e347..4e185685 100644 --- a/cde/programs/dtinfo/DtMmdb/schema/store_desc.C +++ b/cde/programs/dtinfo/DtMmdb/schema/store_desc.C @@ -115,15 +115,13 @@ void store_desc::set_mode(const char* str) 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 active_elmts()); diff --git a/cde/programs/dtinfo/DtMmdb/storage/page_storage.C b/cde/programs/dtinfo/DtMmdb/storage/page_storage.C index aa15811f..5694eba7 100644 --- a/cde/programs/dtinfo/DtMmdb/storage/page_storage.C +++ b/cde/programs/dtinfo/DtMmdb/storage/page_storage.C @@ -391,8 +391,6 @@ debug(cerr, len); debug(cerr, str_offset); */ - Boolean ok = false; - buffer in_cache(0); in_cache.set_chunk(base, len); @@ -595,8 +593,8 @@ debug(cerr, name); 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; @@ -761,9 +759,9 @@ debug(cerr, int(string_ptr)); #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; } @@ -779,8 +777,8 @@ cerr << "append:" << u1 << "." << u2 << " " << len << "\n"; - int page_num ; - int slot_num ; + int page_num = 0; + int slot_num = 0; page* y; spointer_t *x; @@ -910,8 +908,10 @@ io_status page_storage::asciiOut(ostream& out) { int ind = first(); while ( ind != 0 ) { +#ifdef DEBUG page* p = (*this)(ind, READ); debug(out, *p); +#endif next(ind); } return done; @@ -1187,7 +1187,7 @@ void page_storage::roll_back() // 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) && diff --git a/cde/programs/dtinfo/DtMmdb/storage/page_storage.h b/cde/programs/dtinfo/DtMmdb/storage/page_storage.h index a919293c..edeb398d 100644 --- a/cde/programs/dtinfo/DtMmdb/storage/page_storage.h +++ b/cde/programs/dtinfo/DtMmdb/storage/page_storage.h @@ -89,14 +89,14 @@ class store_trans 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); @@ -125,7 +125,7 @@ class page_storage : public abs_storage { protected: - buffer* v_buf; // aux. buf. + store_trans trans_info; int page_sz ; // page size @@ -142,15 +142,15 @@ protected: 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); diff --git a/cde/programs/dtinfo/DtMmdb/storage/spointer.h b/cde/programs/dtinfo/DtMmdb/storage/spointer.h index f8574267..af5d4445 100644 --- a/cde/programs/dtinfo/DtMmdb/storage/spointer.h +++ b/cde/programs/dtinfo/DtMmdb/storage/spointer.h @@ -90,7 +90,7 @@ public: 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; }; diff --git a/cde/programs/dtinfo/DtMmdb/storage/store_test.C b/cde/programs/dtinfo/DtMmdb/storage/store_test.C index b5835ea8..ce7314bb 100644 --- a/cde/programs/dtinfo/DtMmdb/storage/store_test.C +++ b/cde/programs/dtinfo/DtMmdb/storage/store_test.C @@ -35,7 +35,7 @@ void real_page_cache_test_1(pm_random& rand_gen, page_storage** st, unsigned int 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 @@ -66,7 +66,7 @@ prepare_store(char* path, lru& open_file_policy, page_storage** x = new page_storagePtr[ct]; unixf_storage* unix_file = 0; - for ( int i=0; i fd()); #else + char* info_lib_file = form("%s/%s", path, name); + total_bytes = ::bytes(info_lib_file); #endif } diff --git a/cde/programs/dtinfo/DtMmdb/utility/atoi_fast.C b/cde/programs/dtinfo/DtMmdb/utility/atoi_fast.C index f19ef0a7..11d10ae4 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/atoi_fast.C +++ b/cde/programs/dtinfo/DtMmdb/utility/atoi_fast.C @@ -66,8 +66,8 @@ void atoi_fast::init(int r, int, pm_random& rdm_generator) 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++ ) { @@ -113,22 +113,22 @@ int atoi_fast::atoi(const char* string, int l, int , int rang ) const 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; @@ -187,7 +187,7 @@ int atoi_fast::atoi(const char* str, int offset, int rang ) const 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; } diff --git a/cde/programs/dtinfo/DtMmdb/utility/atoi_pearson.C b/cde/programs/dtinfo/DtMmdb/utility/atoi_pearson.C index 6e9a9f5d..f2379d43 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/atoi_pearson.C +++ b/cde/programs/dtinfo/DtMmdb/utility/atoi_pearson.C @@ -75,7 +75,7 @@ void atoi_pearson::init(int r, int, pm_random& rdm_generator) v_tbl = new char[v_entries]; - int i; + unsigned int i; for ( i = 0; i < v_entries; i++ ) v_tbl[i] = i; @@ -175,7 +175,7 @@ int atoi_pearson::atoi(const char* str, int offset, int rang ) const 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; } diff --git a/cde/programs/dtinfo/DtMmdb/utility/atoi_pearson.h b/cde/programs/dtinfo/DtMmdb/utility/atoi_pearson.h index ff684508..4fdd224e 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/atoi_pearson.h +++ b/cde/programs/dtinfo/DtMmdb/utility/atoi_pearson.h @@ -75,13 +75,13 @@ private: 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; }; diff --git a/cde/programs/dtinfo/DtMmdb/utility/atomic_lock.C b/cde/programs/dtinfo/DtMmdb/utility/atomic_lock.C index 34ab68ba..0cd00cd0 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/atomic_lock.C +++ b/cde/programs/dtinfo/DtMmdb/utility/atomic_lock.C @@ -58,7 +58,8 @@ extern int errno; 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() diff --git a/cde/programs/dtinfo/DtMmdb/utility/buffer.C b/cde/programs/dtinfo/DtMmdb/utility/buffer.C index 344ef69f..1ab495ac 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/buffer.C +++ b/cde/programs/dtinfo/DtMmdb/utility/buffer.C @@ -308,7 +308,7 @@ buffer& buffer::put(const char content, Boolean exp_buf) { //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); @@ -391,7 +391,7 @@ buffer& buffer::put(const float content, Boolean exp_buf) /***********************************************************/ 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 { diff --git a/cde/programs/dtinfo/DtMmdb/utility/c_ios.h b/cde/programs/dtinfo/DtMmdb/utility/c_ios.h index 5ee86840..1c6dff14 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/c_ios.h +++ b/cde/programs/dtinfo/DtMmdb/utility/c_ios.h @@ -32,8 +32,8 @@ class ios { protected: - int f_state; streambuf* sbuf; // buffer that provides char sequence read/write + int f_state; public: diff --git a/cde/programs/dtinfo/DtMmdb/utility/c_streambuf.h b/cde/programs/dtinfo/DtMmdb/utility/c_streambuf.h index 0b23fcd0..9528ee66 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/c_streambuf.h +++ b/cde/programs/dtinfo/DtMmdb/utility/c_streambuf.h @@ -57,16 +57,16 @@ class streambuf 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) {}; diff --git a/cde/programs/dtinfo/DtMmdb/utility/filebuf.C b/cde/programs/dtinfo/DtMmdb/utility/filebuf.C index 9e1865ec..a8b7ce51 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/filebuf.C +++ b/cde/programs/dtinfo/DtMmdb/utility/filebuf.C @@ -48,8 +48,8 @@ filebuf::~filebuf() ///////////////////////////////////////////// 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; @@ -66,8 +66,8 @@ filebuf::filebuf(int __fd) : } 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); } diff --git a/cde/programs/dtinfo/DtMmdb/utility/funcs.C b/cde/programs/dtinfo/DtMmdb/utility/funcs.C index 96e8cfed..ab51d6d0 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/funcs.C +++ b/cde/programs/dtinfo/DtMmdb/utility/funcs.C @@ -80,6 +80,8 @@ int getdomainname(char *, int); #endif /* __osf__ */ #include +#define BUFLEN 512 + #ifdef USL int _DtMmdbStrcasecmp(register const char* s1, register const char* s2) @@ -201,8 +203,8 @@ int pos_of_LSB(const unsigned int y) { switch (y) { - case 8192: return 14; - case 1024: return 11; + case 8192: return 13; + case 1024: return 10; default: { @@ -211,8 +213,8 @@ int pos_of_LSB(const unsigned int y) //debug(cerr, x); //debug(cerr, hex(x)); - int i; - for ( int i =0; i>= 8; else @@ -275,7 +277,8 @@ unsigned getbits(unsigned x, unsigned p, unsigned n) int del_file(const char* filename, const char* pathname) { - static char buf[512]; + unsigned int len, slen; + static char buf[BUFLEN]; int ok; @@ -283,13 +286,19 @@ int del_file(const char* filename, const char* pathname) 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); } @@ -331,8 +340,8 @@ copy_file(const char* path, const char* file, 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) ; } @@ -689,15 +698,18 @@ char* form(const char* fmt, ...) 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; } @@ -731,16 +743,15 @@ char* access_info( char* request ) 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"), */ @@ -801,6 +812,7 @@ Boolean writeToTmpFile(char* unique_nm, char* str, int size) 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"; @@ -815,12 +827,15 @@ Boolean writeToTmpFile(char* unique_nm, char* str, int size) 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); diff --git a/cde/programs/dtinfo/DtMmdb/utility/macro.h b/cde/programs/dtinfo/DtMmdb/utility/macro.h index 8513e228..a7eaf0d4 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/macro.h +++ b/cde/programs/dtinfo/DtMmdb/utility/macro.h @@ -70,6 +70,11 @@ #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__ diff --git a/cde/programs/dtinfo/DtMmdb/utility/rw_lock.C b/cde/programs/dtinfo/DtMmdb/utility/rw_lock.C index 412b47bb..e6e466b8 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/rw_lock.C +++ b/cde/programs/dtinfo/DtMmdb/utility/rw_lock.C @@ -184,7 +184,7 @@ Boolean write_lock(char* lock_file_path, char*& ai_info ) { - int ret; + unsigned int len, slen; atomic_lock l(lock_file_path); if ( l.lock() == false ) { @@ -217,8 +217,14 @@ Boolean write_lock(char* lock_file_path, 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'; } } @@ -232,7 +238,9 @@ Boolean write_lock(char* lock_file_path, ///////////////////////////////////////// // 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"; diff --git a/cde/programs/dtinfo/DtMmdb/utility/stream.C b/cde/programs/dtinfo/DtMmdb/utility/stream.C index 3447e68f..9458e377 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/stream.C +++ b/cde/programs/dtinfo/DtMmdb/utility/stream.C @@ -35,7 +35,7 @@ char* sform(const char* fmt ...) va_start(args, fmt); - (void) vsprintf(buf, fmt, args); + (void) vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); diff --git a/cde/programs/dtinfo/DtMmdb/utility/types.h b/cde/programs/dtinfo/DtMmdb/utility/types.h index 1a319c6e..bd689ebb 100644 --- a/cde/programs/dtinfo/DtMmdb/utility/types.h +++ b/cde/programs/dtinfo/DtMmdb/utility/types.h @@ -79,7 +79,7 @@ typedef void (*print_func_ptr_t)(ostream&, const void*); //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; -- 2.25.1