# HG changeset patch # User David A. Holland # Date 1653968782 14400 # Node ID 607e3be6bad86c78ba8221e1229010f561cdb462 # Parent 7661c1604e49cdbfface54e4cf05962cc510dc8b Adjust to the moving target called the C++ standard. Apparently nowadays it's not allowed to define an explicit copy constructor but not an assignment operator. Consequently, defining the explicit copy constructor in terms of the implicit/automatic assignment operator for general convenience no longer works. Add assignment operators. Caution: not tested with the IBM compiler, but there's no particular reason it shouldn't work. diff -r 7661c1604e49 -r 607e3be6bad8 anagram/agcore/keyword.cpp --- a/anagram/agcore/keyword.cpp Mon May 30 23:32:56 2022 -0400 +++ b/anagram/agcore/keyword.cpp Mon May 30 23:46:22 2022 -0400 @@ -332,6 +332,10 @@ : KeyedObjectRegister(t) {} +void Keyword::operator = (const Keyword &t) { + KeyedObjectRegister::operator = (t); +} + Keyword::Keyword(const char *x) : KeyedObjectRegister(KeywordDescriptor(x)) {} diff -r 7661c1604e49 -r 607e3be6bad8 anagram/agcore/keyword.h --- a/anagram/agcore/keyword.h Mon May 30 23:32:56 2022 -0400 +++ b/anagram/agcore/keyword.h Mon May 30 23:46:22 2022 -0400 @@ -21,6 +21,7 @@ Keyword(const char *x); Keyword(unsigned x); Keyword(const Keyword &t); + void operator = (const Keyword &t); static void reset(); static Keyword create(); diff -r 7661c1604e49 -r 607e3be6bad8 anagram/agcore/rpz.cpp --- a/anagram/agcore/rpz.cpp Mon May 30 23:32:56 2022 -0400 +++ b/anagram/agcore/rpz.cpp Mon May 30 23:46:22 2022 -0400 @@ -319,7 +319,8 @@ sis(tn); return; } - tn = n->token_number = Token::create(); + n->token_number = Token::create(); + tn = n->token_number; tn->token_name = n; tn->value_type = 0; if (!flag && n->parse_tree.isNotNull()) { @@ -356,7 +357,8 @@ rcs(); LOGV((int) keyword->token_number); if (keyword->token_number.isNull()) { - Token token = keyword->token_number = Token::create(); + keyword->token_number = Token::create(); + Token token = keyword->token_number; LOGV((int) token); token->key = keyword; token->value_type = void_token_type; diff -r 7661c1604e49 -r 607e3be6bad8 anagram/agcore/rule.cpp --- a/anagram/agcore/rule.cpp Mon May 30 23:32:56 2022 -0400 +++ b/anagram/agcore/rule.cpp Mon May 30 23:46:22 2022 -0400 @@ -44,6 +44,9 @@ Rule::Rule() : ObjectRegister() {} Rule::Rule(int x) : ObjectRegister(x) {} Rule::Rule(const Rule &t) : ObjectRegister(t) {} +void Rule::operator = (const Rule &t) { + ObjectRegister::operator = (t); +} RuleDescriptor &Rule::Map::operator [] (unsigned x) { @@ -216,7 +219,7 @@ int VpRuleDescriptor::operator < (const VpRuleDescriptor x) const { if (elementList < x.elementList) return 1; if (x.elementList < elementList) return 0; - return procedureName < procedureName; + return procedureName < x.procedureName; } VpRule::VpRule() : KeyedObjectRegister() {} diff -r 7661c1604e49 -r 607e3be6bad8 anagram/agcore/rule.h --- a/anagram/agcore/rule.h Mon May 30 23:32:56 2022 -0400 +++ b/anagram/agcore/rule.h Mon May 30 23:46:22 2022 -0400 @@ -24,6 +24,7 @@ Rule();// {} Rule(int x); Rule(const Rule &t); + void operator = (const Rule &); Token &token(int) const; static Rule create(); diff -r 7661c1604e49 -r 607e3be6bad8 anagram/agcore/symbol.cpp --- a/anagram/agcore/symbol.cpp Mon May 30 23:32:56 2022 -0400 +++ b/anagram/agcore/symbol.cpp Mon May 30 23:46:22 2022 -0400 @@ -22,6 +22,10 @@ // Nothing to do } +void Symbol::operator = (const Symbol &t) { + KeyedObjectRegister::operator = (t); +} + void Symbol::reset() { LOGSECTION("Symbol::reset"); KeyedObjectRegister::reset(); diff -r 7661c1604e49 -r 607e3be6bad8 anagram/agcore/symbol.h --- a/anagram/agcore/symbol.h Mon May 30 23:32:56 2022 -0400 +++ b/anagram/agcore/symbol.h Mon May 30 23:46:22 2022 -0400 @@ -20,6 +20,7 @@ Symbol(const char *x); Symbol(unsigned x); Symbol(const Symbol &t); + void operator = (const Symbol &t); static void reset(); static Symbol create(); static Symbol sorted(int x); diff -r 7661c1604e49 -r 607e3be6bad8 anagram/agcore/token.cpp --- a/anagram/agcore/token.cpp Mon May 30 23:32:56 2022 -0400 +++ b/anagram/agcore/token.cpp Mon May 30 23:46:22 2022 -0400 @@ -56,7 +56,9 @@ Token::Token(int x) : ObjectRegister(x) {} Token::Token(const Token &t) : ObjectRegister(t) {} - +void Token::operator = (const Token &t) { + ObjectRegister::operator = (t); +} Token Token::create() { LOGSECTION("Token::create"); diff -r 7661c1604e49 -r 607e3be6bad8 anagram/agcore/token.h --- a/anagram/agcore/token.h Mon May 30 23:32:56 2022 -0400 +++ b/anagram/agcore/token.h Mon May 30 23:46:22 2022 -0400 @@ -20,6 +20,7 @@ Token() {} Token(int x); Token(const Token &t); + void operator = (const Token &); static Token create(); static const int first; static void reset(); diff -r 7661c1604e49 -r 607e3be6bad8 anagram/agcore/tree.cpp --- a/anagram/agcore/tree.cpp Mon May 30 23:32:56 2022 -0400 +++ b/anagram/agcore/tree.cpp Mon May 30 23:46:22 2022 -0400 @@ -37,6 +37,10 @@ : KeyedObjectRegister(t) {} +void ParseTree::operator = (const ParseTree &t) { + KeyedObjectRegister::operator = (t); +} + ParseTree::ParseTree(CharSetExpression *x) : KeyedObjectRegister(parse_tree_map(x)) { diff -r 7661c1604e49 -r 607e3be6bad8 anagram/agcore/tree.h --- a/anagram/agcore/tree.h Mon May 30 23:32:56 2022 -0400 +++ b/anagram/agcore/tree.h Mon May 30 23:46:22 2022 -0400 @@ -21,6 +21,7 @@ ParseTree(unsigned x); ParseTree(const ParseTree &t); ParseTree(CharSetExpression *x); + void operator = (const ParseTree &t); static void reset(); class Map; diff -r 7661c1604e49 -r 607e3be6bad8 anagram/support/agarray-imp.h --- a/anagram/support/agarray-imp.h Mon May 30 23:32:56 2022 -0400 +++ b/anagram/support/agarray-imp.h Mon May 30 23:46:22 2022 -0400 @@ -91,6 +91,18 @@ } template +AgArray::AgArray(const AgArray &c) + : AgReferenceBase(c.size() ? new Kernel(c.size()) : 0) +{ + //LOGSECTION("AgArray::AgArray(AgArray)"); + //LOGV(c.size()); + int n = c.size(); + for (int i = 0; i < n; i++) { + (*this)[i] = c[i]; + } +} + +template void AgArray::copy(T *s, unsigned n) { T *data = kernel().data; assert(n <= kernel().length); diff -r 7661c1604e49 -r 607e3be6bad8 anagram/support/agarray.h --- a/anagram/support/agarray.h Mon May 30 23:32:56 2022 -0400 +++ b/anagram/support/agarray.h Mon May 30 23:46:22 2022 -0400 @@ -47,6 +47,7 @@ AgArray(); inline AgArray(unsigned n) : AgReferenceBase(n ? new Kernel(n) : 0) {} AgArray(const AgIndexedContainer &); + AgArray(const AgArray &); void reset() { discardData(); } diff -r 7661c1604e49 -r 607e3be6bad8 anagram/support/cint.h --- a/anagram/support/cint.h Mon May 30 23:32:56 2022 -0400 +++ b/anagram/support/cint.h Mon May 30 23:46:22 2022 -0400 @@ -38,6 +38,12 @@ } #endif + cint operator = (cint r) { + x = r.x; + y = r.y; + return r; + } + int operator == (const cint r) const { return (x == r.x && y == r.y); } int operator != (const cint r) const { return (x != r.x || y != r.y); } cint operator + (cint r) const { diff -r 7661c1604e49 -r 607e3be6bad8 examples/dsl/redirect.cpp --- a/examples/dsl/redirect.cpp Mon May 30 23:32:56 2022 -0400 +++ b/examples/dsl/redirect.cpp Mon May 30 23:46:22 2022 -0400 @@ -64,7 +64,14 @@ copy_flag = 0; // live } -redirect::redirect(redirect &r) { +void redirect::operator = (const redirect &r) { + handle = r.handle; + old_handle = r.old_handle; + strcpy(name, r.name); + copy_flag = r.copy_flag; +} + +redirect::redirect(const redirect &r) { *this = r; copy_flag++; // memorex } diff -r 7661c1604e49 -r 607e3be6bad8 examples/dsl/redirect.h --- a/examples/dsl/redirect.h Mon May 30 23:32:56 2022 -0400 +++ b/examples/dsl/redirect.h Mon May 30 23:46:22 2022 -0400 @@ -59,7 +59,8 @@ // Constructors redirect(int h); redirect(int h, char *file_name, int append_flag = 0); - redirect(redirect &); + redirect(const redirect &); + void operator = (const redirect &); // Reset friend redirect &reset(redirect &e) { diff -r 7661c1604e49 -r 607e3be6bad8 oldclasslib/README.txt --- a/oldclasslib/README.txt Mon May 30 23:32:56 2022 -0400 +++ b/oldclasslib/README.txt Mon May 30 23:46:22 2022 -0400 @@ -31,3 +31,7 @@ as well as using the provided operator[] directly. This seems stupid bordering on insane, but when compilers start citing the standard at you there isn't much choice but to go along. + +- Added explicit assignment operator definitions in places where gcc +10.x now refuses to produce them automatically. Added missing "const" +to some of the copy constructor arguments. diff -r 7661c1604e49 -r 607e3be6bad8 oldclasslib/include/charsink.h --- a/oldclasslib/include/charsink.h Mon May 30 23:32:56 2022 -0400 +++ b/oldclasslib/include/charsink.h Mon May 30 23:46:22 2022 -0400 @@ -67,7 +67,14 @@ error_flag = copy_flag = 0; } - output_file(output_file &f) : character_sink() { + void operator = (const output_file &f) { + file = f.file; + name = f.name; + error_flag = f.error_flag; + copy_flag = f.copy_flag; + } + + output_file(const output_file &f) : character_sink() { *this = f; copy_flag++; } @@ -123,6 +130,7 @@ string_accumulator(int nc, int nx = 1); string_accumulator(const string_accumulator &); + void operator = (const string_accumulator &); // Destructor diff -r 7661c1604e49 -r 607e3be6bad8 oldclasslib/include/strdict.h --- a/oldclasslib/include/strdict.h Mon May 30 23:32:56 2022 -0400 +++ b/oldclasslib/include/strdict.h Mon May 30 23:46:22 2022 -0400 @@ -45,8 +45,9 @@ string_dictionary(unsigned size, unsigned word_length = 10); - string_dictionary(string_dictionary &); + string_dictionary(const string_dictionary &); + void operator = (const string_dictionary &); // Destructor diff -r 7661c1604e49 -r 607e3be6bad8 oldclasslib/source/charsink.cpp --- a/oldclasslib/source/charsink.cpp Mon May 30 23:32:56 2022 -0400 +++ b/oldclasslib/source/charsink.cpp Mon May 30 23:46:22 2022 -0400 @@ -63,6 +63,16 @@ // Copy constructor +void string_accumulator::operator = (const string_accumulator &s) { + cs = s.cs; + xs = s.xs; + csx = s.csx; + xsx = s.xsx; + csmax = s.csmax; + xsmax = s.xsmax; + copy_flag = s.copy_flag; +} + string_accumulator::string_accumulator(const string_accumulator &s) : character_sink() { diff -r 7661c1604e49 -r 607e3be6bad8 oldclasslib/source/strdict.cpp --- a/oldclasslib/source/strdict.cpp Mon May 30 23:32:56 2022 -0400 +++ b/oldclasslib/source/strdict.cpp Mon May 30 23:46:22 2022 -0400 @@ -46,7 +46,22 @@ copy_flag = 0; // live } -string_dictionary::string_dictionary(string_dictionary &s) { +void string_dictionary::operator = (const string_dictionary &s) { + sxs = s.sxs; + cs = s.cs; + csx = s.csx; + csxmax = s.csxmax; + ns = s.ns; + nsmax = s.nsmax; + ht = s.ht; + htl = s.htl; + htmask = s.htmask; + n_calls = s.n_calls; + n_collisions = s.n_collisions; + copy_flag = s.copy_flag; +} + +string_dictionary::string_dictionary(const string_dictionary &s) { *this = s; copy_flag++; //memorex }