Skip to content

Commit 005afb0

Browse files
committed
instream: make InStream constructor take std::string
... to eliminate the c_str() conversions all over the code No changes in behavior intended by this commit.
1 parent eea3155 commit 005afb0

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/abstract-writer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool AbstractWriter::handleFile(
5959
bool AbstractWriter::handleFile(const std::string &fileName, bool silent)
6060
{
6161
try {
62-
InStream str(fileName.c_str());
62+
InStream str(fileName);
6363
return this->handleFile(str.str(), fileName, silent);
6464
}
6565
catch (const InFileException &e) {

src/csdiff.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ int main(int argc, char *argv[])
153153

154154
try {
155155
// open streams
156-
InStream strOld(fnOld.c_str());
157-
InStream strNew(fnNew.c_str());
156+
InStream strOld(fnOld);
157+
InStream strNew(fnNew);
158158

159159
// run the core
160160
return diffScans(std::cout, strOld.str(), strNew.str(),

src/cshtml.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,15 @@ int main(int argc, char *argv[])
122122

123123
try {
124124
// initialize parser for .err
125-
InStream strInput(fnInput.c_str());
125+
InStream strInput(fnInput);
126126
Parser pInput(strInput.str(), fnInput, silent);
127127

128128
DefLookup baseLookup;
129129
TScanProps baseProps;
130130

131131
// read old defects if given
132132
if (!fnBase.empty()) {
133-
InStream strBase(fnBase.c_str());
133+
InStream strBase(fnBase);
134134
Parser pBase(strBase.str(), fnBase, silent);
135135
Defect def;
136136
while (pBase.getNext(&def))

src/cslinker.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool loadPropsFromIniFile(
5555
{
5656
try {
5757
// open the input file
58-
InStream input(fName.c_str());
58+
InStream input(fName);
5959

6060
// parse .ini
6161
pt::ptree root;
@@ -233,7 +233,7 @@ int main(int argc, char *argv[])
233233
if (!fnCwe.empty()) {
234234
try {
235235
// load CWE mapping from the given file
236-
InStream strCwe(fnCwe.c_str());
236+
InStream strCwe(fnCwe);
237237
if (!cweDec->cweMap().loadCweMap(strCwe.str(), fnCwe))
238238
hasError = true;
239239
}
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
246246
if (!fnImp.empty()) {
247247
try {
248248
// load list of important defects
249-
InStream strImp(fnImp.c_str());
249+
InStream strImp(fnImp);
250250
Parser pImp(strImp.str(), fnImp);
251251
Defect defImp;
252252
while (pImp.getNext(&defImp))
@@ -267,7 +267,7 @@ int main(int argc, char *argv[])
267267

268268
try {
269269
// initialize parser for .err
270-
InStream strErr(fnErr.c_str());
270+
InStream strErr(fnErr);
271271
Parser pErr(strErr.str(), fnErr, silent);
272272

273273
if (!i) {

src/instream.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919

2020
#include "instream.hh"
2121

22-
InStream::InStream(const char *fName):
22+
InStream::InStream(const std::string &fName):
2323
fileName_(fName),
2424
str_((!fileName_.compare("-"))
2525
? std::cin
2626
: fileStr_)
2727
{
2828
if (&str_ == &fileStr_)
29-
fileStr_.open(fName, std::ios::in);
29+
fileStr_.open(fileName_, std::ios::in);
3030

3131
if (!fileStr_)
3232
throw InFileException(fileName_);

src/instream.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct InFileException {
3636

3737
class InStream {
3838
public:
39-
InStream(const char *fileName);
39+
InStream(const std::string &fileName);
4040
~InStream();
4141

4242
const std::string& fileName() const { return fileName_; }

0 commit comments

Comments
 (0)