Commit 4361020f authored by Jochen Meyer's avatar Jochen Meyer Committed by Graeme Stewart
Browse files

removing gcc 2.95 specific code (MuonCablingTools-00-01-10)

	* removing gcc 2.95 specific code
	* tagged as MuonCablingTools-00-01-10

2015-05-22  Jochen Meyer <jomeyer@mail.cern.ch>
	* addressing coverity defect 30158 OBO Scott Snyder (ATLASRECTS-2115)
	* tagged as MuonCablingTools-00-01-09

2015-05-15  Jochen Meyer <jomeyer@mail.cern.ch>
	* addressing coverity defect 11842 ... OBO Scott Snyder (ATLASRECTS-2115)
	* tagged as MuonCablingTools-00-01-08

2015-05-12  ADA <dellacqu@mail.cern.ch>
	* addressing coverity defect 11842 and similar
	* tagged as MuonCablingTools-00-01-07

2015-05-11  Jochen Meyer <jomeyer@mail.cern.ch>
	* addressing coverity defect 11464 (again)
	* tagged as MuonCablingTools-00-01-06

2015-04-10  Jochen Meyer <jomeyer@mail.cern.ch>
...
(Long ChangeLog diff - truncated)
parent 8a829f14
......@@ -45,12 +45,7 @@ enum ObjectType {Logic,Data,Hardware,Monitoring};
class MessageStream
{
private:
#if (__GNUC__) && (__GNUC__ > 2) // put your gcc 3.2 specific code here
__osstream* m_display;
#else // put your gcc 2.95 specific code here
char* m_buffer_display;
__osstream* m_display;
#endif
public:
void init_message(void);
void delete_message(void);
......@@ -79,7 +74,7 @@ class BaseObject
BaseObject (const BaseObject&);
~BaseObject();
BaseObject operator = (const BaseObject&);
BaseObject& operator = (const BaseObject&);
ObjectType tag(void) const {return m_tag;}
std::string name(void) const {return m_name;}
......
......@@ -5,19 +5,8 @@
#ifndef OUTPUTDEF_H
#define OUTPUTDEF_H
// for compatibility between gcc2.95 and gcc3.2
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
#include <sstream>
typedef std::ostringstream __osstream;
#define COUNT str().size()
#else
// put your gcc 2.95 specific code here
#include <strstream>
typedef ostrstream __osstream;
#define COUNT pcount()
#endif
#include <sstream>
typedef std::ostringstream __osstream;
#define COUNT str().size()
#endif
......@@ -6,21 +6,9 @@
#define RPCDECODER_H
#include "MuonCablingTools/RPCdef.h"
#include <iostream>
// for compatibility between gcc2.95 and gcc3.2
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
#include <sstream>
typedef std::ostringstream __osstream;
#else
// put your gcc 2.95 specific code here
#include <strstream>
typedef ostrstream __osstream;
#endif
#include <sstream>
typedef std::ostringstream __osstream;
class RPCdecoder
{
......@@ -59,7 +47,7 @@ class RPCdecoder
RPCdecoder(ViewType,int,int,int,int,int);
RPCdecoder(const RPCdecoder& deco);
RPCdecoder operator = (const RPCdecoder& deco);
RPCdecoder& operator = (const RPCdecoder& deco);
~RPCdecoder() {}
......@@ -95,17 +83,7 @@ class RPCdecoder
template <class X> X& operator<<(X& stream,const RPCdecoder& decoder)
{
// for compatibility between gcc2.95 and gcc3.2
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
__osstream display;
#else
// put your gcc 2.95 specific code here
char buffer[10000];
for (int i=0;i<10000;++i) buffer[i] = '\0';
__osstream display(buffer,10000);
#endif
decoder.Print(display,false);
stream << display.str();
return stream;
......
......@@ -7,17 +7,8 @@
#include <iostream>
// for compatibility between gcc2.95 and gcc3.2
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
#include <sstream>
typedef std::ostringstream __osstream;
#else
// put your gcc 2.95 specific code here
#include <strstream>
typedef ostrstream __osstream;
#endif
#include <sstream>
typedef std::ostringstream __osstream;
template <class Type>
class ShowRequest
......@@ -53,16 +44,7 @@ template <class Type> std::ostream& operator<<
(std::ostream& stream,const ShowRequest<Type>& print)
{
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
__osstream display;
#else
// put your gcc 2.95 specific code here
char buffer[50000];
for (int i=0;i<50000;++i) buffer[i] = '\0';
__osstream display(buffer,50000);
#endif
print.m_object->Print(display,print.m_detail);
stream << display.str();
return stream;
......@@ -74,17 +56,7 @@ template <class Type> std::ostream& operator<<
template <class Type> MsgStream& operator<<
(MsgStream& stream,const ShowRequest<Type>& print)
{
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
__osstream display;
#else
// put your gcc 2.95 specific code here
char buffer[50000];
for (int i=0;i<50000;++i) buffer[i] = '\0';
__osstream display(buffer,50000);
#endif
print.m_object->Print(display,print.m_detail);
stream << display.str();
return stream;
......
......@@ -268,19 +268,9 @@
#include <typeinfo>
#include <stdint.h>
// for compatibility between gcc2.95 and gcc3.2
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
#include <sstream>
typedef std::ostringstream __osstream;
typedef std::istringstream __isstream;
#else
// put your gcc 2.95 specific code here
#include <strstream>
typedef ostrstream __osstream;
typedef istrstream __isstream;
#endif
#include <sstream>
typedef std::ostringstream __osstream;
typedef std::istringstream __isstream;
typedef enum result_extraction {not_extracted,extracted} DBstatus;
......@@ -305,6 +295,7 @@ class DBline: virtual public std::ios
bool m_fail;
bool m_empty;
DBstatus m_extraction;
int m_base;
// Private member functions for setting internal status
......@@ -323,6 +314,7 @@ class DBline: virtual public std::ios
// Private member functions for extracting data
template <class type> void GetValue(type &value);
void GetValue(std::string &value);
quote check_quote(std::string &);
void GetStr(std::string &);
......
......@@ -15,29 +15,13 @@ using namespace std;
void
MessageStream::init_message()
{
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
m_display = new __osstream;
#else
// put your gcc 2.95 specific code here
const int buffer_length=10000;
m_buffer_display = new char[buffer_length];
for(int i=0;i<buffer_length;++i) m_buffer_display[i]='\0';
m_display = new __osstream(m_buffer_display,buffer_length);
#endif
}
void
MessageStream::delete_message()
{
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
delete m_display;
#else
// put your gcc 2.95 specific code here
delete []m_buffer_display;
delete m_display;
#endif
}
......@@ -157,10 +141,14 @@ BaseObject::unlock() const
pthread_mutex_unlock(&StopDisplayStream);
}
BaseObject
BaseObject&
BaseObject::operator=(const BaseObject& obj)
{
m_tag = obj.tag();
m_name = obj.name();
if(this!=&obj) {
m_tag = obj.m_tag;
m_name = obj.m_name;
delete m_message;
m_message = new MessageStream;
}
return*this;
}
......@@ -20,7 +20,7 @@ const char RPCdecoder::value_descriptions[4][15] =
{{"strip_type"},{"logic_sector"},{"lvl1_station"},{"rpc_layer"}};
///////////////////////////////////////////////////////////////////////////////
RPCdecoder::RPCdecoder() {this->reset_status();}
RPCdecoder::RPCdecoder() {this->reset();}
RPCdecoder::RPCdecoder(unsigned int code)
{
......@@ -53,7 +53,7 @@ RPCdecoder::RPCdecoder(const RPCdecoder& deco)
///////////////////////////////////////////////////////////////////////////////
RPCdecoder RPCdecoder::operator = (const RPCdecoder& deco)
RPCdecoder& RPCdecoder::operator = (const RPCdecoder& deco)
{
this->reset();
this->set_indexes(deco.code());
......@@ -89,15 +89,7 @@ RPCdecoder::reset_status()
void
RPCdecoder::fault_decoding(int value,value_type type)
{
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
__osstream disp;
#else
// put your gcc 2.95 specific code here
char buffer[5000];
for (int i=0;i<5000;++i) buffer[i] = '\0';
__osstream disp(buffer,5000);
#endif
disp << " RPC decoder error: received " << value_descriptions[type]
<< " = " << value << " (min = " << value_boundaries[type][0]
<< ", max = " << value_boundaries[type][1] << ")"<< endl;
......
......@@ -3,6 +3,7 @@
*/
#include "MuonCablingTools/dbline.h"
#include <type_traits>
using namespace std;
......@@ -72,17 +73,46 @@ template <class type> void
DBline::GetValue(type &value)
{
if (!m_extraction||m_fail) return;
unsigned long int start = m_data.find_first_not_of(" ",m_pos);
std::string::size_type start = m_data.find_first_not_of(" ",m_pos);
if(start == string::npos) {BadExtraction();return;}
unsigned long int stop = m_data.find_first_of(" ",start+1) - 1;
std::string::size_type stop = m_data.find_first_of(" ",start+1);
if (stop == std::string::npos) stop = m_data.size();
__isstream tmp(m_data.substr(start,stop).c_str());
// __isstream tmp(m_data.substr(start,stop).c_str());
tmp.flags(flags());
tmp >> value;
// tmp.flags(flags());
// tmp >> value;
if (typename std::is_unsigned<type>::type()) {
unsigned long temp=std::stoul(m_data.substr(start,stop-start),nullptr,m_base);
value = temp;
}
else {
int temp=std::stoi(m_data.substr(start,stop-start),nullptr,m_base);
value=temp;
}
m_data.erase(m_pos,stop-m_pos);
check_data();
}
void
DBline::GetValue(std::string &value)
{
if (!m_extraction||m_fail) return;
std::string::size_type start = m_data.find_first_not_of(" ",m_pos);
if(start == string::npos) {BadExtraction();return;}
std::string::size_type stop = m_data.find_first_of(" ",start+1);
if (stop == std::string::npos) stop = m_data.size();
// __isstream tmp(m_data.substr(start,stop).c_str());
// tmp.flags(flags());
// tmp >> value;
value = m_data.substr(start,stop-start);
unsigned long int del = (stop - start) + (start - m_pos) + 1;
m_data.erase(m_pos,del);
m_data.erase(m_pos,stop-m_pos);
check_data();
}
......@@ -91,7 +121,7 @@ DBline::GetStr(string &str)
{
GetValue(str);
quote pos = check_quote(str);
if(!pos) {return;}
if(pos == no_quote) {return;}
if(pos == begin_quote)
{
unsigned long int pos = m_data.find('"',m_pos);
......@@ -188,15 +218,8 @@ DBline::token(const string &str, type t)
if (pos != string::npos)
{
__osstream tmp;
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
tmp << t ;
string rep = tmp.str();
#else
// put your gcc 2.95 specific code here
tmp << t << ends;
string rep(tmp.str());
#endif
new_token.replace(pos,rep.length(),rep);
token(new_token);
......@@ -214,15 +237,8 @@ DBline::token(const string &str, type t, int /*size*/)
if (pos != string::npos)
{
__osstream tmp;
#if (__GNUC__) && (__GNUC__ > 2)
// put your gcc 3.2 specific code here
tmp << setw(2) << setfill('0') << t ;
string rep = tmp.str();
#else
// put your gcc 2.95 specific code here
tmp << t << ends;
string rep(tmp.str());
#endif
new_token.replace(pos,rep.length(),rep);
token(new_token);
......@@ -257,10 +273,10 @@ const char* DBline::dump(void) {return m_store.c_str();}
//////////////////////// FUNCTIONS TO SET THE I/O FORMAT //////////////////////
///////////////////////////////////////////////////////////////////////////////
DBline& DBline::hex(void){setf(ios::hex,ios::basefield);return*this;}
DBline& DBline::dec(void){setf(ios::dec,ios::basefield);return*this;}
DBline& DBline::oct(void){setf(ios::dec,ios::basefield);return*this;}
DBline& DBline::reset_fmt(void) {flags(m_default);return*this;}
DBline& DBline::hex(void){m_base=16;setf(ios::hex,ios::basefield);return*this;}
DBline& DBline::dec(void){m_base=10;setf(ios::dec,ios::basefield);return*this;}
DBline& DBline::oct(void){m_base=8; setf(ios::dec,ios::basefield);return*this;}
DBline& DBline::reset_fmt(void) {m_base=10;flags(m_default);return*this;}
///////////////////////////////////////////////////////////////////////////////
......@@ -298,6 +314,10 @@ DBline& DBline::operator>> (uint64_t &i64) {GetValue(i64);return*this;}
DBline& DBline::operator>> (DBfmt* f) {
flags(f->flags());
const std::ios_base::fmtflags fmt = f->flags() & std::ios_base::basefield;
if (fmt == std::ios::hex) m_base = 16;
else if (fmt == std::ios::oct) m_base = 8;
else m_base = 10;
if(del_dbfmt)delete f;
return*this;
}
......@@ -376,7 +396,8 @@ DBline::operator()(const string& str, int n, int s) {token(str,n,s);return*this;
DBline::DBline():
m_file(0),m_stream(0),m_data(""),m_backup(""),m_store(""),
m_pos(0), m_line(0),
m_fail(false),m_empty(false),m_extraction(extracted)
m_fail(false),m_empty(false),m_extraction(extracted),
m_base(10)
{
this->setf (std::ios::unitbuf |
std::ios::dec );
......@@ -406,7 +427,8 @@ DBline::DBline():
DBline::DBline(ifstream& file):
m_file(&file),m_stream(0),m_data(""),m_backup(""),m_store(""),
m_pos(0), m_line(0),
m_fail(false),m_empty(false),m_extraction(extracted)
m_fail(false),m_empty(false),m_extraction(extracted),
m_base(10)
{
this->setf (std::ios::unitbuf |
std::ios::dec );
......@@ -437,7 +459,8 @@ DBline::DBline(ifstream& file):
DBline::DBline(istream& stream):
m_file(0),m_stream(&stream),m_data(""),m_backup(""),m_store(""),
m_pos(0), m_line(0),
m_fail(false),m_empty(false),m_extraction(extracted)
m_fail(false),m_empty(false),m_extraction(extracted),
m_base(10)
{
this->setf (std::ios::unitbuf |
std::ios::dec );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment