summaryrefslogtreecommitdiffhomepage
path: root/Parser
diff options
context:
space:
mode:
authorFWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2011-12-08 16:45:43 +0000
committerFWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544>2011-12-08 16:45:43 +0000
commit50971e84e295033941fac5291b08e593541fe945 (patch)
treea1e43917a11c9cceef9bd54e3e526e640f89ae02 /Parser
parent8b31193bae95cadc667c6e65817aab688c915f1d (diff)
downloadstarshatter-50971e84e295033941fac5291b08e593541fe945.zip
starshatter-50971e84e295033941fac5291b08e593541fe945.tar.gz
starshatter-50971e84e295033941fac5291b08e593541fe945.tar.bz2
Various replacements for unsafe string handling
Diffstat (limited to 'Parser')
-rw-r--r--Parser/Parser.cpp2
-rw-r--r--Parser/Reader.cpp5
-rw-r--r--Parser/Token.cpp10
3 files changed, 8 insertions, 9 deletions
diff --git a/Parser/Parser.cpp b/Parser/Parser.cpp
index f8dea6f..ae1c157 100644
--- a/Parser/Parser.cpp
+++ b/Parser/Parser.cpp
@@ -30,7 +30,7 @@ static int dump_tokens = 0;
Term* error(char* msg, const Token& token)
{
static char buf[1024];
- sprintf(buf, " near '%s' in line %d.", (const char*) token.symbol(), token.line());
+ sprintf_s(buf, " near '%s' in line %d.", (const char*) token.symbol(), token.line());
return error(msg, buf);
}
diff --git a/Parser/Reader.cpp b/Parser/Reader.cpp
index 14b1126..2863d01 100644
--- a/Parser/Reader.cpp
+++ b/Parser/Reader.cpp
@@ -15,7 +15,7 @@
#include "MemDebug.h"
#include "reader.h"
#include <stdio.h>
-#include <fstream.h>
+#include <fstream>
#include <ctype.h>
@@ -60,8 +60,7 @@ FileReader::more()
{
if (done) return Text();
- ifstream fin;
- fin.open(filename, ios::in | ios::nocreate);
+ std::fstream fin(filename, std::fstream::in);
if (!fin) {
Print("ERROR(Parse): Could not open file '%s'\n", filename);
diff --git a/Parser/Token.cpp b/Parser/Token.cpp
index a7470ee..7ccabd8 100644
--- a/Parser/Token.cpp
+++ b/Parser/Token.cpp
@@ -42,7 +42,7 @@ Token::Token(const Token& rhs)
{
mLength = rhs.mLength;
if (mLength < 8) {
- strcpy(mSymbol, rhs.mSymbol);
+ strcpy_s(mSymbol, rhs.mSymbol);
}
else {
mFullSymbol = new(__FILE__, __LINE__) char[mLength + 1];
@@ -62,7 +62,7 @@ Token::Token(const char* s, int t, int k, int l, int c)
{
mLength = strlen(s);
if (mLength < 8) {
- strcpy(mSymbol, s);
+ strcpy_s(mSymbol, s);
}
else {
mFullSymbol = new(__FILE__, __LINE__) char[mLength + 1];
@@ -75,7 +75,7 @@ Token::Token(const Text& s, int t, int k, int l, int c)
{
mLength = s.length();
if (mLength < 8) {
- strcpy(mSymbol, s.data());
+ strcpy_s(mSymbol, s.data());
}
else {
mFullSymbol = new(__FILE__, __LINE__) char[mLength + 1];
@@ -107,7 +107,7 @@ Token::operator = (const Token& rhs)
mLength = rhs.mLength;
if (mLength < 8) {
- strcpy(mSymbol, rhs.mSymbol);
+ strcpy_s(mSymbol, rhs.mSymbol);
}
else {
mFullSymbol = new(__FILE__, __LINE__) char[mLength + 1];
@@ -181,7 +181,7 @@ bool
Token::findKey(const Text& k, int& v)
{
if (keymap.contains(k)) {
- v = keymap.find(k);
+ v = keymap.find(k, 0);
return true;
}
else