Massive warnings fix, mostly "char *"->"const char *"

This commit is contained in:
Sven Hesse 2008-07-20 13:34:04 +00:00
parent 46ccb9d6f7
commit 8f16dad07c
41 changed files with 220 additions and 218 deletions

View file

@ -97,7 +97,7 @@ public:
void prepareSmushFrame(int width, int height, byte *bitmap); void prepareSmushFrame(int width, int height, byte *bitmap);
void drawSmushFrame(int offsetX, int offsetY); void drawSmushFrame(int offsetX, int offsetY);
char *getVideoDeviceName(); const char *getVideoDeviceName();
const ControlDescriptor *listControls(); const ControlDescriptor *listControls();
int getNumControls(); int getNumControls();

View file

@ -604,7 +604,7 @@ void DriverRonin::drawSmushFrame(int offsetX, int offsetY)
_polyCount++; _polyCount++;
} }
char *DriverRonin::getVideoDeviceName() const char *DriverRonin::getVideoDeviceName()
{ {
return "Dreamcast PowerVR Video Device"; return "Dreamcast PowerVR Video Device";
} }

View file

@ -124,7 +124,7 @@ public:
virtual void prepareSmushFrame(int width, int height, byte *bitmap) = 0; virtual void prepareSmushFrame(int width, int height, byte *bitmap) = 0;
virtual void drawSmushFrame(int offsetX, int offsetY) = 0; virtual void drawSmushFrame(int offsetX, int offsetY) = 0;
virtual char *getVideoDeviceName() = 0; virtual const char *getVideoDeviceName() = 0;
/** @name Events and Time */ /** @name Events and Time */
//@{ //@{
@ -192,7 +192,7 @@ public:
* *
*/ */
struct ControlDescriptor { struct ControlDescriptor {
char *name; const char *name;
int key; int key;
}; };

View file

@ -317,7 +317,7 @@ void DriverSDL::init() {
#endif #endif
} }
char *DriverSDL::getVideoDeviceName() { const char *DriverSDL::getVideoDeviceName() {
return "SDL Video Device"; return "SDL Video Device";
} }

View file

@ -54,7 +54,7 @@ public:
void setupIcon(); void setupIcon();
char *getVideoDeviceName(); const char *getVideoDeviceName();
const ControlDescriptor *listControls(); const ControlDescriptor *listControls();
int getNumControls(); int getNumControls();

View file

@ -954,7 +954,7 @@ void Costume::stopChores() {
_chores[i].stop(); _chores[i].stop();
} }
int Costume::isChoring(char *name, bool excludeLooping) { int Costume::isChoring(const char *name, bool excludeLooping) {
for (int i = 0; i < _numChores; i++) { for (int i = 0; i < _numChores; i++) {
if (!strcmp(_chores[i]._name, name) && _chores[i]._playing && !(excludeLooping && _chores[i]._looping)) if (!strcmp(_chores[i]._name, name) && _chores[i]._playing && !(excludeLooping && _chores[i]._looping))
return i; return i;

View file

@ -54,7 +54,7 @@ public:
Model::HierNode *getModelNodes(); Model::HierNode *getModelNodes();
void setColormap(char *map); void setColormap(char *map);
void stopChores(); void stopChores();
int isChoring(char *name, bool excludeLooping); int isChoring(const char *name, bool excludeLooping);
int isChoring(int num, bool excludeLooping); int isChoring(int num, bool excludeLooping);
int isChoring(bool excludeLooping); int isChoring(bool excludeLooping);

View file

@ -174,7 +174,7 @@ public:
bool _savegameLoadRequest; bool _savegameLoadRequest;
bool _savegameSaveRequest; bool _savegameSaveRequest;
char *_savegameFileName; const char *_savegameFileName;
SaveGame *_savedState; SaveGame *_savedState;
Engine(); Engine();

View file

@ -81,8 +81,8 @@ extern DIR *g_searchFile;
#define strmatch(src, dst) (strlen(src) == strlen(dst) && strcmp(src, dst) == 0) #define strmatch(src, dst) (strlen(src) == strlen(dst) && strcmp(src, dst) == 0)
#define DEBUG_FUNCTION() debugFunction("Function", __FUNCTION__) #define DEBUG_FUNCTION() debugFunction("Function", __FUNCTION__)
static void debugFunction(char *debugMessage, const char *funcName); static void debugFunction(const char *debugMessage, const char *funcName);
static void stubWarning(char *funcName); static void stubWarning(const char *funcName);
static inline bool isObject(int num) { static inline bool isObject(int num) {
lua_Object param = lua_getparam(num); lua_Object param = lua_getparam(num);
@ -222,7 +222,7 @@ static inline void pushbool(bool val) {
lua_pushnil(); lua_pushnil();
} }
static Costume *get_costume(Actor *a, int param, char *called_from) { static Costume *get_costume(Actor *a, int param, const char *called_from) {
Costume *result; Costume *result;
if (lua_isnil(lua_getparam(param))) { if (lua_isnil(lua_getparam(param))) {
result = a->currentCostume(); result = a->currentCostume();
@ -239,7 +239,7 @@ static Costume *get_costume(Actor *a, int param, char *called_from) {
// Lua interface to bundle_dofile // Lua interface to bundle_dofile
static void new_dofile() { static void new_dofile() {
char *fname_str = luaL_check_string(1); const char *fname_str = luaL_check_string(1);
bundle_dofile(fname_str); bundle_dofile(fname_str);
} }
@ -278,9 +278,9 @@ static void PrintWarning() {
} }
static void FunctionName() { static void FunctionName() {
char *name; const char *name;
char buf[256]; char buf[256];
char *filename; const char *filename;
int line; int line;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
@ -321,7 +321,7 @@ static void FunctionName() {
// File functions // File functions
static void CheckForFile() { static void CheckForFile() {
char *filename = luaL_check_string(1); const char *filename = luaL_check_string(1);
DEBUG_FUNCTION(); DEBUG_FUNCTION();
pushbool(g_resourceloader->fileExists(filename)); pushbool(g_resourceloader->fileExists(filename));
@ -359,7 +359,7 @@ static void GetColorComponents() {
// Registry functions // Registry functions
static void ReadRegistryValue() { static void ReadRegistryValue() {
char *key; const char *key;
const char *val; const char *val;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
@ -369,8 +369,8 @@ static void ReadRegistryValue() {
} }
static void WriteRegistryValue() { static void WriteRegistryValue() {
char *key; const char *key;
char *val; const char *val;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
key = luaL_check_string(1); key = luaL_check_string(1);
@ -420,7 +420,7 @@ static void GetCameraActor() {
} }
static void SetSayLineDefaults() { static void SetSayLineDefaults() {
char *key_text = NULL; const char *key_text = NULL;
lua_Object table_obj; lua_Object table_obj;
lua_Object key = LUA_NOOBJECT; lua_Object key = LUA_NOOBJECT;
@ -892,7 +892,7 @@ static void SetActorWalkDominate() {
} }
static void SetActorColormap() { static void SetActorColormap() {
char *mapname; const char *mapname;
CMap *_cmap; CMap *_cmap;
Actor *act; Actor *act;
@ -1467,7 +1467,7 @@ static void SetActorShadowPlane() {
DEBUG_FUNCTION(); DEBUG_FUNCTION();
Actor *act = check_actor(1); Actor *act = check_actor(1);
char *name = lua_getstring(lua_getparam(2)); const char *name = lua_getstring(lua_getparam(2));
act->setShadowPlane(name); act->setShadowPlane(name);
} }
@ -1476,7 +1476,7 @@ static void AddShadowPlane() {
DEBUG_FUNCTION(); DEBUG_FUNCTION();
Actor *act = check_actor(1); Actor *act = check_actor(1);
char *name = lua_getstring(lua_getparam(2)); const char *name = lua_getstring(lua_getparam(2));
act->addShadowPlane(name); act->addShadowPlane(name);
} }
@ -1534,7 +1534,7 @@ std::string parseMsgText(const char *msg, char *msgId) {
static void TextFileGetLine() { static void TextFileGetLine() {
char textBuf[512]; char textBuf[512];
textBuf[0] = 0; textBuf[0] = 0;
char *filename; const char *filename;
FILE *file; FILE *file;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
@ -1555,7 +1555,7 @@ static void TextFileGetLine() {
static void TextFileGetLineCount() { static void TextFileGetLineCount() {
char textBuf[512]; char textBuf[512];
char *filename; const char *filename;
FILE *file; FILE *file;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
@ -1592,8 +1592,8 @@ static void TextFileGetLineCount() {
// Localization function // Localization function
static void LocalizeString() { static void LocalizeString() {
char msgId[32], buf[640], *str; char msgId[32], buf[640];
char *result; const char *str, *result;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
str = luaL_check_string(1); str = luaL_check_string(1);
@ -1607,7 +1607,7 @@ static void LocalizeString() {
} else { } else {
result = str; result = str;
} }
lua_pushstring(const_cast<char *>(result)); lua_pushstring(result);
} }
static void SayLine() { static void SayLine() {
@ -1623,7 +1623,7 @@ static void SayLine() {
if (!lua_isnil(param2)) { if (!lua_isnil(param2)) {
do { do {
if (lua_isstring(param2)) { if (lua_isstring(param2)) {
char *tmpstr = lua_getstring(param2); const char *tmpstr = lua_getstring(param2);
msg = parseMsgText(tmpstr, msgId); msg = parseMsgText(tmpstr, msgId);
} else if (lua_isnumber(param2)) { } else if (lua_isnumber(param2)) {
pan = 64; pan = 64;
@ -1774,7 +1774,7 @@ static void MakeSectorActive(void) {
numSectors = g_engine->currScene()->getSectorCount(); numSectors = g_engine->currScene()->getSectorCount();
if (lua_isstring(sectorName)) { if (lua_isstring(sectorName)) {
char *name = luaL_check_string(1); const char *name = luaL_check_string(1);
for (i = 0; i < numSectors; i++) { for (i = 0; i < numSectors; i++) {
Sector *sector = g_engine->currScene()->getSectorBase(i); Sector *sector = g_engine->currScene()->getSectorBase(i);
@ -1906,7 +1906,7 @@ enum ImuseParam {
static void ImStartSound() { static void ImStartSound() {
int priority, group; int priority, group;
char *soundName; const char *soundName;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
soundName = luaL_check_string(1); soundName = luaL_check_string(1);
@ -1930,7 +1930,7 @@ static void ImStartSound() {
} }
static void ImStopSound() { static void ImStopSound() {
char *soundName; const char *soundName;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
soundName = luaL_check_string(1); soundName = luaL_check_string(1);
@ -1953,7 +1953,7 @@ static void ImResume() {
} }
static void ImSetVoiceEffect() { static void ImSetVoiceEffect() {
char *effectName; const char *effectName;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
effectName = luaL_check_string(1); effectName = luaL_check_string(1);
@ -1993,7 +1993,7 @@ static void ImGetSfxVol() {
static void ImSetParam() { static void ImSetParam() {
int param, value; int param, value;
char *soundName; const char *soundName;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
soundName = luaL_check_string(1); soundName = luaL_check_string(1);
@ -2014,7 +2014,7 @@ static void ImSetParam() {
} }
void ImGetParam() { void ImGetParam() {
char *soundName; const char *soundName;
int param; int param;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
@ -2036,7 +2036,7 @@ void ImGetParam() {
static void ImFadeParam() { static void ImFadeParam() {
int opcode, value, duration; int opcode, value, duration;
char *soundName; const char *soundName;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
soundName = luaL_check_string(1); soundName = luaL_check_string(1);
@ -2093,7 +2093,7 @@ static void SetSoundPosition() {
g_engine->currScene()->getSoundParameters(&minVolume, &maxVolume); g_engine->currScene()->getSoundParameters(&minVolume, &maxVolume);
} }
char *soundName = lua_getstring(lua_getresult(1)); const char *soundName = lua_getstring(lua_getresult(1));
if (isActor(lua_getparam(2))) { if (isActor(lua_getparam(2))) {
Actor *act = check_actor(2); Actor *act = check_actor(2);
@ -2197,7 +2197,7 @@ static void luaFileFindNext() {
} }
static void luaFileFindFirst() { static void luaFileFindFirst() {
char *path, *extension; const char *path, *extension;
lua_Object pathObj; lua_Object pathObj;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
@ -2291,7 +2291,7 @@ static void killBitmapPrimitives(Bitmap *bitmap)
} }
static void GetImage() { static void GetImage() {
char *bitmapName; const char *bitmapName;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
bitmapName = luaL_check_string(1); bitmapName = luaL_check_string(1);
@ -2326,7 +2326,7 @@ static void BlastImage() {
} }
void getTextObjectParams(TextObject *textObject, lua_Object table_obj) { void getTextObjectParams(TextObject *textObject, lua_Object table_obj) {
char *key_text = NULL; const char *key_text = NULL;
lua_Object key = LUA_NOOBJECT; lua_Object key = LUA_NOOBJECT;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
@ -2481,7 +2481,7 @@ static void SetTextSpeed() {
static void MakeTextObject() { static void MakeTextObject() {
TextObject *textObject = new TextObject(); TextObject *textObject = new TextObject();
lua_Object tableObj; lua_Object tableObj;
char *line; const char *line;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
line = lua_getstring(lua_getparam(1)); line = lua_getstring(lua_getparam(1));
@ -2538,7 +2538,7 @@ static void BlastText() {
DEBUG_FUNCTION(); DEBUG_FUNCTION();
TextObject *textObject = new TextObject(); TextObject *textObject = new TextObject();
lua_Object tableObj; lua_Object tableObj;
char *line; const char *line;
DEBUG_FUNCTION(); DEBUG_FUNCTION();
line = lua_getstring(lua_getparam(1)); line = lua_getstring(lua_getparam(1));
@ -2894,7 +2894,7 @@ static void GetDiskFreeSpace() {
static void NewObjectState() { static void NewObjectState() {
ObjectState *state = NULL; ObjectState *state = NULL;
ObjectState::Position pos; ObjectState::Position pos;
char *bitmap, *zbitmap; const char *bitmap, *zbitmap;
bool visible; bool visible;
int setupID; int setupID;
@ -2986,7 +2986,8 @@ static void ScreenShot() {
*/ */
static void GetSaveGameImage() { static void GetSaveGameImage() {
int width = 250, height = 188; int width = 250, height = 188;
char *filename, *data; const char *filename;
char *data;
Bitmap *screenshot; Bitmap *screenshot;
int dataSize; int dataSize;
@ -3013,7 +3014,7 @@ static void SubmitSaveGameData() {
lua_Object table, table2; lua_Object table, table2;
SaveGame *savedState; SaveGame *savedState;
int count = 0; int count = 0;
char *str; const char *str;
printf("SubmitSaveGameData() started.\n"); printf("SubmitSaveGameData() started.\n");
DEBUG_FUNCTION(); DEBUG_FUNCTION();
@ -3042,7 +3043,7 @@ static void SubmitSaveGameData() {
static void GetSaveGameData() { static void GetSaveGameData() {
lua_Object result; lua_Object result;
char *filename; const char *filename;
int dataSize; int dataSize;
printf("GetSaveGameData() started.\n"); printf("GetSaveGameData() started.\n");
@ -3127,7 +3128,7 @@ static void LockFont() {
DEBUG_FUNCTION(); DEBUG_FUNCTION();
param1 = lua_getparam(1); param1 = lua_getparam(1);
if (lua_isstring(param1)) { if (lua_isstring(param1)) {
char *fontName = lua_getstring(param1); const char *fontName = lua_getstring(param1);
Font *result = g_resourceloader->loadFont(fontName); Font *result = g_resourceloader->loadFont(fontName);
if (result) { if (result) {
result->luaRef(); result->luaRef();
@ -3243,7 +3244,7 @@ static void LoadBundle() {
* generate warnings about missing functions when the debug flag * generate warnings about missing functions when the debug flag
* is set to "Stub", warnings, or everything. * is set to "Stub", warnings, or everything.
*/ */
static void debugFunction(char *debugMessage, const char *funcName) { static void debugFunction(const char *debugMessage, const char *funcName) {
bool stubFn = strcmp(debugMessage, "WARNING: Stub function") == 0; bool stubFn = strcmp(debugMessage, "WARNING: Stub function") == 0;
FILE *output; FILE *output;
@ -3289,7 +3290,7 @@ static void debugFunction(char *debugMessage, const char *funcName) {
} }
// Stub function for builtin functions not yet implemented // Stub function for builtin functions not yet implemented
static void stubWarning(char *funcName) { static void stubWarning(const char *funcName) {
// If the user doesn't want these debug messages then don't print them // If the user doesn't want these debug messages then don't print them
if (debugLevel != DEBUG_WARN && debugLevel != DEBUG_STUB && debugLevel != DEBUG_FUNC && debugLevel != DEBUG_ALL) if (debugLevel != DEBUG_WARN && debugLevel != DEBUG_STUB && debugLevel != DEBUG_FUNC && debugLevel != DEBUG_ALL)
return; return;
@ -3454,7 +3455,7 @@ static void dummyHandler() {
// Entries in the system table // Entries in the system table
static struct { static struct {
char *name; const char *name;
int key; int key;
} system_defaults[] = { } system_defaults[] = {
{ "frameTime", 0 }, { "frameTime", 0 },
@ -3891,7 +3892,7 @@ int bundle_dofile(const char *filename) {
return result; return result;
} }
lua_Object getTableFunction(lua_Object table, char *name) { lua_Object getTableFunction(lua_Object table, const char *name) {
lua_pushobject(table); lua_pushobject(table);
lua_pushstring(const_cast<char *>(name)); lua_pushstring(const_cast<char *>(name));
lua_Object handler = lua_gettable(); lua_Object handler = lua_gettable();
@ -3917,8 +3918,8 @@ lua_Object getTableFunction(lua_Object table, char *name) {
return handler; return handler;
} }
lua_Object getTableValue(lua_Object table, char *name) { lua_Object getTableValue(lua_Object table, const char *name) {
char *key_text = NULL; const char *key_text = NULL;
lua_Object key = LUA_NOOBJECT; lua_Object key = LUA_NOOBJECT;
if (!lua_istable(table)) { if (!lua_istable(table)) {
@ -3978,14 +3979,14 @@ lua_Object getIndexedTableValue(lua_Object table, int index) {
return lua_getresult(2); return lua_getresult(2);
} }
void setTableValue(lua_Object table, char *name, int newvalue) { void setTableValue(lua_Object table, const char *name, int newvalue) {
lua_pushobject(table); lua_pushobject(table);
lua_pushstring(name); lua_pushstring(name);
lua_pushnumber(newvalue); lua_pushnumber(newvalue);
lua_settable(); lua_settable();
} }
void setTableValue(lua_Object table, char *name, lua_Object newvalue) { void setTableValue(lua_Object table, const char *name, lua_Object newvalue) {
lua_pushobject(table); lua_pushobject(table);
lua_pushstring(name); lua_pushstring(name);
if (newvalue == 0) if (newvalue == 0)
@ -4019,5 +4020,5 @@ Vector3d tableToVector(lua_Object table) {
lua_Object getEventHandler(const char *name) { lua_Object getEventHandler(const char *name) {
lua_Object system_table = lua_getglobal("system"); lua_Object system_table = lua_getglobal("system");
return getTableFunction(system_table, (char *)name); return getTableFunction(system_table, name);
} }

View file

@ -50,17 +50,17 @@ void setMovieTime(float movieTime);
lua_Object getEventHandler(const char *name); lua_Object getEventHandler(const char *name);
// set the value for a table item // set the value for a table item
void setTableValue(lua_Object table, char *name, int newvalue); void setTableValue(lua_Object table, const char *name, int newvalue);
void setTableValue(lua_Object table, char *name, lua_Object newvalue); void setTableValue(lua_Object table, const char *name, lua_Object newvalue);
// get the value of a table item // get the value of a table item
lua_Object getTableValue(lua_Object table, char *name); lua_Object getTableValue(lua_Object table, const char *name);
lua_Object getIndexedTableValue(lua_Object table, int index); lua_Object getIndexedTableValue(lua_Object table, int index);
// make a Vector3d object from coordinate table values // make a Vector3d object from coordinate table values
Vector3d tableToVector(lua_Object table); Vector3d tableToVector(lua_Object table);
// get a function stored in a table // get a function stored in a table
lua_Object getTableFunction(lua_Object table, char *name); lua_Object getTableFunction(lua_Object table, const char *name);
#endif #endif

View file

@ -136,13 +136,13 @@ int lua_callfunction (lua_Object function)
} }
lua_Object lua_gettagmethod (int tag, char *event) lua_Object lua_gettagmethod (int tag, const char *event)
{ {
return put_luaObject(luaT_gettagmethod(tag, event)); return put_luaObject(luaT_gettagmethod(tag, event));
} }
lua_Object lua_settagmethod (int tag, char *event) lua_Object lua_settagmethod (int tag, const char *event)
{ {
checkCparams(1); checkCparams(1);
luaT_settagmethod(tag, event, L->stack.top-1); luaT_settagmethod(tag, event, L->stack.top-1);
@ -208,7 +208,7 @@ lua_Object lua_createtable (void)
} }
lua_Object lua_getglobal (char *name) lua_Object lua_getglobal (const char *name)
{ {
luaD_checkstack(2); /* may need that to call T.M. */ luaD_checkstack(2); /* may need that to call T.M. */
luaV_getglobal(luaS_new(name)); luaV_getglobal(luaS_new(name));
@ -216,14 +216,14 @@ lua_Object lua_getglobal (char *name)
} }
lua_Object lua_rawgetglobal (char *name) lua_Object lua_rawgetglobal (const char *name)
{ {
TaggedString *ts = luaS_new(name); TaggedString *ts = luaS_new(name);
return put_luaObject(&ts->u.s.globalval); return put_luaObject(&ts->u.s.globalval);
} }
void lua_setglobal (char *name) void lua_setglobal (const char *name)
{ {
checkCparams(1); checkCparams(1);
luaD_checkstack(2); /* may need that to call T.M. */ luaD_checkstack(2); /* may need that to call T.M. */
@ -231,7 +231,7 @@ void lua_setglobal (char *name)
} }
void lua_rawsetglobal (char *name) void lua_rawsetglobal (const char *name)
{ {
TaggedString *ts = luaS_new(name); TaggedString *ts = luaS_new(name);
checkCparams(1); checkCparams(1);
@ -285,7 +285,7 @@ double lua_getnumber (lua_Object object)
else return (nvalue(Address(object))); else return (nvalue(Address(object)));
} }
char *lua_getstring (lua_Object object) const char *lua_getstring (lua_Object object)
{ {
luaC_checkGC(); /* "tostring" may create a new string */ luaC_checkGC(); /* "tostring" may create a new string */
if (object == LUA_NOOBJECT || tostring(Address(object))) if (object == LUA_NOOBJECT || tostring(Address(object)))
@ -329,7 +329,7 @@ void lua_pushnumber (double n)
incr_top; incr_top;
} }
void lua_pushlstring (char *s, long len) void lua_pushlstring (const char *s, long len)
{ {
tsvalue(L->stack.top) = luaS_newlstr(s, len); tsvalue(L->stack.top) = luaS_newlstr(s, len);
ttype(L->stack.top) = LUA_T_STRING; ttype(L->stack.top) = LUA_T_STRING;
@ -337,7 +337,7 @@ void lua_pushlstring (char *s, long len)
luaC_checkGC(); luaC_checkGC();
} }
void lua_pushstring (char *s) void lua_pushstring (const char *s)
{ {
if (s == NULL) if (s == NULL)
lua_pushnil(); lua_pushnil();
@ -508,7 +508,7 @@ int lua_setlocal (lua_Function func, int local_number)
} }
void lua_funcinfo (lua_Object func, char **filename, int *linedefined) void lua_funcinfo (lua_Object func, const char **filename, int *linedefined)
{ {
if (!lua_isfunction(func)) if (!lua_isfunction(func))
lua_error("API - `funcinfo' called with a non-function value"); lua_error("API - `funcinfo' called with a non-function value");
@ -532,7 +532,7 @@ static int checkfunc (TObject *o)
} }
char *lua_getobjname (lua_Object o, char **name) const char *lua_getobjname (lua_Object o, const char **name)
{ /* try to find a name for given function */ { /* try to find a name for given function */
set_normalized(L->stack.top, Address(o)); /* to be accessed by "checkfunc */ set_normalized(L->stack.top, Address(o)); /* to be accessed by "checkfunc */
if ((*name = luaT_travtagmethods(checkfunc)) != NULL) if ((*name = luaT_travtagmethods(checkfunc)) != NULL)

View file

@ -20,7 +20,7 @@
#include "lmem.h" #include "lmem.h"
int luaL_findstring (char *name, char *list[]) { int luaL_findstring (const char *name, const char *list[]) {
int i; int i;
for (i=0; list[i]; i++) for (i=0; list[i]; i++)
if (strcmp(list[i], name) == 0) if (strcmp(list[i], name) == 0)
@ -28,9 +28,9 @@ int luaL_findstring (char *name, char *list[]) {
return -1; /* name not found */ return -1; /* name not found */
} }
void luaL_argerror (int numarg, char *extramsg) void luaL_argerror (int numarg, const char *extramsg)
{ {
char *funcname; const char *funcname;
lua_getobjname(lua_stackedfunction(0), &funcname); lua_getobjname(lua_stackedfunction(0), &funcname);
if (funcname == NULL) if (funcname == NULL)
funcname = "???"; funcname = "???";
@ -41,7 +41,7 @@ void luaL_argerror (int numarg, char *extramsg)
numarg, funcname, extramsg); numarg, funcname, extramsg);
} }
char *luaL_check_lstr (int numArg, long *len) const char *luaL_check_lstr (int numArg, long *len)
{ {
lua_Object o = lua_getparam(numArg); lua_Object o = lua_getparam(numArg);
luaL_arg_check(lua_isstring(o), numArg, "string expected"); luaL_arg_check(lua_isstring(o), numArg, "string expected");
@ -49,7 +49,7 @@ char *luaL_check_lstr (int numArg, long *len)
return lua_getstring(o); return lua_getstring(o);
} }
char *luaL_opt_lstr (int numArg, char *def, long *len) const char *luaL_opt_lstr (int numArg, const char *def, long *len)
{ {
return (lua_getparam(numArg) == LUA_NOOBJECT) ? def : return (lua_getparam(numArg) == LUA_NOOBJECT) ? def :
luaL_check_lstr(numArg, len); luaL_check_lstr(numArg, len);
@ -120,7 +120,7 @@ void luaL_openlib (struct luaL_reg *l, int n)
} }
void luaL_verror (char *fmt, ...) void luaL_verror (const char *fmt, ...)
{ {
char buff[500]; char buff[500];
va_list argp; va_list argp;

View file

@ -13,7 +13,7 @@
struct luaL_reg { struct luaL_reg {
char *name; const char *name;
lua_CFunction func; lua_CFunction func;
}; };
@ -30,17 +30,17 @@ extern luaL_libList *list_of_libs;
void luaL_openlib (struct luaL_reg *l, int n); void luaL_openlib (struct luaL_reg *l, int n);
void luaL_addlibtolist(luaL_reg *l, int n); void luaL_addlibtolist(luaL_reg *l, int n);
void luaL_argerror (int numarg, char *extramsg); void luaL_argerror (int numarg, const char *extramsg);
#define luaL_check_string(n) (luaL_check_lstr((n), NULL)) #define luaL_check_string(n) (luaL_check_lstr((n), NULL))
char *luaL_check_lstr (int numArg, long *len); const char *luaL_check_lstr (int numArg, long *len);
#define luaL_opt_string(n, d) (luaL_opt_lstr((n), (d), NULL)) #define luaL_opt_string(n, d) (luaL_opt_lstr((n), (d), NULL))
char *luaL_opt_lstr (int numArg, char *def, long *len); const char *luaL_opt_lstr (int numArg, const char *def, long *len);
double luaL_check_number (int numArg); double luaL_check_number (int numArg);
double luaL_opt_number (int numArg, double def); double luaL_opt_number (int numArg, double def);
lua_Object luaL_functionarg (int arg); lua_Object luaL_functionarg (int arg);
lua_Object luaL_tablearg (int arg); lua_Object luaL_tablearg (int arg);
lua_Object luaL_nonnullarg (int numArg); lua_Object luaL_nonnullarg (int numArg);
void luaL_verror (char *fmt, ...); void luaL_verror (const char *fmt, ...);
char *luaL_openspace (int size); char *luaL_openspace (int size);
void luaL_resetbuffer (void); void luaL_resetbuffer (void);
void luaL_addchar (int c); void luaL_addchar (int c);
@ -49,7 +49,7 @@ void luaL_addsize (int n);
int luaL_newbuffer (int size); int luaL_newbuffer (int size);
void luaL_oldbuffer (int old); void luaL_oldbuffer (int old);
char *luaL_buffer (void); char *luaL_buffer (void);
int luaL_findstring (char *name, char *list[]); int luaL_findstring (const char *name, const char *list[]);
#endif #endif

View file

@ -119,7 +119,7 @@ static void foreach (void)
static void internaldostring (void) static void internaldostring (void)
{ {
long l; long l;
char *s = luaL_check_lstr(1, &l); const char *s = luaL_check_lstr(1, &l);
if (*s == ID_CHUNK) if (*s == ID_CHUNK)
lua_error("`dostring' cannot run pre-compiled code"); lua_error("`dostring' cannot run pre-compiled code");
if (lua_dobuffer(s, l, luaL_opt_string(2, NULL)) == 0) if (lua_dobuffer(s, l, luaL_opt_string(2, NULL)) == 0)
@ -130,7 +130,7 @@ static void internaldostring (void)
static void internaldofile (void) static void internaldofile (void)
{ {
char *fname = luaL_opt_string(1, NULL); const char *fname = luaL_opt_string(1, NULL);
if (lua_dofile(fname) == 0) if (lua_dofile(fname) == 0)
if (luaA_passresults() == 0) if (luaA_passresults() == 0)
lua_pushuserdata(NULL); /* at least one result to signal no errors */ lua_pushuserdata(NULL); /* at least one result to signal no errors */
@ -216,12 +216,13 @@ static void tonumber (void)
lua_pushnumber(lua_getnumber(o)); lua_pushnumber(lua_getnumber(o));
} }
else { else {
char *s = luaL_check_string(1); const char *s = luaL_check_string(1);
char *e;
unsigned long n; unsigned long n;
luaL_arg_check(0 <= base && base <= 36, 2, "base out of range"); luaL_arg_check(0 <= base && base <= 36, 2, "base out of range");
n = strtol(s, &s, base); n = strtol(s, &e, base);
while (isspace(*s)) s++; /* skip trailing spaces */ while (isspace(*e)) e++; /* skip trailing spaces */
if (*s) lua_pushnil(); /* invalid format: return nil */ if (*e) lua_pushnil(); /* invalid format: return nil */
else lua_pushnumber(n); else lua_pushnumber(n);
} }
} }
@ -243,7 +244,7 @@ static void luaI_assert (void)
static void setglobal (void) static void setglobal (void)
{ {
char *n = luaL_check_string(1); const char *n = luaL_check_string(1);
lua_Object value = luaL_nonnullarg(2); lua_Object value = luaL_nonnullarg(2);
lua_pushobject(value); lua_pushobject(value);
lua_setglobal(n); lua_setglobal(n);
@ -252,7 +253,7 @@ static void setglobal (void)
static void rawsetglobal (void) static void rawsetglobal (void)
{ {
char *n = luaL_check_string(1); const char *n = luaL_check_string(1);
lua_Object value = luaL_nonnullarg(2); lua_Object value = luaL_nonnullarg(2);
lua_pushobject(value); lua_pushobject(value);
lua_rawsetglobal(n); lua_rawsetglobal(n);
@ -287,7 +288,7 @@ static void luaI_call (void)
{ {
lua_Object f = luaL_nonnullarg(1); lua_Object f = luaL_nonnullarg(1);
lua_Object arg = luaL_tablearg(2); lua_Object arg = luaL_tablearg(2);
char *options = luaL_opt_string(3, ""); const char *options = luaL_opt_string(3, "");
lua_Object err = lua_getparam(4); lua_Object err = lua_getparam(4);
int narg = getnarg(arg); int narg = getnarg(arg);
int i, status; int i, status;

View file

@ -342,7 +342,7 @@ void luaD_travstack (int (*fn)(TObject *))
static void message (char *s) static void message (const char *s)
{ {
TObject im = L->errorim; TObject im = L->errorim;
if (ttype(&im) != LUA_T_NIL) { if (ttype(&im) != LUA_T_NIL) {
@ -354,7 +354,7 @@ static void message (char *s)
/* /*
** Reports an error, and jumps up to the available recover label ** Reports an error, and jumps up to the available recover label
*/ */
void lua_error (char *s) void lua_error (const char *s)
{ {
if (s) message(s); if (s) message(s);
if (L->errorJmp) if (L->errorJmp)
@ -465,7 +465,7 @@ void luaD_gcIM (TObject *o)
} }
int lua_dofile (char *filename) int lua_dofile (const char *filename)
{ {
ZIO z; ZIO z;
int status; int status;
@ -493,7 +493,7 @@ int lua_dofile (char *filename)
#define SSIZE_PREF "20" #define SSIZE_PREF "20"
static void build_name (char *str, char *name) { static void build_name (const char *str, char *name) {
if (str == NULL || *str == ID_CHUNK) if (str == NULL || *str == ID_CHUNK)
strcpy(name, "(buffer)"); strcpy(name, "(buffer)");
else { else {
@ -508,12 +508,12 @@ static void build_name (char *str, char *name) {
} }
int lua_dostring (char *str) { int lua_dostring (const char *str) {
return lua_dobuffer(str, strlen(str), NULL); return lua_dobuffer(str, strlen(str), NULL);
} }
int lua_dobuffer (char *buff, int size, char *name) { int lua_dobuffer (const char *buff, int size, const char *name) {
char newname[SIZE_PREF+25]; char newname[SIZE_PREF+25];
ZIO z; ZIO z;
int status; int status;

View file

@ -78,7 +78,7 @@ static int ishandler (lua_Object f)
else return 0; else return 0;
} }
static FILE *getfile (char *name) static FILE *getfile (const char *name)
{ {
lua_Object f = lua_getglobal(name); lua_Object f = lua_getglobal(name);
if (!ishandler(f)) if (!ishandler(f))
@ -87,7 +87,7 @@ static FILE *getfile (char *name)
} }
static FILE *getfileparam (char *name, int *arg) static FILE *getfileparam (const char *name, int *arg)
{ {
lua_Object f = lua_getparam(*arg); lua_Object f = lua_getparam(*arg);
if (ishandler(f)) { if (ishandler(f)) {
@ -99,7 +99,7 @@ static FILE *getfileparam (char *name, int *arg)
} }
static void closefile (char *name) static void closefile (const char *name)
{ {
FILE *f = getfile(name); FILE *f = getfile(name);
if (f == stdin || f == stdout) return; if (f == stdin || f == stdout) return;
@ -110,14 +110,14 @@ static void closefile (char *name)
} }
static void setfile (FILE *f, char *name, int tag) static void setfile (FILE *f, const char *name, int tag)
{ {
lua_pushusertag(f, tag); lua_pushusertag(f, tag);
lua_setglobal(name); lua_setglobal(name);
} }
static void setreturn (FILE *f, char *name) static void setreturn (FILE *f, const char *name)
{ {
int tag = gettag(IOTAG); int tag = gettag(IOTAG);
setfile(f, name, tag); setfile(f, name, tag);
@ -136,7 +136,7 @@ static void io_readfrom (void)
else if (lua_tag(f) == gettag(IOTAG)) else if (lua_tag(f) == gettag(IOTAG))
current = (FILE *)lua_getuserdata(f); current = (FILE *)lua_getuserdata(f);
else { else {
char *s = luaL_check_string(FIRSTARG); const char *s = luaL_check_string(FIRSTARG);
if (*s == '|') if (*s == '|')
current = popen(s+1, "r"); current = popen(s+1, "r");
else { else {
@ -166,7 +166,7 @@ static void io_writeto (void)
else if (lua_tag(f) == gettag(IOTAG)) else if (lua_tag(f) == gettag(IOTAG))
current = (FILE *)lua_getuserdata(f); current = (FILE *)lua_getuserdata(f);
else { else {
char *s = luaL_check_string(FIRSTARG); const char *s = luaL_check_string(FIRSTARG);
current = (*s == '|') ? popen(s+1,"w") : fopen(s,"w"); current = (*s == '|') ? popen(s+1,"w") : fopen(s,"w");
if (current == NULL) { if (current == NULL) {
pushresult(0); pushresult(0);
@ -179,7 +179,7 @@ static void io_writeto (void)
static void io_appendto (void) static void io_appendto (void)
{ {
char *s = luaL_check_string(FIRSTARG); const char *s = luaL_check_string(FIRSTARG);
FILE *fp = fopen (s, "a"); FILE *fp = fopen (s, "a");
if (fp != NULL) if (fp != NULL)
setreturn(fp, FOUTPUT); setreturn(fp, FOUTPUT);
@ -205,7 +205,7 @@ static void read_until (FILE *f, int lim) {
static void io_read (void) { static void io_read (void) {
int arg = FIRSTARG; int arg = FIRSTARG;
FILE *f = getfileparam(FINPUT, &arg); FILE *f = getfileparam(FINPUT, &arg);
char *p = luaL_opt_string(arg, NULL); const char *p = luaL_opt_string(arg, NULL);
luaL_resetbuffer(); luaL_resetbuffer();
if (p == NULL) /* default: read a line */ if (p == NULL) /* default: read a line */
read_until(f, '\n'); read_until(f, '\n');
@ -228,7 +228,7 @@ static void io_read (void) {
p++; p++;
continue; continue;
default: { default: {
char *ep; /* get what is next */ const char *ep; /* get what is next */
int m; /* match result */ int m; /* match result */
if (c == NEED_OTHER) c = getc(f); if (c == NEED_OTHER) c = getc(f);
if (c == EOF) { if (c == EOF) {
@ -273,7 +273,7 @@ static void io_write (void)
int arg = FIRSTARG; int arg = FIRSTARG;
FILE *f = getfileparam(FOUTPUT, &arg); FILE *f = getfileparam(FOUTPUT, &arg);
int status = 1; int status = 1;
char *s; const char *s;
long l; long l;
while ((s = luaL_opt_lstr(arg++, NULL, &l)) != NULL) while ((s = luaL_opt_lstr(arg++, NULL, &l)) != NULL)
status = status && (fwrite(s, 1, l, f) == (unsigned long)l); status = status && (fwrite(s, 1, l, f) == (unsigned long)l);
@ -322,7 +322,7 @@ static void io_date (void)
{ {
time_t t; time_t t;
struct tm *tm; struct tm *tm;
char *s = luaL_opt_string(1, "%c"); const char *s = luaL_opt_string(1, "%c");
char b[BUFSIZ]; char b[BUFSIZ];
time(&t); tm = localtime(&t); time(&t); tm = localtime(&t);
if (strftime(b,sizeof(b),s,tm)) if (strftime(b,sizeof(b),s,tm))
@ -336,7 +336,7 @@ static void setloc (void)
{ {
static int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, static int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC,
LC_TIME}; LC_TIME};
static char *catnames[] = {"all", "collate", "ctype", "monetary", static const char *catnames[] = {"all", "collate", "ctype", "monetary",
"numeric", "time", NULL}; "numeric", "time", NULL};
int op = luaL_findstring(luaL_opt_string(2, "all"), catnames); int op = luaL_findstring(luaL_opt_string(2, "all"), catnames);
luaL_arg_check(op != -1, 2, "invalid option"); luaL_arg_check(op != -1, 2, "invalid option");
@ -368,9 +368,9 @@ static void lua_printstack (FILE *f)
int level = 1; /* skip level 0 (it's this function) */ int level = 1; /* skip level 0 (it's this function) */
lua_Object func; lua_Object func;
while ((func = lua_stackedfunction(level++)) != LUA_NOOBJECT) { while ((func = lua_stackedfunction(level++)) != LUA_NOOBJECT) {
char *name; const char *name;
int currentline; int currentline;
char *filename; const char *filename;
int linedefined; int linedefined;
lua_funcinfo(func, &filename, &linedefined); lua_funcinfo(func, &filename, &linedefined);
fprintf(f, (level==2) ? "Active Stack:\n\t" : "\t"); fprintf(f, (level==2) ? "Active Stack:\n\t" : "\t");

View file

@ -30,7 +30,7 @@ int lua_debug=0;
#define save_and_next(LS) (save(LS->current), next(LS)) #define save_and_next(LS) (save(LS->current), next(LS))
char *reserved [] = {"and", "do", "else", "elseif", "end", "function", const char *reserved [] = {"and", "do", "else", "elseif", "end", "function",
"if", "local", "nil", "not", "or", "repeat", "return", "then", "if", "local", "nil", "not", "or", "repeat", "return", "then",
"until", "while"}; "until", "while"};
@ -45,7 +45,7 @@ void luaX_init (void)
} }
void luaX_syntaxerror (LexState *ls, char *s, char *token) { void luaX_syntaxerror (LexState *ls, const char *s, const char *token) {
if (token[0] == 0) if (token[0] == 0)
token = "<eof>"; token = "<eof>";
luaL_verror("%.100s;\n last token read: `%.50s' at line %d in chunk `%.50s'", luaL_verror("%.100s;\n last token read: `%.50s' at line %d in chunk `%.50s'",
@ -53,7 +53,7 @@ void luaX_syntaxerror (LexState *ls, char *s, char *token) {
} }
void luaX_error (LexState *ls, char *s) { void luaX_error (LexState *ls, const char *s) {
save(0); save(0);
luaX_syntaxerror(ls, s, luaL_buffer()); luaX_syntaxerror(ls, s, luaL_buffer());
} }
@ -117,7 +117,7 @@ static void skipspace (LexState *LS)
static int checkcond (LexState *LS, char *buff) static int checkcond (LexState *LS, char *buff)
{ {
static char *opts[] = {"nil", "1", NULL}; static const char *opts[] = {"nil", "1", NULL};
int i = luaL_findstring(buff, opts); int i = luaL_findstring(buff, opts);
if (i >= 0) return i; if (i >= 0) return i;
else if (isalpha((unsigned char)buff[0]) || buff[0] == '_') else if (isalpha((unsigned char)buff[0]) || buff[0] == '_')
@ -162,7 +162,7 @@ static void ifskip (LexState *LS)
static void inclinenumber (LexState *LS) static void inclinenumber (LexState *LS)
{ {
static char *pragmas [] = static const char *pragmas [] =
{"debug", "nodebug", "endinput", "end", "ifnot", "if", "else", NULL}; {"debug", "nodebug", "endinput", "end", "ifnot", "if", "else", NULL};
next(LS); /* skip '\n' */ next(LS); /* skip '\n' */
++LS->linenumber; ++LS->linenumber;

View file

@ -54,8 +54,8 @@ typedef struct LexState {
void luaX_init (void); void luaX_init (void);
void luaX_setinput (LexState *LS, ZIO *z); void luaX_setinput (LexState *LS, ZIO *z);
int luaX_lex (LexState *LS); int luaX_lex (LexState *LS);
void luaX_syntaxerror (LexState *ls, char *s, char *token); void luaX_syntaxerror (LexState *ls, const char *s, const char *token);
void luaX_error (LexState *ls, char *s); void luaX_error (LexState *ls, const char *s);
void luaX_token2str (LexState *ls, int token, char *s); void luaX_token2str (LexState *ls, int token, char *s);

View file

@ -14,7 +14,7 @@
int luaM_growaux (void **block, unsigned long nelems, int size, int luaM_growaux (void **block, unsigned long nelems, int size,
char *errormsg, unsigned long limit) const char *errormsg, unsigned long limit)
{ {
if (nelems >= limit) if (nelems >= limit)
lua_error(errormsg); lua_error(errormsg);

View file

@ -22,7 +22,7 @@
void *luaM_realloc (void *oldblock, unsigned long size); void *luaM_realloc (void *oldblock, unsigned long size);
int luaM_growaux (void **block, unsigned long nelems, int size, int luaM_growaux (void **block, unsigned long nelems, int size,
char *errormsg, unsigned long limit); const char *errormsg, unsigned long limit);
#define luaM_free(b) free((b)) #define luaM_free(b) free((b))
#define luaM_malloc(t) malloc((t)) #define luaM_malloc(t) malloc((t))

View file

@ -10,7 +10,7 @@
#include "lua.h" #include "lua.h"
char *luaO_typenames[] = { /* ORDER LUA_T */ const char *luaO_typenames[] = { /* ORDER LUA_T */
"userdata", "number", "string", "table", "function", "function", "task", "userdata", "number", "string", "table", "function", "function", "task",
"nil", "function", "mark", "mark", "mark", "line", NULL "nil", "function", "mark", "mark", "mark", "line", NULL
}; };

View file

@ -191,7 +191,7 @@ typedef struct Hash {
} Hash; } Hash;
extern char *luaO_typenames[]; extern const char *luaO_typenames[];
extern TObject luaO_nilobject; extern TObject luaO_nilobject;

View file

@ -37,7 +37,7 @@ void luaS_init (void)
} }
static unsigned long hash_s (char *s, long l) static unsigned long hash_s (const char *s, long l)
{ {
unsigned long h = 0; unsigned long h = 0;
while (l--) while (l--)
@ -86,7 +86,7 @@ static void grow (stringtable *tb)
} }
static TaggedString *newone_s (char *str, long l, unsigned long h) static TaggedString *newone_s (const char *str, long l, unsigned long h)
{ {
TaggedString *ts = (TaggedString *)luaM_malloc(sizeof(TaggedString)+l); TaggedString *ts = (TaggedString *)luaM_malloc(sizeof(TaggedString)+l);
memcpy(ts->str, str, l); memcpy(ts->str, str, l);
@ -114,7 +114,7 @@ static TaggedString *newone_u (char *buff, int tag, unsigned long h)
return ts; return ts;
} }
static TaggedString *insert_s (char *str, long l, stringtable *tb) static TaggedString *insert_s (const char *str, long l, stringtable *tb)
{ {
TaggedString *ts; TaggedString *ts;
unsigned long h = hash_s(str, l); unsigned long h = hash_s(str, l);
@ -130,8 +130,7 @@ static TaggedString *insert_s (char *str, long l, stringtable *tb)
j = i; j = i;
else if (ts->constindex >= 0 && else if (ts->constindex >= 0 &&
ts->u.s.len == l && ts->u.s.len == l &&
(memcmp(str, ts->str, l) == 0)) (memcmp(str, ts->str, l) == 0)) return ts;
return ts;
if (++i == size) i=0; if (++i == size) i=0;
} }
/* not found */ /* not found */
@ -177,18 +176,18 @@ TaggedString *luaS_createudata (void *udata, int tag)
return insert_u(udata, tag, &L->string_root[(unsigned long)udata%NUM_HASHS]); return insert_u(udata, tag, &L->string_root[(unsigned long)udata%NUM_HASHS]);
} }
TaggedString *luaS_newlstr (char *str, long l) TaggedString *luaS_newlstr (const char *str, long l)
{ {
int i = (l==0)?0:(unsigned char)str[0]; int i = (l==0)?0:(unsigned char)str[0];
return insert_s(str, l, &L->string_root[i%NUM_HASHS]); return insert_s(str, l, &L->string_root[i%NUM_HASHS]);
} }
TaggedString *luaS_new (char *str) TaggedString *luaS_new (const char *str)
{ {
return luaS_newlstr(str, strlen(str)); return luaS_newlstr(str, strlen(str));
} }
TaggedString *luaS_newfixedstring (char *str) TaggedString *luaS_newfixedstring (const char *str)
{ {
TaggedString *ts = luaS_new(str); TaggedString *ts = luaS_new(str);
if (ts->head.marked == 0) if (ts->head.marked == 0)
@ -305,7 +304,7 @@ char *luaS_travsymbol (int (*fn)(TObject *))
} }
int luaS_globaldefined (char *name) int luaS_globaldefined (const char *name)
{ {
TaggedString *ts = luaS_new(name); TaggedString *ts = luaS_new(name);
return ts->u.s.globalval.ttype != LUA_T_NIL; return ts->u.s.globalval.ttype != LUA_T_NIL;

View file

@ -15,12 +15,12 @@ void luaS_init (void);
TaggedString *luaS_createudata (void *udata, int tag); TaggedString *luaS_createudata (void *udata, int tag);
TaggedString *luaS_collector (void); TaggedString *luaS_collector (void);
void luaS_free (TaggedString *l); void luaS_free (TaggedString *l);
TaggedString *luaS_newlstr (char *str, long l); TaggedString *luaS_newlstr (const char *str, long l);
TaggedString *luaS_new (char *str); TaggedString *luaS_new (const char *str);
TaggedString *luaS_newfixedstring (char *str); TaggedString *luaS_newfixedstring (const char *str);
void luaS_rawsetglobal (TaggedString *ts, TObject *newval); void luaS_rawsetglobal (TaggedString *ts, TObject *newval);
char *luaS_travsymbol (int (*fn)(TObject *)); char *luaS_travsymbol (int (*fn)(TObject *));
int luaS_globaldefined (char *name); int luaS_globaldefined (const char *name);
TaggedString *luaS_collectudata (void); TaggedString *luaS_collectudata (void);
void luaS_freeall (void); void luaS_freeall (void);

View file

@ -16,7 +16,7 @@
static void addnchar (char *s, int n) static void addnchar (const char *s, int n)
{ {
char *b = luaL_openspace(n); char *b = luaL_openspace(n);
memcpy(b, s, n); memcpy(b, s, n);
@ -48,7 +48,7 @@ static long posrelat (long pos, long len)
static void str_sub (void) static void str_sub (void)
{ {
long l; long l;
char *s = luaL_check_lstr(1, &l); const char *s = luaL_check_lstr(1, &l);
long start = posrelat((int)luaL_check_number(2), l); long start = posrelat((int)luaL_check_number(2), l);
long end = posrelat((int)luaL_opt_number(3, -1), l); long end = posrelat((int)luaL_opt_number(3, -1), l);
if (1 <= start && start <= end && end <= l) if (1 <= start && start <= end && end <= l)
@ -61,7 +61,7 @@ static void str_lower (void)
{ {
long l; long l;
int i; int i;
char *s = luaL_check_lstr(1, &l); const char *s = luaL_check_lstr(1, &l);
luaL_resetbuffer(); luaL_resetbuffer();
for (i=0; i<l; i++) for (i=0; i<l; i++)
luaL_addchar(tolower((unsigned char)(s[i]))); luaL_addchar(tolower((unsigned char)(s[i])));
@ -73,7 +73,7 @@ static void str_upper (void)
{ {
long l; long l;
int i; int i;
char *s = luaL_check_lstr(1, &l); const char *s = luaL_check_lstr(1, &l);
luaL_resetbuffer(); luaL_resetbuffer();
for (i=0; i<l; i++) for (i=0; i<l; i++)
luaL_addchar(toupper((unsigned char)(s[i]))); luaL_addchar(toupper((unsigned char)(s[i])));
@ -83,7 +83,7 @@ static void str_upper (void)
static void str_rep (void) static void str_rep (void)
{ {
long l; long l;
char *s = luaL_check_lstr(1, &l); const char *s = luaL_check_lstr(1, &l);
int n = (int)luaL_check_number(2); int n = (int)luaL_check_number(2);
luaL_resetbuffer(); luaL_resetbuffer();
while (n-- > 0) while (n-- > 0)
@ -95,7 +95,7 @@ static void str_rep (void)
static void str_byte (void) static void str_byte (void)
{ {
long l; long l;
char *s = luaL_check_lstr(1, &l); const char *s = luaL_check_lstr(1, &l);
long pos = posrelat((int)luaL_opt_number(2, 1), l); long pos = posrelat((int)luaL_opt_number(2, 1), l);
luaL_arg_check(0<pos && pos<=l, 2, "out of range"); luaL_arg_check(0<pos && pos<=l, 2, "out of range");
lua_pushnumber((unsigned char)s[pos-1]); lua_pushnumber((unsigned char)s[pos-1]);
@ -123,9 +123,9 @@ static void str_char (void) {
struct Capture { struct Capture {
int level; /* total number of captures (finished or unfinished) */ int level; /* total number of captures (finished or unfinished) */
char *src_end; /* end ('\0') of source string */ const char *src_end; /* end ('\0') of source string */
struct { struct {
char *init; const char *init;
int len; /* -1 signals unfinished capture */ int len; /* -1 signals unfinished capture */
} capture[MAX_CAPT]; } capture[MAX_CAPT];
}; };
@ -162,7 +162,7 @@ static int capture_to_close (struct Capture *cap)
} }
static char *bracket_end (char *p) static const char *bracket_end (const char *p)
{ {
return (*p == 0) ? NULL : strchr((*p=='^') ? p+2 : p+1, ']'); return (*p == 0) ? NULL : strchr((*p=='^') ? p+2 : p+1, ']');
} }
@ -187,7 +187,7 @@ static int matchclass (int c, int cl)
} }
int luaI_singlematch (int c, char *p, char **ep) int luaI_singlematch (int c, const char *p, const char **ep)
{ {
switch (*p) { switch (*p) {
case '.': /* matches any char */ case '.': /* matches any char */
@ -202,7 +202,7 @@ int luaI_singlematch (int c, char *p, char **ep)
*ep = p+1; *ep = p+1;
return matchclass(c, (unsigned char)*p); return matchclass(c, (unsigned char)*p);
case '[': { case '[': {
char *end = bracket_end(p+1); const char *end = bracket_end(p+1);
int sig = *(p+1) == '^' ? (p++, 0) : 1; int sig = *(p+1) == '^' ? (p++, 0) : 1;
if (end == NULL) lua_error("incorrect pattern (missing `]')"); if (end == NULL) lua_error("incorrect pattern (missing `]')");
*ep = end+1; *ep = end+1;
@ -227,7 +227,7 @@ int luaI_singlematch (int c, char *p, char **ep)
} }
static char *matchbalance (char *s, int b, int e, struct Capture *cap) static const char *matchbalance (const char *s, int b, int e, struct Capture *cap)
{ {
if (*s != b) return NULL; if (*s != b) return NULL;
else { else {
@ -243,7 +243,7 @@ static char *matchbalance (char *s, int b, int e, struct Capture *cap)
} }
static char *matchitem (char *s, char *p, struct Capture *cap, char **ep) static const char *matchitem (const char *s, const char *p, struct Capture *cap, const char **ep)
{ {
if (*p == ESC) { if (*p == ESC) {
p++; p++;
@ -270,12 +270,12 @@ static char *matchitem (char *s, char *p, struct Capture *cap, char **ep)
} }
static char *match (char *s, char *p, struct Capture *cap) static const char *match (const char *s, const char *p, struct Capture *cap)
{ {
init: /* using goto's to optimize tail recursion */ init: /* using goto's to optimize tail recursion */
switch (*p) { switch (*p) {
case '(': { /* start capture */ case '(': { /* start capture */
char *res; const char *res;
if (cap->level >= MAX_CAPT) lua_error("too many captures"); if (cap->level >= MAX_CAPT) lua_error("too many captures");
cap->capture[cap->level].init = s; cap->capture[cap->level].init = s;
cap->capture[cap->level].len = -1; cap->capture[cap->level].len = -1;
@ -286,7 +286,7 @@ static char *match (char *s, char *p, struct Capture *cap)
} }
case ')': { /* end capture */ case ')': { /* end capture */
int l = capture_to_close(cap); int l = capture_to_close(cap);
char *res; const char *res;
cap->capture[l].len = s - cap->capture[l].init; /* close capture */ cap->capture[l].len = s - cap->capture[l].init; /* close capture */
if ((res = match(s, p+1, cap)) == NULL) /* match failed? */ if ((res = match(s, p+1, cap)) == NULL) /* match failed? */
cap->capture[l].len = -1; /* undo capture */ cap->capture[l].len = -1; /* undo capture */
@ -297,23 +297,23 @@ static char *match (char *s, char *p, struct Capture *cap)
return s; return s;
/* else go through */ /* else go through */
default: { /* it is a pattern item */ default: { /* it is a pattern item */
char *ep; /* get what is next */ const char *ep; /* get what is next */
char *s1 = matchitem(s, p, cap, &ep); const char *s1 = matchitem(s, p, cap, &ep);
switch (*ep) { switch (*ep) {
case '*': { /* repetition */ case '*': { /* repetition */
char *res; const char *res;
if (s1 && s1>s && ((res=match(s1, p, cap)) != NULL)) if (s1 && s1>s && ((res=match(s1, p, cap)) != NULL))
return res; return res;
p=ep+1; goto init; /* else return match(s, ep+1, cap); */ p=ep+1; goto init; /* else return match(s, ep+1, cap); */
} }
case '?': { /* optional */ case '?': { /* optional */
char *res; const char *res;
if (s1 && ((res=match(s1, ep+1, cap)) != NULL)) if (s1 && ((res=match(s1, ep+1, cap)) != NULL))
return res; return res;
p=ep+1; goto init; /* else return match(s, ep+1, cap); */ p=ep+1; goto init; /* else return match(s, ep+1, cap); */
} }
case '-': { /* repetition */ case '-': { /* repetition */
char *res; const char *res;
if ((res = match(s, ep+1, cap)) != NULL) if ((res = match(s, ep+1, cap)) != NULL)
return res; return res;
else if (s1 && s1>s) { else if (s1 && s1>s) {
@ -335,8 +335,8 @@ static char *match (char *s, char *p, struct Capture *cap)
static void str_find (void) static void str_find (void)
{ {
long l; long l;
char *s = luaL_check_lstr(1, &l); const char *s = luaL_check_lstr(1, &l);
char *p = luaL_check_string(2); const char *p = luaL_check_string(2);
long init = posrelat((int)luaL_opt_number(3, 1), l) - 1; long init = posrelat((int)luaL_opt_number(3, 1), l) - 1;
struct Capture cap; struct Capture cap;
luaL_arg_check(0 <= init && init <= l, 3, "out of range"); luaL_arg_check(0 <= init && init <= l, 3, "out of range");
@ -351,10 +351,10 @@ static void str_find (void)
} }
else { else {
int anchor = (*p == '^') ? (p++, 1) : 0; int anchor = (*p == '^') ? (p++, 1) : 0;
char *s1=s+init; const char *s1=s+init;
cap.src_end = s+l; cap.src_end = s+l;
do { do {
char *res; const char *res;
cap.level = 0; cap.level = 0;
if ((res=match(s1, p, &cap)) != NULL) { if ((res=match(s1, p, &cap)) != NULL) {
lua_pushnumber(s1-s+1); /* start */ lua_pushnumber(s1-s+1); /* start */
@ -371,7 +371,7 @@ static void str_find (void)
static void add_s (lua_Object newp, struct Capture *cap) static void add_s (lua_Object newp, struct Capture *cap)
{ {
if (lua_isstring(newp)) { if (lua_isstring(newp)) {
char *news = lua_getstring(newp); const char *news = lua_getstring(newp);
int l = lua_strlen(newp); int l = lua_strlen(newp);
int i; int i;
for (i=0; i<l; i++) { for (i=0; i<l; i++) {
@ -414,8 +414,8 @@ static void add_s (lua_Object newp, struct Capture *cap)
static void str_gsub (void) static void str_gsub (void)
{ {
long srcl; long srcl;
char *src = luaL_check_lstr(1, &srcl); const char *src = luaL_check_lstr(1, &srcl);
char *p = luaL_check_string(2); const char *p = luaL_check_string(2);
lua_Object newp = lua_getparam(3); lua_Object newp = lua_getparam(3);
int max_s = (int)luaL_opt_number(4, srcl+1); int max_s = (int)luaL_opt_number(4, srcl+1);
int anchor = (*p == '^') ? (p++, 1) : 0; int anchor = (*p == '^') ? (p++, 1) : 0;
@ -426,7 +426,7 @@ static void str_gsub (void)
luaL_resetbuffer(); luaL_resetbuffer();
cap.src_end = src+srcl; cap.src_end = src+srcl;
while (n < max_s) { while (n < max_s) {
char *e; const char *e;
cap.level = 0; cap.level = 0;
e = match(src, p, &cap); e = match(src, p, &cap);
if (e) { if (e) {
@ -446,7 +446,7 @@ static void str_gsub (void)
} }
static void luaI_addquoted (char *s) static void luaI_addquoted (const char *s)
{ {
luaL_addchar('"'); luaL_addchar('"');
for (; *s; s++) { for (; *s; s++) {
@ -462,7 +462,7 @@ static void luaI_addquoted (char *s)
static void str_format (void) static void str_format (void)
{ {
int arg = 1; int arg = 1;
char *strfrmt = luaL_check_string(arg); const char *strfrmt = luaL_check_string(arg);
struct Capture cap; struct Capture cap;
cap.src_end = strfrmt+strlen(strfrmt)+1; cap.src_end = strfrmt+strlen(strfrmt)+1;
luaL_resetbuffer(); luaL_resetbuffer();
@ -474,7 +474,7 @@ static void str_format (void)
else { /* format item */ else { /* format item */
char form[MAX_FORMAT]; /* store the format ('%...') */ char form[MAX_FORMAT]; /* store the format ('%...') */
char *buff; char *buff;
char *initf = strfrmt; const char *initf = strfrmt;
form[0] = '%'; form[0] = '%';
cap.level = 0; cap.level = 0;
if (isdigit((unsigned char)initf[0]) && initf[1] == '$') { if (isdigit((unsigned char)initf[0]) && initf[1] == '$') {
@ -493,7 +493,7 @@ static void str_format (void)
luaI_addquoted(luaL_check_string(arg)); luaI_addquoted(luaL_check_string(arg));
continue; continue;
case 's': { case 's': {
char *s = luaL_check_string(arg); const char *s = luaL_check_string(arg);
buff = luaL_openspace(strlen(s)); buff = luaL_openspace(strlen(s));
sprintf(buff, form, s); sprintf(buff, form, s);
break; break;

View file

@ -16,14 +16,14 @@
#include "ltm.h" #include "ltm.h"
char *luaT_eventname[] = { /* ORDER IM */ const char *luaT_eventname[] = { /* ORDER IM */
"gettable", "settable", "index", "getglobal", "setglobal", "add", "gettable", "settable", "index", "getglobal", "setglobal", "add",
"sub", "mul", "div", "pow", "unm", "lt", "le", "gt", "ge", "sub", "mul", "div", "pow", "unm", "lt", "le", "gt", "ge",
"concat", "gc", "function", NULL "concat", "gc", "function", NULL
}; };
static int luaI_checkevent (char *name, char *list[]) static int luaI_checkevent (const char *name, const char *list[])
{ {
int e = luaL_findstring(name, list); int e = luaL_findstring(name, list);
if (e < 0) if (e < 0)
@ -133,7 +133,7 @@ int luaT_efectivetag (TObject *o)
} }
TObject *luaT_gettagmethod (int t, char *event) TObject *luaT_gettagmethod (int t, const char *event)
{ {
int e = luaI_checkevent(event, luaT_eventname); int e = luaI_checkevent(event, luaT_eventname);
checktag(t); checktag(t);
@ -144,7 +144,7 @@ TObject *luaT_gettagmethod (int t, char *event)
} }
void luaT_settagmethod (int t, char *event, TObject *func) void luaT_settagmethod (int t, const char *event, TObject *func)
{ {
TObject temp = *func; TObject temp = *func;
int e = luaI_checkevent(event, luaT_eventname); int e = luaI_checkevent(event, luaT_eventname);
@ -157,7 +157,7 @@ void luaT_settagmethod (int t, char *event, TObject *func)
} }
char *luaT_travtagmethods (int (*fn)(TObject *)) const char *luaT_travtagmethods (int (*fn)(TObject *))
{ {
int e; int e;
if (fn(&L->errorim)) if (fn(&L->errorim))

View file

@ -48,15 +48,15 @@ struct IM {
#define luaT_getim(tag,event) (&L->IMtable[-(tag)].int_method[event]) #define luaT_getim(tag,event) (&L->IMtable[-(tag)].int_method[event])
#define luaT_getimbyObj(o,e) (luaT_getim(luaT_efectivetag(o),(e))) #define luaT_getimbyObj(o,e) (luaT_getim(luaT_efectivetag(o),(e)))
extern char *luaT_eventname[]; extern const char *luaT_eventname[];
void luaT_init (void); void luaT_init (void);
void luaT_realtag (int tag); void luaT_realtag (int tag);
int luaT_efectivetag (TObject *o); int luaT_efectivetag (TObject *o);
void luaT_settagmethod (int t, char *event, TObject *func); void luaT_settagmethod (int t, const char *event, TObject *func);
TObject *luaT_gettagmethod (int t, char *event); TObject *luaT_gettagmethod (int t, const char *event);
char *luaT_travtagmethods (int (*fn)(TObject *)); const char *luaT_travtagmethods (int (*fn)(TObject *));
void luaT_setfallback (void); /* only if LUA_COMPAT2_5 */ void luaT_setfallback (void); /* only if LUA_COMPAT2_5 */

View file

@ -40,18 +40,18 @@ void lua_open (void);
void lua_close (void); void lua_close (void);
lua_State *lua_setstate (lua_State *st); lua_State *lua_setstate (lua_State *st);
lua_Object lua_settagmethod (int tag, char *event); /* In: new method */ lua_Object lua_settagmethod (int tag, const char *event); /* In: new method */
lua_Object lua_gettagmethod (int tag, char *event); lua_Object lua_gettagmethod (int tag, const char *event);
lua_Object lua_seterrormethod (void); /* In: new method */ lua_Object lua_seterrormethod (void); /* In: new method */
int lua_newtag (void); int lua_newtag (void);
int lua_copytagmethods (int tagto, int tagfrom); int lua_copytagmethods (int tagto, int tagfrom);
void lua_settag (int tag); /* In: object */ void lua_settag (int tag); /* In: object */
void lua_error (char *s); void lua_error (const char *s);
int lua_dofile (char *filename); /* Out: returns */ int lua_dofile (const char *filename); /* Out: returns */
int lua_dostring (char *string); /* Out: returns */ int lua_dostring (const char *string); /* Out: returns */
int lua_dobuffer (char *buff, int size, char *name); int lua_dobuffer (const char *buff, int size, const char *name);
/* Out: returns */ /* Out: returns */
int lua_callfunction (lua_Object f); int lua_callfunction (lua_Object f);
/* In: parameters; Out: returns */ /* In: parameters; Out: returns */
@ -72,7 +72,7 @@ int lua_isstring (lua_Object object);
int lua_isfunction (lua_Object object); int lua_isfunction (lua_Object object);
double lua_getnumber (lua_Object object); double lua_getnumber (lua_Object object);
char *lua_getstring (lua_Object object); const char *lua_getstring (lua_Object object);
long lua_strlen (lua_Object object); long lua_strlen (lua_Object object);
lua_CFunction lua_getcfunction (lua_Object object); lua_CFunction lua_getcfunction (lua_Object object);
void *lua_getuserdata (lua_Object object); void *lua_getuserdata (lua_Object object);
@ -80,18 +80,18 @@ void *lua_getuserdata (lua_Object object);
void lua_pushnil (void); void lua_pushnil (void);
void lua_pushnumber (double n); void lua_pushnumber (double n);
void lua_pushlstring (char *s, long len); void lua_pushlstring (const char *s, long len);
void lua_pushstring (char *s); void lua_pushstring (const char *s);
void lua_pushcclosure (lua_CFunction fn, int n); void lua_pushcclosure (lua_CFunction fn, int n);
void lua_pushusertag (void *u, int tag); void lua_pushusertag (void *u, int tag);
void lua_pushobject (lua_Object object); void lua_pushobject (lua_Object object);
lua_Object lua_pop (void); lua_Object lua_pop (void);
lua_Object lua_getglobal (char *name); lua_Object lua_getglobal (const char *name);
lua_Object lua_rawgetglobal (char *name); lua_Object lua_rawgetglobal (const char *name);
void lua_setglobal (char *name); /* In: value */ void lua_setglobal (const char *name); /* In: value */
void lua_rawsetglobal (char *name); /* In: value */ void lua_rawsetglobal (const char *name); /* In: value */
void lua_settable (void); /* In: table, index, value */ void lua_settable (void); /* In: table, index, value */
void lua_rawsettable (void); /* In: table, index, value */ void lua_rawsettable (void); /* In: table, index, value */

View file

@ -14,12 +14,12 @@
typedef lua_Object lua_Function; typedef lua_Object lua_Function;
typedef void (*lua_LHFunction) (int line); typedef void (*lua_LHFunction) (int line);
typedef void (*lua_CHFunction) (lua_Function func, char *file, int line); typedef void (*lua_CHFunction) (lua_Function func, const char *file, int line);
lua_Function lua_stackedfunction (int level); lua_Function lua_stackedfunction (int level);
void lua_funcinfo (lua_Object func, char **filename, int *linedefined); void lua_funcinfo (lua_Object func, const char **filename, int *linedefined);
int lua_currentline (lua_Function func); int lua_currentline (lua_Function func);
char *lua_getobjname (lua_Object o, char **name); const char *lua_getobjname (lua_Object o, const char **name);
lua_Object lua_getlocal (lua_Function func, int local_number, char **name); lua_Object lua_getlocal (lua_Function func, int local_number, char **name);
int lua_setlocal (lua_Function func, int local_number); int lua_setlocal (lua_Function func, int local_number);

View file

@ -28,7 +28,7 @@ void lua_mathlibopen (void);
/* Auxiliary functions (private) */ /* Auxiliary functions (private) */
int luaI_singlematch (int c, char *p, char **ep); int luaI_singlematch (int c, const char *p, const char **ep);
#endif #endif

View file

@ -181,7 +181,7 @@ static TProtoFunc* LoadFunction(ZIO* Z)
static void LoadSignature(ZIO* Z) static void LoadSignature(ZIO* Z)
{ {
char* s=SIGNATURE; const char* s=SIGNATURE;
while (*s!=0 && ezgetc(Z)==*s) while (*s!=0 && ezgetc(Z)==*s)
++s; ++s;
if (*s!=0) luaL_verror("bad signature in %s",zname(Z)); if (*s!=0) luaL_verror("bad signature in %s",zname(Z));

View file

@ -206,7 +206,7 @@ void luaV_setglobal (TaggedString *ts)
} }
static void call_binTM (IMS event, char *msg) static void call_binTM (IMS event, const char *msg)
{ {
TObject *im = luaT_getimbyObj(L->stack.top-2, event);/* try first operand */ TObject *im = luaT_getimbyObj(L->stack.top-2, event);/* try first operand */
if (ttype(im) == LUA_T_NIL) { if (ttype(im) == LUA_T_NIL) {

View file

@ -20,11 +20,11 @@ static int zmfilbuf (ZIO* /*z*/)
return EOZ; return EOZ;
} }
ZIO* zmopen (ZIO* z, char* b, int size, char *name) ZIO* zmopen (ZIO* z, const char* b, int size, const char *name)
{ {
if (b==NULL) return NULL; if (b==NULL) return NULL;
z->n=size; z->n=size;
z->p= (unsigned char *)b; z->p= (const unsigned char *)b;
z->filbuf=zmfilbuf; z->filbuf=zmfilbuf;
z->u=NULL; z->u=NULL;
z->name=name; z->name=name;
@ -33,7 +33,7 @@ ZIO* zmopen (ZIO* z, char* b, int size, char *name)
/* ------------------------------------------------------------ strings --- */ /* ------------------------------------------------------------ strings --- */
ZIO* zsopen (ZIO* z, char* s, char *name) ZIO* zsopen (ZIO* z, const char* s, const char *name)
{ {
if (s==NULL) return NULL; if (s==NULL) return NULL;
return zmopen(z,s,strlen(s),name); return zmopen(z,s,strlen(s),name);
@ -51,7 +51,7 @@ static int zffilbuf (ZIO* z)
} }
ZIO* zFopen (ZIO* z, FILE* f, char *name) ZIO* zFopen (ZIO* z, FILE* f, const char *name)
{ {
if (f==NULL) return NULL; if (f==NULL) return NULL;
z->n=0; z->n=0;

View file

@ -22,9 +22,9 @@
typedef struct zio ZIO; typedef struct zio ZIO;
ZIO* zFopen (ZIO* z, FILE* f, char *name); /* open FILEs */ ZIO* zFopen (ZIO* z, FILE* f, const char *name); /* open FILEs */
ZIO* zsopen (ZIO* z, char* s, char *name); /* string */ ZIO* zsopen (ZIO* z, const char* s, const char *name); /* string */
ZIO* zmopen (ZIO* z, char* b, int size, char *name); /* memory */ ZIO* zmopen (ZIO* z, const char* b, int size, const char *name); /* memory */
int zread (ZIO* z, void* b, int n); /* read next n bytes */ int zread (ZIO* z, void* b, int n); /* read next n bytes */
@ -39,10 +39,10 @@ int zread (ZIO* z, void* b, int n); /* read next n bytes */
struct zio { struct zio {
int n; /* bytes still unread */ int n; /* bytes still unread */
unsigned char* p; /* current position in buffer */ const unsigned char* p; /* current position in buffer */
int (*filbuf)(ZIO* z); int (*filbuf)(ZIO* z);
void* u; /* additional data */ void* u; /* additional data */
char *name; const char *name;
unsigned char buffer[ZBSIZE]; /* buffer */ unsigned char buffer[ZBSIZE]; /* buffer */
}; };

View file

@ -31,7 +31,7 @@
#define SAVEGAME_VERSION 2 #define SAVEGAME_VERSION 2
// Constructor. Should create/open a saved game // Constructor. Should create/open a saved game
SaveGame::SaveGame(char *filename, bool saving) : SaveGame::SaveGame(const char *filename, bool saving) :
_saving(saving), _currentSection(0) { _saving(saving), _currentSection(0) {
if (_saving) { if (_saving) {
uint32 tag = SAVEGAME_HEADERTAG; uint32 tag = SAVEGAME_HEADERTAG;
@ -99,6 +99,7 @@ void SaveGame::endSection() {
} }
delete[] _sectionBuffer; delete[] _sectionBuffer;
_sectionBuffer = NULL; _sectionBuffer = NULL;
_currentSection = 0;
} }
void SaveGame::read(void *data, int size) { void SaveGame::read(void *data, int size) {
@ -110,7 +111,7 @@ void SaveGame::read(void *data, int size) {
_sectionPtr += size; _sectionPtr += size;
} }
void SaveGame::write(void *data, int size) { void SaveGame::write(const void *data, int size) {
if (!_saving) if (!_saving)
error("SaveGame::writeBlock called when restoring a savegame!"); error("SaveGame::writeBlock called when restoring a savegame!");
if (_currentSection == 0) if (_currentSection == 0)

View file

@ -38,13 +38,13 @@
class SaveGame { class SaveGame {
public: public:
SaveGame(char *filename, bool saving); SaveGame(const char *filename, bool saving);
~SaveGame(); ~SaveGame();
uint32 beginSection(uint32 sectionTag); uint32 beginSection(uint32 sectionTag);
void endSection(); void endSection();
void read(void *data, int size); void read(void *data, int size);
void write(void *data, int size); void write(const void *data, int size);
protected: protected:
bool _saving; bool _saving;

View file

@ -3,7 +3,7 @@
#include "engine/tinygl/zgl.h" #include "engine/tinygl/zgl.h"
void gl_fatal_error(char *format, ...) { void gl_fatal_error(const char *format, ...) {
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);

View file

@ -1,7 +1,7 @@
#include "engine/tinygl/zgl.h" #include "engine/tinygl/zgl.h"
static char *op_table_str[] = { static const char *op_table_str[] = {
#define ADD_OP(a, b, c) "gl" #a " " #c, #define ADD_OP(a, b, c) "gl" #a " " #c,
#include "engine/tinygl/opinfo.h" #include "engine/tinygl/opinfo.h"
@ -64,7 +64,7 @@ static GLList *alloc_list(GLContext *c, int list) {
void gl_print_op(FILE *f, TGLParam *p) { void gl_print_op(FILE *f, TGLParam *p) {
int op; int op;
char *s; const char *s;
op = p[0].op; op = p[0].op;
p++; p++;

View file

@ -321,7 +321,7 @@ void gl_resizeImageNoInterpolate(unsigned char *dest, int xsize_dest, int ysize_
GLContext *gl_get_context(void); GLContext *gl_get_context(void);
void gl_fatal_error(char *format, ...); void gl_fatal_error(const char *format, ...);
// specular buffer "api" // specular buffer "api"
GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, const float shininess); GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, const float shininess);

View file

@ -43,8 +43,8 @@ public:
void setVisible(bool visible); void setVisible(bool visible);
const char *name() const { return _name.c_str(); } const char *name() const { return _name.c_str(); }
const int id() const { return _id; } int id() const { return _id; }
const int type() const { return _type; } // FIXME: Implement type de-masking int type() const { return _type; } // FIXME: Implement type de-masking
bool visible() const { return _visible; } bool visible() const { return _visible; }
bool isPointInSector(Vector3d point) const; bool isPointInSector(Vector3d point) const;

View file

@ -1,5 +1,5 @@
/* XPM */ /* XPM */
static char * residual_icon[] = { static const char * residual_icon[] = {
"32 32 84 1", "32 32 84 1",
" c None", " c None",
". c #000100", ". c #000100",