aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2017-02-08 11:03:42 +0100
committerEugene Sandulenko2017-02-08 17:30:17 +0100
commit296dac6bc278400e3d17b4596de8e10f515c07f1 (patch)
tree536f4d0f1378203ba6fd423c48de6f52c956e460 /engines
parent1b53a2ce75c0bd693d0a3f6c26805b0ea8f2fc15 (diff)
downloadscummvm-rg350-296dac6bc278400e3d17b4596de8e10f515c07f1.tar.gz
scummvm-rg350-296dac6bc278400e3d17b4596de8e10f515c07f1.tar.bz2
scummvm-rg350-296dac6bc278400e3d17b4596de8e10f515c07f1.zip
DIRECTOR: Lingo: Switched Symbol::name to Common::String
Diffstat (limited to 'engines')
-rw-r--r--engines/director/lingo/lingo-builtins.cpp3
-rw-r--r--engines/director/lingo/lingo-code.cpp10
-rw-r--r--engines/director/lingo/lingo-codegen.cpp10
-rw-r--r--engines/director/lingo/lingo.cpp3
-rw-r--r--engines/director/lingo/lingo.h2
5 files changed, 11 insertions, 17 deletions
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 40a6e917ca..2005aa11a2 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -254,8 +254,7 @@ void Lingo::initBuiltIns() {
for (BuiltinProto *blt = builtins; blt->name; blt++) {
Symbol *sym = new Symbol;
- sym->name = (char *)calloc(strlen(blt->name) + 1, 1);
- Common::strlcpy(sym->name, blt->name, strlen(blt->name));
+ sym->name = blt->name;
sym->type = BLTIN;
sym->nargs = blt->minArgs;
sym->maxArgs = blt->maxArgs;
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 7046fed979..9e737176a8 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -170,8 +170,8 @@ void Lingo::c_printtop(void) {
if (!d.u.sym) {
warning("Inconsistent stack: var, val: %d", d.u.i);
} else {
- if (d.u.sym->name)
- warning("var: %s", d.u.sym->name);
+ if (!d.u.sym->name.empty())
+ warning("var: %s", d.u.sym->name.c_str());
else
warning("Nameless var. val: %d", d.u.sym->u.i);
}
@@ -305,7 +305,7 @@ void Lingo::c_assign() {
if (d1.u.sym->type != INT && d1.u.sym->type != VOID &&
d1.u.sym->type != FLOAT && d1.u.sym->type != STRING) {
- warning("assignment to non-variable '%s'", d1.u.sym->name);
+ warning("assignment to non-variable '%s'", d1.u.sym->name.c_str());
return;
}
@@ -341,13 +341,13 @@ void Lingo::c_assign() {
bool Lingo::verify(Symbol *s) {
if (s->type != INT && s->type != VOID && s->type != FLOAT && s->type != STRING && s->type != POINT) {
- warning("attempt to evaluate non-variable '%s'", s->name);
+ warning("attempt to evaluate non-variable '%s'", s->name.c_str());
return false;
}
if (s->type == VOID)
- warning("Variable used before assigning a value '%s'", s->name);
+ warning("Variable used before assigning a value '%s'", s->name.c_str());
return true;
}
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp
index 32d0bbbc11..dccb95e0c1 100644
--- a/engines/director/lingo/lingo-codegen.cpp
+++ b/engines/director/lingo/lingo-codegen.cpp
@@ -170,8 +170,7 @@ Symbol *Lingo::lookupVar(const char *name, bool create, bool putInGlobalList) {
return NULL;
sym = new Symbol;
- sym->name = (char *)calloc(strlen(name) + 1, 1);
- Common::strlcpy(sym->name, name, strlen(name) + 1);
+ sym->name = name;
sym->type = VOID;
sym->u.i = 0;
@@ -198,7 +197,6 @@ void Lingo::cleanLocalVars() {
for (SymbolHash::const_iterator h = _localvars->begin(); h != _localvars->end(); ++h) {
if (!h->_value->global) {
Symbol *sym = h->_value;
- free(sym->name);
delete sym;
}
}
@@ -218,8 +216,7 @@ void Lingo::define(Common::String &name, int start, int nargs, Common::String *p
if (sym == NULL) { // Create variable if it was not defined
sym = new Symbol;
- sym->name = (char *)calloc(name.size() + 1, 1);
- Common::strlcpy(sym->name, name.c_str(), name.size() + 1);
+ sym->name = name;
sym->type = HANDLER;
_handlers[ENTITY_INDEX(_eventHandlerTypeIds[name.c_str()], _currentEntityId)] = sym;
@@ -388,8 +385,7 @@ void Lingo::codeFactory(Common::String &name) {
Symbol *sym = new Symbol;
- sym->name = (char *)calloc(name.size() + 1, 1);
- Common::strlcpy(sym->name, name.c_str(), name.size());
+ sym->name = name;
sym->type = BLTIN;
sym->nargs = -1;
sym->maxArgs = 0;
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index f7eafda11b..9a92d2f2ac 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -75,7 +75,6 @@ struct EventHandlerType {
};
Symbol::Symbol() {
- name = NULL;
type = VOID;
u.s = NULL;
nargs = 0;
@@ -395,7 +394,7 @@ Common::String *Datum::toString() {
*s = "#void";
break;
case VAR:
- *s = Common::String::format("var: #%s", u.sym->name);
+ *s = Common::String::format("var: #%s", u.sym->name.c_str());
break;
default:
warning("Incorrect operation toString() for type: %s", type2str());
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index afadef7a90..66f3d3a3d3 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -104,7 +104,7 @@ struct Pointer_Hash {
typedef Common::HashMap<void *, FuncDesc *, Pointer_Hash, Pointer_EqualTo> FuncHash;
struct Symbol { /* symbol table entry */
- char *name;
+ Common::String name;
int type;
union {
int i; /* VAR */